blob: f4c704209714a34a9dcae1c1052be1c89ee9d36a [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;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800294 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530295
296 if (req->channel.half_rate)
297 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
298 else if (req->channel.quarter_rate)
299 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
300
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800301 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
302
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530303 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530304 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530305 cmd->disable_hw_ack = req->disable_hw_ack;
306 }
307
Krishna Rao0b952ea2017-03-20 13:30:10 +0530308 if (req->channel.dfs_set_cfreq2)
309 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
310
Kai Chen4710d462017-12-15 14:06:06 -0800311 /* According to firmware both reg power and max tx power
312 * on set channel power is used and set it to max reg
313 * power from regulatory.
314 */
315 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
316 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530317 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800318 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
319 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
320 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530321
322}
323#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530324/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530325 * send_vdev_start_cmd_tlv() - send vdev start request to fw
326 * @wmi_handle: wmi handle
327 * @req: vdev start params
328 *
329 * Return: QDF status
330 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530331static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530332 struct vdev_start_params *req)
333{
334 wmi_vdev_start_request_cmd_fixed_param *cmd;
335 wmi_buf_t buf;
336 wmi_channel *chan;
337 int32_t len, ret;
338 uint8_t *buf_ptr;
339
340 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
341 buf = wmi_buf_alloc(wmi_handle, len);
342 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530343 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530344 return QDF_STATUS_E_NOMEM;
345 }
346 buf_ptr = (uint8_t *) wmi_buf_data(buf);
347 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
348 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
349 WMITLV_SET_HDR(&cmd->tlv_header,
350 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
351 WMITLV_GET_STRUCT_TLVLEN
352 (wmi_vdev_start_request_cmd_fixed_param));
353 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
354 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
355 cmd->vdev_id = req->vdev_id;
356
357 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530358 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530359
360 cmd->beacon_interval = req->beacon_intval;
361 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530362
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800363 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
364 if (req->bcn_tx_rate_code)
365 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
366
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530367 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530368 cmd->beacon_interval = req->beacon_intval;
369 cmd->dtim_period = req->dtim_period;
370
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530371 /* Copy the SSID */
372 if (req->ssid.length) {
373 if (req->ssid.length < sizeof(cmd->ssid.ssid))
374 cmd->ssid.ssid_len = req->ssid.length;
375 else
376 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
377 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
378 cmd->ssid.ssid_len);
379 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530380
381 if (req->hidden_ssid)
382 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
383
384 if (req->pmf_enabled)
385 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530386 }
387
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700388 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530389 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530390 cmd->preferred_rx_streams = req->preferred_rx_streams;
391 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700392 cmd->cac_duration_ms = req->cac_duration_ms;
393 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700394 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530395
396 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
397 sizeof(wmi_channel));
398 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
399 cmd->num_noa_descriptors *
400 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800401 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530402 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
403 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800404 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
405 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
406 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530407 req->is_dfs, req->beacon_intval, cmd->dtim_period,
408 chan->band_center_freq1, chan->band_center_freq2,
409 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700410 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700411 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800412 req->regdomain, req->he_ops,
413 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530414
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530415 if (req->is_restart)
416 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
417 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530418 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530419 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
420 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530421 if (ret) {
422 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530423 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530424 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530425 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530426
427 return QDF_STATUS_SUCCESS;
428}
429
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530430/**
431 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
432 * @wmi_handle: wmi handle
433 * @restart_params: vdev restart params
434 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530435 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530436 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530437static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530438 struct hidden_ssid_vdev_restart_params *restart_params)
439{
440 wmi_vdev_start_request_cmd_fixed_param *cmd;
441 wmi_buf_t buf;
442 wmi_channel *chan;
443 int32_t len;
444 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530445 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530446
447 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
448 buf = wmi_buf_alloc(wmi_handle, len);
449 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530450 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530451 return QDF_STATUS_E_NOMEM;
452 }
453 buf_ptr = (uint8_t *) wmi_buf_data(buf);
454 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
455 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
456
457 WMITLV_SET_HDR(&cmd->tlv_header,
458 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
459 WMITLV_GET_STRUCT_TLVLEN
460 (wmi_vdev_start_request_cmd_fixed_param));
461
462 WMITLV_SET_HDR(&chan->tlv_header,
463 WMITLV_TAG_STRUC_wmi_channel,
464 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
465
466 cmd->vdev_id = restart_params->session_id;
467 cmd->ssid.ssid_len = restart_params->ssid_len;
468 qdf_mem_copy(cmd->ssid.ssid,
469 restart_params->ssid,
470 cmd->ssid.ssid_len);
471 cmd->flags = restart_params->flags;
472 cmd->requestor_id = restart_params->requestor_id;
473 cmd->disable_hw_ack = restart_params->disable_hw_ack;
474
475 chan->mhz = restart_params->mhz;
476 chan->band_center_freq1 =
477 restart_params->band_center_freq1;
478 chan->band_center_freq2 =
479 restart_params->band_center_freq2;
480 chan->info = restart_params->info;
481 chan->reg_info_1 = restart_params->reg_info_1;
482 chan->reg_info_2 = restart_params->reg_info_2;
483
484 cmd->num_noa_descriptors = 0;
485 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
486 sizeof(wmi_channel));
487 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
488 cmd->num_noa_descriptors *
489 sizeof(wmi_p2p_noa_descriptor));
490
491 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
492 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530493 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530494 wmi_buf_free(buf);
495 return QDF_STATUS_E_FAILURE;
496 }
497 return QDF_STATUS_SUCCESS;
498}
499
500
501/**
Govind Singh5eb51532016-03-09 11:34:12 +0530502 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
503 * @wmi: wmi handle
504 * @peer_addr: peer mac address
505 * @param: pointer to hold peer flush tid parameter
506 *
507 * Return: 0 for sucess or error code
508 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530509static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530510 uint8_t peer_addr[IEEE80211_ADDR_LEN],
511 struct peer_flush_params *param)
512{
513 wmi_peer_flush_tids_cmd_fixed_param *cmd;
514 wmi_buf_t buf;
515 int32_t len = sizeof(*cmd);
516
517 buf = wmi_buf_alloc(wmi, len);
518 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530519 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530520 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530521 }
522 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
523 WMITLV_SET_HDR(&cmd->tlv_header,
524 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
525 WMITLV_GET_STRUCT_TLVLEN
526 (wmi_peer_flush_tids_cmd_fixed_param));
527 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
528 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
529 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530530 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530531 peer_addr, param->vdev_id,
532 param->peer_tid_bitmap);
533 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530534 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530535 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530536 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530537 }
538
539 return 0;
540}
541
542/**
543 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
544 * @wmi: wmi handle
545 * @peer_addr: peer mac addr
546 * @vdev_id: vdev id
547 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530548 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530549 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530550static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530551 uint8_t peer_addr[IEEE80211_ADDR_LEN],
552 uint8_t vdev_id)
553{
554 wmi_peer_delete_cmd_fixed_param *cmd;
555 wmi_buf_t buf;
556 int32_t len = sizeof(*cmd);
557 buf = wmi_buf_alloc(wmi, len);
558 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530559 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530560 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530561 }
562 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
563 WMITLV_SET_HDR(&cmd->tlv_header,
564 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
565 WMITLV_GET_STRUCT_TLVLEN
566 (wmi_peer_delete_cmd_fixed_param));
567 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
568 cmd->vdev_id = vdev_id;
569
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800570 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530571 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530572 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530573 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530574 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530575 }
Govind Singh5eb51532016-03-09 11:34:12 +0530576
577 return 0;
578}
579
580/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530581 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
582 * to target id.
583 * @targ_paramid: Target parameter id to hold the result.
584 * @peer_param_id: host param id.
585 *
586 * Return: QDF_STATUS_SUCCESS for success
587 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
588 */
589#ifdef CONFIG_MCL
590static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
591 uint32_t *targ_paramid,
592 uint32_t peer_param_id)
593{
594 *targ_paramid = peer_param_id;
595 return QDF_STATUS_SUCCESS;
596}
597#else
598static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
599 uint32_t *targ_paramid,
600 uint32_t peer_param_id)
601{
602 switch (peer_param_id) {
603 case WMI_HOST_PEER_MIMO_PS_STATE:
604 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
605 break;
606 case WMI_HOST_PEER_AMPDU:
607 *targ_paramid = WMI_PEER_AMPDU;
608 break;
609 case WMI_HOST_PEER_AUTHORIZE:
610 *targ_paramid = WMI_PEER_AUTHORIZE;
611 break;
612 case WMI_HOST_PEER_CHWIDTH:
613 *targ_paramid = WMI_PEER_CHWIDTH;
614 break;
615 case WMI_HOST_PEER_NSS:
616 *targ_paramid = WMI_PEER_NSS;
617 break;
618 case WMI_HOST_PEER_USE_4ADDR:
619 *targ_paramid = WMI_PEER_USE_4ADDR;
620 break;
621 case WMI_HOST_PEER_MEMBERSHIP:
622 *targ_paramid = WMI_PEER_MEMBERSHIP;
623 break;
624 case WMI_HOST_PEER_USERPOS:
625 *targ_paramid = WMI_PEER_USERPOS;
626 break;
627 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
628 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
629 break;
630 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
631 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
632 break;
633 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
634 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
635 break;
636 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
637 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
638 break;
639 case WMI_HOST_PEER_PHYMODE:
640 *targ_paramid = WMI_PEER_PHYMODE;
641 break;
642 case WMI_HOST_PEER_USE_FIXED_PWR:
643 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
644 break;
645 case WMI_HOST_PEER_PARAM_FIXED_RATE:
646 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
647 break;
648 case WMI_HOST_PEER_SET_MU_WHITELIST:
649 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
650 break;
651 case WMI_HOST_PEER_SET_MAC_TX_RATE:
652 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
653 break;
654 case WMI_HOST_PEER_SET_MIN_TX_RATE:
655 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
656 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530657 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
658 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
659 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530660 case WMI_HOST_PEER_NSS_VHT160:
661 *targ_paramid = WMI_PEER_NSS_VHT160;
662 break;
663 case WMI_HOST_PEER_NSS_VHT80_80:
664 *targ_paramid = WMI_PEER_NSS_VHT80_80;
665 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530666 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
667 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
668 break;
669 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
670 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
671 break;
672 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
673 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
674 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530675 case WMI_HOST_PEER_PARAM_MU_ENABLE:
676 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
677 break;
678 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
679 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
680 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530681 default:
682 return QDF_STATUS_E_NOSUPPORT;
683 }
684
685 return QDF_STATUS_SUCCESS;
686}
687#endif
688/**
Govind Singh5eb51532016-03-09 11:34:12 +0530689 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530690 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530691 * @peer_addr: peer mac address
692 * @param : pointer to hold peer set parameter
693 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530694 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530695 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530696static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530697 uint8_t peer_addr[IEEE80211_ADDR_LEN],
698 struct peer_set_params *param)
699{
700 wmi_peer_set_param_cmd_fixed_param *cmd;
701 wmi_buf_t buf;
702 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530703 uint32_t param_id;
704
705 if (convert_host_peer_id_to_target_id_tlv(&param_id,
706 param->param_id) != QDF_STATUS_SUCCESS)
707 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530708
709 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
710 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530711 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530712 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530713 }
714 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
715 WMITLV_SET_HDR(&cmd->tlv_header,
716 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
717 WMITLV_GET_STRUCT_TLVLEN
718 (wmi_peer_set_param_cmd_fixed_param));
719 cmd->vdev_id = param->vdev_id;
720 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530721 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530722 cmd->param_value = param->param_value;
723 err = wmi_unified_cmd_send(wmi, buf,
724 sizeof(wmi_peer_set_param_cmd_fixed_param),
725 WMI_PEER_SET_PARAM_CMDID);
726 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530727 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530728 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530729 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530730 }
731
732 return 0;
733}
734
735/**
736 * send_vdev_up_cmd_tlv() - send vdev up command in fw
737 * @wmi: wmi handle
738 * @bssid: bssid
739 * @vdev_up_params: pointer to hold vdev up parameter
740 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530741 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530742 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530743static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530744 uint8_t bssid[IEEE80211_ADDR_LEN],
745 struct vdev_up_params *params)
746{
747 wmi_vdev_up_cmd_fixed_param *cmd;
748 wmi_buf_t buf;
749 int32_t len = sizeof(*cmd);
750
Govind Singhb53420c2016-03-09 14:32:57 +0530751 WMI_LOGD("%s: VDEV_UP", __func__);
752 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530753 params->vdev_id, params->assoc_id, bssid);
754 buf = wmi_buf_alloc(wmi, len);
755 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530756 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530757 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530758 }
759 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
760 WMITLV_SET_HDR(&cmd->tlv_header,
761 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
762 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
763 cmd->vdev_id = params->vdev_id;
764 cmd->vdev_assoc_id = params->assoc_id;
765 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
766 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530767 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530768 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530769 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530770 }
771
772 return 0;
773}
774
775/**
776 * send_peer_create_cmd_tlv() - send peer create command to fw
777 * @wmi: wmi handle
778 * @peer_addr: peer mac address
779 * @peer_type: peer type
780 * @vdev_id: vdev id
781 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530782 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530783 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530784static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530785 struct peer_create_params *param)
786{
787 wmi_peer_create_cmd_fixed_param *cmd;
788 wmi_buf_t buf;
789 int32_t len = sizeof(*cmd);
790
791 buf = wmi_buf_alloc(wmi, len);
792 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530793 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530794 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530795 }
796 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
797 WMITLV_SET_HDR(&cmd->tlv_header,
798 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
799 WMITLV_GET_STRUCT_TLVLEN
800 (wmi_peer_create_cmd_fixed_param));
801 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
802 cmd->peer_type = param->peer_type;
803 cmd->vdev_id = param->vdev_id;
804
805 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530806 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530807 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530808 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530809 }
Govind Singhb53420c2016-03-09 14:32:57 +0530810 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530811 param->vdev_id);
812
813 return 0;
814}
815
816/**
Leo Changeee40872016-09-28 13:43:36 -0700817 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
818 * command to fw
819 * @wmi: wmi handle
820 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
821 *
822 * Return: 0 for success or error code
823 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700824static
Leo Changeee40872016-09-28 13:43:36 -0700825QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
826 struct rx_reorder_queue_setup_params *param)
827{
828 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
829 wmi_buf_t buf;
830 int32_t len = sizeof(*cmd);
831
832 buf = wmi_buf_alloc(wmi, len);
833 if (!buf) {
834 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
835 return QDF_STATUS_E_NOMEM;
836 }
837 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
838 WMITLV_SET_HDR(&cmd->tlv_header,
839 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
840 WMITLV_GET_STRUCT_TLVLEN
841 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
842 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
843 cmd->vdev_id = param->vdev_id;
844 cmd->tid = param->tid;
845 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
846 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
847 cmd->queue_no = param->queue_no;
848
849 if (wmi_unified_cmd_send(wmi, buf, len,
850 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
851 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
852 __func__);
853 qdf_nbuf_free(buf);
854 return QDF_STATUS_E_FAILURE;
855 }
856 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
857 param->peer_macaddr, param->vdev_id, param->tid);
858
859 return QDF_STATUS_SUCCESS;
860}
861
862/**
863 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
864 * command to fw
865 * @wmi: wmi handle
866 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
867 *
868 * Return: 0 for success or error code
869 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700870static
Leo Changeee40872016-09-28 13:43:36 -0700871QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
872 struct rx_reorder_queue_remove_params *param)
873{
874 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
875 wmi_buf_t buf;
876 int32_t len = sizeof(*cmd);
877
878 buf = wmi_buf_alloc(wmi, len);
879 if (!buf) {
880 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
881 return QDF_STATUS_E_NOMEM;
882 }
883 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
884 wmi_buf_data(buf);
885 WMITLV_SET_HDR(&cmd->tlv_header,
886 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
887 WMITLV_GET_STRUCT_TLVLEN
888 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
889 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
890 cmd->vdev_id = param->vdev_id;
891 cmd->tid_mask = param->peer_tid_bitmap;
892
893 if (wmi_unified_cmd_send(wmi, buf, len,
894 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
895 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
896 __func__);
897 qdf_nbuf_free(buf);
898 return QDF_STATUS_E_FAILURE;
899 }
900 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
901 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
902
903 return QDF_STATUS_SUCCESS;
904}
905
906/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530907 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
908 * @wmi_handle: wmi handle
909 * @param: pointer holding peer details
910 *
911 * Return: 0 for success or error code
912 */
913static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
914 struct peer_add_wds_entry_params *param)
915{
916 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
917 wmi_buf_t buf;
918 int len = sizeof(*cmd);
919
920 buf = wmi_buf_alloc(wmi_handle, len);
921 if (!buf) {
922 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
923 return QDF_STATUS_E_FAILURE;
924 }
925 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
926 WMITLV_SET_HDR(&cmd->tlv_header,
927 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
928 WMITLV_GET_STRUCT_TLVLEN
929 (wmi_peer_add_wds_entry_cmd_fixed_param));
930 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
931 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800932 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
933 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530934
935 return wmi_unified_cmd_send(wmi_handle, buf, len,
936 WMI_PEER_ADD_WDS_ENTRY_CMDID);
937}
938
939/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530940 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530941 * @wmi_handle: wmi handle
942 * @param: pointer holding peer details
943 *
944 * Return: 0 for success or error code
945 */
946static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
947 struct peer_del_wds_entry_params *param)
948{
949 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
950 wmi_buf_t buf;
951 int len = sizeof(*cmd);
952
953 buf = wmi_buf_alloc(wmi_handle, len);
954 if (!buf) {
955 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
956 return QDF_STATUS_E_NOMEM;
957 }
958 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
959 WMITLV_SET_HDR(&cmd->tlv_header,
960 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
961 WMITLV_GET_STRUCT_TLVLEN
962 (wmi_peer_remove_wds_entry_cmd_fixed_param));
963 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800964 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530965 return wmi_unified_cmd_send(wmi_handle, buf, len,
966 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
967}
968
969/**
970 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
971 * @wmi_handle: wmi handle
972 * @param: pointer holding peer details
973 *
974 * Return: 0 for success or error code
975 */
976static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
977 struct peer_update_wds_entry_params *param)
978{
979 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
980 wmi_buf_t buf;
981 int len = sizeof(*cmd);
982
983 buf = wmi_buf_alloc(wmi_handle, len);
984 if (!buf) {
985 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
986 return QDF_STATUS_E_NOMEM;
987 }
988
989 /* wmi_buf_alloc returns zeroed command buffer */
990 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
991 WMITLV_SET_HDR(&cmd->tlv_header,
992 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
993 WMITLV_GET_STRUCT_TLVLEN
994 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800995 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
996 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530997 if (param->wds_macaddr)
998 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
999 &cmd->wds_macaddr);
1000 if (param->peer_macaddr)
1001 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1002 &cmd->peer_macaddr);
1003 return wmi_unified_cmd_send(wmi_handle, buf, len,
1004 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1005}
1006
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001007/**
1008 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1009 * @wmi_handle: wmi handle
1010 * @param: pointer to get tpc config params
1011 *
1012 * Return: 0 for success or error code
1013 */
1014static QDF_STATUS
1015send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1016 uint32_t param)
1017{
1018 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1019 wmi_buf_t buf;
1020 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1021
1022 buf = wmi_buf_alloc(wmi_handle, len);
1023 if (!buf) {
1024 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1025 return QDF_STATUS_E_NOMEM;
1026 }
1027 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1028 WMITLV_SET_HDR(&cmd->tlv_header,
1029 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1030 WMITLV_GET_STRUCT_TLVLEN
1031 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1032
1033 cmd->param = param;
1034 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1035 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1036 WMI_LOGE("Send pdev get tpc config cmd failed");
1037 wmi_buf_free(buf);
1038 return QDF_STATUS_E_FAILURE;
1039
1040 }
1041 WMI_LOGD("%s:send success", __func__);
1042
1043 return QDF_STATUS_SUCCESS;
1044}
1045
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301046#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301047/**
Govind Singh5eb51532016-03-09 11:34:12 +05301048 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1049 * @wmi_handle: wmi handle
1050 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301051 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301052 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301053 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301054 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301055static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301056 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301057{
1058 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1059 wmi_buf_t buf;
1060 int32_t len = sizeof(*cmd);
1061
Govind Singhb53420c2016-03-09 14:32:57 +05301062 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301063
1064 buf = wmi_buf_alloc(wmi_handle, len);
1065 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301066 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301067 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301068 }
1069
1070 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1071 WMITLV_SET_HDR(&cmd->tlv_header,
1072 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1073 WMITLV_GET_STRUCT_TLVLEN
1074 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301075 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301076 cmd->enable = value;
1077
1078 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1079 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301080 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301081 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301082 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301083 }
1084
1085 return 0;
1086}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301087#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301088
1089/**
1090 * send_pdev_utf_cmd_tlv() - send utf command to fw
1091 * @wmi_handle: wmi handle
1092 * @param: pointer to pdev_utf_params
1093 * @mac_id: mac id to have radio context
1094 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301095 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301096 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301097static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301098send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1099 struct pdev_utf_params *param,
1100 uint8_t mac_id)
1101{
1102 wmi_buf_t buf;
1103 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001104 /* if param->len is 0 no data is sent, return error */
1105 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301106 static uint8_t msgref = 1;
1107 uint8_t segNumber = 0, segInfo, numSegments;
1108 uint16_t chunk_len, total_bytes;
1109 uint8_t *bufpos;
1110 struct seg_hdr_info segHdrInfo;
1111
1112 bufpos = param->utf_payload;
1113 total_bytes = param->len;
1114 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1115 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1116 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1117
1118 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1119 numSegments++;
1120
1121 while (param->len) {
1122 if (param->len > MAX_WMI_UTF_LEN)
1123 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1124 else
1125 chunk_len = param->len;
1126
1127 buf = wmi_buf_alloc(wmi_handle,
1128 (chunk_len + sizeof(segHdrInfo) +
1129 WMI_TLV_HDR_SIZE));
1130 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301131 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301132 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301133 }
1134
1135 cmd = (uint8_t *) wmi_buf_data(buf);
1136
1137 segHdrInfo.len = total_bytes;
1138 segHdrInfo.msgref = msgref;
1139 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1140 segHdrInfo.segmentInfo = segInfo;
1141 segHdrInfo.pad = 0;
1142
Govind Singhb53420c2016-03-09 14:32:57 +05301143 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301144 " segHdrInfo.segmentInfo = %d",
1145 __func__, segHdrInfo.len, segHdrInfo.msgref,
1146 segHdrInfo.segmentInfo);
1147
Govind Singhb53420c2016-03-09 14:32:57 +05301148 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301149 "chunk len %d", __func__, total_bytes, segNumber,
1150 numSegments, chunk_len);
1151
1152 segNumber++;
1153
1154 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1155 (chunk_len + sizeof(segHdrInfo)));
1156 cmd += WMI_TLV_HDR_SIZE;
1157 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1158 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1159
1160 ret = wmi_unified_cmd_send(wmi_handle, buf,
1161 (chunk_len + sizeof(segHdrInfo) +
1162 WMI_TLV_HDR_SIZE),
1163 WMI_PDEV_UTF_CMDID);
1164
Govind Singh67922e82016-04-01 16:48:57 +05301165 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301166 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301167 wmi_buf_free(buf);
1168 break;
1169 }
1170
1171 param->len -= chunk_len;
1172 bufpos += chunk_len;
1173 }
1174
1175 msgref++;
1176
1177 return ret;
1178}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301179#ifdef CONFIG_MCL
1180static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1181 uint32_t host_param)
1182{
1183 return host_param;
1184}
1185#else
1186static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1187 uint32_t host_param)
1188{
1189 if (host_param < wmi_pdev_param_max)
1190 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301191
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301192 return WMI_UNAVAILABLE_PARAM;
1193}
1194#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301195/**
1196 * send_pdev_param_cmd_tlv() - set pdev parameters
1197 * @wmi_handle: wmi handle
1198 * @param: pointer to pdev parameter
1199 * @mac_id: radio context
1200 *
1201 * Return: 0 on success, errno on failure
1202 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301203static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301204send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1205 struct pdev_params *param,
1206 uint8_t mac_id)
1207{
Govind Singh67922e82016-04-01 16:48:57 +05301208 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301209 wmi_pdev_set_param_cmd_fixed_param *cmd;
1210 wmi_buf_t buf;
1211 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301212 uint32_t pdev_param;
1213
1214 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1215 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1216 WMI_LOGW("%s: Unavailable param %d\n",
1217 __func__, param->param_id);
1218 return QDF_STATUS_E_INVAL;
1219 }
Govind Singh5eb51532016-03-09 11:34:12 +05301220
1221 buf = wmi_buf_alloc(wmi_handle, len);
1222 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301223 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301224 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301225 }
1226 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1227 WMITLV_SET_HDR(&cmd->tlv_header,
1228 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1229 WMITLV_GET_STRUCT_TLVLEN
1230 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301231 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301232 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301233 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301234 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301235 param->param_value);
1236 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1237 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301238 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301239 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301240 wmi_buf_free(buf);
1241 }
1242 return ret;
1243}
1244
1245/**
1246 * send_suspend_cmd_tlv() - WMI suspend function
1247 * @param wmi_handle : handle to WMI.
1248 * @param param : pointer to hold suspend parameter
1249 * @mac_id: radio context
1250 *
1251 * Return 0 on success and -ve on failure.
1252 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301253static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301254 struct suspend_params *param,
1255 uint8_t mac_id)
1256{
1257 wmi_pdev_suspend_cmd_fixed_param *cmd;
1258 wmi_buf_t wmibuf;
1259 uint32_t len = sizeof(*cmd);
1260 int32_t ret;
1261
1262 /*
1263 * send the comand to Target to ignore the
1264 * PCIE reset so as to ensure that Host and target
1265 * states are in sync
1266 */
1267 wmibuf = wmi_buf_alloc(wmi_handle, len);
1268 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301269 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301270
1271 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1272 WMITLV_SET_HDR(&cmd->tlv_header,
1273 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1274 WMITLV_GET_STRUCT_TLVLEN
1275 (wmi_pdev_suspend_cmd_fixed_param));
1276 if (param->disable_target_intr)
1277 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1278 else
1279 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301280
1281 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1282
Govind Singh5eb51532016-03-09 11:34:12 +05301283 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1284 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301285 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301286 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301287 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301288 }
1289
1290 return ret;
1291}
1292
1293/**
1294 * send_resume_cmd_tlv() - WMI resume function
1295 * @param wmi_handle : handle to WMI.
1296 * @mac_id: radio context
1297 *
1298 * Return: 0 on success and -ve on failure.
1299 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301300static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301301 uint8_t mac_id)
1302{
1303 wmi_buf_t wmibuf;
1304 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301305 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301306
1307 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1308 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301309 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301310 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1311 WMITLV_SET_HDR(&cmd->tlv_header,
1312 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1313 WMITLV_GET_STRUCT_TLVLEN
1314 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301315 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301316 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1317 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301318 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301319 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301320 wmi_buf_free(wmibuf);
1321 }
1322
1323 return ret;
1324}
1325
Will Huang422ac9a2017-11-17 13:19:16 +08001326#ifdef FEATURE_WLAN_D0WOW
1327/**
1328 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1329 * @param wmi_handle: handle to WMI.
1330 * @mac_id: radio context
1331 *
1332 * Return: 0 on success and error code on failure.
1333 */
1334static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1335 uint8_t mac_id)
1336{
1337 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1338 wmi_buf_t buf;
1339 int32_t len;
1340 QDF_STATUS status;
1341
1342 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1343
1344 buf = wmi_buf_alloc(wmi_handle, len);
1345 if (!buf) {
1346 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1347 return QDF_STATUS_E_NOMEM;
1348 }
1349 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1350 WMITLV_SET_HDR(&cmd->tlv_header,
1351 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1352 WMITLV_GET_STRUCT_TLVLEN
1353 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1354
1355 cmd->enable = true;
1356
1357 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1358 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1359 if (QDF_IS_STATUS_ERROR(status))
1360 wmi_buf_free(buf);
1361
1362 return status;
1363}
1364
1365/**
1366 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1367 * @param wmi_handle: handle to WMI.
1368 * @mac_id: radio context
1369 *
1370 * Return: 0 on success and error code on failure.
1371 */
1372static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1373 uint8_t mac_id)
1374{
1375 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1376 wmi_buf_t buf;
1377 int32_t len;
1378 QDF_STATUS status;
1379
1380 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1381
1382 buf = wmi_buf_alloc(wmi_handle, len);
1383 if (!buf) {
1384 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1385 return QDF_STATUS_E_NOMEM;
1386 }
1387 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1388 WMITLV_SET_HDR(&cmd->tlv_header,
1389 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1390 WMITLV_GET_STRUCT_TLVLEN
1391 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1392
1393 cmd->enable = false;
1394
1395 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1396 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1397 if (QDF_IS_STATUS_ERROR(status))
1398 wmi_buf_free(buf);
1399
1400 return status;
1401}
1402#endif
1403
Govind Singh5eb51532016-03-09 11:34:12 +05301404/**
1405 * send_wow_enable_cmd_tlv() - WMI wow enable function
1406 * @param wmi_handle : handle to WMI.
1407 * @param param : pointer to hold wow enable parameter
1408 * @mac_id: radio context
1409 *
1410 * Return: 0 on success and -ve on failure.
1411 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301412static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301413 struct wow_cmd_params *param,
1414 uint8_t mac_id)
1415{
1416 wmi_wow_enable_cmd_fixed_param *cmd;
1417 wmi_buf_t buf;
1418 int32_t len;
1419 int32_t ret;
1420
1421 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1422
1423 buf = wmi_buf_alloc(wmi_handle, len);
1424 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301425 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1426 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301427 }
1428 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1429 WMITLV_SET_HDR(&cmd->tlv_header,
1430 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1431 WMITLV_GET_STRUCT_TLVLEN
1432 (wmi_wow_enable_cmd_fixed_param));
1433 cmd->enable = param->enable;
1434 if (param->can_suspend_link)
1435 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1436 else
1437 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001438 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301439
Govind Singhb53420c2016-03-09 14:32:57 +05301440 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301441 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1442 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1443
1444 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1445 WMI_WOW_ENABLE_CMDID);
1446 if (ret)
1447 wmi_buf_free(buf);
1448
1449 return ret;
1450}
1451
1452/**
1453 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301454 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301455 * @peer_addr: peer mac address
1456 * @param: pointer to ap_ps parameter structure
1457 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301458 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301459 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301460static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301461 uint8_t *peer_addr,
1462 struct ap_ps_params *param)
1463{
1464 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1465 wmi_buf_t buf;
1466 int32_t err;
1467
1468 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1469 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301470 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301471 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301472 }
1473 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1474 WMITLV_SET_HDR(&cmd->tlv_header,
1475 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1476 WMITLV_GET_STRUCT_TLVLEN
1477 (wmi_ap_ps_peer_cmd_fixed_param));
1478 cmd->vdev_id = param->vdev_id;
1479 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1480 cmd->param = param->param;
1481 cmd->value = param->value;
1482 err = wmi_unified_cmd_send(wmi_handle, buf,
1483 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1484 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301485 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301486 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301487 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301488 }
1489
1490 return 0;
1491}
1492
1493/**
1494 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301495 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301496 * @peer_addr: peer mac address
1497 * @param: pointer to sta_ps parameter structure
1498 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301499 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301500 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301501static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301502 struct sta_ps_params *param)
1503{
1504 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1505 wmi_buf_t buf;
1506 int32_t len = sizeof(*cmd);
1507
1508 buf = wmi_buf_alloc(wmi_handle, len);
1509 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301510 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301511 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301512 }
1513
1514 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1515 WMITLV_SET_HDR(&cmd->tlv_header,
1516 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1517 WMITLV_GET_STRUCT_TLVLEN
1518 (wmi_sta_powersave_param_cmd_fixed_param));
1519 cmd->vdev_id = param->vdev_id;
1520 cmd->param = param->param;
1521 cmd->value = param->value;
1522
1523 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1524 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301525 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301526 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301527 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301528 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301529 }
1530
1531 return 0;
1532}
1533
1534/**
1535 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301536 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301537 * @param: ponirt to crash inject paramter structure
1538 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301539 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301540 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301541static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301542 struct crash_inject *param)
1543{
1544 int32_t ret = 0;
1545 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1546 uint16_t len = sizeof(*cmd);
1547 wmi_buf_t buf;
1548
1549 buf = wmi_buf_alloc(wmi_handle, len);
1550 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301551 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301552 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301553 }
1554
1555 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1556 WMITLV_SET_HDR(&cmd->tlv_header,
1557 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1558 WMITLV_GET_STRUCT_TLVLEN
1559 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1560 cmd->type = param->type;
1561 cmd->delay_time_ms = param->delay_time_ms;
1562
1563 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1564 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301565 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301566 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301567 __func__, ret);
1568 wmi_buf_free(buf);
1569 }
1570
1571 return ret;
1572}
1573
1574/**
1575 * send_dbglog_cmd_tlv() - set debug log level
1576 * @param wmi_handle : handle to WMI.
1577 * @param param : pointer to hold dbglog level parameter
1578 *
1579 * Return: 0 on success and -ve on failure.
1580 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301581 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301582send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1583 struct dbglog_params *dbglog_param)
1584{
1585 wmi_buf_t buf;
1586 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001587 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301588 int32_t i;
1589 int32_t len;
1590 int8_t *buf_ptr;
1591 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1592
Alok Kumar240afea2017-08-30 14:45:34 +05301593 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301594
1595 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1596 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1597 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1598 buf = wmi_buf_alloc(wmi_handle, len);
1599 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001600 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301601
1602 configmsg =
1603 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1604 buf_ptr = (int8_t *) configmsg;
1605 WMITLV_SET_HDR(&configmsg->tlv_header,
1606 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1607 WMITLV_GET_STRUCT_TLVLEN
1608 (wmi_debug_log_config_cmd_fixed_param));
1609 configmsg->dbg_log_param = dbglog_param->param;
1610 configmsg->value = dbglog_param->val;
1611 /* Filling in the data part of second tlv -- should
1612 * follow first tlv _ WMI_TLV_HDR_SIZE */
1613 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1614 sizeof
1615 (wmi_debug_log_config_cmd_fixed_param)
1616 + WMI_TLV_HDR_SIZE);
1617 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1618 WMITLV_TAG_ARRAY_UINT32,
1619 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1620 if (dbglog_param->module_id_bitmap) {
1621 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1622 module_id_bitmap_array[i] =
1623 dbglog_param->module_id_bitmap[i];
1624 }
1625 }
1626
1627 status = wmi_unified_cmd_send(wmi_handle, buf,
1628 len, WMI_DBGLOG_CFG_CMDID);
1629
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001630 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301631 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301632
1633 return status;
1634}
1635
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301636#ifdef CONFIG_MCL
1637static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1638 uint32_t host_param)
1639{
1640 return host_param;
1641}
1642#else
1643static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1644 uint32_t host_param)
1645{
1646 if (host_param < wmi_vdev_param_max)
1647 return wmi_handle->vdev_param[host_param];
1648
1649 return WMI_UNAVAILABLE_PARAM;
1650}
1651#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301652/**
1653 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1654 * @param wmi_handle : handle to WMI.
1655 * @param macaddr : MAC address
1656 * @param param : pointer to hold vdev set parameter
1657 *
1658 * Return: 0 on success and -ve on failure.
1659 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301660static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301661 struct vdev_set_params *param)
1662{
Govind Singh67922e82016-04-01 16:48:57 +05301663 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301664 wmi_vdev_set_param_cmd_fixed_param *cmd;
1665 wmi_buf_t buf;
1666 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301667 uint32_t vdev_param;
1668
1669 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1670 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1671 WMI_LOGW("%s:Vdev param %d not available", __func__,
1672 param->param_id);
1673 return QDF_STATUS_E_INVAL;
1674
1675 }
Govind Singh5eb51532016-03-09 11:34:12 +05301676
1677 buf = wmi_buf_alloc(wmi_handle, len);
1678 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301679 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301680 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301681 }
1682 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1683 WMITLV_SET_HDR(&cmd->tlv_header,
1684 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1685 WMITLV_GET_STRUCT_TLVLEN
1686 (wmi_vdev_set_param_cmd_fixed_param));
1687 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301688 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301689 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301690 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301691 param->if_id, param->param_id, param->param_value);
1692 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1693 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301694 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301695 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301696 wmi_buf_free(buf);
1697 }
1698
1699 return ret;
1700}
1701
1702/**
1703 * send_stats_request_cmd_tlv() - WMI request stats function
1704 * @param wmi_handle : handle to WMI.
1705 * @param macaddr : MAC address
1706 * @param param : pointer to hold stats request parameter
1707 *
1708 * Return: 0 on success and -ve on failure.
1709 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301710static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301711 uint8_t macaddr[IEEE80211_ADDR_LEN],
1712 struct stats_request_params *param)
1713{
Govind Singhd3156eb2016-02-26 17:50:39 +05301714 int32_t ret;
1715 wmi_request_stats_cmd_fixed_param *cmd;
1716 wmi_buf_t buf;
1717 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1718
1719 buf = wmi_buf_alloc(wmi_handle, len);
1720 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301721 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1722 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301723 }
1724
1725 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1726 WMITLV_SET_HDR(&cmd->tlv_header,
1727 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1728 WMITLV_GET_STRUCT_TLVLEN
1729 (wmi_request_stats_cmd_fixed_param));
1730 cmd->stats_id = param->stats_id;
1731 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301732 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1733 param->pdev_id);
1734 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001735
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301736 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1737 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001738
1739 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1740 WMI_REQUEST_STATS_CMDID);
1741
Govind Singhd3156eb2016-02-26 17:50:39 +05301742 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301743 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301744 wmi_buf_free(buf);
1745 }
1746
1747 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301748}
1749
Govind Singh87542482016-06-08 19:40:11 +05301750#ifdef CONFIG_WIN
1751/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001752 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301753 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001754 * @param PKTLOG_EVENT : packet log event
1755 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301756 *
1757 * Return: 0 on success and -ve on failure.
1758 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301759static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001760 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301761{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001762 int32_t ret;
1763 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1764 wmi_buf_t buf;
1765 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1766
1767 buf = wmi_buf_alloc(wmi_handle, len);
1768 if (!buf) {
1769 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1770 return -QDF_STATUS_E_NOMEM;
1771 }
1772
1773 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1774 WMITLV_SET_HDR(&cmd->tlv_header,
1775 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1776 WMITLV_GET_STRUCT_TLVLEN
1777 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1778 cmd->evlist = PKTLOG_EVENT;
1779 cmd->pdev_id = mac_id;
1780 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1781 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1782 if (ret) {
1783 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1784 wmi_buf_free(buf);
1785 }
1786
1787 return ret;
1788}
1789
1790/**
1791 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1792 * @param wmi_handle : handle to WMI.
1793 * @mac_id: mac id to have radio context
1794 *
1795 * Return: 0 on success and -ve on failure.
1796 */
1797static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001798 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001799{
1800 int32_t ret;
1801 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1802 wmi_buf_t buf;
1803 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1804
1805 buf = wmi_buf_alloc(wmi_handle, len);
1806 if (!buf) {
1807 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1808 return -QDF_STATUS_E_NOMEM;
1809 }
1810
1811 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1812 WMITLV_SET_HDR(&cmd->tlv_header,
1813 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1814 WMITLV_GET_STRUCT_TLVLEN
1815 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1816 cmd->pdev_id = mac_id;
1817 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1818 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1819 if (ret) {
1820 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1821 wmi_buf_free(buf);
1822 }
1823
1824 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301825}
1826#else
Govind Singh5eb51532016-03-09 11:34:12 +05301827/**
Keyur Parekhde522342017-08-18 14:01:05 -07001828 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1829 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301830 * @param wmi_handle : handle to WMI.
1831 * @param macaddr : MAC address
1832 * @param param : pointer to hold stats request parameter
1833 *
1834 * Return: 0 on success and -ve on failure.
1835 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301836static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301837 uint8_t macaddr[IEEE80211_ADDR_LEN],
1838 struct packet_enable_params *param)
1839{
1840 return 0;
1841}
Keyur Parekhde522342017-08-18 14:01:05 -07001842/**
1843 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1844 * packet-log
1845 * @param wmi_handle : handle to WMI.
1846 * @mac_id: mac id to have radio context
1847 *
1848 * Return: 0 on success and -ve on failure.
1849 */
1850static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1851 uint8_t mac_id)
1852{
1853 return 0;
1854}
Govind Singh87542482016-06-08 19:40:11 +05301855#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301856
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301857#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1858/**
1859 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1860 * sync time between bwtween host and firmware
1861 * @param wmi_handle : handle to WMI.
1862 *
1863 * Return: None
1864 */
1865static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1866{
1867 wmi_buf_t buf;
1868 A_STATUS status = A_OK;
1869 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1870 int32_t len;
1871 qdf_time_t time_ms;
1872
1873 len = sizeof(*time_stamp);
1874 buf = wmi_buf_alloc(wmi_handle, len);
1875
1876 if (!buf) {
1877 WMI_LOGP(FL("wmi_buf_alloc failed"));
1878 return;
1879 }
1880 time_stamp =
1881 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1882 (wmi_buf_data(buf));
1883 WMITLV_SET_HDR(&time_stamp->tlv_header,
1884 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1885 WMITLV_GET_STRUCT_TLVLEN(
1886 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1887
1888 time_ms = qdf_get_time_of_the_day_ms();
1889 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1890 time_stamp->time_stamp_low = time_ms &
1891 WMI_FW_TIME_STAMP_LOW_MASK;
1892 /*
1893 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1894 * wont exceed 27 bit
1895 */
1896 time_stamp->time_stamp_high = 0;
1897 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1898 time_stamp->mode, time_stamp->time_stamp_low,
1899 time_stamp->time_stamp_high);
1900
1901 status = wmi_unified_cmd_send(wmi_handle, buf,
1902 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
1903 if (status) {
1904 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
1905 wmi_buf_free(buf);
1906 }
1907
1908}
1909
Subrat Mishrad7c7a562017-09-27 14:41:20 +05301910#ifdef WLAN_SUPPORT_FILS
1911/**
1912 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
1913 * @wmi_handle: wmi handle
1914 * @evt_buf: pointer to event buffer
1915 * @vdev_id: pointer to hold vdev id
1916 *
1917 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
1918 */
1919static QDF_STATUS
1920extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
1921 void *evt_buf, uint32_t *vdev_id)
1922{
1923 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
1924 wmi_host_swfda_event_fixed_param *swfda_event;
1925
1926 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
1927 if (!param_buf) {
1928 WMI_LOGE("Invalid swfda event buffer");
1929 return QDF_STATUS_E_INVAL;
1930 }
1931 swfda_event = param_buf->fixed_param;
1932 *vdev_id = swfda_event->vdev_id;
1933
1934 return QDF_STATUS_SUCCESS;
1935}
1936
1937/**
1938 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
1939 * @wmi_handle: wmi handle
1940 * @param: pointer to hold FILS discovery enable param
1941 *
1942 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
1943 */
1944static QDF_STATUS
1945send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
1946 struct config_fils_params *param)
1947{
1948 wmi_enable_fils_cmd_fixed_param *cmd;
1949 wmi_buf_t buf;
1950 QDF_STATUS status;
1951 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
1952
1953 buf = wmi_buf_alloc(wmi_handle, len);
1954 if (!buf) {
1955 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1956 return QDF_STATUS_E_NOMEM;
1957 }
1958 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
1959 WMITLV_SET_HDR(&cmd->tlv_header,
1960 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
1961 WMITLV_GET_STRUCT_TLVLEN(
1962 wmi_enable_fils_cmd_fixed_param));
1963 cmd->vdev_id = param->vdev_id;
1964 cmd->fd_period = param->fd_period;
1965 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
1966 param->fd_period, param->vdev_id);
1967
1968 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1969 WMI_ENABLE_FILS_CMDID);
1970 if (status != QDF_STATUS_SUCCESS) {
1971 wmi_buf_free(buf);
1972 return QDF_STATUS_E_FAILURE;
1973 }
1974
1975 return QDF_STATUS_SUCCESS;
1976}
1977
1978/**
1979 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
1980 * @wmi_handle: wmi handle
1981 * @param: pointer to hold FD send cmd parameter
1982 *
1983 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
1984 */
1985static QDF_STATUS
1986send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
1987 struct fd_params *param)
1988{
1989 QDF_STATUS ret;
1990 wmi_fd_send_from_host_cmd_fixed_param *cmd;
1991 wmi_buf_t wmi_buf;
1992 qdf_dma_addr_t dma_addr;
1993
1994 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1995 if (!wmi_buf) {
1996 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1997 return QDF_STATUS_E_NOMEM;
1998 }
1999 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2000 WMITLV_SET_HDR(&cmd->tlv_header,
2001 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2002 WMITLV_GET_STRUCT_TLVLEN(
2003 wmi_fd_send_from_host_cmd_fixed_param));
2004 cmd->vdev_id = param->vdev_id;
2005 cmd->data_len = qdf_nbuf_len(param->wbuf);
2006 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2007 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2008 cmd->frame_ctrl = param->frame_ctrl;
2009
2010 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2011 WMI_PDEV_SEND_FD_CMDID);
2012 if (ret != QDF_STATUS_SUCCESS) {
2013 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2014 __func__, ret);
2015 wmi_buf_free(wmi_buf);
2016 }
2017
2018 return ret;
2019}
2020#endif /* WLAN_SUPPORT_FILS */
2021
Sathish Kumarfd347372017-02-13 12:29:09 +05302022static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302023 struct beacon_params *param)
2024{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302025 QDF_STATUS ret;
2026 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2027 wmi_buf_t wmi_buf;
2028 qdf_dma_addr_t dma_addr;
2029 uint32_t dtim_flag = 0;
2030
2031 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2032 if (!wmi_buf) {
2033 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2034 return QDF_STATUS_E_NOMEM;
2035 }
2036 if (param->is_dtim_count_zero) {
2037 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2038 if (param->is_bitctl_reqd) {
2039 /* deliver CAB traffic in next DTIM beacon */
2040 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2041 }
2042 }
2043 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2044 WMITLV_SET_HDR(&cmd->tlv_header,
2045 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2046 WMITLV_GET_STRUCT_TLVLEN
2047 (wmi_bcn_send_from_host_cmd_fixed_param));
2048 cmd->vdev_id = param->vdev_id;
2049 cmd->data_len = qdf_nbuf_len(param->wbuf);
2050 cmd->frame_ctrl = param->frame_ctrl;
2051 cmd->dtim_flag = dtim_flag;
2052 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2053 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2054#if defined(HTT_PADDR64)
2055 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2056#endif
2057 cmd->bcn_antenna = param->bcn_txant;
2058
2059 ret = wmi_unified_cmd_send(wmi_handle,
2060 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2061 if (ret != QDF_STATUS_SUCCESS) {
2062 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2063 wmi_buf_free(wmi_buf);
2064 }
2065
2066 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302067}
2068
2069/**
2070 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2071 * @param wmi_handle : handle to WMI.
2072 * @param param : pointer to hold beacon send cmd parameter
2073 *
2074 * Return: 0 on success and -ve on failure.
2075 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302076static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302077 struct beacon_tmpl_params *param)
2078{
2079 int32_t ret;
2080 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2081 wmi_bcn_prb_info *bcn_prb_info;
2082 wmi_buf_t wmi_buf;
2083 uint8_t *buf_ptr;
2084 uint32_t wmi_buf_len;
2085
2086 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2087 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2088 param->tmpl_len_aligned;
2089 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2090 if (!wmi_buf) {
2091 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2092 return QDF_STATUS_E_NOMEM;
2093 }
2094 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2095 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2096 WMITLV_SET_HDR(&cmd->tlv_header,
2097 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2098 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2099 cmd->vdev_id = param->vdev_id;
2100 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302101 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2102 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05302103 cmd->buf_len = param->tmpl_len;
2104 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2105
2106 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2107 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2108 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2109 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2110 bcn_prb_info->caps = 0;
2111 bcn_prb_info->erp = 0;
2112 buf_ptr += sizeof(wmi_bcn_prb_info);
2113
2114 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2115 buf_ptr += WMI_TLV_HDR_SIZE;
2116 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2117
2118 ret = wmi_unified_cmd_send(wmi_handle,
2119 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2120 if (ret) {
2121 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2122 wmi_buf_free(wmi_buf);
2123 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302124
Govind Singh87542482016-06-08 19:40:11 +05302125 return 0;
2126}
Govind Singh5eb51532016-03-09 11:34:12 +05302127
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302128#ifdef CONFIG_MCL
2129static inline void copy_peer_flags_tlv(
2130 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2131 struct peer_assoc_params *param)
2132{
2133 cmd->peer_flags = param->peer_flags;
2134}
2135#else
2136static inline void copy_peer_flags_tlv(
2137 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2138 struct peer_assoc_params *param)
2139{
2140 /*
2141 * The target only needs a subset of the flags maintained in the host.
2142 * Just populate those flags and send it down
2143 */
2144 cmd->peer_flags = 0;
2145
2146 /*
2147 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2148 */
2149 if (param->is_wme_set) {
2150
2151 if (param->qos_flag)
2152 cmd->peer_flags |= WMI_PEER_QOS;
2153 if (param->apsd_flag)
2154 cmd->peer_flags |= WMI_PEER_APSD;
2155 if (param->ht_flag)
2156 cmd->peer_flags |= WMI_PEER_HT;
2157 if (param->bw_40)
2158 cmd->peer_flags |= WMI_PEER_40MHZ;
2159 if (param->bw_80)
2160 cmd->peer_flags |= WMI_PEER_80MHZ;
2161 if (param->bw_160)
2162 cmd->peer_flags |= WMI_PEER_160MHZ;
2163
2164 /* Typically if STBC is enabled for VHT it should be enabled
2165 * for HT as well
2166 **/
2167 if (param->stbc_flag)
2168 cmd->peer_flags |= WMI_PEER_STBC;
2169
2170 /* Typically if LDPC is enabled for VHT it should be enabled
2171 * for HT as well
2172 **/
2173 if (param->ldpc_flag)
2174 cmd->peer_flags |= WMI_PEER_LDPC;
2175
2176 if (param->static_mimops_flag)
2177 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2178 if (param->dynamic_mimops_flag)
2179 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2180 if (param->spatial_mux_flag)
2181 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2182 if (param->vht_flag)
2183 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002184 if (param->he_flag)
2185 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302186 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002187
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302188 if (param->is_pmf_enabled)
2189 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302190 /*
2191 * Suppress authorization for all AUTH modes that need 4-way handshake
2192 * (during re-association).
2193 * Authorization will be done for these modes on key installation.
2194 */
2195 if (param->auth_flag)
2196 cmd->peer_flags |= WMI_PEER_AUTH;
2197 if (param->need_ptk_4_way)
2198 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2199 else
2200 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2201 if (param->need_gtk_2_way)
2202 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2203 /* safe mode bypass the 4-way handshake */
2204 if (param->safe_mode_enabled)
2205 cmd->peer_flags &=
2206 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2207 /* Disable AMSDU for station transmit, if user configures it */
2208 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2209 * it
2210 * if (param->amsdu_disable) Add after FW support
2211 **/
2212
2213 /* Target asserts if node is marked HT and all MCS is set to 0.
2214 * Mark the node as non-HT if all the mcs rates are disabled through
2215 * iwpriv
2216 **/
2217 if (param->peer_ht_rates.num_rates == 0)
2218 cmd->peer_flags &= ~WMI_PEER_HT;
2219}
2220#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302221
2222#ifdef CONFIG_MCL
2223static inline void copy_peer_mac_addr_tlv(
2224 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2225 struct peer_assoc_params *param)
2226{
2227 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2228 sizeof(param->peer_macaddr));
2229}
2230#else
2231static inline void copy_peer_mac_addr_tlv(
2232 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2233 struct peer_assoc_params *param)
2234{
2235 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2236}
2237#endif
2238
Govind Singh5eb51532016-03-09 11:34:12 +05302239/**
2240 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2241 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302242 * @param param : pointer to peer assoc parameter
2243 *
2244 * Return: 0 on success and -ve on failure.
2245 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302246static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302247 struct peer_assoc_params *param)
2248{
Govind Singhd3156eb2016-02-26 17:50:39 +05302249 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2250 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002251 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302252 wmi_buf_t buf;
2253 int32_t len;
2254 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302255 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302256 uint32_t peer_legacy_rates_align;
2257 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002258 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302259
2260
2261 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2262 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302263
2264 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002265 (peer_legacy_rates_align * sizeof(uint8_t)) +
2266 WMI_TLV_HDR_SIZE +
2267 (peer_ht_rates_align * sizeof(uint8_t)) +
2268 sizeof(wmi_vht_rate_set) +
2269 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2270 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302271
2272 buf = wmi_buf_alloc(wmi_handle, len);
2273 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302274 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302275 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302276 }
2277
2278 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2279 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2280 WMITLV_SET_HDR(&cmd->tlv_header,
2281 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2282 WMITLV_GET_STRUCT_TLVLEN
2283 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302284
Govind Singhd3156eb2016-02-26 17:50:39 +05302285 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302286
Govind Singhd3156eb2016-02-26 17:50:39 +05302287 cmd->peer_new_assoc = param->peer_new_assoc;
2288 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302289
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302290 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302291 copy_peer_mac_addr_tlv(cmd, param);
2292
Govind Singhd3156eb2016-02-26 17:50:39 +05302293 cmd->peer_rate_caps = param->peer_rate_caps;
2294 cmd->peer_caps = param->peer_caps;
2295 cmd->peer_listen_intval = param->peer_listen_intval;
2296 cmd->peer_ht_caps = param->peer_ht_caps;
2297 cmd->peer_max_mpdu = param->peer_max_mpdu;
2298 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302299 cmd->peer_vht_caps = param->peer_vht_caps;
2300 cmd->peer_phymode = param->peer_phymode;
2301
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002302 /* Update 11ax capabilities */
2303 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2304 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002305 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2306 sizeof(param->peer_he_cap_phyinfo));
2307 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2308 sizeof(param->peer_ppet));
2309
Govind Singhd3156eb2016-02-26 17:50:39 +05302310 /* Update peer legacy rate information */
2311 buf_ptr += sizeof(*cmd);
2312 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302313 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302314 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302315 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302316 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302317 param->peer_legacy_rates.num_rates);
2318
2319 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002320 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302321 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302322 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302323 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302324 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302325 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302326 param->peer_ht_rates.num_rates);
2327
2328 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002329 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302330 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2331 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2332
2333 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302334
2335 /* Update bandwidth-NSS mapping */
2336 cmd->peer_bw_rxnss_override = 0;
2337 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2338
Govind Singhd3156eb2016-02-26 17:50:39 +05302339 mcs = (wmi_vht_rate_set *) buf_ptr;
2340 if (param->vht_capable) {
2341 mcs->rx_max_rate = param->rx_max_rate;
2342 mcs->rx_mcs_set = param->rx_mcs_set;
2343 mcs->tx_max_rate = param->tx_max_rate;
2344 mcs->tx_mcs_set = param->tx_mcs_set;
2345 }
2346
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002347 /* HE Rates */
2348 cmd->peer_he_mcs = param->peer_he_mcs_count;
2349 buf_ptr += sizeof(wmi_vht_rate_set);
2350 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2351 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2352 buf_ptr += WMI_TLV_HDR_SIZE;
2353
2354 /* Loop through the HE rate set */
2355 for (i = 0; i < param->peer_he_mcs_count; i++) {
2356 he_mcs = (wmi_he_rate_set *) buf_ptr;
2357 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2358 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2359
2360 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2361 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2362 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2363 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2364 buf_ptr += sizeof(wmi_he_rate_set);
2365 }
2366
2367
Govind Singhb53420c2016-03-09 14:32:57 +05302368 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302369 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2370 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002371 "cmd->peer_vht_caps %x "
2372 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302373 "HE phy %x %x %x "
2374 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302375 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2376 cmd->peer_rate_caps, cmd->peer_caps,
2377 cmd->peer_listen_intval, cmd->peer_ht_caps,
2378 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2379 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002380 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2381 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302382 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2383 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302384
2385 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2386 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302387 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302388 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302389 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302390 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302391 }
2392
2393 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302394}
2395
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302396/* copy_scan_notify_events() - Helper routine to copy scan notify events
2397 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302398static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302399 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302400 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302401{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302402
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302403 /* Scan events subscription */
2404 if (param->scan_ev_started)
2405 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2406 if (param->scan_ev_completed)
2407 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2408 if (param->scan_ev_bss_chan)
2409 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2410 if (param->scan_ev_foreign_chan)
2411 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2412 if (param->scan_ev_dequeued)
2413 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2414 if (param->scan_ev_preempted)
2415 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2416 if (param->scan_ev_start_failed)
2417 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2418 if (param->scan_ev_restarted)
2419 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2420 if (param->scan_ev_foreign_chn_exit)
2421 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2422 if (param->scan_ev_suspended)
2423 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2424 if (param->scan_ev_resumed)
2425 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302426
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302427 /** Set scan control flags */
2428 cmd->scan_ctrl_flags = 0;
2429 if (param->scan_f_passive)
2430 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2431 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302432 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302433 if (param->scan_f_promisc_mode)
2434 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2435 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302436 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302437 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302438 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302439 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302440 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302441 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302442 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302443 if (param->scan_f_ofdm_rates)
2444 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2445 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302446 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302447 if (param->scan_f_filter_prb_req)
2448 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2449 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302450 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302451 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302452 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302453 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302454 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302455 if (param->scan_f_force_active_dfs_chn)
2456 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2457 if (param->scan_f_add_tpc_ie_in_probe)
2458 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2459 if (param->scan_f_add_ds_ie_in_probe)
2460 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2461 if (param->scan_f_add_spoofed_mac_in_probe)
2462 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2463 if (param->scan_f_add_rand_seq_in_probe)
2464 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2465 if (param->scan_f_en_ie_whitelist_in_probe)
2466 cmd->scan_ctrl_flags |=
2467 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302468
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302469 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2470 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2471 param->adaptive_dwell_time_mode);
2472}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302473
2474/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302475static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302476 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302477{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302478 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302479}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302480
Anish Natarajdd855152017-03-20 12:49:08 +05302481/*
2482 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2483 * @param wmi_handle : Handle to WMI
2484 * @param vdev_id : vdev identifier
2485 *
2486 * Return : void *
2487 */
2488static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2489{
2490 struct wlan_objmgr_vdev *vdev = NULL;
2491 struct wlan_objmgr_pdev *pdev = NULL;
2492 uint8_t pdev_id = 0;
2493
2494 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2495 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2496 vdev_id, WLAN_SCAN_ID);
2497 if (vdev) {
2498 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2499 pdev = wlan_vdev_get_pdev(vdev);
2500 if (pdev)
2501 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2502 else {
2503 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2504 }
2505 } else {
2506 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2507 }
2508
2509 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2510}
2511
Govind Singh5eb51532016-03-09 11:34:12 +05302512/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302513 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2514 * @mac: random mac addr
2515 * @mask: random mac mask
2516 * @mac_addr: wmi random mac
2517 * @mac_mask: wmi random mac mask
2518 *
2519 * Return None.
2520 */
2521static inline
2522void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2523 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2524{
2525 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2526 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2527}
2528
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302529/*
2530 * wmi_fill_vendor_oui() - fill vendor OUIs
2531 * @buf_ptr: pointer to wmi tlv buffer
2532 * @num_vendor_oui: number of vendor OUIs to be filled
2533 * @param_voui: pointer to OUI buffer
2534 *
2535 * This function populates the wmi tlv buffer when vendor specific OUIs are
2536 * present.
2537 *
2538 * Return: None
2539 */
2540static inline
2541void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2542 uint32_t *pvoui)
2543{
2544 wmi_vendor_oui *voui = NULL;
2545 uint32_t i;
2546
2547 voui = (wmi_vendor_oui *)buf_ptr;
2548
2549 for (i = 0; i < num_vendor_oui; i++) {
2550 WMITLV_SET_HDR(&voui[i].tlv_header,
2551 WMITLV_TAG_STRUC_wmi_vendor_oui,
2552 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2553 voui[i].oui_type_subtype = pvoui[i];
2554 }
2555}
2556
2557/*
2558 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2559 * @ie_bitmap: output pointer to ie bit map in cmd
2560 * @num_vendor_oui: output pointer to num vendor OUIs
2561 * @ie_whitelist: input parameter
2562 *
2563 * This function populates the IE whitelist attrs of scan, pno and
2564 * scan oui commands for ie_whitelist parameter.
2565 *
2566 * Return: None
2567 */
2568static inline
2569void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2570 uint32_t *num_vendor_oui,
2571 struct probe_req_whitelist_attr *ie_whitelist)
2572{
2573 uint32_t i = 0;
2574
2575 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2576 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2577
2578 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2579}
2580
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302581/**
Govind Singh5eb51532016-03-09 11:34:12 +05302582 * send_scan_start_cmd_tlv() - WMI scan start function
2583 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302584 * @param param : pointer to hold scan start cmd parameter
2585 *
2586 * Return: 0 on success and -ve on failure.
2587 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302588static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302589 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302590{
Govind Singhd3156eb2016-02-26 17:50:39 +05302591 int32_t ret = 0;
2592 int32_t i;
2593 wmi_buf_t wmi_buf;
2594 wmi_start_scan_cmd_fixed_param *cmd;
2595 uint8_t *buf_ptr;
2596 uint32_t *tmp_ptr;
2597 wmi_ssid *ssid = NULL;
2598 wmi_mac_addr *bssid;
2599 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302600 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302601 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302602 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002603 wmi_unified_t pdev_wmi_handle;
Govind Singhd3156eb2016-02-26 17:50:39 +05302604
2605 /* Length TLV placeholder for array of uint32_t */
2606 len += WMI_TLV_HDR_SIZE;
2607 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302608 if (params->chan_list.num_chan)
2609 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302610
2611 /* Length TLV placeholder for array of wmi_ssid structures */
2612 len += WMI_TLV_HDR_SIZE;
2613 if (params->num_ssids)
2614 len += params->num_ssids * sizeof(wmi_ssid);
2615
2616 /* Length TLV placeholder for array of wmi_mac_addr structures */
2617 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302618 if (params->num_bssid)
2619 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302620
2621 /* Length TLV placeholder for array of bytes */
2622 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302623 if (params->extraie.len)
2624 extraie_len_with_pad =
2625 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002626 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302627
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302628 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2629 if (ie_whitelist->num_vendor_oui)
2630 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2631
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302632 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2633 if (params->scan_f_wide_band)
2634 phymode_roundup =
2635 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2636 sizeof(uint32_t));
2637 len += phymode_roundup;
2638
Govind Singhd3156eb2016-02-26 17:50:39 +05302639 /* Allocate the memory */
2640 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2641 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302642 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302643 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302644 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302645 }
2646 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2647 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2648 WMITLV_SET_HDR(&cmd->tlv_header,
2649 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2650 WMITLV_GET_STRUCT_TLVLEN
2651 (wmi_start_scan_cmd_fixed_param));
2652
2653 cmd->scan_id = params->scan_id;
2654 cmd->scan_req_id = params->scan_req_id;
2655 cmd->vdev_id = params->vdev_id;
2656 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302657
2658 copy_scan_event_cntrl_flags(cmd, params);
2659
Govind Singhd3156eb2016-02-26 17:50:39 +05302660 cmd->dwell_time_active = params->dwell_time_active;
2661 cmd->dwell_time_passive = params->dwell_time_passive;
2662 cmd->min_rest_time = params->min_rest_time;
2663 cmd->max_rest_time = params->max_rest_time;
2664 cmd->repeat_probe_time = params->repeat_probe_time;
2665 cmd->probe_spacing_time = params->probe_spacing_time;
2666 cmd->idle_time = params->idle_time;
2667 cmd->max_scan_time = params->max_scan_time;
2668 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302669 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302670 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302671 cmd->num_bssid = params->num_bssid;
2672 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302673 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302674 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302675 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2676
2677 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2678
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302679 if (params->scan_random.randomize)
2680 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2681 params->scan_random.mac_mask,
2682 &cmd->mac_addr,
2683 &cmd->mac_mask);
2684
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302685 if (ie_whitelist->white_list)
2686 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2687 &cmd->num_vendor_oui,
2688 ie_whitelist);
2689
Govind Singhd3156eb2016-02-26 17:50:39 +05302690 buf_ptr += sizeof(*cmd);
2691 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302692 for (i = 0; i < params->chan_list.num_chan; ++i)
2693 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302694
2695 WMITLV_SET_HDR(buf_ptr,
2696 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302697 (params->chan_list.num_chan * sizeof(uint32_t)));
2698 buf_ptr += WMI_TLV_HDR_SIZE +
2699 (params->chan_list.num_chan * sizeof(uint32_t));
2700
Govind Singh4eacd2b2016-03-07 14:24:22 +05302701 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302702 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302703 goto error;
2704 }
2705
2706 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2707 (params->num_ssids * sizeof(wmi_ssid)));
2708
2709 if (params->num_ssids) {
2710 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2711 for (i = 0; i < params->num_ssids; ++i) {
2712 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302713 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302714 params->ssid[i].length);
2715 ssid++;
2716 }
2717 }
2718 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2719
2720 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2721 (params->num_bssid * sizeof(wmi_mac_addr)));
2722 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302723
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302724 if (params->num_bssid) {
2725 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302726 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2727 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302728 bssid++;
2729 }
2730 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302731
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302732 buf_ptr += WMI_TLV_HDR_SIZE +
2733 (params->num_bssid * sizeof(wmi_mac_addr));
2734
2735 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2736 if (params->extraie.len)
2737 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2738 params);
2739
2740 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302741
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302742 /* probe req ie whitelisting */
2743 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2744 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2745
2746 buf_ptr += WMI_TLV_HDR_SIZE;
2747
2748 if (cmd->num_vendor_oui) {
2749 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2750 ie_whitelist->voui);
2751 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2752 }
2753
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302754 /* Add phy mode TLV if it's a wide band scan */
2755 if (params->scan_f_wide_band) {
2756 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2757 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2758 for (i = 0; i < params->chan_list.num_chan; ++i)
2759 buf_ptr[i] =
2760 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2761 buf_ptr += phymode_roundup;
2762 } else {
2763 /* Add ZERO legth phy mode TLV */
2764 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2765 }
2766
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002767 pdev_wmi_handle = get_pdev_wmi_handle(wmi_handle, cmd->vdev_id);
2768 if (pdev_wmi_handle == NULL) {
2769 WMI_LOGE("%s: Invalid PDEV WMI handle", __func__);
2770 goto error;
2771 }
2772
2773 ret = wmi_unified_cmd_send(pdev_wmi_handle, wmi_buf,
2774 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302775 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302776 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302777 wmi_buf_free(wmi_buf);
2778 }
2779 return ret;
2780error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302781 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302782 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302783}
2784
2785/**
2786 * send_scan_stop_cmd_tlv() - WMI scan start function
2787 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302788 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302789 *
2790 * Return: 0 on success and -ve on failure.
2791 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302792static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302793 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302794{
Govind Singhd3156eb2016-02-26 17:50:39 +05302795 wmi_stop_scan_cmd_fixed_param *cmd;
2796 int ret;
2797 int len = sizeof(*cmd);
2798 wmi_buf_t wmi_buf;
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002799 wmi_unified_t pdev_wmi_handle;
Govind Singhd3156eb2016-02-26 17:50:39 +05302800
2801 /* Allocate the memory */
2802 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2803 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302804 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302805 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302806 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302807 goto error;
2808 }
2809
2810 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2811 WMITLV_SET_HDR(&cmd->tlv_header,
2812 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2813 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2814 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302815 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302816 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302817 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2818 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302819 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302820 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2821 /* Cancelling all scans */
2822 cmd->req_type = WMI_SCAN_STOP_ALL;
2823 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2824 /* Cancelling VAP scans */
2825 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2826 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2827 /* Cancelling specific scan */
2828 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302829 } else {
2830 WMI_LOGE("%s: Invalid Command : ", __func__);
2831 wmi_buf_free(wmi_buf);
2832 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302833 }
2834
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002835 pdev_wmi_handle = get_pdev_wmi_handle(wmi_handle, cmd->vdev_id);
2836 if (pdev_wmi_handle == NULL) {
2837 WMI_LOGE("%s: Invalid PDEV WMI handle", __func__);
2838 wmi_buf_free(wmi_buf);
2839 return QDF_STATUS_E_NULL_VALUE;
2840 }
2841
2842 ret = wmi_unified_cmd_send(pdev_wmi_handle, wmi_buf,
2843 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302844 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302845 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302846 wmi_buf_free(wmi_buf);
2847 }
2848
2849error:
2850 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302851}
2852
Govind Singh87542482016-06-08 19:40:11 +05302853#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302854/**
2855 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2856 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302857 * @param param : pointer to hold scan channel list parameter
2858 *
2859 * Return: 0 on success and -ve on failure.
2860 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302861static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302862 struct scan_chan_list_params *chan_list)
2863{
2864 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302865 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302866 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302867 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302868 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302869 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302870 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2871
2872 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2873 buf = wmi_buf_alloc(wmi_handle, len);
2874 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302875 WMI_LOGE("Failed to allocate memory");
2876 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302877 goto end;
2878 }
2879
2880 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2881 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2882 WMITLV_SET_HDR(&cmd->tlv_header,
2883 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2884 WMITLV_GET_STRUCT_TLVLEN
2885 (wmi_scan_chan_list_cmd_fixed_param));
2886
Govind Singhb53420c2016-03-09 14:32:57 +05302887 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302888
2889 cmd->num_scan_chans = chan_list->num_scan_chans;
2890 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2891 WMITLV_TAG_ARRAY_STRUC,
2892 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302893 chan_info = (wmi_channel_param *)
2894 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302895 tchan_info = chan_list->chan_info;
2896
2897 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2898 WMITLV_SET_HDR(&chan_info->tlv_header,
2899 WMITLV_TAG_STRUC_wmi_channel,
2900 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2901 chan_info->mhz = tchan_info->mhz;
2902 chan_info->band_center_freq1 =
2903 tchan_info->band_center_freq1;
2904 chan_info->band_center_freq2 =
2905 tchan_info->band_center_freq2;
2906 chan_info->info = tchan_info->info;
2907 chan_info->reg_info_1 = tchan_info->reg_info_1;
2908 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302909 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302910
2911 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2912 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2913 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2914 tchan_info++;
2915 chan_info++;
2916 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302917 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2918 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302919
Anish Natarajdd855152017-03-20 12:49:08 +05302920 qdf_status = wmi_unified_cmd_send(wmi_handle,
2921 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302922
Govind Singh67922e82016-04-01 16:48:57 +05302923 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302924 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302925 wmi_buf_free(buf);
2926 }
Govind Singh67922e82016-04-01 16:48:57 +05302927
Govind Singhd3156eb2016-02-26 17:50:39 +05302928end:
Govind Singhb53420c2016-03-09 14:32:57 +05302929 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302930}
Govind Singh87542482016-06-08 19:40:11 +05302931#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302932static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302933 struct scan_chan_list_params *chan_list)
2934{
2935 wmi_buf_t buf;
2936 QDF_STATUS qdf_status;
2937 wmi_scan_chan_list_cmd_fixed_param *cmd;
2938 int i;
2939 uint8_t *buf_ptr;
2940 wmi_channel *chan_info;
2941 struct channel_param *tchan_info;
2942 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302943
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302944 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302945 buf = wmi_buf_alloc(wmi_handle, len);
2946 if (!buf) {
2947 WMI_LOGE("Failed to allocate memory");
2948 qdf_status = QDF_STATUS_E_NOMEM;
2949 goto end;
2950 }
2951
2952 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2953 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2954 WMITLV_SET_HDR(&cmd->tlv_header,
2955 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2956 WMITLV_GET_STRUCT_TLVLEN
2957 (wmi_scan_chan_list_cmd_fixed_param));
2958
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302959 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302960
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302961 if (chan_list->append)
2962 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2963
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302964 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2965 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302966 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302967 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2968 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302969 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302970 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2971 tchan_info = &(chan_list->ch_param[0]);
2972
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302973 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302974 WMITLV_SET_HDR(&chan_info->tlv_header,
2975 WMITLV_TAG_STRUC_wmi_channel,
2976 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2977 chan_info->mhz = tchan_info->mhz;
2978 chan_info->band_center_freq1 =
2979 tchan_info->cfreq1;
2980 chan_info->band_center_freq2 =
2981 tchan_info->cfreq2;
2982
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302983 if (tchan_info->is_chan_passive)
2984 WMI_SET_CHANNEL_FLAG(chan_info,
2985 WMI_CHAN_FLAG_PASSIVE);
2986
2987 if (tchan_info->allow_vht)
2988 WMI_SET_CHANNEL_FLAG(chan_info,
2989 WMI_CHAN_FLAG_ALLOW_VHT);
2990 else if (tchan_info->allow_ht)
2991 WMI_SET_CHANNEL_FLAG(chan_info,
2992 WMI_CHAN_FLAG_ALLOW_HT);
2993 WMI_SET_CHANNEL_MODE(chan_info,
2994 tchan_info->phy_mode);
2995
2996 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2997 * after FW support
2998 */
2999
3000 /* also fill in power information */
3001 WMI_SET_CHANNEL_MIN_POWER(chan_info,
3002 tchan_info->minpower);
3003 WMI_SET_CHANNEL_MAX_POWER(chan_info,
3004 tchan_info->maxpower);
3005 WMI_SET_CHANNEL_REG_POWER(chan_info,
3006 tchan_info->maxregpower);
3007 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
3008 tchan_info->antennamax);
3009 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
3010 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08003011 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
3012 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303013
Govind Singh87542482016-06-08 19:40:11 +05303014 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
3015
Govind Singh87542482016-06-08 19:40:11 +05303016 tchan_info++;
3017 chan_info++;
3018 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303019 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3020 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05303021
Anish Natarajdd855152017-03-20 12:49:08 +05303022 qdf_status = wmi_unified_cmd_send(
3023 wmi_handle,
3024 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05303025
3026 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3027 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
3028 wmi_buf_free(buf);
3029 }
3030
3031end:
3032 return qdf_status;
3033}
3034#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05303035
3036/**
3037 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3038 *
3039 * @bufp: Pointer to buffer
3040 * @param: Pointer to tx param
3041 *
3042 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3043 */
3044static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3045 struct tx_send_params param)
3046{
3047 wmi_tx_send_params *tx_param;
3048 QDF_STATUS status = QDF_STATUS_SUCCESS;
3049
3050 if (!bufp) {
3051 status = QDF_STATUS_E_FAILURE;
3052 return status;
3053 }
3054 tx_param = (wmi_tx_send_params *)bufp;
3055 WMITLV_SET_HDR(&tx_param->tlv_header,
3056 WMITLV_TAG_STRUC_wmi_tx_send_params,
3057 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3058 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3059 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3060 param.mcs_mask);
3061 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3062 param.nss_mask);
3063 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3064 param.retry_limit);
3065 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3066 param.chain_mask);
3067 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3068 param.bw_mask);
3069 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3070 param.preamble_type);
3071 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3072 param.frame_type);
3073
3074 return status;
3075}
3076
Govind Singhd3156eb2016-02-26 17:50:39 +05303077/**
3078 * send_mgmt_cmd_tlv() - WMI scan start function
3079 * @wmi_handle : handle to WMI.
3080 * @param : pointer to hold mgmt cmd parameter
3081 *
3082 * Return: 0 on success and -ve on failure.
3083 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303084static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303085 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303086{
Govind Singh427ee5a2016-02-26 18:09:36 +05303087 wmi_buf_t buf;
3088 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3089 int32_t cmd_len;
3090 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303091 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303092 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303093 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303094 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3095 mgmt_tx_dl_frm_len;
3096
3097 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303098 WMI_TLV_HDR_SIZE +
3099 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303100
Sathish Kumar5b636932017-06-28 14:40:32 +05303101 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303102 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303103 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3104 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303105 }
3106
3107 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3108 bufp = (uint8_t *) cmd;
3109 WMITLV_SET_HDR(&cmd->tlv_header,
3110 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3111 WMITLV_GET_STRUCT_TLVLEN
3112 (wmi_mgmt_tx_send_cmd_fixed_param));
3113
3114 cmd->vdev_id = param->vdev_id;
3115
Govind Singh224a7312016-06-21 14:33:26 +05303116 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303117 cmd->chanfreq = param->chanfreq;
3118 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3119 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3120 sizeof(uint32_t)));
3121 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303122 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303123
3124 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3125 QDF_DMA_TO_DEVICE);
3126 if (status != QDF_STATUS_SUCCESS) {
3127 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303128 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303129 }
3130
Govind Singhb53420c2016-03-09 14:32:57 +05303131 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303132 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003133#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303134 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3135#endif
3136 cmd->frame_len = param->frm_len;
3137 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303138 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303139
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003140 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003141 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003142
Sathish Kumar5b636932017-06-28 14:40:32 +05303143 bufp += roundup(bufp_len, sizeof(uint32_t));
3144 if (param->tx_params_valid) {
3145 status = populate_tx_send_params(bufp, param->tx_param);
3146 if (status != QDF_STATUS_SUCCESS) {
3147 WMI_LOGE("%s: Populate TX send params failed",
3148 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303149 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303150 }
3151 cmd_len += sizeof(wmi_tx_send_params);
3152 }
3153
Govind Singh427ee5a2016-02-26 18:09:36 +05303154 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3155 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303156 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303157 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303158 }
Govind Singhb53420c2016-03-09 14:32:57 +05303159 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303160
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303161unmap_tx_frame:
3162 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3163 QDF_DMA_TO_DEVICE);
3164free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303165 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303166 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303167}
3168
3169/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303170 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3171 * @wmi_handle : handle to WMI.
3172 * @param : pointer to offchan data tx cmd parameter
3173 *
3174 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3175 */
3176static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3177 struct wmi_offchan_data_tx_params *param)
3178{
3179 wmi_buf_t buf;
3180 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3181 int32_t cmd_len;
3182 uint64_t dma_addr;
3183 void *qdf_ctx = param->qdf_ctx;
3184 uint8_t *bufp;
3185 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3186 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303187 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303188
3189 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303190 WMI_TLV_HDR_SIZE +
3191 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303192
Sathish Kumar5b636932017-06-28 14:40:32 +05303193 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303194 if (!buf) {
3195 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3196 return QDF_STATUS_E_NOMEM;
3197 }
3198
3199 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3200 bufp = (uint8_t *) cmd;
3201 WMITLV_SET_HDR(&cmd->tlv_header,
3202 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3203 WMITLV_GET_STRUCT_TLVLEN
3204 (wmi_offchan_data_tx_send_cmd_fixed_param));
3205
3206 cmd->vdev_id = param->vdev_id;
3207
3208 cmd->desc_id = param->desc_id;
3209 cmd->chanfreq = param->chanfreq;
3210 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3211 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3212 sizeof(uint32_t)));
3213 bufp += WMI_TLV_HDR_SIZE;
3214 qdf_mem_copy(bufp, param->pdata, bufp_len);
3215 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3216 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3217 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3218#if defined(HTT_PADDR64)
3219 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3220#endif
3221 cmd->frame_len = param->frm_len;
3222 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303223 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303224
3225 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3226 bufp, cmd->vdev_id, cmd->chanfreq);
3227
Sathish Kumar5b636932017-06-28 14:40:32 +05303228 bufp += roundup(bufp_len, sizeof(uint32_t));
3229 if (param->tx_params_valid) {
3230 status = populate_tx_send_params(bufp, param->tx_param);
3231 if (status != QDF_STATUS_SUCCESS) {
3232 WMI_LOGE("%s: Populate TX send params failed",
3233 __func__);
3234 goto err1;
3235 }
3236 cmd_len += sizeof(wmi_tx_send_params);
3237 }
3238
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303239 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3240 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3241 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303242 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303243 }
3244
3245 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303246
3247err1:
3248 wmi_buf_free(buf);
3249 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303250}
3251
3252/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303253 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3254 * @wmi_handle: wmi handle
3255 * @param_value: parameter value
3256 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303257 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303258 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303259static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303260 uint32_t param_value)
3261{
Govind Singh67922e82016-04-01 16:48:57 +05303262 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303263 wmi_modem_power_state_cmd_param *cmd;
3264 wmi_buf_t buf;
3265 uint16_t len = sizeof(*cmd);
3266
3267 buf = wmi_buf_alloc(wmi_handle, len);
3268 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303269 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303270 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303271 }
3272 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3273 WMITLV_SET_HDR(&cmd->tlv_header,
3274 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3275 WMITLV_GET_STRUCT_TLVLEN
3276 (wmi_modem_power_state_cmd_param));
3277 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303278 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303279 param_value);
3280 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3281 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303282 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303283 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303284 wmi_buf_free(buf);
3285 }
Govind Singh67922e82016-04-01 16:48:57 +05303286
Govind Singh427ee5a2016-02-26 18:09:36 +05303287 return ret;
3288}
3289
3290/**
3291 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3292 * @wmi_handle: wmi handle
3293 * @vdev_id: vdev id
3294 * @val: value
3295 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303296 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303297 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303298static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303299 uint32_t vdev_id, uint8_t val)
3300{
3301 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3302 wmi_buf_t buf;
3303 int32_t len = sizeof(*cmd);
3304
Govind Singhb53420c2016-03-09 14:32:57 +05303305 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303306
3307 buf = wmi_buf_alloc(wmi_handle, len);
3308 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303309 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303310 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303311 }
3312 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3313 WMITLV_SET_HDR(&cmd->tlv_header,
3314 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3315 WMITLV_GET_STRUCT_TLVLEN
3316 (wmi_sta_powersave_mode_cmd_fixed_param));
3317 cmd->vdev_id = vdev_id;
3318 if (val)
3319 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3320 else
3321 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3322
3323 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3324 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303325 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303326 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303327 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303328 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303329 }
Govind Singh5eb51532016-03-09 11:34:12 +05303330 return 0;
3331}
3332
Govind Singh427ee5a2016-02-26 18:09:36 +05303333/**
3334 * send_set_mimops_cmd_tlv() - set MIMO powersave
3335 * @wmi_handle: wmi handle
3336 * @vdev_id: vdev id
3337 * @value: value
3338 *
Govind Singhb53420c2016-03-09 14:32:57 +05303339 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303340 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303341static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303342 uint8_t vdev_id, int value)
3343{
Govind Singh67922e82016-04-01 16:48:57 +05303344 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303345 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3346 wmi_buf_t buf;
3347 uint16_t len = sizeof(*cmd);
3348
3349 buf = wmi_buf_alloc(wmi_handle, len);
3350 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303351 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303352 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303353 }
3354 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3355 WMITLV_SET_HDR(&cmd->tlv_header,
3356 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3357 WMITLV_GET_STRUCT_TLVLEN
3358 (wmi_sta_smps_force_mode_cmd_fixed_param));
3359
3360 cmd->vdev_id = vdev_id;
3361
Houston Hoffmanb5168052016-04-14 02:18:01 -07003362 /* WMI_SMPS_FORCED_MODE values do not directly map
3363 * to SM power save values defined in the specification.
3364 * Make sure to send the right mapping.
3365 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303366 switch (value) {
3367 case 0:
3368 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3369 break;
3370 case 1:
3371 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3372 break;
3373 case 2:
3374 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3375 break;
3376 case 3:
3377 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3378 break;
3379 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303380 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
3381 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303382 }
3383
Govind Singhb53420c2016-03-09 14:32:57 +05303384 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303385
3386 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3387 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303388 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303389 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303390 wmi_buf_free(buf);
3391 }
3392
3393 return ret;
3394}
3395
3396/**
3397 * send_set_smps_params_cmd_tlv() - set smps params
3398 * @wmi_handle: wmi handle
3399 * @vdev_id: vdev id
3400 * @value: value
3401 *
Govind Singhb53420c2016-03-09 14:32:57 +05303402 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303403 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303404static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303405 int value)
3406{
Govind Singh67922e82016-04-01 16:48:57 +05303407 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303408 wmi_sta_smps_param_cmd_fixed_param *cmd;
3409 wmi_buf_t buf;
3410 uint16_t len = sizeof(*cmd);
3411
3412 buf = wmi_buf_alloc(wmi_handle, len);
3413 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303414 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303415 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303416 }
3417 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3418 WMITLV_SET_HDR(&cmd->tlv_header,
3419 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3420 WMITLV_GET_STRUCT_TLVLEN
3421 (wmi_sta_smps_param_cmd_fixed_param));
3422
3423 cmd->vdev_id = vdev_id;
3424 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3425 cmd->param =
3426 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3427
Govind Singhb53420c2016-03-09 14:32:57 +05303428 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303429 cmd->param);
3430
3431 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3432 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303433 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303434 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303435 wmi_buf_free(buf);
3436 }
3437
3438 return ret;
3439}
3440
3441/**
3442 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3443 * @wmi_handle: wmi handle
3444 * @noa: p2p power save parameters
3445 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303446 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303447 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303448static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303449 struct p2p_ps_params *noa)
3450{
3451 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3452 wmi_p2p_noa_descriptor *noa_discriptor;
3453 wmi_buf_t buf;
3454 uint8_t *buf_ptr;
3455 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303456 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303457 uint32_t duration;
3458
Govind Singhb53420c2016-03-09 14:32:57 +05303459 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303460 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3461 buf = wmi_buf_alloc(wmi_handle, len);
3462 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303463 WMI_LOGE("Failed to allocate memory");
3464 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303465 goto end;
3466 }
3467
3468 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3469 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3470 WMITLV_SET_HDR(&cmd->tlv_header,
3471 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3472 WMITLV_GET_STRUCT_TLVLEN
3473 (wmi_p2p_set_noa_cmd_fixed_param));
3474 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3475 cmd->vdev_id = noa->session_id;
3476 cmd->enable = (duration) ? true : false;
3477 cmd->num_noa = 1;
3478
3479 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3480 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3481 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3482 sizeof
3483 (wmi_p2p_set_noa_cmd_fixed_param)
3484 + WMI_TLV_HDR_SIZE);
3485 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3486 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3487 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3488 noa_discriptor->type_count = noa->count;
3489 noa_discriptor->duration = duration;
3490 noa_discriptor->interval = noa->interval;
3491 noa_discriptor->start_time = 0;
3492
Govind Singhb53420c2016-03-09 14:32:57 +05303493 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303494 cmd->vdev_id, noa->count, noa_discriptor->duration,
3495 noa->interval);
3496 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3497 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303498 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303499 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303500 wmi_buf_free(buf);
3501 }
3502
3503end:
Govind Singhb53420c2016-03-09 14:32:57 +05303504 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303505 return status;
3506}
3507
3508
3509/**
3510 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3511 * @wmi_handle: wmi handle
3512 * @noa: p2p opp power save parameters
3513 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303514 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303515 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303516static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303517 struct p2p_ps_params *oppps)
3518{
3519 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3520 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303521 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303522
Govind Singhb53420c2016-03-09 14:32:57 +05303523 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303524 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3525 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303526 WMI_LOGE("Failed to allocate memory");
3527 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303528 goto end;
3529 }
3530
3531 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3532 WMITLV_SET_HDR(&cmd->tlv_header,
3533 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3534 WMITLV_GET_STRUCT_TLVLEN
3535 (wmi_p2p_set_oppps_cmd_fixed_param));
3536 cmd->vdev_id = oppps->session_id;
3537 if (oppps->ctwindow)
3538 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3539
3540 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303541 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303542 cmd->vdev_id, oppps->ctwindow);
3543 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3544 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303545 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303546 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303547 wmi_buf_free(buf);
3548 }
3549
3550end:
Govind Singhb53420c2016-03-09 14:32:57 +05303551 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303552 return status;
3553}
3554
Wu Gaocd3a8512017-03-13 20:17:34 +08003555#ifdef CONVERGED_P2P_ENABLE
3556/**
3557 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3558 * @wmi_handle: wmi handle
3559 * @param: p2p listen offload start parameters
3560 *
3561 * Return: QDF status
3562 */
3563static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3564 struct p2p_lo_start *param)
3565{
3566 wmi_buf_t buf;
3567 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3568 int32_t len = sizeof(*cmd);
3569 uint8_t *buf_ptr;
3570 QDF_STATUS status;
3571 int device_types_len_aligned;
3572 int probe_resp_len_aligned;
3573
3574 if (!param) {
3575 WMI_LOGE("lo start param is null");
3576 return QDF_STATUS_E_INVAL;
3577 }
3578
3579 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3580
3581 device_types_len_aligned =
3582 qdf_roundup(param->dev_types_len,
3583 sizeof(A_UINT32));
3584 probe_resp_len_aligned =
3585 qdf_roundup(param->probe_resp_len,
3586 sizeof(A_UINT32));
3587
3588 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3589 probe_resp_len_aligned;
3590
3591 buf = wmi_buf_alloc(wmi_handle, len);
3592 if (!buf) {
3593 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3594 __func__);
3595 return QDF_STATUS_E_NOMEM;
3596 }
3597
3598 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3599 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3600
3601 WMITLV_SET_HDR(&cmd->tlv_header,
3602 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3603 WMITLV_GET_STRUCT_TLVLEN(
3604 wmi_p2p_lo_start_cmd_fixed_param));
3605
3606 cmd->vdev_id = param->vdev_id;
3607 cmd->ctl_flags = param->ctl_flags;
3608 cmd->channel = param->freq;
3609 cmd->period = param->period;
3610 cmd->interval = param->interval;
3611 cmd->count = param->count;
3612 cmd->device_types_len = param->dev_types_len;
3613 cmd->prob_resp_len = param->probe_resp_len;
3614
3615 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3616 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3617 device_types_len_aligned);
3618 buf_ptr += WMI_TLV_HDR_SIZE;
3619 qdf_mem_copy(buf_ptr, param->device_types,
3620 param->dev_types_len);
3621
3622 buf_ptr += device_types_len_aligned;
3623 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3624 probe_resp_len_aligned);
3625 buf_ptr += WMI_TLV_HDR_SIZE;
3626 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3627 param->probe_resp_len);
3628
3629 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3630 cmd->channel, cmd->period, cmd->interval, cmd->count);
3631
3632 status = wmi_unified_cmd_send(wmi_handle,
3633 buf, len,
3634 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3635 if (status != QDF_STATUS_SUCCESS) {
3636 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3637 __func__, status);
3638 wmi_buf_free(buf);
3639 return status;
3640 }
3641
3642 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3643
3644 return QDF_STATUS_SUCCESS;
3645}
3646
3647/**
3648 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3649 * @wmi_handle: wmi handle
3650 * @param: p2p listen offload stop parameters
3651 *
3652 * Return: QDF status
3653 */
3654static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3655 uint8_t vdev_id)
3656{
3657 wmi_buf_t buf;
3658 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3659 int32_t len;
3660 QDF_STATUS status;
3661
3662 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3663
3664 len = sizeof(*cmd);
3665 buf = wmi_buf_alloc(wmi_handle, len);
3666 if (!buf) {
3667 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3668 __func__);
3669 return QDF_STATUS_E_NOMEM;
3670 }
3671 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3672
3673 WMITLV_SET_HDR(&cmd->tlv_header,
3674 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3675 WMITLV_GET_STRUCT_TLVLEN(
3676 wmi_p2p_lo_stop_cmd_fixed_param));
3677
3678 cmd->vdev_id = vdev_id;
3679
3680 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3681
3682 status = wmi_unified_cmd_send(wmi_handle,
3683 buf, len,
3684 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3685 if (status != QDF_STATUS_SUCCESS) {
3686 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3687 __func__, status);
3688 wmi_buf_free(buf);
3689 return status;
3690 }
3691
3692 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3693
3694 return QDF_STATUS_SUCCESS;
3695}
3696#endif /* End of CONVERGED_P2P_ENABLE */
3697
Govind Singh427ee5a2016-02-26 18:09:36 +05303698/**
3699 * send_get_temperature_cmd_tlv() - get pdev temperature req
3700 * @wmi_handle: wmi handle
3701 *
Govind Singhb53420c2016-03-09 14:32:57 +05303702 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303703 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303704static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303705{
3706 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3707 wmi_buf_t wmi_buf;
3708 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3709 uint8_t *buf_ptr;
3710
3711 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303712 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3713 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303714 }
3715
3716 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3717 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303718 WMI_LOGE(FL("wmi_buf_alloc failed"));
3719 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303720 }
3721
3722 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3723
3724 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3725 WMITLV_SET_HDR(&cmd->tlv_header,
3726 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3727 WMITLV_GET_STRUCT_TLVLEN
3728 (wmi_pdev_get_temperature_cmd_fixed_param));
3729
3730 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3731 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303732 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303733 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303734 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303735 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303736
Govind Singhb53420c2016-03-09 14:32:57 +05303737 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303738}
3739
3740/**
3741 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3742 * @wmi_handle: wmi handle
3743 * @vdevid: vdev id
3744 * @peer_addr: peer mac address
3745 * @auto_triggerparam: auto trigger parameters
3746 * @num_ac: number of access category
3747 *
3748 * This function sets the trigger
3749 * uapsd params such as service interval, delay interval
3750 * and suspend interval which will be used by the firmware
3751 * to send trigger frames periodically when there is no
3752 * traffic on the transmit side.
3753 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303754 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303755 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303756static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303757 struct sta_uapsd_trig_params *param)
3758{
3759 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303760 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303761 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3762 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3763 uint32_t i;
3764 wmi_buf_t buf;
3765 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003766 struct sta_uapsd_params *uapsd_param;
3767 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303768
3769 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3770 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303771 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303772 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303773 }
3774
3775 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3776 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3777 WMITLV_SET_HDR(&cmd->tlv_header,
3778 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3779 WMITLV_GET_STRUCT_TLVLEN
3780 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3781 cmd->vdev_id = param->vdevid;
3782 cmd->num_ac = param->num_ac;
3783 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3784
3785 /* TLV indicating array of structures to follow */
3786 buf_ptr += sizeof(*cmd);
3787 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3788
3789 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303790
3791 /*
3792 * Update tag and length for uapsd auto trigger params (this will take
3793 * care of updating tag and length if it is not pre-filled by caller).
3794 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003795 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3796 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303797 for (i = 0; i < param->num_ac; i++) {
3798 WMITLV_SET_HDR((buf_ptr +
3799 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3800 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3801 WMITLV_GET_STRUCT_TLVLEN
3802 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003803 trig_param->wmm_ac = uapsd_param->wmm_ac;
3804 trig_param->user_priority = uapsd_param->user_priority;
3805 trig_param->service_interval = uapsd_param->service_interval;
3806 trig_param->suspend_interval = uapsd_param->suspend_interval;
3807 trig_param->delay_interval = uapsd_param->delay_interval;
3808 trig_param++;
3809 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303810 }
3811
3812 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3813 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303814 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303815 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303816 wmi_buf_free(buf);
3817 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303818
Govind Singh427ee5a2016-02-26 18:09:36 +05303819 return ret;
3820}
3821
Zhang Qian11c0de32018-01-05 16:50:53 +08003822#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303823/**
3824 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3825 * @wmi_handle: pointer to the wmi handle
3826 * @utc: pointer to the UTC time struct
3827 *
3828 * Return: 0 on succes
3829 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303830static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303831 struct ocb_utc_param *utc)
3832{
Govind Singh67922e82016-04-01 16:48:57 +05303833 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303834 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3835 uint8_t *buf_ptr;
3836 uint32_t len, i;
3837 wmi_buf_t buf;
3838
3839 len = sizeof(*cmd);
3840 buf = wmi_buf_alloc(wmi_handle, len);
3841 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303842 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303843 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303844 }
3845
3846 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3847 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3848 WMITLV_SET_HDR(&cmd->tlv_header,
3849 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3850 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3851 cmd->vdev_id = utc->vdev_id;
3852
3853 for (i = 0; i < SIZE_UTC_TIME; i++)
3854 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3855
3856 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3857 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3858
3859 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3860 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303861 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303862 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303863 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303864 }
3865
Govind Singh67922e82016-04-01 16:48:57 +05303866 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303867}
3868
3869/**
3870 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3871 * frames on a channel
3872 * @wmi_handle: pointer to the wmi handle
3873 * @timing_advert: pointer to the timing advertisement struct
3874 *
3875 * Return: 0 on succes
3876 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303877static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303878 struct ocb_timing_advert_param *timing_advert)
3879{
Govind Singh67922e82016-04-01 16:48:57 +05303880 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303881 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3882 uint8_t *buf_ptr;
3883 uint32_t len, len_template;
3884 wmi_buf_t buf;
3885
3886 len = sizeof(*cmd) +
3887 WMI_TLV_HDR_SIZE;
3888
3889 len_template = timing_advert->template_length;
3890 /* Add padding to the template if needed */
3891 if (len_template % 4 != 0)
3892 len_template += 4 - (len_template % 4);
3893 len += len_template;
3894
3895 buf = wmi_buf_alloc(wmi_handle, len);
3896 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303897 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303898 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303899 }
3900
3901 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3902 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3903 WMITLV_SET_HDR(&cmd->tlv_header,
3904 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3905 WMITLV_GET_STRUCT_TLVLEN(
3906 wmi_ocb_start_timing_advert_cmd_fixed_param));
3907 cmd->vdev_id = timing_advert->vdev_id;
3908 cmd->repeat_rate = timing_advert->repeat_rate;
3909 cmd->channel_freq = timing_advert->chan_freq;
3910 cmd->timestamp_offset = timing_advert->timestamp_offset;
3911 cmd->time_value_offset = timing_advert->time_value_offset;
3912 cmd->timing_advert_template_length = timing_advert->template_length;
3913 buf_ptr += sizeof(*cmd);
3914
3915 /* Add the timing advert template */
3916 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3917 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303918 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303919 (uint8_t *)timing_advert->template_value,
3920 timing_advert->template_length);
3921
3922 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3923 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303924 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303925 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303926 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303927 }
3928
Govind Singh67922e82016-04-01 16:48:57 +05303929 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303930}
3931
3932/**
3933 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3934 * on a channel
3935 * @wmi_handle: pointer to the wmi handle
3936 * @timing_advert: pointer to the timing advertisement struct
3937 *
3938 * Return: 0 on succes
3939 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303940static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303941 struct ocb_timing_advert_param *timing_advert)
3942{
Govind Singh67922e82016-04-01 16:48:57 +05303943 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303944 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3945 uint8_t *buf_ptr;
3946 uint32_t len;
3947 wmi_buf_t buf;
3948
3949 len = sizeof(*cmd);
3950 buf = wmi_buf_alloc(wmi_handle, len);
3951 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303952 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303953 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303954 }
3955
3956 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3957 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3958 WMITLV_SET_HDR(&cmd->tlv_header,
3959 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3960 WMITLV_GET_STRUCT_TLVLEN(
3961 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3962 cmd->vdev_id = timing_advert->vdev_id;
3963 cmd->channel_freq = timing_advert->chan_freq;
3964
3965 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3966 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303967 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303968 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303969 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303970 }
3971
Govind Singh67922e82016-04-01 16:48:57 +05303972 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303973}
3974
3975/**
3976 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3977 * @wmi_handle: pointer to the wmi handle
3978 * @request: pointer to the request
3979 *
3980 * Return: 0 on succes
3981 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303982static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303983 uint8_t vdev_id)
3984{
Govind Singhb53420c2016-03-09 14:32:57 +05303985 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303986 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3987 uint8_t *buf_ptr;
3988 wmi_buf_t buf;
3989 int32_t len;
3990
3991 len = sizeof(*cmd);
3992 buf = wmi_buf_alloc(wmi_handle, len);
3993 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303994 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303995 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303996 }
3997 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3998
3999 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304000 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304001 WMITLV_SET_HDR(&cmd->tlv_header,
4002 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
4003 WMITLV_GET_STRUCT_TLVLEN(
4004 wmi_ocb_get_tsf_timer_cmd_fixed_param));
4005 cmd->vdev_id = vdev_id;
4006
4007 /* Send the WMI command */
4008 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4009 WMI_OCB_GET_TSF_TIMER_CMDID);
4010 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304011 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304012 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304013 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304014 }
4015
Govind Singh67922e82016-04-01 16:48:57 +05304016 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304017}
4018
4019/**
4020 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
4021 * @wmi_handle: pointer to the wmi handle
4022 * @get_stats_param: pointer to the dcc stats
4023 *
4024 * Return: 0 on succes
4025 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304026static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004027 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304028{
Govind Singh67922e82016-04-01 16:48:57 +05304029 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304030 wmi_dcc_get_stats_cmd_fixed_param *cmd;
4031 wmi_dcc_channel_stats_request *channel_stats_array;
4032 wmi_buf_t buf;
4033 uint8_t *buf_ptr;
4034 uint32_t len;
4035 uint32_t i;
4036
4037 /* Validate the input */
4038 if (get_stats_param->request_array_len !=
4039 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304040 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304041 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304042 }
4043
4044 /* Allocate memory for the WMI command */
4045 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4046 get_stats_param->request_array_len;
4047
4048 buf = wmi_buf_alloc(wmi_handle, len);
4049 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304050 WMI_LOGE(FL("wmi_buf_alloc failed"));
4051 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304052 }
4053
4054 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304055 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304056
4057 /* Populate the WMI command */
4058 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4059 buf_ptr += sizeof(*cmd);
4060
4061 WMITLV_SET_HDR(&cmd->tlv_header,
4062 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4063 WMITLV_GET_STRUCT_TLVLEN(
4064 wmi_dcc_get_stats_cmd_fixed_param));
4065 cmd->vdev_id = get_stats_param->vdev_id;
4066 cmd->num_channels = get_stats_param->channel_count;
4067
4068 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4069 get_stats_param->request_array_len);
4070 buf_ptr += WMI_TLV_HDR_SIZE;
4071
4072 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304073 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304074 get_stats_param->request_array_len);
4075 for (i = 0; i < cmd->num_channels; i++)
4076 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4077 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4078 WMITLV_GET_STRUCT_TLVLEN(
4079 wmi_dcc_channel_stats_request));
4080
4081 /* Send the WMI command */
4082 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4083 WMI_DCC_GET_STATS_CMDID);
4084
Govind Singh67922e82016-04-01 16:48:57 +05304085 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304086 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304087 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304088 }
4089
Govind Singh67922e82016-04-01 16:48:57 +05304090 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304091}
4092
4093/**
4094 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4095 * @wmi_handle: pointer to the wmi handle
4096 * @vdev_id: vdev id
4097 * @dcc_stats_bitmap: dcc status bitmap
4098 *
4099 * Return: 0 on succes
4100 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304101static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304102 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4103{
Govind Singh67922e82016-04-01 16:48:57 +05304104 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304105 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4106 wmi_buf_t buf;
4107 uint8_t *buf_ptr;
4108 uint32_t len;
4109
4110 /* Allocate memory for the WMI command */
4111 len = sizeof(*cmd);
4112
4113 buf = wmi_buf_alloc(wmi_handle, len);
4114 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304115 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304116 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304117 }
4118
4119 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304120 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304121
4122 /* Populate the WMI command */
4123 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4124
4125 WMITLV_SET_HDR(&cmd->tlv_header,
4126 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4127 WMITLV_GET_STRUCT_TLVLEN(
4128 wmi_dcc_clear_stats_cmd_fixed_param));
4129 cmd->vdev_id = vdev_id;
4130 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4131
4132 /* Send the WMI command */
4133 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4134 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304135 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304136 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304137 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304138 }
4139
Govind Singh67922e82016-04-01 16:48:57 +05304140 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304141}
4142
4143/**
4144 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4145 * @wmi_handle: pointer to the wmi handle
4146 * @update_ndl_param: pointer to the request parameters
4147 *
4148 * Return: 0 on success
4149 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304150static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004151 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304152{
Govind Singhb53420c2016-03-09 14:32:57 +05304153 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304154 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4155 wmi_dcc_ndl_chan *ndl_chan_array;
4156 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4157 uint32_t active_state_count;
4158 wmi_buf_t buf;
4159 uint8_t *buf_ptr;
4160 uint32_t len;
4161 uint32_t i;
4162
4163 /* validate the input */
4164 if (update_ndl_param->dcc_ndl_chan_list_len !=
4165 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304166 WMI_LOGE(FL("Invalid parameter"));
4167 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304168 }
4169 active_state_count = 0;
4170 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4171 for (i = 0; i < update_ndl_param->channel_count; i++)
4172 active_state_count +=
4173 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4174 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4175 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304176 WMI_LOGE(FL("Invalid parameter"));
4177 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304178 }
4179
4180 /* Allocate memory for the WMI command */
4181 len = sizeof(*cmd) +
4182 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4183 WMI_TLV_HDR_SIZE +
4184 update_ndl_param->dcc_ndl_active_state_list_len;
4185
4186 buf = wmi_buf_alloc(wmi_handle, len);
4187 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304188 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304189 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304190 }
4191
4192 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304193 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304194
4195 /* Populate the WMI command */
4196 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4197 buf_ptr += sizeof(*cmd);
4198
4199 WMITLV_SET_HDR(&cmd->tlv_header,
4200 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4201 WMITLV_GET_STRUCT_TLVLEN(
4202 wmi_dcc_update_ndl_cmd_fixed_param));
4203 cmd->vdev_id = update_ndl_param->vdev_id;
4204 cmd->num_channel = update_ndl_param->channel_count;
4205
4206 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4207 update_ndl_param->dcc_ndl_chan_list_len);
4208 buf_ptr += WMI_TLV_HDR_SIZE;
4209
4210 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304211 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304212 update_ndl_param->dcc_ndl_chan_list_len);
4213 for (i = 0; i < cmd->num_channel; i++)
4214 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4215 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4216 WMITLV_GET_STRUCT_TLVLEN(
4217 wmi_dcc_ndl_chan));
4218 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4219
4220 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4221 update_ndl_param->dcc_ndl_active_state_list_len);
4222 buf_ptr += WMI_TLV_HDR_SIZE;
4223
4224 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304225 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304226 update_ndl_param->dcc_ndl_active_state_list,
4227 update_ndl_param->dcc_ndl_active_state_list_len);
4228 for (i = 0; i < active_state_count; i++) {
4229 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4230 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4231 WMITLV_GET_STRUCT_TLVLEN(
4232 wmi_dcc_ndl_active_state_config));
4233 }
4234 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4235
4236 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304237 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304238 WMI_DCC_UPDATE_NDL_CMDID);
4239 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304240 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304241 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304242 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304243 }
4244
Govind Singh67922e82016-04-01 16:48:57 +05304245 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304246}
4247
4248/**
4249 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4250 * @wmi_handle: pointer to the wmi handle
4251 * @config: the OCB configuration
4252 *
4253 * Return: 0 on success
4254 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304255static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004256 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304257{
Govind Singh67922e82016-04-01 16:48:57 +05304258 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304259 wmi_ocb_set_config_cmd_fixed_param *cmd;
4260 wmi_channel *chan;
4261 wmi_ocb_channel *ocb_chan;
4262 wmi_qos_parameter *qos_param;
4263 wmi_dcc_ndl_chan *ndl_chan;
4264 wmi_dcc_ndl_active_state_config *ndl_active_config;
4265 wmi_ocb_schedule_element *sched_elem;
4266 uint8_t *buf_ptr;
4267 wmi_buf_t buf;
4268 int32_t len;
4269 int32_t i, j, active_state_count;
4270
4271 /*
4272 * Validate the dcc_ndl_chan_list_len and count the number of active
4273 * states. Validate dcc_ndl_active_state_list_len.
4274 */
4275 active_state_count = 0;
4276 if (config->dcc_ndl_chan_list_len) {
4277 if (!config->dcc_ndl_chan_list ||
4278 config->dcc_ndl_chan_list_len !=
4279 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304280 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304281 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304282 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304283 }
4284
4285 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4286 i < config->channel_count; ++i, ++ndl_chan)
4287 active_state_count +=
4288 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4289
4290 if (active_state_count) {
4291 if (!config->dcc_ndl_active_state_list ||
4292 config->dcc_ndl_active_state_list_len !=
4293 active_state_count *
4294 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304295 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304296 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304297 }
4298 }
4299 }
4300
4301 len = sizeof(*cmd) +
4302 WMI_TLV_HDR_SIZE + config->channel_count *
4303 sizeof(wmi_channel) +
4304 WMI_TLV_HDR_SIZE + config->channel_count *
4305 sizeof(wmi_ocb_channel) +
4306 WMI_TLV_HDR_SIZE + config->channel_count *
4307 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4308 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4309 WMI_TLV_HDR_SIZE + active_state_count *
4310 sizeof(wmi_dcc_ndl_active_state_config) +
4311 WMI_TLV_HDR_SIZE + config->schedule_size *
4312 sizeof(wmi_ocb_schedule_element);
4313 buf = wmi_buf_alloc(wmi_handle, len);
4314 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304315 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304316 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304317 }
4318
4319 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4320 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4321 WMITLV_SET_HDR(&cmd->tlv_header,
4322 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4323 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004324 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304325 cmd->channel_count = config->channel_count;
4326 cmd->schedule_size = config->schedule_size;
4327 cmd->flags = config->flags;
4328 buf_ptr += sizeof(*cmd);
4329
4330 /* Add the wmi_channel info */
4331 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4332 config->channel_count*sizeof(wmi_channel));
4333 buf_ptr += WMI_TLV_HDR_SIZE;
4334 for (i = 0; i < config->channel_count; i++) {
4335 chan = (wmi_channel *)buf_ptr;
4336 WMITLV_SET_HDR(&chan->tlv_header,
4337 WMITLV_TAG_STRUC_wmi_channel,
4338 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4339 chan->mhz = config->channels[i].chan_freq;
4340 chan->band_center_freq1 = config->channels[i].chan_freq;
4341 chan->band_center_freq2 = 0;
4342 chan->info = 0;
4343
Zhang Qian11c0de32018-01-05 16:50:53 +08004344 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304345 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4346 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4347 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4348 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4349 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4350 config->channels[i].antenna_max);
4351
4352 if (config->channels[i].bandwidth < 10)
4353 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4354 else if (config->channels[i].bandwidth < 20)
4355 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4356 buf_ptr += sizeof(*chan);
4357 }
4358
4359 /* Add the wmi_ocb_channel info */
4360 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4361 config->channel_count*sizeof(wmi_ocb_channel));
4362 buf_ptr += WMI_TLV_HDR_SIZE;
4363 for (i = 0; i < config->channel_count; i++) {
4364 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4365 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4366 WMITLV_TAG_STRUC_wmi_ocb_channel,
4367 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4368 ocb_chan->bandwidth = config->channels[i].bandwidth;
4369 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4370 config->channels[i].mac_address.bytes,
4371 &ocb_chan->mac_address);
4372 buf_ptr += sizeof(*ocb_chan);
4373 }
4374
4375 /* Add the wmi_qos_parameter info */
4376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4377 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4378 buf_ptr += WMI_TLV_HDR_SIZE;
4379 /* WMI_MAX_NUM_AC parameters for each channel */
4380 for (i = 0; i < config->channel_count; i++) {
4381 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4382 qos_param = (wmi_qos_parameter *)buf_ptr;
4383 WMITLV_SET_HDR(&qos_param->tlv_header,
4384 WMITLV_TAG_STRUC_wmi_qos_parameter,
4385 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4386 qos_param->aifsn =
4387 config->channels[i].qos_params[j].aifsn;
4388 qos_param->cwmin =
4389 config->channels[i].qos_params[j].cwmin;
4390 qos_param->cwmax =
4391 config->channels[i].qos_params[j].cwmax;
4392 buf_ptr += sizeof(*qos_param);
4393 }
4394 }
4395
4396 /* Add the wmi_dcc_ndl_chan (per channel) */
4397 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4398 config->dcc_ndl_chan_list_len);
4399 buf_ptr += WMI_TLV_HDR_SIZE;
4400 if (config->dcc_ndl_chan_list_len) {
4401 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304402 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304403 config->dcc_ndl_chan_list_len);
4404 for (i = 0; i < config->channel_count; i++)
4405 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4406 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4407 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4408 buf_ptr += config->dcc_ndl_chan_list_len;
4409 }
4410
4411 /* Add the wmi_dcc_ndl_active_state_config */
4412 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4413 sizeof(wmi_dcc_ndl_active_state_config));
4414 buf_ptr += WMI_TLV_HDR_SIZE;
4415 if (active_state_count) {
4416 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304417 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304418 config->dcc_ndl_active_state_list,
4419 active_state_count * sizeof(*ndl_active_config));
4420 for (i = 0; i < active_state_count; ++i)
4421 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4422 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4423 WMITLV_GET_STRUCT_TLVLEN(
4424 wmi_dcc_ndl_active_state_config));
4425 buf_ptr += active_state_count *
4426 sizeof(*ndl_active_config);
4427 }
4428
4429 /* Add the wmi_ocb_schedule_element info */
4430 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4431 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4432 buf_ptr += WMI_TLV_HDR_SIZE;
4433 for (i = 0; i < config->schedule_size; i++) {
4434 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4435 WMITLV_SET_HDR(&sched_elem->tlv_header,
4436 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4437 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4438 sched_elem->channel_freq = config->schedule[i].chan_freq;
4439 sched_elem->total_duration = config->schedule[i].total_duration;
4440 sched_elem->guard_interval = config->schedule[i].guard_interval;
4441 buf_ptr += sizeof(*sched_elem);
4442 }
4443
4444
4445 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4446 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304447 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304448 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304449 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304450 }
4451
Govind Singh67922e82016-04-01 16:48:57 +05304452 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304453}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304454
4455/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004456 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4457 * @wmi_handle: wmi handle
4458 * @evt_buf: wmi event buffer
4459 * @status: status buffer
4460 *
4461 * Return: QDF_STATUS_SUCCESS on success
4462 */
4463static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4464 void *evt_buf,
4465 uint32_t *status)
4466{
4467 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4468 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4469
4470 param_tlvs = evt_buf;
4471 fix_param = param_tlvs->fixed_param;
4472
4473 *status = fix_param->status;
4474 return QDF_STATUS_SUCCESS;
4475}
4476
4477/**
4478 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4479 * @wmi_handle: wmi handle
4480 * @evt_buf: wmi event buffer
4481 * @resp: response buffer
4482 *
4483 * Return: QDF_STATUS_SUCCESS on success
4484 */
4485static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4486 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4487{
4488 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4489 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4490
4491 param_tlvs = evt_buf;
4492 fix_param = param_tlvs->fixed_param;
4493 resp->vdev_id = fix_param->vdev_id;
4494 resp->timer_high = fix_param->tsf_timer_high;
4495 resp->timer_low = fix_param->tsf_timer_low;
4496
4497 return QDF_STATUS_SUCCESS;
4498}
4499
4500/**
4501 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4502 * @wmi_handle: wmi handle
4503 * @evt_buf: wmi event buffer
4504 * @resp: response buffer
4505 *
4506 * Return: QDF_STATUS_SUCCESS on success
4507 */
4508static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4509 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4510{
4511 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4512 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4513
4514 param_tlvs = evt_buf;
4515 fix_param = param_tlvs->fixed_param;
4516 resp->vdev_id = fix_param->vdev_id;
4517 resp->status = fix_param->status;
4518 return QDF_STATUS_SUCCESS;
4519}
4520
4521/**
4522 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4523 * @wmi_handle: wmi handle
4524 * @evt_buf: wmi event buffer
4525 * @resp: response buffer
4526 *
4527 * Since length of stats is variable, buffer for DCC stats will be allocated
4528 * in this function. The caller must free the buffer.
4529 *
4530 * Return: QDF_STATUS_SUCCESS on success
4531 */
4532static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4533 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4534{
4535 struct ocb_dcc_get_stats_response *response;
4536 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4537 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4538
4539 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4540 fix_param = param_tlvs->fixed_param;
4541
4542 /* Allocate and populate the response */
4543 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4544 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4545 WMI_LOGE("%s: too many channels:%d", __func__,
4546 fix_param->num_channels);
4547 QDF_ASSERT(0);
4548 *resp = NULL;
4549 return QDF_STATUS_E_INVAL;
4550 }
4551 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4552 sizeof(wmi_dcc_ndl_stats_per_channel));
4553 *resp = response;
4554 if (!response)
4555 return QDF_STATUS_E_NOMEM;
4556
4557 response->vdev_id = fix_param->vdev_id;
4558 response->num_channels = fix_param->num_channels;
4559 response->channel_stats_array_len =
4560 fix_param->num_channels *
4561 sizeof(wmi_dcc_ndl_stats_per_channel);
4562 response->channel_stats_array = ((uint8_t *)response) +
4563 sizeof(*response);
4564 qdf_mem_copy(response->channel_stats_array,
4565 param_tlvs->stats_per_channel_list,
4566 response->channel_stats_array_len);
4567
4568 return QDF_STATUS_SUCCESS;
4569}
4570#endif
4571
4572/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304573 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4574 * @wmi_handle: wmi handle
4575 * @mcc_adaptive_scheduler: enable/disable
4576 *
4577 * This function enable/disable mcc adaptive scheduler in fw.
4578 *
Govind Singhb53420c2016-03-09 14:32:57 +05304579 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304580 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304581static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004582 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4583 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304584{
Govind Singh67922e82016-04-01 16:48:57 +05304585 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304586 wmi_buf_t buf = 0;
4587 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4588 uint16_t len =
4589 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4590
4591 buf = wmi_buf_alloc(wmi_handle, len);
4592 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304593 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4594 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304595 }
4596 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4597 wmi_buf_data(buf);
4598
4599 WMITLV_SET_HDR(&cmd->tlv_header,
4600 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4601 WMITLV_GET_STRUCT_TLVLEN
4602 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4603 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304604 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304605
4606 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4607 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304608 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304609 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304610 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304611 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304612 }
Govind Singh67922e82016-04-01 16:48:57 +05304613
4614 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304615}
4616
4617/**
4618 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4619 * @wmi: wmi handle
4620 * @mcc_channel: mcc channel
4621 * @mcc_channel_time_latency: MCC channel time latency.
4622 *
4623 * Currently used to set time latency for an MCC vdev/adapter using operating
4624 * channel of it and channel number. The info is provided run time using
4625 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4626 *
4627 * Return: CDF status
4628 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304629static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304630 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4631{
Govind Singh67922e82016-04-01 16:48:57 +05304632 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304633 wmi_buf_t buf = 0;
4634 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4635 uint16_t len = 0;
4636 uint8_t *buf_ptr = NULL;
4637 wmi_resmgr_chan_latency chan_latency;
4638 /* Note: we only support MCC time latency for a single channel */
4639 uint32_t num_channels = 1;
4640 uint32_t chan1_freq = mcc_channel_freq;
4641 uint32_t latency_chan1 = mcc_channel_time_latency;
4642
4643
4644 /* If 0ms latency is provided, then FW will set to a default.
4645 * Otherwise, latency must be at least 30ms.
4646 */
4647 if ((latency_chan1 > 0) &&
4648 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304649 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304650 "Minimum is 30ms (or 0 to use default value by "
4651 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304652 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304653 }
4654
4655 /* Set WMI CMD for channel time latency here */
4656 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4657 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4658 num_channels * sizeof(wmi_resmgr_chan_latency);
4659 buf = wmi_buf_alloc(wmi_handle, len);
4660 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304661 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4662 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304663 }
4664 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4665 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4666 wmi_buf_data(buf);
4667 WMITLV_SET_HDR(&cmdTL->tlv_header,
4668 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4669 WMITLV_GET_STRUCT_TLVLEN
4670 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4671 cmdTL->num_chans = num_channels;
4672 /* Update channel time latency information for home channel(s) */
4673 buf_ptr += sizeof(*cmdTL);
4674 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4675 num_channels * sizeof(wmi_resmgr_chan_latency));
4676 buf_ptr += WMI_TLV_HDR_SIZE;
4677 chan_latency.chan_mhz = chan1_freq;
4678 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304679 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304680 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4681 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304682 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304683 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304684 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304685 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304686 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304687 }
Govind Singh67922e82016-04-01 16:48:57 +05304688
4689 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304690}
4691
4692/**
4693 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4694 * @wmi: wmi handle
4695 * @adapter_1_chan_number: adapter 1 channel number
4696 * @adapter_1_quota: adapter 1 quota
4697 * @adapter_2_chan_number: adapter 2 channel number
4698 *
4699 * Return: CDF status
4700 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304701static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304702 uint32_t adapter_1_chan_freq,
4703 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4704{
Govind Singh67922e82016-04-01 16:48:57 +05304705 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304706 wmi_buf_t buf = 0;
4707 uint16_t len = 0;
4708 uint8_t *buf_ptr = NULL;
4709 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4710 wmi_resmgr_chan_time_quota chan_quota;
4711 uint32_t quota_chan1 = adapter_1_quota;
4712 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4713 uint32_t quota_chan2 = 100 - quota_chan1;
4714 /* Note: setting time quota for MCC requires info for 2 channels */
4715 uint32_t num_channels = 2;
4716 uint32_t chan1_freq = adapter_1_chan_freq;
4717 uint32_t chan2_freq = adapter_2_chan_freq;
4718
Govind Singhb53420c2016-03-09 14:32:57 +05304719 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304720 "freq2:%dMHz, Quota2:%dms", __func__,
4721 chan1_freq, quota_chan1, chan2_freq,
4722 quota_chan2);
4723
4724 /*
4725 * Perform sanity check on time quota values provided.
4726 */
4727 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4728 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304729 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304730 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304731 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304732 }
4733 /* Set WMI CMD for channel time quota here */
4734 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4735 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4736 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4737 buf = wmi_buf_alloc(wmi_handle, len);
4738 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304739 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4740 QDF_ASSERT(0);
4741 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304742 }
4743 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4744 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4745 wmi_buf_data(buf);
4746 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4747 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4748 WMITLV_GET_STRUCT_TLVLEN
4749 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4750 cmdTQ->num_chans = num_channels;
4751
4752 /* Update channel time quota information for home channel(s) */
4753 buf_ptr += sizeof(*cmdTQ);
4754 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4755 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4756 buf_ptr += WMI_TLV_HDR_SIZE;
4757 chan_quota.chan_mhz = chan1_freq;
4758 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304759 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304760 /* Construct channel and quota record for the 2nd MCC mode. */
4761 buf_ptr += sizeof(chan_quota);
4762 chan_quota.chan_mhz = chan2_freq;
4763 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304764 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304765
4766 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4767 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304768 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304769 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304770 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304771 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304772 }
Govind Singh67922e82016-04-01 16:48:57 +05304773
4774 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304775}
4776
4777/**
4778 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4779 * @wmi_handle: Pointer to wmi handle
4780 * @thermal_info: Thermal command information
4781 *
4782 * This function sends the thermal management command
4783 * to the firmware
4784 *
Govind Singhb53420c2016-03-09 14:32:57 +05304785 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304786 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304787static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304788 struct thermal_cmd_params *thermal_info)
4789{
4790 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4791 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304792 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304793 uint32_t len = 0;
4794
4795 len = sizeof(*cmd);
4796
4797 buf = wmi_buf_alloc(wmi_handle, len);
4798 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304799 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4800 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304801 }
4802
4803 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4804
4805 WMITLV_SET_HDR(&cmd->tlv_header,
4806 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4807 WMITLV_GET_STRUCT_TLVLEN
4808 (wmi_thermal_mgmt_cmd_fixed_param));
4809
4810 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4811 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4812 cmd->enable = thermal_info->thermal_enable;
4813
Govind Singhb53420c2016-03-09 14:32:57 +05304814 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304815 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4816
4817 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4818 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304819 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304820 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304821 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304822 }
4823
Govind Singh67922e82016-04-01 16:48:57 +05304824 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304825}
4826
4827
4828/**
4829 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304830 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304831 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4832 *
4833 * This function sends down the LRO configuration parameters to
4834 * the firmware to enable LRO, sets the TCP flags and sets the
4835 * seed values for the toeplitz hash generation
4836 *
Govind Singhb53420c2016-03-09 14:32:57 +05304837 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304838 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304839static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304840 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4841{
4842 wmi_lro_info_cmd_fixed_param *cmd;
4843 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304844 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304845
4846
4847 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4848 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304849 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4850 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304851 }
4852
4853 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4854
4855 WMITLV_SET_HDR(&cmd->tlv_header,
4856 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4857 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4858
4859 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4860 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4861 wmi_lro_cmd->tcp_flag);
4862 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4863 wmi_lro_cmd->tcp_flag_mask);
4864 cmd->toeplitz_hash_ipv4_0_3 =
4865 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4866 cmd->toeplitz_hash_ipv4_4_7 =
4867 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4868 cmd->toeplitz_hash_ipv4_8_11 =
4869 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4870 cmd->toeplitz_hash_ipv4_12_15 =
4871 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4872 cmd->toeplitz_hash_ipv4_16 =
4873 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4874
4875 cmd->toeplitz_hash_ipv6_0_3 =
4876 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4877 cmd->toeplitz_hash_ipv6_4_7 =
4878 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4879 cmd->toeplitz_hash_ipv6_8_11 =
4880 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4881 cmd->toeplitz_hash_ipv6_12_15 =
4882 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4883 cmd->toeplitz_hash_ipv6_16_19 =
4884 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4885 cmd->toeplitz_hash_ipv6_20_23 =
4886 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4887 cmd->toeplitz_hash_ipv6_24_27 =
4888 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4889 cmd->toeplitz_hash_ipv6_28_31 =
4890 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4891 cmd->toeplitz_hash_ipv6_32_35 =
4892 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4893 cmd->toeplitz_hash_ipv6_36_39 =
4894 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4895 cmd->toeplitz_hash_ipv6_40 =
4896 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4897
Govind Singhb53420c2016-03-09 14:32:57 +05304898 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304899 cmd->lro_enable, cmd->tcp_flag_u32);
4900
4901 status = wmi_unified_cmd_send(wmi_handle, buf,
4902 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304903 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304904 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304905 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304906 }
4907
Govind Singh67922e82016-04-01 16:48:57 +05304908 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304909}
4910
Govind Singh4eacd2b2016-03-07 14:24:22 +05304911/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304912 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4913 * @wmi_handle: Pointer to wmi handle
4914 * @rate_report_params: Pointer to peer rate report parameters
4915 *
4916 *
4917 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4918 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304919static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304920 struct wmi_peer_rate_report_params *rate_report_params)
4921{
4922 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4923 wmi_buf_t buf = NULL;
4924 QDF_STATUS status = 0;
4925 uint32_t len = 0;
4926 uint32_t i, j;
4927
4928 len = sizeof(*cmd);
4929
4930 buf = wmi_buf_alloc(wmi_handle, len);
4931 if (!buf) {
4932 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4933 return QDF_STATUS_E_FAILURE;
4934 }
4935
4936 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4937 wmi_buf_data(buf);
4938
4939 WMITLV_SET_HDR(
4940 &cmd->tlv_header,
4941 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4942 WMITLV_GET_STRUCT_TLVLEN(
4943 wmi_peer_set_rate_report_condition_fixed_param));
4944
4945 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4946 cmd->report_backoff_time = rate_report_params->backoff_time;
4947 cmd->report_timer_period = rate_report_params->timer_period;
4948 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4949 cmd->cond_per_phy[i].val_cond_flags =
4950 rate_report_params->report_per_phy[i].cond_flags;
4951 cmd->cond_per_phy[i].rate_delta.min_delta =
4952 rate_report_params->report_per_phy[i].delta.delta_min;
4953 cmd->cond_per_phy[i].rate_delta.percentage =
4954 rate_report_params->report_per_phy[i].delta.percent;
4955 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4956 cmd->cond_per_phy[i].rate_threshold[j] =
4957 rate_report_params->report_per_phy[i].
4958 report_rate_threshold[j];
4959 }
4960 }
4961
4962 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4963 cmd->enable_rate_report,
4964 cmd->report_backoff_time, cmd->report_timer_period);
4965
4966 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4967 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4968 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304969 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304970 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4971 __func__);
4972 }
4973 return status;
4974}
4975
4976/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304977 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4978 * @wmi_handle: wmi handle
4979 * @param: bcn ll cmd parameter
4980 *
Govind Singhb53420c2016-03-09 14:32:57 +05304981 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304982 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304983static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304984 wmi_bcn_send_from_host_cmd_fixed_param *param)
4985{
4986 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4987 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304988 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304989
4990 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4991 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304992 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4993 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304994 }
4995
4996 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4997 WMITLV_SET_HDR(&cmd->tlv_header,
4998 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4999 WMITLV_GET_STRUCT_TLVLEN
5000 (wmi_bcn_send_from_host_cmd_fixed_param));
5001 cmd->vdev_id = param->vdev_id;
5002 cmd->data_len = param->data_len;
5003 cmd->frame_ctrl = param->frame_ctrl;
5004 cmd->frag_ptr = param->frag_ptr;
5005 cmd->dtim_flag = param->dtim_flag;
5006
5007 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
5008 WMI_PDEV_SEND_BCN_CMDID);
5009
Govind Singh67922e82016-04-01 16:48:57 +05305010 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305011 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305012 wmi_buf_free(wmi_buf);
5013 }
5014
5015 return ret;
5016}
5017
5018/**
5019 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
5020 * @wmi_handle: wmi handle
5021 * @vdev_id: vdev id
5022 * @max_retries: max retries
5023 * @retry_interval: retry interval
5024 * This function sets sta query related parameters in fw.
5025 *
Govind Singhb53420c2016-03-09 14:32:57 +05305026 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305027 */
5028
Sathish Kumarfd347372017-02-13 12:29:09 +05305029static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305030 uint8_t vdev_id, uint32_t max_retries,
5031 uint32_t retry_interval)
5032{
5033 wmi_buf_t buf;
5034 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5035 int len;
5036
5037 len = sizeof(*cmd);
5038 buf = wmi_buf_alloc(wmi_handle, len);
5039 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305040 WMI_LOGE(FL("wmi_buf_alloc failed"));
5041 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305042 }
5043
5044 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5045 WMITLV_SET_HDR(&cmd->tlv_header,
5046 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5047 WMITLV_GET_STRUCT_TLVLEN
5048 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5049
5050
5051 cmd->vdev_id = vdev_id;
5052 cmd->sa_query_max_retry_count = max_retries;
5053 cmd->sa_query_retry_interval = retry_interval;
5054
Govind Singhb53420c2016-03-09 14:32:57 +05305055 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305056 vdev_id, retry_interval, max_retries);
5057
5058 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5059 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305060 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305061 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305062 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305063 }
5064
Govind Singhb53420c2016-03-09 14:32:57 +05305065 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305066 return 0;
5067}
5068
5069/**
5070 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5071 * @wmi_handle: wmi handle
5072 * @params: sta keep alive parameter
5073 *
5074 * This function sets keep alive related parameters in fw.
5075 *
5076 * Return: CDF status
5077 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305078static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305079 struct sta_params *params)
5080{
5081 wmi_buf_t buf;
5082 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5083 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5084 uint8_t *buf_ptr;
5085 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305086 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305087
Govind Singhb53420c2016-03-09 14:32:57 +05305088 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305089
Govind Singh4eacd2b2016-03-07 14:24:22 +05305090 len = sizeof(*cmd) + sizeof(*arp_rsp);
5091 buf = wmi_buf_alloc(wmi_handle, len);
5092 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305093 WMI_LOGE("wmi_buf_alloc failed");
5094 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305095 }
5096
5097 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5098 buf_ptr = (uint8_t *) cmd;
5099 WMITLV_SET_HDR(&cmd->tlv_header,
5100 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5101 WMITLV_GET_STRUCT_TLVLEN
5102 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5103 cmd->interval = params->timeperiod;
5104 cmd->enable = (params->timeperiod) ? 1 : 0;
5105 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305106 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305107 params->timeperiod, params->method);
5108 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5109 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5110 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5111 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5112
c_manjee2772b9c2017-01-23 15:14:13 +05305113 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5114 (params->method ==
5115 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305116 if ((NULL == params->hostv4addr) ||
5117 (NULL == params->destv4addr) ||
5118 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005119 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5120 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305121 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305122 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305123 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305124 }
c_manjee2772b9c2017-01-23 15:14:13 +05305125 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305126 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305127 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305128 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305129 WMI_IPV4_ADDR_LEN);
5130 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5131 } else {
5132 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5133 }
5134
Govind Singh67922e82016-04-01 16:48:57 +05305135 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5136 WMI_STA_KEEPALIVE_CMDID);
5137 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305138 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305139 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305140 }
5141
Govind Singhb53420c2016-03-09 14:32:57 +05305142 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305143 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305144}
5145
5146/**
5147 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5148 * @wmi_handle: wmi handle
5149 * @if_id: vdev id
5150 * @gtx_info: GTX config params
5151 *
5152 * This function set GTX related params in firmware.
5153 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305154 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305155 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305156static 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 +05305157 struct wmi_gtx_config *gtx_info)
5158{
5159 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5160 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305161 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305162 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305163
Govind Singh4eacd2b2016-03-07 14:24:22 +05305164 buf = wmi_buf_alloc(wmi_handle, len);
5165 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305166 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305167 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305168 }
5169 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5170 WMITLV_SET_HDR(&cmd->tlv_header,
5171 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5172 WMITLV_GET_STRUCT_TLVLEN
5173 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5174 cmd->vdev_id = if_id;
5175
5176 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5177 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5178 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5179 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5180 cmd->gtxPERMargin = gtx_info->gtx_margin;
5181 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5182 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5183 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5184
Govind Singhb53420c2016-03-09 14:32:57 +05305185 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305186 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5187 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5188 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5189 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5190
Abhishek Singh716c46c2016-05-04 16:24:07 +05305191 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305192 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305193 if (QDF_IS_STATUS_ERROR(ret)) {
5194 WMI_LOGE("Failed to set GTX PARAMS");
5195 wmi_buf_free(buf);
5196 }
5197 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305198}
5199
5200/**
5201 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5202 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305203 * @vdev_id: vdev id.
5204 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305205 *
5206 * This function updates EDCA parameters to the target
5207 *
5208 * Return: CDF Status
5209 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305210static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305211 uint8_t vdev_id,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305212 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305213{
5214 uint8_t *buf_ptr;
5215 wmi_buf_t buf;
5216 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305217 wmi_wmm_vparams *wmm_param;
5218 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305219 int len = sizeof(*cmd);
5220 int ac;
5221
5222 buf = wmi_buf_alloc(wmi_handle, len);
5223
5224 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305225 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5226 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305227 }
5228
5229 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5230 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5231 WMITLV_SET_HDR(&cmd->tlv_header,
5232 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5233 WMITLV_GET_STRUCT_TLVLEN
5234 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5235 cmd->vdev_id = vdev_id;
5236
5237 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5238 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305239 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305240 WMITLV_SET_HDR(&wmm_param->tlv_header,
5241 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5242 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5243 wmm_param->cwmin = twmm_param->cwmin;
5244 wmm_param->cwmax = twmm_param->cwmax;
5245 wmm_param->aifs = twmm_param->aifs;
5246 wmm_param->txoplimit = twmm_param->txoplimit;
5247 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305248 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305249 }
5250
5251 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5252 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5253 goto fail;
5254
Govind Singhb53420c2016-03-09 14:32:57 +05305255 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305256
5257fail:
5258 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305259 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5260 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305261}
5262
5263/**
5264 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5265 * @wmi_handle: wmi handle
5266 * @vdev_id: vdev id
5267 * @probe_rsp_info: probe response info
5268 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305269 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305270 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305271static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305272 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005273 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305274{
5275 wmi_prb_tmpl_cmd_fixed_param *cmd;
5276 wmi_bcn_prb_info *bcn_prb_info;
5277 wmi_buf_t wmi_buf;
5278 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5279 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305280 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305281
Govind Singhb53420c2016-03-09 14:32:57 +05305282 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305283
Krunal Soni89426862017-11-14 15:42:48 -08005284 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305285 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
5286
5287 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5288 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5289 tmpl_len_aligned;
5290
5291 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305292 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305293 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305294 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305295 }
5296
5297 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5298 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305299 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305300 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305301 }
5302
5303 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5304
5305 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5306 WMITLV_SET_HDR(&cmd->tlv_header,
5307 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5308 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5309 cmd->vdev_id = vdev_id;
5310 cmd->buf_len = tmpl_len;
5311 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5312
5313 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5314 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5315 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5316 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5317 bcn_prb_info->caps = 0;
5318 bcn_prb_info->erp = 0;
5319 buf_ptr += sizeof(wmi_bcn_prb_info);
5320
5321 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5322 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005323 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305324
5325 ret = wmi_unified_cmd_send(wmi_handle,
5326 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305327 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305328 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305329 wmi_buf_free(wmi_buf);
5330 }
5331
5332 return ret;
5333}
5334
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305335#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305336#define WPI_IV_LEN 16
5337
5338/**
5339 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5340 *
5341 * @dest_tx: destination address of tsc key counter
5342 * @src_tx: source address of tsc key counter
5343 * @dest_rx: destination address of rsc key counter
5344 * @src_rx: source address of rsc key counter
5345 *
5346 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5347 *
5348 * Return: None
5349 *
5350 */
5351static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5352 uint8_t *dest_rx, uint8_t *src_rx)
5353{
5354 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5355 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5356}
5357#else
5358static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5359 uint8_t *dest_rx, uint8_t *src_rx)
5360{
5361 return;
5362}
5363#endif
5364
5365/**
5366 * send_setup_install_key_cmd_tlv() - set key parameters
5367 * @wmi_handle: wmi handle
5368 * @key_params: key parameters
5369 *
5370 * This function fills structure from information
5371 * passed in key_params.
5372 *
5373 * Return: QDF_STATUS_SUCCESS - success
5374 * QDF_STATUS_E_FAILURE - failure
5375 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5376 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305377static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305378 struct set_key_params *key_params)
5379{
5380 wmi_vdev_install_key_cmd_fixed_param *cmd;
5381 wmi_buf_t buf;
5382 uint8_t *buf_ptr;
5383 uint32_t len;
5384 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305385 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305386
5387 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5388 WMI_TLV_HDR_SIZE;
5389
5390 buf = wmi_buf_alloc(wmi_handle, len);
5391 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305392 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305393 return QDF_STATUS_E_NOMEM;
5394 }
5395
5396 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5397 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5398 WMITLV_SET_HDR(&cmd->tlv_header,
5399 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5400 WMITLV_GET_STRUCT_TLVLEN
5401 (wmi_vdev_install_key_cmd_fixed_param));
5402 cmd->vdev_id = key_params->vdev_id;
5403 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305404
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305405
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305406 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5407 cmd->key_flags |= key_params->key_flags;
5408 cmd->key_cipher = key_params->key_cipher;
5409 if ((key_params->key_txmic_len) &&
5410 (key_params->key_rxmic_len)) {
5411 cmd->key_txmic_len = key_params->key_txmic_len;
5412 cmd->key_rxmic_len = key_params->key_rxmic_len;
5413 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305414#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305415 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5416 key_params->tx_iv,
5417 cmd->wpi_key_rsc_counter,
5418 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305419#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305420 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5421 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5422 roundup(key_params->key_len, sizeof(uint32_t)));
5423 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
5424 qdf_mem_copy((void *)key_data,
5425 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005426 if (key_params->key_rsc_counter)
5427 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5428 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305429 cmd->key_len = key_params->key_len;
5430
5431 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5432 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305433 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305434 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305435
Govind Singh67922e82016-04-01 16:48:57 +05305436 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305437}
5438
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305439/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005440 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5441 * @wmi_handle: wmi handle
5442 * @params: sar limit params
5443 *
5444 * Return: QDF_STATUS_SUCCESS for success or error code
5445 */
5446static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5447 struct sar_limit_cmd_params *sar_limit_params)
5448{
5449 wmi_buf_t buf;
5450 QDF_STATUS qdf_status;
5451 wmi_sar_limits_cmd_fixed_param *cmd;
5452 int i;
5453 uint8_t *buf_ptr;
5454 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5455 struct sar_limit_cmd_row *sar_rows_list;
5456 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5457
5458 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5459 buf = wmi_buf_alloc(wmi_handle, len);
5460 if (!buf) {
5461 WMI_LOGE("Failed to allocate memory");
5462 qdf_status = QDF_STATUS_E_NOMEM;
5463 goto end;
5464 }
5465
5466 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5467 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5468 WMITLV_SET_HDR(&cmd->tlv_header,
5469 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5470 WMITLV_GET_STRUCT_TLVLEN
5471 (wmi_sar_limits_cmd_fixed_param));
5472 cmd->sar_enable = sar_limit_params->sar_enable;
5473 cmd->commit_limits = sar_limit_params->commit_limits;
5474 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5475
5476 WMI_LOGD("no of sar rows = %d, len = %d",
5477 sar_limit_params->num_limit_rows, len);
5478 buf_ptr += sizeof(*cmd);
5479 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5480 sizeof(wmi_sar_limit_cmd_row) *
5481 sar_limit_params->num_limit_rows);
5482 if (cmd->num_limit_rows == 0)
5483 goto send_sar_limits;
5484
5485 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5486 (buf_ptr + WMI_TLV_HDR_SIZE);
5487 sar_rows_list = sar_limit_params->sar_limit_row_list;
5488
5489 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5490 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5491 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5492 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5493 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5494 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5495 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5496 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5497 wmi_sar_rows_list->validity_bitmap =
5498 sar_rows_list->validity_bitmap;
5499 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5500 i, wmi_sar_rows_list->band_id,
5501 wmi_sar_rows_list->chain_id,
5502 wmi_sar_rows_list->mod_id,
5503 wmi_sar_rows_list->limit_value,
5504 wmi_sar_rows_list->validity_bitmap);
5505 sar_rows_list++;
5506 wmi_sar_rows_list++;
5507 }
5508send_sar_limits:
5509 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5510 WMI_SAR_LIMITS_CMDID);
5511
5512 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5513 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5514 wmi_buf_free(buf);
5515 }
5516
5517end:
5518 return qdf_status;
5519}
5520
Jeff Johnson4783f902017-12-14 15:50:16 -08005521static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5522{
5523 wmi_sar_get_limits_cmd_fixed_param *cmd;
5524 wmi_buf_t wmi_buf;
5525 uint32_t len;
5526 QDF_STATUS status;
5527
5528 WMI_LOGD(FL("Enter"));
5529
5530 len = sizeof(*cmd);
5531 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5532 if (!wmi_buf) {
5533 WMI_LOGP(FL("failed to allocate memory for msg"));
5534 return QDF_STATUS_E_NOMEM;
5535 }
5536
5537 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5538
5539 WMITLV_SET_HDR(&cmd->tlv_header,
5540 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5541 WMITLV_GET_STRUCT_TLVLEN
5542 (wmi_sar_get_limits_cmd_fixed_param));
5543
5544 cmd->reserved = 0;
5545
5546 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5547 WMI_SAR_GET_LIMITS_CMDID);
5548 if (QDF_IS_STATUS_ERROR(status)) {
5549 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5550 wmi_buf_free(wmi_buf);
5551 }
5552
5553 WMI_LOGD(FL("Exit"));
5554
5555 return status;
5556}
5557
5558static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5559 uint8_t *evt_buf,
5560 struct sar_limit_event *event)
5561{
5562 wmi_sar_get_limits_event_fixed_param *fixed_param;
5563 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5564 wmi_sar_get_limit_event_row *row_in;
5565 struct sar_limit_event_row *row_out;
5566 uint32_t row;
5567
5568 if (!evt_buf) {
5569 WMI_LOGE(FL("input event is NULL"));
5570 return QDF_STATUS_E_INVAL;
5571 }
5572 if (!event) {
5573 WMI_LOGE(FL("output event is NULL"));
5574 return QDF_STATUS_E_INVAL;
5575 }
5576
5577 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5578
5579 fixed_param = param_buf->fixed_param;
5580 if (!fixed_param) {
5581 WMI_LOGE(FL("Invalid fixed param"));
5582 return QDF_STATUS_E_INVAL;
5583 }
5584
5585 event->sar_enable = fixed_param->sar_enable;
5586 event->num_limit_rows = fixed_param->num_limit_rows;
5587
5588 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5589 QDF_ASSERT(0);
5590 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5591 event->num_limit_rows,
5592 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5593 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5594 }
5595
5596 row_in = param_buf->sar_get_limits;
5597 row_out = &event->sar_limit_row[0];
5598 for (row = 0; row < event->num_limit_rows; row++) {
5599 row_out->band_id = row_in->band_id;
5600 row_out->chain_id = row_in->chain_id;
5601 row_out->mod_id = row_in->mod_id;
5602 row_out->limit_value = row_in->limit_value;
5603 row_out++;
5604 row_in++;
5605 }
5606
5607 return QDF_STATUS_SUCCESS;
5608}
5609
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305610#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005611/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305612 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5613 * @wmi_handle: wmi handle
5614 * @params: encrypt/decrypt params
5615 *
5616 * Return: QDF_STATUS_SUCCESS for success or error code
5617 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005618static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305619QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305620 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305621{
5622 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5623 wmi_buf_t wmi_buf;
5624 uint8_t *buf_ptr;
5625 QDF_STATUS ret;
5626 uint32_t len;
5627
5628 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5629
5630 len = sizeof(*cmd) +
5631 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
5632 WMI_TLV_HDR_SIZE;
5633 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5634 if (!wmi_buf) {
5635 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5636 __func__);
5637 return QDF_STATUS_E_NOMEM;
5638 }
5639
5640 buf_ptr = wmi_buf_data(wmi_buf);
5641 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5642
5643 WMITLV_SET_HDR(&cmd->tlv_header,
5644 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5645 WMITLV_GET_STRUCT_TLVLEN(
5646 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5647
5648 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5649 cmd->key_flag = encrypt_decrypt_params->key_flag;
5650 cmd->key_idx = encrypt_decrypt_params->key_idx;
5651 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5652 cmd->key_len = encrypt_decrypt_params->key_len;
5653 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5654 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5655
5656 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5657 encrypt_decrypt_params->key_len);
5658
5659 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5660 MAX_MAC_HEADER_LEN);
5661
5662 cmd->data_len = encrypt_decrypt_params->data_len;
5663
5664 if (cmd->data_len) {
5665 buf_ptr += sizeof(*cmd);
5666 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5667 roundup(encrypt_decrypt_params->data_len,
5668 sizeof(A_UINT32)));
5669 buf_ptr += WMI_TLV_HDR_SIZE;
5670 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5671 encrypt_decrypt_params->data_len);
5672 }
5673
5674 /* This conversion is to facilitate data to FW in little endian */
5675 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5676 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5677 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5678 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5679 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5680 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5681
5682 ret = wmi_unified_cmd_send(wmi_handle,
5683 wmi_buf, len,
5684 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5685 if (QDF_IS_STATUS_ERROR(ret)) {
5686 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5687 wmi_buf_free(wmi_buf);
5688 }
5689
5690 return ret;
5691}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305692
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305693/**
5694 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5695 * params from event
5696 * @wmi_handle: wmi handle
5697 * @evt_buf: pointer to event buffer
5698 * @resp: Pointer to hold resp parameters
5699 *
5700 * Return: QDF_STATUS_SUCCESS for success or error code
5701 */
5702static
5703QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5704 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5705{
5706 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5707 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5708
5709 param_buf = evt_buf;
5710 if (!param_buf) {
5711 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5712 return QDF_STATUS_E_INVAL;
5713 }
5714
5715 data_event = param_buf->fixed_param;
5716
5717 resp->vdev_id = data_event->vdev_id;
5718 resp->status = data_event->status;
5719
5720 if (data_event->data_length > param_buf->num_enc80211_frame) {
5721 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5722 data_event->data_length,
5723 param_buf->num_enc80211_frame);
5724 return QDF_STATUS_E_INVAL;
5725 }
5726
5727 resp->data_len = data_event->data_length;
5728
5729 if (resp->data_len)
5730 resp->data = (uint8_t *)param_buf->enc80211_frame;
5731
5732 return QDF_STATUS_SUCCESS;
5733}
5734#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305735
Govind Singh4eacd2b2016-03-07 14:24:22 +05305736/**
5737 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5738 * @wmi_handle: wmi handle
5739 * @vdev_id: vdev id
5740 * @p2p_ie: p2p IE
5741 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305742 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305743 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305744static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305745 A_UINT32 vdev_id, uint8_t *p2p_ie)
5746{
Govind Singh67922e82016-04-01 16:48:57 +05305747 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305748 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5749 wmi_buf_t wmi_buf;
5750 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5751 uint8_t *buf_ptr;
5752
5753 ie_len = (uint32_t) (p2p_ie[1] + 2);
5754
5755 /* More than one P2P IE may be included in a single frame.
5756 If multiple P2P IEs are present, the complete P2P attribute
5757 data consists of the concatenation of the P2P Attribute
5758 fields of the P2P IEs. The P2P Attributes field of each
5759 P2P IE may be any length up to the maximum (251 octets).
5760 In this case host sends one P2P IE to firmware so the length
5761 should not exceed more than 251 bytes
5762 */
5763 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305764 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305765 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305766 }
5767
5768 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
5769
5770 wmi_buf_len =
5771 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5772 WMI_TLV_HDR_SIZE;
5773
5774 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5775 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305776 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305777 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305778 }
5779
5780 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5781
5782 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5783 WMITLV_SET_HDR(&cmd->tlv_header,
5784 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5785 WMITLV_GET_STRUCT_TLVLEN
5786 (wmi_p2p_go_set_beacon_ie_fixed_param));
5787 cmd->vdev_id = vdev_id;
5788 cmd->ie_buf_len = ie_len;
5789
5790 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5791 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5792 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305793 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305794
Govind Singhb53420c2016-03-09 14:32:57 +05305795 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305796
5797 ret = wmi_unified_cmd_send(wmi_handle,
5798 wmi_buf, wmi_buf_len,
5799 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305800 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305801 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305802 wmi_buf_free(wmi_buf);
5803 }
5804
Govind Singhb53420c2016-03-09 14:32:57 +05305805 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305806 return ret;
5807}
5808
5809/**
5810 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5811 * @wmi_handle: wmi handle
5812 * @req: gateway parameter update request structure
5813 *
5814 * This function reads the incoming @req and fill in the destination
5815 * WMI structure and sends down the gateway configs down to the firmware
5816 *
Govind Singhb53420c2016-03-09 14:32:57 +05305817 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305818 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305819static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305820 struct gateway_update_req_param *req)
5821{
5822 wmi_roam_subnet_change_config_fixed_param *cmd;
5823 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305824 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305825 int len = sizeof(*cmd);
5826
5827 buf = wmi_buf_alloc(wmi_handle, len);
5828 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305829 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5830 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305831 }
5832
5833 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5834 WMITLV_SET_HDR(&cmd->tlv_header,
5835 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5836 WMITLV_GET_STRUCT_TLVLEN(
5837 wmi_roam_subnet_change_config_fixed_param));
5838
5839 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305840 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5841 QDF_IPV4_ADDR_SIZE);
5842 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5843 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305844 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5845 &cmd->inet_gw_mac_addr);
5846 cmd->max_retries = req->max_retries;
5847 cmd->timeout = req->timeout;
5848 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5849 cmd->flag = 0;
5850 if (req->ipv4_addr_type)
5851 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5852
5853 if (req->ipv6_addr_type)
5854 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5855
5856 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5857 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305858 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305859 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305860 ret);
5861 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305862 }
5863
Govind Singh67922e82016-04-01 16:48:57 +05305864 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305865}
5866
5867/**
5868 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5869 * @wmi_handle: wmi handle
5870 * @req: rssi monitoring request structure
5871 *
5872 * This function reads the incoming @req and fill in the destination
5873 * WMI structure and send down the rssi monitoring configs down to the firmware
5874 *
5875 * Return: 0 on success; error number otherwise
5876 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305877static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305878 struct rssi_monitor_param *req)
5879{
5880 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5881 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305882 QDF_STATUS ret;
5883 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305884
5885 buf = wmi_buf_alloc(wmi_handle, len);
5886 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305887 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5888 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305889 }
5890
5891 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5892 WMITLV_SET_HDR(&cmd->tlv_header,
5893 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5894 WMITLV_GET_STRUCT_TLVLEN(
5895 wmi_rssi_breach_monitor_config_fixed_param));
5896
5897 cmd->vdev_id = req->session_id;
5898 cmd->request_id = req->request_id;
5899 cmd->lo_rssi_reenable_hysteresis = 0;
5900 cmd->hi_rssi_reenable_histeresis = 0;
5901 cmd->min_report_interval = 0;
5902 cmd->max_num_report = 1;
5903 if (req->control) {
5904 /* enable one threshold for each min/max */
5905 cmd->enabled_bitmap = 0x09;
5906 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5907 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5908 } else {
5909 cmd->enabled_bitmap = 0;
5910 cmd->low_rssi_breach_threshold[0] = 0;
5911 cmd->hi_rssi_breach_threshold[0] = 0;
5912 }
5913
5914 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5915 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305916 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305917 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305918 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305919 }
5920
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005921 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5922
Govind Singh67922e82016-04-01 16:48:57 +05305923 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305924}
5925
5926/**
5927 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5928 * @wmi_handle: wmi handle
5929 * @psetoui: OUI parameters
5930 *
5931 * set scan probe OUI parameters in firmware
5932 *
5933 * Return: CDF status
5934 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305935static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305936 struct scan_mac_oui *psetoui)
5937{
5938 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5939 wmi_buf_t wmi_buf;
5940 uint32_t len;
5941 uint8_t *buf_ptr;
5942 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305943 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305944
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305945 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5946 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5947
Govind Singh4eacd2b2016-03-07 14:24:22 +05305948 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5949 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305950 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5951 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305952 }
5953 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5954 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5955 WMITLV_SET_HDR(&cmd->tlv_header,
5956 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5957 WMITLV_GET_STRUCT_TLVLEN
5958 (wmi_scan_prob_req_oui_cmd_fixed_param));
5959
5960 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305961 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305962 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5963 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305964 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305965 cmd->prob_req_oui);
5966
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305967 cmd->vdev_id = psetoui->vdev_id;
5968 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5969 if (psetoui->enb_probe_req_sno_randomization)
5970 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5971
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305972 if (ie_whitelist->white_list) {
5973 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5974 &cmd->num_vendor_oui,
5975 ie_whitelist);
5976 cmd->flags |=
5977 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5978 }
5979
5980 buf_ptr += sizeof(*cmd);
5981 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5982 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5983 buf_ptr += WMI_TLV_HDR_SIZE;
5984
5985 if (cmd->num_vendor_oui != 0) {
5986 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5987 ie_whitelist->voui);
5988 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5989 }
5990
Govind Singh4eacd2b2016-03-07 14:24:22 +05305991 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5992 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305993 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305994 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305995 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305996 }
Govind Singhb53420c2016-03-09 14:32:57 +05305997 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305998}
5999
6000/**
6001 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
6002 * @wmi_handle: wmi handle
6003 * @req: passpoint network request structure
6004 *
6005 * This function sends down WMI command with network id set to wildcard id.
6006 * firmware shall clear all the config entries
6007 *
Govind Singhb53420c2016-03-09 14:32:57 +05306008 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05306009 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306010static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306011 struct wifi_passpoint_req_param *req)
6012{
6013 wmi_passpoint_config_cmd_fixed_param *cmd;
6014 wmi_buf_t buf;
6015 uint32_t len;
6016 int ret;
6017
6018 len = sizeof(*cmd);
6019 buf = wmi_buf_alloc(wmi_handle, len);
6020 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306021 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6022 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306023 }
6024
6025 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
6026
6027 WMITLV_SET_HDR(&cmd->tlv_header,
6028 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
6029 WMITLV_GET_STRUCT_TLVLEN(
6030 wmi_passpoint_config_cmd_fixed_param));
6031 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
6032
6033 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6034 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6035 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306036 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306037 __func__);
6038 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306039 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306040 }
6041
Govind Singhb53420c2016-03-09 14:32:57 +05306042 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306043}
6044
6045/**
6046 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
6047 * @wmi_handle: wmi handle
6048 * @req: passpoint network request structure
6049 *
6050 * This function reads the incoming @req and fill in the destination
6051 * WMI structure and send down the passpoint configs down to the firmware
6052 *
Govind Singhb53420c2016-03-09 14:32:57 +05306053 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05306054 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306055static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306056 struct wifi_passpoint_req_param *req)
6057{
6058 wmi_passpoint_config_cmd_fixed_param *cmd;
6059 u_int8_t i, j, *bytes;
6060 wmi_buf_t buf;
6061 uint32_t len;
6062 int ret;
6063
6064 len = sizeof(*cmd);
6065 for (i = 0; i < req->num_networks; i++) {
6066 buf = wmi_buf_alloc(wmi_handle, len);
6067 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306068 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6069 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306070 }
6071
6072 cmd = (wmi_passpoint_config_cmd_fixed_param *)
6073 wmi_buf_data(buf);
6074
6075 WMITLV_SET_HDR(&cmd->tlv_header,
6076 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
6077 WMITLV_GET_STRUCT_TLVLEN(
6078 wmi_passpoint_config_cmd_fixed_param));
6079 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05306080 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
6081 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306082 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05306083 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306084 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
6085 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05306086 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306087 j, bytes[0], bytes[1], bytes[2], bytes[3],
6088 bytes[4], bytes[5], bytes[6], bytes[7]);
6089
Govind Singhb53420c2016-03-09 14:32:57 +05306090 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05306091 &req->networks[i].roaming_consortium_ids[j],
6092 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
6093 }
Govind Singhb53420c2016-03-09 14:32:57 +05306094 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306095 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05306096 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306097 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
6098
6099 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6100 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6101 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306102 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306103 __func__);
6104 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306105 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306106 }
6107 }
6108
Govind Singhb53420c2016-03-09 14:32:57 +05306109 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306110}
6111
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306112#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306113/**
6114 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6115 * @wmi_handle: wmi handle
6116 * @roam_req: Roam scan offload params
6117 * @buf_ptr: command buffer to send
6118 * @fils_tlv_len: fils tlv length
6119 *
6120 * Return: Updated buffer pointer
6121 */
6122static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6123 struct roam_offload_scan_params *roam_req,
6124 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6125{
6126 wmi_roam_fils_offload_tlv_param *fils_tlv;
6127 wmi_erp_info *erp_info;
6128 struct roam_fils_params *roam_fils_params;
6129
6130 if (!roam_req->add_fils_tlv)
6131 return buf_ptr;
6132
6133 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6134 sizeof(*fils_tlv));
6135 buf_ptr += WMI_TLV_HDR_SIZE;
6136
6137 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6138 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6139 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6140 WMITLV_GET_STRUCT_TLVLEN
6141 (wmi_roam_fils_offload_tlv_param));
6142
6143 roam_fils_params = &roam_req->roam_fils_params;
6144 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6145
6146 erp_info->username_length = roam_fils_params->username_length;
6147 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6148 erp_info->username_length);
6149
6150 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6151
6152 erp_info->rRk_length = roam_fils_params->rrk_length;
6153 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6154 erp_info->rRk_length);
6155
6156 erp_info->rIk_length = roam_fils_params->rik_length;
6157 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6158 erp_info->rIk_length);
6159
6160 erp_info->realm_len = roam_fils_params->realm_len;
6161 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6162 erp_info->realm_len);
6163
6164 buf_ptr += sizeof(*fils_tlv);
6165 return buf_ptr;
6166}
6167#else
6168static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6169 struct roam_offload_scan_params *roam_req,
6170 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6171{
6172 return buf_ptr;
6173}
6174#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306175/**
6176 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6177 * @wmi_handle: wmi handle
6178 * @scan_cmd_fp: start scan command ptr
6179 * @roam_req: roam request param
6180 *
6181 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6182 * of WMI_ROAM_SCAN_MODE.
6183 *
6184 * Return: QDF status
6185 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306186static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306187 wmi_start_scan_cmd_fixed_param *
6188 scan_cmd_fp,
6189 struct roam_offload_scan_params *roam_req)
6190{
6191 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306192 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306193 int len;
6194 uint8_t *buf_ptr;
6195 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306196
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306197#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6198 int auth_mode = roam_req->auth_mode;
6199 wmi_roam_offload_tlv_param *roam_offload_params;
6200 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6201 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6202 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306203 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306204 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306205#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6206 /* Need to create a buf with roam_scan command at
6207 * front and piggyback with scan command */
6208 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6209#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6210 (2 * WMI_TLV_HDR_SIZE) +
6211#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6212 sizeof(wmi_start_scan_cmd_fixed_param);
6213#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006214 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306215 if (roam_req->is_roam_req_valid &&
6216 roam_req->roam_offload_enabled) {
6217 len += sizeof(wmi_roam_offload_tlv_param);
6218 len += WMI_TLV_HDR_SIZE;
6219 if ((auth_mode != WMI_AUTH_NONE) &&
6220 ((auth_mode != WMI_AUTH_OPEN) ||
6221 (auth_mode == WMI_AUTH_OPEN &&
6222 roam_req->mdid.mdie_present) ||
6223 roam_req->is_ese_assoc)) {
6224 len += WMI_TLV_HDR_SIZE;
6225 if (roam_req->is_ese_assoc)
6226 len +=
6227 sizeof(wmi_roam_ese_offload_tlv_param);
6228 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6229 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6230 (auth_mode == WMI_AUTH_OPEN &&
6231 roam_req->mdid.mdie_present))
6232 len +=
6233 sizeof(wmi_roam_11r_offload_tlv_param);
6234 else
6235 len +=
6236 sizeof(wmi_roam_11i_offload_tlv_param);
6237 } else {
6238 len += WMI_TLV_HDR_SIZE;
6239 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306240
6241 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6242 + roundup(roam_req->assoc_ie_length,
6243 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306244
6245 if (roam_req->add_fils_tlv) {
6246 fils_tlv_len = sizeof(
6247 wmi_roam_fils_offload_tlv_param);
6248 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6249 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306250 } else {
6251 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306252 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306253 __func__, roam_req->roam_offload_enabled);
6254 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306255 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306256 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306257 }
6258 if (roam_req->is_roam_req_valid &&
6259 roam_req->roam_offload_enabled) {
6260 roam_req->mode = roam_req->mode |
6261 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6262 }
6263#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6264
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306265 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6266 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6267 len = sizeof(wmi_roam_scan_mode_fixed_param);
6268
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306269 buf = wmi_buf_alloc(wmi_handle, len);
6270 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306271 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306272 return QDF_STATUS_E_NOMEM;
6273 }
6274
6275 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6276 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6277 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6278 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6279 WMITLV_GET_STRUCT_TLVLEN
6280 (wmi_roam_scan_mode_fixed_param));
6281
6282 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6283 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306284 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6285 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6286 roam_scan_mode_fp->flags |=
6287 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306288 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306289 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306290
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306291 /* Fill in scan parameters suitable for roaming scan */
6292 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306293
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306294 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6295 sizeof(wmi_start_scan_cmd_fixed_param));
6296 /* Ensure there is no additional IEs */
6297 scan_cmd_fp->ie_len = 0;
6298 WMITLV_SET_HDR(buf_ptr,
6299 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6300 WMITLV_GET_STRUCT_TLVLEN
6301 (wmi_start_scan_cmd_fixed_param));
6302#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6303 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6304 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6305 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6306 sizeof(wmi_roam_offload_tlv_param));
6307 buf_ptr += WMI_TLV_HDR_SIZE;
6308 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6309 WMITLV_SET_HDR(buf_ptr,
6310 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6311 WMITLV_GET_STRUCT_TLVLEN
6312 (wmi_roam_offload_tlv_param));
6313 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6314 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6315 roam_offload_params->select_5g_margin =
6316 roam_req->select_5ghz_margin;
6317 roam_offload_params->reassoc_failure_timeout =
6318 roam_req->reassoc_failure_timeout;
6319
6320 /* Fill the capabilities */
6321 roam_offload_params->capability =
6322 roam_req->roam_offload_params.capability;
6323 roam_offload_params->ht_caps_info =
6324 roam_req->roam_offload_params.ht_caps_info;
6325 roam_offload_params->ampdu_param =
6326 roam_req->roam_offload_params.ampdu_param;
6327 roam_offload_params->ht_ext_cap =
6328 roam_req->roam_offload_params.ht_ext_cap;
6329 roam_offload_params->ht_txbf =
6330 roam_req->roam_offload_params.ht_txbf;
6331 roam_offload_params->asel_cap =
6332 roam_req->roam_offload_params.asel_cap;
6333 roam_offload_params->qos_caps =
6334 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006335 roam_offload_params->qos_enabled =
6336 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306337 roam_offload_params->wmm_caps =
6338 roam_req->roam_offload_params.wmm_caps;
6339 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6340 (uint8_t *)roam_req->roam_offload_params.mcsset,
6341 ROAM_OFFLOAD_NUM_MCS_SET);
6342
6343 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6344 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6345 * they are filled in the same order.Depending on the
6346 * authentication type, the other mode TLV's are nullified
6347 * and only headers are filled.*/
6348 if ((auth_mode != WMI_AUTH_NONE) &&
6349 ((auth_mode != WMI_AUTH_OPEN) ||
6350 (auth_mode == WMI_AUTH_OPEN
6351 && roam_req->mdid.mdie_present) ||
6352 roam_req->is_ese_assoc)) {
6353 if (roam_req->is_ese_assoc) {
6354 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6355 WMITLV_GET_STRUCT_TLVLEN(0));
6356 buf_ptr += WMI_TLV_HDR_SIZE;
6357 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6358 WMITLV_GET_STRUCT_TLVLEN(0));
6359 buf_ptr += WMI_TLV_HDR_SIZE;
6360 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6361 sizeof(wmi_roam_ese_offload_tlv_param));
6362 buf_ptr += WMI_TLV_HDR_SIZE;
6363 roam_offload_ese =
6364 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6365 qdf_mem_copy(roam_offload_ese->krk,
6366 roam_req->krk,
6367 sizeof(roam_req->krk));
6368 qdf_mem_copy(roam_offload_ese->btk,
6369 roam_req->btk,
6370 sizeof(roam_req->btk));
6371 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6372 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6373 WMITLV_GET_STRUCT_TLVLEN
6374 (wmi_roam_ese_offload_tlv_param));
6375 buf_ptr +=
6376 sizeof(wmi_roam_ese_offload_tlv_param);
6377 } else if (auth_mode == WMI_AUTH_FT_RSNA
6378 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6379 || (auth_mode == WMI_AUTH_OPEN
6380 && roam_req->mdid.mdie_present)) {
6381 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6382 0);
6383 buf_ptr += WMI_TLV_HDR_SIZE;
6384 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6385 sizeof(wmi_roam_11r_offload_tlv_param));
6386 buf_ptr += WMI_TLV_HDR_SIZE;
6387 roam_offload_11r =
6388 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6389 roam_offload_11r->r0kh_id_len =
6390 roam_req->rokh_id_length;
6391 qdf_mem_copy(roam_offload_11r->r0kh_id,
6392 roam_req->rokh_id,
6393 roam_offload_11r->r0kh_id_len);
6394 qdf_mem_copy(roam_offload_11r->psk_msk,
6395 roam_req->psk_pmk,
6396 sizeof(roam_req->psk_pmk));
6397 roam_offload_11r->psk_msk_len =
6398 roam_req->pmk_len;
6399 roam_offload_11r->mdie_present =
6400 roam_req->mdid.mdie_present;
6401 roam_offload_11r->mdid =
6402 roam_req->mdid.mobility_domain;
6403 if (auth_mode == WMI_AUTH_OPEN) {
6404 /* If FT-Open ensure pmk length
6405 and r0khid len are zero */
6406 roam_offload_11r->r0kh_id_len = 0;
6407 roam_offload_11r->psk_msk_len = 0;
6408 }
6409 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6410 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6411 WMITLV_GET_STRUCT_TLVLEN
6412 (wmi_roam_11r_offload_tlv_param));
6413 buf_ptr +=
6414 sizeof(wmi_roam_11r_offload_tlv_param);
6415 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6416 WMITLV_GET_STRUCT_TLVLEN(0));
6417 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006418 WMI_LOGD("psk_msk_len = %d",
6419 roam_offload_11r->psk_msk_len);
6420 if (roam_offload_11r->psk_msk_len)
6421 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6422 QDF_TRACE_LEVEL_DEBUG,
6423 roam_offload_11r->psk_msk,
6424 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306425 } else {
6426 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6427 sizeof(wmi_roam_11i_offload_tlv_param));
6428 buf_ptr += WMI_TLV_HDR_SIZE;
6429 roam_offload_11i =
6430 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006431
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006432 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006433 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306434 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6435 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006436 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306437 } else {
6438 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6439 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006440 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006441 }
6442 if (roam_req->roam_key_mgmt_offload_enabled &&
6443 roam_req->fw_pmksa_cache) {
6444 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6445 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006446 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006447 } else {
6448 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6449 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006450 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306451 }
6452
6453 qdf_mem_copy(roam_offload_11i->pmk,
6454 roam_req->psk_pmk,
6455 sizeof(roam_req->psk_pmk));
6456 roam_offload_11i->pmk_len = roam_req->pmk_len;
6457 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6458 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6459 WMITLV_GET_STRUCT_TLVLEN
6460 (wmi_roam_11i_offload_tlv_param));
6461 buf_ptr +=
6462 sizeof(wmi_roam_11i_offload_tlv_param);
6463 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6464 0);
6465 buf_ptr += WMI_TLV_HDR_SIZE;
6466 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6467 0);
6468 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006469 WMI_LOGD("pmk_len = %d",
6470 roam_offload_11i->pmk_len);
6471 if (roam_offload_11i->pmk_len)
6472 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6473 QDF_TRACE_LEVEL_DEBUG,
6474 roam_offload_11i->pmk,
6475 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306476 }
6477 } else {
6478 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6479 WMITLV_GET_STRUCT_TLVLEN(0));
6480 buf_ptr += WMI_TLV_HDR_SIZE;
6481 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6482 WMITLV_GET_STRUCT_TLVLEN(0));
6483 buf_ptr += WMI_TLV_HDR_SIZE;
6484 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6485 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306486 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306487 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306488
6489 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6490 sizeof(*assoc_ies));
6491 buf_ptr += WMI_TLV_HDR_SIZE;
6492
6493 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6494 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6495 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6496 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6497 assoc_ies->buf_len = roam_req->assoc_ie_length;
6498
6499 buf_ptr += sizeof(*assoc_ies);
6500
6501 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6502 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6503 buf_ptr += WMI_TLV_HDR_SIZE;
6504
6505 if (assoc_ies->buf_len != 0) {
6506 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6507 assoc_ies->buf_len);
6508 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306509 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6510 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6511 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306512 } else {
6513 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6514 WMITLV_GET_STRUCT_TLVLEN(0));
6515 buf_ptr += WMI_TLV_HDR_SIZE;
6516 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6517 WMITLV_GET_STRUCT_TLVLEN(0));
6518 buf_ptr += WMI_TLV_HDR_SIZE;
6519 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6520 WMITLV_GET_STRUCT_TLVLEN(0));
6521 buf_ptr += WMI_TLV_HDR_SIZE;
6522 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6523 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306524 buf_ptr += WMI_TLV_HDR_SIZE;
6525 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6526 WMITLV_GET_STRUCT_TLVLEN(0));
6527 buf_ptr += WMI_TLV_HDR_SIZE;
6528 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6529 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306530 }
6531#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306532
6533send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306534 status = wmi_unified_cmd_send(wmi_handle, buf,
6535 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306536 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306537 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306538 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6539 status);
6540 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306541 }
6542
Govind Singh67922e82016-04-01 16:48:57 +05306543 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306544}
6545
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006546static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6547 struct wmi_mawc_roam_params *params)
6548{
6549 wmi_buf_t buf = NULL;
6550 QDF_STATUS status;
6551 int len;
6552 uint8_t *buf_ptr;
6553 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6554
6555 len = sizeof(*wmi_roam_mawc_params);
6556 buf = wmi_buf_alloc(wmi_handle, len);
6557 if (!buf) {
6558 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6559 return QDF_STATUS_E_NOMEM;
6560 }
6561
6562 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6563 wmi_roam_mawc_params =
6564 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6565 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6566 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6567 WMITLV_GET_STRUCT_TLVLEN
6568 (wmi_roam_configure_mawc_cmd_fixed_param));
6569 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6570 if (params->enable)
6571 wmi_roam_mawc_params->enable = 1;
6572 else
6573 wmi_roam_mawc_params->enable = 0;
6574 wmi_roam_mawc_params->traffic_load_threshold =
6575 params->traffic_load_threshold;
6576 wmi_roam_mawc_params->best_ap_rssi_threshold =
6577 params->best_ap_rssi_threshold;
6578 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6579 params->rssi_stationary_high_adjust;
6580 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6581 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006582 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6583 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6584 wmi_roam_mawc_params->traffic_load_threshold,
6585 wmi_roam_mawc_params->best_ap_rssi_threshold,
6586 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6587 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006588
6589 status = wmi_unified_cmd_send(wmi_handle, buf,
6590 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6591 if (QDF_IS_STATUS_ERROR(status)) {
6592 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6593 status);
6594 wmi_buf_free(buf);
6595 return status;
6596 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006597
6598 return QDF_STATUS_SUCCESS;
6599}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306600
6601/**
6602 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6603 * rssi threashold
6604 * @wmi_handle: wmi handle
6605 * @roam_req: Roaming request buffer
6606 *
6607 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6608 *
6609 * Return: QDF status
6610 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306611static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306612 struct roam_offload_scan_rssi_params *roam_req)
6613{
6614 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306615 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306616 int len;
6617 uint8_t *buf_ptr;
6618 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6619 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6620 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306621 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006622 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306623
6624 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6625 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6626 len += sizeof(wmi_roam_scan_extended_threshold_param);
6627 len += WMI_TLV_HDR_SIZE;
6628 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306629 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6630 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006631 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6632 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306633 buf = wmi_buf_alloc(wmi_handle, len);
6634 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306635 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306636 return QDF_STATUS_E_NOMEM;
6637 }
6638
6639 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6640 rssi_threshold_fp =
6641 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6642 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6643 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6644 WMITLV_GET_STRUCT_TLVLEN
6645 (wmi_roam_scan_rssi_threshold_fixed_param));
6646 /* fill in threshold values */
6647 rssi_threshold_fp->vdev_id = roam_req->session_id;
6648 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6649 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6650 rssi_threshold_fp->hirssi_scan_max_count =
6651 roam_req->hi_rssi_scan_max_count;
6652 rssi_threshold_fp->hirssi_scan_delta =
6653 roam_req->hi_rssi_scan_rssi_delta;
6654 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006655 rssi_threshold_fp->rssi_thresh_offset_5g =
6656 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306657
6658 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6659 WMITLV_SET_HDR(buf_ptr,
6660 WMITLV_TAG_ARRAY_STRUC,
6661 sizeof(wmi_roam_scan_extended_threshold_param));
6662 buf_ptr += WMI_TLV_HDR_SIZE;
6663 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6664
6665 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6666 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6667 ext_thresholds->boost_threshold_5g =
6668 roam_req->boost_threshold_5g;
6669
6670 ext_thresholds->boost_algorithm_5g =
6671 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6672 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6673 ext_thresholds->penalty_algorithm_5g =
6674 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6675 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6676 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6677 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6678 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6679
6680 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6681 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6682 WMITLV_GET_STRUCT_TLVLEN
6683 (wmi_roam_scan_extended_threshold_param));
6684 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6685 WMITLV_SET_HDR(buf_ptr,
6686 WMITLV_TAG_ARRAY_STRUC,
6687 sizeof(wmi_roam_earlystop_rssi_thres_param));
6688 buf_ptr += WMI_TLV_HDR_SIZE;
6689 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6690 early_stop_thresholds->roam_earlystop_thres_min =
6691 roam_req->roam_earlystop_thres_min;
6692 early_stop_thresholds->roam_earlystop_thres_max =
6693 roam_req->roam_earlystop_thres_max;
6694 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6695 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6696 WMITLV_GET_STRUCT_TLVLEN
6697 (wmi_roam_earlystop_rssi_thres_param));
6698
Gupta, Kapil7e652922016-04-12 15:02:00 +05306699 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6700 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6701 sizeof(wmi_roam_dense_thres_param));
6702 buf_ptr += WMI_TLV_HDR_SIZE;
6703 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6704 dense_thresholds->roam_dense_rssi_thres_offset =
6705 roam_req->dense_rssi_thresh_offset;
6706 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6707 dense_thresholds->roam_dense_traffic_thres =
6708 roam_req->traffic_threshold;
6709 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6710 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6711 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6712 WMITLV_GET_STRUCT_TLVLEN
6713 (wmi_roam_dense_thres_param));
6714
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006715 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6716 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6717 sizeof(wmi_roam_bg_scan_roaming_param));
6718 buf_ptr += WMI_TLV_HDR_SIZE;
6719 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6720 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6721 roam_req->bg_scan_bad_rssi_thresh;
6722 bg_scan_params->roam_bg_scan_client_bitmap =
6723 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306724 bg_scan_params->bad_rssi_thresh_offset_2g =
6725 roam_req->roam_bad_rssi_thresh_offset_2g;
6726 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006727 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6728 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6729 WMITLV_GET_STRUCT_TLVLEN
6730 (wmi_roam_bg_scan_roaming_param));
6731
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306732 status = wmi_unified_cmd_send(wmi_handle, buf,
6733 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306734 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306735 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306736 status);
6737 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306738 }
6739
Govind Singh67922e82016-04-01 16:48:57 +05306740 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306741}
6742
6743/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306744 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6745 * configuration params
6746 * @wma_handle: wma handler
6747 * @dwelltime_params: pointer to dwelltime_params
6748 *
6749 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6750 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006751static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306752QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6753 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6754{
6755 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6756 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6757 wmi_buf_t buf;
6758 uint8_t *buf_ptr;
6759 int32_t err;
6760 int len;
6761
6762 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6763 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6764 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6765 buf = wmi_buf_alloc(wmi_handle, len);
6766 if (!buf) {
6767 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6768 __func__);
6769 return QDF_STATUS_E_NOMEM;
6770 }
6771 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6772 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6773 WMITLV_SET_HDR(&dwell_param->tlv_header,
6774 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6775 WMITLV_GET_STRUCT_TLVLEN
6776 (wmi_scan_adaptive_dwell_config_fixed_param));
6777
6778 dwell_param->enable = dwelltime_params->is_enabled;
6779 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6780 WMITLV_SET_HDR(buf_ptr,
6781 WMITLV_TAG_ARRAY_STRUC,
6782 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6783 buf_ptr += WMI_TLV_HDR_SIZE;
6784
6785 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6786 WMITLV_SET_HDR(&cmd->tlv_header,
6787 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6788 WMITLV_GET_STRUCT_TLVLEN(
6789 wmi_scan_adaptive_dwell_parameters_tlv));
6790
6791 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6792 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6793 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6794 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6795 err = wmi_unified_cmd_send(wmi_handle, buf,
6796 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6797 if (err) {
6798 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6799 wmi_buf_free(buf);
6800 return QDF_STATUS_E_FAILURE;
6801 }
6802
6803 return QDF_STATUS_SUCCESS;
6804}
6805
Nitesh Shah52323d02017-05-22 15:49:00 +05306806/**
6807 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6808 * configuration params
6809 * @wmi_handle: wmi handler
6810 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6811 *
6812 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6813 */
6814static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6815 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6816{
6817 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6818 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6819 wmi_buf_t buf;
6820 uint8_t *buf_ptr;
6821 QDF_STATUS err;
6822 uint32_t i;
6823 int len;
6824
6825 len = sizeof(*dbs_scan_param);
6826 len += WMI_TLV_HDR_SIZE;
6827 len += dbs_scan_params->num_clients * sizeof(*cmd);
6828
6829 buf = wmi_buf_alloc(wmi_handle, len);
6830 if (!buf) {
6831 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6832 return QDF_STATUS_E_NOMEM;
6833 }
6834
6835 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6836 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6837 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6838 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6839 WMITLV_GET_STRUCT_TLVLEN
6840 (wmi_scan_dbs_duty_cycle_fixed_param));
6841
6842 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6843 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6844 buf_ptr += sizeof(*dbs_scan_param);
6845 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6846 (sizeof(*cmd) * dbs_scan_params->num_clients));
6847 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6848
6849 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6850 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6851 WMITLV_SET_HDR(&cmd->tlv_header,
6852 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6853 WMITLV_GET_STRUCT_TLVLEN(
6854 wmi_scan_dbs_duty_cycle_tlv_param));
6855 cmd->module_id = dbs_scan_params->module_id[i];
6856 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6857 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6858 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6859 }
6860
6861 err = wmi_unified_cmd_send(wmi_handle, buf,
6862 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6863 if (QDF_IS_STATUS_ERROR(err)) {
6864 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6865 wmi_buf_free(buf);
6866 return QDF_STATUS_E_FAILURE;
6867 }
6868
6869 return QDF_STATUS_SUCCESS;
6870}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306871
6872/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306873 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6874 * @wmi_handle: wmi handle
6875 * @roam_req: Request which contains the filters
6876 *
6877 * There are filters such as whitelist, blacklist and preferred
6878 * list that need to be applied to the scan results to form the
6879 * probable candidates for roaming.
6880 *
6881 * Return: Return success upon succesfully passing the
6882 * parameters to the firmware, otherwise failure.
6883 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306884static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306885 struct roam_scan_filter_params *roam_req)
6886{
6887 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306888 QDF_STATUS status;
6889 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306890 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306891 uint8_t *buf_ptr;
6892 wmi_roam_filter_fixed_param *roam_filter;
6893 uint8_t *bssid_src_ptr = NULL;
6894 wmi_mac_addr *bssid_dst_ptr = NULL;
6895 wmi_ssid *ssid_ptr = NULL;
6896 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306897 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306898 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306899
6900 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306901
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306902 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306903 if (roam_req->num_bssid_black_list)
6904 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6905 len += WMI_TLV_HDR_SIZE;
6906 if (roam_req->num_ssid_white_list)
6907 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6908 len += 2 * WMI_TLV_HDR_SIZE;
6909 if (roam_req->num_bssid_preferred_list) {
6910 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
6911 len += roam_req->num_bssid_preferred_list * sizeof(A_UINT32);
6912 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306913 len += WMI_TLV_HDR_SIZE;
6914 if (roam_req->lca_disallow_config_present) {
6915 len += sizeof(*blist_param);
6916 blist_len = sizeof(*blist_param);
6917 }
6918
6919 len += WMI_TLV_HDR_SIZE;
6920 if (roam_req->num_rssi_rejection_ap)
6921 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306922
6923 buf = wmi_buf_alloc(wmi_handle, len);
6924 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306925 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306926 return QDF_STATUS_E_NOMEM;
6927 }
6928
6929 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6930 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6931 WMITLV_SET_HDR(&roam_filter->tlv_header,
6932 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6933 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6934 /* fill in fixed values */
6935 roam_filter->vdev_id = roam_req->session_id;
6936 roam_filter->flags = 0;
6937 roam_filter->op_bitmap = roam_req->op_bitmap;
6938 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6939 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6940 roam_filter->num_bssid_preferred_list =
6941 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306942 roam_filter->num_rssi_rejection_ap =
6943 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306944 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6945
6946 WMITLV_SET_HDR((buf_ptr),
6947 WMITLV_TAG_ARRAY_FIXED_STRUC,
6948 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6949 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6950 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6951 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6952 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6953 bssid_src_ptr += ATH_MAC_LEN;
6954 bssid_dst_ptr++;
6955 }
6956 buf_ptr += WMI_TLV_HDR_SIZE +
6957 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6958 WMITLV_SET_HDR((buf_ptr),
6959 WMITLV_TAG_ARRAY_FIXED_STRUC,
6960 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6961 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6962 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6963 qdf_mem_copy(&ssid_ptr->ssid,
6964 &roam_req->ssid_allowed_list[i].mac_ssid,
6965 roam_req->ssid_allowed_list[i].length);
6966 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6967 ssid_ptr++;
6968 }
6969 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6970 sizeof(wmi_ssid));
6971 WMITLV_SET_HDR((buf_ptr),
6972 WMITLV_TAG_ARRAY_FIXED_STRUC,
6973 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6974 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6975 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6976 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6977 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6978 (wmi_mac_addr *)bssid_dst_ptr);
6979 bssid_src_ptr += ATH_MAC_LEN;
6980 bssid_dst_ptr++;
6981 }
6982 buf_ptr += WMI_TLV_HDR_SIZE +
6983 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6984 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6985 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6986 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6987 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6988 *bssid_preferred_factor_ptr =
6989 roam_req->bssid_favored_factor[i];
6990 bssid_preferred_factor_ptr++;
6991 }
6992 buf_ptr += WMI_TLV_HDR_SIZE +
6993 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6994
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306995 WMITLV_SET_HDR(buf_ptr,
6996 WMITLV_TAG_ARRAY_STRUC, blist_len);
6997 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306998 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306999 blist_param =
7000 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
7001 WMITLV_SET_HDR(&blist_param->tlv_header,
7002 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
7003 WMITLV_GET_STRUCT_TLVLEN(
7004 wmi_roam_lca_disallow_config_tlv_param));
7005
7006 blist_param->disallow_duration = roam_req->disallow_duration;
7007 blist_param->rssi_channel_penalization =
7008 roam_req->rssi_channel_penalization;
7009 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05307010 blist_param->disallow_lca_enable_source_bitmap =
7011 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
7012 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307013 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
7014 }
7015
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307016 WMITLV_SET_HDR(buf_ptr,
7017 WMITLV_TAG_ARRAY_STRUC,
7018 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
7019 buf_ptr += WMI_TLV_HDR_SIZE;
7020 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
7021 rssi_rej =
7022 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7023 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7024 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7025 WMITLV_GET_STRUCT_TLVLEN(
7026 wmi_roam_rssi_rejection_oce_config_param));
7027 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7028 roam_req->rssi_rejection_ap[i].bssid.bytes,
7029 &rssi_rej->bssid);
7030 rssi_rej->remaining_disallow_duration =
7031 roam_req->rssi_rejection_ap[i].remaining_duration;
7032 rssi_rej->requested_rssi =
7033 (A_INT32)roam_req->rssi_rejection_ap[i].expected_rssi;
7034 buf_ptr +=
7035 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7036 }
7037
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307038 status = wmi_unified_cmd_send(wmi_handle, buf,
7039 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307040 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307041 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307042 status);
7043 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307044 }
Govind Singh67922e82016-04-01 16:48:57 +05307045
7046 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307047}
7048
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307049#if defined(WLAN_FEATURE_FILS_SK)
7050static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7051 struct hlp_params *params)
7052{
7053 uint32_t len;
7054 uint8_t *buf_ptr;
7055 wmi_buf_t buf = NULL;
7056 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7057
7058 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7059 len += WMI_TLV_HDR_SIZE;
7060 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7061
7062 buf = wmi_buf_alloc(wmi_handle, len);
7063 if (!buf) {
7064 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7065 return QDF_STATUS_E_NOMEM;
7066 }
7067
7068 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7069 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7070 WMITLV_SET_HDR(&hlp_params->tlv_header,
7071 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7072 WMITLV_GET_STRUCT_TLVLEN(
7073 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7074
7075 hlp_params->vdev_id = params->vdev_id;
7076 hlp_params->size = params->hlp_ie_len;
7077 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7078
7079 buf_ptr += sizeof(*hlp_params);
7080
7081 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7082 round_up(params->hlp_ie_len,
7083 sizeof(uint32_t)));
7084 buf_ptr += WMI_TLV_HDR_SIZE;
7085 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7086
7087 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7088 hlp_params->vdev_id, hlp_params->size);
7089 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7090 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7091 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7092 wmi_buf_free(buf);
7093 return QDF_STATUS_E_FAILURE;
7094 }
7095
7096 return QDF_STATUS_SUCCESS;
7097}
7098#endif
7099
Govind Singh4eacd2b2016-03-07 14:24:22 +05307100/** send_set_epno_network_list_cmd_tlv() - set epno network list
7101 * @wmi_handle: wmi handle
7102 * @req: epno config params request structure
7103 *
7104 * This function reads the incoming epno config request structure
7105 * and constructs the WMI message to the firmware.
7106 *
7107 * Returns: 0 on success, error number otherwise
7108 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307109static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307110 struct wifi_enhanched_pno_params *req)
7111{
7112 wmi_nlo_config_cmd_fixed_param *cmd;
7113 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307114 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307115 u_int8_t i, *buf_ptr;
7116 wmi_buf_t buf;
7117 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307118 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307119
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307120 /* Fixed Params */
7121 len = sizeof(*cmd);
7122 if (req->num_networks) {
7123 /* TLV place holder for array of structures
7124 * then each nlo_configured_parameters(nlo_list) TLV.
7125 */
7126 len += WMI_TLV_HDR_SIZE;
7127 len += (sizeof(nlo_configured_parameters)
7128 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
7129 /* TLV for array of uint32 channel_list */
7130 len += WMI_TLV_HDR_SIZE;
7131 /* TLV for nlo_channel_prediction_cfg */
7132 len += WMI_TLV_HDR_SIZE;
7133 /* TLV for candidate score params */
7134 len += sizeof(enlo_candidate_score_params);
7135 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05307136
7137 buf = wmi_buf_alloc(wmi_handle, len);
7138 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307139 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7140 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307141 }
7142
7143 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7144
7145 buf_ptr = (u_int8_t *) cmd;
7146 WMITLV_SET_HDR(&cmd->tlv_header,
7147 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7148 WMITLV_GET_STRUCT_TLVLEN(
7149 wmi_nlo_config_cmd_fixed_param));
7150 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307151
7152 /* set flag to reset if num of networks are 0 */
7153 cmd->flags = (req->num_networks == 0 ?
7154 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307155
7156 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7157
Govind Singhb53420c2016-03-09 14:32:57 +05307158 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307159 WMI_LOGD("SSID count: %d flags: %d",
7160 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307161
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307162 /* Fill nlo_config only when num_networks are non zero */
7163 if (cmd->no_of_ssids) {
7164 /* Fill networks */
7165 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7166 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7167 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307168
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307169 nlo_list = (nlo_configured_parameters *) buf_ptr;
7170 for (i = 0; i < cmd->no_of_ssids; i++) {
7171 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7172 WMITLV_TAG_ARRAY_BYTE,
7173 WMITLV_GET_STRUCT_TLVLEN(
7174 nlo_configured_parameters));
7175 /* Copy ssid and it's length */
7176 nlo_list[i].ssid.valid = true;
7177 nlo_list[i].ssid.ssid.ssid_len =
7178 req->networks[i].ssid.length;
7179 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
7180 req->networks[i].ssid.mac_ssid,
7181 nlo_list[i].ssid.ssid.ssid_len);
7182 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
7183 nlo_list[i].ssid.ssid.ssid_len,
7184 (char *) nlo_list[i].ssid.ssid.ssid,
7185 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307186
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307187 /* Copy pno flags */
7188 nlo_list[i].bcast_nw_type.valid = true;
7189 nlo_list[i].bcast_nw_type.bcast_nw_type =
7190 req->networks[i].flags;
7191 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307192 nlo_list[i].bcast_nw_type.bcast_nw_type);
7193
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307194 /* Copy auth bit field */
7195 nlo_list[i].auth_type.valid = true;
7196 nlo_list[i].auth_type.auth_type =
7197 req->networks[i].auth_bit_field;
7198 WMI_LOGD("Auth bit field (%u)",
7199 nlo_list[i].auth_type.auth_type);
7200 }
7201
7202 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7203 /* Fill the channel list */
7204 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7205 buf_ptr += WMI_TLV_HDR_SIZE;
7206
7207 /* Fill prediction_param */
7208 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7209 buf_ptr += WMI_TLV_HDR_SIZE;
7210
7211 /* Fill epno candidate score params */
7212 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
7213 WMITLV_SET_HDR(buf_ptr,
7214 WMITLV_TAG_STRUC_enlo_candidate_score_param,
7215 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7216 cand_score_params->min5GHz_rssi =
7217 req->min_5ghz_rssi;
7218 cand_score_params->min24GHz_rssi =
7219 req->min_24ghz_rssi;
7220 cand_score_params->initial_score_max =
7221 req->initial_score_max;
7222 cand_score_params->current_connection_bonus =
7223 req->current_connection_bonus;
7224 cand_score_params->same_network_bonus =
7225 req->same_network_bonus;
7226 cand_score_params->secure_bonus =
7227 req->secure_bonus;
7228 cand_score_params->band5GHz_bonus =
7229 req->band_5ghz_bonus;
7230 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307231 }
7232
Govind Singh4eacd2b2016-03-07 14:24:22 +05307233 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307234 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307235 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307236 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307237 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307238 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307239 }
7240
Govind Singhb53420c2016-03-09 14:32:57 +05307241 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307242 req->session_id);
7243
Govind Singh67922e82016-04-01 16:48:57 +05307244 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307245}
7246
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307247
Govind Singh4eacd2b2016-03-07 14:24:22 +05307248/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7249 * @wmi_handle: wmi handle
7250 * @ipa_offload: ipa offload control parameter
7251 *
7252 * Returns: 0 on success, error number otherwise
7253 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307254static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307255 struct ipa_offload_control_params *ipa_offload)
7256{
7257 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7258 wmi_buf_t wmi_buf;
7259 uint32_t len;
7260 u_int8_t *buf_ptr;
7261
7262 len = sizeof(*cmd);
7263 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7264 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307265 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7266 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307267 }
7268
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007269 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307270 ipa_offload->offload_type, ipa_offload->enable);
7271
7272 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7273
7274 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7275 WMITLV_SET_HDR(&cmd->tlv_header,
7276 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7277 WMITLV_GET_STRUCT_TLVLEN(
7278 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7279
7280 cmd->offload_type = ipa_offload->offload_type;
7281 cmd->vdev_id = ipa_offload->vdev_id;
7282 cmd->enable = ipa_offload->enable;
7283
7284 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7285 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307286 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307287 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307288 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307289 }
7290
Govind Singhb53420c2016-03-09 14:32:57 +05307291 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307292}
7293
7294/**
7295 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
7296 * @wmi_handle: wmi handle
7297 * @pgetcapab: get capabilities params
7298 *
7299 * This function send request to fw to get extscan capabilities.
7300 *
7301 * Return: CDF status
7302 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307303static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307304 struct extscan_capabilities_params *pgetcapab)
7305{
7306 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
7307 wmi_buf_t wmi_buf;
7308 uint32_t len;
7309 uint8_t *buf_ptr;
7310
7311 len = sizeof(*cmd);
7312 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7313 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307314 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7315 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307316 }
7317 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7318
7319 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
7320 WMITLV_SET_HDR(&cmd->tlv_header,
7321 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
7322 WMITLV_GET_STRUCT_TLVLEN
7323 (wmi_extscan_get_capabilities_cmd_fixed_param));
7324
7325 cmd->request_id = pgetcapab->request_id;
7326
7327 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7328 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307329 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307330 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307331 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307332 }
Govind Singhb53420c2016-03-09 14:32:57 +05307333 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307334}
7335
7336/**
7337 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
7338 * @wmi_handle: wmi handle
7339 * @pcached_results: cached results parameters
7340 *
7341 * This function send request to fw to get cached results.
7342 *
7343 * Return: CDF status
7344 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307345static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307346 struct extscan_cached_result_params *pcached_results)
7347{
7348 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
7349 wmi_buf_t wmi_buf;
7350 uint32_t len;
7351 uint8_t *buf_ptr;
7352
7353 len = sizeof(*cmd);
7354 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7355 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307356 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7357 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307358 }
7359 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7360
7361 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
7362 WMITLV_SET_HDR(&cmd->tlv_header,
7363 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
7364 WMITLV_GET_STRUCT_TLVLEN
7365 (wmi_extscan_get_cached_results_cmd_fixed_param));
7366
7367 cmd->request_id = pcached_results->request_id;
7368 cmd->vdev_id = pcached_results->session_id;
7369 cmd->control_flags = pcached_results->flush;
7370
7371 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7372 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307373 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307374 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307375 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307376 }
Govind Singhb53420c2016-03-09 14:32:57 +05307377 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307378}
7379
7380/**
7381 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
7382 * @wmi_handle: wmi handle
7383 * @reset_req: Reset change request params
7384 *
7385 * This function sends stop change monitor request to fw.
7386 *
7387 * Return: CDF status
7388 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307389static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307390 struct extscan_capabilities_reset_params *reset_req)
7391{
7392 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7393 wmi_buf_t wmi_buf;
7394 uint32_t len;
7395 uint8_t *buf_ptr;
7396 int change_list = 0;
7397
7398 len = sizeof(*cmd);
7399
7400 /* reset significant change tlv is set to 0 */
7401 len += WMI_TLV_HDR_SIZE;
7402 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
7403 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7404 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307405 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7406 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307407 }
7408 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7409
7410 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7411 buf_ptr;
7412 WMITLV_SET_HDR(&cmd->tlv_header,
7413 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7414 WMITLV_GET_STRUCT_TLVLEN
7415 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7416
7417 cmd->request_id = reset_req->request_id;
7418 cmd->vdev_id = reset_req->session_id;
7419 cmd->mode = 0;
7420
7421 buf_ptr += sizeof(*cmd);
7422 WMITLV_SET_HDR(buf_ptr,
7423 WMITLV_TAG_ARRAY_STRUC,
7424 change_list *
7425 sizeof(wmi_extscan_wlan_change_bssid_param));
7426 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
7427 sizeof
7428 (wmi_extscan_wlan_change_bssid_param));
7429
7430 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7431 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307432 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307433 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307434 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307435 }
Govind Singhb53420c2016-03-09 14:32:57 +05307436 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307437}
7438
7439/**
7440 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
7441 * @wmi_handle: wmi handle
7442 * @psigchange: change monitor request params
7443 * @buf: wmi buffer
7444 * @buf_len: buffer length
7445 *
7446 * This function fills elements of change monitor request buffer.
7447 *
7448 * Return: CDF status
7449 */
Govind Singhb53420c2016-03-09 14:32:57 +05307450static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307451 struct extscan_set_sig_changereq_params
7452 *psigchange, wmi_buf_t *buf, int *buf_len)
7453{
7454 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7455 wmi_extscan_wlan_change_bssid_param *dest_chglist;
7456 uint8_t *buf_ptr;
7457 int j;
7458 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007459 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307460 struct ap_threshold_params *src_ap = psigchange->ap;
7461
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007462 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307463 WMI_LOGE("%s: Invalid number of bssid's", __func__);
7464 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307465 }
7466 len += WMI_TLV_HDR_SIZE;
7467 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
7468
7469 *buf = wmi_buf_alloc(wmi_handle, len);
7470 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307471 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307472 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307473 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307474 }
7475 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7476 cmd =
7477 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7478 buf_ptr;
7479 WMITLV_SET_HDR(&cmd->tlv_header,
7480 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7481 WMITLV_GET_STRUCT_TLVLEN
7482 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7483
7484 cmd->request_id = psigchange->request_id;
7485 cmd->vdev_id = psigchange->session_id;
7486 cmd->total_entries = numap;
7487 cmd->mode = 1;
7488 cmd->num_entries_in_page = numap;
7489 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
7490 cmd->max_rssi_samples = psigchange->rssi_sample_size;
7491 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
7492 cmd->max_out_of_range_count = psigchange->min_breaching;
7493
7494 buf_ptr += sizeof(*cmd);
7495 WMITLV_SET_HDR(buf_ptr,
7496 WMITLV_TAG_ARRAY_STRUC,
7497 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7498 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
7499 (buf_ptr + WMI_TLV_HDR_SIZE);
7500
7501 for (j = 0; j < numap; j++) {
7502 WMITLV_SET_HDR(dest_chglist,
7503 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7504 WMITLV_GET_STRUCT_TLVLEN
7505 (wmi_extscan_wlan_change_bssid_param));
7506
7507 dest_chglist->lower_rssi_limit = src_ap->low;
7508 dest_chglist->upper_rssi_limit = src_ap->high;
7509 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
7510 &dest_chglist->bssid);
7511
Govind Singhb53420c2016-03-09 14:32:57 +05307512 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307513 dest_chglist->lower_rssi_limit);
7514 dest_chglist++;
7515 src_ap++;
7516 }
7517 buf_ptr += WMI_TLV_HDR_SIZE +
7518 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7519 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307520 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307521}
7522
7523/**
7524 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
7525 * @wmi_handle: wmi handle
7526 * @psigchange: change monitor request params
7527 *
7528 * This function sends start change monitor request to fw.
7529 *
7530 * Return: CDF status
7531 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307532static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307533 struct extscan_set_sig_changereq_params *
7534 psigchange)
7535{
Govind Singhb53420c2016-03-09 14:32:57 +05307536 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307537 wmi_buf_t buf;
7538 int len;
7539
7540
Govind Singhb53420c2016-03-09 14:32:57 +05307541 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307542 psigchange, &buf,
7543 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307544 if (qdf_status != QDF_STATUS_SUCCESS) {
7545 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307546 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307547 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307548 }
7549 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307550 WMI_LOGE("%s: Failed to get buffer", __func__);
7551 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307552 }
7553 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7554 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307555 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307556 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307557 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307558 }
Govind Singhb53420c2016-03-09 14:32:57 +05307559 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307560}
7561
7562/**
7563 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
7564 * @wmi_handle: wmi handle
7565 * @photlist_reset: hotlist reset params
7566 *
7567 * This function configures hotlist monitor to stop in fw.
7568 *
7569 * Return: CDF status
7570 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307571static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307572 struct extscan_bssid_hotlist_reset_params *photlist_reset)
7573{
7574 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
7575 wmi_buf_t wmi_buf;
7576 uint32_t len;
7577 uint8_t *buf_ptr;
7578 int hotlist_entries = 0;
7579
7580 len = sizeof(*cmd);
7581
7582 /* reset bssid hotlist with tlv set to 0 */
7583 len += WMI_TLV_HDR_SIZE;
7584 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
7585
7586 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7587 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307588 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7589 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307590 }
7591
7592 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7593 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
7594 buf_ptr;
7595 WMITLV_SET_HDR(&cmd->tlv_header,
7596 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
7597 WMITLV_GET_STRUCT_TLVLEN
7598 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
7599
7600 cmd->request_id = photlist_reset->request_id;
7601 cmd->vdev_id = photlist_reset->session_id;
7602 cmd->mode = 0;
7603
7604 buf_ptr += sizeof(*cmd);
7605 WMITLV_SET_HDR(buf_ptr,
7606 WMITLV_TAG_ARRAY_STRUC,
7607 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7608 buf_ptr += WMI_TLV_HDR_SIZE +
7609 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7610
7611 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7612 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307613 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307614 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307615 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307616 }
Govind Singhb53420c2016-03-09 14:32:57 +05307617 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307618}
7619
7620/**
7621 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
7622 * @wmi_handle: wmi handle
7623 * @pstopcmd: stop scan command request params
7624 *
7625 * This function sends stop extscan request to fw.
7626 *
7627 * Return: CDF Status.
7628 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307629static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307630 struct extscan_stop_req_params *pstopcmd)
7631{
7632 wmi_extscan_stop_cmd_fixed_param *cmd;
7633 wmi_buf_t wmi_buf;
7634 uint32_t len;
7635 uint8_t *buf_ptr;
7636
7637 len = sizeof(*cmd);
7638 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7639 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307640 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7641 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307642 }
7643 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7644 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
7645 WMITLV_SET_HDR(&cmd->tlv_header,
7646 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
7647 WMITLV_GET_STRUCT_TLVLEN
7648 (wmi_extscan_stop_cmd_fixed_param));
7649
7650 cmd->request_id = pstopcmd->request_id;
7651 cmd->vdev_id = pstopcmd->session_id;
7652
7653 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7654 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307655 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307656 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307657 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307658 }
7659
Govind Singhb53420c2016-03-09 14:32:57 +05307660 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307661}
7662
7663/**
7664 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
7665 * @wmi_handle: wmi handle
7666 * @pstart: scan command request params
7667 * @buf: event buffer
7668 * @buf_len: length of buffer
7669 *
7670 * This function fills individual elements of extscan request and
7671 * TLV for buckets, channel list.
7672 *
7673 * Return: CDF Status.
7674 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007675static
Govind Singhb53420c2016-03-09 14:32:57 +05307676QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307677 struct wifi_scan_cmd_req_params *pstart,
7678 wmi_buf_t *buf, int *buf_len)
7679{
7680 wmi_extscan_start_cmd_fixed_param *cmd;
7681 wmi_extscan_bucket *dest_blist;
7682 wmi_extscan_bucket_channel *dest_clist;
7683 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
7684 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
7685 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
7686
7687 uint8_t *buf_ptr;
7688 int i, k, count = 0;
7689 int len = sizeof(*cmd);
7690 int nbuckets = pstart->numBuckets;
7691 int nchannels = 0;
7692
7693 /* These TLV's are are NULL by default */
7694 uint32_t ie_len_with_pad = 0;
7695 int num_ssid = 0;
7696 int num_bssid = 0;
7697 int ie_len = 0;
7698
7699 uint32_t base_period = pstart->basePeriod;
7700
7701 /* TLV placeholder for ssid_list (NULL) */
7702 len += WMI_TLV_HDR_SIZE;
7703 len += num_ssid * sizeof(wmi_ssid);
7704
7705 /* TLV placeholder for bssid_list (NULL) */
7706 len += WMI_TLV_HDR_SIZE;
7707 len += num_bssid * sizeof(wmi_mac_addr);
7708
7709 /* TLV placeholder for ie_data (NULL) */
7710 len += WMI_TLV_HDR_SIZE;
7711 len += ie_len * sizeof(uint32_t);
7712
7713 /* TLV placeholder for bucket */
7714 len += WMI_TLV_HDR_SIZE;
7715 len += nbuckets * sizeof(wmi_extscan_bucket);
7716
7717 /* TLV channel placeholder */
7718 len += WMI_TLV_HDR_SIZE;
7719 for (i = 0; i < nbuckets; i++) {
7720 nchannels += src_bucket->numChannels;
7721 src_bucket++;
7722 }
7723
Govind Singhb53420c2016-03-09 14:32:57 +05307724 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307725 __func__, nbuckets, nchannels);
7726 len += nchannels * sizeof(wmi_extscan_bucket_channel);
7727 /* Allocate the memory */
7728 *buf = wmi_buf_alloc(wmi_handle, len);
7729 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307730 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307731 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307732 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307733 }
7734 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7735 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
7736 WMITLV_SET_HDR(&cmd->tlv_header,
7737 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
7738 WMITLV_GET_STRUCT_TLVLEN
7739 (wmi_extscan_start_cmd_fixed_param));
7740
7741 cmd->request_id = pstart->requestId;
7742 cmd->vdev_id = pstart->sessionId;
7743 cmd->base_period = pstart->basePeriod;
7744 cmd->num_buckets = nbuckets;
7745 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05307746 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307747 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05307748 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307749 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05307750#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05307751 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
7752 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05307753 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
7754 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
7755#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307756 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7757
7758 /* The max dwell time is retrieved from the first channel
7759 * of the first bucket and kept common for all channels.
7760 */
7761 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
7762 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
7763 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
7764 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
7765 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7766 cmd->max_table_usage = pstart->report_threshold_percent;
7767 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
7768
7769 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05307770 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307771 cmd->probe_delay = 0;
7772 cmd->probe_spacing_time = 0;
7773 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307774 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
7775 WMI_SCAN_ADD_CCK_RATES |
7776 WMI_SCAN_ADD_OFDM_RATES |
7777 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
7778 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05307779 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
7780 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05307781 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307782 cmd->num_ssids = 0;
7783 cmd->num_bssid = 0;
7784 cmd->ie_len = 0;
7785 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
7786 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
7787
7788 buf_ptr += sizeof(*cmd);
7789 WMITLV_SET_HDR(buf_ptr,
7790 WMITLV_TAG_ARRAY_FIXED_STRUC,
7791 num_ssid * sizeof(wmi_ssid));
7792 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
7793
7794 WMITLV_SET_HDR(buf_ptr,
7795 WMITLV_TAG_ARRAY_FIXED_STRUC,
7796 num_bssid * sizeof(wmi_mac_addr));
7797 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7798
7799 ie_len_with_pad = 0;
7800 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7801 ie_len_with_pad);
7802 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7803
7804 WMITLV_SET_HDR(buf_ptr,
7805 WMITLV_TAG_ARRAY_STRUC,
7806 nbuckets * sizeof(wmi_extscan_bucket));
7807 dest_blist = (wmi_extscan_bucket *)
7808 (buf_ptr + WMI_TLV_HDR_SIZE);
7809 src_bucket = pstart->buckets;
7810
7811 /* Retrieve scanning information from each bucket and
7812 * channels and send it to the target
7813 */
7814 for (i = 0; i < nbuckets; i++) {
7815 WMITLV_SET_HDR(dest_blist,
7816 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7817 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7818
7819 dest_blist->bucket_id = src_bucket->bucket;
7820 dest_blist->base_period_multiplier =
7821 src_bucket->period / base_period;
7822 dest_blist->min_period = src_bucket->period;
7823 dest_blist->max_period = src_bucket->max_period;
7824 dest_blist->exp_backoff = src_bucket->exponent;
7825 dest_blist->exp_max_step_count = src_bucket->step_count;
7826 dest_blist->channel_band = src_bucket->band;
7827 dest_blist->num_channels = src_bucket->numChannels;
7828 dest_blist->notify_extscan_events = 0;
7829
7830 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7831 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007832 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7833 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307834
7835 if (src_bucket->reportEvents &
7836 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7837 dest_blist->forwarding_flags =
7838 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7839 dest_blist->notify_extscan_events |=
7840 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7841 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7842 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7843 } else {
7844 dest_blist->forwarding_flags =
7845 WMI_EXTSCAN_NO_FORWARDING;
7846 }
7847
7848 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7849 dest_blist->configuration_flags = 0;
7850 else
7851 dest_blist->configuration_flags =
7852 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7853
Govind Singhb53420c2016-03-09 14:32:57 +05307854 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307855 __func__, dest_blist->notify_extscan_events,
7856 dest_blist->configuration_flags,
7857 dest_blist->forwarding_flags);
7858
7859 dest_blist->min_dwell_time_active =
7860 src_bucket->min_dwell_time_active;
7861 dest_blist->max_dwell_time_active =
7862 src_bucket->max_dwell_time_active;
7863 dest_blist->min_dwell_time_passive =
7864 src_bucket->min_dwell_time_passive;
7865 dest_blist->max_dwell_time_passive =
7866 src_bucket->max_dwell_time_passive;
7867 src_channel = src_bucket->channels;
7868
7869 /* save the channel info to later populate
7870 * the channel TLV
7871 */
7872 for (k = 0; k < src_bucket->numChannels; k++) {
7873 save_channel[count++].channel = src_channel->channel;
7874 src_channel++;
7875 }
7876 dest_blist++;
7877 src_bucket++;
7878 }
7879 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7880 WMITLV_SET_HDR(buf_ptr,
7881 WMITLV_TAG_ARRAY_STRUC,
7882 nchannels * sizeof(wmi_extscan_bucket_channel));
7883 dest_clist = (wmi_extscan_bucket_channel *)
7884 (buf_ptr + WMI_TLV_HDR_SIZE);
7885
7886 /* Active or passive scan is based on the bucket dwell time
7887 * and channel specific active,passive scans are not
7888 * supported yet
7889 */
7890 for (i = 0; i < nchannels; i++) {
7891 WMITLV_SET_HDR(dest_clist,
7892 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7893 WMITLV_GET_STRUCT_TLVLEN
7894 (wmi_extscan_bucket_channel));
7895 dest_clist->channel = save_channel[i].channel;
7896 dest_clist++;
7897 }
7898 buf_ptr += WMI_TLV_HDR_SIZE +
7899 (nchannels * sizeof(wmi_extscan_bucket_channel));
7900 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307901 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307902}
7903
7904/**
7905 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7906 * @wmi_handle: wmi handle
7907 * @pstart: scan command request params
7908 *
7909 * This function sends start extscan request to fw.
7910 *
7911 * Return: CDF Status.
7912 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307913static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307914 struct wifi_scan_cmd_req_params *pstart)
7915{
Govind Singhb53420c2016-03-09 14:32:57 +05307916 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307917 wmi_buf_t buf;
7918 int len;
7919
7920 /* Fill individual elements of extscan request and
7921 * TLV for buckets, channel list.
7922 */
Govind Singhb53420c2016-03-09 14:32:57 +05307923 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307924 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307925 if (qdf_status != QDF_STATUS_SUCCESS) {
7926 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7927 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307928 }
7929 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307930 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307931 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307932 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307933 }
7934 if (wmi_unified_cmd_send(wmi_handle, buf,
7935 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307936 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307937 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307938 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307939 }
7940
Govind Singhb53420c2016-03-09 14:32:57 +05307941 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307942}
7943
7944/**
7945 * send_plm_stop_cmd_tlv() - plm stop request
7946 * @wmi_handle: wmi handle
7947 * @plm: plm request parameters
7948 *
7949 * This function request FW to stop PLM.
7950 *
7951 * Return: CDF status
7952 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307953static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307954 const struct plm_req_params *plm)
7955{
7956 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7957 int32_t len;
7958 wmi_buf_t buf;
7959 uint8_t *buf_ptr;
7960 int ret;
7961
7962 len = sizeof(*cmd);
7963 buf = wmi_buf_alloc(wmi_handle, len);
7964 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307965 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7966 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307967 }
7968
7969 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7970
7971 buf_ptr = (uint8_t *) cmd;
7972
7973 WMITLV_SET_HDR(&cmd->tlv_header,
7974 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7975 WMITLV_GET_STRUCT_TLVLEN
7976 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7977
7978 cmd->vdev_id = plm->session_id;
7979
7980 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307981 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307982
7983 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7984 WMI_VDEV_PLMREQ_STOP_CMDID);
7985 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307986 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307987 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307988 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307989 }
7990
Govind Singhb53420c2016-03-09 14:32:57 +05307991 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307992}
7993
7994/**
7995 * send_plm_start_cmd_tlv() - plm start request
7996 * @wmi_handle: wmi handle
7997 * @plm: plm request parameters
7998 *
7999 * This function request FW to start PLM.
8000 *
8001 * Return: CDF status
8002 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308003static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308004 const struct plm_req_params *plm,
8005 uint32_t *gchannel_list)
8006{
8007 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
8008 uint32_t *channel_list;
8009 int32_t len;
8010 wmi_buf_t buf;
8011 uint8_t *buf_ptr;
8012 uint8_t count;
8013 int ret;
8014
8015 /* TLV place holder for channel_list */
8016 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
8017 len += sizeof(uint32_t) * plm->plm_num_ch;
8018
8019 buf = wmi_buf_alloc(wmi_handle, len);
8020 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308021 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8022 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308023 }
8024 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
8025
8026 buf_ptr = (uint8_t *) cmd;
8027
8028 WMITLV_SET_HDR(&cmd->tlv_header,
8029 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
8030 WMITLV_GET_STRUCT_TLVLEN
8031 (wmi_vdev_plmreq_start_cmd_fixed_param));
8032
8033 cmd->vdev_id = plm->session_id;
8034
8035 cmd->meas_token = plm->meas_token;
8036 cmd->dialog_token = plm->diag_token;
8037 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05308038 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308039 cmd->off_duration = plm->meas_duration;
8040 cmd->burst_cycle = plm->burst_len;
8041 cmd->tx_power = plm->desired_tx_pwr;
8042 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
8043 cmd->num_chans = plm->plm_num_ch;
8044
8045 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
8046
Govind Singhb53420c2016-03-09 14:32:57 +05308047 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
8048 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
8049 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
8050 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
8051 WMI_LOGD("off_duration: %d", cmd->off_duration);
8052 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
8053 WMI_LOGD("tx_power: %d", cmd->tx_power);
8054 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308055
8056 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8057 (cmd->num_chans * sizeof(uint32_t)));
8058
8059 buf_ptr += WMI_TLV_HDR_SIZE;
8060 if (cmd->num_chans) {
8061 channel_list = (uint32_t *) buf_ptr;
8062 for (count = 0; count < cmd->num_chans; count++) {
8063 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308064 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308065 channel_list[count] =
8066 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308067 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308068 }
8069 buf_ptr += cmd->num_chans * sizeof(uint32_t);
8070 }
8071
8072 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8073 WMI_VDEV_PLMREQ_START_CMDID);
8074 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308075 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308076 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308077 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308078 }
8079
Govind Singhb53420c2016-03-09 14:32:57 +05308080 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308081}
8082
8083/**
8084 * send_pno_stop_cmd_tlv() - PNO stop request
8085 * @wmi_handle: wmi handle
8086 * @vdev_id: vdev id
8087 *
8088 * This function request FW to stop ongoing PNO operation.
8089 *
8090 * Return: CDF status
8091 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308092static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308093{
8094 wmi_nlo_config_cmd_fixed_param *cmd;
8095 int32_t len = sizeof(*cmd);
8096 wmi_buf_t buf;
8097 uint8_t *buf_ptr;
8098 int ret;
8099
8100 /*
8101 * TLV place holder for array of structures nlo_configured_parameters
8102 * TLV place holder for array of uint32_t channel_list
8103 * TLV place holder for chnl prediction cfg
8104 */
8105 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
8106 buf = wmi_buf_alloc(wmi_handle, len);
8107 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308108 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8109 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308110 }
8111
8112 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8113 buf_ptr = (uint8_t *) cmd;
8114
8115 WMITLV_SET_HDR(&cmd->tlv_header,
8116 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8117 WMITLV_GET_STRUCT_TLVLEN
8118 (wmi_nlo_config_cmd_fixed_param));
8119
8120 cmd->vdev_id = vdev_id;
8121 cmd->flags = WMI_NLO_CONFIG_STOP;
8122 buf_ptr += sizeof(*cmd);
8123
8124 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8125 buf_ptr += WMI_TLV_HDR_SIZE;
8126
8127 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
8128 buf_ptr += WMI_TLV_HDR_SIZE;
8129
8130 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8131 buf_ptr += WMI_TLV_HDR_SIZE;
8132
8133
8134 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8135 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8136 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308137 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308138 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308139 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308140 }
8141
Govind Singhb53420c2016-03-09 14:32:57 +05308142 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308143}
8144
8145/**
Govind Singhccb0c272016-04-01 16:30:08 +05308146 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
8147 * @buf_ptr: Buffer passed by upper layers
8148 * @pno: Buffer to be sent to the firmware
8149 *
8150 * Copy the PNO Channel prediction configuration parameters
8151 * passed by the upper layers to a WMI format TLV and send it
8152 * down to the firmware.
8153 *
8154 * Return: None
8155 */
8156static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
8157 struct pno_scan_req_params *pno)
8158{
8159 nlo_channel_prediction_cfg *channel_prediction_cfg =
8160 (nlo_channel_prediction_cfg *) buf_ptr;
8161 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
8162 WMITLV_TAG_ARRAY_BYTE,
8163 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05308164#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05308165 channel_prediction_cfg->enable = pno->pno_channel_prediction;
8166 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
8167 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
8168 channel_prediction_cfg->full_scan_period_ms =
8169 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05308170#endif
Govind Singhccb0c272016-04-01 16:30:08 +05308171 buf_ptr += sizeof(nlo_channel_prediction_cfg);
8172 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
8173 channel_prediction_cfg->enable,
8174 channel_prediction_cfg->top_k_num,
8175 channel_prediction_cfg->stationary_threshold,
8176 channel_prediction_cfg->full_scan_period_ms);
8177}
8178
8179/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008180 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
8181 * @wmi_handle: wmi handle
8182 * @params: configuration parameters
8183 *
8184 * Return: QDF_STATUS
8185 */
8186static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
8187 struct nlo_mawc_params *params)
8188{
8189 wmi_buf_t buf = NULL;
8190 QDF_STATUS status;
8191 int len;
8192 uint8_t *buf_ptr;
8193 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
8194
8195 len = sizeof(*wmi_nlo_mawc_params);
8196 buf = wmi_buf_alloc(wmi_handle, len);
8197 if (!buf) {
8198 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8199 return QDF_STATUS_E_NOMEM;
8200 }
8201
8202 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8203 wmi_nlo_mawc_params =
8204 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
8205 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
8206 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
8207 WMITLV_GET_STRUCT_TLVLEN
8208 (wmi_nlo_configure_mawc_cmd_fixed_param));
8209 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
8210 if (params->enable)
8211 wmi_nlo_mawc_params->enable = 1;
8212 else
8213 wmi_nlo_mawc_params->enable = 0;
8214 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
8215 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
8216 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07008217 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
8218 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
8219 wmi_nlo_mawc_params->exp_backoff_ratio,
8220 wmi_nlo_mawc_params->init_scan_interval,
8221 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008222
8223 status = wmi_unified_cmd_send(wmi_handle, buf,
8224 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
8225 if (QDF_IS_STATUS_ERROR(status)) {
8226 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
8227 status);
8228 wmi_buf_free(buf);
8229 return QDF_STATUS_E_FAILURE;
8230 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008231
8232 return QDF_STATUS_SUCCESS;
8233}
8234
8235/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05308236 * send_pno_start_cmd_tlv() - PNO start request
8237 * @wmi_handle: wmi handle
8238 * @pno: PNO request
8239 *
8240 * This function request FW to start PNO request.
8241 * Request: CDF status
8242 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308243static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05308244 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308245{
8246 wmi_nlo_config_cmd_fixed_param *cmd;
8247 nlo_configured_parameters *nlo_list;
8248 uint32_t *channel_list;
8249 int32_t len;
8250 wmi_buf_t buf;
8251 uint8_t *buf_ptr;
8252 uint8_t i;
8253 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308254 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308255 connected_nlo_rssi_params *nlo_relative_rssi;
8256 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308257
8258 /*
8259 * TLV place holder for array nlo_configured_parameters(nlo_list)
8260 * TLV place holder for array of uint32_t channel_list
8261 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308262 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308263 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05308264 */
8265 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308266 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308267 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308268
Abhishek Singh5987b632017-03-03 22:09:07 +05308269 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308270 WMI_NLO_MAX_CHAN);
8271 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05308272 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308273 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308274 len += sizeof(enlo_candidate_score_params);
8275 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308276 len += sizeof(connected_nlo_rssi_params);
8277 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308278
8279 buf = wmi_buf_alloc(wmi_handle, len);
8280 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308281 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8282 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308283 }
8284
8285 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8286
8287 buf_ptr = (uint8_t *) cmd;
8288 WMITLV_SET_HDR(&cmd->tlv_header,
8289 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8290 WMITLV_GET_STRUCT_TLVLEN
8291 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05308292 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308293 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
8294
Govind Singh87542482016-06-08 19:40:11 +05308295#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05308296 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05308297 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05308298#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05308299 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05308300 cmd->active_dwell_time = pno->active_dwell_time;
8301 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308302
Manjeet Singhcd2dc062016-08-11 15:31:34 +05308303 if (pno->do_passive_scan)
8304 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308305 /* Copy scan interval */
8306 cmd->fast_scan_period = pno->fast_scan_period;
8307 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08008308 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308309 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07008310 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05308311 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308312 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05308313 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308314
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05308315 /* mac randomization attributes */
8316 if (pno->scan_random.randomize) {
8317 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
8318 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
8319 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
8320 pno->scan_random.mac_mask,
8321 &cmd->mac_addr,
8322 &cmd->mac_mask);
8323 }
8324
Govind Singh4eacd2b2016-03-07 14:24:22 +05308325 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
8326
Abhishek Singh5987b632017-03-03 22:09:07 +05308327 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05308328 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308329 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8330 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
8331 buf_ptr += WMI_TLV_HDR_SIZE;
8332
8333 nlo_list = (nlo_configured_parameters *) buf_ptr;
8334 for (i = 0; i < cmd->no_of_ssids; i++) {
8335 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
8336 WMITLV_TAG_ARRAY_BYTE,
8337 WMITLV_GET_STRUCT_TLVLEN
8338 (nlo_configured_parameters));
8339 /* Copy ssid and it's length */
8340 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05308341 nlo_list[i].ssid.ssid.ssid_len =
8342 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05308343 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05308344 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308345 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05308346 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308347 nlo_list[i].ssid.ssid.ssid_len,
8348 (char *)nlo_list[i].ssid.ssid.ssid,
8349 nlo_list[i].ssid.ssid.ssid_len);
8350
8351 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05308352 if (pno->networks_list[i].rssi_thresh &&
8353 pno->networks_list[i].rssi_thresh >
8354 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05308355 nlo_list[i].rssi_cond.valid = true;
8356 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05308357 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05308358 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308359 nlo_list[i].rssi_cond.rssi);
8360 }
8361 nlo_list[i].bcast_nw_type.valid = true;
8362 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05308363 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07008364 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308365 nlo_list[i].bcast_nw_type.bcast_nw_type);
8366 }
8367 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
8368
8369 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05308370 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308371 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05308372 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308373 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8374 (cmd->num_of_channels * sizeof(uint32_t)));
8375 buf_ptr += WMI_TLV_HDR_SIZE;
8376
8377 channel_list = (uint32_t *) buf_ptr;
8378 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05308379 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05308380
8381 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05308382 channel_list[i] =
8383 wlan_chan_to_freq(pno->
8384 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308385
Govind Singhb53420c2016-03-09 14:32:57 +05308386 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308387 }
8388 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
8389 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8390 sizeof(nlo_channel_prediction_cfg));
8391 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05308392 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308393 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308394 /** TODO: Discrete firmware doesn't have command/option to configure
8395 * App IE which comes from wpa_supplicant as of part PNO start request.
8396 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308397 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
8398 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
8399 buf_ptr += sizeof(enlo_candidate_score_params);
8400
8401 if (ie_whitelist->white_list) {
8402 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
8403 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
8404 &cmd->num_vendor_oui,
8405 ie_whitelist);
8406 }
8407
8408 /* ie white list */
8409 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8410 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
8411 buf_ptr += WMI_TLV_HDR_SIZE;
8412 if (cmd->num_vendor_oui != 0) {
8413 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
8414 ie_whitelist->voui);
8415 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
8416 }
8417
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308418 if (pno->relative_rssi_set)
8419 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
8420
8421 /*
8422 * Firmware calculation using connected PNO params:
8423 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
8424 * deduction of rssi_pref for chosen band_pref and
8425 * addition of rssi_pref for remaining bands (other than chosen band).
8426 */
8427 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
8428 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
8429 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
8430 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
8431 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
8432 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
8433 buf_ptr += sizeof(*nlo_relative_rssi);
8434
8435 /*
8436 * As of now Kernel and Host supports one band and rssi preference.
8437 * Firmware supports array of band and rssi preferences
8438 */
8439 cmd->num_cnlo_band_pref = 1;
8440 WMITLV_SET_HDR(buf_ptr,
8441 WMITLV_TAG_ARRAY_STRUC,
8442 cmd->num_cnlo_band_pref *
8443 sizeof(connected_nlo_bss_band_rssi_pref));
8444 buf_ptr += WMI_TLV_HDR_SIZE;
8445
8446 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
8447 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
8448 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
8449 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
8450 WMITLV_GET_STRUCT_TLVLEN(
8451 connected_nlo_bss_band_rssi_pref));
8452 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
8453 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
8454 WMI_LOGI("band_pref %d, rssi_pref %d",
8455 nlo_band_rssi[i].band,
8456 nlo_band_rssi[i].rssi_pref);
8457 }
8458 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
8459
Govind Singh4eacd2b2016-03-07 14:24:22 +05308460 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8461 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8462 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308463 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308464 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308465 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308466 }
8467
Govind Singhb53420c2016-03-09 14:32:57 +05308468 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308469}
8470
8471/* send_set_ric_req_cmd_tlv() - set ric request element
8472 * @wmi_handle: wmi handle
8473 * @msg: message
8474 * @is_add_ts: is addts required
8475 *
8476 * This function sets ric request element for 11r roaming.
8477 *
8478 * Return: CDF status
8479 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308480static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308481 void *msg, uint8_t is_add_ts)
8482{
8483 wmi_ric_request_fixed_param *cmd;
8484 wmi_ric_tspec *tspec_param;
8485 wmi_buf_t buf;
8486 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05308487 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308488 int32_t len = sizeof(wmi_ric_request_fixed_param) +
8489 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
8490
8491 buf = wmi_buf_alloc(wmi_handle, len);
8492 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308493 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8494 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308495 }
8496
8497 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8498
8499 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
8500 WMITLV_SET_HDR(&cmd->tlv_header,
8501 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
8502 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
8503 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07008504 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308505 else
8506 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
8507 cmd->num_ric_request = 1;
8508 cmd->is_add_ric = is_add_ts;
8509
8510 buf_ptr += sizeof(wmi_ric_request_fixed_param);
8511 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
8512
8513 buf_ptr += WMI_TLV_HDR_SIZE;
8514 tspec_param = (wmi_ric_tspec *) buf_ptr;
8515 WMITLV_SET_HDR(&tspec_param->tlv_header,
8516 WMITLV_TAG_STRUC_wmi_ric_tspec,
8517 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
8518
8519 if (is_add_ts)
8520 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05308521#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05308522 else
8523 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05308524#endif
8525 if (ptspecIE) {
8526 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308527#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05308528 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
8529 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308530#else
Govind Singh87542482016-06-08 19:40:11 +05308531 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
8532 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308533#endif /* ANI_LITTLE_BIT_ENDIAN */
8534
Govind Singh87542482016-06-08 19:40:11 +05308535 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
8536 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
8537 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
8538 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
8539 tspec_param->inactivity_interval = ptspecIE->inactInterval;
8540 tspec_param->suspension_interval = ptspecIE->suspendInterval;
8541 tspec_param->svc_start_time = ptspecIE->svcStartTime;
8542 tspec_param->min_data_rate = ptspecIE->minDataRate;
8543 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
8544 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
8545 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
8546 tspec_param->delay_bound = ptspecIE->delayBound;
8547 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
8548 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
8549 tspec_param->medium_time = 0;
8550 }
Govind Singhb53420c2016-03-09 14:32:57 +05308551 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308552
8553 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8554 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308555 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308556 __func__);
8557 if (is_add_ts)
8558 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05308559 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308560 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308561 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308562 }
8563
Govind Singhb53420c2016-03-09 14:32:57 +05308564 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308565}
8566
8567/**
8568 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
8569 * @wmi_handle: wmi handle
8570 * @clear_req: ll stats clear request command params
8571 *
Govind Singhb53420c2016-03-09 14:32:57 +05308572 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308573 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308574static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308575 const struct ll_stats_clear_params *clear_req,
8576 uint8_t addr[IEEE80211_ADDR_LEN])
8577{
8578 wmi_clear_link_stats_cmd_fixed_param *cmd;
8579 int32_t len;
8580 wmi_buf_t buf;
8581 uint8_t *buf_ptr;
8582 int ret;
8583
8584 len = sizeof(*cmd);
8585 buf = wmi_buf_alloc(wmi_handle, len);
8586
8587 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308588 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8589 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308590 }
8591
8592 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308593 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308594 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
8595
8596 WMITLV_SET_HDR(&cmd->tlv_header,
8597 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
8598 WMITLV_GET_STRUCT_TLVLEN
8599 (wmi_clear_link_stats_cmd_fixed_param));
8600
8601 cmd->stop_stats_collection_req = clear_req->stop_req;
8602 cmd->vdev_id = clear_req->sta_id;
8603 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
8604
8605 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8606 &cmd->peer_macaddr);
8607
Govind Singhb53420c2016-03-09 14:32:57 +05308608 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
8609 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
8610 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
8611 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
8612 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308613 cmd->peer_macaddr); */
8614
8615 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8616 WMI_CLEAR_LINK_STATS_CMDID);
8617 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308618 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308619 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308620 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308621 }
8622
Govind Singhb53420c2016-03-09 14:32:57 +05308623 WMI_LOGD("Clear Link Layer Stats request sent successfully");
8624 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308625}
8626
8627/**
8628 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
8629 * @wmi_handle: wmi handle
8630 * @setReq: ll stats set request command params
8631 *
Govind Singhb53420c2016-03-09 14:32:57 +05308632 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308633 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308634static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308635 const struct ll_stats_set_params *set_req)
8636{
8637 wmi_start_link_stats_cmd_fixed_param *cmd;
8638 int32_t len;
8639 wmi_buf_t buf;
8640 uint8_t *buf_ptr;
8641 int ret;
8642
8643 len = sizeof(*cmd);
8644 buf = wmi_buf_alloc(wmi_handle, len);
8645
8646 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308647 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8648 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308649 }
8650
8651 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308652 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308653 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
8654
8655 WMITLV_SET_HDR(&cmd->tlv_header,
8656 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
8657 WMITLV_GET_STRUCT_TLVLEN
8658 (wmi_start_link_stats_cmd_fixed_param));
8659
8660 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
8661 cmd->aggressive_statistics_gathering =
8662 set_req->aggressive_statistics_gathering;
8663
Govind Singhb53420c2016-03-09 14:32:57 +05308664 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
8665 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
8666 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308667
8668 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8669 WMI_START_LINK_STATS_CMDID);
8670 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308671 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308672 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308673 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308674 }
8675
Govind Singhb53420c2016-03-09 14:32:57 +05308676 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308677}
8678
8679/**
8680 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
8681 * @wmi_handle:wmi handle
8682 * @get_req:ll stats get request command params
8683 * @addr: mac address
8684 *
Govind Singhb53420c2016-03-09 14:32:57 +05308685 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308686 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308687static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308688 const struct ll_stats_get_params *get_req,
8689 uint8_t addr[IEEE80211_ADDR_LEN])
8690{
8691 wmi_request_link_stats_cmd_fixed_param *cmd;
8692 int32_t len;
8693 wmi_buf_t buf;
8694 uint8_t *buf_ptr;
8695 int ret;
8696
8697 len = sizeof(*cmd);
8698 buf = wmi_buf_alloc(wmi_handle, len);
8699
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308700 if (!buf) {
8701 WMI_LOGE("%s: buf allocation failed", __func__);
8702 return QDF_STATUS_E_NOMEM;
8703 }
8704
Govind Singh4eacd2b2016-03-07 14:24:22 +05308705 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308706 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308707 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8708
8709 WMITLV_SET_HDR(&cmd->tlv_header,
8710 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8711 WMITLV_GET_STRUCT_TLVLEN
8712 (wmi_request_link_stats_cmd_fixed_param));
8713
8714 cmd->request_id = get_req->req_id;
8715 cmd->stats_type = get_req->param_id_mask;
8716 cmd->vdev_id = get_req->sta_id;
8717
8718 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8719 &cmd->peer_macaddr);
8720
Govind Singhb53420c2016-03-09 14:32:57 +05308721 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008722 WMI_LOGD("Request ID : %u", cmd->request_id);
8723 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308724 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8725 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308726
8727 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8728 WMI_REQUEST_LINK_STATS_CMDID);
8729 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308730 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308731 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308732 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308733 }
8734
Govind Singhb53420c2016-03-09 14:32:57 +05308735 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308736}
8737
Govind Singh4eacd2b2016-03-07 14:24:22 +05308738
Govind Singh20c5dac2016-03-07 15:33:31 +05308739/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308740 * send_congestion_cmd_tlv() - send request to fw to get CCA
8741 * @wmi_handle: wmi handle
8742 * @vdev_id: vdev id
8743 *
8744 * Return: CDF status
8745 */
8746static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
8747 A_UINT8 vdev_id)
8748{
8749 wmi_buf_t buf;
8750 wmi_request_stats_cmd_fixed_param *cmd;
8751 uint8_t len;
8752 uint8_t *buf_ptr;
8753
8754 len = sizeof(*cmd);
8755 buf = wmi_buf_alloc(wmi_handle, len);
8756 if (!buf) {
8757 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8758 return QDF_STATUS_E_FAILURE;
8759 }
8760
8761 buf_ptr = wmi_buf_data(buf);
8762 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8763 WMITLV_SET_HDR(&cmd->tlv_header,
8764 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8765 WMITLV_GET_STRUCT_TLVLEN
8766 (wmi_request_stats_cmd_fixed_param));
8767
8768 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8769 cmd->vdev_id = vdev_id;
8770 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8771 cmd->vdev_id, cmd->stats_id);
8772
8773 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8774 WMI_REQUEST_STATS_CMDID)) {
8775 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8776 __func__);
8777 wmi_buf_free(buf);
8778 return QDF_STATUS_E_FAILURE;
8779 }
8780
8781 return QDF_STATUS_SUCCESS;
8782}
8783
8784/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308785 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8786 * @wmi_handle: wmi handle
8787 * @rssi_req: get RSSI request
8788 *
8789 * Return: CDF status
8790 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308791static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308792{
8793 wmi_buf_t buf;
8794 wmi_request_stats_cmd_fixed_param *cmd;
8795 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8796
8797 buf = wmi_buf_alloc(wmi_handle, len);
8798 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308799 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8800 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308801 }
8802
8803 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8804 WMITLV_SET_HDR(&cmd->tlv_header,
8805 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8806 WMITLV_GET_STRUCT_TLVLEN
8807 (wmi_request_stats_cmd_fixed_param));
8808 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8809 if (wmi_unified_cmd_send
8810 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308811 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308812 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308813 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308814 }
8815
Govind Singhb53420c2016-03-09 14:32:57 +05308816 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308817}
8818
8819/**
8820 * send_snr_cmd_tlv() - get RSSI from fw
8821 * @wmi_handle: wmi handle
8822 * @vdev_id: vdev id
8823 *
8824 * Return: CDF status
8825 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308826static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308827{
8828 wmi_buf_t buf;
8829 wmi_request_stats_cmd_fixed_param *cmd;
8830 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8831
8832 buf = wmi_buf_alloc(wmi_handle, len);
8833 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308834 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8835 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308836 }
8837
8838 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8839 cmd->vdev_id = vdev_id;
8840
8841 WMITLV_SET_HDR(&cmd->tlv_header,
8842 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8843 WMITLV_GET_STRUCT_TLVLEN
8844 (wmi_request_stats_cmd_fixed_param));
8845 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8846 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8847 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308848 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308849 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308850 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308851 }
8852
Govind Singhb53420c2016-03-09 14:32:57 +05308853 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308854}
8855
8856/**
8857 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8858 * @wmi_handle: wmi handle
8859 * @link_status: get link params
8860 *
8861 * Return: CDF status
8862 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308863static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308864 struct link_status_params *link_status)
8865{
8866 wmi_buf_t buf;
8867 wmi_request_stats_cmd_fixed_param *cmd;
8868 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8869
8870 buf = wmi_buf_alloc(wmi_handle, len);
8871 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308872 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8873 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308874 }
8875
8876 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8877 WMITLV_SET_HDR(&cmd->tlv_header,
8878 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8879 WMITLV_GET_STRUCT_TLVLEN
8880 (wmi_request_stats_cmd_fixed_param));
8881 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8882 cmd->vdev_id = link_status->session_id;
8883 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8884 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308885 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308886 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308887 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308888 }
8889
Govind Singhb53420c2016-03-09 14:32:57 +05308890 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308891}
8892
Govind Singh20c5dac2016-03-07 15:33:31 +05308893/**
8894 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8895 * @wmi_handle: wmi handle
8896 * @ta_dhcp_ind: DHCP indication parameter
8897 *
8898 * Return: CDF Status
8899 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308900static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308901 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8902{
Govind Singh67922e82016-04-01 16:48:57 +05308903 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308904 wmi_buf_t buf = NULL;
8905 uint8_t *buf_ptr;
8906 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8907 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8908
8909
8910 buf = wmi_buf_alloc(wmi_handle, len);
8911 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308912 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8913 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308914 }
8915
8916 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8917 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8918 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8919 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8920 WMITLV_GET_STRUCT_TLVLEN
8921 (wmi_peer_set_param_cmd_fixed_param));
8922
8923 /* fill in values */
8924 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8925 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8926 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308927 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308928 &ta_dhcp_ind->peer_macaddr,
8929 sizeof(ta_dhcp_ind->peer_macaddr));
8930
8931 status = wmi_unified_cmd_send(wmi_handle, buf,
8932 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308933 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308934 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308935 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308936 wmi_buf_free(buf);
8937 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308938
Govind Singh67922e82016-04-01 16:48:57 +05308939 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308940}
8941
8942/**
8943 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8944 * @wmi_handle: wmi handle
8945 * @pLinkSpeed: link speed info
8946 *
8947 * Return: CDF status
8948 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308949static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308950 wmi_mac_addr peer_macaddr)
8951{
8952 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8953 wmi_buf_t wmi_buf;
8954 uint32_t len;
8955 uint8_t *buf_ptr;
8956
8957 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8958 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8959 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308960 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8961 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308962 }
8963 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8964
8965 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8966 WMITLV_SET_HDR(&cmd->tlv_header,
8967 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8968 WMITLV_GET_STRUCT_TLVLEN
8969 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8970
8971 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308972 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308973 &peer_macaddr,
8974 sizeof(peer_macaddr));
8975
8976
8977 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8978 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308979 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308980 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308981 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308982 }
Govind Singhb53420c2016-03-09 14:32:57 +05308983 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308984}
8985
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308986#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308987/**
8988 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8989 * @wmi_handle: wmi handler
8990 * @egap_params: pointer to egap_params
8991 *
8992 * Return: 0 for success, otherwise appropriate error code
8993 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308994static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308995 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308996{
8997 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8998 wmi_buf_t buf;
8999 int32_t err;
9000
9001 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9002 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309003 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
9004 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309005 }
9006 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
9007 WMITLV_SET_HDR(&cmd->tlv_header,
9008 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
9009 WMITLV_GET_STRUCT_TLVLEN(
9010 wmi_ap_ps_egap_param_cmd_fixed_param));
9011
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05309012 cmd->enable = egap_params->host_enable_egap;
9013 cmd->inactivity_time = egap_params->egap_inactivity_time;
9014 cmd->wait_time = egap_params->egap_wait_time;
9015 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05309016 err = wmi_unified_cmd_send(wmi_handle, buf,
9017 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
9018 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05309019 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309020 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309021 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309022 }
9023
Govind Singhb53420c2016-03-09 14:32:57 +05309024 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309025}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05309026#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05309027
9028/**
9029 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
9030 * @wmi_handl: wmi handle
9031 * @cmd: Profiling command index
9032 * @value1: parameter1 value
9033 * @value2: parameter2 value
9034 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309035 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309036 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309037static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309038 uint32_t cmd, uint32_t value1, uint32_t value2)
9039{
9040 wmi_buf_t buf;
9041 int32_t len = 0;
9042 int ret;
9043 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
9044 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
9045 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
9046 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
9047
9048 switch (cmd) {
9049 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
9050 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
9051 buf = wmi_buf_alloc(wmi_handle, len);
9052 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309053 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309054 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309055 }
9056 prof_trig_cmd =
9057 (wmi_wlan_profile_trigger_cmd_fixed_param *)
9058 wmi_buf_data(buf);
9059 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
9060 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
9061 WMITLV_GET_STRUCT_TLVLEN
9062 (wmi_wlan_profile_trigger_cmd_fixed_param));
9063 prof_trig_cmd->enable = value1;
9064 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9065 WMI_WLAN_PROFILE_TRIGGER_CMDID);
9066 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309067 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309068 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309069 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309070 return ret;
9071 }
9072 break;
9073
9074 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
9075 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
9076 buf = wmi_buf_alloc(wmi_handle, len);
9077 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309078 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309079 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309080 }
9081 profile_getdata_cmd =
9082 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
9083 wmi_buf_data(buf);
9084 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
9085 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
9086 WMITLV_GET_STRUCT_TLVLEN
9087 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
9088 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9089 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
9090 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309091 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309092 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309093 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309094 return ret;
9095 }
9096 break;
9097
9098 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
9099 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
9100 buf = wmi_buf_alloc(wmi_handle, len);
9101 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309102 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309103 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309104 }
9105 hist_intvl_cmd =
9106 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
9107 wmi_buf_data(buf);
9108 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
9109 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
9110 WMITLV_GET_STRUCT_TLVLEN
9111 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
9112 hist_intvl_cmd->profile_id = value1;
9113 hist_intvl_cmd->value = value2;
9114 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9115 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
9116 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309117 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309118 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309119 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309120 return ret;
9121 }
9122 break;
9123
9124 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
9125 len =
9126 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
9127 buf = wmi_buf_alloc(wmi_handle, len);
9128 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309129 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309130 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309131 }
9132 profile_enable_cmd =
9133 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
9134 wmi_buf_data(buf);
9135 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
9136 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
9137 WMITLV_GET_STRUCT_TLVLEN
9138 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
9139 profile_enable_cmd->profile_id = value1;
9140 profile_enable_cmd->enable = value2;
9141 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9142 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
9143 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309144 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309145 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309146 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309147 return ret;
9148 }
9149 break;
9150
9151 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309152 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309153 break;
9154 }
9155
9156 return 0;
9157}
9158
Paul Zhang92ab8d32017-12-08 16:08:00 +08009159static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
9160 struct wlm_latency_level_param *params)
9161{
9162 wmi_wlm_config_cmd_fixed_param *cmd;
9163 wmi_buf_t buf;
9164 uint32_t len = sizeof(*cmd);
9165 static uint32_t ll[4] = {100, 60, 40, 20};
9166
9167 buf = wmi_buf_alloc(wmi_handle, len);
9168 if (!buf) {
9169 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9170 return QDF_STATUS_E_NOMEM;
9171 }
9172 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
9173 WMITLV_SET_HDR(&cmd->tlv_header,
9174 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
9175 WMITLV_GET_STRUCT_TLVLEN
9176 (wmi_wlm_config_cmd_fixed_param));
9177 cmd->vdev_id = params->vdev_id;
9178 cmd->latency_level = params->wlm_latency_level;
9179 cmd->ul_latency = ll[params->wlm_latency_level];
9180 cmd->dl_latency = ll[params->wlm_latency_level];
9181 cmd->flags = params->wlm_latency_flags;
9182 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9183 WMI_WLM_CONFIG_CMDID)) {
9184 WMI_LOGE("%s: Failed to send setting latency config command",
9185 __func__);
9186 wmi_buf_free(buf);
9187 return QDF_STATUS_E_FAILURE;
9188 }
9189
9190 return 0;
9191}
Govind Singh20c5dac2016-03-07 15:33:31 +05309192/**
9193 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
9194 * @wmi_handle: wmi handle
9195 * @vdev_id: vdev id
9196 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309197 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309198 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309199static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309200{
9201 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
9202 wmi_buf_t buf;
9203 int32_t len = sizeof(*cmd);
9204
Govind Singhb53420c2016-03-09 14:32:57 +05309205 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309206 buf = wmi_buf_alloc(wmi_handle, len);
9207 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309208 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309209 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309210 }
9211 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
9212 wmi_buf_data(buf);
9213 WMITLV_SET_HDR(&cmd->tlv_header,
9214 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
9215 WMITLV_GET_STRUCT_TLVLEN
9216 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
9217 cmd->vdev_id = vdev_id;
9218 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
9219 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9220 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309221 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309222 __func__);
9223 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309224 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309225 }
9226
9227 return 0;
9228}
9229
9230/**
9231 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
9232 * @wmi_handle: wmi handle
9233 * @vdev_id: vdev id
9234 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309235 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309236 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309237static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309238 uint8_t vdev_id)
9239{
9240 wmi_csa_offload_enable_cmd_fixed_param *cmd;
9241 wmi_buf_t buf;
9242 int32_t len = sizeof(*cmd);
9243
Govind Singhb53420c2016-03-09 14:32:57 +05309244 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309245 buf = wmi_buf_alloc(wmi_handle, len);
9246 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309247 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309248 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309249 }
9250 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
9251 WMITLV_SET_HDR(&cmd->tlv_header,
9252 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
9253 WMITLV_GET_STRUCT_TLVLEN
9254 (wmi_csa_offload_enable_cmd_fixed_param));
9255 cmd->vdev_id = vdev_id;
9256 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
9257 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9258 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309259 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309260 __func__);
9261 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309262 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309263 }
9264
9265 return 0;
9266}
9267
Naveen Rawat42cd1e62017-05-13 15:56:57 -07009268#ifdef WLAN_FEATURE_CIF_CFR
9269/**
9270 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
9271 * @wmi_handle: wmi handle
9272 * @data_len: len of dma cfg req
9273 * @data: dma cfg req
9274 *
9275 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9276 */
9277static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9278 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
9279{
9280 wmi_buf_t buf;
9281 uint8_t *cmd;
9282 QDF_STATUS ret;
9283
9284 WMITLV_SET_HDR(cfg,
9285 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
9286 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
9287
9288 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
9289 if (!buf) {
9290 WMI_LOGE(FL("wmi_buf_alloc failed"));
9291 return QDF_STATUS_E_FAILURE;
9292 }
9293
9294 cmd = (uint8_t *) wmi_buf_data(buf);
9295 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
9296 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
9297 sizeof(*cfg));
9298 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
9299 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
9300 if (QDF_IS_STATUS_ERROR(ret)) {
9301 WMI_LOGE(FL(":wmi cmd send failed"));
9302 wmi_buf_free(buf);
9303 }
9304
9305 return ret;
9306}
9307#endif
9308
Govind Singh20c5dac2016-03-07 15:33:31 +05309309/**
Sathish Kumarf396c722017-11-17 17:30:41 +05309310 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
9311 * @wmi_handle: wmi handle
9312 * @data_len: len of dma cfg req
9313 * @data: dma cfg req
9314 *
9315 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9316 */
9317static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9318 struct direct_buf_rx_cfg_req *cfg)
9319{
9320 wmi_buf_t buf;
9321 wmi_dma_ring_cfg_req_fixed_param *cmd;
9322 QDF_STATUS ret;
9323 int32_t len = sizeof(*cmd);
9324
9325 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9326 if (!buf) {
9327 WMI_LOGE(FL("wmi_buf_alloc failed"));
9328 return QDF_STATUS_E_FAILURE;
9329 }
9330
9331 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
9332
9333 WMITLV_SET_HDR(&cmd->tlv_header,
9334 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
9335 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
9336
9337 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9338 cfg->pdev_id);
9339 cmd->mod_id = cfg->mod_id;
9340 cmd->base_paddr_lo = cfg->base_paddr_lo;
9341 cmd->base_paddr_hi = cfg->base_paddr_hi;
9342 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
9343 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
9344 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
9345 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
9346 cmd->num_elems = cfg->num_elems;
9347 cmd->buf_size = cfg->buf_size;
9348 cmd->num_resp_per_event = cfg->num_resp_per_event;
9349 cmd->event_timeout_ms = cfg->event_timeout_ms;
9350
9351 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
9352 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
9353 "head idx paddr hi %x tail idx paddr lo %x"
9354 "tail idx addr hi %x num elems %d buf size %d num resp %d"
9355 "event timeout %d\n", __func__, cmd->pdev_id,
9356 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
9357 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
9358 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
9359 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
9360 cmd->event_timeout_ms);
9361 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9362 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
9363 if (QDF_IS_STATUS_ERROR(ret)) {
9364 WMI_LOGE(FL(":wmi cmd send failed"));
9365 wmi_buf_free(buf);
9366 }
9367
9368 return ret;
9369}
9370
9371/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009372 * send_start_11d_scan_cmd_tlv() - start 11d scan request
9373 * @wmi_handle: wmi handle
9374 * @start_11d_scan: 11d scan start request parameters
9375 *
9376 * This function request FW to start 11d scan.
9377 *
9378 * Return: QDF status
9379 */
9380static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9381 struct reg_start_11d_scan_req *start_11d_scan)
9382{
9383 wmi_11d_scan_start_cmd_fixed_param *cmd;
9384 int32_t len;
9385 wmi_buf_t buf;
9386 int ret;
9387
9388 len = sizeof(*cmd);
9389 buf = wmi_buf_alloc(wmi_handle, len);
9390 if (!buf) {
9391 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9392 return QDF_STATUS_E_NOMEM;
9393 }
9394
9395 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
9396
9397 WMITLV_SET_HDR(&cmd->tlv_header,
9398 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
9399 WMITLV_GET_STRUCT_TLVLEN
9400 (wmi_11d_scan_start_cmd_fixed_param));
9401
9402 cmd->vdev_id = start_11d_scan->vdev_id;
9403 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
9404 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
9405
9406 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
9407
9408 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9409 WMI_11D_SCAN_START_CMDID);
9410 if (ret) {
9411 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
9412 wmi_buf_free(buf);
9413 return QDF_STATUS_E_FAILURE;
9414 }
9415
9416 return QDF_STATUS_SUCCESS;
9417}
9418
9419/**
9420 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
9421 * @wmi_handle: wmi handle
9422 * @start_11d_scan: 11d scan stop request parameters
9423 *
9424 * This function request FW to stop 11d scan.
9425 *
9426 * Return: QDF status
9427 */
9428static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9429 struct reg_stop_11d_scan_req *stop_11d_scan)
9430{
9431 wmi_11d_scan_stop_cmd_fixed_param *cmd;
9432 int32_t len;
9433 wmi_buf_t buf;
9434 int ret;
9435
9436 len = sizeof(*cmd);
9437 buf = wmi_buf_alloc(wmi_handle, len);
9438 if (!buf) {
9439 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9440 return QDF_STATUS_E_NOMEM;
9441 }
9442
9443 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
9444
9445 WMITLV_SET_HDR(&cmd->tlv_header,
9446 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
9447 WMITLV_GET_STRUCT_TLVLEN
9448 (wmi_11d_scan_stop_cmd_fixed_param));
9449
9450 cmd->vdev_id = stop_11d_scan->vdev_id;
9451
9452 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
9453
9454 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9455 WMI_11D_SCAN_STOP_CMDID);
9456 if (ret) {
9457 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
9458 wmi_buf_free(buf);
9459 return QDF_STATUS_E_FAILURE;
9460 }
9461
9462 return QDF_STATUS_SUCCESS;
9463}
9464
9465/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309466 * send_start_oem_data_cmd_tlv() - start OEM data request to target
9467 * @wmi_handle: wmi handle
9468 * @startOemDataReq: start request params
9469 *
9470 * Return: CDF status
9471 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309472static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07009473 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05309474 uint8_t *data)
9475{
9476 wmi_buf_t buf;
9477 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309478 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309479
9480 buf = wmi_buf_alloc(wmi_handle,
9481 (data_len + WMI_TLV_HDR_SIZE));
9482 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309483 WMI_LOGE(FL("wmi_buf_alloc failed"));
9484 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309485 }
9486
9487 cmd = (uint8_t *) wmi_buf_data(buf);
9488
9489 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
9490 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309491 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05309492 data_len);
9493
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08009494 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309495 data_len);
9496
9497 ret = wmi_unified_cmd_send(wmi_handle, buf,
9498 (data_len +
9499 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
9500
Govind Singh67922e82016-04-01 16:48:57 +05309501 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309502 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309503 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309504 }
9505
Govind Singh67922e82016-04-01 16:48:57 +05309506 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309507}
9508
9509/**
9510 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
9511 * @wmi_handle: wmi handle
9512 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
9513 *
9514 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
9515 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
9516 * to firmware based on phyerr filtering
9517 * offload status.
9518 *
9519 * Return: 1 success, 0 failure
9520 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309521static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05309522send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
9523 bool dfs_phyerr_filter_offload)
9524{
9525 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
9526 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
9527 wmi_buf_t buf;
9528 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05309529 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309530
9531
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07009532 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05309533 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309534 __func__);
9535 len = sizeof(*disable_phyerr_offload_cmd);
9536 buf = wmi_buf_alloc(wmi_handle, len);
9537 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309538 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309539 return 0;
9540 }
9541 disable_phyerr_offload_cmd =
9542 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
9543 wmi_buf_data(buf);
9544
9545 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
9546 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
9547 WMITLV_GET_STRUCT_TLVLEN
9548 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
9549
9550 /*
9551 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
9552 * to the firmware to disable the phyerror
9553 * filtering offload.
9554 */
9555 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9556 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309557 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309558 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309559 __func__, ret);
9560 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309561 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309562 }
Govind Singhb53420c2016-03-09 14:32:57 +05309563 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309564 __func__);
9565 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05309566 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309567 __func__);
9568
9569 len = sizeof(*enable_phyerr_offload_cmd);
9570 buf = wmi_buf_alloc(wmi_handle, len);
9571 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309572 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9573 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309574 }
9575
9576 enable_phyerr_offload_cmd =
9577 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
9578 wmi_buf_data(buf);
9579
9580 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
9581 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
9582 WMITLV_GET_STRUCT_TLVLEN
9583 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
9584
9585 /*
9586 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
9587 * to the firmware to enable the phyerror
9588 * filtering offload.
9589 */
9590 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9591 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
9592
Govind Singh67922e82016-04-01 16:48:57 +05309593 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309594 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309595 __func__, ret);
9596 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309597 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309598 }
Govind Singhb53420c2016-03-09 14:32:57 +05309599 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309600 __func__);
9601 }
9602
Govind Singhb53420c2016-03-09 14:32:57 +05309603 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309604}
9605
Naveen Rawata5817e72017-10-26 18:50:19 -07009606/**
9607 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
9608 * will wake up host after specified time is elapsed
9609 * @wmi_handle: wmi handle
9610 * @vdev_id: vdev id
9611 * @cookie: value to identify reason why host set up wake call.
9612 * @time: time in ms
9613 *
9614 * Return: QDF status
9615 */
9616static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9617 uint8_t vdev_id, uint32_t cookie, uint32_t time)
9618{
9619 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
9620 wmi_buf_t buf;
9621 uint8_t *buf_ptr;
9622 int32_t len;
9623 int ret;
9624
9625 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
9626 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
9627 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
9628 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
9629 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
9630 WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32) +
9631 WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
9632
9633 buf = wmi_buf_alloc(wmi_handle, len);
9634 if (!buf) {
9635 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9636 return QDF_STATUS_E_NOMEM;
9637 }
9638
9639 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9640 buf_ptr = (uint8_t *) cmd;
9641
9642 WMITLV_SET_HDR(&cmd->tlv_header,
9643 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
9644 WMITLV_GET_STRUCT_TLVLEN
9645 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
9646 cmd->vdev_id = vdev_id;
9647 cmd->pattern_id = cookie,
9648 cmd->pattern_type = WOW_TIMER_PATTERN;
9649 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
9650
9651 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
9652 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9653 buf_ptr += WMI_TLV_HDR_SIZE;
9654
9655 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
9656 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9657 buf_ptr += WMI_TLV_HDR_SIZE;
9658
9659 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
9660 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9661 buf_ptr += WMI_TLV_HDR_SIZE;
9662
9663 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
9664 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9665 buf_ptr += WMI_TLV_HDR_SIZE;
9666
9667 /* Fill TLV for pattern_info_timeout, and time value */
9668 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
9669 buf_ptr += WMI_TLV_HDR_SIZE;
9670 *((A_UINT32 *) buf_ptr) = time;
9671 buf_ptr += sizeof(A_UINT32);
9672
9673 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
9674 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
9675 buf_ptr += WMI_TLV_HDR_SIZE;
9676 *((A_UINT32 *) buf_ptr) = 0;
9677
9678 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
9679 __func__, time, vdev_id);
9680
9681 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9682 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9683 if (ret) {
9684 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9685 __func__);
9686 wmi_buf_free(buf);
9687 return QDF_STATUS_E_FAILURE;
9688 }
9689
9690 return QDF_STATUS_SUCCESS;
9691}
9692
Govind Singh20c5dac2016-03-07 15:33:31 +05309693#if !defined(REMOVE_PKT_LOG)
9694/**
9695 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9696 * @wmi_handle: wmi handle
9697 * @pktlog_event: pktlog event
9698 * @cmd_id: pktlog cmd id
9699 *
9700 * Return: CDF status
9701 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309702static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309703 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309704 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309705{
9706 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9707 WMI_CMD_ID CMD_ID;
9708 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9709 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9710 int len = 0;
9711 wmi_buf_t buf;
9712
9713 PKTLOG_EVENT = pktlog_event;
9714 CMD_ID = cmd_id;
9715
9716 switch (CMD_ID) {
9717 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9718 len = sizeof(*cmd);
9719 buf = wmi_buf_alloc(wmi_handle, len);
9720 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309721 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9722 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309723 }
9724 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9725 wmi_buf_data(buf);
9726 WMITLV_SET_HDR(&cmd->tlv_header,
9727 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9728 WMITLV_GET_STRUCT_TLVLEN
9729 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9730 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309731 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9732 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309733 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9734 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309735 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9736 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309737 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309738 goto wmi_send_failed;
9739 }
9740 break;
9741 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9742 len = sizeof(*disable_cmd);
9743 buf = wmi_buf_alloc(wmi_handle, len);
9744 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309745 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9746 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309747 }
9748 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9749 wmi_buf_data(buf);
9750 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9751 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9752 WMITLV_GET_STRUCT_TLVLEN
9753 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309754 disable_cmd->pdev_id =
9755 wmi_handle->ops->convert_pdev_id_host_to_target(
9756 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309757 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9758 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309759 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309760 goto wmi_send_failed;
9761 }
9762 break;
9763 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309764 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309765 break;
9766 }
9767
Govind Singhb53420c2016-03-09 14:32:57 +05309768 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309769
9770wmi_send_failed:
9771 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309772 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309773}
9774#endif /* REMOVE_PKT_LOG */
9775
9776/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309777 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9778 * @wmi_handle: wmi handle
9779 * @ptrn_id: pattern id
9780 * @vdev_id: vdev id
9781 *
9782 * Return: CDF status
9783 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309784static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9785 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309786{
9787 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9788 wmi_buf_t buf;
9789 int32_t len;
9790 int ret;
9791
9792 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9793
9794
9795 buf = wmi_buf_alloc(wmi_handle, len);
9796 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309797 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9798 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309799 }
9800
9801 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9802
9803 WMITLV_SET_HDR(&cmd->tlv_header,
9804 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9805 WMITLV_GET_STRUCT_TLVLEN(
9806 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9807 cmd->vdev_id = vdev_id;
9808 cmd->pattern_id = ptrn_id;
9809 cmd->pattern_type = WOW_BITMAP_PATTERN;
9810
Govind Singhb53420c2016-03-09 14:32:57 +05309811 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309812 cmd->pattern_id, vdev_id);
9813
9814 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9815 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9816 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309817 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309818 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309819 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309820 }
9821
Govind Singhb53420c2016-03-09 14:32:57 +05309822 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309823}
9824
9825/**
9826 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9827 * @wmi_handle: wmi handle
9828 *
9829 * Sends host wakeup indication to FW. On receiving this indication,
9830 * FW will come out of WOW.
9831 *
9832 * Return: CDF status
9833 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309834static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309835{
9836 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9837 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309838 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309839 int32_t len;
9840 int ret;
9841
9842 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9843
9844 buf = wmi_buf_alloc(wmi_handle, len);
9845 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309846 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9847 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309848 }
9849
9850 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9851 wmi_buf_data(buf);
9852 WMITLV_SET_HDR(&cmd->tlv_header,
9853 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9854 WMITLV_GET_STRUCT_TLVLEN
9855 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9856
9857
9858 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9859 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9860 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309861 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309862 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309863 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309864 }
9865
Govind Singhb53420c2016-03-09 14:32:57 +05309866 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309867}
9868
9869/**
9870 * send_del_ts_cmd_tlv() - send DELTS request to fw
9871 * @wmi_handle: wmi handle
9872 * @msg: delts params
9873 *
9874 * Return: CDF status
9875 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309876static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309877 uint8_t ac)
9878{
9879 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9880 wmi_buf_t buf;
9881 int32_t len = sizeof(*cmd);
9882
9883 buf = wmi_buf_alloc(wmi_handle, len);
9884 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309885 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9886 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309887 }
9888 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9889 WMITLV_SET_HDR(&cmd->tlv_header,
9890 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9891 WMITLV_GET_STRUCT_TLVLEN
9892 (wmi_vdev_wmm_delts_cmd_fixed_param));
9893 cmd->vdev_id = vdev_id;
9894 cmd->ac = ac;
9895
Govind Singhb53420c2016-03-09 14:32:57 +05309896 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309897 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9898 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9899 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309900 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309901 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309902 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309903 }
9904
Govind Singhb53420c2016-03-09 14:32:57 +05309905 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309906}
9907
9908/**
9909 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9910 * @wmi_handle: handle to wmi
9911 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9912 *
Govind Singhb53420c2016-03-09 14:32:57 +05309913 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309914 * ADD_TS requestes to firmware in loop for all the ACs with
9915 * active flow.
9916 *
9917 * Return: CDF status
9918 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309919static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309920 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9921{
9922 int i = 0;
9923 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9924 wmi_buf_t buf;
9925 int32_t len = sizeof(*cmd);
9926
9927 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9928 /* if flow in this AC is active */
9929 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9930 /*
9931 * as per implementation of wma_add_ts_req() we
9932 * are not waiting any response from firmware so
9933 * apart from sending ADDTS to firmware just send
9934 * success to upper layers
9935 */
Govind Singhb53420c2016-03-09 14:32:57 +05309936 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309937
9938 buf = wmi_buf_alloc(wmi_handle, len);
9939 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309940 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9941 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309942 }
9943 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9944 wmi_buf_data(buf);
9945 WMITLV_SET_HDR(&cmd->tlv_header,
9946 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9947 WMITLV_GET_STRUCT_TLVLEN
9948 (wmi_vdev_wmm_addts_cmd_fixed_param));
9949 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9950 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309951 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309952 traffic.userPrio);
9953 cmd->medium_time_us =
9954 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9955 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309956 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309957 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9958 cmd->medium_time_us, cmd->downgrade_type);
9959 if (wmi_unified_cmd_send
9960 (wmi_handle, buf, len,
9961 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309962 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309963 __func__);
9964 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309965 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309966 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309967 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309968 }
9969 }
9970 }
9971
Govind Singhb53420c2016-03-09 14:32:57 +05309972 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309973}
9974
9975/**
9976 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9977 * @wmi_handle: wmi handle
9978 * @msg: ADDTS params
9979 *
9980 * Return: CDF status
9981 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309982static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309983 struct add_ts_param *msg)
9984{
9985 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9986 wmi_buf_t buf;
9987 int32_t len = sizeof(*cmd);
9988
Govind Singhb53420c2016-03-09 14:32:57 +05309989 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309990
9991 buf = wmi_buf_alloc(wmi_handle, len);
9992 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309993 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9994 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309995 }
9996 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9997 WMITLV_SET_HDR(&cmd->tlv_header,
9998 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9999 WMITLV_GET_STRUCT_TLVLEN
10000 (wmi_vdev_wmm_addts_cmd_fixed_param));
10001 cmd->vdev_id = msg->sme_session_id;
10002 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
10003 cmd->medium_time_us = msg->tspec.mediumTime * 32;
10004 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +053010005 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010006 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
10007 cmd->downgrade_type, __func__, __LINE__);
10008 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10009 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010010 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
10011 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +053010012 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010013 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010014 }
10015
Govind Singhb53420c2016-03-09 14:32:57 +053010016 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010017}
10018
10019/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010020 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
10021 * @wmi_handle: wmi handle
10022 * @pAddPeriodicTxPtrnParams: tx ptrn params
10023 *
10024 * Retrun: CDF status
10025 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010026static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010027 struct periodic_tx_pattern *
10028 pAddPeriodicTxPtrnParams,
10029 uint8_t vdev_id)
10030{
10031 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10032 wmi_buf_t wmi_buf;
10033 uint32_t len;
10034 uint8_t *buf_ptr;
10035 uint32_t ptrn_len, ptrn_len_aligned;
10036 int j;
10037
10038 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
10039 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
10040 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
10041 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
10042
10043 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10044 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010045 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10046 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010047 }
10048
10049 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10050
10051 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
10052 WMITLV_SET_HDR(&cmd->tlv_header,
10053 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10054 WMITLV_GET_STRUCT_TLVLEN
10055 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10056
10057 /* Pass the pattern id to delete for the corresponding vdev id */
10058 cmd->vdev_id = vdev_id;
10059 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
10060 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
10061 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
10062
10063 /* Pattern info */
10064 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10065 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
10066 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010067 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010068 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +053010069 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +053010070
Govind Singhb53420c2016-03-09 14:32:57 +053010071 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010072 __func__, cmd->pattern_id, cmd->vdev_id);
10073
10074 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10075 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010076 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010077 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010078 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010079 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010080 }
Govind Singhb53420c2016-03-09 14:32:57 +053010081 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010082}
10083
10084/**
10085 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
10086 * @wmi_handle: wmi handle
10087 * @vdev_id: vdev id
10088 * @pattern_id: pattern id
10089 *
10090 * Retrun: CDF status
10091 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010092static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010093 uint8_t vdev_id,
10094 uint8_t pattern_id)
10095{
10096 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10097 wmi_buf_t wmi_buf;
10098 uint32_t len =
10099 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10100
10101 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10102 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010103 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10104 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010105 }
10106
10107 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
10108 wmi_buf_data(wmi_buf);
10109 WMITLV_SET_HDR(&cmd->tlv_header,
10110 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10111 WMITLV_GET_STRUCT_TLVLEN
10112 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10113
10114 /* Pass the pattern id to delete for the corresponding vdev id */
10115 cmd->vdev_id = vdev_id;
10116 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +053010117 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010118 __func__, cmd->pattern_id, cmd->vdev_id);
10119
10120 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10121 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010122 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010123 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010124 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010125 }
Govind Singhb53420c2016-03-09 14:32:57 +053010126 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010127}
10128
10129/**
10130 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
10131 * @wmi_handle: wmi handle
10132 * @preq: stats ext params
10133 *
10134 * Return: CDF status
10135 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010136static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010137 struct stats_ext_params *preq)
10138{
Govind Singh67922e82016-04-01 16:48:57 +053010139 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010140 wmi_req_stats_ext_cmd_fixed_param *cmd;
10141 wmi_buf_t buf;
10142 uint16_t len;
10143 uint8_t *buf_ptr;
10144
10145 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
10146
10147 buf = wmi_buf_alloc(wmi_handle, len);
10148 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010149 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010150 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010151 }
10152
10153 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10154 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
10155
10156 WMITLV_SET_HDR(&cmd->tlv_header,
10157 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
10158 WMITLV_GET_STRUCT_TLVLEN
10159 (wmi_req_stats_ext_cmd_fixed_param));
10160 cmd->vdev_id = preq->vdev_id;
10161 cmd->data_len = preq->request_data_len;
10162
Govind Singhb53420c2016-03-09 14:32:57 +053010163 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +053010164 __func__, preq->request_data_len, preq->vdev_id);
10165
10166 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
10167 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
10168
10169 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010170 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010171
10172 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10173 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010174 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010175 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +053010176 ret);
10177 wmi_buf_free(buf);
10178 }
10179
10180 return ret;
10181}
10182
10183/**
10184 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
10185 * @wmi_handle: wmi handle
10186 * @params: ext wow params
10187 *
10188 * Return:0 for success or error code
10189 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010190static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010191 struct ext_wow_params *params)
10192{
10193 wmi_extwow_enable_cmd_fixed_param *cmd;
10194 wmi_buf_t buf;
10195 int32_t len;
10196 int ret;
10197
10198 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
10199 buf = wmi_buf_alloc(wmi_handle, len);
10200 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010201 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10202 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010203 }
10204
10205 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
10206
10207 WMITLV_SET_HDR(&cmd->tlv_header,
10208 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
10209 WMITLV_GET_STRUCT_TLVLEN
10210 (wmi_extwow_enable_cmd_fixed_param));
10211
10212 cmd->vdev_id = params->vdev_id;
10213 cmd->type = params->type;
10214 cmd->wakeup_pin_num = params->wakeup_pin_num;
10215
Govind Singhb53420c2016-03-09 14:32:57 +053010216 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +053010217 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
10218
10219 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10220 WMI_EXTWOW_ENABLE_CMDID);
10221 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010222 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010223 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010224 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010225 }
10226
Govind Singhb53420c2016-03-09 14:32:57 +053010227 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010228
10229}
10230
10231/**
10232 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
10233 * @wmi_handle: wmi handle
10234 * @app_type1_params: app type1 params
10235 *
10236 * Return: CDF status
10237 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010238static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010239 struct app_type1_params *app_type1_params)
10240{
10241 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
10242 wmi_buf_t buf;
10243 int32_t len;
10244 int ret;
10245
10246 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
10247 buf = wmi_buf_alloc(wmi_handle, len);
10248 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010249 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10250 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010251 }
10252
10253 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
10254 wmi_buf_data(buf);
10255
10256 WMITLV_SET_HDR(&cmd->tlv_header,
10257 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
10258 WMITLV_GET_STRUCT_TLVLEN
10259 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
10260
10261 cmd->vdev_id = app_type1_params->vdev_id;
10262 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
10263 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +053010264 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +053010265 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +053010266 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010267 cmd->passwd_len = app_type1_params->pass_length;
10268
Govind Singhb53420c2016-03-09 14:32:57 +053010269 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010270 "identification_id %.8s id_length %u "
10271 "password %.16s pass_length %u",
10272 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
10273 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
10274
10275 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10276 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
10277 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010278 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010279 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010280 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010281 }
10282
Govind Singhb53420c2016-03-09 14:32:57 +053010283 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010284}
10285
10286/**
10287 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
10288 * @wmi_handle: wmi handle
10289 * @appType2Params: app type2 params
10290 *
10291 * Return: CDF status
10292 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010293static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010294 struct app_type2_params *appType2Params)
10295{
10296 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
10297 wmi_buf_t buf;
10298 int32_t len;
10299 int ret;
10300
10301 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
10302 buf = wmi_buf_alloc(wmi_handle, len);
10303 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010304 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10305 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010306 }
10307
10308 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
10309 wmi_buf_data(buf);
10310
10311 WMITLV_SET_HDR(&cmd->tlv_header,
10312 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
10313 WMITLV_GET_STRUCT_TLVLEN
10314 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
10315
10316 cmd->vdev_id = appType2Params->vdev_id;
10317
Govind Singhb53420c2016-03-09 14:32:57 +053010318 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010319 cmd->rc4_key_len = appType2Params->rc4_key_len;
10320
10321 cmd->ip_id = appType2Params->ip_id;
10322 cmd->ip_device_ip = appType2Params->ip_device_ip;
10323 cmd->ip_server_ip = appType2Params->ip_server_ip;
10324
10325 cmd->tcp_src_port = appType2Params->tcp_src_port;
10326 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
10327 cmd->tcp_seq = appType2Params->tcp_seq;
10328 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
10329
10330 cmd->keepalive_init = appType2Params->keepalive_init;
10331 cmd->keepalive_min = appType2Params->keepalive_min;
10332 cmd->keepalive_max = appType2Params->keepalive_max;
10333 cmd->keepalive_inc = appType2Params->keepalive_inc;
10334
10335 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
10336 &cmd->gateway_mac);
10337 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
10338 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
10339
Govind Singhb53420c2016-03-09 14:32:57 +053010340 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010341 "rc4_key %.16s rc4_key_len %u "
10342 "ip_id %x ip_device_ip %x ip_server_ip %x "
10343 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
10344 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
10345 "keepalive_max %u keepalive_inc %u "
10346 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
10347 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
10348 cmd->rc4_key, cmd->rc4_key_len,
10349 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
10350 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
10351 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
10352 cmd->keepalive_max, cmd->keepalive_inc,
10353 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
10354
10355 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10356 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
10357 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010358 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010359 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010360 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010361 }
10362
Govind Singhb53420c2016-03-09 14:32:57 +053010363 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010364
10365}
10366
10367/**
10368 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
10369 * @wmi_handle: wmi handle
10370 * @timer_val: auto shutdown timer value
10371 *
10372 * Return: CDF status
10373 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010374static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010375 uint32_t timer_val)
10376{
Govind Singh67922e82016-04-01 16:48:57 +053010377 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010378 wmi_buf_t buf = NULL;
10379 uint8_t *buf_ptr;
10380 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
10381 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
10382
Govind Singhb53420c2016-03-09 14:32:57 +053010383 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010384 __func__, timer_val);
10385
10386 buf = wmi_buf_alloc(wmi_handle, len);
10387 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010388 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10389 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010390 }
10391
10392 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10393 wmi_auto_sh_cmd =
10394 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
10395 wmi_auto_sh_cmd->timer_value = timer_val;
10396
10397 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
10398 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
10399 WMITLV_GET_STRUCT_TLVLEN
10400 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
10401
10402 status = wmi_unified_cmd_send(wmi_handle, buf,
10403 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010404 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010405 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010406 __func__, status);
10407 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010408 }
10409
Govind Singh67922e82016-04-01 16:48:57 +053010410 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010411}
10412
10413/**
10414 * send_nan_req_cmd_tlv() - to send nan request to target
10415 * @wmi_handle: wmi handle
10416 * @nan_req: request data which will be non-null
10417 *
10418 * Return: CDF status
10419 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010420static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010421 struct nan_req_params *nan_req)
10422{
Govind Singh67922e82016-04-01 16:48:57 +053010423 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010424 wmi_nan_cmd_param *cmd;
10425 wmi_buf_t buf;
10426 uint16_t len = sizeof(*cmd);
10427 uint16_t nan_data_len, nan_data_len_aligned;
10428 uint8_t *buf_ptr;
10429
10430 /*
10431 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
10432 * +------------+----------+-----------------------+--------------+
10433 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
10434 * +------------+----------+-----------------------+--------------+
10435 */
10436 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +053010437 WMI_LOGE("%s:nan req is not valid", __func__);
10438 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010439 }
10440 nan_data_len = nan_req->request_data_len;
10441 nan_data_len_aligned = roundup(nan_req->request_data_len,
10442 sizeof(uint32_t));
10443 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
10444 buf = wmi_buf_alloc(wmi_handle, len);
10445 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010446 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
10447 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010448 }
10449 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10450 cmd = (wmi_nan_cmd_param *) buf_ptr;
10451 WMITLV_SET_HDR(&cmd->tlv_header,
10452 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
10453 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
10454 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +053010455 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +053010456 __func__, nan_req->request_data_len);
10457 buf_ptr += sizeof(wmi_nan_cmd_param);
10458 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
10459 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010460 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010461
10462 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10463 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010464 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010465 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010466 __func__, ret);
10467 wmi_buf_free(buf);
10468 }
10469
10470 return ret;
10471}
10472
10473/**
10474 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
10475 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -070010476 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +053010477 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010478 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010479 */
Jeff Johnsona87370f2017-10-04 19:19:20 -070010480static QDF_STATUS
10481send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
10482 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +053010483{
10484 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
10485 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +053010486 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010487
10488 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10489 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010490 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +053010491 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010492 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010493 }
10494
10495 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010496
10497 WMITLV_SET_HDR(&cmd->tlv_header,
10498 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
10499 WMITLV_GET_STRUCT_TLVLEN
10500 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -070010501 cmd->vdev_id = params->vdev_id;
10502 cmd->enable = params->dhcp_offload_enabled;
10503 cmd->num_client = params->dhcp_client_num;
10504 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +053010505 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +053010506 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +053010507 sizeof(*cmd),
10508 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010509 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010510 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +053010511 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010512 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010513 }
Govind Singhb53420c2016-03-09 14:32:57 +053010514 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -070010515 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +053010516
10517 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010518}
10519
10520/**
10521 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
10522 * @wmi_handle: wmi handle
10523 * @flashing: flashing request
10524 *
10525 * Return: CDF status
10526 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010527static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010528 struct flashing_req_params *flashing)
10529{
10530 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +053010531 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010532 wmi_buf_t buf;
10533 uint8_t *buf_ptr;
10534 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
10535
10536 buf = wmi_buf_alloc(wmi_handle, len);
10537 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010538 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +053010539 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010540 }
10541 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10542 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
10543 WMITLV_SET_HDR(&cmd->tlv_header,
10544 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
10545 WMITLV_GET_STRUCT_TLVLEN
10546 (wmi_set_led_flashing_cmd_fixed_param));
10547 cmd->pattern_id = flashing->pattern_id;
10548 cmd->led_x0 = flashing->led_x0;
10549 cmd->led_x1 = flashing->led_x1;
10550
10551 status = wmi_unified_cmd_send(wmi_handle, buf, len,
10552 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010553 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010554 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +053010555 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010556 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010557 }
Govind Singh67922e82016-04-01 16:48:57 +053010558
10559 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010560}
10561
10562/**
10563 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
10564 * @wmi_handle: wmi handle
10565 * @ch_avoid_update_req: channel avoid update params
10566 *
10567 * Return: CDF status
10568 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010569static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +053010570{
Govind Singh67922e82016-04-01 16:48:57 +053010571 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010572 wmi_buf_t buf = NULL;
10573 uint8_t *buf_ptr;
10574 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
10575 int len = sizeof(wmi_chan_avoid_update_cmd_param);
10576
10577
10578 buf = wmi_buf_alloc(wmi_handle, len);
10579 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010580 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10581 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010582 }
10583
10584 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10585 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
10586 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
10587 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
10588 WMITLV_GET_STRUCT_TLVLEN
10589 (wmi_chan_avoid_update_cmd_param));
10590
10591 status = wmi_unified_cmd_send(wmi_handle, buf,
10592 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010593 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010594 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +053010595 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
10596 " returned Error %d", status);
10597 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010598 }
10599
Govind Singh67922e82016-04-01 16:48:57 +053010600 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010601}
10602
10603/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010604 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
10605 * @wmi_handle: wmi handle
10606 * @param: pointer to pdev regdomain params
10607 *
10608 * Return: 0 for success or error code
10609 */
10610static QDF_STATUS
10611send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
10612 struct pdev_set_regdomain_params *param)
10613{
10614 wmi_buf_t buf;
10615 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10616 int32_t len = sizeof(*cmd);
10617
10618
10619 buf = wmi_buf_alloc(wmi_handle, len);
10620 if (!buf) {
10621 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10622 return QDF_STATUS_E_NOMEM;
10623 }
10624 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10625 WMITLV_SET_HDR(&cmd->tlv_header,
10626 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10627 WMITLV_GET_STRUCT_TLVLEN
10628 (wmi_pdev_set_regdomain_cmd_fixed_param));
10629
10630 cmd->reg_domain = param->currentRDinuse;
10631 cmd->reg_domain_2G = param->currentRD2G;
10632 cmd->reg_domain_5G = param->currentRD5G;
10633 cmd->conformance_test_limit_2G = param->ctl_2G;
10634 cmd->conformance_test_limit_5G = param->ctl_5G;
10635 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010636 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10637 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010638
10639 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10640 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
10641 WMI_LOGE("%s: Failed to send pdev set regdomain command",
10642 __func__);
10643 wmi_buf_free(buf);
10644 return QDF_STATUS_E_FAILURE;
10645 }
10646
10647 return QDF_STATUS_SUCCESS;
10648}
10649
10650/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010651 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
10652 * @wmi_handle: wmi handle
10653 * @reg_dmn: reg domain
10654 * @regdmn2G: 2G reg domain
10655 * @regdmn5G: 5G reg domain
10656 * @ctl2G: 2G test limit
10657 * @ctl5G: 5G test limit
10658 *
10659 * Return: none
10660 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010661static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010662 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +053010663 uint16_t regdmn5G, uint8_t ctl2G,
10664 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +053010665{
10666 wmi_buf_t buf;
10667 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10668 int32_t len = sizeof(*cmd);
10669
10670
10671 buf = wmi_buf_alloc(wmi_handle, len);
10672 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010673 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10674 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010675 }
10676 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10677 WMITLV_SET_HDR(&cmd->tlv_header,
10678 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10679 WMITLV_GET_STRUCT_TLVLEN
10680 (wmi_pdev_set_regdomain_cmd_fixed_param));
10681 cmd->reg_domain = reg_dmn;
10682 cmd->reg_domain_2G = regdmn2G;
10683 cmd->reg_domain_5G = regdmn5G;
10684 cmd->conformance_test_limit_2G = ctl2G;
10685 cmd->conformance_test_limit_5G = ctl5G;
10686
10687 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10688 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010689 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010690 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010691 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010692 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010693 }
10694
Govind Singhb53420c2016-03-09 14:32:57 +053010695 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010696}
10697
10698
10699/**
10700 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10701 * @wmi_handle: wmi handle
10702 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10703 *
10704 * This function sets tdls off channel mode
10705 *
10706 * Return: 0 on success; Negative errno otherwise
10707 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010708static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010709 struct tdls_channel_switch_params *chan_switch_params)
10710{
10711 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10712 wmi_buf_t wmi_buf;
10713 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10714
10715 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10716 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010717 WMI_LOGE(FL("wmi_buf_alloc failed"));
10718 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010719 }
10720 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10721 wmi_buf_data(wmi_buf);
10722 WMITLV_SET_HDR(&cmd->tlv_header,
10723 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10724 WMITLV_GET_STRUCT_TLVLEN(
10725 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10726
10727 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10728 &cmd->peer_macaddr);
10729 cmd->vdev_id = chan_switch_params->vdev_id;
10730 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10731 cmd->is_peer_responder = chan_switch_params->is_responder;
10732 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10733 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10734 cmd->offchan_oper_class = chan_switch_params->oper_class;
10735
Govind Singhb53420c2016-03-09 14:32:57 +053010736 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010737 cmd->peer_macaddr.mac_addr31to0,
10738 cmd->peer_macaddr.mac_addr47to32);
10739
Govind Singhb53420c2016-03-09 14:32:57 +053010740 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010741 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10742 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10743 ),
10744 cmd->vdev_id,
10745 cmd->offchan_mode,
10746 cmd->offchan_num,
10747 cmd->offchan_bw_bitmap,
10748 cmd->is_peer_responder,
10749 cmd->offchan_oper_class);
10750
10751 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10752 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010753 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010754 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010755 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010756 }
10757
10758
Govind Singhb53420c2016-03-09 14:32:57 +053010759 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010760}
10761
10762/**
10763 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10764 * @wmi_handle: wmi handle
10765 * @pwmaTdlsparams: TDLS params
10766 *
10767 * Return: 0 for sucess or error code
10768 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010769static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010770 void *tdls_param, uint8_t tdls_state)
10771{
10772 wmi_tdls_set_state_cmd_fixed_param *cmd;
10773 wmi_buf_t wmi_buf;
10774
10775 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10776 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10777
10778 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10779 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010780 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10781 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010782 }
10783 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10784 WMITLV_SET_HDR(&cmd->tlv_header,
10785 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10786 WMITLV_GET_STRUCT_TLVLEN
10787 (wmi_tdls_set_state_cmd_fixed_param));
10788 cmd->vdev_id = wmi_tdls->vdev_id;
10789 cmd->state = tdls_state;
10790 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10791 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10792 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10793 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10794 cmd->rssi_delta = wmi_tdls->rssi_delta;
10795 cmd->tdls_options = wmi_tdls->tdls_options;
10796 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10797 cmd->tdls_peer_traffic_response_timeout_ms =
10798 wmi_tdls->peer_traffic_response_timeout;
10799 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10800 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10801 cmd->tdls_puapsd_rx_frame_threshold =
10802 wmi_tdls->puapsd_rx_frame_threshold;
10803 cmd->teardown_notification_ms =
10804 wmi_tdls->teardown_notification_ms;
10805 cmd->tdls_peer_kickout_threshold =
10806 wmi_tdls->tdls_peer_kickout_threshold;
10807
Govind Singhb53420c2016-03-09 14:32:57 +053010808 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010809 "notification_interval_ms: %d, "
10810 "tx_discovery_threshold: %d, "
10811 "tx_teardown_threshold: %d, "
10812 "rssi_teardown_threshold: %d, "
10813 "rssi_delta: %d, "
10814 "tdls_options: 0x%x, "
10815 "tdls_peer_traffic_ind_window: %d, "
10816 "tdls_peer_traffic_response_timeout: %d, "
10817 "tdls_puapsd_mask: 0x%x, "
10818 "tdls_puapsd_inactivity_time: %d, "
10819 "tdls_puapsd_rx_frame_threshold: %d, "
10820 "teardown_notification_ms: %d, "
10821 "tdls_peer_kickout_threshold: %d",
10822 __func__, tdls_state, cmd->state,
10823 cmd->notification_interval_ms,
10824 cmd->tx_discovery_threshold,
10825 cmd->tx_teardown_threshold,
10826 cmd->rssi_teardown_threshold,
10827 cmd->rssi_delta,
10828 cmd->tdls_options,
10829 cmd->tdls_peer_traffic_ind_window,
10830 cmd->tdls_peer_traffic_response_timeout_ms,
10831 cmd->tdls_puapsd_mask,
10832 cmd->tdls_puapsd_inactivity_time_ms,
10833 cmd->tdls_puapsd_rx_frame_threshold,
10834 cmd->teardown_notification_ms,
10835 cmd->tdls_peer_kickout_threshold);
10836
10837 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10838 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010839 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010840 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010841 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010842 }
Govind Singhb53420c2016-03-09 14:32:57 +053010843 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010844
Govind Singhb53420c2016-03-09 14:32:57 +053010845 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010846}
10847
10848/**
10849 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10850 * @wmi_handle: wmi handle
10851 * @peerStateParams: TDLS peer state params
10852 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010853 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010854 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010855static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010856 struct tdls_peer_state_params *peerStateParams,
10857 uint32_t *ch_mhz)
10858{
10859 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10860 wmi_tdls_peer_capabilities *peer_cap;
10861 wmi_channel *chan_info;
10862 wmi_buf_t wmi_buf;
10863 uint8_t *buf_ptr;
10864 uint32_t i;
10865 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10866 sizeof(wmi_tdls_peer_capabilities);
10867
10868
10869 len += WMI_TLV_HDR_SIZE +
10870 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10871
10872 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10873 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010874 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10875 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010876 }
10877
10878 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10879 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10880 WMITLV_SET_HDR(&cmd->tlv_header,
10881 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10882 WMITLV_GET_STRUCT_TLVLEN
10883 (wmi_tdls_peer_update_cmd_fixed_param));
10884
10885 cmd->vdev_id = peerStateParams->vdevId;
10886 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10887 &cmd->peer_macaddr);
10888
10889
10890 cmd->peer_state = peerStateParams->peerState;
10891
Govind Singhb53420c2016-03-09 14:32:57 +053010892 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010893 "peer_macaddr.mac_addr31to0: 0x%x, "
10894 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10895 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10896 cmd->peer_macaddr.mac_addr31to0,
10897 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10898
10899 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10900 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10901 WMITLV_SET_HDR(&peer_cap->tlv_header,
10902 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10903 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10904
10905 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10906 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10907 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10908 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10909 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10910 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10911 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10912 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10913
10914 /* Ack and More Data Ack are sent as 0, so no need to set
10915 * but fill SP
10916 */
10917 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10918 peerStateParams->peerCap.peerMaxSp);
10919
10920 peer_cap->buff_sta_support =
10921 peerStateParams->peerCap.peerBuffStaSupport;
10922 peer_cap->off_chan_support =
10923 peerStateParams->peerCap.peerOffChanSupport;
10924 peer_cap->peer_curr_operclass =
10925 peerStateParams->peerCap.peerCurrOperClass;
10926 /* self curr operclass is not being used and so pass op class for
10927 * preferred off chan in it.
10928 */
10929 peer_cap->self_curr_operclass =
10930 peerStateParams->peerCap.opClassForPrefOffChan;
10931 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10932 peer_cap->peer_operclass_len =
10933 peerStateParams->peerCap.peerOperClassLen;
10934
Govind Singhb53420c2016-03-09 14:32:57 +053010935 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010936 __func__, peer_cap->peer_operclass_len);
10937 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10938 peer_cap->peer_operclass[i] =
10939 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010940 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010941 __func__, i, peer_cap->peer_operclass[i]);
10942 }
10943
10944 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10945 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10946 peer_cap->pref_offchan_bw =
10947 peerStateParams->peerCap.prefOffChanBandwidth;
10948
Govind Singhb53420c2016-03-09 14:32:57 +053010949 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010950 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10951 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10952 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10953 " %d, pref_offchan_bw: %d",
10954 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10955 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10956 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10957 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10958 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10959
10960 /* next fill variable size array of peer chan info */
10961 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10962 WMITLV_SET_HDR(buf_ptr,
10963 WMITLV_TAG_ARRAY_STRUC,
10964 sizeof(wmi_channel) *
10965 peerStateParams->peerCap.peerChanLen);
10966 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10967
10968 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10969 WMITLV_SET_HDR(&chan_info->tlv_header,
10970 WMITLV_TAG_STRUC_wmi_channel,
10971 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10972 chan_info->mhz = ch_mhz[i];
10973 chan_info->band_center_freq1 = chan_info->mhz;
10974 chan_info->band_center_freq2 = 0;
10975
Govind Singhb53420c2016-03-09 14:32:57 +053010976 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010977
10978 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10979 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010980 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010981 peerStateParams->peerCap.peerChan[i].chanId,
10982 peerStateParams->peerCap.peerChan[i].dfsSet);
10983 }
10984
10985 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10986 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10987 else
10988 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10989
10990 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10991 peerStateParams->peerCap.
10992 peerChan[i].pwr);
10993
10994 WMI_SET_CHANNEL_REG_POWER(chan_info,
10995 peerStateParams->peerCap.peerChan[i].
10996 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010997 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010998 peerStateParams->peerCap.peerChan[i].pwr);
10999
11000 chan_info++;
11001 }
11002
11003 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
11004 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011005 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053011006 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011007 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011008 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053011009 }
11010
11011
Govind Singhb53420c2016-03-09 14:32:57 +053011012 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053011013}
11014
11015/*
Govind Singh20c5dac2016-03-07 15:33:31 +053011016 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
11017 * @wmi_handle: Pointer to WMi handle
11018 * @ie_data: Pointer for ie data
11019 *
11020 * This function sends IE information to firmware
11021 *
Govind Singhb53420c2016-03-09 14:32:57 +053011022 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053011023 *
11024 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011025static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053011026 struct vdev_ie_info_param *ie_info)
11027{
11028 wmi_vdev_set_ie_cmd_fixed_param *cmd;
11029 wmi_buf_t buf;
11030 uint8_t *buf_ptr;
11031 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053011032 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053011033
11034
11035 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
11036 /* Allocate memory for the WMI command */
11037 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
11038
11039 buf = wmi_buf_alloc(wmi_handle, len);
11040 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011041 WMI_LOGE(FL("wmi_buf_alloc failed"));
11042 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053011043 }
11044
11045 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011046 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011047
11048 /* Populate the WMI command */
11049 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
11050
11051 WMITLV_SET_HDR(&cmd->tlv_header,
11052 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
11053 WMITLV_GET_STRUCT_TLVLEN(
11054 wmi_vdev_set_ie_cmd_fixed_param));
11055 cmd->vdev_id = ie_info->vdev_id;
11056 cmd->ie_id = ie_info->ie_id;
11057 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070011058 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053011059
Govind Singhb53420c2016-03-09 14:32:57 +053011060 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053011061 ie_info->length, ie_info->vdev_id);
11062
11063 buf_ptr += sizeof(*cmd);
11064 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
11065 buf_ptr += WMI_TLV_HDR_SIZE;
11066
Govind Singhb53420c2016-03-09 14:32:57 +053011067 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011068
11069 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11070 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011071 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011072 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053011073 wmi_buf_free(buf);
11074 }
11075
11076 return ret;
11077}
11078
Sathish Kumar497bef42017-03-01 14:02:36 +053011079/**
11080 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
11081 *
11082 * @param wmi_handle : handle to WMI.
11083 * @param param : pointer to antenna param
11084 *
11085 * This function sends smart antenna enable command to FW
11086 *
11087 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11088 */
11089static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
11090 struct smart_ant_enable_params *param)
11091{
11092 /* Send WMI COMMAND to Enable */
11093 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
11094 wmi_pdev_smart_ant_gpio_handle *gpio_param;
11095 wmi_buf_t buf;
11096 uint8_t *buf_ptr;
11097 int len = 0;
11098 QDF_STATUS ret;
11099 int loop = 0;
11100
11101 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11102 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
11103 buf = wmi_buf_alloc(wmi_handle, len);
11104
11105 if (!buf) {
11106 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11107 return QDF_STATUS_E_NOMEM;
11108 }
11109
11110 buf_ptr = wmi_buf_data(buf);
11111 qdf_mem_zero(buf_ptr, len);
11112 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
11113
11114 WMITLV_SET_HDR(&cmd->tlv_header,
11115 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
11116 WMITLV_GET_STRUCT_TLVLEN(
11117 wmi_pdev_smart_ant_enable_cmd_fixed_param));
11118
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011119 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11120 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011121 cmd->enable = param->enable;
11122 cmd->mode = param->mode;
11123 cmd->rx_antenna = param->rx_antenna;
11124 cmd->tx_default_antenna = param->rx_antenna;
11125
11126 /* TLV indicating array of structures to follow */
11127 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
11128 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11129 WMI_HAL_MAX_SANTENNA *
11130 sizeof(wmi_pdev_smart_ant_gpio_handle));
11131
11132 buf_ptr += WMI_TLV_HDR_SIZE;
11133 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
11134
11135 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
11136 WMITLV_SET_HDR(&gpio_param->tlv_header,
11137 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
11138 WMITLV_GET_STRUCT_TLVLEN(
11139 wmi_pdev_smart_ant_gpio_handle));
11140 if (param->mode == SMART_ANT_MODE_SERIAL) {
11141 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
11142 gpio_param->gpio_pin = param->gpio_pin[loop];
11143 gpio_param->gpio_func = param->gpio_func[loop];
11144 } else {
11145 gpio_param->gpio_pin = 0;
11146 gpio_param->gpio_func = 0;
11147 }
11148 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
11149 gpio_param->gpio_pin = param->gpio_pin[loop];
11150 gpio_param->gpio_func = param->gpio_func[loop];
11151 }
11152 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011153 gpio_param->pdev_id =
11154 wmi_handle->ops->convert_pdev_id_host_to_target(
11155 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011156 gpio_param++;
11157 }
11158
11159 ret = wmi_unified_cmd_send(wmi_handle,
11160 buf,
11161 len,
11162 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
11163
11164 if (ret != 0) {
11165 WMI_LOGE(" %s :WMI Failed\n", __func__);
11166 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
11167 cmd->enable,
11168 cmd->mode,
11169 cmd->rx_antenna,
11170 param->gpio_pin[0], param->gpio_pin[1],
11171 param->gpio_pin[2], param->gpio_pin[3],
11172 param->gpio_func[0], param->gpio_func[1],
11173 param->gpio_func[2], param->gpio_func[3],
11174 ret);
11175 wmi_buf_free(buf);
11176 }
11177
11178 return ret;
11179}
11180
11181/**
11182 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
11183 *
11184 * @param wmi_handle : handle to WMI.
11185 * @param param : pointer to rx antenna param
11186 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11187 */
11188static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11189 struct smart_ant_rx_ant_params *param)
11190{
11191 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
11192 wmi_buf_t buf;
11193 uint8_t *buf_ptr;
11194 uint32_t len;
11195 QDF_STATUS ret;
11196
11197 len = sizeof(*cmd);
11198 buf = wmi_buf_alloc(wmi_handle, len);
11199 WMI_LOGD("%s:\n", __func__);
11200 if (!buf) {
11201 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11202 return QDF_STATUS_E_NOMEM;
11203 }
11204
11205 buf_ptr = wmi_buf_data(buf);
11206 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
11207 WMITLV_SET_HDR(&cmd->tlv_header,
11208 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
11209 WMITLV_GET_STRUCT_TLVLEN(
11210 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
11211 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011212 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11213 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011214
11215 ret = wmi_unified_cmd_send(wmi_handle,
11216 buf,
11217 len,
11218 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
11219
11220 if (ret != 0) {
11221 WMI_LOGE(" %s :WMI Failed\n", __func__);
11222 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
11223 __func__,
11224 cmd->rx_antenna,
11225 ret);
11226 wmi_buf_free(buf);
11227 }
11228
11229 return ret;
11230}
11231
11232/**
11233 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
11234 * @wmi_handle: wmi handle
11235 * @param: pointer to hold ctl table param
11236 *
11237 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11238 */
11239static QDF_STATUS
11240send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
11241 struct ctl_table_params *param)
11242{
11243 uint16_t len, ctl_tlv_len;
11244 uint8_t *buf_ptr;
11245 wmi_buf_t buf;
11246 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
11247 uint32_t *ctl_array;
11248
11249 if (!param->ctl_array)
11250 return QDF_STATUS_E_FAILURE;
11251
Sathish Kumar497bef42017-03-01 14:02:36 +053011252 ctl_tlv_len = WMI_TLV_HDR_SIZE +
11253 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
11254 len = sizeof(*cmd) + ctl_tlv_len;
11255
11256 buf = wmi_buf_alloc(wmi_handle, len);
11257 if (!buf) {
11258 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11259 return QDF_STATUS_E_FAILURE;
11260 }
11261
11262 buf_ptr = wmi_buf_data(buf);
11263 qdf_mem_zero(buf_ptr, len);
11264
11265 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
11266
11267 WMITLV_SET_HDR(&cmd->tlv_header,
11268 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
11269 WMITLV_GET_STRUCT_TLVLEN(
11270 wmi_pdev_set_ctl_table_cmd_fixed_param));
11271 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011272 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11273 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011274
11275 buf_ptr += sizeof(*cmd);
11276 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11277 (cmd->ctl_len));
11278 buf_ptr += WMI_TLV_HDR_SIZE;
11279 ctl_array = (uint32_t *)buf_ptr;
11280
11281 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
11282 sizeof(param->ctl_band));
11283 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
11284 param->ctl_cmd_len -
11285 sizeof(param->ctl_band));
11286
11287 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11288 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
11289 WMI_LOGE("%s:Failed to send command\n", __func__);
11290 wmi_buf_free(buf);
11291 return QDF_STATUS_E_FAILURE;
11292 }
11293
11294 return QDF_STATUS_SUCCESS;
11295}
11296
11297/**
11298 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
11299 * @wmi_handle: wmi handle
11300 * @param: pointer to hold mimogain table param
11301 *
11302 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11303 */
11304static QDF_STATUS
11305send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
11306 struct mimogain_table_params *param)
11307{
11308 uint16_t len, table_tlv_len;
11309 wmi_buf_t buf;
11310 uint8_t *buf_ptr;
11311 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
11312 uint32_t *gain_table;
11313
11314 if (!param->array_gain)
11315 return QDF_STATUS_E_FAILURE;
11316
11317 /* len must be multiple of a single array gain table */
11318 if (param->tbl_len %
11319 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
11320 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
11321 WMI_LOGE("Array gain table len not correct\n");
11322 return QDF_STATUS_E_FAILURE;
11323 }
11324
11325 table_tlv_len = WMI_TLV_HDR_SIZE +
11326 roundup(param->tbl_len, sizeof(uint32_t));
11327 len = sizeof(*cmd) + table_tlv_len;
11328
11329 buf = wmi_buf_alloc(wmi_handle, len);
11330 if (!buf) {
11331 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11332 return QDF_STATUS_E_FAILURE;
11333 }
11334
11335 buf_ptr = wmi_buf_data(buf);
11336 qdf_mem_zero(buf_ptr, len);
11337
11338 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
11339
11340 WMITLV_SET_HDR(&cmd->tlv_header,
11341 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
11342 WMITLV_GET_STRUCT_TLVLEN(
11343 wmi_pdev_set_mimogain_table_cmd_fixed_param));
11344
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011345 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11346 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011347 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
11348 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
11349 param->multichain_gain_bypass);
11350
11351 buf_ptr += sizeof(*cmd);
11352 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11353 (param->tbl_len));
11354 buf_ptr += WMI_TLV_HDR_SIZE;
11355 gain_table = (uint32_t *)buf_ptr;
11356
11357 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
11358 param->array_gain,
11359 param->tbl_len);
11360
11361 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11362 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
11363 return QDF_STATUS_E_FAILURE;
11364 }
11365
11366 return QDF_STATUS_SUCCESS;
11367}
11368
11369/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011370 * enum packet_power_tlv_flags: target defined
11371 * packet power rate flags for TLV
11372 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
11373 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
11374 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
11375 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
11376 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
11377 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
11378 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
11379 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
11380 * @WMI_TLV_FLAG_STBC: STBC is set
11381 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
11382 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
11383 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
11384 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
11385 * @WMI_TLV_FLAG_RTSENA: RTS enabled
11386 * @WMI_TLV_FLAG_CTSENA: CTS enabled
11387 * @WMI_TLV_FLAG_LDPC: LDPC is set
11388 * @WMI_TLV_FLAG_SGI: Short gaurd interval
11389 * @WMI_TLV_FLAG_SU: SU Data
11390 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
11391 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
11392 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
11393 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
11394 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
11395 *
11396 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
11397 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
11398 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
11399 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
11400 */
11401enum packet_power_tlv_flags {
11402 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
11403 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
11404 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
11405 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
11406 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
11407 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
11408 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
11409 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
11410 WMI_TLV_FLAG_STBC = 0x00000100,
11411 WMI_TLV_FLAG_40MHZ = 0x00000200,
11412 WMI_TLV_FLAG_80MHZ = 0x00000300,
11413 WMI_TLV_FLAG_160MHZ = 0x00000400,
11414 WMI_TLV_FLAG_TXBF = 0x00000800,
11415 WMI_TLV_FLAG_RTSENA = 0x00001000,
11416 WMI_TLV_FLAG_CTSENA = 0x00002000,
11417 WMI_TLV_FLAG_LDPC = 0x00004000,
11418 WMI_TLV_FLAG_SGI = 0x00008000,
11419 WMI_TLV_FLAG_SU = 0x00100000,
11420 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
11421 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
11422 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
11423 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
11424 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
11425
11426 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
11427 WMI_TLV_FLAG_BW_MASK = 0x3,
11428 WMI_TLV_FLAG_BW_SHIFT = 9,
11429 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
11430 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
11431};
11432
11433/**
11434 * convert_to_power_info_rate_flags() - convert packet_power_info_params
11435 * to FW understandable format
11436 * @param: pointer to hold packet power info param
11437 *
11438 * @return FW understandable 32 bit rate flags
11439 */
11440static uint32_t
11441convert_to_power_info_rate_flags(struct packet_power_info_params *param)
11442{
11443 uint32_t rateflags = 0;
11444
11445 if (param->chainmask)
11446 rateflags |=
11447 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
11448 if (param->chan_width)
11449 rateflags |=
11450 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
11451 << WMI_TLV_FLAG_BW_SHIFT);
11452 if (param->su_mu_ofdma)
11453 rateflags |=
11454 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
11455 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
11456 if (param->rate_flags & WMI_HOST_FLAG_STBC)
11457 rateflags |= WMI_TLV_FLAG_STBC;
11458 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
11459 rateflags |= WMI_TLV_FLAG_LDPC;
11460 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
11461 rateflags |= WMI_TLV_FLAG_TXBF;
11462 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
11463 rateflags |= WMI_TLV_FLAG_RTSENA;
11464 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
11465 rateflags |= WMI_TLV_FLAG_CTSENA;
11466 if (param->rate_flags & WMI_HOST_FLAG_SGI)
11467 rateflags |= WMI_TLV_FLAG_SGI;
11468
11469 return rateflags;
11470}
11471
11472/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011473 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
11474 * info to fw
11475 * @wmi_handle: wmi handle
11476 * @param: pointer to hold packet power info param
11477 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011478 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053011479 */
11480static QDF_STATUS
11481send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
11482 struct packet_power_info_params *param)
11483{
11484 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
11485 wmi_buf_t wmibuf;
11486 uint8_t *buf_ptr;
11487 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
11488
11489 wmibuf = wmi_buf_alloc(wmi_handle, len);
11490 if (wmibuf == NULL)
11491 return QDF_STATUS_E_NOMEM;
11492
11493 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
11494
11495 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
11496 WMITLV_SET_HDR(&cmd->tlv_header,
11497 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
11498 WMITLV_GET_STRUCT_TLVLEN(
11499 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011500 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11501 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011502 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053011503 cmd->nss = param->nss;
11504 cmd->preamble = param->preamble;
11505 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011506
11507 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
11508 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
11509 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
11510 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
11511
Sathish Kumar497bef42017-03-01 14:02:36 +053011512 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
11513 WMI_PDEV_GET_TPC_CMDID)) {
11514 WMI_LOGE(FL("Failed to get tpc command\n"));
11515 wmi_buf_free(wmibuf);
11516 return QDF_STATUS_E_FAILURE;
11517 }
11518
11519 return QDF_STATUS_SUCCESS;
11520}
11521
11522/**
11523 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
11524 * @wmi_handle: wmi handle
11525 * @param: pointer to hold config ratemask params
11526 *
11527 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11528 */
11529static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
11530 struct config_ratemask_params *param)
11531{
11532 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
11533 wmi_buf_t buf;
11534 int32_t len = sizeof(*cmd);
11535
11536 buf = wmi_buf_alloc(wmi_handle, len);
11537 if (!buf) {
11538 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11539 return QDF_STATUS_E_FAILURE;
11540 }
11541 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
11542 WMITLV_SET_HDR(&cmd->tlv_header,
11543 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
11544 WMITLV_GET_STRUCT_TLVLEN(
11545 wmi_vdev_config_ratemask_cmd_fixed_param));
11546 cmd->vdev_id = param->vdev_id;
11547 cmd->type = param->type;
11548 cmd->mask_lower32 = param->lower32;
11549 cmd->mask_higher32 = param->higher32;
11550 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
11551 param->vdev_id, param->type, param->lower32, param->higher32);
11552
11553 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11554 WMI_VDEV_RATEMASK_CMDID)) {
11555 WMI_LOGE("Seting vdev ratemask failed\n");
11556 wmi_buf_free(buf);
11557 return QDF_STATUS_E_FAILURE;
11558 }
11559
11560 return QDF_STATUS_SUCCESS;
11561}
11562
11563/**
Sathish Kumar6011c742017-11-08 14:49:58 +053011564 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
11565 * @param: param sent from the host side
11566 * @cmd: param to be sent to the fw side
11567 */
11568static inline void copy_custom_aggr_bitmap(
11569 struct set_custom_aggr_size_params *param,
11570 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
11571{
11572 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
11573 param->ac);
11574 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
11575 param->aggr_type);
11576 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11577 param->tx_aggr_size_disable);
11578 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11579 param->rx_aggr_size_disable);
11580 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
11581 param->tx_ac_enable);
11582}
11583
11584/**
11585 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
11586 * @wmi_handle: wmi handle
11587 * @param: pointer to hold custom aggr size params
11588 *
11589 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11590 */
11591static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
11592 wmi_unified_t wmi_handle,
11593 struct set_custom_aggr_size_params *param)
11594{
11595 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
11596 wmi_buf_t buf;
11597 int32_t len = sizeof(*cmd);
11598
11599 buf = wmi_buf_alloc(wmi_handle, len);
11600 if (!buf) {
11601 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11602 return QDF_STATUS_E_FAILURE;
11603 }
11604 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
11605 wmi_buf_data(buf);
11606 WMITLV_SET_HDR(&cmd->tlv_header,
11607 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
11608 WMITLV_GET_STRUCT_TLVLEN(
11609 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
11610 cmd->vdev_id = param->vdev_id;
11611 cmd->tx_aggr_size = param->tx_aggr_size;
11612 cmd->rx_aggr_size = param->rx_aggr_size;
11613 copy_custom_aggr_bitmap(param, cmd);
11614
11615 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
11616 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
11617 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
11618 "tx_ac_enable=0x%X\n",
11619 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
11620 param->ac, param->aggr_type, param->tx_aggr_size_disable,
11621 param->rx_aggr_size_disable, param->tx_ac_enable);
11622
11623 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11624 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
11625 WMI_LOGE("Seting custom aggregation size failed\n");
11626 wmi_buf_free(buf);
11627 return QDF_STATUS_E_FAILURE;
11628 }
11629
11630 return QDF_STATUS_SUCCESS;
11631}
11632
11633/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011634 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
11635 * @param wmi_handle : handle to WMI.
11636 * @param param : pointer to tx antenna param
11637 *
11638 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11639 */
11640
11641static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
11642 struct set_qdepth_thresh_params *param)
11643{
11644 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
11645 wmi_msduq_qdepth_thresh_update *cmd_update;
11646 wmi_buf_t buf;
11647 int32_t len = 0;
11648 int i;
11649 uint8_t *buf_ptr;
11650 QDF_STATUS ret;
11651
11652 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
11653 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
11654 return QDF_STATUS_E_INVAL;
11655 }
11656
11657 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11658 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
11659 param->num_of_msduq_updates);
11660 buf = wmi_buf_alloc(wmi_handle, len);
11661
11662 if (!buf) {
11663 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11664 return QDF_STATUS_E_NOMEM;
11665 }
11666
11667 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11668 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11669 buf_ptr;
11670
11671 WMITLV_SET_HDR(&cmd->tlv_header,
11672 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11673 , WMITLV_GET_STRUCT_TLVLEN(
11674 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11675
11676 cmd->pdev_id =
11677 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11678 cmd->vdev_id = param->vdev_id;
11679 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11680 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11681
11682 buf_ptr += sizeof(
11683 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11684 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11685 param->num_of_msduq_updates *
11686 sizeof(wmi_msduq_qdepth_thresh_update));
11687 buf_ptr += WMI_TLV_HDR_SIZE;
11688 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11689
11690 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11691 WMITLV_SET_HDR(&cmd_update->tlv_header,
11692 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11693 WMITLV_GET_STRUCT_TLVLEN(
11694 wmi_msduq_qdepth_thresh_update));
11695 cmd_update->tid_num = param->update_params[i].tid_num;
11696 cmd_update->msduq_update_mask =
11697 param->update_params[i].msduq_update_mask;
11698 cmd_update->qdepth_thresh_value =
11699 param->update_params[i].qdepth_thresh_value;
11700 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11701 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11702 " update mask=0x%X thresh val=0x%X\n",
11703 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11704 cmd->peer_mac_address.mac_addr31to0,
11705 cmd->peer_mac_address.mac_addr47to32,
11706 cmd_update->msduq_update_mask,
11707 cmd_update->qdepth_thresh_value);
11708 cmd_update++;
11709 }
11710
11711 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11712 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11713
11714 if (ret != 0) {
11715 WMI_LOGE(" %s :WMI Failed\n", __func__);
11716 wmi_buf_free(buf);
11717 }
11718
11719 return ret;
11720}
11721
11722/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011723 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11724 * @wmi_handle: wmi handle
11725 * @param: pointer to hold vap dscp tid map param
11726 *
11727 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11728 */
11729static QDF_STATUS
11730send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11731 struct vap_dscp_tid_map_params *param)
11732{
11733 wmi_buf_t buf;
11734 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11735 int32_t len = sizeof(*cmd);
11736
11737 buf = wmi_buf_alloc(wmi_handle, len);
11738 if (!buf) {
11739 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11740 return QDF_STATUS_E_FAILURE;
11741 }
11742
11743 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11744 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
11745 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
11746
11747 cmd->vdev_id = param->vdev_id;
11748 cmd->enable_override = 0;
11749
11750 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11751 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11752 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11753 WMI_LOGE("Failed to set dscp cmd\n");
11754 wmi_buf_free(buf);
11755 return QDF_STATUS_E_FAILURE;
11756 }
11757
11758 return QDF_STATUS_SUCCESS;
11759}
11760
11761/**
11762 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11763 * @wmi_handle: wmi handle
11764 * @macaddr: vdev mac address
11765 * @param: pointer to hold neigbour rx param
11766 *
11767 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11768 */
11769static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11770 uint8_t macaddr[IEEE80211_ADDR_LEN],
11771 struct set_neighbour_rx_params *param)
11772{
11773 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11774 wmi_buf_t buf;
11775 int32_t len = sizeof(*cmd);
11776
11777 buf = wmi_buf_alloc(wmi_handle, len);
11778 if (!buf) {
11779 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11780 return QDF_STATUS_E_FAILURE;
11781 }
11782 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11783 WMITLV_SET_HDR(&cmd->tlv_header,
11784 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11785 WMITLV_GET_STRUCT_TLVLEN(
11786 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11787 cmd->vdev_id = param->vdev_id;
11788 cmd->bssid_idx = param->idx;
11789 cmd->action = param->action;
11790 cmd->type = param->type;
11791 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11792 cmd->flag = 0;
11793
11794 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11795 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11796 WMI_LOGE("Failed to set neighbour rx param\n");
11797 wmi_buf_free(buf);
11798 return QDF_STATUS_E_FAILURE;
11799 }
11800
11801 return QDF_STATUS_SUCCESS;
11802}
11803
11804/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011805 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011806 * @param wmi_handle : handle to WMI.
11807 * @param macaddr : vdev mac address
11808 * @param param : pointer to tx antenna param
11809 *
11810 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11811 */
11812static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11813 uint8_t macaddr[IEEE80211_ADDR_LEN],
11814 struct smart_ant_tx_ant_params *param)
11815{
11816 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11817 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11818 wmi_buf_t buf;
11819 int32_t len = 0;
11820 int i;
11821 uint8_t *buf_ptr;
11822 QDF_STATUS ret;
11823
11824 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11825 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11826 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11827 buf = wmi_buf_alloc(wmi_handle, len);
11828
11829 if (!buf) {
11830 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11831 return QDF_STATUS_E_NOMEM;
11832 }
11833
11834 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11835 qdf_mem_zero(buf_ptr, len);
11836 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11837
11838 WMITLV_SET_HDR(&cmd->tlv_header,
11839 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11840 WMITLV_GET_STRUCT_TLVLEN(
11841 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11842
11843 cmd->vdev_id = param->vdev_id;
11844 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11845
11846 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11847 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11848 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11849 buf_ptr += WMI_TLV_HDR_SIZE;
11850 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11851
11852 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11853 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11854 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11855 WMITLV_GET_STRUCT_TLVLEN(
11856 wmi_peer_smart_ant_set_tx_antenna_series));
11857 ant_tx_series->antenna_series = param->antenna_array[i];
11858 ant_tx_series++;
11859 }
11860
11861 ret = wmi_unified_cmd_send(wmi_handle,
11862 buf,
11863 len,
11864 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11865
11866 if (ret != 0) {
11867 WMI_LOGE(" %s :WMI Failed\n", __func__);
11868 wmi_buf_free(buf);
11869 }
11870
11871 return ret;
11872}
11873
Sathish Kumar02c3b542017-02-22 17:24:45 +053011874/**
11875 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11876 * @wmi_handle: wmi handle
11877 * @param: pointer to hold ant switch tbl param
11878 *
11879 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11880 */
11881static QDF_STATUS
11882send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11883 struct ant_switch_tbl_params *param)
11884{
11885 uint8_t len;
11886 wmi_buf_t buf;
11887 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11888 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11889 uint8_t *buf_ptr;
11890
11891 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11892 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11893 buf = wmi_buf_alloc(wmi_handle, len);
11894
11895 if (!buf) {
11896 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11897 return QDF_STATUS_E_NOMEM;
11898 }
11899
11900 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11901 qdf_mem_zero(buf_ptr, len);
11902 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11903
11904 WMITLV_SET_HDR(&cmd->tlv_header,
11905 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11906 WMITLV_GET_STRUCT_TLVLEN(
11907 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11908
11909 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11910 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011911 cmd->mac_id =
11912 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011913
11914 /* TLV indicating array of structures to follow */
11915 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11916 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11917 sizeof(wmi_pdev_set_ant_ctrl_chain));
11918 buf_ptr += WMI_TLV_HDR_SIZE;
11919 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11920
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011921 ctrl_chain->pdev_id =
11922 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011923 ctrl_chain->antCtrlChain = param->antCtrlChain;
11924
11925 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11926 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11927 wmi_buf_free(buf);
11928 return QDF_STATUS_E_FAILURE;
11929 }
11930
11931 return QDF_STATUS_SUCCESS;
11932}
11933
11934/**
11935 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11936 * training information function
11937 * @param wmi_handle : handle to WMI.
11938 * @macaddr : vdev mac address
11939 * @param param : pointer to tx antenna param
11940 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11941 */
11942static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11943 wmi_unified_t wmi_handle,
11944 uint8_t macaddr[IEEE80211_ADDR_LEN],
11945 struct smart_ant_training_info_params *param)
11946{
11947 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11948 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11949 wmi_buf_t buf;
11950 uint8_t *buf_ptr;
11951 int32_t len = 0;
11952 QDF_STATUS ret;
11953 int loop;
11954
11955 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11956 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11957 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11958 buf = wmi_buf_alloc(wmi_handle, len);
11959
11960 if (!buf) {
11961 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11962 return QDF_STATUS_E_NOMEM;
11963 }
11964
11965 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11966 qdf_mem_zero(buf_ptr, len);
11967 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11968
11969 WMITLV_SET_HDR(&cmd->tlv_header,
11970 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11971 WMITLV_GET_STRUCT_TLVLEN(
11972 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11973
11974 cmd->vdev_id = param->vdev_id;
11975 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11976 cmd->num_pkts = param->numpkts;
11977
11978 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11979 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11980 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11981 WMI_SMART_ANT_MAX_RATE_SERIES);
11982
11983 buf_ptr += WMI_TLV_HDR_SIZE;
11984 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11985
11986 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11987 WMITLV_SET_HDR(&train_param->tlv_header,
11988 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11989 WMITLV_GET_STRUCT_TLVLEN(
11990 wmi_peer_smart_ant_set_train_antenna_param));
11991 train_param->train_rate_series = param->rate_array[loop];
11992 train_param->train_antenna_series = param->antenna_array[loop];
11993 train_param->rc_flags = 0;
11994 WMI_LOGI(FL("Series number:%d\n"), loop);
11995 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11996 train_param->train_rate_series,
11997 train_param->train_antenna_series);
11998 train_param++;
11999 }
12000
12001 ret = wmi_unified_cmd_send(wmi_handle,
12002 buf,
12003 len,
12004 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
12005
12006 if (ret != 0) {
12007 WMI_LOGE(" %s :WMI Failed\n", __func__);
12008 wmi_buf_free(buf);
12009 return QDF_STATUS_E_FAILURE;
12010 }
12011
12012 return ret;
12013}
12014
12015/**
12016 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
12017 * configuration function
12018 * @param wmi_handle : handle to WMI.
12019 * @macaddr : vdev mad address
12020 * @param param : pointer to tx antenna param
12021 *
12022 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12023 */
12024static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
12025 wmi_unified_t wmi_handle,
12026 uint8_t macaddr[IEEE80211_ADDR_LEN],
12027 struct smart_ant_node_config_params *param)
12028{
12029 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
12030 wmi_buf_t buf;
12031 uint8_t *buf_ptr;
12032 int32_t len = 0, args_tlv_len;
12033 int ret;
12034 int i = 0;
12035 A_UINT32 *node_config_args;
12036
12037 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
12038 len = sizeof(*cmd) + args_tlv_len;
12039
12040 if ((param->args_count == 0)) {
12041 WMI_LOGE("%s: Can't send a command with %d arguments\n",
12042 __func__, param->args_count);
12043 return QDF_STATUS_E_FAILURE;
12044 }
12045
12046 buf = wmi_buf_alloc(wmi_handle, len);
12047 if (!buf) {
12048 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12049 return QDF_STATUS_E_NOMEM;
12050 }
12051
12052 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
12053 wmi_buf_data(buf);
12054 buf_ptr = (uint8_t *)cmd;
12055 WMITLV_SET_HDR(&cmd->tlv_header,
12056 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
12057 WMITLV_GET_STRUCT_TLVLEN(
12058 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
12059 cmd->vdev_id = param->vdev_id;
12060 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12061 cmd->cmd_id = param->cmd_id;
12062 cmd->args_count = param->args_count;
12063 buf_ptr += sizeof(
12064 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
12065 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12066 (cmd->args_count * sizeof(A_UINT32)));
12067 buf_ptr += WMI_TLV_HDR_SIZE;
12068 node_config_args = (A_UINT32 *)buf_ptr;
12069
12070 for (i = 0; i < param->args_count; i++) {
12071 node_config_args[i] = param->args_arr[i];
12072 WMI_LOGI("%d", param->args_arr[i]);
12073 }
12074
12075 ret = wmi_unified_cmd_send(wmi_handle,
12076 buf,
12077 len,
12078 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
12079
12080 if (ret != 0) {
12081 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
12082 __func__, param->cmd_id, macaddr[0],
12083 macaddr[1], macaddr[2], macaddr[3],
12084 macaddr[4], macaddr[5], ret);
12085 wmi_buf_free(buf);
12086 }
12087
12088 return ret;
12089}
12090
12091/**
12092 * send_set_atf_cmd_tlv() - send set atf command to fw
12093 * @wmi_handle: wmi handle
12094 * @param: pointer to set atf param
12095 *
12096 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12097 */
12098static QDF_STATUS
12099send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
12100 struct set_atf_params *param)
12101{
12102 wmi_atf_peer_info *peer_info;
12103 wmi_peer_atf_request_fixed_param *cmd;
12104 wmi_buf_t buf;
12105 uint8_t *buf_ptr;
12106 int i;
12107 int32_t len = 0;
12108 QDF_STATUS retval;
12109
12110 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12111 len += param->num_peers * sizeof(wmi_atf_peer_info);
12112 buf = wmi_buf_alloc(wmi_handle, len);
12113 if (!buf) {
12114 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12115 return QDF_STATUS_E_FAILURE;
12116 }
12117 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12118 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
12119 WMITLV_SET_HDR(&cmd->tlv_header,
12120 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
12121 WMITLV_GET_STRUCT_TLVLEN(
12122 wmi_peer_atf_request_fixed_param));
12123 cmd->num_peers = param->num_peers;
12124
12125 buf_ptr += sizeof(*cmd);
12126 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12127 sizeof(wmi_atf_peer_info) *
12128 cmd->num_peers);
12129 buf_ptr += WMI_TLV_HDR_SIZE;
12130 peer_info = (wmi_atf_peer_info *)buf_ptr;
12131
12132 for (i = 0; i < cmd->num_peers; i++) {
12133 WMITLV_SET_HDR(&peer_info->tlv_header,
12134 WMITLV_TAG_STRUC_wmi_atf_peer_info,
12135 WMITLV_GET_STRUCT_TLVLEN(
12136 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012137 qdf_mem_copy(&(peer_info->peer_macaddr),
12138 &(param->peer_info[i].peer_macaddr),
12139 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053012140 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012141 peer_info->vdev_id = param->peer_info[i].vdev_id;
12142 peer_info->pdev_id =
12143 wmi_handle->ops->convert_pdev_id_host_to_target(
12144 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053012145 /*
12146 * TLV definition for peer atf request fixed param combines
12147 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
12148 * stats and atf extension stats as two different
12149 * implementations.
12150 * Need to discuss with FW on this.
12151 *
12152 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
12153 * peer_info->atf_units_reserved =
12154 * param->peer_ext_info[i].atf_index_reserved;
12155 */
12156 peer_info++;
12157 }
12158
12159 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12160 WMI_PEER_ATF_REQUEST_CMDID);
12161
12162 if (retval != QDF_STATUS_SUCCESS) {
12163 WMI_LOGE("%s : WMI Failed\n", __func__);
12164 wmi_buf_free(buf);
12165 }
12166
12167 return retval;
12168}
12169
12170/**
12171 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
12172 * @wmi_handle: wmi handle
12173 * @param: pointer to hold fwtest param
12174 *
12175 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12176 */
12177static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
12178 struct set_fwtest_params *param)
12179{
12180 wmi_fwtest_set_param_cmd_fixed_param *cmd;
12181 wmi_buf_t buf;
12182 int32_t len = sizeof(*cmd);
12183
12184 buf = wmi_buf_alloc(wmi_handle, len);
12185
12186 if (!buf) {
12187 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12188 return QDF_STATUS_E_FAILURE;
12189 }
12190
12191 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
12192 WMITLV_SET_HDR(&cmd->tlv_header,
12193 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
12194 WMITLV_GET_STRUCT_TLVLEN(
12195 wmi_fwtest_set_param_cmd_fixed_param));
12196 cmd->param_id = param->arg;
12197 cmd->param_value = param->value;
12198
12199 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
12200 WMI_LOGE("Setting FW test param failed\n");
12201 wmi_buf_free(buf);
12202 return QDF_STATUS_E_FAILURE;
12203 }
12204
12205 return QDF_STATUS_SUCCESS;
12206}
12207
12208/**
12209 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
12210 * @wmi_handle: wmi handle
12211 * @param: pointer to qboost params
12212 * @macaddr: vdev mac address
12213 *
12214 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12215 */
12216static QDF_STATUS
12217send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
12218 uint8_t macaddr[IEEE80211_ADDR_LEN],
12219 struct set_qboost_params *param)
12220{
12221 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
12222 wmi_buf_t buf;
12223 int32_t len;
12224 QDF_STATUS ret;
12225
12226 len = sizeof(*cmd);
12227
12228 buf = wmi_buf_alloc(wmi_handle, len);
12229 if (!buf) {
12230 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12231 return QDF_STATUS_E_FAILURE;
12232 }
12233
12234 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
12235 WMITLV_SET_HDR(&cmd->tlv_header,
12236 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
12237 WMITLV_GET_STRUCT_TLVLEN(
12238 WMI_QBOOST_CFG_CMD_fixed_param));
12239 cmd->vdev_id = param->vdev_id;
12240 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12241 cmd->qb_enable = param->value;
12242
12243 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12244 WMI_QBOOST_CFG_CMDID);
12245
12246 if (ret != 0) {
12247 WMI_LOGE("Setting qboost cmd failed\n");
12248 wmi_buf_free(buf);
12249 }
12250
12251 return ret;
12252}
12253
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012254/**
12255 * send_gpio_config_cmd_tlv() - send gpio config to fw
12256 * @wmi_handle: wmi handle
12257 * @param: pointer to hold gpio config param
12258 *
12259 * Return: 0 for success or error code
12260 */
12261static QDF_STATUS
12262send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
12263 struct gpio_config_params *param)
12264{
12265 wmi_gpio_config_cmd_fixed_param *cmd;
12266 wmi_buf_t buf;
12267 int32_t len;
12268 QDF_STATUS ret;
12269
12270 len = sizeof(*cmd);
12271
12272 /* Sanity Checks */
12273 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
12274 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
12275 return QDF_STATUS_E_FAILURE;
12276 }
12277
12278 buf = wmi_buf_alloc(wmi_handle, len);
12279 if (!buf) {
12280 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12281 return QDF_STATUS_E_FAILURE;
12282 }
12283
12284 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
12285 WMITLV_SET_HDR(&cmd->tlv_header,
12286 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
12287 WMITLV_GET_STRUCT_TLVLEN(
12288 wmi_gpio_config_cmd_fixed_param));
12289 cmd->gpio_num = param->gpio_num;
12290 cmd->input = param->input;
12291 cmd->pull_type = param->pull_type;
12292 cmd->intr_mode = param->intr_mode;
12293
12294 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12295 WMI_GPIO_CONFIG_CMDID);
12296
12297 if (ret != 0) {
12298 WMI_LOGE("Sending GPIO config cmd failed\n");
12299 wmi_buf_free(buf);
12300 }
12301
12302 return ret;
12303}
12304
12305/**
12306 * send_gpio_output_cmd_tlv() - send gpio output to fw
12307 * @wmi_handle: wmi handle
12308 * @param: pointer to hold gpio output param
12309 *
12310 * Return: 0 for success or error code
12311 */
12312static QDF_STATUS
12313send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
12314 struct gpio_output_params *param)
12315{
12316 wmi_gpio_output_cmd_fixed_param *cmd;
12317 wmi_buf_t buf;
12318 int32_t len;
12319 QDF_STATUS ret;
12320
12321 len = sizeof(*cmd);
12322
12323 buf = wmi_buf_alloc(wmi_handle, len);
12324 if (!buf) {
12325 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12326 return QDF_STATUS_E_FAILURE;
12327 }
12328
12329 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
12330 WMITLV_SET_HDR(&cmd->tlv_header,
12331 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
12332 WMITLV_GET_STRUCT_TLVLEN(
12333 wmi_gpio_output_cmd_fixed_param));
12334 cmd->gpio_num = param->gpio_num;
12335 cmd->set = param->set;
12336
12337 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12338 WMI_GPIO_OUTPUT_CMDID);
12339
12340 if (ret != 0) {
12341 WMI_LOGE("Sending GPIO output cmd failed\n");
12342 wmi_buf_free(buf);
12343 }
12344
12345 return ret;
12346
12347}
12348
12349/**
12350 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
12351 *
12352 * @param wmi_handle : handle to WMI.
12353 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12354 */
12355static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
12356{
12357 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
12358 wmi_buf_t buf;
12359 QDF_STATUS ret;
12360 int32_t len;
12361
12362 len = sizeof(*cmd);
12363
12364 buf = wmi_buf_alloc(wmi_handle, len);
12365 if (!buf) {
12366 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12367 return QDF_STATUS_E_FAILURE;
12368 }
12369
12370 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
12371 WMITLV_SET_HDR(&cmd->tlv_header,
12372 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
12373 WMITLV_GET_STRUCT_TLVLEN(
12374 wmi_pdev_dfs_disable_cmd_fixed_param));
12375 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012376 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12377 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012378
12379 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12380 WMI_PDEV_DFS_DISABLE_CMDID);
12381
12382 if (ret != 0) {
12383 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
12384 wmi_buf_free(buf);
12385 }
12386
12387 return ret;
12388}
12389
12390/**
12391 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
12392 *
12393 * @param wmi_handle : handle to WMI.
12394 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12395 */
12396static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
12397{
12398 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
12399 wmi_buf_t buf;
12400 QDF_STATUS ret;
12401 int32_t len;
12402
12403 len = sizeof(*cmd);
12404
12405 buf = wmi_buf_alloc(wmi_handle, len);
12406 if (!buf) {
12407 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12408 return QDF_STATUS_E_FAILURE;
12409 }
12410
12411 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
12412 WMITLV_SET_HDR(&cmd->tlv_header,
12413 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
12414 WMITLV_GET_STRUCT_TLVLEN(
12415 wmi_pdev_dfs_enable_cmd_fixed_param));
12416 /* Reserved for future use */
12417 cmd->reserved0 = 0;
12418
12419 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12420 WMI_PDEV_DFS_ENABLE_CMDID);
12421
12422 if (ret != 0) {
12423 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
12424 wmi_buf_free(buf);
12425 }
12426
12427 return ret;
12428}
12429
12430/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053012431 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
12432 * to fw
12433 * @wmi_handle: wmi handle
12434 * @param: pointer to hold periodic chan stats param
12435 *
12436 * Return: 0 for success or error code
12437 */
12438static QDF_STATUS
12439send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
12440 struct periodic_chan_stats_params *param)
12441{
12442 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
12443 wmi_buf_t buf;
12444 QDF_STATUS ret;
12445 int32_t len;
12446
12447 len = sizeof(*cmd);
12448
12449 buf = wmi_buf_alloc(wmi_handle, len);
12450 if (!buf) {
12451 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12452 return QDF_STATUS_E_FAILURE;
12453 }
12454
12455 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
12456 wmi_buf_data(buf);
12457 WMITLV_SET_HDR(&cmd->tlv_header,
12458 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
12459 WMITLV_GET_STRUCT_TLVLEN(
12460 wmi_set_periodic_channel_stats_config_fixed_param));
12461 cmd->enable = param->enable;
12462 cmd->stats_period = param->stats_period;
12463 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12464 param->pdev_id);
12465
12466 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12467 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
12468
12469 if (ret != 0) {
12470 WMI_LOGE("Sending periodic chan stats config failed");
12471 wmi_buf_free(buf);
12472 }
12473
12474 return ret;
12475}
12476
12477/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012478 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
12479 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080012480 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012481 *
12482 * Return: 0 for success or error code
12483 */
12484static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080012485send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012486{
12487 wmi_buf_t buf;
12488 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080012489 wmi_pdev_get_nfcal_power_fixed_param *cmd;
12490 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012491
nobeljf74583b2018-01-25 16:35:36 -080012492 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012493 if (buf == NULL)
12494 return QDF_STATUS_E_NOMEM;
12495
nobeljf74583b2018-01-25 16:35:36 -080012496 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
12497 WMITLV_SET_HDR(&cmd->tlv_header,
12498 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
12499 WMITLV_GET_STRUCT_TLVLEN
12500 (wmi_pdev_get_nfcal_power_fixed_param));
12501 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
12502
12503 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012504 WMI_PDEV_GET_NFCAL_POWER_CMDID);
12505 if (ret != 0) {
12506 WMI_LOGE("Sending get nfcal power cmd failed\n");
12507 wmi_buf_free(buf);
12508 }
12509
12510 return ret;
12511}
12512
12513/**
12514 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
12515 * @wmi_handle: wmi handle
12516 * @param: pointer to ht ie param
12517 *
12518 * Return: 0 for success or error code
12519 */
12520static QDF_STATUS
12521send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12522 struct ht_ie_params *param)
12523{
12524 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
12525 wmi_buf_t buf;
12526 QDF_STATUS ret;
12527 int32_t len;
12528 uint8_t *buf_ptr;
12529
12530 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12531 roundup(param->ie_len, sizeof(uint32_t));
12532
12533 buf = wmi_buf_alloc(wmi_handle, len);
12534 if (!buf) {
12535 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12536 return QDF_STATUS_E_FAILURE;
12537 }
12538
12539 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12540 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
12541 WMITLV_SET_HDR(&cmd->tlv_header,
12542 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
12543 WMITLV_GET_STRUCT_TLVLEN(
12544 wmi_pdev_set_ht_ie_cmd_fixed_param));
12545 cmd->reserved0 = 0;
12546 cmd->ie_len = param->ie_len;
12547 cmd->tx_streams = param->tx_streams;
12548 cmd->rx_streams = param->rx_streams;
12549
12550 buf_ptr += sizeof(*cmd);
12551 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12552 buf_ptr += WMI_TLV_HDR_SIZE;
12553 if (param->ie_len)
12554 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12555 cmd->ie_len);
12556
12557 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12558 WMI_PDEV_SET_HT_CAP_IE_CMDID);
12559
12560 if (ret != 0) {
12561 WMI_LOGE("Sending set ht ie cmd failed\n");
12562 wmi_buf_free(buf);
12563 }
12564
12565 return ret;
12566}
12567
12568/**
12569 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
12570 * @wmi_handle: wmi handle
12571 * @param: pointer to vht ie param
12572 *
12573 * Return: 0 for success or error code
12574 */
12575static QDF_STATUS
12576send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12577 struct vht_ie_params *param)
12578{
12579 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
12580 wmi_buf_t buf;
12581 QDF_STATUS ret;
12582 int32_t len;
12583 uint8_t *buf_ptr;
12584
12585 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12586 roundup(param->ie_len, sizeof(uint32_t));
12587
12588 buf = wmi_buf_alloc(wmi_handle, len);
12589 if (!buf) {
12590 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12591 return QDF_STATUS_E_FAILURE;
12592 }
12593
12594 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12595 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
12596 WMITLV_SET_HDR(&cmd->tlv_header,
12597 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
12598 WMITLV_GET_STRUCT_TLVLEN(
12599 wmi_pdev_set_vht_ie_cmd_fixed_param));
12600 cmd->reserved0 = 0;
12601 cmd->ie_len = param->ie_len;
12602 cmd->tx_streams = param->tx_streams;
12603 cmd->rx_streams = param->rx_streams;
12604
12605 buf_ptr += sizeof(*cmd);
12606 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12607 buf_ptr += WMI_TLV_HDR_SIZE;
12608 if (param->ie_len)
12609 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12610 cmd->ie_len);
12611
12612 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12613 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
12614
12615 if (ret != 0) {
12616 WMI_LOGE("Sending set vht ie cmd failed\n");
12617 wmi_buf_free(buf);
12618 }
12619
12620 return ret;
12621}
12622
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012623/**
12624 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
12625 * @wmi_handle: wmi handle
12626 * @param: pointer to quiet mode params
12627 *
12628 * Return: 0 for success or error code
12629 */
12630static QDF_STATUS
12631send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
12632 struct set_quiet_mode_params *param)
12633{
12634 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
12635 wmi_buf_t buf;
12636 QDF_STATUS ret;
12637 int32_t len;
12638
12639 len = sizeof(*quiet_cmd);
12640 buf = wmi_buf_alloc(wmi_handle, len);
12641 if (!buf) {
12642 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12643 return QDF_STATUS_E_FAILURE;
12644 }
12645
12646 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12647 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
12648 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
12649 WMITLV_GET_STRUCT_TLVLEN(
12650 wmi_pdev_set_quiet_cmd_fixed_param));
12651 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12652 quiet_cmd->enabled = param->enabled;
12653 quiet_cmd->period = (param->period)*(param->intval);
12654 quiet_cmd->duration = param->duration;
12655 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012656 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12657 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012658
12659 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12660 WMI_PDEV_SET_QUIET_MODE_CMDID);
12661
12662 if (ret != 0) {
12663 WMI_LOGE("Sending set quiet cmd failed\n");
12664 wmi_buf_free(buf);
12665 }
12666
12667 return ret;
12668}
12669
12670/**
12671 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12672 * @wmi_handle: wmi handle
12673 * @param: pointer to set bwf param
12674 *
12675 * Return: 0 for success or error code
12676 */
12677static QDF_STATUS
12678send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12679 struct set_bwf_params *param)
12680{
12681 wmi_bwf_peer_info *peer_info;
12682 wmi_peer_bwf_request_fixed_param *cmd;
12683 wmi_buf_t buf;
12684 QDF_STATUS retval;
12685 int32_t len;
12686 uint8_t *buf_ptr;
12687 int i;
12688
12689 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12690 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12691 buf = wmi_buf_alloc(wmi_handle, len);
12692 if (!buf) {
12693 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12694 return QDF_STATUS_E_FAILURE;
12695 }
12696 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12697 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12698 WMITLV_SET_HDR(&cmd->tlv_header,
12699 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12700 WMITLV_GET_STRUCT_TLVLEN(
12701 wmi_peer_bwf_request_fixed_param));
12702 cmd->num_peers = param->num_peers;
12703
12704 buf_ptr += sizeof(*cmd);
12705 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12706 sizeof(wmi_bwf_peer_info) *
12707 cmd->num_peers);
12708 buf_ptr += WMI_TLV_HDR_SIZE;
12709 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12710
12711 for (i = 0; i < cmd->num_peers; i++) {
12712 WMITLV_SET_HDR(&peer_info->tlv_header,
12713 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12714 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12715 peer_info->bwf_guaranteed_bandwidth =
12716 param->peer_info[i].throughput;
12717 peer_info->bwf_max_airtime =
12718 param->peer_info[i].max_airtime;
12719 peer_info->bwf_peer_priority =
12720 param->peer_info[i].priority;
12721 qdf_mem_copy(&peer_info->peer_macaddr,
12722 &param->peer_info[i].peer_macaddr,
12723 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012724 peer_info->vdev_id =
12725 param->peer_info[i].vdev_id;
12726 peer_info->pdev_id =
12727 wmi_handle->ops->convert_pdev_id_host_to_target(
12728 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012729 peer_info++;
12730 }
12731
12732 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12733 WMI_PEER_BWF_REQUEST_CMDID);
12734
12735 if (retval != QDF_STATUS_SUCCESS) {
12736 WMI_LOGE("%s : WMI Failed\n", __func__);
12737 wmi_buf_free(buf);
12738 }
12739
12740 return retval;
12741}
12742
12743/**
12744 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12745 * @wmi_handle: wmi handle
12746 * @param: pointer to hold mcast update param
12747 *
12748 * Return: 0 for success or error code
12749 */
12750static QDF_STATUS
12751send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12752 struct mcast_group_update_params *param)
12753{
12754 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12755 wmi_buf_t buf;
12756 QDF_STATUS ret;
12757 int32_t len;
12758 int offset = 0;
12759 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12760
12761 len = sizeof(*cmd);
12762 buf = wmi_buf_alloc(wmi_handle, len);
12763 if (!buf) {
12764 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12765 return QDF_STATUS_E_FAILURE;
12766 }
12767 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12768 WMITLV_SET_HDR(&cmd->tlv_header,
12769 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12770 WMITLV_GET_STRUCT_TLVLEN(
12771 wmi_peer_mcast_group_cmd_fixed_param));
12772 /* confirm the buffer is 4-byte aligned */
12773 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12774 qdf_mem_zero(cmd, sizeof(*cmd));
12775
12776 cmd->vdev_id = param->vap_id;
12777 /* construct the message assuming our endianness matches the target */
12778 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12779 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12780 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12781 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12782 if (param->is_action_delete)
12783 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12784
12785 if (param->is_mcast_addr_len)
12786 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12787
12788 if (param->is_filter_mode_snoop)
12789 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12790
12791 /* unicast address spec only applies for non-wildcard cases */
12792 if (!param->wildcard && param->ucast_mac_addr) {
12793 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12794 &cmd->ucast_mac_addr);
12795 }
Amar Singhal5593c902017-10-03 13:00:29 -070012796
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012797 if (param->mcast_ip_addr) {
12798 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12799 sizeof(cmd->mcast_ip_addr));
12800 offset = sizeof(cmd->mcast_ip_addr) -
12801 param->mcast_ip_addr_bytes;
12802 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12803 param->mcast_ip_addr,
12804 param->mcast_ip_addr_bytes);
12805 }
12806 if (!param->mask)
12807 param->mask = &dummymask[0];
12808
12809 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12810 param->mask,
12811 param->mcast_ip_addr_bytes);
12812
12813 if (param->srcs && param->nsrcs) {
12814 cmd->num_filter_addr = param->nsrcs;
12815 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12816 sizeof(cmd->filter_addr));
12817
12818 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12819 param->nsrcs * param->mcast_ip_addr_bytes);
12820 }
12821
12822 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12823 WMI_PEER_MCAST_GROUP_CMDID);
12824
12825 if (ret != QDF_STATUS_SUCCESS) {
12826 WMI_LOGE("%s : WMI Failed\n", __func__);
12827 wmi_buf_free(buf);
12828 }
12829
12830 return ret;
12831}
12832
12833/**
12834 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12835 * command to fw
12836 * @wmi_handle: wmi handle
12837 * @param: pointer to hold spectral config parameter
12838 *
12839 * Return: 0 for success or error code
12840 */
12841static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12842 struct vdev_spectral_configure_params *param)
12843{
12844 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12845 wmi_buf_t buf;
12846 QDF_STATUS ret;
12847 int32_t len;
12848
12849 len = sizeof(*cmd);
12850 buf = wmi_buf_alloc(wmi_handle, len);
12851 if (!buf) {
12852 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12853 return QDF_STATUS_E_FAILURE;
12854 }
12855
12856 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12857 WMITLV_SET_HDR(&cmd->tlv_header,
12858 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12859 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012860 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012861
12862 cmd->vdev_id = param->vdev_id;
12863 cmd->spectral_scan_count = param->count;
12864 cmd->spectral_scan_period = param->period;
12865 cmd->spectral_scan_priority = param->spectral_pri;
12866 cmd->spectral_scan_fft_size = param->fft_size;
12867 cmd->spectral_scan_gc_ena = param->gc_enable;
12868 cmd->spectral_scan_restart_ena = param->restart_enable;
12869 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12870 cmd->spectral_scan_init_delay = param->init_delay;
12871 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12872 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12873 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12874 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12875 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12876 cmd->spectral_scan_pwr_format = param->pwr_format;
12877 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12878 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012879 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012880 cmd->spectral_scan_chn_mask = param->chn_mask;
12881
12882 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12883 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12884
12885 if (ret != 0) {
12886 WMI_LOGE("Sending set quiet cmd failed\n");
12887 wmi_buf_free(buf);
12888 }
12889
12890 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12891 __func__);
12892
12893 WMI_LOGI("vdev_id = %u\n"
12894 "spectral_scan_count = %u\n"
12895 "spectral_scan_period = %u\n"
12896 "spectral_scan_priority = %u\n"
12897 "spectral_scan_fft_size = %u\n"
12898 "spectral_scan_gc_ena = %u\n"
12899 "spectral_scan_restart_ena = %u\n"
12900 "spectral_scan_noise_floor_ref = %u\n"
12901 "spectral_scan_init_delay = %u\n"
12902 "spectral_scan_nb_tone_thr = %u\n"
12903 "spectral_scan_str_bin_thr = %u\n"
12904 "spectral_scan_wb_rpt_mode = %u\n"
12905 "spectral_scan_rssi_rpt_mode = %u\n"
12906 "spectral_scan_rssi_thr = %u\n"
12907 "spectral_scan_pwr_format = %u\n"
12908 "spectral_scan_rpt_mode = %u\n"
12909 "spectral_scan_bin_scale = %u\n"
12910 "spectral_scan_dBm_adj = %u\n"
12911 "spectral_scan_chn_mask = %u\n",
12912 param->vdev_id,
12913 param->count,
12914 param->period,
12915 param->spectral_pri,
12916 param->fft_size,
12917 param->gc_enable,
12918 param->restart_enable,
12919 param->noise_floor_ref,
12920 param->init_delay,
12921 param->nb_tone_thr,
12922 param->str_bin_thr,
12923 param->wb_rpt_mode,
12924 param->rssi_rpt_mode,
12925 param->rssi_thr,
12926 param->pwr_format,
12927 param->rpt_mode,
12928 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012929 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012930 param->chn_mask);
12931 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12932
12933 return ret;
12934}
12935
12936/**
12937 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12938 * command to fw
12939 * @wmi_handle: wmi handle
12940 * @param: pointer to hold spectral enable parameter
12941 *
12942 * Return: 0 for success or error code
12943 */
12944static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12945 struct vdev_spectral_enable_params *param)
12946{
12947 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12948 wmi_buf_t buf;
12949 QDF_STATUS ret;
12950 int32_t len;
12951
12952 len = sizeof(*cmd);
12953 buf = wmi_buf_alloc(wmi_handle, len);
12954 if (!buf) {
12955 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12956 return QDF_STATUS_E_FAILURE;
12957 }
12958
12959 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12960 WMITLV_SET_HDR(&cmd->tlv_header,
12961 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12962 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012963 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012964
12965 cmd->vdev_id = param->vdev_id;
12966
12967 if (param->active_valid) {
12968 cmd->trigger_cmd = param->active ? 1 : 2;
12969 /* 1: Trigger, 2: Clear Trigger */
12970 } else {
12971 cmd->trigger_cmd = 0; /* 0: Ignore */
12972 }
12973
12974 if (param->enabled_valid) {
12975 cmd->enable_cmd = param->enabled ? 1 : 2;
12976 /* 1: Enable 2: Disable */
12977 } else {
12978 cmd->enable_cmd = 0; /* 0: Ignore */
12979 }
12980
12981 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12982 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12983
12984 if (ret != 0) {
12985 WMI_LOGE("Sending scan enable CMD failed\n");
12986 wmi_buf_free(buf);
12987 }
12988
12989 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12990
12991 WMI_LOGI("vdev_id = %u\n"
12992 "trigger_cmd = %u\n"
12993 "enable_cmd = %u\n",
12994 cmd->vdev_id,
12995 cmd->trigger_cmd,
12996 cmd->enable_cmd);
12997
12998 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12999
13000 return ret;
13001}
13002
13003/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053013004 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
13005 * @param wmi_handle : handle to WMI.
13006 * @param param : pointer to hold thermal mitigation param
13007 *
13008 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
13009 */
13010static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
13011 wmi_unified_t wmi_handle,
13012 struct thermal_mitigation_params *param)
13013{
13014 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
13015 wmi_therm_throt_level_config_info *lvl_conf = NULL;
13016 wmi_buf_t buf = NULL;
13017 uint8_t *buf_ptr = NULL;
13018 int error;
13019 int32_t len;
13020 int i;
13021
13022 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
13023 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
13024
13025 buf = wmi_buf_alloc(wmi_handle, len);
13026 if (!buf) {
13027 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13028 return QDF_STATUS_E_NOMEM;
13029 }
13030 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
13031
13032 /* init fixed params */
13033 WMITLV_SET_HDR(tt_conf,
13034 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
13035 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
13036
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013037 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13038 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053013039 tt_conf->enable = param->enable;
13040 tt_conf->dc = param->dc;
13041 tt_conf->dc_per_event = param->dc_per_event;
13042 tt_conf->therm_throt_levels = THERMAL_LEVELS;
13043
13044 buf_ptr = (uint8_t *) ++tt_conf;
13045 /* init TLV params */
13046 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13047 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
13048
13049 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
13050 for (i = 0; i < THERMAL_LEVELS; i++) {
13051 WMITLV_SET_HDR(&lvl_conf->tlv_header,
13052 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
13053 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
13054 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
13055 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
13056 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
13057 lvl_conf->prio = param->levelconf[i].priority;
13058 lvl_conf++;
13059 }
13060
13061 error = wmi_unified_cmd_send(wmi_handle, buf, len,
13062 WMI_THERM_THROT_SET_CONF_CMDID);
13063 if (QDF_IS_STATUS_ERROR(error)) {
13064 wmi_buf_free(buf);
13065 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
13066 }
13067
13068 return error;
13069}
13070
13071/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013072 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
13073 * @wmi_handle: wmi handle
13074 * @param: pointer to pdev_qvit_params
13075 *
13076 * Return: 0 for success or error code
13077 */
13078static QDF_STATUS
13079send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
13080 struct pdev_qvit_params *param)
13081{
13082 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013083 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013084 uint8_t *cmd;
13085 static uint8_t msgref = 1;
13086 uint8_t segnumber = 0, seginfo, numsegments;
13087 uint16_t chunk_len, total_bytes;
13088 uint8_t *bufpos;
13089 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
13090
13091 bufpos = param->utf_payload;
13092 total_bytes = param->len;
13093 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
13094 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
13095 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
13096
13097 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
13098 numsegments++;
13099
13100 while (param->len) {
13101 if (param->len > MAX_WMI_QVIT_LEN)
13102 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
13103 else
13104 chunk_len = param->len;
13105
13106 buf = wmi_buf_alloc(wmi_handle,
13107 (chunk_len + sizeof(seghdrinfo) +
13108 WMI_TLV_HDR_SIZE));
13109 if (!buf) {
13110 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13111 return QDF_STATUS_E_NOMEM;
13112 }
13113
13114 cmd = (uint8_t *) wmi_buf_data(buf);
13115
13116 seghdrinfo.len = total_bytes;
13117 seghdrinfo.msgref = msgref;
13118 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
13119 seghdrinfo.segmentInfo = seginfo;
13120
13121 segnumber++;
13122
13123 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
13124 (chunk_len + sizeof(seghdrinfo)));
13125 cmd += WMI_TLV_HDR_SIZE;
13126 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
13127 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
13128
13129 ret = wmi_unified_cmd_send(wmi_handle, buf,
13130 (chunk_len + sizeof(seghdrinfo) +
13131 WMI_TLV_HDR_SIZE),
13132 WMI_PDEV_QVIT_CMDID);
13133
13134 if (ret != 0) {
13135 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
13136 wmi_buf_free(buf);
13137 break;
13138 }
13139
13140 param->len -= chunk_len;
13141 bufpos += chunk_len;
13142 }
13143 msgref++;
13144
13145 return ret;
13146}
13147
13148/**
13149 * send_wmm_update_cmd_tlv() - send wmm update command to fw
13150 * @wmi_handle: wmi handle
13151 * @param: pointer to wmm update param
13152 *
13153 * Return: 0 for success or error code
13154 */
13155static QDF_STATUS
13156send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
13157 struct wmm_update_params *param)
13158{
13159 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
13160 wmi_wmm_params *wmm_param;
13161 wmi_buf_t buf;
13162 QDF_STATUS ret;
13163 int32_t len;
13164 int ac = 0;
13165 struct wmi_host_wmeParams *wmep;
13166 uint8_t *buf_ptr;
13167
13168 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
13169 buf = wmi_buf_alloc(wmi_handle, len);
13170 if (!buf) {
13171 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13172 return QDF_STATUS_E_FAILURE;
13173 }
13174
13175 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13176 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
13177 WMITLV_SET_HDR(&cmd->tlv_header,
13178 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
13179 WMITLV_GET_STRUCT_TLVLEN
13180 (wmi_pdev_set_wmm_params_cmd_fixed_param));
13181
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013182 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013183
13184 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
13185
13186 for (ac = 0; ac < WME_NUM_AC; ac++) {
13187 wmep = &param->wmep_array[ac];
13188 wmm_param = (wmi_wmm_params *)buf_ptr;
13189 WMITLV_SET_HDR(&wmm_param->tlv_header,
13190 WMITLV_TAG_STRUC_wmi_wmm_params,
13191 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
13192 wmm_param->aifs = wmep->wmep_aifsn;
13193 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
13194 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
13195 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
13196 wmm_param->acm = wmep->wmep_acm;
13197 wmm_param->no_ack = wmep->wmep_noackPolicy;
13198 buf_ptr += sizeof(wmi_wmm_params);
13199 }
13200 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13201 WMI_PDEV_SET_WMM_PARAMS_CMDID);
13202
13203 if (ret != 0) {
13204 WMI_LOGE("Sending WMM update CMD failed\n");
13205 wmi_buf_free(buf);
13206 }
13207
13208 return ret;
13209}
13210
Sathish Kumar80f4f382017-04-24 11:36:00 +053013211/**
13212 * send_coex_config_cmd_tlv() - send coex config command to fw
13213 * @wmi_handle: wmi handle
13214 * @param: pointer to coex config param
13215 *
13216 * Return: 0 for success or error code
13217 */
13218static QDF_STATUS
13219send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
13220 struct coex_config_params *param)
13221{
13222 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
13223 wmi_buf_t buf;
13224 QDF_STATUS ret;
13225 int32_t len;
13226
13227 len = sizeof(*cmd);
13228 buf = wmi_buf_alloc(wmi_handle, len);
13229 if (!buf) {
13230 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13231 return QDF_STATUS_E_FAILURE;
13232 }
13233
13234 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
13235 WMITLV_SET_HDR(&cmd->tlv_header,
13236 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
13237 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053013238 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053013239
13240 cmd->vdev_id = param->vdev_id;
13241 cmd->config_type = param->config_type;
13242 cmd->config_arg1 = param->config_arg1;
13243 cmd->config_arg2 = param->config_arg2;
13244 cmd->config_arg3 = param->config_arg3;
13245 cmd->config_arg4 = param->config_arg4;
13246 cmd->config_arg5 = param->config_arg5;
13247 cmd->config_arg6 = param->config_arg6;
13248
13249 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13250 WMI_COEX_CONFIG_CMDID);
13251
13252 if (ret != 0) {
13253 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
13254 wmi_buf_free(buf);
13255 }
13256
13257 return ret;
13258}
13259
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013260static
Govind Singh9ddd5162016-03-07 16:30:32 +053013261void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053013262 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053013263{
Govind Singhe7f2f342016-05-23 12:12:52 +053013264 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053013265 resource_cfg->num_peers = tgt_res_cfg->num_peers;
13266 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
13267 resource_cfg->num_offload_reorder_buffs =
13268 tgt_res_cfg->num_offload_reorder_buffs;
13269 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
13270 resource_cfg->num_tids = tgt_res_cfg->num_tids;
13271 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
13272 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
13273 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
13274 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
13275 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
13276 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
13277 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
13278 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
13279 resource_cfg->scan_max_pending_req =
13280 tgt_res_cfg->scan_max_pending_req;
13281 resource_cfg->bmiss_offload_max_vdev =
13282 tgt_res_cfg->bmiss_offload_max_vdev;
13283 resource_cfg->roam_offload_max_vdev =
13284 tgt_res_cfg->roam_offload_max_vdev;
13285 resource_cfg->roam_offload_max_ap_profiles =
13286 tgt_res_cfg->roam_offload_max_ap_profiles;
13287 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
13288 resource_cfg->num_mcast_table_elems =
13289 tgt_res_cfg->num_mcast_table_elems;
13290 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
13291 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
13292 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
13293 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
13294 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
13295 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
13296 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
13297 resource_cfg->vow_config = tgt_res_cfg->vow_config;
13298 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
13299 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
13300 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
13301 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
13302 resource_cfg->num_tdls_conn_table_entries =
13303 tgt_res_cfg->num_tdls_conn_table_entries;
13304 resource_cfg->beacon_tx_offload_max_vdev =
13305 tgt_res_cfg->beacon_tx_offload_max_vdev;
13306 resource_cfg->num_multicast_filter_entries =
13307 tgt_res_cfg->num_multicast_filter_entries;
13308 resource_cfg->num_wow_filters =
13309 tgt_res_cfg->num_wow_filters;
13310 resource_cfg->num_keep_alive_pattern =
13311 tgt_res_cfg->num_keep_alive_pattern;
13312 resource_cfg->keep_alive_pattern_size =
13313 tgt_res_cfg->keep_alive_pattern_size;
13314 resource_cfg->max_tdls_concurrent_sleep_sta =
13315 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
13316 resource_cfg->max_tdls_concurrent_buffer_sta =
13317 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
13318 resource_cfg->wmi_send_separate =
13319 tgt_res_cfg->wmi_send_separate;
13320 resource_cfg->num_ocb_vdevs =
13321 tgt_res_cfg->num_ocb_vdevs;
13322 resource_cfg->num_ocb_channels =
13323 tgt_res_cfg->num_ocb_channels;
13324 resource_cfg->num_ocb_schedules =
13325 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013326 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
13327 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
13328 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013329 resource_cfg->max_num_dbs_scan_duty_cycle =
13330 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080013331 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053013332
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013333 if (tgt_res_cfg->atf_config)
13334 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
13335 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
13336 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
13337 resource_cfg->flag1, 1);
13338 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
13339 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
13340 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053013341 if (tgt_res_cfg->cce_disable)
13342 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Govind Singh9ddd5162016-03-07 16:30:32 +053013343}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013344
13345/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13346 * @wmi_handle: pointer to wmi handle
13347 * @buf_ptr: pointer to current position in init command buffer
13348 * @len: pointer to length. This will be updated with current lenght of cmd
13349 * @param: point host parameters for init command
13350 *
13351 * Return: Updated pointer of buf_ptr.
13352 */
13353static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
13354 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
13355{
13356 uint16_t idx;
13357
13358 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13359 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13360 wmi_pdev_band_to_mac *band_to_mac;
13361
13362 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13363 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13364 sizeof(wmi_resource_config) +
13365 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13366 sizeof(wlan_host_memory_chunk)));
13367
13368 WMITLV_SET_HDR(&hw_mode->tlv_header,
13369 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13370 (WMITLV_GET_STRUCT_TLVLEN
13371 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13372
13373 hw_mode->hw_mode_index = param->hw_mode_id;
13374 hw_mode->num_band_to_mac = param->num_band_to_mac;
13375
13376 buf_ptr = (uint8_t *) (hw_mode + 1);
13377 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13378 WMI_TLV_HDR_SIZE);
13379 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13380 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13381 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13382 WMITLV_GET_STRUCT_TLVLEN
13383 (wmi_pdev_band_to_mac));
13384 band_to_mac[idx].pdev_id =
13385 wmi_handle->ops->convert_pdev_id_host_to_target(
13386 param->band_to_mac[idx].pdev_id);
13387 band_to_mac[idx].start_freq =
13388 param->band_to_mac[idx].start_freq;
13389 band_to_mac[idx].end_freq =
13390 param->band_to_mac[idx].end_freq;
13391 }
13392 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13393 (param->num_band_to_mac *
13394 sizeof(wmi_pdev_band_to_mac)) +
13395 WMI_TLV_HDR_SIZE;
13396
13397 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13398 (param->num_band_to_mac *
13399 sizeof(wmi_pdev_band_to_mac)));
13400 }
13401
13402 return buf_ptr;
13403}
13404
13405static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
13406 wmi_init_cmd_fixed_param *cmd)
13407{
13408 int num_whitelist;
13409 wmi_abi_version my_vers;
13410
13411 num_whitelist = sizeof(version_whitelist) /
13412 sizeof(wmi_whitelist_version_info);
13413 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
13414 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
13415 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
13416 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13417 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13418 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13419
13420 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13421 &my_vers,
13422 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13423 &cmd->host_abi_vers);
13424
13425 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13426 __func__,
13427 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13428 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13429 cmd->host_abi_vers.abi_version_ns_0,
13430 cmd->host_abi_vers.abi_version_ns_1,
13431 cmd->host_abi_vers.abi_version_ns_2,
13432 cmd->host_abi_vers.abi_version_ns_3);
13433
13434 /* Save version sent from host -
13435 * Will be used to check ready event
13436 */
13437 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13438 sizeof(wmi_abi_version));
13439}
13440
Sathish Kumarfd347372017-02-13 12:29:09 +053013441static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053013442{
13443 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13444 wmi_service_ready_event_fixed_param *ev;
13445
13446
13447 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13448
13449 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13450 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053013451 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013452
13453 /*Save fw version from service ready message */
13454 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053013455 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013456 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013457
Govind Singhb53420c2016-03-09 14:32:57 +053013458 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013459}
13460
13461/**
13462 * wmi_unified_save_fw_version_cmd() - save fw version
13463 * @wmi_handle: pointer to wmi handle
13464 * @res_cfg: resource config
13465 * @num_mem_chunks: no of mem chunck
13466 * @mem_chunk: pointer to mem chunck structure
13467 *
13468 * This function sends IE information to firmware
13469 *
Govind Singhb53420c2016-03-09 14:32:57 +053013470 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053013471 *
13472 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013473static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053013474 void *evt_buf)
13475{
13476 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13477 wmi_ready_event_fixed_param *ev = NULL;
13478
13479 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13480 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013481 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
13482 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013483 &ev->fw_abi_vers)) {
13484 /*
13485 * Error: Our host version and the given firmware version
13486 * are incompatible.
13487 **/
Govind Singhb53420c2016-03-09 14:32:57 +053013488 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053013489 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
13490 __func__,
13491 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
13492 abi_version_0),
13493 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
13494 abi_version_0),
13495 wmi_handle->final_abi_vers.abi_version_ns_0,
13496 wmi_handle->final_abi_vers.abi_version_ns_1,
13497 wmi_handle->final_abi_vers.abi_version_ns_2,
13498 wmi_handle->final_abi_vers.abi_version_ns_3,
13499 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
13500 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
13501 ev->fw_abi_vers.abi_version_ns_0,
13502 ev->fw_abi_vers.abi_version_ns_1,
13503 ev->fw_abi_vers.abi_version_ns_2,
13504 ev->fw_abi_vers.abi_version_ns_3);
13505
Govind Singhb53420c2016-03-09 14:32:57 +053013506 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013507 }
Govind Singhb53420c2016-03-09 14:32:57 +053013508 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013509 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053013510 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013511 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053013512
Govind Singhb53420c2016-03-09 14:32:57 +053013513 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013514}
Govind Singha4836fd2016-03-07 16:45:38 +053013515
13516/**
13517 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
13518 * @wmi_handle: wmi handle
13519 * @custom_addr: base mac address
13520 *
Govind Singhe7f2f342016-05-23 12:12:52 +053013521 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053013522 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013523static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013524 uint8_t *custom_addr)
13525{
13526 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
13527 wmi_buf_t buf;
13528 int err;
13529
13530 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13531 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013532 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053013533 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013534 }
13535
13536 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013537 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053013538
13539 WMITLV_SET_HDR(&cmd->tlv_header,
13540 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
13541 WMITLV_GET_STRUCT_TLVLEN
13542 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
13543 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013544 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13545 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013546 err = wmi_unified_cmd_send(wmi_handle, buf,
13547 sizeof(*cmd),
13548 WMI_PDEV_SET_BASE_MACADDR_CMDID);
13549 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053013550 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053013551 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013552 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013553 }
13554
13555 return 0;
13556}
13557
13558/**
13559 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
13560 * @handle: wmi handle
13561 * @event: Event received from FW
13562 * @len: Length of the event
13563 *
13564 * Enables the low frequency events and disables the high frequency
13565 * events. Bit 17 indicates if the event if low/high frequency.
13566 * 1 - high frequency, 0 - low frequency
13567 *
13568 * Return: 0 on successfully enabling/disabling the events
13569 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013570static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013571 uint8_t *event,
13572 uint32_t len)
13573{
13574 uint32_t num_of_diag_events_logs;
13575 wmi_diag_event_log_config_fixed_param *cmd;
13576 wmi_buf_t buf;
13577 uint8_t *buf_ptr;
13578 uint32_t *cmd_args, *evt_args;
13579 uint32_t buf_len, i;
13580
13581 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
13582 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
13583
Govind Singhb53420c2016-03-09 14:32:57 +053013584 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053013585
13586 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
13587 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013588 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053013589 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013590 }
13591 wmi_event = param_buf->fixed_param;
13592 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070013593
13594 if (num_of_diag_events_logs >
13595 param_buf->num_diag_events_logs_list) {
13596 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
13597 num_of_diag_events_logs,
13598 param_buf->num_diag_events_logs_list);
13599 return QDF_STATUS_E_INVAL;
13600 }
13601
Govind Singha4836fd2016-03-07 16:45:38 +053013602 evt_args = param_buf->diag_events_logs_list;
13603 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053013604 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013605 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053013606 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013607 }
13608
Govind Singhb53420c2016-03-09 14:32:57 +053013609 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013610 __func__, num_of_diag_events_logs);
13611
13612 /* Free any previous allocation */
13613 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053013614 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013615
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070013616 if (num_of_diag_events_logs >
13617 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
13618 WMI_LOGE("%s: excess num of logs:%d", __func__,
13619 num_of_diag_events_logs);
13620 QDF_ASSERT(0);
13621 return QDF_STATUS_E_INVAL;
13622 }
Govind Singha4836fd2016-03-07 16:45:38 +053013623 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053013624 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053013625 sizeof(uint32_t));
13626 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013627 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013628 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013629 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013630 }
13631 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
13632
13633 /* Prepare the send buffer */
13634 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13635 (num_of_diag_events_logs * sizeof(uint32_t));
13636
13637 buf = wmi_buf_alloc(wmi_handle, buf_len);
13638 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013639 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13640 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013641 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013642 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013643 }
13644
13645 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13646 buf_ptr = (uint8_t *) cmd;
13647
13648 WMITLV_SET_HDR(&cmd->tlv_header,
13649 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13650 WMITLV_GET_STRUCT_TLVLEN(
13651 wmi_diag_event_log_config_fixed_param));
13652
13653 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13654
13655 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13656
13657 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13658 (num_of_diag_events_logs * sizeof(uint32_t)));
13659
13660 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13661
13662 /* Populate the events */
13663 for (i = 0; i < num_of_diag_events_logs; i++) {
13664 /* Low freq (0) - Enable (1) the event
13665 * High freq (1) - Disable (0) the event
13666 */
13667 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13668 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13669 /* Set the event ID */
13670 WMI_DIAG_ID_SET(cmd_args[i],
13671 WMI_DIAG_ID_GET(evt_args[i]));
13672 /* Set the type */
13673 WMI_DIAG_TYPE_SET(cmd_args[i],
13674 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013675 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013676 wmi_handle->events_logs_list[i] = evt_args[i];
13677 }
13678
13679 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13680 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013681 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013682 __func__);
13683 wmi_buf_free(buf);
13684 /* Not clearing events_logs_list, though wmi cmd failed.
13685 * Host can still have this list
13686 */
Govind Singh67922e82016-04-01 16:48:57 +053013687 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013688 }
13689
13690 return 0;
13691}
13692
13693/**
13694 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13695 * @wmi_handle: wmi handle
13696 * @start_log: Start logging related parameters
13697 *
13698 * Send the command to the FW based on which specific logging of diag
13699 * event/log id can be started/stopped
13700 *
13701 * Return: None
13702 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013703static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013704 struct wmi_wifi_start_log *start_log)
13705{
13706 wmi_diag_event_log_config_fixed_param *cmd;
13707 wmi_buf_t buf;
13708 uint8_t *buf_ptr;
13709 uint32_t len, count, log_level, i;
13710 uint32_t *cmd_args;
13711 uint32_t total_len;
13712 count = 0;
13713
13714 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013715 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013716 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013717 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013718 }
13719 /* total_len stores the number of events where BITS 17 and 18 are set.
13720 * i.e., events of high frequency (17) and for extended debugging (18)
13721 */
13722 total_len = 0;
13723 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13724 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13725 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13726 total_len++;
13727 }
13728
13729 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13730 (total_len * sizeof(uint32_t));
13731
13732 buf = wmi_buf_alloc(wmi_handle, len);
13733 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013734 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013735 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013736 }
13737 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13738 buf_ptr = (uint8_t *) cmd;
13739
13740 WMITLV_SET_HDR(&cmd->tlv_header,
13741 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13742 WMITLV_GET_STRUCT_TLVLEN(
13743 wmi_diag_event_log_config_fixed_param));
13744
13745 cmd->num_of_diag_events_logs = total_len;
13746
13747 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13748
13749 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13750 (total_len * sizeof(uint32_t)));
13751
13752 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13753
Govind Singh224a7312016-06-21 14:33:26 +053013754 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013755 log_level = 1;
13756 else
13757 log_level = 0;
13758
Govind Singhb53420c2016-03-09 14:32:57 +053013759 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013760 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13761 uint32_t val = wmi_handle->events_logs_list[i];
13762 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13763 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13764
13765 WMI_DIAG_ID_SET(cmd_args[count],
13766 WMI_DIAG_ID_GET(val));
13767 WMI_DIAG_TYPE_SET(cmd_args[count],
13768 WMI_DIAG_TYPE_GET(val));
13769 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13770 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013771 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013772 count++;
13773 }
13774 }
13775
13776 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13777 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013778 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013779 __func__);
13780 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013781 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013782 }
13783
Govind Singhb53420c2016-03-09 14:32:57 +053013784 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013785}
13786
13787/**
13788 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13789 * @wmi_handle: WMI handle
13790 *
13791 * This function is used to send the flush command to the FW,
13792 * that will flush the fw logs that are residue in the FW
13793 *
13794 * Return: None
13795 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013796static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013797{
13798 wmi_debug_mesg_flush_fixed_param *cmd;
13799 wmi_buf_t buf;
13800 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013801 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013802
13803 buf = wmi_buf_alloc(wmi_handle, len);
13804 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013805 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013806 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013807 }
13808
13809 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13810 WMITLV_SET_HDR(&cmd->tlv_header,
13811 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13812 WMITLV_GET_STRUCT_TLVLEN(
13813 wmi_debug_mesg_flush_fixed_param));
13814 cmd->reserved0 = 0;
13815
13816 ret = wmi_unified_cmd_send(wmi_handle,
13817 buf,
13818 len,
13819 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013820 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013821 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013822 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013823 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013824 }
Govind Singhb53420c2016-03-09 14:32:57 +053013825 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013826
Govind Singh67922e82016-04-01 16:48:57 +053013827 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013828}
13829
13830/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013831 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013832 * @wmi_handle: wmi handle
13833 * @msg: PCL structure containing the PCL and the number of channels
13834 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013835 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013836 * firmware. The DBS Manager is the consumer of this information in the WLAN
13837 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13838 * to migrate to a new channel without host driver involvement. An example of
13839 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13840 * manage the channel selection without firmware involvement.
13841 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013842 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13843 * channel list. The weights corresponds to the channels sent in
13844 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13845 * weightage compared to the non PCL channels.
13846 *
Govind Singha4836fd2016-03-07 16:45:38 +053013847 * Return: Success if the cmd is sent successfully to the firmware
13848 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013849static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013850 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013851{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013852 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013853 wmi_buf_t buf;
13854 uint8_t *buf_ptr;
13855 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013856 uint32_t chan_len;
13857
13858 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013859
13860 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013861 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013862
13863 buf = wmi_buf_alloc(wmi_handle, len);
13864 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013865 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13866 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013867 }
13868
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013869 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013870 buf_ptr = (uint8_t *) cmd;
13871 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013872 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13873 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013874
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013875 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13876 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013877 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013878 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013879
13880 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013881 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013882 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013883 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013884 for (i = 0; i < chan_len ; i++) {
13885 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013886 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013887 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013888 }
13889 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013890 WMI_PDEV_SET_PCL_CMDID)) {
13891 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013892 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013893 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013894 }
Govind Singhb53420c2016-03-09 14:32:57 +053013895 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013896}
13897
13898/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013899 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013900 * @wmi_handle: wmi handle
13901 * @msg: Structure containing the following parameters
13902 *
13903 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13904 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13905 *
13906 * Provides notification to the WLAN firmware that host driver is requesting a
13907 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13908 * configurations that include the Dual Band Simultaneous (DBS) feature.
13909 *
13910 * Return: Success if the cmd is sent successfully to the firmware
13911 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013912static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013913 uint32_t hw_mode_index)
13914{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013915 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013916 wmi_buf_t buf;
13917 uint32_t len;
13918
13919 len = sizeof(*cmd);
13920
13921 buf = wmi_buf_alloc(wmi_handle, len);
13922 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013923 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13924 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013925 }
13926
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013927 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013928 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013929 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13930 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13931
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013932 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13933 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013934 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013935 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013936
13937 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013938 WMI_PDEV_SET_HW_MODE_CMDID)) {
13939 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013940 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013941 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013942 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013943 }
13944
Govind Singhb53420c2016-03-09 14:32:57 +053013945 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013946}
13947
13948/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013949 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013950 * @wmi_handle: wmi handle
13951 * @msg: Dual MAC config parameters
13952 *
13953 * Configures WLAN firmware with the dual MAC features
13954 *
Govind Singhb53420c2016-03-09 14:32:57 +053013955 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013956 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013957static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013958QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013959 struct wmi_dual_mac_config *msg)
13960{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013961 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013962 wmi_buf_t buf;
13963 uint32_t len;
13964
13965 len = sizeof(*cmd);
13966
13967 buf = wmi_buf_alloc(wmi_handle, len);
13968 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013969 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13970 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013971 }
13972
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013973 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013974 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013975 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013976 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013977 wmi_pdev_set_mac_config_cmd_fixed_param));
13978
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013979 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13980 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013981 cmd->concurrent_scan_config_bits = msg->scan_config;
13982 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013983 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013984 __func__, msg->scan_config, msg->fw_mode_config);
13985
13986 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013987 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13988 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013989 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013990 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013991 }
Govind Singhb53420c2016-03-09 14:32:57 +053013992 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013993}
13994
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013995#ifdef BIG_ENDIAN_HOST
13996/**
13997* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13998* @param data_len - data length
13999* @param data - pointer to data
14000*
14001* Return: QDF_STATUS - success or error status
14002*/
14003static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14004 struct fips_params *param)
14005{
14006 unsigned char *key_unaligned, *data_unaligned;
14007 int c;
14008 u_int8_t *key_aligned = NULL;
14009 u_int8_t *data_aligned = NULL;
14010
14011 /* Assigning unaligned space to copy the key */
14012 key_unaligned = qdf_mem_malloc(
14013 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
14014 data_unaligned = qdf_mem_malloc(
14015 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
14016
14017 /* Checking if kmalloc is succesful to allocate space */
14018 if (key_unaligned == NULL)
14019 return QDF_STATUS_SUCCESS;
14020 /* Checking if space is aligned */
14021 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
14022 /* align to 4 */
14023 key_aligned =
14024 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
14025 FIPS_ALIGN);
14026 } else {
14027 key_aligned = (u_int8_t *)key_unaligned;
14028 }
14029
14030 /* memset and copy content from key to key aligned */
14031 OS_MEMSET(key_aligned, 0, param->key_len);
14032 OS_MEMCPY(key_aligned, param->key, param->key_len);
14033
14034 /* print a hexdump for host debug */
14035 print_hex_dump(KERN_DEBUG,
14036 "\t Aligned and Copied Key:@@@@ ",
14037 DUMP_PREFIX_NONE,
14038 16, 1, key_aligned, param->key_len, true);
14039
14040 /* Checking if kmalloc is succesful to allocate space */
14041 if (data_unaligned == NULL)
14042 return QDF_STATUS_SUCCESS;
14043 /* Checking of space is aligned */
14044 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
14045 /* align to 4 */
14046 data_aligned =
14047 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
14048 FIPS_ALIGN);
14049 } else {
14050 data_aligned = (u_int8_t *)data_unaligned;
14051 }
14052
14053 /* memset and copy content from data to data aligned */
14054 OS_MEMSET(data_aligned, 0, param->data_len);
14055 OS_MEMCPY(data_aligned, param->data, param->data_len);
14056
14057 /* print a hexdump for host debug */
14058 print_hex_dump(KERN_DEBUG,
14059 "\t Properly Aligned and Copied Data:@@@@ ",
14060 DUMP_PREFIX_NONE,
14061 16, 1, data_aligned, param->data_len, true);
14062
14063 /* converting to little Endian both key_aligned and
14064 * data_aligned*/
14065 for (c = 0; c < param->key_len/4; c++) {
14066 *((u_int32_t *)key_aligned+c) =
14067 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
14068 }
14069 for (c = 0; c < param->data_len/4; c++) {
14070 *((u_int32_t *)data_aligned+c) =
14071 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
14072 }
14073
14074 /* update endian data to key and data vectors */
14075 OS_MEMCPY(param->key, key_aligned, param->key_len);
14076 OS_MEMCPY(param->data, data_aligned, param->data_len);
14077
14078 /* clean up allocated spaces */
14079 qdf_mem_free(key_unaligned);
14080 key_unaligned = NULL;
14081 key_aligned = NULL;
14082
14083 qdf_mem_free(data_unaligned);
14084 data_unaligned = NULL;
14085 data_aligned = NULL;
14086
14087 return QDF_STATUS_SUCCESS;
14088}
14089#else
14090/**
14091* fips_align_data_be() - DUMMY for LE platform
14092*
14093* Return: QDF_STATUS - success
14094*/
14095static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14096 struct fips_params *param)
14097{
14098 return QDF_STATUS_SUCCESS;
14099}
14100#endif
14101
14102
14103/**
14104 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
14105 * @wmi_handle: wmi handle
14106 * @param: pointer to hold pdev fips param
14107 *
14108 * Return: 0 for success or error code
14109 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014110static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014111send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
14112 struct fips_params *param)
14113{
14114 wmi_pdev_fips_cmd_fixed_param *cmd;
14115 wmi_buf_t buf;
14116 uint8_t *buf_ptr;
14117 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
14118 QDF_STATUS retval = QDF_STATUS_SUCCESS;
14119
14120 /* Length TLV placeholder for array of bytes */
14121 len += WMI_TLV_HDR_SIZE;
14122 if (param->data_len)
14123 len += (param->data_len*sizeof(uint8_t));
14124
14125 /*
14126 * Data length must be multiples of 16 bytes - checked against 0xF -
14127 * and must be less than WMI_SVC_MSG_SIZE - static size of
14128 * wmi_pdev_fips_cmd structure
14129 */
14130
14131 /* do sanity on the input */
14132 if (!(((param->data_len & 0xF) == 0) &&
14133 ((param->data_len > 0) &&
14134 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
14135 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
14136 return QDF_STATUS_E_INVAL;
14137 }
14138
14139 buf = wmi_buf_alloc(wmi_handle, len);
14140 if (!buf) {
14141 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
14142 return QDF_STATUS_E_FAILURE;
14143 }
14144
14145 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14146 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
14147 WMITLV_SET_HDR(&cmd->tlv_header,
14148 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
14149 WMITLV_GET_STRUCT_TLVLEN
14150 (wmi_pdev_fips_cmd_fixed_param));
14151
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014152 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14153 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014154 if (param->key != NULL && param->data != NULL) {
14155 cmd->key_len = param->key_len;
14156 cmd->data_len = param->data_len;
14157 cmd->fips_cmd = !!(param->op);
14158
14159 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
14160 return QDF_STATUS_E_FAILURE;
14161
14162 qdf_mem_copy(cmd->key, param->key, param->key_len);
14163
14164 if (param->mode == FIPS_ENGINE_AES_CTR ||
14165 param->mode == FIPS_ENGINE_AES_MIC) {
14166 cmd->mode = param->mode;
14167 } else {
14168 cmd->mode = FIPS_ENGINE_AES_CTR;
14169 }
14170 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
14171 cmd->key_len, cmd->data_len);
14172
14173 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
14174 cmd->key, cmd->key_len, true);
14175 buf_ptr += sizeof(*cmd);
14176
14177 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
14178
14179 buf_ptr += WMI_TLV_HDR_SIZE;
14180 if (param->data_len)
14181 qdf_mem_copy(buf_ptr,
14182 (uint8_t *) param->data, param->data_len);
14183
14184 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
14185 16, 1, buf_ptr, cmd->data_len, true);
14186
14187 buf_ptr += param->data_len;
14188
14189 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
14190 WMI_PDEV_FIPS_CMDID);
14191 qdf_print("%s return value %d\n", __func__, retval);
14192 } else {
14193 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
14194 wmi_buf_free(buf);
14195 retval = -QDF_STATUS_E_BADMSG;
14196 }
14197
14198 return retval;
14199}
14200
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014201#ifdef WLAN_PMO_ENABLE
14202/**
14203 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
14204 * @wmi_handle: wmi handle
14205 * @vdev_id: vdev id
14206 * @bitmap: Event bitmap
14207 * @enable: enable/disable
14208 *
14209 * Return: CDF status
14210 */
14211static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
14212 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014213 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014214 bool enable)
14215{
14216 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
14217 uint16_t len;
14218 wmi_buf_t buf;
14219 int ret;
14220
14221 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
14222 buf = wmi_buf_alloc(wmi_handle, len);
14223 if (!buf) {
14224 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14225 return QDF_STATUS_E_NOMEM;
14226 }
14227 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
14228 WMITLV_SET_HDR(&cmd->tlv_header,
14229 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
14230 WMITLV_GET_STRUCT_TLVLEN
14231 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
14232 cmd->vdev_id = vdev_id;
14233 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014234 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
14235 WMI_WOW_MAX_EVENT_BM_LEN);
14236
14237 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
14238 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
14239 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014240
14241 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14242 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
14243 if (ret) {
14244 WMI_LOGE("Failed to config wow wakeup event");
14245 wmi_buf_free(buf);
14246 return QDF_STATUS_E_FAILURE;
14247 }
14248
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014249 return QDF_STATUS_SUCCESS;
14250}
14251
14252/**
14253 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
14254 * @wmi_handle: wmi handle
14255 * @vdev_id: vdev id
14256 * @ptrn_id: pattern id
14257 * @ptrn: pattern
14258 * @ptrn_len: pattern length
14259 * @ptrn_offset: pattern offset
14260 * @mask: mask
14261 * @mask_len: mask length
14262 * @user: true for user configured pattern and false for default pattern
14263 * @default_patterns: default patterns
14264 *
14265 * Return: CDF status
14266 */
14267static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
14268 uint8_t vdev_id, uint8_t ptrn_id,
14269 const uint8_t *ptrn, uint8_t ptrn_len,
14270 uint8_t ptrn_offset, const uint8_t *mask,
14271 uint8_t mask_len, bool user,
14272 uint8_t default_patterns)
14273{
14274 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14275 WOW_BITMAP_PATTERN_T *bitmap_pattern;
14276 wmi_buf_t buf;
14277 uint8_t *buf_ptr;
14278 int32_t len;
14279 int ret;
14280
14281 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14282 WMI_TLV_HDR_SIZE +
14283 1 * sizeof(WOW_BITMAP_PATTERN_T) +
14284 WMI_TLV_HDR_SIZE +
14285 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14286 WMI_TLV_HDR_SIZE +
14287 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14288 WMI_TLV_HDR_SIZE +
14289 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14290 WMI_TLV_HDR_SIZE +
14291 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
14292
14293 buf = wmi_buf_alloc(wmi_handle, len);
14294 if (!buf) {
14295 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14296 return QDF_STATUS_E_NOMEM;
14297 }
14298
14299 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14300 buf_ptr = (uint8_t *) cmd;
14301
14302 WMITLV_SET_HDR(&cmd->tlv_header,
14303 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14304 WMITLV_GET_STRUCT_TLVLEN
14305 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14306 cmd->vdev_id = vdev_id;
14307 cmd->pattern_id = ptrn_id;
14308
14309 cmd->pattern_type = WOW_BITMAP_PATTERN;
14310 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14311
14312 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14313 sizeof(WOW_BITMAP_PATTERN_T));
14314 buf_ptr += WMI_TLV_HDR_SIZE;
14315 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
14316
14317 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
14318 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
14319 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
14320
14321 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
14322 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
14323
14324 bitmap_pattern->pattern_offset = ptrn_offset;
14325 bitmap_pattern->pattern_len = ptrn_len;
14326
14327 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
14328 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
14329
14330 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
14331 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
14332
14333 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
14334 bitmap_pattern->pattern_id = ptrn_id;
14335
14336 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
14337 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
14338 bitmap_pattern->pattern_offset, user);
14339 WMI_LOGI("Pattern : ");
14340 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14341 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
14342
14343 WMI_LOGI("Mask : ");
14344 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14345 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
14346
14347 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
14348
14349 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14350 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14351 buf_ptr += WMI_TLV_HDR_SIZE;
14352
14353 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14354 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14355 buf_ptr += WMI_TLV_HDR_SIZE;
14356
14357 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14359 buf_ptr += WMI_TLV_HDR_SIZE;
14360
14361 /* Fill TLV for pattern_info_timeout but no data. */
14362 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14363 buf_ptr += WMI_TLV_HDR_SIZE;
14364
14365 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
14366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
14367 buf_ptr += WMI_TLV_HDR_SIZE;
14368 *(A_UINT32 *) buf_ptr = 0;
14369
14370 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14371 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14372 if (ret) {
14373 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
14374 wmi_buf_free(buf);
14375 return QDF_STATUS_E_FAILURE;
14376 }
14377
14378 return QDF_STATUS_SUCCESS;
14379}
14380
Govind Singha4836fd2016-03-07 16:45:38 +053014381/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014382 * fill_arp_offload_params_tlv() - Fill ARP offload data
14383 * @wmi_handle: wmi handle
14384 * @offload_req: offload request
14385 * @buf_ptr: buffer pointer
14386 *
14387 * To fill ARP offload data to firmware
14388 * when target goes to wow mode.
14389 *
14390 * Return: None
14391 */
14392static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014393 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014394{
14395
14396 int i;
14397 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014398 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014399
14400 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14401 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
14402 *buf_ptr += WMI_TLV_HDR_SIZE;
14403 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
14404 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
14405 WMITLV_SET_HDR(&arp_tuple->tlv_header,
14406 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
14407 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
14408
14409 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014410 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014411 /* Copy the target ip addr and flags */
14412 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
14413 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014414 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014415 WMI_IPV4_ADDR_LEN);
14416 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014417 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014418 }
14419 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
14420 }
14421}
14422
14423#ifdef WLAN_NS_OFFLOAD
14424/**
14425 * fill_ns_offload_params_tlv() - Fill NS offload data
14426 * @wmi|_handle: wmi handle
14427 * @offload_req: offload request
14428 * @buf_ptr: buffer pointer
14429 *
14430 * To fill NS offload data to firmware
14431 * when target goes to wow mode.
14432 *
14433 * Return: None
14434 */
14435static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014436 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014437{
14438
14439 int i;
14440 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014441
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014442 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14443 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14444 *buf_ptr += WMI_TLV_HDR_SIZE;
14445 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
14446 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14447 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14448 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14449 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
14450
14451 /*
14452 * Fill data only for NS offload in the first ARP tuple for LA
14453 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014454 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014455 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14456 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014457 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014458 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014459 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014460 sizeof(WMI_IPV6_ADDR));
14461 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014462 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014463 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014464 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014465 ns_tuple->flags |=
14466 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14467 }
14468 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014469 i, &ns_req->self_ipv6_addr[i],
14470 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014471
14472 /* target MAC is optional, check if it is valid,
14473 * if this is not valid, the target will use the known
14474 * local MAC address rather than the tuple
14475 */
14476 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014477 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014478 &ns_tuple->target_mac);
14479 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14480 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14481 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14482 }
14483 }
14484 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14485 }
14486}
14487
14488
14489/**
14490 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
14491 * @wmi: wmi handle
14492 * @offload_req: offload request
14493 * @buf_ptr: buffer pointer
14494 *
14495 * To fill extended NS offload extended data to firmware
14496 * when target goes to wow mode.
14497 *
14498 * Return: None
14499 */
14500static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014501 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014502{
14503 int i;
14504 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
14505 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014506
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014507 count = ns_req->num_ns_offload_count;
14508 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014509 WMI_MAX_NS_OFFLOADS;
14510
14511 /* Populate extended NS offload tuples */
14512 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14513 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14514 *buf_ptr += WMI_TLV_HDR_SIZE;
14515 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
14516 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14517 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14518 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14519 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
14520
14521 /*
14522 * Fill data only for NS offload in the first ARP tuple for LA
14523 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014524 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014525 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14526 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014527 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014528 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014529 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014530 sizeof(WMI_IPV6_ADDR));
14531 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014532 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014533 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014534 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014535 ns_tuple->flags |=
14536 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14537 }
14538 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014539 i, &ns_req->self_ipv6_addr[i],
14540 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014541
14542 /* target MAC is optional, check if it is valid,
14543 * if this is not valid, the target will use the
14544 * known local MAC address rather than the tuple
14545 */
14546 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014547 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014548 &ns_tuple->target_mac);
14549 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14550 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14551 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14552 }
14553 }
14554 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14555 }
14556}
14557#else
14558static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014559 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014560{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014561}
14562
14563static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014564 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014565{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014566}
14567#endif
14568
14569/**
Govind Singha4836fd2016-03-07 16:45:38 +053014570 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
14571 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014572 * @arp_offload_req: arp offload request
14573 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053014574 * @arp_only: flag
14575 *
14576 * To configure ARP NS off load data to firmware
14577 * when target goes to wow mode.
14578 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014579 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053014580 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014581static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014582 struct pmo_arp_offload_params *arp_offload_req,
14583 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053014584 uint8_t vdev_id)
14585{
Govind Singha4836fd2016-03-07 16:45:38 +053014586 int32_t res;
14587 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053014588 A_UINT8 *buf_ptr;
14589 wmi_buf_t buf;
14590 int32_t len;
14591 uint32_t count = 0, num_ns_ext_tuples = 0;
14592
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014593 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053014594
Govind Singha4836fd2016-03-07 16:45:38 +053014595 /*
14596 * TLV place holder size for array of NS tuples
14597 * TLV place holder size for array of ARP tuples
14598 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014599 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
14600 WMI_TLV_HDR_SIZE +
14601 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
14602 WMI_TLV_HDR_SIZE +
14603 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014604
14605 /*
14606 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
14607 * extra length for extended NS offload tuples which follows ARP offload
14608 * tuples. Host needs to fill this structure in following format:
14609 * 2 NS ofload tuples
14610 * 2 ARP offload tuples
14611 * N numbers of extended NS offload tuples if HDD has given more than
14612 * 2 NS offload addresses
14613 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014614 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053014615 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014616 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
14617 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014618 }
14619
14620 buf = wmi_buf_alloc(wmi_handle, len);
14621 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014622 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014623 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014624 }
14625
14626 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
14627 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
14628 WMITLV_SET_HDR(&cmd->tlv_header,
14629 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
14630 WMITLV_GET_STRUCT_TLVLEN
14631 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
14632 cmd->flags = 0;
14633 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014634 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053014635
Govind Singhb53420c2016-03-09 14:32:57 +053014636 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053014637
Govind Singha4836fd2016-03-07 16:45:38 +053014638 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014639 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
14640 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14641 if (num_ns_ext_tuples)
14642 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014643
14644 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14645 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14646 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014647 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014648 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014649 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014650 }
14651
Govind Singhb53420c2016-03-09 14:32:57 +053014652 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014653}
14654
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014655/**
14656 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14657 * @wmi_handle: wmi handle
14658 * @vdev_id: vdev id
14659 * @action: true for enable else false
14660 *
14661 * To enable enhance multicast offload to firmware
14662 * when target goes to wow mode.
14663 *
14664 * Return: QDF Status
14665 */
14666
14667static
14668QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14669 wmi_unified_t wmi_handle,
14670 uint8_t vdev_id, bool action)
14671{
14672 QDF_STATUS status;
14673 wmi_buf_t buf;
14674 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14675
14676 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14677 if (!buf) {
14678 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14679 return QDF_STATUS_E_NOMEM;
14680 }
14681
14682 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14683 wmi_buf_data(buf);
14684
14685 WMITLV_SET_HDR(&cmd->tlv_header,
14686 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14687 WMITLV_GET_STRUCT_TLVLEN(
14688 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14689
14690 cmd->vdev_id = vdev_id;
14691 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14692 ENHANCED_MCAST_FILTER_ENABLED);
14693 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14694 __func__, action, vdev_id);
14695 status = wmi_unified_cmd_send(wmi_handle, buf,
14696 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14697 if (status != QDF_STATUS_SUCCESS) {
14698 qdf_nbuf_free(buf);
14699 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14700 __func__);
14701 }
14702
14703 return status;
14704}
14705
14706/**
14707 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14708 * @wmi_handle: wmi handle
14709 * @param evt_buf: pointer to event buffer
14710 * @param hdr: Pointer to hold header
14711 * @param bufp: Pointer to hold pointer to rx param buffer
14712 *
14713 * Return: QDF_STATUS_SUCCESS for success or error code
14714 */
14715static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14716 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14717{
14718 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14719 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14720
14721 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14722 if (!param_buf) {
14723 WMI_LOGE("gtk param_buf is NULL");
14724 return QDF_STATUS_E_INVAL;
14725 }
14726
14727 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14728 WMI_LOGE("Invalid length for GTK status");
14729 return QDF_STATUS_E_INVAL;
14730 }
14731
14732 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14733 param_buf->fixed_param;
14734 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14735 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14736 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14737 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14738 &fixed_param->replay_counter,
14739 GTK_REPLAY_COUNTER_BYTES);
14740
14741 return QDF_STATUS_SUCCESS;
14742
14743}
14744
14745#ifdef FEATURE_WLAN_RA_FILTERING
14746/**
14747 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14748 * @wmi_handle: wmi handle
14749 * @vdev_id: vdev id
14750 *
14751 * Return: CDF status
14752 */
14753static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14754 uint8_t vdev_id, uint8_t default_pattern,
14755 uint16_t rate_limit_interval)
14756{
14757
14758 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14759 wmi_buf_t buf;
14760 uint8_t *buf_ptr;
14761 int32_t len;
14762 int ret;
14763
14764 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14765 WMI_TLV_HDR_SIZE +
14766 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14767 WMI_TLV_HDR_SIZE +
14768 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14769 WMI_TLV_HDR_SIZE +
14770 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14771 WMI_TLV_HDR_SIZE +
14772 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14773 WMI_TLV_HDR_SIZE +
14774 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
14775
14776 buf = wmi_buf_alloc(wmi_handle, len);
14777 if (!buf) {
14778 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14779 return QDF_STATUS_E_NOMEM;
14780 }
14781
14782 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14783 buf_ptr = (uint8_t *) cmd;
14784
14785 WMITLV_SET_HDR(&cmd->tlv_header,
14786 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14787 WMITLV_GET_STRUCT_TLVLEN
14788 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14789 cmd->vdev_id = vdev_id;
14790 cmd->pattern_id = default_pattern,
14791 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14792 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14793
14794 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14795 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14796 buf_ptr += WMI_TLV_HDR_SIZE;
14797
14798 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14799 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14800 buf_ptr += WMI_TLV_HDR_SIZE;
14801
14802 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14803 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14804 buf_ptr += WMI_TLV_HDR_SIZE;
14805
14806 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14807 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14808 buf_ptr += WMI_TLV_HDR_SIZE;
14809
14810 /* Fill TLV for pattern_info_timeout but no data. */
14811 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14812 buf_ptr += WMI_TLV_HDR_SIZE;
14813
14814 /* Fill TLV for ra_ratelimit_interval. */
14815 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
14816 buf_ptr += WMI_TLV_HDR_SIZE;
14817
14818 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
14819
14820 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14821 rate_limit_interval, vdev_id);
14822
14823 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14824 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14825 if (ret) {
14826 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14827 wmi_buf_free(buf);
14828 return QDF_STATUS_E_FAILURE;
14829 }
14830
14831 return QDF_STATUS_SUCCESS;
14832
14833}
14834#endif /* FEATURE_WLAN_RA_FILTERING */
14835
14836/**
14837 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14838 * @wmi_handle: wmi handle
14839 * @vdev_id: vdev id
14840 * @multicastAddr: mcast address
14841 * @clearList: clear list flag
14842 *
14843 * Return: QDF_STATUS_SUCCESS for success or error code
14844 */
14845static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14846 uint8_t vdev_id,
14847 struct qdf_mac_addr multicast_addr,
14848 bool clearList)
14849{
14850 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14851 wmi_buf_t buf;
14852 int err;
14853
14854 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14855 if (!buf) {
14856 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14857 return QDF_STATUS_E_NOMEM;
14858 }
14859
14860 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14861 qdf_mem_zero(cmd, sizeof(*cmd));
14862
14863 WMITLV_SET_HDR(&cmd->tlv_header,
14864 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14865 WMITLV_GET_STRUCT_TLVLEN
14866 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14867 cmd->action =
14868 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14869 cmd->vdev_id = vdev_id;
14870 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14871
14872 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14873 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14874
14875 err = wmi_unified_cmd_send(wmi_handle, buf,
14876 sizeof(*cmd),
14877 WMI_SET_MCASTBCAST_FILTER_CMDID);
14878 if (err) {
14879 WMI_LOGE("Failed to send set_param cmd");
14880 wmi_buf_free(buf);
14881 return QDF_STATUS_E_FAILURE;
14882 }
14883
14884 return QDF_STATUS_SUCCESS;
14885}
14886
14887/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014888 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14889 * command to fw
14890 * @wmi_handle: wmi handle
14891 * @vdev_id: vdev id
14892 * @mcast_filter_params: mcast filter params
14893 *
14894 * Return: QDF_STATUS_SUCCESS for success or error code
14895 */
14896static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14897 wmi_unified_t wmi_handle,
14898 uint8_t vdev_id,
14899 struct pmo_mcast_filter_params *filter_param)
14900
14901{
14902 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14903 uint8_t *buf_ptr;
14904 wmi_buf_t buf;
14905 int err;
14906 int i;
14907 uint8_t *mac_addr_src_ptr = NULL;
14908 wmi_mac_addr *mac_addr_dst_ptr;
14909 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14910 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14911
14912 buf = wmi_buf_alloc(wmi_handle, len);
14913 if (!buf) {
14914 WMI_LOGE("Failed to allocate memory");
14915 return QDF_STATUS_E_NOMEM;
14916 }
14917
14918 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
14919 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14920 wmi_buf_data(buf);
14921 qdf_mem_zero(cmd, sizeof(*cmd));
14922
14923 WMITLV_SET_HDR(&cmd->tlv_header,
14924 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14925 WMITLV_GET_STRUCT_TLVLEN
14926 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14927 cmd->operation =
14928 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14929 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14930 cmd->vdev_id = vdev_id;
14931 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14932
14933 buf_ptr += sizeof(*cmd);
14934 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14935 sizeof(wmi_mac_addr) *
14936 filter_param->multicast_addr_cnt);
14937
14938 if (filter_param->multicast_addr_cnt == 0)
14939 goto send_cmd;
14940
14941 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14942 mac_addr_dst_ptr = (wmi_mac_addr *)
14943 (buf_ptr + WMI_TLV_HDR_SIZE);
14944
14945 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14946 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14947 mac_addr_src_ptr += ATH_MAC_LEN;
14948 mac_addr_dst_ptr++;
14949 }
14950
14951send_cmd:
14952 err = wmi_unified_cmd_send(wmi_handle, buf,
14953 len,
14954 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14955 if (err) {
14956 WMI_LOGE("Failed to send set_param cmd");
14957 wmi_buf_free(buf);
14958 return QDF_STATUS_E_FAILURE;
14959 }
14960
14961 return QDF_STATUS_SUCCESS;
14962}
14963
14964
14965/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014966 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14967 * @wmi_handle: wmi handle
14968 * @vdev_id: vdev id
14969 * @params: GTK offload parameters
14970 *
14971 * Return: CDF status
14972 */
14973static
14974QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14975 struct pmo_gtk_req *params,
14976 bool enable_offload,
14977 uint32_t gtk_offload_opcode)
14978{
14979 int len;
14980 wmi_buf_t buf;
14981 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014982 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014983 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014984 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014985
14986 WMI_LOGD("%s Enter", __func__);
14987
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014988 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014989
14990 /* alloc wmi buffer */
14991 buf = wmi_buf_alloc(wmi_handle, len);
14992 if (!buf) {
14993 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14994 status = QDF_STATUS_E_NOMEM;
14995 goto out;
14996 }
14997
14998 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014999 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015000 WMITLV_SET_HDR(&cmd->tlv_header,
15001 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15002 WMITLV_GET_STRUCT_TLVLEN
15003 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15004
15005 cmd->vdev_id = vdev_id;
15006
15007 /* Request target to enable GTK offload */
15008 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
15009 cmd->flags = gtk_offload_opcode;
15010
15011 /* Copy the keys and replay counter */
15012 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015013 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015014 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
15015 GTK_REPLAY_COUNTER_BYTES);
15016 } else {
15017 cmd->flags = gtk_offload_opcode;
15018 }
15019
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015020 buf_ptr += sizeof(*cmd);
15021 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
15022 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015023
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015024 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
15025 WMITLV_SET_HDR(&ext_param->tlv_header,
15026 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
15027 WMITLV_GET_STRUCT_TLVLEN(
15028 wmi_gtk_offload_fils_tlv_param));
15029 ext_param->vdev_id = vdev_id;
15030 ext_param->flags = cmd->flags;
15031 ext_param->kek_len = params->kek_len;
15032 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
15033 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
15034 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
15035 GTK_REPLAY_COUNTER_BYTES);
15036
15037 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 +053015038 /* send the wmi command */
15039 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15040 WMI_GTK_OFFLOAD_CMDID)) {
15041 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
15042 wmi_buf_free(buf);
15043 status = QDF_STATUS_E_FAILURE;
15044 }
15045
15046out:
15047 WMI_LOGD("%s Exit", __func__);
15048 return status;
15049}
15050
15051/**
15052 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
15053 * @wmi_handle: wmi handle
15054 * @params: GTK offload params
15055 *
15056 * Return: CDF status
15057 */
15058static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
15059 wmi_unified_t wmi_handle,
15060 uint8_t vdev_id,
15061 uint64_t offload_req_opcode)
15062{
15063 int len;
15064 wmi_buf_t buf;
15065 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
15066 QDF_STATUS status = QDF_STATUS_SUCCESS;
15067
15068 len = sizeof(*cmd);
15069
15070 /* alloc wmi buffer */
15071 buf = wmi_buf_alloc(wmi_handle, len);
15072 if (!buf) {
15073 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
15074 status = QDF_STATUS_E_NOMEM;
15075 goto out;
15076 }
15077
15078 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
15079 WMITLV_SET_HDR(&cmd->tlv_header,
15080 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15081 WMITLV_GET_STRUCT_TLVLEN
15082 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15083
15084 /* Request for GTK offload status */
15085 cmd->flags = offload_req_opcode;
15086 cmd->vdev_id = vdev_id;
15087
15088 /* send the wmi command */
15089 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15090 WMI_GTK_OFFLOAD_CMDID)) {
15091 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
15092 wmi_buf_free(buf);
15093 status = QDF_STATUS_E_FAILURE;
15094 }
15095
15096out:
15097 return status;
15098}
15099
15100/**
15101 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
15102 * @wmi_handle: wmi handler
15103 * @action_params: pointer to action_params
15104 *
15105 * Return: 0 for success, otherwise appropriate error code
15106 */
15107static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
15108 struct pmo_action_wakeup_set_params *action_params)
15109{
15110 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
15111 wmi_buf_t buf;
15112 int i;
15113 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015114 uint32_t len = 0, *cmd_args;
15115 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015116
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015117 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32))
15118 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
15119 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015120 if (!buf) {
15121 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
15122 return QDF_STATUS_E_NOMEM;
15123 }
15124 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015125 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015126 WMITLV_SET_HDR(&cmd->tlv_header,
15127 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
15128 WMITLV_GET_STRUCT_TLVLEN(
15129 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
15130
15131 cmd->vdev_id = action_params->vdev_id;
15132 cmd->operation = action_params->operation;
15133
15134 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
15135 cmd->action_category_map[i] =
15136 action_params->action_category_map[i];
15137
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015138 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
15139 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15140 (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32)));
15141 buf_ptr += WMI_TLV_HDR_SIZE;
15142 cmd_args = (uint32_t *) buf_ptr;
15143 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
15144 cmd_args[i] = action_params->action_per_category[i];
15145
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015146 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015147 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015148 if (err) {
15149 WMI_LOGE("Failed to send ap_ps_egap cmd");
15150 wmi_buf_free(buf);
15151 return QDF_STATUS_E_FAILURE;
15152 }
15153
15154 return QDF_STATUS_SUCCESS;
15155}
15156
15157#ifdef FEATURE_WLAN_LPHB
15158
15159/**
15160 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
15161 * @wmi_handle: wmi handle
15162 * @lphb_conf_req: configuration info
15163 *
15164 * Return: CDF status
15165 */
15166static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
15167 wmi_hb_set_enable_cmd_fixed_param *params)
15168{
15169 QDF_STATUS status;
15170 wmi_buf_t buf = NULL;
15171 uint8_t *buf_ptr;
15172 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
15173 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
15174
15175
15176 buf = wmi_buf_alloc(wmi_handle, len);
15177 if (!buf) {
15178 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15179 return QDF_STATUS_E_NOMEM;
15180 }
15181
15182 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15183 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
15184 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
15185 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
15186 WMITLV_GET_STRUCT_TLVLEN
15187 (wmi_hb_set_enable_cmd_fixed_param));
15188
15189 /* fill in values */
15190 hb_enable_fp->vdev_id = params->session;
15191 hb_enable_fp->enable = params->enable;
15192 hb_enable_fp->item = params->item;
15193 hb_enable_fp->session = params->session;
15194
15195 status = wmi_unified_cmd_send(wmi_handle, buf,
15196 len, WMI_HB_SET_ENABLE_CMDID);
15197 if (QDF_IS_STATUS_ERROR(status)) {
15198 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
15199 status);
15200 wmi_buf_free(buf);
15201 }
15202
15203 return status;
15204}
15205
15206/**
15207 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
15208 * @wmi_handle: wmi handle
15209 * @lphb_conf_req: lphb config request
15210 *
15211 * Return: CDF status
15212 */
15213static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
15214 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
15215{
15216 QDF_STATUS status;
15217 wmi_buf_t buf = NULL;
15218 uint8_t *buf_ptr;
15219 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
15220 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
15221
15222 buf = wmi_buf_alloc(wmi_handle, len);
15223 if (!buf) {
15224 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15225 return QDF_STATUS_E_NOMEM;
15226 }
15227
15228 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15229 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
15230 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
15231 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
15232 WMITLV_GET_STRUCT_TLVLEN
15233 (wmi_hb_set_tcp_params_cmd_fixed_param));
15234
15235 /* fill in values */
15236 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15237 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15238 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15239 hb_tcp_params_fp->seq = lphb_conf_req->seq;
15240 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
15241 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
15242 hb_tcp_params_fp->interval = lphb_conf_req->interval;
15243 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
15244 hb_tcp_params_fp->session = lphb_conf_req->session;
15245 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
15246 &lphb_conf_req->gateway_mac,
15247 sizeof(hb_tcp_params_fp->gateway_mac));
15248
15249 status = wmi_unified_cmd_send(wmi_handle, buf,
15250 len, WMI_HB_SET_TCP_PARAMS_CMDID);
15251 if (QDF_IS_STATUS_ERROR(status)) {
15252 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
15253 status);
15254 wmi_buf_free(buf);
15255 }
15256
15257 return status;
15258}
15259
15260/**
15261 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
15262 * @wmi_handle: wmi handle
15263 * @lphb_conf_req: lphb config request
15264 *
15265 * Return: CDF status
15266 */
15267static
15268QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15269 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
15270{
15271 QDF_STATUS status;
15272 wmi_buf_t buf = NULL;
15273 uint8_t *buf_ptr;
15274 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
15275 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
15276
15277 buf = wmi_buf_alloc(wmi_handle, len);
15278 if (!buf) {
15279 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15280 return QDF_STATUS_E_NOMEM;
15281 }
15282
15283 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15284 hb_tcp_filter_fp =
15285 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
15286 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
15287 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
15288 WMITLV_GET_STRUCT_TLVLEN
15289 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
15290
15291 /* fill in values */
15292 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
15293 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
15294 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
15295 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
15296 memcpy((void *)&hb_tcp_filter_fp->filter,
15297 (void *)&g_hb_tcp_filter_fp->filter,
15298 WMI_WLAN_HB_MAX_FILTER_SIZE);
15299
15300 status = wmi_unified_cmd_send(wmi_handle, buf,
15301 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
15302 if (QDF_IS_STATUS_ERROR(status)) {
15303 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
15304 status);
15305 wmi_buf_free(buf);
15306 }
15307
15308 return status;
15309}
15310
15311/**
15312 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
15313 * @wmi_handle: wmi handle
15314 * @lphb_conf_req: lphb config request
15315 *
15316 * Return: CDF status
15317 */
15318static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
15319 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
15320{
15321 QDF_STATUS status;
15322 wmi_buf_t buf = NULL;
15323 uint8_t *buf_ptr;
15324 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
15325 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
15326
15327 buf = wmi_buf_alloc(wmi_handle, len);
15328 if (!buf) {
15329 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15330 return QDF_STATUS_E_NOMEM;
15331 }
15332
15333 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15334 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
15335 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
15336 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
15337 WMITLV_GET_STRUCT_TLVLEN
15338 (wmi_hb_set_udp_params_cmd_fixed_param));
15339
15340 /* fill in values */
15341 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15342 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15343 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15344 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
15345 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
15346 hb_udp_params_fp->interval = lphb_conf_req->interval;
15347 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
15348 hb_udp_params_fp->session = lphb_conf_req->session;
15349 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
15350 &lphb_conf_req->gateway_mac,
15351 sizeof(lphb_conf_req->gateway_mac));
15352
15353 status = wmi_unified_cmd_send(wmi_handle, buf,
15354 len, WMI_HB_SET_UDP_PARAMS_CMDID);
15355 if (QDF_IS_STATUS_ERROR(status)) {
15356 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
15357 status);
15358 wmi_buf_free(buf);
15359 }
15360
15361 return status;
15362}
15363
15364/**
15365 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
15366 * @wmi_handle: wmi handle
15367 * @lphb_conf_req: lphb config request
15368 *
15369 * Return: CDF status
15370 */
15371static
15372QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15373 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
15374{
15375 QDF_STATUS status;
15376 wmi_buf_t buf = NULL;
15377 uint8_t *buf_ptr;
15378 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
15379 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
15380
15381 buf = wmi_buf_alloc(wmi_handle, len);
15382 if (!buf) {
15383 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15384 return QDF_STATUS_E_NOMEM;
15385 }
15386
15387 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15388 hb_udp_filter_fp =
15389 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
15390 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
15391 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
15392 WMITLV_GET_STRUCT_TLVLEN
15393 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
15394
15395 /* fill in values */
15396 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
15397 hb_udp_filter_fp->length = lphb_conf_req->length;
15398 hb_udp_filter_fp->offset = lphb_conf_req->offset;
15399 hb_udp_filter_fp->session = lphb_conf_req->session;
15400 memcpy((void *)&hb_udp_filter_fp->filter,
15401 (void *)&lphb_conf_req->filter,
15402 WMI_WLAN_HB_MAX_FILTER_SIZE);
15403
15404 status = wmi_unified_cmd_send(wmi_handle, buf,
15405 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
15406 if (QDF_IS_STATUS_ERROR(status)) {
15407 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
15408 status);
15409 wmi_buf_free(buf);
15410 }
15411
15412 return status;
15413}
15414#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015415
Dustin Brownf31f88b2017-05-12 14:01:44 -070015416static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
15417 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015418{
Dustin Brownf31f88b2017-05-12 14:01:44 -070015419 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015420 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070015421 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015422
Dustin Brownf31f88b2017-05-12 14:01:44 -070015423 if (!req) {
15424 WMI_LOGE("req is null");
15425 return QDF_STATUS_E_INVAL;
15426 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015427
Dustin Brownf31f88b2017-05-12 14:01:44 -070015428 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
15429 if (!wmi_buf) {
15430 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015431 return QDF_STATUS_E_NOMEM;
15432 }
15433
Dustin Brownf31f88b2017-05-12 14:01:44 -070015434 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015435 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070015436 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
15437 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
15438 cmd->vdev_id = req->vdev_id;
15439 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
15440 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015441
Dustin Brownf31f88b2017-05-12 14:01:44 -070015442 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
15443 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015444
Dustin Brownf31f88b2017-05-12 14:01:44 -070015445 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
15446 WMI_HW_DATA_FILTER_CMDID);
15447 if (QDF_IS_STATUS_ERROR(status)) {
15448 WMI_LOGE("Failed to configure hw filter");
15449 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015450 }
15451
Dustin Brownf31f88b2017-05-12 14:01:44 -070015452 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015453}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015454
15455/**
15456 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
15457 * @wmi_handle: wmi handle
15458 * @vdev_id: vdev id
15459 * @enable: Flag to enable/disable packet filter
15460 *
15461 * Return: QDF_STATUS_SUCCESS for success or error code
15462 */
15463static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
15464 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
15465{
15466 int32_t len;
15467 int ret = 0;
15468 wmi_buf_t buf;
15469 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
15470
15471 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
15472
15473 buf = wmi_buf_alloc(wmi_handle, len);
15474 if (!buf) {
15475 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
15476 return QDF_STATUS_E_NOMEM;
15477 }
15478
15479 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
15480 WMITLV_SET_HDR(&cmd->tlv_header,
15481 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
15482 WMITLV_GET_STRUCT_TLVLEN(
15483 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
15484
15485 cmd->vdev_id = vdev_id;
15486 if (enable)
15487 cmd->enable = PACKET_FILTER_SET_ENABLE;
15488 else
15489 cmd->enable = PACKET_FILTER_SET_DISABLE;
15490
15491 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
15492 __func__, cmd->enable, vdev_id);
15493
15494 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15495 WMI_PACKET_FILTER_ENABLE_CMDID);
15496 if (ret) {
15497 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
15498 wmi_buf_free(buf);
15499 }
15500
15501 return ret;
15502}
15503
15504/**
15505 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
15506 * @wmi_handle: wmi handle
15507 * @vdev_id: vdev id
15508 * @rcv_filter_param: Packet filter parameters
15509 * @filter_id: Filter id
15510 * @enable: Flag to add/delete packet filter configuration
15511 *
15512 * Return: QDF_STATUS_SUCCESS for success or error code
15513 */
15514static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
15515 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
15516 uint8_t filter_id, bool enable)
15517{
15518 int len, i;
15519 int err = 0;
15520 wmi_buf_t buf;
15521 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
15522
15523
15524 /* allocate the memory */
15525 len = sizeof(*cmd);
15526 buf = wmi_buf_alloc(wmi_handle, len);
15527 if (!buf) {
15528 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
15529 return QDF_STATUS_E_NOMEM;
15530 }
15531
15532 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
15533 WMITLV_SET_HDR(&cmd->tlv_header,
15534 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
15535 WMITLV_GET_STRUCT_TLVLEN
15536 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
15537
15538 cmd->vdev_id = vdev_id;
15539 cmd->filter_id = filter_id;
15540 if (enable)
15541 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
15542 else
15543 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
15544
15545 if (enable) {
15546 cmd->num_params = QDF_MIN(
15547 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
15548 rcv_filter_param->num_params);
15549 cmd->filter_type = rcv_filter_param->filter_type;
15550 cmd->coalesce_time = rcv_filter_param->coalesce_time;
15551
15552 for (i = 0; i < cmd->num_params; i++) {
15553 cmd->paramsData[i].proto_type =
15554 rcv_filter_param->params_data[i].protocol_layer;
15555 cmd->paramsData[i].cmp_type =
15556 rcv_filter_param->params_data[i].compare_flag;
15557 cmd->paramsData[i].data_length =
15558 rcv_filter_param->params_data[i].data_length;
15559 cmd->paramsData[i].data_offset =
15560 rcv_filter_param->params_data[i].data_offset;
15561 memcpy(&cmd->paramsData[i].compareData,
15562 rcv_filter_param->params_data[i].compare_data,
15563 sizeof(cmd->paramsData[i].compareData));
15564 memcpy(&cmd->paramsData[i].dataMask,
15565 rcv_filter_param->params_data[i].data_mask,
15566 sizeof(cmd->paramsData[i].dataMask));
15567 }
15568 }
15569
15570 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
15571 cmd->filter_action, cmd->filter_id, cmd->num_params);
15572 /* send the command along with data */
15573 err = wmi_unified_cmd_send(wmi_handle, buf, len,
15574 WMI_PACKET_FILTER_CONFIG_CMDID);
15575 if (err) {
15576 WMI_LOGE("Failed to send pkt_filter cmd");
15577 wmi_buf_free(buf);
15578 return QDF_STATUS_E_FAILURE;
15579 }
15580
15581 return QDF_STATUS_SUCCESS;
15582}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053015583#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015584
Govind Singha4836fd2016-03-07 16:45:38 +053015585/**
15586 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
15587 * @wmi_handle: wmi handle
15588 * @request: SSID hotlist set request
15589 *
Govind Singhb53420c2016-03-09 14:32:57 +053015590 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053015591 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015592static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053015593send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
15594 struct ssid_hotlist_request_params *request)
15595{
15596 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
15597 wmi_buf_t wmi_buf;
15598 uint32_t len;
15599 uint32_t array_size;
15600 uint8_t *buf_ptr;
15601
15602 /* length of fixed portion */
15603 len = sizeof(*cmd);
15604
15605 /* length of variable portion */
15606 array_size =
15607 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
15608 len += WMI_TLV_HDR_SIZE + array_size;
15609
15610 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15611 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015612 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15613 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015614 }
15615
15616 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
15617 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
15618 buf_ptr;
15619 WMITLV_SET_HDR
15620 (&cmd->tlv_header,
15621 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15622 WMITLV_GET_STRUCT_TLVLEN
15623 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15624
15625 cmd->request_id = request->request_id;
15626 cmd->requestor_id = 0;
15627 cmd->vdev_id = request->session_id;
15628 cmd->table_id = 0;
15629 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15630 cmd->total_entries = request->ssid_count;
15631 cmd->num_entries_in_page = request->ssid_count;
15632 cmd->first_entry_index = 0;
15633
15634 buf_ptr += sizeof(*cmd);
15635 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15636
15637 if (request->ssid_count) {
15638 wmi_extscan_hotlist_ssid_entry *entry;
15639 int i;
15640
15641 buf_ptr += WMI_TLV_HDR_SIZE;
15642 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15643 for (i = 0; i < request->ssid_count; i++) {
15644 WMITLV_SET_HDR
15645 (entry,
15646 WMITLV_TAG_ARRAY_STRUC,
15647 WMITLV_GET_STRUCT_TLVLEN
15648 (wmi_extscan_hotlist_ssid_entry));
15649 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015650 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015651 request->ssids[i].ssid.mac_ssid,
15652 request->ssids[i].ssid.length);
15653 entry->band = request->ssids[i].band;
15654 entry->min_rssi = request->ssids[i].rssi_low;
15655 entry->max_rssi = request->ssids[i].rssi_high;
15656 entry++;
15657 }
15658 cmd->mode = WMI_EXTSCAN_MODE_START;
15659 } else {
15660 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15661 }
15662
15663 if (wmi_unified_cmd_send
15664 (wmi_handle, wmi_buf, len,
15665 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015666 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015667 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015668 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015669 }
15670
Govind Singhb53420c2016-03-09 14:32:57 +053015671 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015672}
15673
15674/**
15675 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15676 * @wmi_handle: wmi handle
15677 * @vdev_id: vdev id
15678 *
15679 * This function sends roam synch complete event to fw.
15680 *
15681 * Return: CDF STATUS
15682 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015683static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015684 uint8_t vdev_id)
15685{
15686 wmi_roam_synch_complete_fixed_param *cmd;
15687 wmi_buf_t wmi_buf;
15688 uint8_t *buf_ptr;
15689 uint16_t len;
15690 len = sizeof(wmi_roam_synch_complete_fixed_param);
15691
15692 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15693 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015694 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15695 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015696 }
15697 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15698 buf_ptr = (uint8_t *) cmd;
15699 WMITLV_SET_HDR(&cmd->tlv_header,
15700 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15701 WMITLV_GET_STRUCT_TLVLEN
15702 (wmi_roam_synch_complete_fixed_param));
15703 cmd->vdev_id = vdev_id;
15704 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15705 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015706 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015707 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015708 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015709 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015710 }
15711
Govind Singhb53420c2016-03-09 14:32:57 +053015712 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015713}
15714
15715/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015716 * send_fw_test_cmd_tlv() - send fw test command to fw.
15717 * @wmi_handle: wmi handle
15718 * @wmi_fwtest: fw test command
15719 *
15720 * This function sends fw test command to fw.
15721 *
15722 * Return: CDF STATUS
15723 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015724static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015725QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15726 struct set_fwtest_params *wmi_fwtest)
15727{
15728 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15729 wmi_buf_t wmi_buf;
15730 uint16_t len;
15731
15732 len = sizeof(*cmd);
15733
15734 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15735 if (!wmi_buf) {
15736 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15737 return QDF_STATUS_E_NOMEM;
15738 }
15739
15740 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15741 WMITLV_SET_HDR(&cmd->tlv_header,
15742 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15743 WMITLV_GET_STRUCT_TLVLEN(
15744 wmi_fwtest_set_param_cmd_fixed_param));
15745 cmd->param_id = wmi_fwtest->arg;
15746 cmd->param_value = wmi_fwtest->value;
15747
15748 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15749 WMI_FWTEST_CMDID)) {
15750 WMI_LOGP("%s: failed to send fw test command", __func__);
15751 qdf_nbuf_free(wmi_buf);
15752 return QDF_STATUS_E_FAILURE;
15753 }
15754
15755 return QDF_STATUS_SUCCESS;
15756}
15757
15758/**
Govind Singha4836fd2016-03-07 16:45:38 +053015759 * send_unit_test_cmd_tlv() - send unit test command to fw.
15760 * @wmi_handle: wmi handle
15761 * @wmi_utest: unit test command
15762 *
15763 * This function send unit test command to fw.
15764 *
15765 * Return: CDF STATUS
15766 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015767static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015768 struct wmi_unit_test_cmd *wmi_utest)
15769{
15770 wmi_unit_test_cmd_fixed_param *cmd;
15771 wmi_buf_t wmi_buf;
15772 uint8_t *buf_ptr;
15773 int i;
15774 uint16_t len, args_tlv_len;
15775 A_UINT32 *unit_test_cmd_args;
15776
15777 args_tlv_len =
15778 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
15779 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15780
15781 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15782 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015783 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15784 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015785 }
15786
15787 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15788 buf_ptr = (uint8_t *) cmd;
15789 WMITLV_SET_HDR(&cmd->tlv_header,
15790 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15791 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15792 cmd->vdev_id = wmi_utest->vdev_id;
15793 cmd->module_id = wmi_utest->module_id;
15794 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015795 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015796 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15797 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15798 (wmi_utest->num_args * sizeof(uint32_t)));
15799 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015800 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15801 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15802 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015803 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015804 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015805 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015806 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015807 }
15808 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15809 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015810 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015811 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015812 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015813 }
15814
Govind Singhb53420c2016-03-09 14:32:57 +053015815 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015816}
15817
15818/**
15819 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15820 * @wmi_handle: wma handle
15821 * @roaminvoke: roam invoke command
15822 *
15823 * Send roam invoke command to fw for fastreassoc.
15824 *
15825 * Return: CDF STATUS
15826 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015827static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015828 struct wmi_roam_invoke_cmd *roaminvoke,
15829 uint32_t ch_hz)
15830{
15831 wmi_roam_invoke_cmd_fixed_param *cmd;
15832 wmi_buf_t wmi_buf;
15833 u_int8_t *buf_ptr;
15834 u_int16_t len, args_tlv_len;
15835 A_UINT32 *channel_list;
15836 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015837 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015838
15839 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080015840 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
15841 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15842 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015843 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15844 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15845 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015846 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15847 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015848 }
15849
15850 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15851 buf_ptr = (u_int8_t *) cmd;
15852 WMITLV_SET_HDR(&cmd->tlv_header,
15853 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15854 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15855 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015856 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015857 if (roaminvoke->is_same_bssid)
15858 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15859 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015860
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015861 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015862 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015863 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15864 cmd->num_buf = 1;
15865 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015866 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015867 cmd->num_buf = 0;
15868 }
Naveen Rawat77797922017-01-20 17:00:07 -080015869
Govind Singha4836fd2016-03-07 16:45:38 +053015870 cmd->roam_ap_sel_mode = 0;
15871 cmd->roam_delay = 0;
15872 cmd->num_chan = 1;
15873 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015874
Govind Singha4836fd2016-03-07 16:45:38 +053015875 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15876 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15877 (sizeof(u_int32_t)));
15878 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
15879 *channel_list = ch_hz;
15880 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
15881 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15882 (sizeof(wmi_mac_addr)));
15883 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15884 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015885
15886 /* move to next tlv i.e. bcn_prb_buf_list */
15887 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15888
15889 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15890 sizeof(wmi_tlv_buf_len_param));
15891
15892 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15893 buf_len_tlv->buf_len = roaminvoke->frame_len;
15894
15895 /* move to next tlv i.e. bcn_prb_frm */
15896 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15897 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15898 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15899
15900 /* copy frame after the header */
15901 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15902 roaminvoke->frame_buf,
15903 roaminvoke->frame_len);
15904
15905 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
15906 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
15907 buf_ptr + WMI_TLV_HDR_SIZE,
15908 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015909 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15910 cmd->flags, cmd->roam_scan_mode,
15911 cmd->roam_ap_sel_mode, cmd->roam_delay,
15912 cmd->num_chan, cmd->num_bssid);
15913 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015914
Govind Singha4836fd2016-03-07 16:45:38 +053015915 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15916 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015917 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015918 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015919 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015920 }
15921
Govind Singhb53420c2016-03-09 14:32:57 +053015922 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015923}
15924
15925/**
15926 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15927 * @wmi_handle: wmi handle
15928 * @command: command
15929 * @vdev_id: vdev id
15930 *
15931 * This function set roam offload command to fw.
15932 *
15933 * Return: CDF status
15934 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015935static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015936 uint32_t command, uint32_t vdev_id)
15937{
Govind Singh67922e82016-04-01 16:48:57 +053015938 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015939 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15940 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015941 int len;
15942 uint8_t *buf_ptr;
15943
15944 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15945 buf = wmi_buf_alloc(wmi_handle, len);
15946 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015947 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15948 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015949 }
15950
15951 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15952
15953 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15954 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15955 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15956 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15957 cmd_fp->vdev_id = vdev_id;
15958 cmd_fp->command_arg = command;
15959
15960 status = wmi_unified_cmd_send(wmi_handle, buf,
15961 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015962 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015963 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015964 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015965 goto error;
15966 }
15967
Govind Singhb53420c2016-03-09 14:32:57 +053015968 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15969 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015970
15971error:
15972 wmi_buf_free(buf);
15973
Govind Singh67922e82016-04-01 16:48:57 +053015974 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015975}
15976
15977/**
15978 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15979 * @wmi_handle: wmi handle
15980 * @ap_profile_p: ap profile
15981 * @vdev_id: vdev id
15982 *
15983 * Send WMI_ROAM_AP_PROFILE to firmware
15984 *
15985 * Return: CDF status
15986 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015987static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015988 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015989{
Govind Singha4836fd2016-03-07 16:45:38 +053015990 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015991 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015992 int len;
15993 uint8_t *buf_ptr;
15994 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015995 wmi_roam_cnd_scoring_param *score_param;
15996 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015997
15998 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015999 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053016000 buf = wmi_buf_alloc(wmi_handle, len);
16001 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016002 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16003 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016004 }
16005
16006 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16007 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
16008 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
16009 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
16010 WMITLV_GET_STRUCT_TLVLEN
16011 (wmi_roam_ap_profile_fixed_param));
16012 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016013 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053016014 roam_ap_profile_fp->id = 0;
16015 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
16016
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016017 profile = (wmi_ap_profile *)buf_ptr;
16018 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053016019 WMITLV_TAG_STRUC_wmi_ap_profile,
16020 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016021 profile->flags = ap_profile->profile.flags;
16022 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
16023 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
16024 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
16025 profile->ssid.ssid_len);
16026 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
16027 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
16028 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
16029 profile->rsn_mcastmgmtcipherset =
16030 ap_profile->profile.rsn_mcastmgmtcipherset;
16031 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
16032
16033 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",
16034 profile->flags, profile->rssi_threshold,
16035 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
16036 profile->rsn_authmode, profile->rsn_ucastcipherset,
16037 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
16038 profile->rssi_abs_thresh);
16039
16040 buf_ptr += sizeof(wmi_ap_profile);
16041
16042 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
16043 WMITLV_SET_HDR(&score_param->tlv_header,
16044 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
16045 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
16046 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
16047 score_param->rssi_weightage_pcnt =
16048 ap_profile->param.rssi_weightage;
16049 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
16050 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
16051 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
16052 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
16053 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
16054 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
16055 score_param->esp_qbss_weightage_pcnt =
16056 ap_profile->param.esp_qbss_weightage;
16057 score_param->beamforming_weightage_pcnt =
16058 ap_profile->param.beamforming_weightage;
16059 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
16060 score_param->oce_wan_weightage_pcnt =
16061 ap_profile->param.oce_wan_weightage;
16062
16063 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",
16064 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
16065 score_param->ht_weightage_pcnt,
16066 score_param->vht_weightage_pcnt,
16067 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
16068 score_param->band_weightage_pcnt,
16069 score_param->nss_weightage_pcnt,
16070 score_param->esp_qbss_weightage_pcnt,
16071 score_param->beamforming_weightage_pcnt,
16072 score_param->pcl_weightage_pcnt,
16073 score_param->oce_wan_weightage_pcnt);
16074
16075 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
16076 score_param->band_scoring.score_pcnt =
16077 ap_profile->param.band_index_score;
16078 score_param->nss_scoring.score_pcnt =
16079 ap_profile->param.nss_index_score;
16080
16081 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
16082 score_param->bw_scoring.score_pcnt,
16083 score_param->band_scoring.score_pcnt,
16084 score_param->nss_scoring.score_pcnt);
16085
16086 score_param->rssi_scoring.best_rssi_threshold =
16087 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
16088 score_param->rssi_scoring.good_rssi_threshold =
16089 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
16090 score_param->rssi_scoring.bad_rssi_threshold =
16091 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
16092 score_param->rssi_scoring.good_rssi_pcnt =
16093 ap_profile->param.rssi_scoring.good_rssi_pcnt;
16094 score_param->rssi_scoring.bad_rssi_pcnt =
16095 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
16096 score_param->rssi_scoring.good_bucket_size =
16097 ap_profile->param.rssi_scoring.good_bucket_size;
16098 score_param->rssi_scoring.bad_bucket_size =
16099 ap_profile->param.rssi_scoring.bad_bucket_size;
16100 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
16101 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
16102
16103 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
16104 score_param->rssi_scoring.best_rssi_threshold,
16105 score_param->rssi_scoring.good_rssi_threshold,
16106 score_param->rssi_scoring.bad_rssi_threshold,
16107 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
16108 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
16109 score_param->rssi_scoring.good_rssi_pcnt,
16110 score_param->rssi_scoring.bad_rssi_pcnt,
16111 score_param->rssi_scoring.good_bucket_size,
16112 score_param->rssi_scoring.bad_bucket_size);
16113
16114 score_param->esp_qbss_scoring.num_slot =
16115 ap_profile->param.esp_qbss_scoring.num_slot;
16116 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
16117 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
16118 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
16119 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
16120 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
16121 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
16122 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
16123 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
16124
16125 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16126 score_param->esp_qbss_scoring.num_slot,
16127 score_param->esp_qbss_scoring.score_pcnt3_to_0,
16128 score_param->esp_qbss_scoring.score_pcnt7_to_4,
16129 score_param->esp_qbss_scoring.score_pcnt11_to_8,
16130 score_param->esp_qbss_scoring.score_pcnt15_to_12);
16131
16132 score_param->oce_wan_scoring.num_slot =
16133 ap_profile->param.oce_wan_scoring.num_slot;
16134 score_param->oce_wan_scoring.score_pcnt3_to_0 =
16135 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
16136 score_param->oce_wan_scoring.score_pcnt7_to_4 =
16137 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
16138 score_param->oce_wan_scoring.score_pcnt11_to_8 =
16139 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
16140 score_param->oce_wan_scoring.score_pcnt15_to_12 =
16141 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
16142
16143 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16144 score_param->oce_wan_scoring.num_slot,
16145 score_param->oce_wan_scoring.score_pcnt3_to_0,
16146 score_param->oce_wan_scoring.score_pcnt7_to_4,
16147 score_param->oce_wan_scoring.score_pcnt11_to_8,
16148 score_param->oce_wan_scoring.score_pcnt15_to_12);
16149
Govind Singha4836fd2016-03-07 16:45:38 +053016150 status = wmi_unified_cmd_send(wmi_handle, buf,
16151 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053016152 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016153 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016154 status);
Govind Singh67922e82016-04-01 16:48:57 +053016155 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053016156 }
16157
Govind Singhb53420c2016-03-09 14:32:57 +053016158 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053016159
Govind Singh67922e82016-04-01 16:48:57 +053016160 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016161}
16162
16163/**
16164 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
16165 * @wmi_handle: wmi handle
16166 * @scan_period: scan period
16167 * @scan_age: scan age
16168 * @vdev_id: vdev id
16169 *
16170 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
16171 *
16172 * Return: CDF status
16173 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016174static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016175 uint32_t scan_period,
16176 uint32_t scan_age,
16177 uint32_t vdev_id)
16178{
Govind Singh67922e82016-04-01 16:48:57 +053016179 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016180 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053016181 int len;
16182 uint8_t *buf_ptr;
16183 wmi_roam_scan_period_fixed_param *scan_period_fp;
16184
16185 /* Send scan period values */
16186 len = sizeof(wmi_roam_scan_period_fixed_param);
16187 buf = wmi_buf_alloc(wmi_handle, len);
16188 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016189 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16190 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016191 }
16192
16193 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16194 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
16195 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
16196 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
16197 WMITLV_GET_STRUCT_TLVLEN
16198 (wmi_roam_scan_period_fixed_param));
16199 /* fill in scan period values */
16200 scan_period_fp->vdev_id = vdev_id;
16201 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
16202 scan_period_fp->roam_scan_age = scan_age;
16203
16204 status = wmi_unified_cmd_send(wmi_handle, buf,
16205 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053016206 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016207 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016208 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016209 goto error;
16210 }
16211
Govind Singhb53420c2016-03-09 14:32:57 +053016212 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053016213 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053016214 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016215error:
16216 wmi_buf_free(buf);
16217
Govind Singh67922e82016-04-01 16:48:57 +053016218 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016219}
16220
16221/**
16222 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
16223 * @wmi_handle: wmi handle
16224 * @chan_count: channel count
16225 * @chan_list: channel list
16226 * @list_type: list type
16227 * @vdev_id: vdev id
16228 *
16229 * Set roam offload channel list.
16230 *
16231 * Return: CDF status
16232 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016233static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016234 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070016235 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053016236 uint8_t list_type, uint32_t vdev_id)
16237{
Govind Singha4836fd2016-03-07 16:45:38 +053016238 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016239 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016240 int len, list_tlv_len;
16241 int i;
16242 uint8_t *buf_ptr;
16243 wmi_roam_chan_list_fixed_param *chan_list_fp;
16244 A_UINT32 *roam_chan_list_array;
16245
16246 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053016247 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053016248 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053016249 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053016250 }
16251 /* Channel list is a table of 2 TLV's */
16252 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
16253 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
16254 buf = wmi_buf_alloc(wmi_handle, len);
16255 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016256 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16257 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016258 }
16259
16260 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16261 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
16262 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
16263 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
16264 WMITLV_GET_STRUCT_TLVLEN
16265 (wmi_roam_chan_list_fixed_param));
16266 chan_list_fp->vdev_id = vdev_id;
16267 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053016268 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053016269 /* external app is controlling channel list */
16270 chan_list_fp->chan_list_type =
16271 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
16272 } else {
16273 /* umac supplied occupied channel list in LFR */
16274 chan_list_fp->chan_list_type =
16275 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
16276 }
16277
16278 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
16279 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16280 (chan_list_fp->num_chan * sizeof(uint32_t)));
16281 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016282 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053016283 for (i = 0; ((i < chan_list_fp->num_chan) &&
16284 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
16285 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053016286 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053016287 }
16288
16289 status = wmi_unified_cmd_send(wmi_handle, buf,
16290 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053016291 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016292 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016293 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016294 goto error;
16295 }
16296
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016297 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053016298 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016299error:
16300 wmi_buf_free(buf);
16301
Govind Singh67922e82016-04-01 16:48:57 +053016302 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016303}
16304
16305/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016306 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
16307 * @wmi_handle: wmi handle
16308 * @req_buf: per roam config buffer
16309 *
16310 * Return: QDF status
16311 */
16312static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
16313 struct wmi_per_roam_config_req *req_buf)
16314{
16315 wmi_buf_t buf = NULL;
16316 QDF_STATUS status;
16317 int len;
16318 uint8_t *buf_ptr;
16319 wmi_roam_per_config_fixed_param *wmi_per_config;
16320
16321 len = sizeof(wmi_roam_per_config_fixed_param);
16322 buf = wmi_buf_alloc(wmi_handle, len);
16323 if (!buf) {
16324 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16325 return QDF_STATUS_E_NOMEM;
16326 }
16327
16328 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16329 wmi_per_config =
16330 (wmi_roam_per_config_fixed_param *) buf_ptr;
16331 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
16332 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
16333 WMITLV_GET_STRUCT_TLVLEN
16334 (wmi_roam_per_config_fixed_param));
16335
16336 /* fill in per roam config values */
16337 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016338
16339 wmi_per_config->enable = req_buf->per_config.enable;
16340 wmi_per_config->high_rate_thresh =
16341 (req_buf->per_config.tx_high_rate_thresh << 16) |
16342 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
16343 wmi_per_config->low_rate_thresh =
16344 (req_buf->per_config.tx_low_rate_thresh << 16) |
16345 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
16346 wmi_per_config->pkt_err_rate_thresh_pct =
16347 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
16348 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
16349 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053016350 wmi_per_config->pkt_err_rate_mon_time =
16351 (req_buf->per_config.tx_per_mon_time << 16) |
16352 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053016353 wmi_per_config->min_candidate_rssi =
16354 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016355
16356 /* Send per roam config parameters */
16357 status = wmi_unified_cmd_send(wmi_handle, buf,
16358 len, WMI_ROAM_PER_CONFIG_CMDID);
16359 if (QDF_IS_STATUS_ERROR(status)) {
16360 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
16361 status);
16362 wmi_buf_free(buf);
16363 return status;
16364 }
16365
16366 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
16367 req_buf->per_config.enable, req_buf->vdev_id);
16368 return QDF_STATUS_SUCCESS;
16369}
16370
16371/**
Govind Singha4836fd2016-03-07 16:45:38 +053016372 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
16373 * @wmi_handle: wmi handle
16374 * @rssi_change_thresh: RSSI Change threshold
16375 * @bcn_rssi_weight: beacon RSSI weight
16376 * @vdev_id: vdev id
16377 *
16378 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
16379 *
16380 * Return: CDF status
16381 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016382static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016383 uint32_t vdev_id,
16384 int32_t rssi_change_thresh,
16385 uint32_t bcn_rssi_weight,
16386 uint32_t hirssi_delay_btw_scans)
16387{
Govind Singha4836fd2016-03-07 16:45:38 +053016388 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016389 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016390 int len;
16391 uint8_t *buf_ptr;
16392 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
16393
16394 /* Send rssi change parameters */
16395 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
16396 buf = wmi_buf_alloc(wmi_handle, len);
16397 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016398 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16399 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016400 }
16401
16402 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16403 rssi_change_fp =
16404 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
16405 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
16406 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
16407 WMITLV_GET_STRUCT_TLVLEN
16408 (wmi_roam_scan_rssi_change_threshold_fixed_param));
16409 /* fill in rssi change threshold (hysteresis) values */
16410 rssi_change_fp->vdev_id = vdev_id;
16411 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
16412 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
16413 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
16414
16415 status = wmi_unified_cmd_send(wmi_handle, buf,
16416 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053016417 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016418 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016419 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016420 goto error;
16421 }
16422
Govind Singhb53420c2016-03-09 14:32:57 +053016423 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053016424 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053016425 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
16426 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016427error:
16428 wmi_buf_free(buf);
16429
Govind Singh67922e82016-04-01 16:48:57 +053016430 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016431}
16432
16433/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
16434 * @wmi_handle: wmi handle.
16435 * @cmd: size of command structure.
16436 * @per_entry_size: per entry size.
16437 *
16438 * This utility function calculates how many hotlist entries can
16439 * fit in one page.
16440 *
16441 * Return: number of entries
16442 */
16443static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
16444 size_t cmd_size,
16445 size_t per_entry_size)
16446{
16447 uint32_t avail_space = 0;
16448 int num_entries = 0;
16449 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
16450
16451 /* Calculate number of hotlist entries that can
16452 * be passed in wma message request.
16453 */
16454 avail_space = max_msg_len - cmd_size;
16455 num_entries = avail_space / per_entry_size;
16456 return num_entries;
16457}
16458
16459/**
16460 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
16461 * @wmi_handle: wmi handle
16462 * @photlist: hotlist command params
16463 * @buf_len: buffer length
16464 *
16465 * This function fills individual elements for hotlist request and
16466 * TLV for bssid entries
16467 *
16468 * Return: CDF Status.
16469 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016470static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016471 struct ext_scan_setbssi_hotlist_params *
16472 photlist, int *buf_len)
16473{
16474 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
16475 wmi_extscan_hotlist_entry *dest_hotlist;
16476 struct ap_threshold_params *src_ap = photlist->ap;
16477 wmi_buf_t buf;
16478 uint8_t *buf_ptr;
16479
16480 int j, index = 0;
16481 int cmd_len = 0;
16482 int num_entries;
16483 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016484 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053016485 int len = sizeof(*cmd);
16486
16487 len += WMI_TLV_HDR_SIZE;
16488 cmd_len = len;
16489
16490 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
16491 cmd_len,
16492 sizeof(*dest_hotlist));
16493 /* setbssid hotlist expects the bssid list
16494 * to be non zero value
16495 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016496 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080016497 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053016498 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053016499 }
16500
16501 /* Split the hot list entry pages and send multiple command
16502 * requests if the buffer reaches the maximum request size
16503 */
16504 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053016505 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053016506 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
16507 buf = wmi_buf_alloc(wmi_handle, len);
16508 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016509 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
16510 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016511 }
16512 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16513 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
16514 buf_ptr;
16515 WMITLV_SET_HDR(&cmd->tlv_header,
16516 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
16517 WMITLV_GET_STRUCT_TLVLEN
16518 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
16519
16520 /* Multiple requests are sent until the num_entries_in_page
16521 * matches the total_entries
16522 */
16523 cmd->request_id = photlist->requestId;
16524 cmd->vdev_id = photlist->sessionId;
16525 cmd->total_entries = numap;
16526 cmd->mode = 1;
16527 cmd->num_entries_in_page = min_entries;
16528 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
16529 cmd->first_entry_index = index;
16530
Govind Singhb53420c2016-03-09 14:32:57 +053016531 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016532 __func__, cmd->vdev_id, cmd->total_entries,
16533 cmd->num_entries_in_page,
16534 cmd->lost_ap_scan_count);
16535
16536 buf_ptr += sizeof(*cmd);
16537 WMITLV_SET_HDR(buf_ptr,
16538 WMITLV_TAG_ARRAY_STRUC,
16539 min_entries * sizeof(wmi_extscan_hotlist_entry));
16540 dest_hotlist = (wmi_extscan_hotlist_entry *)
16541 (buf_ptr + WMI_TLV_HDR_SIZE);
16542
16543 /* Populate bssid, channel info and rssi
16544 * for the bssid's that are sent as hotlists.
16545 */
16546 for (j = 0; j < min_entries; j++) {
16547 WMITLV_SET_HDR(dest_hotlist,
16548 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
16549 WMITLV_GET_STRUCT_TLVLEN
16550 (wmi_extscan_hotlist_entry));
16551
16552 dest_hotlist->min_rssi = src_ap->low;
16553 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
16554 &dest_hotlist->bssid);
16555
Govind Singhb53420c2016-03-09 14:32:57 +053016556 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016557 __func__, dest_hotlist->channel,
16558 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053016559 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053016560 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16561 __func__, dest_hotlist->bssid.mac_addr31to0,
16562 dest_hotlist->bssid.mac_addr47to32);
16563 dest_hotlist++;
16564 src_ap++;
16565 }
16566 buf_ptr += WMI_TLV_HDR_SIZE +
16567 (min_entries * sizeof(wmi_extscan_hotlist_entry));
16568
16569 if (wmi_unified_cmd_send(wmi_handle, buf, len,
16570 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016571 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053016572 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053016573 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016574 }
16575 index = index + min_entries;
16576 num_entries = numap - min_entries;
16577 len = cmd_len;
16578 }
Govind Singhb53420c2016-03-09 14:32:57 +053016579 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016580}
16581
Govind Singhbca3b1b2016-05-02 17:59:24 +053016582/**
Dustin Brown4423f632017-01-13 15:24:07 -080016583 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
16584 * @wmi_handle: the WMI handle
16585 * @vdev_id: the Id of the vdev to apply the configuration to
16586 * @ucast_mode: the active BPF mode to configure for unicast packets
16587 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
16588 * packets
16589 *
16590 * Return: QDF status
16591 */
16592static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
16593 uint8_t vdev_id,
16594 enum wmi_host_active_bpf_mode ucast_mode,
16595 enum wmi_host_active_bpf_mode mcast_bcast_mode)
16596{
16597 const WMITLV_TAG_ID tag_id =
16598 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
16599 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
16600 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
16601 QDF_STATUS status;
16602 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
16603 wmi_buf_t buf;
16604
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016605 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080016606 vdev_id, ucast_mode, mcast_bcast_mode);
16607
16608 /* allocate command buffer */
16609 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
16610 if (!buf) {
16611 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
16612 return QDF_STATUS_E_NOMEM;
16613 }
16614
16615 /* set TLV header */
16616 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
16617 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
16618
16619 /* populate data */
16620 cmd->vdev_id = vdev_id;
16621 cmd->uc_mode = ucast_mode;
16622 cmd->mcbc_mode = mcast_bcast_mode;
16623
16624 /* send to FW */
16625 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
16626 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
16627 if (QDF_IS_STATUS_ERROR(status)) {
16628 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
16629 status);
16630 wmi_buf_free(buf);
16631 return status;
16632 }
16633
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016634 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080016635
16636 return QDF_STATUS_SUCCESS;
16637}
16638
16639/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053016640 * send_power_dbg_cmd_tlv() - send power debug commands
16641 * @wmi_handle: wmi handle
16642 * @param: wmi power debug parameter
16643 *
16644 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
16645 *
16646 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16647 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016648static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
16649 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053016650{
16651 wmi_buf_t buf = NULL;
16652 QDF_STATUS status;
16653 int len, args_tlv_len;
16654 uint8_t *buf_ptr;
16655 uint8_t i;
16656 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
16657 uint32_t *cmd_args;
16658
16659 /* Prepare and send power debug cmd parameters */
16660 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
16661 len = sizeof(*cmd) + args_tlv_len;
16662 buf = wmi_buf_alloc(wmi_handle, len);
16663 if (!buf) {
16664 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16665 return QDF_STATUS_E_NOMEM;
16666 }
16667
16668 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16669 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
16670 WMITLV_SET_HDR(&cmd->tlv_header,
16671 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
16672 WMITLV_GET_STRUCT_TLVLEN
16673 (wmi_pdev_wal_power_debug_cmd_fixed_param));
16674
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016675 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16676 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016677 cmd->module_id = param->module_id;
16678 cmd->num_args = param->num_args;
16679 buf_ptr += sizeof(*cmd);
16680 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16681 (param->num_args * sizeof(uint32_t)));
16682 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
16683 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080016684 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053016685 cmd_args[i] = param->args[i];
16686 WMI_LOGI("%d,", param->args[i]);
16687 }
16688
16689 status = wmi_unified_cmd_send(wmi_handle, buf,
16690 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
16691 if (QDF_IS_STATUS_ERROR(status)) {
16692 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
16693 status);
16694 goto error;
16695 }
16696
16697 return QDF_STATUS_SUCCESS;
16698error:
16699 wmi_buf_free(buf);
16700
16701 return status;
16702}
16703
Govind Singhe7f2f342016-05-23 12:12:52 +053016704/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016705 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
16706 * @wmi_handle: wmi handle
16707 * @param: wmi multiple vdev restart req param
16708 *
16709 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
16710 *
16711 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16712 */
16713static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
16714 wmi_unified_t wmi_handle,
16715 struct multiple_vdev_restart_params *param)
16716{
16717 wmi_buf_t buf;
16718 QDF_STATUS qdf_status;
16719 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
16720 int i;
16721 uint8_t *buf_ptr;
16722 uint32_t *vdev_ids;
16723 wmi_channel *chan_info;
16724 struct channel_param *tchan_info;
16725 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
16726
16727 len += sizeof(wmi_channel);
16728 if (param->num_vdevs)
16729 len += sizeof(uint32_t) * param->num_vdevs;
16730
16731 buf = wmi_buf_alloc(wmi_handle, len);
16732 if (!buf) {
16733 WMI_LOGE("Failed to allocate memory\n");
16734 qdf_status = QDF_STATUS_E_NOMEM;
16735 goto end;
16736 }
16737
16738 buf_ptr = (uint8_t *)wmi_buf_data(buf);
16739 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
16740 buf_ptr;
16741
16742 WMITLV_SET_HDR(&cmd->tlv_header,
16743 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
16744 WMITLV_GET_STRUCT_TLVLEN
16745 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016746 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16747 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016748 cmd->requestor_id = param->requestor_id;
16749 cmd->disable_hw_ack = param->disable_hw_ack;
16750 cmd->cac_duration_ms = param->cac_duration_ms;
16751 cmd->num_vdevs = param->num_vdevs;
16752
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016753 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
16754 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
16755 " cmd->num_vdevs: %d ",
16756 __func__, cmd->pdev_id, cmd->requestor_id,
16757 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016758 buf_ptr += sizeof(*cmd);
16759
16760 WMITLV_SET_HDR(buf_ptr,
16761 WMITLV_TAG_ARRAY_UINT32,
16762 sizeof(A_UINT32) * param->num_vdevs);
16763 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
16764 for (i = 0; i < param->num_vdevs; i++) {
16765 vdev_ids[i] = param->vdev_ids[i];
16766 }
16767
16768 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
16769
16770 WMITLV_SET_HDR(buf_ptr,
16771 WMITLV_TAG_STRUC_wmi_channel,
16772 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053016773 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016774 tchan_info = &(param->ch_param);
16775 chan_info->mhz = tchan_info->mhz;
16776 chan_info->band_center_freq1 = tchan_info->cfreq1;
16777 chan_info->band_center_freq2 = tchan_info->cfreq2;
16778 if (tchan_info->is_chan_passive)
16779 WMI_SET_CHANNEL_FLAG(chan_info,
16780 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016781 if (tchan_info->dfs_set)
16782 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
16783
Sathish Kumar45e991b2017-02-27 10:35:40 +053016784 if (tchan_info->allow_vht)
16785 WMI_SET_CHANNEL_FLAG(chan_info,
16786 WMI_CHAN_FLAG_ALLOW_VHT);
16787 else if (tchan_info->allow_ht)
16788 WMI_SET_CHANNEL_FLAG(chan_info,
16789 WMI_CHAN_FLAG_ALLOW_HT);
16790 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
16791 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
16792 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
16793 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
16794 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
16795 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080016796 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016797
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016798 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
16799 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
16800 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
16801 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
16802 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
16803 "tchan_info->reg_class_id: %d ,"
16804 "tchan_info->maxregpower : %d ", __func__,
16805 tchan_info->is_chan_passive, tchan_info->dfs_set,
16806 tchan_info->allow_vht, tchan_info->allow_ht,
16807 tchan_info->antennamax, tchan_info->phy_mode,
16808 tchan_info->minpower, tchan_info->maxpower,
16809 tchan_info->maxregpower, tchan_info->reg_class_id,
16810 tchan_info->maxregpower);
16811
Sathish Kumar45e991b2017-02-27 10:35:40 +053016812 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
16813 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
16814
16815 if (QDF_IS_STATUS_ERROR(qdf_status)) {
16816 WMI_LOGE("%s: Failed to send\n", __func__);
16817 wmi_buf_free(buf);
16818 }
16819
16820end:
16821 return qdf_status;
16822}
16823
16824/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080016825 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
16826 * @wmi_handle: wmi handle
16827 * @pdev_id: pdev id
16828 *
16829 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16830 *
16831 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16832 */
16833static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16834 uint32_t pdev_id)
16835{
16836 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16837 wmi_buf_t buf;
16838 uint16_t len;
16839 QDF_STATUS ret;
16840
16841 len = sizeof(*cmd);
16842 buf = wmi_buf_alloc(wmi_handle, len);
16843
16844 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16845
16846 if (!buf) {
16847 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16848 return QDF_STATUS_E_NOMEM;
16849 }
16850
16851 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16852 wmi_buf_data(buf);
16853
16854 WMITLV_SET_HDR(&cmd->tlv_header,
16855 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16856 WMITLV_GET_STRUCT_TLVLEN(
16857 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16858
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016859 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016860 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16861 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16862 if (QDF_IS_STATUS_ERROR(ret)) {
16863 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16864 __func__, ret, pdev_id);
16865 wmi_buf_free(buf);
16866 return QDF_STATUS_E_FAILURE;
16867 }
16868
16869 return QDF_STATUS_SUCCESS;
16870}
16871
16872/**
16873 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16874 * @wmi_handle: wmi handle
16875 * @pdev_id: pdev id
16876 *
16877 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16878 *
16879 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16880 */
16881static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16882 uint32_t pdev_id)
16883{
16884 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16885 wmi_buf_t buf;
16886 uint16_t len;
16887 QDF_STATUS ret;
16888
16889 len = sizeof(*cmd);
16890 buf = wmi_buf_alloc(wmi_handle, len);
16891
16892 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16893
16894 if (!buf) {
16895 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16896 return QDF_STATUS_E_NOMEM;
16897 }
16898
16899 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16900 wmi_buf_data(buf);
16901
16902 WMITLV_SET_HDR(&cmd->tlv_header,
16903 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16904 WMITLV_GET_STRUCT_TLVLEN(
16905 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16906
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016907 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016908 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16909 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16910 if (QDF_IS_STATUS_ERROR(ret)) {
16911 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16912 __func__, ret, pdev_id);
16913 wmi_buf_free(buf);
16914 return QDF_STATUS_E_FAILURE;
16915 }
16916
16917 return QDF_STATUS_SUCCESS;
16918}
16919
16920/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016921 * init_cmd_send_tlv() - send initialization cmd to fw
16922 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016923 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016924 *
16925 * Return: QDF_STATUS_SUCCESS for success or error code
16926 */
16927static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016928 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016929{
16930 wmi_buf_t buf;
16931 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016932 uint8_t *buf_ptr;
16933 wmi_resource_config *resource_cfg;
16934 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016935 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016936 uint16_t idx;
16937 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016938 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016939
Kiran Venkatappa26117052016-12-23 19:58:54 +053016940 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16941 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016942 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016943
16944 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16945 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16946 WMI_TLV_HDR_SIZE +
16947 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16948
16949 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016950 if (!buf) {
16951 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16952 return QDF_STATUS_E_FAILURE;
16953 }
16954
16955 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16956 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16957 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16958
16959 host_mem_chunks = (wlan_host_memory_chunk *)
16960 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16961 + WMI_TLV_HDR_SIZE);
16962
16963 WMITLV_SET_HDR(&cmd->tlv_header,
16964 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16965 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16966
Kiran Venkatappa26117052016-12-23 19:58:54 +053016967 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016968 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16969 WMITLV_TAG_STRUC_wmi_resource_config,
16970 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16971
Kiran Venkatappa26117052016-12-23 19:58:54 +053016972 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016973 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16974 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16975 WMITLV_GET_STRUCT_TLVLEN
16976 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016977 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16978 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16979 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016980 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16981 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016982 idx, host_mem_chunks[idx].size,
16983 host_mem_chunks[idx].ptr);
16984 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016985 cmd->num_host_mem_chunks = param->num_mem_chunks;
16986 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16987
Govind Singhe7f2f342016-05-23 12:12:52 +053016988 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16989 WMITLV_TAG_ARRAY_STRUC,
16990 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016991 param->num_mem_chunks));
16992
16993 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016994 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016995
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016996 /* Fill fw_abi_vers */
16997 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016998
Abhishek Singh716c46c2016-05-04 16:24:07 +053016999 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
17000 if (QDF_IS_STATUS_ERROR(ret)) {
17001 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
17002 ret);
17003 wmi_buf_free(buf);
17004 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017005
Abhishek Singh716c46c2016-05-04 16:24:07 +053017006 return ret;
17007
Govind Singhe7f2f342016-05-23 12:12:52 +053017008}
17009
17010/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080017011 * send_addba_send_cmd_tlv() - send addba send command to fw
17012 * @wmi_handle: wmi handle
17013 * @param: pointer to delba send params
17014 * @macaddr: peer mac address
17015 *
17016 * Send WMI_ADDBA_SEND_CMDID command to firmware
17017 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17018 */
17019static QDF_STATUS
17020send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
17021 uint8_t macaddr[IEEE80211_ADDR_LEN],
17022 struct addba_send_params *param)
17023{
17024 wmi_addba_send_cmd_fixed_param *cmd;
17025 wmi_buf_t buf;
17026 uint16_t len;
17027 QDF_STATUS ret;
17028
17029 len = sizeof(*cmd);
17030
17031 buf = wmi_buf_alloc(wmi_handle, len);
17032 if (!buf) {
17033 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17034 return QDF_STATUS_E_NOMEM;
17035 }
17036
17037 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
17038
17039 WMITLV_SET_HDR(&cmd->tlv_header,
17040 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
17041 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
17042
17043 cmd->vdev_id = param->vdev_id;
17044 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17045 cmd->tid = param->tidno;
17046 cmd->buffersize = param->buffersize;
17047
17048 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
17049 if (QDF_IS_STATUS_ERROR(ret)) {
17050 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17051 wmi_buf_free(buf);
17052 return QDF_STATUS_E_FAILURE;
17053 }
17054
17055 return QDF_STATUS_SUCCESS;
17056}
17057
17058/**
17059 * send_delba_send_cmd_tlv() - send delba send command to fw
17060 * @wmi_handle: wmi handle
17061 * @param: pointer to delba send params
17062 * @macaddr: peer mac address
17063 *
17064 * Send WMI_DELBA_SEND_CMDID command to firmware
17065 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17066 */
17067static QDF_STATUS
17068send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
17069 uint8_t macaddr[IEEE80211_ADDR_LEN],
17070 struct delba_send_params *param)
17071{
17072 wmi_delba_send_cmd_fixed_param *cmd;
17073 wmi_buf_t buf;
17074 uint16_t len;
17075 QDF_STATUS ret;
17076
17077 len = sizeof(*cmd);
17078
17079 buf = wmi_buf_alloc(wmi_handle, len);
17080 if (!buf) {
17081 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17082 return QDF_STATUS_E_NOMEM;
17083 }
17084
17085 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
17086
17087 WMITLV_SET_HDR(&cmd->tlv_header,
17088 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
17089 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
17090
17091 cmd->vdev_id = param->vdev_id;
17092 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17093 cmd->tid = param->tidno;
17094 cmd->initiator = param->initiator;
17095 cmd->reasoncode = param->reasoncode;
17096
17097 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
17098 if (QDF_IS_STATUS_ERROR(ret)) {
17099 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17100 wmi_buf_free(buf);
17101 return QDF_STATUS_E_FAILURE;
17102 }
17103
17104 return QDF_STATUS_SUCCESS;
17105}
17106
17107/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080017108 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
17109 * to fw
17110 * @wmi_handle: wmi handle
17111 * @param: pointer to addba clearresp params
17112 * @macaddr: peer mac address
17113 * Return: 0 for success or error code
17114 */
17115static QDF_STATUS
17116send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
17117 uint8_t macaddr[IEEE80211_ADDR_LEN],
17118 struct addba_clearresponse_params *param)
17119{
17120 wmi_addba_clear_resp_cmd_fixed_param *cmd;
17121 wmi_buf_t buf;
17122 uint16_t len;
17123 QDF_STATUS ret;
17124
17125 len = sizeof(*cmd);
17126
17127 buf = wmi_buf_alloc(wmi_handle, len);
17128 if (!buf) {
17129 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
17130 return QDF_STATUS_E_FAILURE;
17131 }
17132 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
17133
17134 WMITLV_SET_HDR(&cmd->tlv_header,
17135 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
17136 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
17137
17138 cmd->vdev_id = param->vdev_id;
17139 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17140
17141 ret = wmi_unified_cmd_send(wmi_handle,
17142 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
17143 if (QDF_IS_STATUS_ERROR(ret)) {
17144 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17145 wmi_buf_free(buf);
17146 return QDF_STATUS_E_FAILURE;
17147 }
17148
17149 return QDF_STATUS_SUCCESS;
17150}
17151
17152/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017153 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
17154 * @wmi_handle: wmi handle
17155 * @bcn_ctrl_param: pointer to bcn_offload_control param
17156 *
17157 * Return: QDF_STATUS_SUCCESS for success or error code
17158 */
17159static
17160QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
17161 struct bcn_offload_control *bcn_ctrl_param)
17162{
17163 wmi_buf_t buf;
17164 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
17165 QDF_STATUS ret;
17166 uint32_t len;
17167
17168 len = sizeof(*cmd);
17169
17170 buf = wmi_buf_alloc(wmi_handle, len);
17171 if (!buf) {
17172 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17173 return QDF_STATUS_E_FAILURE;
17174 }
17175
17176 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
17177 WMITLV_SET_HDR(&cmd->tlv_header,
17178 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
17179 WMITLV_GET_STRUCT_TLVLEN
17180 (wmi_bcn_offload_ctrl_cmd_fixed_param));
17181 cmd->vdev_id = bcn_ctrl_param->vdev_id;
17182 if (bcn_ctrl_param->bcn_tx_enable)
17183 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
17184 else
17185 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
17186
17187
17188 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
17189 WMI_BCN_OFFLOAD_CTRL_CMDID);
17190
17191 if (QDF_IS_STATUS_ERROR(ret)) {
17192 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
17193 ret);
17194 wmi_buf_free(buf);
17195 }
17196
17197 return ret;
17198}
17199
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017200#ifdef WLAN_FEATURE_NAN_CONVERGENCE
17201static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
17202 struct nan_datapath_initiator_req *ndp_req)
17203{
17204 uint16_t len;
17205 wmi_buf_t buf;
17206 uint8_t *tlv_ptr;
17207 QDF_STATUS status;
17208 wmi_channel *ch_tlv;
17209 wmi_ndp_initiator_req_fixed_param *cmd;
17210 uint32_t passphrase_len, service_name_len;
17211 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
17212
17213 /*
17214 * WMI command expects 4 byte alligned len:
17215 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17216 */
17217 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
17218 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
17219 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
17220 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
17221 service_name_len =
17222 qdf_roundup(ndp_req->service_name.service_name_len, 4);
17223 /* allocated memory for fixed params as well as variable size data */
17224 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
17225 + ndp_cfg_len + ndp_app_info_len + pmk_len
17226 + passphrase_len + service_name_len;
17227
17228 buf = wmi_buf_alloc(wmi_handle, len);
17229 if (!buf) {
17230 WMI_LOGE("wmi_buf_alloc failed");
17231 return QDF_STATUS_E_NOMEM;
17232 }
17233
17234 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
17235 WMITLV_SET_HDR(&cmd->tlv_header,
17236 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
17237 WMITLV_GET_STRUCT_TLVLEN(
17238 wmi_ndp_initiator_req_fixed_param));
17239 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
17240 cmd->transaction_id = ndp_req->transaction_id;
17241 cmd->service_instance_id = ndp_req->service_instance_id;
17242 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
17243 &cmd->peer_discovery_mac_addr);
17244
17245 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
17246 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
17247 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
17248 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
17249 cmd->nan_csid = ndp_req->ncs_sk_type;
17250 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
17251 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
17252
17253 ch_tlv = (wmi_channel *)&cmd[1];
17254 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
17255 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
17256 ch_tlv->mhz = ndp_req->channel;
17257 tlv_ptr = (uint8_t *)&ch_tlv[1];
17258
17259 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17260 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17261 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17262 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17263
17264 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17265 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17266 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
17267 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17268
17269 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17270 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
17271 cmd->nan_pmk_len);
17272 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17273
17274 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17275 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
17276 cmd->nan_passphrase_len);
17277 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17278
17279 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17280 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17281 ndp_req->service_name.service_name,
17282 cmd->nan_servicename_len);
17283 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17284
17285 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
17286 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
17287 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
17288 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
17289 cmd->peer_discovery_mac_addr.mac_addr31to0,
17290 cmd->peer_discovery_mac_addr.mac_addr47to32);
17291
17292 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
17293 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17294 ndp_req->ndp_config.ndp_cfg,
17295 ndp_req->ndp_config.ndp_cfg_len);
17296
17297 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
17298 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17299 ndp_req->ndp_info.ndp_app_info,
17300 ndp_req->ndp_info.ndp_app_info_len);
17301
17302 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17303 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17304 ndp_req->pmk.pmk, cmd->nan_pmk_len);
17305
17306 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17307 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17308 ndp_req->passphrase.passphrase,
17309 cmd->nan_passphrase_len);
17310
17311 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17312 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17313 ndp_req->service_name.service_name,
17314 cmd->nan_servicename_len);
17315
17316 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
17317 WMI_NDP_INITIATOR_REQ_CMDID);
17318
17319 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17320 WMI_NDP_INITIATOR_REQ_CMDID);
17321 if (QDF_IS_STATUS_ERROR(status)) {
17322 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
17323 wmi_buf_free(buf);
17324 }
17325
17326 return status;
17327}
17328
17329static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
17330 struct nan_datapath_responder_req *req)
17331{
17332 uint16_t len;
17333 wmi_buf_t buf;
17334 uint8_t *tlv_ptr;
17335 QDF_STATUS status;
17336 wmi_ndp_responder_req_fixed_param *cmd;
17337 uint32_t passphrase_len, service_name_len;
17338 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
17339
17340 vdev_id = wlan_vdev_get_id(req->vdev);
17341 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
17342 vdev_id, req->transaction_id,
17343 req->ndp_rsp,
17344 req->ndp_instance_id,
17345 req->ndp_info.ndp_app_info_len);
17346
17347 /*
17348 * WMI command expects 4 byte alligned len:
17349 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17350 */
17351 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
17352 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
17353 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
17354 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
17355 service_name_len =
17356 qdf_roundup(req->service_name.service_name_len, 4);
17357
17358 /* allocated memory for fixed params as well as variable size data */
17359 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
17360 + pmk_len + passphrase_len + service_name_len;
17361
17362 buf = wmi_buf_alloc(wmi_handle, len);
17363 if (!buf) {
17364 WMI_LOGE("wmi_buf_alloc failed");
17365 return QDF_STATUS_E_NOMEM;
17366 }
17367 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
17368 WMITLV_SET_HDR(&cmd->tlv_header,
17369 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
17370 WMITLV_GET_STRUCT_TLVLEN(
17371 wmi_ndp_responder_req_fixed_param));
17372 cmd->vdev_id = vdev_id;
17373 cmd->transaction_id = req->transaction_id;
17374 cmd->ndp_instance_id = req->ndp_instance_id;
17375 cmd->rsp_code = req->ndp_rsp;
17376 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
17377 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
17378 cmd->nan_pmk_len = req->pmk.pmk_len;
17379 cmd->nan_csid = req->ncs_sk_type;
17380 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
17381 cmd->nan_servicename_len = req->service_name.service_name_len;
17382
17383 tlv_ptr = (uint8_t *)&cmd[1];
17384 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17385 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17386 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17387
17388 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17389 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17390 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17391 req->ndp_info.ndp_app_info,
17392 req->ndp_info.ndp_app_info_len);
17393
17394 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17395 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17396 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
17397 cmd->nan_pmk_len);
17398
17399 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17400 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17401 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17402 req->passphrase.passphrase,
17403 cmd->nan_passphrase_len);
17404 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17405
17406 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17407 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17408 req->service_name.service_name,
17409 cmd->nan_servicename_len);
17410
17411 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17412
17413 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
17414 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
17415
17416 WMI_LOGD("ndp_config len: %d",
17417 req->ndp_config.ndp_cfg_len);
17418 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17419 req->ndp_config.ndp_cfg,
17420 req->ndp_config.ndp_cfg_len);
17421
17422 WMI_LOGD("ndp_app_info len: %d",
17423 req->ndp_info.ndp_app_info_len);
17424 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17425 req->ndp_info.ndp_app_info,
17426 req->ndp_info.ndp_app_info_len);
17427
17428 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17429 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17430 req->pmk.pmk, cmd->nan_pmk_len);
17431
17432 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17433 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17434 req->passphrase.passphrase,
17435 cmd->nan_passphrase_len);
17436
17437 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17438 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17439 req->service_name.service_name,
17440 cmd->nan_servicename_len);
17441
17442 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
17443 WMI_NDP_RESPONDER_REQ_CMDID);
17444 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17445 WMI_NDP_RESPONDER_REQ_CMDID);
17446 if (QDF_IS_STATUS_ERROR(status)) {
17447 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
17448 wmi_buf_free(buf);
17449 }
17450 return status;
17451}
17452
17453static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
17454 struct nan_datapath_end_req *req)
17455{
17456 uint16_t len;
17457 wmi_buf_t buf;
17458 QDF_STATUS status;
17459 uint32_t ndp_end_req_len, i;
17460 wmi_ndp_end_req *ndp_end_req_lst;
17461 wmi_ndp_end_req_fixed_param *cmd;
17462
17463 /* len of tlv following fixed param */
17464 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
17465 /* above comes out to 4 byte alligned already, no need of padding */
17466 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
17467 buf = wmi_buf_alloc(wmi_handle, len);
17468 if (!buf) {
17469 WMI_LOGE("Malloc failed");
17470 return QDF_STATUS_E_NOMEM;
17471 }
17472
17473 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
17474 WMITLV_SET_HDR(&cmd->tlv_header,
17475 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
17476 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
17477
17478 cmd->transaction_id = req->transaction_id;
17479
17480 /* set tlv pointer to end of fixed param */
17481 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
17482 ndp_end_req_len);
17483
17484 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
17485 WMI_TLV_HDR_SIZE);
17486 for (i = 0; i < req->num_ndp_instances; i++) {
17487 WMITLV_SET_HDR(&ndp_end_req_lst[i],
17488 WMITLV_TAG_ARRAY_FIXED_STRUC,
17489 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
17490
17491 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
17492 }
17493
17494 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
17495 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17496 WMI_NDP_END_REQ_CMDID);
17497 if (QDF_IS_STATUS_ERROR(status)) {
17498 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
17499 wmi_buf_free(buf);
17500 }
17501
17502 return status;
17503}
17504
17505static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
17506 uint8_t *data, struct nan_datapath_initiator_rsp **rsp)
17507{
17508 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
17509 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
17510
17511 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
17512 fixed_params = event->fixed_param;
17513
17514 *rsp = qdf_mem_malloc(sizeof(**rsp));
17515 if (!(*rsp)) {
17516 WMI_LOGE("malloc failed");
17517 return QDF_STATUS_E_NOMEM;
17518 }
17519
17520 (*rsp)->vdev =
17521 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17522 fixed_params->vdev_id,
17523 WLAN_NAN_ID);
17524 if (!(*rsp)->vdev) {
17525 WMI_LOGE("vdev is null");
17526 qdf_mem_free(*rsp);
17527 return QDF_STATUS_E_INVAL;
17528 }
17529
17530 (*rsp)->transaction_id = fixed_params->transaction_id;
17531 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17532 (*rsp)->status = fixed_params->rsp_status;
17533 (*rsp)->reason = fixed_params->reason_code;
17534
17535 return QDF_STATUS_SUCCESS;
17536}
17537
17538static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
17539 uint8_t *data, struct nan_datapath_indication_event **rsp)
17540{
17541 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
17542 wmi_ndp_indication_event_fixed_param *fixed_params;
17543
17544 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
17545 fixed_params =
17546 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
17547
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017548 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17549 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17550 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17551 return QDF_STATUS_E_INVAL;
17552 }
17553
17554 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17555 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17556 fixed_params->ndp_app_info_len,
17557 event->num_ndp_app_info);
17558 return QDF_STATUS_E_INVAL;
17559 }
17560
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017561 *rsp = qdf_mem_malloc(sizeof(**rsp));
17562 if (!(*rsp)) {
17563 WMI_LOGE("malloc failed");
17564 return QDF_STATUS_E_NOMEM;
17565 }
17566
17567 (*rsp)->vdev =
17568 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17569 fixed_params->vdev_id,
17570 WLAN_NAN_ID);
17571 if (!(*rsp)->vdev) {
17572 WMI_LOGE("vdev is null");
17573 qdf_mem_free(*rsp);
17574 return QDF_STATUS_E_INVAL;
17575 }
17576 (*rsp)->service_instance_id = fixed_params->service_instance_id;
17577 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17578 (*rsp)->role = fixed_params->self_ndp_role;
17579 (*rsp)->policy = fixed_params->accept_policy;
17580
17581 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17582 (*rsp)->peer_mac_addr.bytes);
17583 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
17584 (*rsp)->peer_discovery_mac_addr.bytes);
17585
17586 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
17587 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
17588 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
17589 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
17590 fixed_params->service_instance_id,
17591 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
17592 fixed_params->accept_policy,
17593 fixed_params->nan_csid, fixed_params->nan_scid_len,
17594 (*rsp)->peer_mac_addr.bytes,
17595 (*rsp)->peer_discovery_mac_addr.bytes);
17596
17597 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17598 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17599 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17600
17601 WMI_LOGD("ndp_app_info - %d bytes",
17602 fixed_params->ndp_app_info_len);
17603 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17604 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17605
17606 (*rsp)->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
17607 (*rsp)->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17608 (*rsp)->ncs_sk_type = fixed_params->nan_csid;
17609 (*rsp)->scid.scid_len = fixed_params->nan_scid_len;
17610 qdf_mem_copy((*rsp)->ndp_config.ndp_cfg, event->ndp_cfg,
17611 (*rsp)->ndp_config.ndp_cfg_len);
17612 qdf_mem_copy((*rsp)->ndp_info.ndp_app_info, event->ndp_app_info,
17613 (*rsp)->ndp_info.ndp_app_info_len);
17614 qdf_mem_copy((*rsp)->scid.scid, event->ndp_scid, (*rsp)->scid.scid_len);
17615 WMI_LOGD("scid hex dump:");
17616 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17617 (*rsp)->scid.scid, (*rsp)->scid.scid_len);
17618
17619 return QDF_STATUS_SUCCESS;
17620}
17621
17622static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
17623 uint8_t *data, struct nan_datapath_confirm_event **rsp)
17624{
17625 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
17626 wmi_ndp_confirm_event_fixed_param *fixed_params;
17627
17628 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
17629 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
17630 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",
17631 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
17632 fixed_params->ndp_instance_id, fixed_params->rsp_code,
17633 fixed_params->reason_code,
17634 fixed_params->num_active_ndps_on_peer);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017635
17636 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17637 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17638 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17639 return QDF_STATUS_E_INVAL;
17640 }
17641
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017642 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17643 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17644 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17645
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017646 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17647 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17648 fixed_params->ndp_app_info_len,
17649 event->num_ndp_app_info);
17650 return QDF_STATUS_E_INVAL;
17651 }
17652
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017653 WMI_LOGD("ndp_app_info - %d bytes",
17654 fixed_params->ndp_app_info_len);
17655 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17656 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17657
17658 *rsp = qdf_mem_malloc(sizeof(**rsp));
17659 if (!(*rsp)) {
17660 WMI_LOGE("malloc failed");
17661 return QDF_STATUS_E_NOMEM;
17662 }
17663
17664 (*rsp)->vdev =
17665 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17666 fixed_params->vdev_id,
17667 WLAN_NAN_ID);
17668 if (!(*rsp)->vdev) {
17669 WMI_LOGE("vdev is null");
17670 qdf_mem_free(*rsp);
17671 return QDF_STATUS_E_INVAL;
17672 }
17673 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17674 (*rsp)->rsp_code = fixed_params->rsp_code;
17675 (*rsp)->reason_code = fixed_params->reason_code;
17676 (*rsp)->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
17677 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17678 (*rsp)->peer_ndi_mac_addr.bytes);
17679 (*rsp)->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17680 qdf_mem_copy((*rsp)->ndp_info.ndp_app_info, event->ndp_app_info,
17681 (*rsp)->ndp_info.ndp_app_info_len);
17682
17683 return QDF_STATUS_SUCCESS;
17684}
17685
17686static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
17687 uint8_t *data, struct nan_datapath_responder_rsp **rsp)
17688{
17689 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17690 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17691
17692 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17693 fixed_params = event->fixed_param;
17694
17695 WMI_LOGD("WMI_NDP_RESPONDER_RSP_EVENTID(0x%X) received. vdev_id: %d, peer_mac_addr: %pM,transaction_id: %d, status_code %d, reason_code: %d, create_peer: %d",
17696 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
17697 (*rsp)->peer_mac_addr.bytes, (*rsp)->transaction_id,
17698 (*rsp)->status, (*rsp)->reason, (*rsp)->create_peer);
17699
17700 *rsp = qdf_mem_malloc(sizeof(**rsp));
17701 if (!(*rsp)) {
17702 WMI_LOGE("malloc failed");
17703 return QDF_STATUS_E_NOMEM;
17704 }
17705
17706 (*rsp)->vdev =
17707 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17708 fixed_params->vdev_id,
17709 WLAN_NAN_ID);
17710 if (!(*rsp)->vdev) {
17711 WMI_LOGE("vdev is null");
17712 qdf_mem_free(*rsp);
17713 return QDF_STATUS_E_INVAL;
17714 }
17715 (*rsp)->transaction_id = fixed_params->transaction_id;
17716 (*rsp)->reason = fixed_params->reason_code;
17717 (*rsp)->status = fixed_params->rsp_status;
17718 (*rsp)->create_peer = fixed_params->create_peer;
17719 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17720 (*rsp)->peer_mac_addr.bytes);
17721
17722 return QDF_STATUS_SUCCESS;
17723}
17724
17725static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
17726 uint8_t *data, struct nan_datapath_end_rsp_event **rsp)
17727{
17728 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17729 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17730
17731 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17732 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
17733 WMI_LOGD("WMI_NDP_END_RSP_EVENTID(0x%X) recieved. transaction_id: %d, rsp_status: %d, reason_code: %d",
17734 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17735 fixed_params->rsp_status, fixed_params->reason_code);
17736
17737 *rsp = qdf_mem_malloc(sizeof(**rsp));
17738 if (!(*rsp)) {
17739 WMI_LOGE("malloc failed");
17740 return QDF_STATUS_E_NOMEM;
17741 }
17742
17743 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17744 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17745 if (!(*rsp)->vdev) {
17746 WMI_LOGE("vdev is null");
17747 qdf_mem_free(*rsp);
17748 return QDF_STATUS_E_INVAL;
17749 }
17750 (*rsp)->transaction_id = fixed_params->transaction_id;
17751 (*rsp)->reason = fixed_params->reason_code;
17752 (*rsp)->status = fixed_params->rsp_status;
17753
17754 return QDF_STATUS_SUCCESS;
17755}
17756
17757static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17758 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17759{
17760 uint32_t i, buf_size;
17761 wmi_ndp_end_indication *ind;
17762 struct qdf_mac_addr peer_addr;
17763 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17764
17765 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17766 ind = event->ndp_end_indication_list;
17767
17768 if (event->num_ndp_end_indication_list == 0) {
17769 WMI_LOGE("Error: Event ignored, 0 ndp instances");
17770 return -EINVAL;
17771 }
17772
17773 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17774 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17775 if (!(*rsp)->vdev) {
17776 WMI_LOGE("vdev is null");
17777 qdf_mem_free(*rsp);
17778 return QDF_STATUS_E_INVAL;
17779 }
17780
17781 WMI_LOGD("number of ndp instances = %d",
17782 event->num_ndp_end_indication_list);
17783 buf_size = sizeof(*rsp) + event->num_ndp_end_indication_list *
17784 sizeof((*rsp)->ndp_map[0]);
17785 *rsp = qdf_mem_malloc(buf_size);
17786 if (!(*rsp)) {
17787 WMI_LOGE("Failed to allocate memory");
17788 return -ENOMEM;
17789 }
17790
17791 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17792 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17793 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17794 peer_addr.bytes);
17795 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17796 i, ind[i].type, ind[i].reason_code,
17797 ind[i].ndp_instance_id,
17798 ind[i].num_active_ndps_on_peer);
17799 /* Add each instance entry to the list */
17800 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17801 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17802 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17803 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17804 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17805 ind[i].num_active_ndps_on_peer;
17806 (*rsp)->ndp_map[i].type = ind[i].type;
17807 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17808 }
17809
17810 return QDF_STATUS_SUCCESS;
17811}
17812#endif
17813
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017814/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017815 * save_service_bitmap_tlv() - save service bitmap
17816 * @wmi_handle: wmi handle
17817 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017818 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017819 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017820 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017821 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017822static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017823QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017824 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017825{
17826 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017827 struct wmi_soc *soc = wmi_handle->soc;
17828
Govind Singhe7f2f342016-05-23 12:12:52 +053017829 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17830
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017831 /* If it is already allocated, use that buffer. This can happen
17832 * during target stop/start scenarios where host allocation is skipped.
17833 */
17834 if (!soc->wmi_service_bitmap) {
17835 soc->wmi_service_bitmap =
17836 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17837 if (!soc->wmi_service_bitmap) {
17838 WMI_LOGE("Failed memory allocation for service bitmap");
17839 return QDF_STATUS_E_NOMEM;
17840 }
17841 }
17842
17843 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017844 param_buf->wmi_service_bitmap,
17845 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017846
17847 if (bitmap_buf)
17848 qdf_mem_copy(bitmap_buf,
17849 param_buf->wmi_service_bitmap,
17850 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017851
17852 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017853}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017854
17855/**
17856 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17857 * @wmi_handle: wmi handle
17858 * @param evt_buf: pointer to event buffer
17859 * @param bitmap_buf: bitmap buffer, for converged legacy support
17860 *
17861 * Return: QDF_STATUS
17862 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017863static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017864QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017865 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017866{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017867 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17868 wmi_service_available_event_fixed_param *ev;
17869 struct wmi_soc *soc = wmi_handle->soc;
17870
17871 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17872
17873 ev = param_buf->fixed_param;
17874
17875 /* If it is already allocated, use that buffer. This can happen
17876 * during target stop/start scenarios where host allocation is skipped.
17877 */
17878 if (!soc->wmi_ext_service_bitmap) {
17879 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17880 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17881 if (!soc->wmi_ext_service_bitmap) {
17882 WMI_LOGE("Failed memory allocation for service bitmap");
17883 return QDF_STATUS_E_NOMEM;
17884 }
17885 }
17886
17887 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17888 ev->wmi_service_segment_bitmap,
17889 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017890
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017891 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17892 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17893 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17894
Rajeev Kumar77901472017-02-12 02:12:17 -080017895 if (bitmap_buf)
17896 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017897 soc->wmi_ext_service_bitmap,
17898 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017899
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017900 return QDF_STATUS_SUCCESS;
17901}
Govind Singhe7f2f342016-05-23 12:12:52 +053017902/**
17903 * is_service_enabled_tlv() - Check if service enabled
17904 * @param wmi_handle: wmi handle
17905 * @param service_id: service identifier
17906 *
17907 * Return: 1 enabled, 0 disabled
17908 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017909static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17910 uint32_t service_id)
17911{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017912 struct wmi_soc *soc = wmi_handle->soc;
17913
17914 if (!soc->wmi_service_bitmap) {
17915 WMI_LOGE("WMI service bit map is not saved yet\n");
17916 return false;
17917 }
17918
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017919 /* if wmi_service_enabled was received with extended bitmap,
17920 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017921 */
17922 if (soc->wmi_ext_service_bitmap)
17923 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17924 soc->wmi_ext_service_bitmap,
17925 service_id);
17926
17927 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17928 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017929}
Govind Singhe7f2f342016-05-23 12:12:52 +053017930
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017931static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17932 struct wlan_psoc_target_capability_info *cap)
17933{
17934 /* except LDPC all flags are common betwen legacy and here
17935 * also IBFEER is not defined for TLV
17936 */
17937 cap->ht_cap_info |= ev_target_cap & (
17938 WMI_HT_CAP_ENABLED
17939 | WMI_HT_CAP_HT20_SGI
17940 | WMI_HT_CAP_DYNAMIC_SMPS
17941 | WMI_HT_CAP_TX_STBC
17942 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17943 | WMI_HT_CAP_RX_STBC
17944 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17945 | WMI_HT_CAP_LDPC
17946 | WMI_HT_CAP_L_SIG_TXOP_PROT
17947 | WMI_HT_CAP_MPDU_DENSITY
17948 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17949 | WMI_HT_CAP_HT40_SGI);
17950 if (ev_target_cap & WMI_HT_CAP_LDPC)
17951 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17952 WMI_HOST_HT_CAP_TX_LDPC;
17953}
Govind Singhe7f2f342016-05-23 12:12:52 +053017954/**
17955 * extract_service_ready_tlv() - extract service ready event
17956 * @wmi_handle: wmi handle
17957 * @param evt_buf: pointer to received event buffer
17958 * @param cap: pointer to hold target capability information extracted from even
17959 *
17960 * Return: QDF_STATUS_SUCCESS for success or error code
17961 */
17962static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017963 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017964{
17965 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17966 wmi_service_ready_event_fixed_param *ev;
17967
17968
17969 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17970
17971 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17972 if (!ev) {
17973 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17974 return QDF_STATUS_E_FAILURE;
17975 }
17976
17977 cap->phy_capability = ev->phy_capability;
17978 cap->max_frag_entry = ev->max_frag_entry;
17979 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017980 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017981 cap->vht_cap_info = ev->vht_cap_info;
17982 cap->vht_supp_mcs = ev->vht_supp_mcs;
17983 cap->hw_min_tx_power = ev->hw_min_tx_power;
17984 cap->hw_max_tx_power = ev->hw_max_tx_power;
17985 cap->sys_cap_info = ev->sys_cap_info;
17986 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17987 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17988 cap->max_num_scan_channels = ev->max_num_scan_channels;
17989 cap->max_supported_macs = ev->max_supported_macs;
17990 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17991 cap->txrx_chainmask = ev->txrx_chainmask;
17992 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17993 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017994 cap->fw_version = ev->fw_build_vers;
17995 /* fw_version_1 is not available in TLV. */
17996 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017997
17998 return QDF_STATUS_SUCCESS;
17999}
18000
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018001/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
18002 * to host internal WMI_HOST_REGDMN_MODE values.
18003 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
18004 * host currently. Add this in the future if required.
18005 * 11AX (Phase II) : 11ax related values are not currently
18006 * advertised separately by FW. As part of phase II regulatory bring-up,
18007 * finalize the advertisement mechanism.
18008 * @target_wireless_mode: target wireless mode received in message
18009 *
18010 * Return: returns the host internal wireless mode.
18011 */
18012static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
18013{
18014
18015 uint32_t wireless_modes = 0;
18016
18017 if (target_wireless_mode & REGDMN_MODE_11A)
18018 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
18019
18020 if (target_wireless_mode & REGDMN_MODE_TURBO)
18021 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
18022
18023 if (target_wireless_mode & REGDMN_MODE_11B)
18024 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
18025
18026 if (target_wireless_mode & REGDMN_MODE_PUREG)
18027 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
18028
18029 if (target_wireless_mode & REGDMN_MODE_11G)
18030 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
18031
18032 if (target_wireless_mode & REGDMN_MODE_108G)
18033 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
18034
18035 if (target_wireless_mode & REGDMN_MODE_108A)
18036 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
18037
18038 if (target_wireless_mode & REGDMN_MODE_XR)
18039 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
18040
18041 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
18042 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
18043
18044 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
18045 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
18046
18047 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
18048 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
18049
18050 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
18051 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
18052
18053 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
18054 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
18055
18056 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
18057 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
18058
18059 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
18060 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
18061
18062 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
18063 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
18064
18065 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
18066 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
18067
18068 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
18069 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
18070
18071 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
18072 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
18073
18074 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
18075 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
18076
18077 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
18078 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
18079
18080 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
18081 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
18082
18083 return wireless_modes;
18084}
18085
Govind Singhe7f2f342016-05-23 12:12:52 +053018086/**
18087 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
18088 * @wmi_handle: wmi handle
18089 * @param evt_buf: Pointer to event buffer
18090 * @param cap: pointer to hold HAL reg capabilities
18091 *
18092 * Return: QDF_STATUS_SUCCESS for success or error code
18093 */
18094static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018095 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053018096{
18097 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18098
18099 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18100
18101 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
18102 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080018103 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053018104
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018105 cap->wireless_modes = convert_wireless_modes_tlv(
18106 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053018107
Govind Singhe7f2f342016-05-23 12:12:52 +053018108 return QDF_STATUS_SUCCESS;
18109}
18110
18111/**
18112 * extract_host_mem_req_tlv() - Extract host memory request event
18113 * @wmi_handle: wmi handle
18114 * @param evt_buf: pointer to event buffer
18115 * @param num_entries: pointer to hold number of entries requested
18116 *
18117 * Return: Number of entries requested
18118 */
18119static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
18120 void *evt_buf, uint8_t *num_entries)
18121{
18122 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18123 wmi_service_ready_event_fixed_param *ev;
18124
18125 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18126
18127 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18128 if (!ev) {
18129 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18130 return NULL;
18131 }
18132
18133 *num_entries = ev->num_mem_reqs;
18134
18135 return (host_mem_req *)param_buf->mem_reqs;
18136}
18137
18138/**
18139 * save_fw_version_in_service_ready_tlv() - Save fw version in service
18140 * ready function
18141 * @wmi_handle: wmi handle
18142 * @param evt_buf: pointer to event buffer
18143 *
18144 * Return: QDF_STATUS_SUCCESS for success or error code
18145 */
18146static QDF_STATUS
18147save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
18148{
18149 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18150 wmi_service_ready_event_fixed_param *ev;
18151
18152
18153 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18154
18155 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18156 if (!ev) {
18157 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18158 return QDF_STATUS_E_FAILURE;
18159 }
18160
18161 /*Save fw version from service ready message */
18162 /*This will be used while sending INIT message */
18163 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
18164 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053018165
Govind Singhe7f2f342016-05-23 12:12:52 +053018166 return QDF_STATUS_SUCCESS;
18167}
18168
18169/**
18170 * ready_extract_init_status_tlv() - Extract init status from ready event
18171 * @wmi_handle: wmi handle
18172 * @param evt_buf: Pointer to event buffer
18173 *
18174 * Return: ready status
18175 */
18176static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
18177 void *evt_buf)
18178{
18179 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18180 wmi_ready_event_fixed_param *ev = NULL;
18181
Govind Singhe7f2f342016-05-23 12:12:52 +053018182 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18183 ev = param_buf->fixed_param;
18184
18185 qdf_print("%s:%d\n", __func__, ev->status);
18186
18187 return ev->status;
18188}
18189
18190/**
18191 * ready_extract_mac_addr_tlv() - extract mac address from ready event
18192 * @wmi_handle: wmi handle
18193 * @param evt_buf: pointer to event buffer
18194 * @param macaddr: Pointer to hold MAC address
18195 *
18196 * Return: QDF_STATUS_SUCCESS for success or error code
18197 */
18198static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
18199 void *evt_buf, uint8_t *macaddr)
18200{
18201 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18202 wmi_ready_event_fixed_param *ev = NULL;
18203
18204
18205 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18206 ev = param_buf->fixed_param;
18207
18208 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
18209
18210 return QDF_STATUS_SUCCESS;
18211}
18212
18213/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070018214 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
18215 * @wmi_handle: wmi handle
18216 * @param evt_buf: pointer to event buffer
18217 * @param macaddr: Pointer to hold number of MAC addresses
18218 *
18219 * Return: Pointer to addr list
18220 */
18221static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
18222 void *evt_buf, uint8_t *num_mac)
18223{
18224 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18225 wmi_ready_event_fixed_param *ev = NULL;
18226
18227 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18228 ev = param_buf->fixed_param;
18229
18230 *num_mac = ev->num_extra_mac_addr;
18231
18232 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
18233}
18234
18235/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018236 * extract_ready_params_tlv() - Extract data from ready event apart from
18237 * status, macaddr and version.
18238 * @wmi_handle: Pointer to WMI handle.
18239 * @evt_buf: Pointer to Ready event buffer.
18240 * @ev_param: Pointer to host defined struct to copy the data from event.
18241 *
18242 * Return: QDF_STATUS_SUCCESS on success.
18243 */
18244static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
18245 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
18246{
18247 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18248 wmi_ready_event_fixed_param *ev = NULL;
18249
18250 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18251 ev = param_buf->fixed_param;
18252
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018253 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018254 ev_param->num_dscp_table = ev->num_dscp_table;
18255 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
18256 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018257 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018258 /* Agile_cap in ready event is not supported in TLV target */
18259 ev_param->agile_capability = false;
18260
18261 return QDF_STATUS_SUCCESS;
18262}
18263
18264/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018265 * extract_dbglog_data_len_tlv() - extract debuglog data length
18266 * @wmi_handle: wmi handle
18267 * @param evt_buf: pointer to event buffer
18268 *
18269 * Return: length
18270 */
18271static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080018272 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053018273{
18274 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
18275
18276 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
18277
18278 *len = param_buf->num_bufp;
18279
18280 return param_buf->bufp;
18281}
18282
18283/**
18284 * extract_vdev_start_resp_tlv() - extract vdev start response
18285 * @wmi_handle: wmi handle
18286 * @param evt_buf: pointer to event buffer
18287 * @param vdev_rsp: Pointer to hold vdev response
18288 *
18289 * Return: QDF_STATUS_SUCCESS for success or error code
18290 */
18291static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
18292 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
18293{
18294 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
18295 wmi_vdev_start_response_event_fixed_param *ev;
18296
18297 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
18298 if (!param_buf) {
18299 qdf_print("Invalid start response event buffer\n");
18300 return QDF_STATUS_E_INVAL;
18301 }
18302
18303 ev = param_buf->fixed_param;
18304 if (!ev) {
18305 qdf_print("Invalid start response event buffer\n");
18306 return QDF_STATUS_E_INVAL;
18307 }
18308
18309 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
18310
18311 vdev_rsp->vdev_id = ev->vdev_id;
18312 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070018313 switch (ev->resp_type) {
18314 case WMI_VDEV_START_RESP_EVENT:
18315 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
18316 break;
18317 case WMI_VDEV_RESTART_RESP_EVENT:
18318 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
18319 break;
18320 default:
18321 qdf_print("Invalid start response event buffer\n");
18322 break;
18323 };
Govind Singhe7f2f342016-05-23 12:12:52 +053018324 vdev_rsp->status = ev->status;
18325 vdev_rsp->chain_mask = ev->chain_mask;
18326 vdev_rsp->smps_mode = ev->smps_mode;
18327 vdev_rsp->mac_id = ev->mac_id;
18328 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
18329 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
18330
18331 return QDF_STATUS_SUCCESS;
18332}
18333
18334/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053018335 * extract_vdev_delete_resp_tlv() - extract vdev delete response
18336 * @wmi_handle: wmi handle
18337 * @param evt_buf: pointer to event buffer
18338 * @param delete_rsp: Pointer to hold vdev delete response
18339 *
18340 * Return: QDF_STATUS_SUCCESS for success or error code
18341 */
18342static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
18343 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
18344{
18345 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
18346 wmi_vdev_delete_resp_event_fixed_param *ev;
18347
18348 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
18349 if (!param_buf) {
18350 WMI_LOGE("Invalid vdev delete response event buffer\n");
18351 return QDF_STATUS_E_INVAL;
18352 }
18353
18354 ev = param_buf->fixed_param;
18355 if (!ev) {
18356 WMI_LOGE("Invalid vdev delete response event\n");
18357 return QDF_STATUS_E_INVAL;
18358 }
18359
18360 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
18361 delete_rsp->vdev_id = ev->vdev_id;
18362
18363 return QDF_STATUS_SUCCESS;
18364}
18365
18366
18367/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018368 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053018369 * @wmi_handle: wmi handle
18370 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018371 * @param num_vdevs: Pointer to hold num vdev
18372 *
18373 * Return: QDF_STATUS_SUCCESS for success or error code
18374 */
18375static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18376 void *evt_buf, uint32_t *num_vdevs)
18377{
18378 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18379 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
18380 uint32_t vdev_map;
18381
18382 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
18383 if (!param_buf) {
18384 qdf_print("Invalid tbtt update ext event buffer\n");
18385 return QDF_STATUS_E_INVAL;
18386 }
18387 tbtt_offset_event = param_buf->fixed_param;
18388 vdev_map = tbtt_offset_event->vdev_map;
18389 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18390
18391 return QDF_STATUS_SUCCESS;
18392}
18393
18394/**
18395 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
18396 * @wmi_handle: wmi handle
18397 * @param evt_buf: pointer to event buffer
18398 * @param num_vdevs: Pointer to hold num vdev
18399 *
18400 * Return: QDF_STATUS_SUCCESS for success or error code
18401 */
18402static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18403 void *evt_buf, uint32_t *num_vdevs)
18404{
18405 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18406 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
18407
18408 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18409 if (!param_buf) {
18410 qdf_print("Invalid tbtt update ext event buffer\n");
18411 return QDF_STATUS_E_INVAL;
18412 }
18413 tbtt_offset_ext_event = param_buf->fixed_param;
18414
18415 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
18416
18417 return QDF_STATUS_SUCCESS;
18418}
18419
18420/**
18421 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
18422 * @wmi_handle: wmi handle
18423 * @param evt_buf: pointer to event buffer
18424 * @param idx: Index refering to a vdev
18425 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053018426 *
18427 * Return: QDF_STATUS_SUCCESS for success or error code
18428 */
18429static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018430 void *evt_buf, uint8_t idx,
18431 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018432{
18433 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18434 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018435 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018436
18437 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
18438 if (!param_buf) {
18439 qdf_print("Invalid tbtt update event buffer\n");
18440 return QDF_STATUS_E_INVAL;
18441 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018442
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018443 tbtt_offset_event = param_buf->fixed_param;
18444 vdev_map = tbtt_offset_event->vdev_map;
18445 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
18446 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
18447 return QDF_STATUS_E_INVAL;
18448 tbtt_param->tbttoffset =
18449 param_buf->tbttoffset_list[tbtt_param->vdev_id];
18450
18451 return QDF_STATUS_SUCCESS;
18452}
18453
18454/**
18455 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
18456 * @wmi_handle: wmi handle
18457 * @param evt_buf: pointer to event buffer
18458 * @param idx: Index refering to a vdev
18459 * @param tbtt_param: Pointer to tbttoffset event param
18460 *
18461 * Return: QDF_STATUS_SUCCESS for success or error code
18462 */
18463static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
18464 void *evt_buf, uint8_t idx,
18465 struct tbttoffset_params *tbtt_param)
18466{
18467 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18468 wmi_tbtt_offset_info *tbtt_offset_info;
18469
18470 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18471 if (!param_buf) {
18472 qdf_print("Invalid tbtt update event buffer\n");
18473 return QDF_STATUS_E_INVAL;
18474 }
18475 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
18476
18477 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
18478 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053018479
18480 return QDF_STATUS_SUCCESS;
18481}
18482
18483/**
18484 * extract_mgmt_rx_params_tlv() - extract management rx params from event
18485 * @wmi_handle: wmi handle
18486 * @param evt_buf: pointer to event buffer
18487 * @param hdr: Pointer to hold header
18488 * @param bufp: Pointer to hold pointer to rx param buffer
18489 *
18490 * Return: QDF_STATUS_SUCCESS for success or error code
18491 */
18492static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053018493 void *evt_buf, struct mgmt_rx_event_params *hdr,
18494 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053018495{
18496 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
18497 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018498 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053018499
18500 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
18501 if (!param_tlvs) {
18502 WMI_LOGE("Get NULL point message from FW");
18503 return QDF_STATUS_E_INVAL;
18504 }
18505
18506 ev_hdr = param_tlvs->hdr;
18507 if (!hdr) {
18508 WMI_LOGE("Rx event is NULL");
18509 return QDF_STATUS_E_INVAL;
18510 }
18511
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018512 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18513 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018514
18515 hdr->channel = ev_hdr->channel;
18516 hdr->snr = ev_hdr->snr;
18517 hdr->rate = ev_hdr->rate;
18518 hdr->phy_mode = ev_hdr->phy_mode;
18519 hdr->buf_len = ev_hdr->buf_len;
18520 hdr->status = ev_hdr->status;
18521 hdr->flags = ev_hdr->flags;
18522 hdr->rssi = ev_hdr->rssi;
18523 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018524 for (i = 0; i < ATH_MAX_ANTENNA; i++)
18525 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053018526
18527 *bufp = param_tlvs->bufp;
18528
18529 return QDF_STATUS_SUCCESS;
18530}
18531
18532/**
18533 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
18534 * @wmi_handle: wmi handle
18535 * @param evt_buf: pointer to event buffer
18536 * @param vdev_id: Pointer to hold vdev identifier
18537 *
18538 * Return: QDF_STATUS_SUCCESS for success or error code
18539 */
18540static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
18541 void *evt_buf, uint32_t *vdev_id)
18542{
18543 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
18544 wmi_vdev_stopped_event_fixed_param *resp_event;
18545
18546 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
18547 if (!param_buf) {
18548 WMI_LOGE("Invalid event buffer");
18549 return QDF_STATUS_E_INVAL;
18550 }
18551 resp_event = param_buf->fixed_param;
18552 *vdev_id = resp_event->vdev_id;
18553
18554 return QDF_STATUS_SUCCESS;
18555}
18556
18557/**
18558 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
18559 * @wmi_handle: wmi handle
18560 * @param evt_buf: pointer to event buffer
18561 * @param param: Pointer to hold roam param
18562 *
18563 * Return: QDF_STATUS_SUCCESS for success or error code
18564 */
18565static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
18566 void *evt_buf, wmi_host_roam_event *param)
18567{
18568 WMI_ROAM_EVENTID_param_tlvs *param_buf;
18569 wmi_roam_event_fixed_param *evt;
18570
18571 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18572 if (!param_buf) {
18573 WMI_LOGE("Invalid roam event buffer");
18574 return QDF_STATUS_E_INVAL;
18575 }
18576
18577 evt = param_buf->fixed_param;
18578 qdf_mem_zero(param, sizeof(*param));
18579
18580 param->vdev_id = evt->vdev_id;
18581 param->reason = evt->reason;
18582 param->rssi = evt->rssi;
18583
18584 return QDF_STATUS_SUCCESS;
18585}
18586
18587/**
18588 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18589 * @wmi_handle: wmi handle
18590 * @param evt_buf: pointer to event buffer
18591 * @param param: Pointer to hold vdev scan param
18592 *
18593 * Return: QDF_STATUS_SUCCESS for success or error code
18594 */
18595static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018596 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018597{
18598 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18599 wmi_scan_event_fixed_param *evt = NULL;
18600
18601 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18602 evt = param_buf->fixed_param;
18603
18604 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018605
Govind Singhe7f2f342016-05-23 12:12:52 +053018606 switch (evt->event) {
18607 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018608 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018609 break;
18610 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018611 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018612 break;
18613 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018614 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018615 break;
18616 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018617 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018618 break;
18619 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018620 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018621 break;
18622 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018623 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018624 break;
18625 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018626 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018627 break;
18628 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018629 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018630 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018631 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018632 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018633 break;
18634 case WMI_SCAN_EVENT_MAX:
18635 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018636 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018637 break;
18638 };
18639
18640 switch (evt->reason) {
18641 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018642 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018643 break;
18644 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018645 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018646 break;
18647 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018648 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018649 break;
18650 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018651 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018652 break;
18653 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018654 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018655 break;
18656 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018657 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018658 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018659 case WMI_SCAN_REASON_SUSPENDED:
18660 param->reason = SCAN_REASON_SUSPENDED;
18661 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018662 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018663 param->reason = SCAN_REASON_MAX;
18664 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018665 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018666 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018667 break;
18668 };
18669
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018670 param->chan_freq = evt->channel_freq;
18671 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018672 param->scan_id = evt->scan_id;
18673 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018674 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018675
18676 return QDF_STATUS_SUCCESS;
18677}
18678
Frank Liu3d5e9992017-03-15 17:51:43 +080018679#ifdef CONVERGED_TDLS_ENABLE
18680/**
18681 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18682 * @wmi_handle: wmi handle
18683 * @param evt_buf: pointer to event buffer
18684 * @param param: Pointer to hold vdev tdls param
18685 *
18686 * Return: QDF_STATUS_SUCCESS for success or error code
18687 */
18688static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18689 void *evt_buf, struct tdls_event_info *param)
18690{
18691 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18692 wmi_tdls_peer_event_fixed_param *evt;
18693
18694 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18695 if (!param_buf) {
18696 WMI_LOGE("%s: NULL param_buf", __func__);
18697 return QDF_STATUS_E_NULL_VALUE;
18698 }
18699
18700 evt = param_buf->fixed_param;
18701
18702 qdf_mem_zero(param, sizeof(*param));
18703
18704 param->vdev_id = evt->vdev_id;
18705 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18706 param->peermac.bytes);
18707 switch (evt->peer_status) {
18708 case WMI_TDLS_SHOULD_DISCOVER:
18709 param->message_type = TDLS_SHOULD_DISCOVER;
18710 break;
18711 case WMI_TDLS_SHOULD_TEARDOWN:
18712 param->message_type = TDLS_SHOULD_TEARDOWN;
18713 break;
18714 case WMI_TDLS_PEER_DISCONNECTED:
18715 param->message_type = TDLS_PEER_DISCONNECTED;
18716 break;
18717 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18718 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18719 break;
18720 default:
18721 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18722 __func__, evt->peer_status);
18723 return QDF_STATUS_E_INVAL;
18724 };
18725
18726 switch (evt->peer_reason) {
18727 case WMI_TDLS_TEARDOWN_REASON_TX:
18728 param->peer_reason = TDLS_TEARDOWN_TX;
18729 break;
18730 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18731 param->peer_reason = TDLS_TEARDOWN_RSSI;
18732 break;
18733 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18734 param->peer_reason = TDLS_TEARDOWN_SCAN;
18735 break;
18736 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18737 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18738 break;
18739 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18740 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18741 break;
18742 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18743 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18744 break;
18745 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18746 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18747 break;
18748 case WMI_TDLS_ENTER_BUF_STA:
18749 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18750 break;
18751 case WMI_TDLS_EXIT_BUF_STA:
18752 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18753 break;
18754 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18755 param->peer_reason = TDLS_ENTER_BT_BUSY;
18756 break;
18757 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18758 param->peer_reason = TDLS_EXIT_BT_BUSY;
18759 break;
18760 case WMI_TDLS_SCAN_STARTED_EVENT:
18761 param->peer_reason = TDLS_SCAN_STARTED;
18762 break;
18763 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18764 param->peer_reason = TDLS_SCAN_COMPLETED;
18765 break;
18766
18767 default:
18768 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18769 __func__, evt->peer_reason, evt->peer_status);
18770 return QDF_STATUS_E_INVAL;
18771 };
18772
18773 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18774 __func__, param->peermac.bytes, param->message_type,
18775 param->peer_reason, param->vdev_id);
18776
18777 return QDF_STATUS_SUCCESS;
18778}
18779#endif
18780
Govind Singhe7f2f342016-05-23 12:12:52 +053018781/**
18782 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18783 * @wmi_handle: wmi handle
18784 * @param evt_buf: pointer to event buffer
18785 * @param param: Pointer to hold MGMT TX completion params
18786 *
18787 * Return: QDF_STATUS_SUCCESS for success or error code
18788 */
18789static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18790 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18791{
18792 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18793 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18794
18795 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18796 evt_buf;
18797 if (!param_buf) {
18798 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18799 return QDF_STATUS_E_INVAL;
18800 }
18801 cmpl_params = param_buf->fixed_param;
18802
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018803 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18804 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018805 param->desc_id = cmpl_params->desc_id;
18806 param->status = cmpl_params->status;
18807
18808 return QDF_STATUS_SUCCESS;
18809}
18810
18811/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018812 * extract_offchan_data_tx_compl_param_tlv() -
18813 * extract Offchan data tx completion event params
18814 * @wmi_handle: wmi handle
18815 * @param evt_buf: pointer to event buffer
18816 * @param param: Pointer to hold offchan data TX completion params
18817 *
18818 * Return: QDF_STATUS_SUCCESS for success or error code
18819 */
18820static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18821 wmi_unified_t wmi_handle, void *evt_buf,
18822 struct wmi_host_offchan_data_tx_compl_event *param)
18823{
18824 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18825 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18826
18827 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18828 evt_buf;
18829 if (!param_buf) {
18830 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18831 return QDF_STATUS_E_INVAL;
18832 }
18833 cmpl_params = param_buf->fixed_param;
18834
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018835 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18836 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018837 param->desc_id = cmpl_params->desc_id;
18838 param->status = cmpl_params->status;
18839
18840 return QDF_STATUS_SUCCESS;
18841}
18842
18843/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018844 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18845 * status tlv
18846 * @wmi_handle: wmi handle
18847 * @param evt_buf: pointer to event buffer
18848 * @param param: Pointer to hold csa switch count status event param
18849 *
18850 * Return: QDF_STATUS_SUCCESS for success or error code
18851 */
18852static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18853 wmi_unified_t wmi_handle,
18854 void *evt_buf,
18855 struct pdev_csa_switch_count_status *param)
18856{
18857 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18858 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18859
18860 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18861 evt_buf;
18862 if (!param_buf) {
18863 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18864 return QDF_STATUS_E_INVAL;
18865 }
18866
18867 csa_status = param_buf->fixed_param;
18868
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018869 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18870 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018871 param->current_switch_count = csa_status->current_switch_count;
18872 param->num_vdevs = csa_status->num_vdevs;
18873 param->vdev_ids = param_buf->vdev_ids;
18874
18875 return QDF_STATUS_SUCCESS;
18876}
18877
18878/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018879 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18880 * param from event
18881 * @wmi_handle: wmi handle
18882 * @param evt_buf: pointer to event buffer
18883 * @param param: Pointer to hold tpc configuration
18884 *
18885 * Return: 0 for success or error code
18886 */
18887static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18888 void *evt_buf,
18889 wmi_host_pdev_tpc_config_event *param)
18890{
18891 wmi_pdev_tpc_config_event_fixed_param *event =
18892 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18893
18894 if (!event) {
18895 WMI_LOGE("Invalid event buffer");
18896 return QDF_STATUS_E_INVAL;
18897 }
18898
18899 param->pdev_id = event->pdev_id;
18900 param->regDomain = event->regDomain;
18901 param->chanFreq = event->chanFreq;
18902 param->phyMode = event->phyMode;
18903 param->twiceAntennaReduction = event->twiceAntennaReduction;
18904 param->twiceMaxRDPower = event->twiceMaxRDPower;
18905 param->powerLimit = event->powerLimit;
18906 param->rateMax = event->rateMax;
18907 param->numTxChain = event->numTxChain;
18908 param->ctl = event->ctl;
18909 param->flags = event->flags;
18910
18911 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18912 sizeof(param->maxRegAllowedPower));
18913 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18914 event->maxRegAllowedPowerAGCDD,
18915 sizeof(param->maxRegAllowedPowerAGCDD));
18916 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18917 event->maxRegAllowedPowerAGSTBC,
18918 sizeof(param->maxRegAllowedPowerAGSTBC));
18919 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18920 event->maxRegAllowedPowerAGTXBF,
18921 sizeof(param->maxRegAllowedPowerAGTXBF));
18922 WMI_LOGD("%s:extract success", __func__);
18923
18924 return QDF_STATUS_SUCCESS;
18925}
18926
18927/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018928 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018929 * @wmi_handle: wmi handle
18930 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018931 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018932 *
18933 * Return: QDF_STATUS_SUCCESS for success or error code
18934 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018935static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18936 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018937{
18938 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18939 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018940 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018941
18942 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18943 if (!param_buf) {
18944 WMI_LOGE("Invalid swba event buffer");
18945 return QDF_STATUS_E_INVAL;
18946 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018947
Govind Singhe7f2f342016-05-23 12:12:52 +053018948 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018949 *num_vdevs = swba_event->num_vdevs;
18950 if (!(*num_vdevs)) {
18951 vdev_map = swba_event->vdev_map;
18952 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18953 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018954
18955 return QDF_STATUS_SUCCESS;
18956}
18957
18958/**
18959 * extract_swba_tim_info_tlv() - extract swba tim info from event
18960 * @wmi_handle: wmi handle
18961 * @param evt_buf: pointer to event buffer
18962 * @param idx: Index to bcn info
18963 * @param tim_info: Pointer to hold tim info
18964 *
18965 * Return: QDF_STATUS_SUCCESS for success or error code
18966 */
18967static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18968 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18969{
18970 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18971 wmi_tim_info *tim_info_ev;
18972
18973 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18974 if (!param_buf) {
18975 WMI_LOGE("Invalid swba event buffer");
18976 return QDF_STATUS_E_INVAL;
18977 }
18978
18979 tim_info_ev = &param_buf->tim_info[idx];
18980
18981 tim_info->tim_len = tim_info_ev->tim_len;
18982 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18983 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18984 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18985 tim_info->tim_changed = tim_info_ev->tim_changed;
18986 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018987 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018988
18989 return QDF_STATUS_SUCCESS;
18990}
18991
18992/**
18993 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18994 * @wmi_handle: wmi handle
18995 * @param evt_buf: pointer to event buffer
18996 * @param idx: Index to bcn info
18997 * @param p2p_desc: Pointer to hold p2p NoA info
18998 *
18999 * Return: QDF_STATUS_SUCCESS for success or error code
19000 */
19001static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
19002 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
19003{
19004 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
19005 wmi_p2p_noa_info *p2p_noa_info;
19006 uint8_t i = 0;
19007
19008 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
19009 if (!param_buf) {
19010 WMI_LOGE("Invalid swba event buffer");
19011 return QDF_STATUS_E_INVAL;
19012 }
19013
19014 p2p_noa_info = &param_buf->p2p_noa_info[idx];
19015
19016 p2p_desc->modified = false;
19017 p2p_desc->num_descriptors = 0;
19018 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
19019 p2p_desc->modified = true;
19020 p2p_desc->index =
19021 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
19022 p2p_desc->oppPS =
19023 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
19024 p2p_desc->ctwindow =
19025 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
19026 p2p_desc->num_descriptors =
19027 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
19028 (p2p_noa_info);
19029 for (i = 0; i < p2p_desc->num_descriptors; i++) {
19030 p2p_desc->noa_descriptors[i].type_count =
19031 (uint8_t) p2p_noa_info->noa_descriptors[i].
19032 type_count;
19033 p2p_desc->noa_descriptors[i].duration =
19034 p2p_noa_info->noa_descriptors[i].duration;
19035 p2p_desc->noa_descriptors[i].interval =
19036 p2p_noa_info->noa_descriptors[i].interval;
19037 p2p_desc->noa_descriptors[i].start_time =
19038 p2p_noa_info->noa_descriptors[i].start_time;
19039 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019040 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019041 }
19042
19043 return QDF_STATUS_SUCCESS;
19044}
19045
Wu Gaocd3a8512017-03-13 20:17:34 +080019046#ifdef CONVERGED_P2P_ENABLE
19047/**
19048 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
19049 * @wmi_handle: wmi handle
19050 * @param evt_buf: pointer to event buffer
19051 * @param param: Pointer to hold p2p noa info
19052 *
19053 * Return: QDF_STATUS_SUCCESS for success or error code
19054 */
19055static QDF_STATUS extract_p2p_noa_ev_param_tlv(
19056 wmi_unified_t wmi_handle, void *evt_buf,
19057 struct p2p_noa_info *param)
19058{
19059 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
19060 wmi_p2p_noa_event_fixed_param *fixed_param;
19061 uint8_t i;
19062 wmi_p2p_noa_info *wmi_noa_info;
19063 uint8_t *buf_ptr;
19064 uint32_t descriptors;
19065
19066 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
19067 if (!param_tlvs) {
19068 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
19069 return QDF_STATUS_E_INVAL;
19070 }
19071
19072 if (!param) {
19073 WMI_LOGE("noa information param is null");
19074 return QDF_STATUS_E_INVAL;
19075 }
19076
19077 fixed_param = param_tlvs->fixed_param;
19078 buf_ptr = (uint8_t *) fixed_param;
19079 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
19080 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
19081
19082 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
19083 WMI_LOGE("%s: noa attr is not modified", __func__);
19084 return QDF_STATUS_E_INVAL;
19085 }
19086
19087 param->vdev_id = fixed_param->vdev_id;
19088 param->index =
19089 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
19090 param->opps_ps =
19091 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
19092 param->ct_window =
19093 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
19094 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
19095 param->num_desc = (uint8_t) descriptors;
19096
19097 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
19098 param->index, param->opps_ps, param->ct_window,
19099 param->num_desc);
19100 for (i = 0; i < param->num_desc; i++) {
19101 param->noa_desc[i].type_count =
19102 (uint8_t) wmi_noa_info->noa_descriptors[i].
19103 type_count;
19104 param->noa_desc[i].duration =
19105 wmi_noa_info->noa_descriptors[i].duration;
19106 param->noa_desc[i].interval =
19107 wmi_noa_info->noa_descriptors[i].interval;
19108 param->noa_desc[i].start_time =
19109 wmi_noa_info->noa_descriptors[i].start_time;
19110 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
19111 __func__, i, param->noa_desc[i].type_count,
19112 param->noa_desc[i].duration,
19113 param->noa_desc[i].interval,
19114 param->noa_desc[i].start_time);
19115 }
19116
19117 return QDF_STATUS_SUCCESS;
19118}
19119
19120/**
19121 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
19122 * information from event
19123 * @wmi_handle: wmi handle
19124 * @param evt_buf: pointer to event buffer
19125 * @param param: Pointer to hold p2p lo stop event information
19126 *
19127 * Return: QDF_STATUS_SUCCESS for success or error code
19128 */
19129static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
19130 wmi_unified_t wmi_handle, void *evt_buf,
19131 struct p2p_lo_event *param)
19132{
19133 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
19134 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
19135
19136 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
19137 evt_buf;
19138 if (!param_tlvs) {
19139 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
19140 return QDF_STATUS_E_INVAL;
19141 }
19142
19143 if (!param) {
19144 WMI_LOGE("lo stop event param is null");
19145 return QDF_STATUS_E_INVAL;
19146 }
19147
19148 lo_param = param_tlvs->fixed_param;
19149 param->vdev_id = lo_param->vdev_id;
19150 param->reason_code = lo_param->reason;
19151 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
19152 param->vdev_id, param->reason_code);
19153
19154 return QDF_STATUS_SUCCESS;
19155}
19156#endif /* End of CONVERGED_P2P_ENABLE */
19157
Govind Singhe7f2f342016-05-23 12:12:52 +053019158/**
19159 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
19160 * @wmi_handle: wmi handle
19161 * @param evt_buf: pointer to event buffer
19162 * @param ev: Pointer to hold peer param
19163 *
19164 * Return: QDF_STATUS_SUCCESS for success or error code
19165 */
19166static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
19167 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
19168{
19169 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
19170 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
19171
19172 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
19173 kickout_event = param_buf->fixed_param;
19174
19175 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
19176 ev->peer_macaddr);
19177
19178 ev->reason = kickout_event->reason;
19179 ev->rssi = kickout_event->rssi;
19180
19181 return QDF_STATUS_SUCCESS;
19182}
19183
19184/**
19185 * extract_all_stats_counts_tlv() - extract all stats count from event
19186 * @wmi_handle: wmi handle
19187 * @param evt_buf: pointer to event buffer
19188 * @param stats_param: Pointer to hold stats count
19189 *
19190 * Return: QDF_STATUS_SUCCESS for success or error code
19191 */
19192static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
19193 void *evt_buf, wmi_host_stats_event *stats_param)
19194{
19195 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19196 wmi_stats_event_fixed_param *ev;
19197
19198 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19199
19200 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19201 if (!ev) {
19202 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
19203 return QDF_STATUS_E_FAILURE;
19204 }
19205
19206 switch (ev->stats_id) {
19207 case WMI_REQUEST_PEER_STAT:
19208 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
19209 break;
19210
19211 case WMI_REQUEST_AP_STAT:
19212 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
19213 break;
19214
19215 case WMI_REQUEST_PDEV_STAT:
19216 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
19217 break;
19218
19219 case WMI_REQUEST_VDEV_STAT:
19220 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
19221 break;
19222
19223 case WMI_REQUEST_BCNFLT_STAT:
19224 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
19225 break;
19226
19227 case WMI_REQUEST_VDEV_RATE_STAT:
19228 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
19229 break;
19230
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019231 case WMI_REQUEST_BCN_STAT:
19232 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
19233 break;
19234
Govind Singhe7f2f342016-05-23 12:12:52 +053019235 default:
19236 stats_param->stats_id = 0;
19237 break;
19238
19239 }
19240
19241 stats_param->num_pdev_stats = ev->num_pdev_stats;
19242 stats_param->num_pdev_ext_stats = 0;
19243 stats_param->num_vdev_stats = ev->num_vdev_stats;
19244 stats_param->num_peer_stats = ev->num_peer_stats;
19245 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
19246 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019247 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053019248 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19249 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053019250
19251 return QDF_STATUS_SUCCESS;
19252}
19253
19254/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019255 * extract_pdev_tx_stats() - extract pdev tx stats from event
19256 */
19257static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
19258{
19259 /* Tx Stats */
19260 tx->comp_queued = tx_stats->comp_queued;
19261 tx->comp_delivered = tx_stats->comp_delivered;
19262 tx->msdu_enqued = tx_stats->msdu_enqued;
19263 tx->mpdu_enqued = tx_stats->mpdu_enqued;
19264 tx->wmm_drop = tx_stats->wmm_drop;
19265 tx->local_enqued = tx_stats->local_enqued;
19266 tx->local_freed = tx_stats->local_freed;
19267 tx->hw_queued = tx_stats->hw_queued;
19268 tx->hw_reaped = tx_stats->hw_reaped;
19269 tx->underrun = tx_stats->underrun;
19270 tx->tx_abort = tx_stats->tx_abort;
19271 tx->mpdus_requed = tx_stats->mpdus_requed;
19272 tx->data_rc = tx_stats->data_rc;
19273 tx->self_triggers = tx_stats->self_triggers;
19274 tx->sw_retry_failure = tx_stats->sw_retry_failure;
19275 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
19276 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
19277 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
19278 tx->pdev_resets = tx_stats->pdev_resets;
19279 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
19280 tx->phy_underrun = tx_stats->phy_underrun;
19281 tx->txop_ovf = tx_stats->txop_ovf;
19282
19283 return;
19284}
19285
19286
19287/**
19288 * extract_pdev_rx_stats() - extract pdev rx stats from event
19289 */
19290static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
19291{
19292 /* Rx Stats */
19293 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
19294 rx->status_rcvd = rx_stats->status_rcvd;
19295 rx->r0_frags = rx_stats->r0_frags;
19296 rx->r1_frags = rx_stats->r1_frags;
19297 rx->r2_frags = rx_stats->r2_frags;
19298 /* Only TLV */
19299 rx->r3_frags = 0;
19300 rx->htt_msdus = rx_stats->htt_msdus;
19301 rx->htt_mpdus = rx_stats->htt_mpdus;
19302 rx->loc_msdus = rx_stats->loc_msdus;
19303 rx->loc_mpdus = rx_stats->loc_mpdus;
19304 rx->oversize_amsdu = rx_stats->oversize_amsdu;
19305 rx->phy_errs = rx_stats->phy_errs;
19306 rx->phy_err_drop = rx_stats->phy_err_drop;
19307 rx->mpdu_errs = rx_stats->mpdu_errs;
19308
19309 return;
19310}
19311
19312/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019313 * extract_pdev_stats_tlv() - extract pdev stats from event
19314 * @wmi_handle: wmi handle
19315 * @param evt_buf: pointer to event buffer
19316 * @param index: Index into pdev stats
19317 * @param pdev_stats: Pointer to hold pdev stats
19318 *
19319 * Return: QDF_STATUS_SUCCESS for success or error code
19320 */
19321static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
19322 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
19323{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019324 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19325 wmi_stats_event_fixed_param *ev_param;
19326 uint8_t *data;
19327
19328 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19329 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19330
19331 data = param_buf->data;
19332
19333 if (index < ev_param->num_pdev_stats) {
19334 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
19335 (index * sizeof(wmi_pdev_stats)));
19336
19337 pdev_stats->chan_nf = ev->chan_nf;
19338 pdev_stats->tx_frame_count = ev->tx_frame_count;
19339 pdev_stats->rx_frame_count = ev->rx_frame_count;
19340 pdev_stats->rx_clear_count = ev->rx_clear_count;
19341 pdev_stats->cycle_count = ev->cycle_count;
19342 pdev_stats->phy_err_count = ev->phy_err_count;
19343 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
19344
19345 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
19346 &(ev->pdev_stats.tx));
19347 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
19348 &(ev->pdev_stats.rx));
19349 }
19350
Govind Singhe7f2f342016-05-23 12:12:52 +053019351 return QDF_STATUS_SUCCESS;
19352}
19353
19354/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070019355 * extract_unit_test_tlv() - extract unit test data
19356 * @wmi_handle: wmi handle
19357 * @param evt_buf: pointer to event buffer
19358 * @param unit_test: pointer to hold unit test data
19359 * @param maxspace: Amount of space in evt_buf
19360 *
19361 * Return: QDF_STATUS_SUCCESS for success or error code
19362 */
19363static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
19364 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
19365{
19366 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
19367 wmi_unit_test_event_fixed_param *ev_param;
19368 uint32_t num_bufp;
19369 uint32_t copy_size;
19370 uint8_t *bufp;
19371
19372 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
19373 ev_param = param_buf->fixed_param;
19374 bufp = param_buf->bufp;
19375 num_bufp = param_buf->num_bufp;
19376 unit_test->vdev_id = ev_param->vdev_id;
19377 unit_test->module_id = ev_param->module_id;
19378 unit_test->diag_token = ev_param->diag_token;
19379 unit_test->flag = ev_param->flag;
19380 unit_test->payload_len = ev_param->payload_len;
19381 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
19382 ev_param->vdev_id,
19383 ev_param->module_id,
19384 ev_param->diag_token,
19385 ev_param->flag);
19386 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
19387 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
19388 bufp, num_bufp);
19389 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
19390 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
19391 unit_test->buffer_len = copy_size;
19392
19393 return QDF_STATUS_SUCCESS;
19394}
19395
19396/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019397 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
19398 * @wmi_handle: wmi handle
19399 * @param evt_buf: pointer to event buffer
19400 * @param index: Index into extended pdev stats
19401 * @param pdev_ext_stats: Pointer to hold extended pdev stats
19402 *
19403 * Return: QDF_STATUS_SUCCESS for success or error code
19404 */
19405static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
19406 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
19407{
19408 return QDF_STATUS_SUCCESS;
19409}
19410
19411/**
19412 * extract_vdev_stats_tlv() - extract vdev stats from event
19413 * @wmi_handle: wmi handle
19414 * @param evt_buf: pointer to event buffer
19415 * @param index: Index into vdev stats
19416 * @param vdev_stats: Pointer to hold vdev stats
19417 *
19418 * Return: QDF_STATUS_SUCCESS for success or error code
19419 */
19420static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
19421 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
19422{
19423 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19424 wmi_stats_event_fixed_param *ev_param;
19425 uint8_t *data;
19426
19427 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19428 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19429 data = (uint8_t *) param_buf->data;
19430
19431 if (index < ev_param->num_vdev_stats) {
19432 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
19433 ((ev_param->num_pdev_stats) *
19434 sizeof(wmi_pdev_stats)) +
19435 (index * sizeof(wmi_vdev_stats)));
19436
19437 vdev_stats->vdev_id = ev->vdev_id;
19438 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
19439 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
19440
19441 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
19442 sizeof(ev->tx_frm_cnt));
19443 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
19444 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
19445 ev->multiple_retry_cnt,
19446 sizeof(ev->multiple_retry_cnt));
19447 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
19448 sizeof(ev->fail_cnt));
19449 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
19450 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
19451 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
19452 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
19453 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
19454 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
19455 sizeof(ev->tx_rate_history));
19456 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
19457 sizeof(ev->bcn_rssi_history));
19458
19459 }
19460
19461 return QDF_STATUS_SUCCESS;
19462}
19463
19464/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019465 * extract_bcn_stats_tlv() - extract bcn stats from event
19466 * @wmi_handle: wmi handle
19467 * @param evt_buf: pointer to event buffer
19468 * @param index: Index into vdev stats
19469 * @param bcn_stats: Pointer to hold bcn stats
19470 *
19471 * Return: QDF_STATUS_SUCCESS for success or error code
19472 */
19473static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
19474 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
19475{
19476 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19477 wmi_stats_event_fixed_param *ev_param;
19478 uint8_t *data;
19479
19480 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19481 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19482 data = (uint8_t *) param_buf->data;
19483
19484 if (index < ev_param->num_bcn_stats) {
19485 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
19486 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19487 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19488 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19489 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
19490 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
19491 (index * sizeof(wmi_bcn_stats)));
19492
19493 bcn_stats->vdev_id = ev->vdev_id;
19494 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
19495 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
19496 }
19497
19498 return QDF_STATUS_SUCCESS;
19499}
19500
19501/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019502 * extract_peer_stats_tlv() - extract peer stats from event
19503 * @wmi_handle: wmi handle
19504 * @param evt_buf: pointer to event buffer
19505 * @param index: Index into peer stats
19506 * @param peer_stats: Pointer to hold peer stats
19507 *
19508 * Return: QDF_STATUS_SUCCESS for success or error code
19509 */
19510static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19511 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19512{
19513 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19514 wmi_stats_event_fixed_param *ev_param;
19515 uint8_t *data;
19516
19517 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19518 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19519 data = (uint8_t *) param_buf->data;
19520
19521 if (index < ev_param->num_peer_stats) {
19522 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19523 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19524 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19525 (index * sizeof(wmi_peer_stats)));
19526
19527 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19528
19529 OS_MEMCPY(&(peer_stats->peer_macaddr),
19530 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19531
19532 peer_stats->peer_rssi = ev->peer_rssi;
19533 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19534 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19535 }
19536
19537 return QDF_STATUS_SUCCESS;
19538}
19539
19540/**
19541 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19542 * @wmi_handle: wmi handle
19543 * @param evt_buf: pointer to event buffer
19544 * @param index: Index into bcn fault stats
19545 * @param bcnflt_stats: Pointer to hold bcn fault stats
19546 *
19547 * Return: QDF_STATUS_SUCCESS for success or error code
19548 */
19549static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19550 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19551{
19552 return QDF_STATUS_SUCCESS;
19553}
19554
19555/**
19556 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19557 * @wmi_handle: wmi handle
19558 * @param evt_buf: pointer to event buffer
19559 * @param index: Index into extended peer stats
19560 * @param peer_extd_stats: Pointer to hold extended peer stats
19561 *
19562 * Return: QDF_STATUS_SUCCESS for success or error code
19563 */
19564static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19565 void *evt_buf, uint32_t index,
19566 wmi_host_peer_extd_stats *peer_extd_stats)
19567{
19568 return QDF_STATUS_SUCCESS;
19569}
19570
19571/**
19572 * extract_chan_stats_tlv() - extract chan stats from event
19573 * @wmi_handle: wmi handle
19574 * @param evt_buf: pointer to event buffer
19575 * @param index: Index into chan stats
19576 * @param vdev_extd_stats: Pointer to hold chan stats
19577 *
19578 * Return: QDF_STATUS_SUCCESS for success or error code
19579 */
19580static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19581 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19582{
19583 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19584 wmi_stats_event_fixed_param *ev_param;
19585 uint8_t *data;
19586
19587 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19588 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19589 data = (uint8_t *) param_buf->data;
19590
19591 if (index < ev_param->num_chan_stats) {
19592 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19593 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19594 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19595 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19596 (index * sizeof(wmi_chan_stats)));
19597
19598
19599 /* Non-TLV doesnt have num_chan_stats */
19600 chan_stats->chan_mhz = ev->chan_mhz;
19601 chan_stats->sampling_period_us = ev->sampling_period_us;
19602 chan_stats->rx_clear_count = ev->rx_clear_count;
19603 chan_stats->tx_duration_us = ev->tx_duration_us;
19604 chan_stats->rx_duration_us = ev->rx_duration_us;
19605 }
19606
19607 return QDF_STATUS_SUCCESS;
19608}
19609
19610/**
19611 * extract_profile_ctx_tlv() - extract profile context from event
19612 * @wmi_handle: wmi handle
19613 * @param evt_buf: pointer to event buffer
19614 * @idx: profile stats index to extract
19615 * @param profile_ctx: Pointer to hold profile context
19616 *
19617 * Return: QDF_STATUS_SUCCESS for success or error code
19618 */
19619static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19620 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19621{
19622 return QDF_STATUS_SUCCESS;
19623}
19624
19625/**
19626 * extract_profile_data_tlv() - extract profile data from event
19627 * @wmi_handle: wmi handle
19628 * @param evt_buf: pointer to event buffer
19629 * @param profile_data: Pointer to hold profile data
19630 *
19631 * Return: QDF_STATUS_SUCCESS for success or error code
19632 */
19633static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19634 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19635{
19636
19637 return QDF_STATUS_SUCCESS;
19638}
19639
19640/**
19641 * extract_chan_info_event_tlv() - extract chan information from event
19642 * @wmi_handle: wmi handle
19643 * @param evt_buf: pointer to event buffer
19644 * @param chan_info: Pointer to hold chan information
19645 *
19646 * Return: QDF_STATUS_SUCCESS for success or error code
19647 */
19648static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19649 void *evt_buf, wmi_host_chan_info_event *chan_info)
19650{
19651 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19652 wmi_chan_info_event_fixed_param *ev;
19653
19654 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19655
19656 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19657 if (!ev) {
19658 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19659 return QDF_STATUS_E_FAILURE;
19660 }
19661
19662 chan_info->err_code = ev->err_code;
19663 chan_info->freq = ev->freq;
19664 chan_info->cmd_flags = ev->cmd_flags;
19665 chan_info->noise_floor = ev->noise_floor;
19666 chan_info->rx_clear_count = ev->rx_clear_count;
19667 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019668 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19669 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019670 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19671 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19672 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019673 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19674 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19675 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19676 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19677 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19678 chan_info->rx_frame_count = ev->rx_frame_count;
19679 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19680 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019681
19682 return QDF_STATUS_SUCCESS;
19683}
19684
19685/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019686 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19687 * @wmi_handle: WMI handle
19688 * @param evt_buf: Pointer to event buffer
19689 * @param param: Pointer to hold data
19690 *
19691 * Return : QDF_STATUS_SUCCESS for success or error code
19692 */
19693static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19694 uint8_t *evt_buf,
19695 struct wmi_host_pdev_utf_event *event)
19696{
19697 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019698 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019699
19700 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19701 event->data = param_buf->data;
19702 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019703 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019704 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019705 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019706 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019707
19708 return QDF_STATUS_SUCCESS;
19709}
Govind Singhe7f2f342016-05-23 12:12:52 +053019710
Kiran Venkatappa06520822016-08-10 23:55:40 +053019711/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019712 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19713 * @wmi_handle: wmi handle
19714 * @param evt_buf: pointer to event buffer
19715 * @param param: Pointer to hold evt buf
19716 *
19717 * Return: QDF_STATUS_SUCCESS for success or error code
19718 */
19719static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19720 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19721{
19722 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19723 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19724 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19725 uint8_t i = 0, j = 0;
19726
19727 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19728 if (!param_buf)
19729 return QDF_STATUS_E_INVAL;
19730
19731 hw_caps = param_buf->soc_hw_mode_caps;
19732 if (!hw_caps)
19733 return QDF_STATUS_E_INVAL;
19734
19735 if (!hw_caps->num_chainmask_tables)
19736 return QDF_STATUS_E_INVAL;
19737
19738 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19739
19740 if (chainmask_caps == NULL)
19741 return QDF_STATUS_E_INVAL;
19742
19743 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19744
19745 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19746 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19747
19748 chainmask_table[i].cap_list[j].chainmask =
19749 chainmask_caps->chainmask;
19750
19751 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19752 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19753
19754 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19755 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19756
19757 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19758 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19759
19760 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19761 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19762
19763 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19764 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19765
19766 chainmask_table[i].cap_list[j].chain_mask_2G =
19767 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19768
19769 chainmask_table[i].cap_list[j].chain_mask_5G =
19770 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19771
19772 chainmask_table[i].cap_list[j].chain_mask_tx =
19773 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19774
19775 chainmask_table[i].cap_list[j].chain_mask_rx =
19776 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19777
19778 chainmask_table[i].cap_list[j].supports_aDFS =
19779 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19780
19781 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19782 chainmask_caps->supported_flags,
19783 chainmask_caps->chainmask
19784 );
19785 chainmask_caps++;
19786 }
19787 }
19788
19789 return QDF_STATUS_SUCCESS;
19790}
19791
19792/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019793 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19794 * from event
19795 * @wmi_handle: wmi handle
19796 * @param evt_buf: pointer to event buffer
19797 * @param param: Pointer to hold evt buf
19798 *
19799 * Return: QDF_STATUS_SUCCESS for success or error code
19800 */
19801static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019802 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019803{
19804 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19805 wmi_service_ready_ext_event_fixed_param *ev;
19806 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19807 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019808 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19809 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019810
19811 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19812 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019813 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019814
19815 ev = param_buf->fixed_param;
19816 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019817 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019818
19819 /* Move this to host based bitmap */
19820 param->default_conc_scan_config_bits =
19821 ev->default_conc_scan_config_bits;
19822 param->default_fw_config_bits = ev->default_fw_config_bits;
19823 param->he_cap_info = ev->he_cap_info;
19824 param->mpdu_density = ev->mpdu_density;
19825 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019826 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019827 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019828 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19829
19830 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019831 if (hw_caps)
19832 param->num_hw_modes = hw_caps->num_hw_modes;
19833 else
19834 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019835
19836 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019837 if (reg_caps)
19838 param->num_phy = reg_caps->num_phy;
19839 else
19840 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019841
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019842 if (hw_caps) {
19843 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
19844 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
19845 } else
19846 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019847
19848 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19849
19850 if (chain_mask_combo == NULL)
19851 return QDF_STATUS_SUCCESS;
19852
19853 qdf_print("Dumping chain mask combo data\n");
19854
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019855 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019856
19857 qdf_print("table_id : %d Num valid chainmasks: %d\n",
19858 chain_mask_combo->chainmask_table_id,
19859 chain_mask_combo->num_valid_chainmask
19860 );
19861
19862 param->chainmask_table[i].table_id =
19863 chain_mask_combo->chainmask_table_id;
19864 param->chainmask_table[i].num_valid_chainmasks =
19865 chain_mask_combo->num_valid_chainmask;
19866 chain_mask_combo++;
19867 }
19868 qdf_print("chain mask combo end\n");
19869
Kiran Venkatappa06520822016-08-10 23:55:40 +053019870 return QDF_STATUS_SUCCESS;
19871}
19872
19873/**
19874 * extract_hw_mode_cap_service_ready_ext_tlv() -
19875 * extract HW mode cap from service ready event
19876 * @wmi_handle: wmi handle
19877 * @param evt_buf: pointer to event buffer
19878 * @param param: Pointer to hold evt buf
19879 * @param hw_mode_idx: hw mode idx should be less than num_mode
19880 *
19881 * Return: QDF_STATUS_SUCCESS for success or error code
19882 */
19883static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19884 wmi_unified_t wmi_handle,
19885 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019886 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019887{
19888 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19889 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19890
19891 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19892 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019893 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019894
19895 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019896 if (!hw_caps)
19897 return QDF_STATUS_E_INVAL;
19898
Kiran Venkatappa06520822016-08-10 23:55:40 +053019899 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019900 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019901
19902 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19903 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19904
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019905 param->hw_mode_config_type =
19906 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19907
Kiran Venkatappa06520822016-08-10 23:55:40 +053019908 return QDF_STATUS_SUCCESS;
19909}
19910
19911/**
19912 * extract_mac_phy_cap_service_ready_ext_tlv() -
19913 * extract MAC phy cap from service ready event
19914 * @wmi_handle: wmi handle
19915 * @param evt_buf: pointer to event buffer
19916 * @param param: Pointer to hold evt buf
19917 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019918 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019919 *
19920 * Return: QDF_STATUS_SUCCESS for success or error code
19921 */
19922static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19923 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019924 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019925 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019926{
19927 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019928 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019929 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19930 uint32_t phy_map;
19931 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019932
19933 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19934 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019935 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019936
19937 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019938 if (!hw_caps)
19939 return QDF_STATUS_E_INVAL;
19940
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019941 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19942 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19943 break;
19944
19945 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19946 while (phy_map) {
19947 phy_map >>= 1;
19948 phy_idx++;
19949 }
19950 }
19951
19952 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019953 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019954
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019955 phy_idx += phy_id;
19956 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019957 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019958
19959 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019960
19961 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019962 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19963 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019964 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019965 param->supports_11b =
19966 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19967 param->supports_11g =
19968 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19969 param->supports_11a =
19970 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19971 param->supports_11n =
19972 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19973 param->supports_11ac =
19974 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19975 param->supports_11ax =
19976 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019977
19978 param->supported_bands = mac_phy_caps->supported_bands;
19979 param->ampdu_density = mac_phy_caps->ampdu_density;
19980 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19981 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19982 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19983 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19984 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19985 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19986 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19987 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19988 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19989 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19990 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19991 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19992 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19993 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19994 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19995 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019996 qdf_mem_copy(&param->he_cap_phy_info_2G,
19997 &mac_phy_caps->he_cap_phy_info_2G,
19998 sizeof(param->he_cap_phy_info_2G));
19999 qdf_mem_copy(&param->he_cap_phy_info_5G,
20000 &mac_phy_caps->he_cap_phy_info_5G,
20001 sizeof(param->he_cap_phy_info_5G));
20002 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
20003 sizeof(param->he_ppet2G));
20004 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
20005 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053020006 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020007
20008 return QDF_STATUS_SUCCESS;
20009}
20010
20011/**
20012 * extract_reg_cap_service_ready_ext_tlv() -
20013 * extract REG cap from service ready event
20014 * @wmi_handle: wmi handle
20015 * @param evt_buf: pointer to event buffer
20016 * @param param: Pointer to hold evt buf
20017 * @param phy_idx: phy idx should be less than num_mode
20018 *
20019 * Return: QDF_STATUS_SUCCESS for success or error code
20020 */
20021static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
20022 wmi_unified_t wmi_handle,
20023 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080020024 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053020025{
20026 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20027 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
20028 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
20029
20030 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
20031 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020032 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020033
20034 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020035 if (!reg_caps)
20036 return QDF_STATUS_E_INVAL;
20037
Kiran Venkatappa06520822016-08-10 23:55:40 +053020038 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020039 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020040
20041 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
20042
20043 param->phy_id = ext_reg_cap->phy_id;
20044 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
20045 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
20046 param->regcap1 = ext_reg_cap->regcap1;
20047 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053020048 param->wireless_modes = convert_wireless_modes_tlv(
20049 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053020050 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
20051 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
20052 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
20053 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
20054
20055 return QDF_STATUS_SUCCESS;
20056}
20057
Sathish Kumarf396c722017-11-17 17:30:41 +053020058static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
20059 wmi_unified_t wmi_handle,
20060 uint8_t *event, uint8_t idx,
20061 struct wlan_psoc_host_dbr_ring_caps *param)
20062{
20063 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20064 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
20065
20066 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
20067 if (!param_buf)
20068 return QDF_STATUS_E_INVAL;
20069
20070 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
20071
20072 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20073 dbr_ring_caps->pdev_id);
20074 param->mod_id = dbr_ring_caps->mod_id;
20075 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
20076 param->min_buf_size = dbr_ring_caps->min_buf_size;
20077 param->min_buf_align = dbr_ring_caps->min_buf_align;
20078
20079 return QDF_STATUS_SUCCESS;
20080}
20081
20082static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
20083 uint8_t *event, struct direct_buf_rx_rsp *param)
20084{
20085 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20086 wmi_dma_buf_release_fixed_param *ev;
20087
20088 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20089 if (!param_buf)
20090 return QDF_STATUS_E_INVAL;
20091
20092 ev = param_buf->fixed_param;
20093 if (!ev)
20094 return QDF_STATUS_E_INVAL;
20095
20096 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20097 ev->pdev_id);
20098 param->mod_id = ev->mod_id;
20099 param->num_buf_release_entry = ev->num_buf_release_entry;
20100 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
20101 param->pdev_id, param->mod_id, param->num_buf_release_entry);
20102
20103 return QDF_STATUS_SUCCESS;
20104}
20105
20106static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
20107 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
20108{
20109 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20110 wmi_dma_buf_release_entry *entry;
20111
20112 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20113 if (!param_buf)
20114 return QDF_STATUS_E_INVAL;
20115
20116 entry = &param_buf->entries[idx];
20117
20118 if (!entry) {
20119 WMI_LOGE("%s: Entry is NULL\n", __func__);
20120 return QDF_STATUS_E_FAILURE;
20121 }
20122
20123 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
20124
20125 param->paddr_lo = entry->paddr_lo;
20126 param->paddr_hi = entry->paddr_hi;
20127
20128 return QDF_STATUS_SUCCESS;
20129}
20130
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020131/**
20132 * extract_dcs_interference_type_tlv() - extract dcs interference type
20133 * from event
20134 * @wmi_handle: wmi handle
20135 * @param evt_buf: pointer to event buffer
20136 * @param param: Pointer to hold dcs interference param
20137 *
20138 * Return: 0 for success or error code
20139 */
20140static QDF_STATUS extract_dcs_interference_type_tlv(
20141 wmi_unified_t wmi_handle,
20142 void *evt_buf, struct wmi_host_dcs_interference_param *param)
20143{
20144 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20145
20146 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20147 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020148 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020149
20150 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020151 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20152 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020153
20154 return QDF_STATUS_SUCCESS;
20155}
20156
20157/*
20158 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
20159 * @wmi_handle: wmi handle
20160 * @param evt_buf: pointer to event buffer
20161 * @param cw_int: Pointer to hold cw interference
20162 *
20163 * Return: 0 for success or error code
20164 */
20165static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
20166 void *evt_buf,
20167 wmi_host_ath_dcs_cw_int *cw_int)
20168{
20169 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20170 wlan_dcs_cw_int *ev;
20171
20172 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20173 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020174 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020175
20176 ev = param_buf->cw_int;
20177
20178 cw_int->channel = ev->channel;
20179
20180 return QDF_STATUS_SUCCESS;
20181}
20182
20183/**
20184 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
20185 * @wmi_handle: wmi handle
20186 * @param evt_buf: pointer to event buffer
20187 * @param wlan_stat: Pointer to hold wlan stats
20188 *
20189 * Return: 0 for success or error code
20190 */
20191static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
20192 void *evt_buf,
20193 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
20194{
20195 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20196 wlan_dcs_im_tgt_stats_t *ev;
20197
20198 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20199 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020200 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020201
20202 ev = param_buf->wlan_stat;
20203 wlan_stat->reg_tsf32 = ev->reg_tsf32;
20204 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
20205 wlan_stat->tx_waste_time = ev->tx_waste_time;
20206 wlan_stat->rx_time = ev->rx_time;
20207 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
20208 wlan_stat->mib_stats.listen_time = ev->listen_time;
20209 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
20210 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
20211 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
20212 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
20213 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
20214 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
20215 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
20216 wlan_stat->chan_nf = ev->chan_nf;
20217 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
20218
20219 return QDF_STATUS_SUCCESS;
20220}
20221
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020222/**
20223 * extract_thermal_stats_tlv() - extract thermal stats from event
20224 * @wmi_handle: wmi handle
20225 * @param evt_buf: Pointer to event buffer
20226 * @param temp: Pointer to hold extracted temperature
20227 * @param level: Pointer to hold extracted level
20228 *
20229 * Return: 0 for success or error code
20230 */
20231static QDF_STATUS
20232extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
20233 void *evt_buf, uint32_t *temp,
20234 uint32_t *level, uint32_t *pdev_id)
20235{
20236 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20237 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
20238
20239 param_buf =
20240 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20241 if (!param_buf)
20242 return QDF_STATUS_E_INVAL;
20243
20244 tt_stats_event = param_buf->fixed_param;
20245
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020246 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20247 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020248 *temp = tt_stats_event->temp;
20249 *level = tt_stats_event->level;
20250
20251 return QDF_STATUS_SUCCESS;
20252}
20253
20254/**
20255 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
20256 * @wmi_handle: wmi handle
20257 * @param evt_buf: pointer to event buffer
20258 * @param idx: Index to level stats
20259 * @param levelcount: Pointer to hold levelcount
20260 * @param dccount: Pointer to hold dccount
20261 *
20262 * Return: 0 for success or error code
20263 */
20264static QDF_STATUS
20265extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
20266 void *evt_buf, uint8_t idx, uint32_t *levelcount,
20267 uint32_t *dccount)
20268{
20269 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20270 wmi_therm_throt_level_stats_info *tt_level_info;
20271
20272 param_buf =
20273 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20274 if (!param_buf)
20275 return QDF_STATUS_E_INVAL;
20276
20277 tt_level_info = param_buf->therm_throt_level_stats_info;
20278
20279 if (idx < THERMAL_LEVELS) {
20280 *levelcount = tt_level_info[idx].level_count;
20281 *dccount = tt_level_info[idx].dc_count;
20282 return QDF_STATUS_SUCCESS;
20283 }
20284
20285 return QDF_STATUS_E_FAILURE;
20286}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020287#ifdef BIG_ENDIAN_HOST
20288/**
20289 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
20290 * @param data_len - data length
20291 * @param data - pointer to data
20292 *
20293 * Return: QDF_STATUS - success or error status
20294 */
20295static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20296{
20297 uint8_t *data_aligned = NULL;
20298 int c;
20299 unsigned char *data_unaligned;
20300
20301 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
20302 FIPS_ALIGN));
20303 /* Assigning unaligned space to copy the data */
20304 /* Checking if kmalloc does succesful allocation */
20305 if (data_unaligned == NULL)
20306 return QDF_STATUS_E_FAILURE;
20307
20308 /* Checking if space is alligned */
20309 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
20310 /* align the data space */
20311 data_aligned =
20312 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
20313 } else {
20314 data_aligned = (u_int8_t *)data_unaligned;
20315 }
20316
20317 /* memset and copy content from data to data aligned */
20318 OS_MEMSET(data_aligned, 0, data_len);
20319 OS_MEMCPY(data_aligned, data, data_len);
20320 /* Endianness to LE */
20321 for (c = 0; c < data_len/4; c++) {
20322 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020323 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020324 }
20325
20326 /* Copy content to event->data */
20327 OS_MEMCPY(data, data_aligned, data_len);
20328
20329 /* clean up allocated space */
20330 qdf_mem_free(data_unaligned);
20331 data_aligned = NULL;
20332 data_unaligned = NULL;
20333
20334 /*************************************************************/
20335
20336 return QDF_STATUS_SUCCESS;
20337}
20338#else
20339/**
20340 * fips_conv_data_be() - DUMMY for LE platform
20341 *
20342 * Return: QDF_STATUS - success
20343 */
20344static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20345{
20346 return QDF_STATUS_SUCCESS;
20347}
20348#endif
20349
20350/**
20351 * extract_fips_event_data_tlv() - extract fips event data
20352 * @wmi_handle: wmi handle
20353 * @param evt_buf: pointer to event buffer
20354 * @param param: pointer FIPS event params
20355 *
20356 * Return: 0 for success or error code
20357 */
20358static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
20359 void *evt_buf, struct wmi_host_fips_event_param *param)
20360{
20361 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
20362 wmi_pdev_fips_event_fixed_param *event;
20363
20364 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
20365 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
20366
20367 if (fips_conv_data_be(event->data_len, param_buf->data) !=
20368 QDF_STATUS_SUCCESS)
20369 return QDF_STATUS_E_FAILURE;
20370
20371 param->data = (uint32_t *)param_buf->data;
20372 param->data_len = event->data_len;
20373 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020374 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20375 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020376
20377 return QDF_STATUS_SUCCESS;
20378}
20379
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020380/*
20381 * extract_peer_delete_response_event_tlv() - extract peer delete response event
20382 * @wmi_handle: wmi handle
20383 * @param evt_buf: pointer to event buffer
20384 * @param vdev_id: Pointer to hold vdev_id
20385 * @param mac_addr: Pointer to hold peer mac address
20386 *
20387 * Return: QDF_STATUS_SUCCESS for success or error code
20388 */
20389static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
20390 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
20391{
20392 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
20393 wmi_peer_delete_resp_event_fixed_param *ev;
20394
20395 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
20396
20397 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
20398 if (!ev) {
20399 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
20400 return QDF_STATUS_E_FAILURE;
20401 }
20402
20403 param->vdev_id = ev->vdev_id;
20404 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
20405 &param->mac_address.bytes[0]);
20406
20407 return QDF_STATUS_SUCCESS;
20408}
20409
Govind Singhecf03cd2016-05-12 12:45:51 +053020410static bool is_management_record_tlv(uint32_t cmd_id)
20411{
jiad36c94d22018-01-22 15:37:03 +080020412 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
20413 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
20414 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053020415 return true;
jiad36c94d22018-01-22 15:37:03 +080020416 }
Govind Singhe7f2f342016-05-23 12:12:52 +053020417
Govind Singhecf03cd2016-05-12 12:45:51 +053020418 return false;
20419}
20420
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053020421static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20422{
20423 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
20424
20425 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
20426
20427 switch (set_cmd->param_id) {
20428 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
20429 case WMI_VDEV_PARAM_DTIM_POLICY:
20430 return HTC_TX_PACKET_TAG_AUTO_PM;
20431 default:
20432 break;
20433 }
20434
20435 return 0;
20436}
20437
20438static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20439{
20440 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
20441
20442 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20443
20444 switch (ps_cmd->param) {
20445 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20446 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20447 case WMI_STA_PS_ENABLE_QPOWER:
20448 return HTC_TX_PACKET_TAG_AUTO_PM;
20449 default:
20450 break;
20451 }
20452
20453 return 0;
20454}
20455
20456static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20457 uint32_t cmd_id)
20458{
20459 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20460 return 0;
20461
20462 switch (cmd_id) {
20463 case WMI_VDEV_SET_PARAM_CMDID:
20464 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20465 case WMI_STA_POWERSAVE_PARAM_CMDID:
20466 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20467 default:
20468 break;
20469 }
20470
20471 return 0;
20472}
20473
20474static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20475{
20476 uint16_t tag = 0;
20477
20478 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20479 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20480 __func__);
20481 return tag;
20482 }
20483
20484 if (wmi_handle->tag_crash_inject)
20485 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20486
20487 wmi_handle->tag_crash_inject = false;
20488 return tag;
20489}
20490
20491/**
20492 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20493 * @wmi_handle: WMI handle
20494 * @buf: WMI buffer
20495 * @cmd_id: WMI command Id
20496 *
20497 * Return htc_tx_tag
20498 */
20499static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20500 wmi_buf_t buf,
20501 uint32_t cmd_id)
20502{
20503 uint16_t htc_tx_tag = 0;
20504
20505 switch (cmd_id) {
20506 case WMI_WOW_ENABLE_CMDID:
20507 case WMI_PDEV_SUSPEND_CMDID:
20508 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20509 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20510 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20511 case WMI_PDEV_RESUME_CMDID:
20512 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20513 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20514#ifdef FEATURE_WLAN_D0WOW
20515 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20516#endif
20517 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20518 break;
20519 case WMI_FORCE_FW_HANG_CMDID:
20520 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20521 break;
20522 case WMI_VDEV_SET_PARAM_CMDID:
20523 case WMI_STA_POWERSAVE_PARAM_CMDID:
20524 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20525 default:
20526 break;
20527 }
20528
20529 return htc_tx_tag;
20530}
20531
Sathish Kumard3ab1002017-02-07 17:10:59 +053020532/**
20533 * extract_channel_hopping_event_tlv() - extract channel hopping param
20534 * from event
20535 * @wmi_handle: wmi handle
20536 * @param evt_buf: pointer to event buffer
20537 * @param ch_hopping: Pointer to hold channel hopping param
20538 *
20539 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20540 */
20541static QDF_STATUS extract_channel_hopping_event_tlv(
20542 wmi_unified_t wmi_handle, void *evt_buf,
20543 wmi_host_pdev_channel_hopping_event *ch_hopping)
20544{
20545 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20546 wmi_pdev_channel_hopping_event_fixed_param *event;
20547
20548 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20549 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20550 param_buf->fixed_param;
20551
20552 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20553 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020554 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20555 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020556
20557 return QDF_STATUS_SUCCESS;
20558}
20559
20560/**
20561 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20562 * @wmi_handle: wmi handle
20563 * @param evt_buf: pointer to event buffer
20564 * @param param: Pointer to hold tpc param
20565 *
20566 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20567 */
20568static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20569 void *evt_buf,
20570 wmi_host_pdev_tpc_event *param)
20571{
20572 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20573 wmi_pdev_tpc_event_fixed_param *event;
20574
20575 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20576 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20577
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020578 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20579 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020580 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20581
20582 return QDF_STATUS_SUCCESS;
20583}
20584
nobeljf74583b2018-01-25 16:35:36 -080020585/**
20586 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20587 * power param from event
20588 * @wmi_handle: wmi handle
20589 * @param evt_buf: pointer to event buffer
20590 * @param param: Pointer to hold nf cal power param
20591 *
20592 * Return: 0 for success or error code
20593 */
20594static QDF_STATUS
20595extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20596 void *evt_buf,
20597 wmi_host_pdev_nfcal_power_all_channels_event *param)
20598{
20599 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20600 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20601 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20602 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20603 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20604 uint32_t i;
20605
20606 param_buf =
20607 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20608 event = param_buf->fixed_param;
20609 ch_nfdbr = param_buf->nfdbr;
20610 ch_nfdbm = param_buf->nfdbm;
20611 ch_freqnum = param_buf->freqnum;
20612
20613 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20614 event->pdev_id, param_buf->num_nfdbr,
20615 param_buf->num_nfdbm, param_buf->num_freqnum);
20616
20617 if (param_buf->num_nfdbr >
20618 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20619 WMI_LOGE("invalid number of nfdBr");
20620 return QDF_STATUS_E_FAILURE;
20621 }
20622
20623 if (param_buf->num_nfdbm >
20624 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20625 WMI_LOGE("invalid number of nfdBm");
20626 return QDF_STATUS_E_FAILURE;
20627 }
20628
20629 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20630 WMI_LOGE("invalid number of freqNum");
20631 return QDF_STATUS_E_FAILURE;
20632 }
20633
20634 for (i = 0; i < param_buf->num_nfdbr; i++) {
20635 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20636 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20637 ch_nfdbr++;
20638 ch_nfdbm++;
20639 }
20640
20641 for (i = 0; i < param_buf->num_freqnum; i++) {
20642 param->freqnum[i] = ch_freqnum->freqNum;
20643 ch_freqnum++;
20644 }
20645
20646 param->pdev_id = event->pdev_id;
20647
20648 return QDF_STATUS_SUCCESS;
20649}
20650
Sathish Kumard3ab1002017-02-07 17:10:59 +053020651
20652#ifdef BIG_ENDIAN_HOST
20653/**
20654 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20655 * @param data_len - data length
20656 * @param data - pointer to data
20657 *
20658 * Return: QDF_STATUS - success or error status
20659 */
20660static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20661{
20662 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020663 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020664 /* Skip swapping the first word */
20665 datap += sizeof(uint32_t);
20666 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20667 i++, datap += sizeof(uint32_t)) {
20668 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20669 }
20670
20671 return QDF_STATUS_SUCCESS;
20672}
20673#else
20674/**
20675 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20676 * @param data_len - data length
20677 * @param data - pointer to data
20678 *
20679 * Return: QDF_STATUS - success or error status
20680 */
20681static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20682{
20683 return QDF_STATUS_SUCCESS;
20684}
20685#endif
20686
20687/**
20688 * extract_wds_addr_event_tlv() - extract wds address from event
20689 * @wmi_handle: wmi handle
20690 * @param evt_buf: pointer to event buffer
20691 * @param wds_ev: Pointer to hold wds address
20692 *
20693 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20694 */
20695static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20696 void *evt_buf,
20697 uint16_t len, wds_addr_event_t *wds_ev)
20698{
20699 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20700 wmi_wds_addr_event_fixed_param *ev;
20701 int i;
20702
20703 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20704 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20705
20706 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20707 return QDF_STATUS_E_FAILURE;
20708
20709 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20710 sizeof(wds_ev->event_type));
20711 for (i = 0; i < 4; i++) {
20712 wds_ev->peer_mac[i] =
20713 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20714 wds_ev->dest_mac[i] =
20715 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20716 }
20717 for (i = 0; i < 2; i++) {
20718 wds_ev->peer_mac[4+i] =
20719 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20720 wds_ev->dest_mac[4+i] =
20721 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20722 }
20723 return QDF_STATUS_SUCCESS;
20724}
20725
20726/**
20727 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20728 * from event
20729 * @wmi_handle: wmi handle
20730 * @param evt_buf: pointer to event buffer
20731 * @param ev: Pointer to hold peer param and ps state
20732 *
20733 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20734 */
20735static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20736 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20737{
20738 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20739 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20740
20741 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20742 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20743 param_buf->fixed_param;
20744
20745 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20746 ev->peer_ps_state = event->peer_ps_state;
20747
20748 return QDF_STATUS_SUCCESS;
20749}
20750
20751/**
20752 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20753 * @wmi_handle: wmi handle
20754 * @param evt_buf: pointer to event buffer
20755 * @param inst_rssi_resp: Pointer to hold inst rssi response
20756 *
20757 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20758 */
20759static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20760 wmi_unified_t wmi_handle, void *evt_buf,
20761 wmi_host_inst_stats_resp *inst_rssi_resp)
20762{
20763 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20764 wmi_inst_rssi_stats_resp_fixed_param *event;
20765
20766 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20767 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20768
20769 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20770 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20771 inst_rssi_resp->iRSSI = event->iRSSI;
20772
20773 return QDF_STATUS_SUCCESS;
20774}
20775
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020776static struct cur_reg_rule
20777*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20778 wmi_regulatory_rule_struct *wmi_reg_rule)
20779{
20780 struct cur_reg_rule *reg_rule_ptr;
20781 uint32_t count;
20782
20783 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20784
20785 if (NULL == reg_rule_ptr) {
20786 WMI_LOGE("memory allocation failure");
20787 return NULL;
20788 }
20789
20790 for (count = 0; count < num_reg_rules; count++) {
20791 reg_rule_ptr[count].start_freq =
20792 WMI_REG_RULE_START_FREQ_GET(
20793 wmi_reg_rule[count].freq_info);
20794 reg_rule_ptr[count].end_freq =
20795 WMI_REG_RULE_END_FREQ_GET(
20796 wmi_reg_rule[count].freq_info);
20797 reg_rule_ptr[count].max_bw =
20798 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020799 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020800 reg_rule_ptr[count].reg_power =
20801 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020802 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020803 reg_rule_ptr[count].ant_gain =
20804 WMI_REG_RULE_ANTENNA_GAIN_GET(
20805 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020806 reg_rule_ptr[count].flags =
20807 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020808 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020809 }
20810
20811 return reg_rule_ptr;
20812}
20813
20814static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20815 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20816 struct cur_regulatory_info *reg_info, uint32_t len)
20817{
20818 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20819 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20820 wmi_regulatory_rule_struct *wmi_reg_rule;
20821 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20822
20823 WMI_LOGD("processing regulatory channel list");
20824
20825 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20826 if (!param_buf) {
20827 WMI_LOGE("invalid channel list event buf");
20828 return QDF_STATUS_E_FAILURE;
20829 }
20830
20831 chan_list_event_hdr = param_buf->fixed_param;
20832
20833 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20834 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20835 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020836 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020837 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20838 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020839 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020840 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020841 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020842 reg_info->ctry_code = chan_list_event_hdr->country_id;
20843 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20844 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20845 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20846 else if (chan_list_event_hdr->status_code ==
20847 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20848 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20849 else if (chan_list_event_hdr->status_code ==
20850 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20851 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20852 else if (chan_list_event_hdr->status_code ==
20853 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20854 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20855 else if (chan_list_event_hdr->status_code ==
20856 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20857 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20858 else if (chan_list_event_hdr->status_code ==
20859 WMI_REG_SET_CC_STATUS_FAIL)
20860 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20861
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020862 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20863 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20864 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20865 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20866
20867 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20868 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20869
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020870 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20871 __func__, reg_info->alpha2, reg_info->dfs_region,
20872 reg_info->min_bw_2g, reg_info->max_bw_2g,
20873 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020874
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020875 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20876 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020877 wmi_reg_rule =
20878 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20879 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20880 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020881 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20882 wmi_reg_rule);
20883 wmi_reg_rule += num_2g_reg_rules;
20884
20885 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20886 wmi_reg_rule);
20887
20888 WMI_LOGD("processed regulatory channel list");
20889
20890 return QDF_STATUS_SUCCESS;
20891}
20892
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020893static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20894 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20895 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20896{
20897 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20898 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20899
20900 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20901 if (!param_buf) {
20902 WMI_LOGE("invalid 11d country event buf");
20903 return QDF_STATUS_E_FAILURE;
20904 }
20905
20906 reg_11d_country_event = param_buf->fixed_param;
20907
20908 qdf_mem_copy(reg_11d_country->alpha2,
20909 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20910
20911 WMI_LOGD("processed 11d country event, new cc %s",
20912 reg_11d_country->alpha2);
20913
20914 return QDF_STATUS_SUCCESS;
20915}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020916
20917static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20918 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20919 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20920{
20921 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20922 wmi_avoid_freq_range_desc *afr_desc;
20923 uint32_t num_freq_ranges, freq_range_idx;
20924 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20925 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20926
20927 if (!param_buf) {
20928 WMI_LOGE("Invalid channel avoid event buffer");
20929 return QDF_STATUS_E_INVAL;
20930 }
20931
20932 afr_fixed_param = param_buf->fixed_param;
20933 if (!afr_fixed_param) {
20934 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20935 return QDF_STATUS_E_INVAL;
20936 }
20937
20938 if (!ch_avoid_ind) {
20939 WMI_LOGE("Invalid channel avoid indication buffer");
20940 return QDF_STATUS_E_INVAL;
20941 }
20942 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20943 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20944 afr_fixed_param->num_freq_ranges;
20945
20946 WMI_LOGD("Channel avoid event received with %d ranges",
20947 num_freq_ranges);
20948
20949 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20950 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20951 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20952 freq_range_idx++) {
20953 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20954 afr_desc->start_freq;
20955 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20956 afr_desc->end_freq;
20957 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20958 freq_range_idx, afr_desc->tlv_header,
20959 afr_desc->start_freq, afr_desc->end_freq);
20960 afr_desc++;
20961 }
20962
20963 return QDF_STATUS_SUCCESS;
20964}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020965#ifdef DFS_COMPONENT_ENABLE
20966/**
20967 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20968 * @wmi_handle: wma handle
20969 * @evt_buf: event buffer
20970 * @vdev_id: vdev id
20971 * @len: length of buffer
20972 *
20973 * Return: 0 for success or error code
20974 */
20975static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20976 uint8_t *evt_buf,
20977 uint32_t *vdev_id,
20978 uint32_t len)
20979{
20980 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20981 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20982
20983 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20984 if (!param_tlvs) {
20985 WMI_LOGE("invalid cac complete event buf");
20986 return QDF_STATUS_E_FAILURE;
20987 }
20988
20989 cac_event = param_tlvs->fixed_param;
20990 *vdev_id = cac_event->vdev_id;
20991 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20992
20993 return QDF_STATUS_SUCCESS;
20994}
20995
20996/**
20997 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20998 * @wmi_handle: wma handle
20999 * @evt_buf: event buffer
21000 * @radar_found: radar found event info
21001 * @len: length of buffer
21002 *
21003 * Return: 0 for success or error code
21004 */
21005static QDF_STATUS extract_dfs_radar_detection_event_tlv(
21006 wmi_unified_t wmi_handle,
21007 uint8_t *evt_buf,
21008 struct radar_found_info *radar_found,
21009 uint32_t len)
21010{
21011 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
21012 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
21013
21014 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
21015 if (!param_tlv) {
21016 WMI_LOGE("invalid radar detection event buf");
21017 return QDF_STATUS_E_FAILURE;
21018 }
21019
21020 radar_event = param_tlv->fixed_param;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021021 radar_found->pdev_id = wmi_handle->ops->
21022 convert_pdev_id_target_to_host(radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021023 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021024 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021025 radar_found->chan_width = radar_event->chan_width;
21026 radar_found->detector_id = radar_event->detector_id;
21027 radar_found->segment_id = radar_event->segment_id;
21028 radar_found->timestamp = radar_event->timestamp;
21029 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021030 radar_found->freq_offset = radar_event->freq_offset;
21031 radar_found->sidx = radar_event->sidx;
21032
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080021033 WMI_LOGI("processed radar found event pdev %d,"
21034 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
21035 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
21036 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
21037 "is_chirp %d,detection mode %d\n",
21038 radar_event->pdev_id, radar_event->pdev_id,
21039 radar_event->timestamp, radar_event->chan_freq,
21040 radar_event->chan_width, radar_event->detector_id,
21041 radar_event->freq_offset, radar_event->segment_id,
21042 radar_event->sidx, radar_event->is_chirp,
21043 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021044
21045 return QDF_STATUS_SUCCESS;
21046}
bings1ea12532017-12-18 16:56:53 +080021047
21048#ifdef QCA_MCL_DFS_SUPPORT
21049/**
21050 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
21051 * @wmi_handle: wma handle
21052 * @evt_buf: event buffer
21053 * @wlan_radar_event: Pointer to struct radar_event_info
21054 * @len: length of buffer
21055 *
21056 * Return: QDF_STATUS
21057 */
21058static QDF_STATUS extract_wlan_radar_event_info_tlv(
21059 wmi_unified_t wmi_handle,
21060 uint8_t *evt_buf,
21061 struct radar_event_info *wlan_radar_event,
21062 uint32_t len)
21063{
21064 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
21065 wmi_dfs_radar_event_fixed_param *radar_event;
21066
21067 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
21068 if (!param_tlv) {
21069 WMI_LOGE("invalid wlan radar event buf");
21070 return QDF_STATUS_E_FAILURE;
21071 }
21072
21073 radar_event = param_tlv->fixed_param;
21074 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
21075 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
21076 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
21077 wlan_radar_event->rssi = radar_event->rssi;
21078 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
21079 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
21080 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
21081 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080021082 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
21083 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings1ea12532017-12-18 16:56:53 +080021084 wlan_radar_event->pdev_id = radar_event->pdev_id;
21085
21086 return QDF_STATUS_SUCCESS;
21087}
21088#else
21089static QDF_STATUS extract_wlan_radar_event_info_tlv(
21090 wmi_unified_t wmi_handle,
21091 uint8_t *evt_buf,
21092 struct radar_event_info *wlan_radar_event,
21093 uint32_t len)
21094{
21095 return QDF_STATUS_SUCCESS;
21096}
21097#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021098#endif
21099
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021100/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021101 * send_get_rcpi_cmd_tlv() - send request for rcpi value
21102 * @wmi_handle: wmi handle
21103 * @get_rcpi_param: rcpi params
21104 *
21105 * Return: QDF status
21106 */
21107static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
21108 struct rcpi_req *get_rcpi_param)
21109{
21110 wmi_buf_t buf;
21111 wmi_request_rcpi_cmd_fixed_param *cmd;
21112 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
21113
21114 buf = wmi_buf_alloc(wmi_handle, len);
21115 if (!buf) {
21116 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21117 return QDF_STATUS_E_NOMEM;
21118 }
21119
21120 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
21121 WMITLV_SET_HDR(&cmd->tlv_header,
21122 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
21123 WMITLV_GET_STRUCT_TLVLEN
21124 (wmi_request_rcpi_cmd_fixed_param));
21125
21126 cmd->vdev_id = get_rcpi_param->vdev_id;
21127 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
21128 &cmd->peer_macaddr);
21129 cmd->measurement_type = get_rcpi_param->measurement_type;
21130 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
21131 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21132 WMI_REQUEST_RCPI_CMDID)) {
21133
21134 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
21135 __func__);
21136 wmi_buf_free(buf);
21137 return QDF_STATUS_E_FAILURE;
21138 }
21139
21140 return QDF_STATUS_SUCCESS;
21141}
21142
21143/**
21144 * extract_rcpi_response_event_tlv() - Extract RCPI event params
21145 * @wmi_handle: wmi handle
21146 * @evt_buf: pointer to event buffer
21147 * @res: pointer to hold rcpi response from firmware
21148 *
21149 * Return: QDF_STATUS_SUCCESS for successful event parse
21150 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
21151 */
21152static QDF_STATUS
21153extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
21154 void *evt_buf, struct rcpi_res *res)
21155{
21156 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
21157 wmi_update_rcpi_event_fixed_param *event;
21158
21159 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
21160 if (!param_buf) {
21161 WMI_LOGE(FL("Invalid rcpi event"));
21162 return QDF_STATUS_E_INVAL;
21163 }
21164
21165 event = param_buf->fixed_param;
21166 res->vdev_id = event->vdev_id;
21167 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
21168
21169 switch (event->measurement_type) {
21170
21171 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21172 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21173 break;
21174
21175 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
21176 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
21177 break;
21178
21179 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21180 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21181 break;
21182
21183 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
21184 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
21185 break;
21186
21187 default:
21188 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
21189 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
21190 return QDF_STATUS_E_FAILURE;
21191 }
21192
21193 if (event->status)
21194 return QDF_STATUS_E_FAILURE;
21195 else
21196 return QDF_STATUS_SUCCESS;
21197}
21198
21199/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053021200 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
21201 * host to target defines. For legacy there is not conversion
21202 * required. Just return pdev_id as it is.
21203 * @param pdev_id: host pdev_id to be converted.
21204 * Return: target pdev_id after conversion.
21205 */
21206static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
21207 uint32_t pdev_id)
21208{
21209 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
21210 return WMI_PDEV_ID_SOC;
21211
21212 /*No conversion required*/
21213 return pdev_id;
21214}
21215
21216/**
21217 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
21218 * target to host defines. For legacy there is not conversion
21219 * required. Just return pdev_id as it is.
21220 * @param pdev_id: target pdev_id to be converted.
21221 * Return: host pdev_id after conversion.
21222 */
21223static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
21224 uint32_t pdev_id)
21225{
21226 /*No conversion required*/
21227 return pdev_id;
21228}
21229
21230/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021231 * send_set_country_cmd_tlv() - WMI scan channel list function
21232 * @param wmi_handle : handle to WMI.
21233 * @param param : pointer to hold scan channel list parameter
21234 *
21235 * Return: 0 on success and -ve on failure.
21236 */
21237static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
21238 struct set_country *params)
21239{
21240 wmi_buf_t buf;
21241 QDF_STATUS qdf_status;
21242 wmi_set_current_country_cmd_fixed_param *cmd;
21243 uint16_t len = sizeof(*cmd);
21244
21245 buf = wmi_buf_alloc(wmi_handle, len);
21246 if (!buf) {
21247 WMI_LOGE("Failed to allocate memory");
21248 qdf_status = QDF_STATUS_E_NOMEM;
21249 goto end;
21250 }
21251
21252 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
21253 WMITLV_SET_HDR(&cmd->tlv_header,
21254 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
21255 WMITLV_GET_STRUCT_TLVLEN
21256 (wmi_set_current_country_cmd_fixed_param));
21257
21258 WMI_LOGD("setting cuurnet country to %s", params->country);
21259
21260 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
21261
21262 cmd->pdev_id = params->pdev_id;
21263
21264 qdf_status = wmi_unified_cmd_send(wmi_handle,
21265 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
21266
21267 if (QDF_IS_STATUS_ERROR(qdf_status)) {
21268 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
21269 wmi_buf_free(buf);
21270 }
21271
21272end:
21273 return qdf_status;
21274}
21275
Abhijit Pradhand38a2692017-06-29 12:32:20 +053021276#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
21277 WMI_SET_BITS(alpha, 0, 8, val0); \
21278 WMI_SET_BITS(alpha, 8, 8, val1); \
21279 WMI_SET_BITS(alpha, 16, 8, val2); \
21280 } while (0)
21281
21282static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
21283 uint8_t pdev_id, struct cc_regdmn_s *rd)
21284{
21285 wmi_set_init_country_cmd_fixed_param *cmd;
21286 uint16_t len;
21287 wmi_buf_t buf;
21288 int ret;
21289
21290 len = sizeof(wmi_set_init_country_cmd_fixed_param);
21291 buf = wmi_buf_alloc(wmi_handle, len);
21292 if (!buf) {
21293 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
21294 return QDF_STATUS_E_NOMEM;
21295 }
21296 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
21297 WMITLV_SET_HDR(&cmd->tlv_header,
21298 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
21299 WMITLV_GET_STRUCT_TLVLEN
21300 (wmi_set_init_country_cmd_fixed_param));
21301
21302 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
21303
21304 if (rd->flags == CC_IS_SET) {
21305 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
21306 cmd->country_code.country_id = rd->cc.country_code;
21307 } else if (rd->flags == ALPHA_IS_SET) {
21308 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
21309 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
21310 rd->cc.alpha[0],
21311 rd->cc.alpha[1],
21312 rd->cc.alpha[2]);
21313 } else if (rd->flags == REGDMN_IS_SET) {
21314 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
21315 cmd->country_code.domain_code = rd->cc.regdmn_id;
21316 }
21317
21318 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
21319 WMI_SET_INIT_COUNTRY_CMDID);
21320 if (ret) {
21321 WMI_LOGE("Failed to config wow wakeup event");
21322 wmi_buf_free(buf);
21323 return QDF_STATUS_E_FAILURE;
21324 }
21325
21326 return QDF_STATUS_SUCCESS;
21327}
21328
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053021329/**
21330 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
21331 * configuration params
21332 * @wmi_handle: wmi handler
21333 * @limit_off_chan_param: pointer to wmi_off_chan_param
21334 *
21335 * Return: 0 for success and non zero for failure
21336 */
21337static
21338QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
21339 struct wmi_limit_off_chan_param *limit_off_chan_param)
21340{
21341 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
21342 wmi_buf_t buf;
21343 uint32_t len = sizeof(*cmd);
21344 int err;
21345
21346 buf = wmi_buf_alloc(wmi_handle, len);
21347 if (!buf) {
21348 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
21349 __func__);
21350 return QDF_STATUS_E_NOMEM;
21351 }
21352
21353 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
21354
21355 WMITLV_SET_HDR(&cmd->tlv_header,
21356 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
21357 WMITLV_GET_STRUCT_TLVLEN(
21358 wmi_vdev_limit_offchan_cmd_fixed_param));
21359
21360 cmd->vdev_id = limit_off_chan_param->vdev_id;
21361
21362 cmd->flags &= 0;
21363 if (limit_off_chan_param->status)
21364 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
21365 if (limit_off_chan_param->skip_dfs_chans)
21366 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
21367
21368 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
21369 cmd->rest_time = limit_off_chan_param->rest_time;
21370
21371 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
21372 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
21373 cmd->rest_time);
21374
21375 err = wmi_unified_cmd_send(wmi_handle, buf,
21376 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
21377 if (QDF_IS_STATUS_ERROR(err)) {
21378 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
21379 wmi_buf_free(buf);
21380 return QDF_STATUS_E_FAILURE;
21381 }
21382
21383 return QDF_STATUS_SUCCESS;
21384}
21385
Anurag Chouhan97f00422017-09-11 14:56:30 +053021386/**
21387 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
21388 * @wmi_handle: wmi handler
21389 * @req_buf: set arp stats request buffer
21390 *
21391 * Return: 0 for success and non zero for failure
21392 */
21393static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21394 struct set_arp_stats *req_buf)
21395{
21396 wmi_buf_t buf = NULL;
21397 QDF_STATUS status;
21398 int len;
21399 uint8_t *buf_ptr;
21400 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
21401
21402 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21403 buf = wmi_buf_alloc(wmi_handle, len);
21404 if (!buf) {
21405 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21406 return QDF_STATUS_E_NOMEM;
21407 }
21408
21409 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21410 wmi_set_arp =
21411 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
21412 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
21413 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
21414 WMITLV_GET_STRUCT_TLVLEN
21415 (wmi_vdev_set_arp_stats_cmd_fixed_param));
21416
21417 /* fill in per roam config values */
21418 wmi_set_arp->vdev_id = req_buf->vdev_id;
21419
21420 wmi_set_arp->set_clr = req_buf->flag;
21421 wmi_set_arp->pkt_type = req_buf->pkt_type;
21422 wmi_set_arp->ipv4 = req_buf->ip_addr;
21423
21424 /* Send per roam config parameters */
21425 status = wmi_unified_cmd_send(wmi_handle, buf,
21426 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21427 if (QDF_IS_STATUS_ERROR(status)) {
21428 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21429 status);
21430 goto error;
21431 }
21432
21433 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
21434 req_buf->flag, req_buf->vdev_id);
21435 return QDF_STATUS_SUCCESS;
21436error:
21437 wmi_buf_free(buf);
21438
21439 return status;
21440}
21441
21442/**
21443 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21444 * @wmi_handle: wmi handler
21445 * @req_buf: get arp stats request buffer
21446 *
21447 * Return: 0 for success and non zero for failure
21448 */
21449static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21450 struct get_arp_stats *req_buf)
21451{
21452 wmi_buf_t buf = NULL;
21453 QDF_STATUS status;
21454 int len;
21455 uint8_t *buf_ptr;
21456 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21457
21458 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21459 buf = wmi_buf_alloc(wmi_handle, len);
21460 if (!buf) {
21461 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21462 return QDF_STATUS_E_NOMEM;
21463 }
21464
21465 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21466 get_arp_stats =
21467 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21468 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21469 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21470 WMITLV_GET_STRUCT_TLVLEN
21471 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21472
21473 /* fill in arp stats req cmd values */
21474 get_arp_stats->vdev_id = req_buf->vdev_id;
21475
21476 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21477 /* Send per roam config parameters */
21478 status = wmi_unified_cmd_send(wmi_handle, buf,
21479 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21480 if (QDF_IS_STATUS_ERROR(status)) {
21481 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21482 status);
21483 goto error;
21484 }
21485
21486 return QDF_STATUS_SUCCESS;
21487error:
21488 wmi_buf_free(buf);
21489
21490 return status;
21491}
21492
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021493/**
21494 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21495 * @wmi_handle: wmi handler
21496 * @pmk_info: pointer to PMK cache entry
21497 * @vdev_id: vdev id
21498 *
21499 * Return: 0 for success and non zero for failure
21500 */
21501static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21502 struct wmi_unified_pmk_cache *pmk_info)
21503{
21504 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21505 wmi_buf_t buf;
21506 QDF_STATUS status;
21507 uint8_t *buf_ptr;
21508 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021509 uint32_t len = sizeof(*cmd);
21510
21511 if (pmk_info->pmk_len)
21512 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021513
21514 buf = wmi_buf_alloc(wmi_handle, len);
21515 if (!buf) {
21516 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21517 __func__);
21518 return QDF_STATUS_E_NOMEM;
21519 }
21520
21521 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21522 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21523
21524 WMITLV_SET_HDR(&cmd->tlv_header,
21525 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21526 WMITLV_GET_STRUCT_TLVLEN(
21527 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21528
21529 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021530
21531 /* If pmk_info->pmk_len is 0, this is a flush request */
21532 if (!pmk_info->pmk_len) {
21533 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21534 cmd->num_cache = 0;
21535 goto send_cmd;
21536 }
21537
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021538 cmd->num_cache = 1;
21539 buf_ptr += sizeof(*cmd);
21540
21541 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21542 sizeof(*pmksa));
21543 buf_ptr += WMI_TLV_HDR_SIZE;
21544
21545 pmksa = (wmi_pmk_cache *)buf_ptr;
21546 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21547 WMITLV_GET_STRUCT_TLVLEN
21548 (wmi_pmk_cache));
21549 pmksa->pmk_len = pmk_info->pmk_len;
21550 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21551 pmksa->pmkid_len = pmk_info->pmkid_len;
21552 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21553 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21554 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21555 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21556 pmksa->ssid.ssid_len);
21557 pmksa->cache_id = pmk_info->cache_id;
21558 pmksa->cat_flag = pmk_info->cat_flag;
21559 pmksa->action_flag = pmk_info->action_flag;
21560
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021561send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021562 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21563 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21564 if (status != QDF_STATUS_SUCCESS) {
21565 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21566 __func__, status);
21567 wmi_buf_free(buf);
21568 }
21569
21570 return status;
21571}
21572
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021573/**
21574 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21575 * @wmi_handle: wmi handle
21576 * @param: reserved param
21577 *
21578 * Return: 0 for success or error code
21579 */
21580static QDF_STATUS
21581send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21582 uint32_t param)
21583{
21584 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21585 wmi_buf_t buf;
21586 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21587
21588 buf = wmi_buf_alloc(wmi_handle, len);
21589 if (!buf) {
21590 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21591 return QDF_STATUS_E_FAILURE;
21592 }
21593 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21594 WMITLV_SET_HDR(&cmd->tlv_header,
21595 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21596 WMITLV_GET_STRUCT_TLVLEN
21597 (wmi_pdev_check_cal_version_cmd_fixed_param));
21598 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21599 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21600 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21601 wmi_buf_free(buf);
21602 return QDF_STATUS_E_FAILURE;
21603 }
21604
21605 return QDF_STATUS_SUCCESS;
21606}
21607
21608/**
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053021609 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
21610 * host to target defines.
21611 * @param pdev_id: host pdev_id to be converted.
21612 * Return: target pdev_id after conversion.
21613 */
21614static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
21615{
21616 switch (pdev_id) {
21617 case WMI_HOST_PDEV_ID_SOC:
21618 return WMI_PDEV_ID_SOC;
21619 case WMI_HOST_PDEV_ID_0:
21620 return WMI_PDEV_ID_1ST;
21621 case WMI_HOST_PDEV_ID_1:
21622 return WMI_PDEV_ID_2ND;
21623 case WMI_HOST_PDEV_ID_2:
21624 return WMI_PDEV_ID_3RD;
21625 }
21626
21627 QDF_ASSERT(0);
21628
21629 return WMI_PDEV_ID_SOC;
21630}
21631
21632/**
21633 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
21634 * target to host defines.
21635 * @param pdev_id: target pdev_id to be converted.
21636 * Return: host pdev_id after conversion.
21637 */
21638static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
21639{
21640 switch (pdev_id) {
21641 case WMI_PDEV_ID_SOC:
21642 return WMI_HOST_PDEV_ID_SOC;
21643 case WMI_PDEV_ID_1ST:
21644 return WMI_HOST_PDEV_ID_0;
21645 case WMI_PDEV_ID_2ND:
21646 return WMI_HOST_PDEV_ID_1;
21647 case WMI_PDEV_ID_3RD:
21648 return WMI_HOST_PDEV_ID_2;
21649 }
21650
21651 QDF_ASSERT(0);
21652
21653 return WMI_HOST_PDEV_ID_SOC;
21654}
21655
21656/**
21657 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
21658 *
21659 * Return None.
21660 */
21661static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
21662{
21663 wmi_handle->ops->convert_pdev_id_host_to_target =
21664 convert_host_pdev_id_to_target_pdev_id;
21665 wmi_handle->ops->convert_pdev_id_target_to_host =
21666 convert_target_pdev_id_to_host_pdev_id;
21667}
21668
21669/**
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021670 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21671 * @wmi_handle: wmi handle
21672 * @param evt_buf: pointer to event buffer
21673 * @param param: Pointer to hold peer caldata version data
21674 *
21675 * Return: 0 for success or error code
21676 */
21677static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21678 wmi_unified_t wmi_handle,
21679 void *evt_buf,
21680 wmi_host_pdev_check_cal_version_event *param)
21681{
21682 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21683 wmi_pdev_check_cal_version_event_fixed_param *event;
21684
21685 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21686 if (!param_tlvs) {
21687 WMI_LOGE("invalid cal version event buf");
21688 return QDF_STATUS_E_FAILURE;
21689 }
21690 event = param_tlvs->fixed_param;
21691 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21692 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21693 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21694 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21695
21696 param->software_cal_version = event->software_cal_version;
21697 param->board_cal_version = event->board_cal_version;
21698 param->cal_ok = event->cal_status;
21699
21700 return QDF_STATUS_SUCCESS;
21701}
21702
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021703/*
21704 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21705 * @wmi_handle: wmi handle
21706 * @params: pointer to wmi_btm_config
21707 *
21708 * Return: QDF_STATUS
21709 */
21710static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21711 struct wmi_btm_config *params)
21712{
21713
21714 wmi_btm_config_fixed_param *cmd;
21715 wmi_buf_t buf;
21716 uint32_t len;
21717
21718 len = sizeof(*cmd);
21719 buf = wmi_buf_alloc(wmi_handle, len);
21720 if (!buf) {
21721 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21722 return QDF_STATUS_E_NOMEM;
21723 }
21724
21725 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21726 WMITLV_SET_HDR(&cmd->tlv_header,
21727 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21728 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21729 cmd->vdev_id = params->vdev_id;
21730 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021731 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21732 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21733 cmd->stick_time_seconds = params->btm_sticky_time;
21734
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021735 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21736 WMI_ROAM_BTM_CONFIG_CMDID)) {
21737 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21738 __func__);
21739 wmi_buf_free(buf);
21740 return QDF_STATUS_E_FAILURE;
21741 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021742
21743 return QDF_STATUS_SUCCESS;
21744}
21745
21746/**
21747 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21748 * configurations to firmware.
21749 * @wmi_handle: wmi handle
21750 * @obss_cfg_param: obss detection configurations
21751 *
21752 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21753 *
21754 * Return: QDF_STATUS
21755 */
21756static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21757 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21758{
21759 wmi_buf_t buf;
21760 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21761 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21762
21763 buf = wmi_buf_alloc(wmi_handle, len);
21764 if (!buf) {
21765 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21766 return QDF_STATUS_E_NOMEM;
21767 }
21768
21769 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21770 WMITLV_SET_HDR(&cmd->tlv_header,
21771 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21772 WMITLV_GET_STRUCT_TLVLEN
21773 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21774
21775 cmd->vdev_id = obss_cfg_param->vdev_id;
21776 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21777 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21778 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21779 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21780 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21781 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21782 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21783 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021784
21785 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21786 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21787 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21788 wmi_buf_free(buf);
21789 return QDF_STATUS_E_FAILURE;
21790 }
21791
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021792 return QDF_STATUS_SUCCESS;
21793}
21794
Arif Hussain33d98502018-01-12 13:15:04 -080021795/**
21796 * extract_obss_detection_info_tlv() - Extract obss detection info
21797 * received from firmware.
21798 * @evt_buf: pointer to event buffer
21799 * @obss_detection: Pointer to hold obss detection info
21800 *
21801 * Return: QDF_STATUS
21802 */
21803static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21804 struct wmi_obss_detect_info
21805 *obss_detection)
21806{
21807 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21808 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21809
21810 if (!obss_detection) {
21811 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21812 return QDF_STATUS_E_INVAL;
21813 }
21814
21815 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21816 if (!param_buf) {
21817 WMI_LOGE("%s: Invalid evt_buf", __func__);
21818 return QDF_STATUS_E_INVAL;
21819 }
21820
21821 fix_param = param_buf->fixed_param;
21822 obss_detection->vdev_id = fix_param->vdev_id;
21823 obss_detection->matched_detection_masks =
21824 fix_param->matched_detection_masks;
21825 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21826 &obss_detection->matched_bssid_addr[0]);
21827 switch (fix_param->reason) {
21828 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21829 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21830 break;
21831 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21832 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21833 break;
21834 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21835 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21836 break;
21837 default:
21838 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21839 return QDF_STATUS_E_INVAL;
21840 }
21841
21842 return QDF_STATUS_SUCCESS;
21843}
21844
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021845/**
21846 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21847 * @wmi_handle: wmi handler
21848 * @params: pointer to 11k offload params
21849 *
21850 * Return: 0 for success and non zero for failure
21851 */
21852static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21853 struct wmi_11k_offload_params *params)
21854{
21855 wmi_11k_offload_report_fixed_param *cmd;
21856 wmi_buf_t buf;
21857 QDF_STATUS status;
21858 uint8_t *buf_ptr;
21859 wmi_neighbor_report_11k_offload_tlv_param
21860 *neighbor_report_offload_params;
21861 wmi_neighbor_report_offload *neighbor_report_offload;
21862
21863 uint32_t len = sizeof(*cmd);
21864
21865 if (params->offload_11k_bitmask &
21866 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21867 len += WMI_TLV_HDR_SIZE +
21868 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21869
21870 buf = wmi_buf_alloc(wmi_handle, len);
21871 if (!buf) {
21872 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21873 __func__);
21874 return QDF_STATUS_E_NOMEM;
21875 }
21876
21877 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21878 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21879
21880 WMITLV_SET_HDR(&cmd->tlv_header,
21881 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21882 WMITLV_GET_STRUCT_TLVLEN(
21883 wmi_11k_offload_report_fixed_param));
21884
21885 cmd->vdev_id = params->vdev_id;
21886 cmd->offload_11k = params->offload_11k_bitmask;
21887
21888 if (params->offload_11k_bitmask &
21889 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21890 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21891
21892 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21893 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21894 buf_ptr += WMI_TLV_HDR_SIZE;
21895
21896 neighbor_report_offload_params =
21897 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21898 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21899 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21900 WMITLV_GET_STRUCT_TLVLEN(
21901 wmi_neighbor_report_11k_offload_tlv_param));
21902
21903 neighbor_report_offload = &neighbor_report_offload_params->
21904 neighbor_rep_ofld_params;
21905
21906 neighbor_report_offload->time_offset =
21907 params->neighbor_report_params.time_offset;
21908 neighbor_report_offload->low_rssi_offset =
21909 params->neighbor_report_params.low_rssi_offset;
21910 neighbor_report_offload->bmiss_count_trigger =
21911 params->neighbor_report_params.bmiss_count_trigger;
21912 neighbor_report_offload->per_threshold_offset =
21913 params->neighbor_report_params.per_threshold_offset;
21914 neighbor_report_offload->neighbor_report_cache_timeout =
21915 params->neighbor_report_params.
21916 neighbor_report_cache_timeout;
21917 neighbor_report_offload->max_neighbor_report_req_cap =
21918 params->neighbor_report_params.
21919 max_neighbor_report_req_cap;
21920 neighbor_report_offload->ssid.ssid_len =
21921 params->neighbor_report_params.ssid.length;
21922 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21923 &params->neighbor_report_params.ssid.mac_ssid,
21924 neighbor_report_offload->ssid.ssid_len);
21925 }
21926
21927 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21928 WMI_11K_OFFLOAD_REPORT_CMDID);
21929 if (status != QDF_STATUS_SUCCESS) {
21930 WMI_LOGE("%s: failed to send 11k offload command %d",
21931 __func__, status);
21932 wmi_buf_free(buf);
21933 }
21934
21935 return status;
21936}
21937
21938/**
21939 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
21940 * command
21941 * @wmi_handle: wmi handler
21942 * @params: pointer to neighbor report invoke params
21943 *
21944 * Return: 0 for success and non zero for failure
21945 */
21946static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
21947 struct wmi_invoke_neighbor_report_params *params)
21948{
21949 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
21950 wmi_buf_t buf;
21951 QDF_STATUS status;
21952 uint8_t *buf_ptr;
21953 uint32_t len = sizeof(*cmd);
21954
21955 buf = wmi_buf_alloc(wmi_handle, len);
21956 if (!buf) {
21957 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
21958 __func__);
21959 return QDF_STATUS_E_NOMEM;
21960 }
21961
21962 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21963 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
21964
21965 WMITLV_SET_HDR(&cmd->tlv_header,
21966 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
21967 WMITLV_GET_STRUCT_TLVLEN(
21968 wmi_11k_offload_invoke_neighbor_report_fixed_param));
21969
21970 cmd->vdev_id = params->vdev_id;
21971 cmd->flags = params->send_resp_to_host;
21972
21973 cmd->ssid.ssid_len = params->ssid.length;
21974 qdf_mem_copy(cmd->ssid.ssid,
21975 &params->ssid.mac_ssid,
21976 cmd->ssid.ssid_len);
21977
21978 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21979 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
21980 if (status != QDF_STATUS_SUCCESS) {
21981 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
21982 __func__, status);
21983 wmi_buf_free(buf);
21984 }
21985
21986 return status;
21987}
21988
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021989#ifdef WLAN_SUPPORT_GREEN_AP
21990static QDF_STATUS extract_green_ap_egap_status_info_tlv(
21991 uint8_t *evt_buf,
21992 struct wlan_green_ap_egap_status_info *egap_status_info_params)
21993{
21994 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
21995 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
21996 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
21997
21998 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
21999 if (!param_buf) {
22000 WMI_LOGE("Invalid EGAP Info status event buffer");
22001 return QDF_STATUS_E_INVAL;
22002 }
22003
22004 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
22005 param_buf->fixed_param;
22006 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
22007 param_buf->chainmask_list;
22008
22009 egap_status_info_params->status = egap_info_event->status;
22010 egap_status_info_params->mac_id = chainmask_event->mac_id;
22011 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
22012 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
22013
22014 return QDF_STATUS_SUCCESS;
22015}
22016#endif
22017
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022018/*
22019 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
22020 * updating bss color change within firmware when AP announces bss color change.
22021 * @wmi_handle: wmi handle
22022 * @vdev_id: vdev ID
22023 * @enable: enable bss color change within firmware
22024 *
22025 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
22026 *
22027 * Return: QDF_STATUS
22028 */
22029static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
22030 uint32_t vdev_id,
22031 bool enable)
22032{
22033 wmi_buf_t buf;
22034 wmi_bss_color_change_enable_fixed_param *cmd;
22035 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
22036
22037 buf = wmi_buf_alloc(wmi_handle, len);
22038 if (!buf) {
22039 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22040 return QDF_STATUS_E_NOMEM;
22041 }
22042
22043 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
22044 WMITLV_SET_HDR(&cmd->tlv_header,
22045 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
22046 WMITLV_GET_STRUCT_TLVLEN
22047 (wmi_bss_color_change_enable_fixed_param));
22048 cmd->vdev_id = vdev_id;
22049 cmd->enable = enable;
22050 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22051 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
22052 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
22053 wmi_buf_free(buf);
22054 return QDF_STATUS_E_FAILURE;
22055 }
22056
22057 return QDF_STATUS_SUCCESS;
22058}
22059
22060/**
22061 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
22062 * configurations to firmware.
22063 * @wmi_handle: wmi handle
22064 * @cfg_param: obss detection configurations
22065 *
22066 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
22067 *
22068 * Return: QDF_STATUS
22069 */
22070static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
22071 wmi_unified_t wmi_handle,
22072 struct wmi_obss_color_collision_cfg_param *cfg_param)
22073{
22074 wmi_buf_t buf;
22075 wmi_obss_color_collision_det_config_fixed_param *cmd;
22076 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
22077
22078 buf = wmi_buf_alloc(wmi_handle, len);
22079 if (!buf) {
22080 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22081 return QDF_STATUS_E_NOMEM;
22082 }
22083
22084 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
22085 buf);
22086 WMITLV_SET_HDR(&cmd->tlv_header,
22087 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
22088 WMITLV_GET_STRUCT_TLVLEN
22089 (wmi_obss_color_collision_det_config_fixed_param));
22090 cmd->vdev_id = cfg_param->vdev_id;
22091 cmd->flags = cfg_param->flags;
22092 cmd->current_bss_color = cfg_param->current_bss_color;
22093 cmd->detection_period_ms = cfg_param->detection_period_ms;
22094 cmd->scan_period_ms = cfg_param->scan_period_ms;
22095 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
22096
22097 switch (cfg_param->evt_type) {
22098 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
22099 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
22100 break;
22101 case OBSS_COLOR_COLLISION_DETECTION:
22102 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
22103 break;
22104 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22105 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22106 break;
22107 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
22108 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
22109 break;
22110 default:
22111 WMI_LOGE("%s: invalid event type: %d",
22112 __func__, cfg_param->evt_type);
22113 wmi_buf_free(buf);
22114 return QDF_STATUS_E_FAILURE;
22115 }
22116
22117 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22118 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
22119 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
22120 __func__, cfg_param->vdev_id);
22121 wmi_buf_free(buf);
22122 return QDF_STATUS_E_FAILURE;
22123 }
22124
22125 return QDF_STATUS_SUCCESS;
22126}
22127
22128/**
22129 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
22130 * received from firmware.
22131 * @evt_buf: pointer to event buffer
22132 * @info: Pointer to hold bss collision info
22133 *
22134 * Return: QDF_STATUS
22135 */
22136static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
22137 struct wmi_obss_color_collision_info *info)
22138{
22139 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
22140 wmi_obss_color_collision_evt_fixed_param *fix_param;
22141
22142 if (!info) {
22143 WMI_LOGE("%s: Invalid obss color buffer", __func__);
22144 return QDF_STATUS_E_INVAL;
22145 }
22146
22147 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
22148 evt_buf;
22149 if (!param_buf) {
22150 WMI_LOGE("%s: Invalid evt_buf", __func__);
22151 return QDF_STATUS_E_INVAL;
22152 }
22153
22154 fix_param = param_buf->fixed_param;
22155 info->vdev_id = fix_param->vdev_id;
22156 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
22157 info->obss_color_bitmap_bit32to63 =
22158 fix_param->bss_color_bitmap_bit32to63;
22159
22160 switch (fix_param->evt_type) {
22161 case WMI_BSS_COLOR_COLLISION_DISABLE:
22162 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
22163 break;
22164 case WMI_BSS_COLOR_COLLISION_DETECTION:
22165 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
22166 break;
22167 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22168 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22169 break;
22170 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
22171 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
22172 break;
22173 default:
22174 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
22175 __func__, fix_param->evt_type, fix_param->vdev_id);
22176 return QDF_STATUS_E_FAILURE;
22177 }
22178
22179 return QDF_STATUS_SUCCESS;
22180}
22181
Govind Singh5eb51532016-03-09 11:34:12 +053022182struct wmi_ops tlv_ops = {
22183 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
22184 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
22185 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053022186 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
22187 .send_hidden_ssid_vdev_restart_cmd =
22188 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022189 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
22190 .send_peer_param_cmd = send_peer_param_cmd_tlv,
22191 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022192 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022193 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022194 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070022195 .send_peer_rx_reorder_queue_setup_cmd =
22196 send_peer_rx_reorder_queue_setup_cmd_tlv,
22197 .send_peer_rx_reorder_queue_remove_cmd =
22198 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053022199 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
22200 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
22201 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022202 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
22203 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022204 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022205 .send_suspend_cmd = send_suspend_cmd_tlv,
22206 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080022207#ifdef FEATURE_WLAN_D0WOW
22208 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
22209 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
22210#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022211 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
22212 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
22213 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
22214 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
22215 .send_dbglog_cmd = send_dbglog_cmd_tlv,
22216 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
22217 .send_stats_request_cmd = send_stats_request_cmd_tlv,
22218 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053022219 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070022220 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022221 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022222 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022223 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
22224 .send_scan_start_cmd = send_scan_start_cmd_tlv,
22225 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
22226 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022227 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022228 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022229 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
22230 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022231 .send_set_sta_uapsd_auto_trig_cmd =
22232 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022233 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
22234 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
22235 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022236#ifdef CONVERGED_P2P_ENABLE
22237 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
22238 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
22239#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053022240 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
22241 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022242#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053022243 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
22244 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
22245 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
22246 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
22247 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
22248 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
22249 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022250 .send_ocb_start_timing_advert_cmd =
22251 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022252 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
22253 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
22254 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
22255 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
22256#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053022257 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
22258 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
22259 .send_set_mcc_channel_time_latency_cmd =
22260 send_set_mcc_channel_time_latency_cmd_tlv,
22261 .send_set_mcc_channel_time_quota_cmd =
22262 send_set_mcc_channel_time_quota_cmd_tlv,
22263 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
22264 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053022265 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022266 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
22267 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
22268 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022269 .send_probe_rsp_tmpl_send_cmd =
22270 send_probe_rsp_tmpl_send_cmd_tlv,
22271 .send_p2p_go_set_beacon_ie_cmd =
22272 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053022273 .send_setup_install_key_cmd =
22274 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022275 .send_set_gateway_params_cmd =
22276 send_set_gateway_params_cmd_tlv,
22277 .send_set_rssi_monitoring_cmd =
22278 send_set_rssi_monitoring_cmd_tlv,
22279 .send_scan_probe_setoui_cmd =
22280 send_scan_probe_setoui_cmd_tlv,
22281 .send_reset_passpoint_network_list_cmd =
22282 send_reset_passpoint_network_list_cmd_tlv,
22283 .send_set_passpoint_network_list_cmd =
22284 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022285 .send_roam_scan_offload_rssi_thresh_cmd =
22286 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070022287 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022288 .send_roam_scan_filter_cmd =
22289 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022290 .send_set_epno_network_list_cmd =
22291 send_set_epno_network_list_cmd_tlv,
22292 .send_ipa_offload_control_cmd =
22293 send_ipa_offload_control_cmd_tlv,
22294 .send_extscan_get_capabilities_cmd =
22295 send_extscan_get_capabilities_cmd_tlv,
22296 .send_extscan_get_cached_results_cmd =
22297 send_extscan_get_cached_results_cmd_tlv,
22298 .send_extscan_stop_change_monitor_cmd =
22299 send_extscan_stop_change_monitor_cmd_tlv,
22300 .send_extscan_start_change_monitor_cmd =
22301 send_extscan_start_change_monitor_cmd_tlv,
22302 .send_extscan_stop_hotlist_monitor_cmd =
22303 send_extscan_stop_hotlist_monitor_cmd_tlv,
22304 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
22305 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
22306 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
22307 .send_plm_start_cmd = send_plm_start_cmd_tlv,
22308 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
22309 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070022310 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022311 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
22312 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
22313 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
22314 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053022315 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022316 .send_snr_request_cmd = send_snr_request_cmd_tlv,
22317 .send_snr_cmd = send_snr_cmd_tlv,
22318 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022319#ifdef WLAN_PMO_ENABLE
22320 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
22321 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
22322 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
22323 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053022324 .send_multiple_add_clear_mcbc_filter_cmd =
22325 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070022326 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022327 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
22328 .send_process_gtk_offload_getinfo_cmd =
22329 send_process_gtk_offload_getinfo_cmd_tlv,
22330 .send_enable_enhance_multicast_offload_cmd =
22331 send_enable_enhance_multicast_offload_tlv,
22332 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
22333#ifdef FEATURE_WLAN_RA_FILTERING
22334 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
22335#endif
22336 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022337 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
22338 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022339 .send_lphb_config_tcp_pkt_filter_cmd =
22340 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022341 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22342 .send_lphb_config_udp_pkt_filter_cmd =
22343 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022344 .send_enable_disable_packet_filter_cmd =
22345 send_enable_disable_packet_filter_cmd_tlv,
22346 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022347#endif /* End of WLAN_PMO_ENABLE */
22348#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022349 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22350 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022351 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022352 .send_roam_scan_offload_mode_cmd =
22353 send_roam_scan_offload_mode_cmd_tlv,
22354 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
22355 .send_roam_scan_offload_ap_profile_cmd =
22356 send_roam_scan_offload_ap_profile_cmd_tlv,
22357#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022358#ifdef WLAN_SUPPORT_GREEN_AP
22359 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22360 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022361 .extract_green_ap_egap_status_info =
22362 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022363#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022364 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22365 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022366 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022367 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022368 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022369#ifdef WLAN_FEATURE_CIF_CFR
22370 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22371#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022372 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022373 .send_dfs_phyerr_filter_offload_en_cmd =
22374 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022375 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22376 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22377 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22378 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22379 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022380 .send_process_add_periodic_tx_ptrn_cmd =
22381 send_process_add_periodic_tx_ptrn_cmd_tlv,
22382 .send_process_del_periodic_tx_ptrn_cmd =
22383 send_process_del_periodic_tx_ptrn_cmd_tlv,
22384 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22385 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22386 .send_set_app_type2_params_in_fw_cmd =
22387 send_set_app_type2_params_in_fw_cmd_tlv,
22388 .send_set_auto_shutdown_timer_cmd =
22389 send_set_auto_shutdown_timer_cmd_tlv,
22390 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22391 .send_process_dhcpserver_offload_cmd =
22392 send_process_dhcpserver_offload_cmd_tlv,
22393 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22394 .send_process_ch_avoid_update_cmd =
22395 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022396 .send_pdev_set_regdomain_cmd =
22397 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022398 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22399 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22400 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22401 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022402 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022403 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022404 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022405 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022406 .send_set_base_macaddr_indicate_cmd =
22407 send_set_base_macaddr_indicate_cmd_tlv,
22408 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22409 .send_enable_specific_fw_logs_cmd =
22410 send_enable_specific_fw_logs_cmd_tlv,
22411 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022412 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022413 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022414 .send_pdev_set_dual_mac_config_cmd =
22415 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022416 .send_app_type1_params_in_fw_cmd =
22417 send_app_type1_params_in_fw_cmd_tlv,
22418 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22419 .send_process_roam_synch_complete_cmd =
22420 send_process_roam_synch_complete_cmd_tlv,
22421 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22422 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22423 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022424 .send_roam_scan_offload_scan_period_cmd =
22425 send_roam_scan_offload_scan_period_cmd_tlv,
22426 .send_roam_scan_offload_chan_list_cmd =
22427 send_roam_scan_offload_chan_list_cmd_tlv,
22428 .send_roam_scan_offload_rssi_change_cmd =
22429 send_roam_scan_offload_rssi_change_cmd_tlv,
22430 .send_get_buf_extscan_hotlist_cmd =
22431 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080022432 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053022433 .send_adapt_dwelltime_params_cmd =
22434 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022435 .send_dbs_scan_sel_params_cmd =
22436 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022437 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022438 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22439 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22440 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22441 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22442 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22443 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022444 .send_vdev_set_custom_aggr_size_cmd =
22445 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022446 .send_vdev_set_qdepth_thresh_cmd =
22447 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022448 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22449 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22450 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022451 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22452 .send_smart_ant_set_training_info_cmd =
22453 send_smart_ant_set_training_info_cmd_tlv,
22454 .send_smart_ant_set_node_config_cmd =
22455 send_smart_ant_set_node_config_cmd_tlv,
22456 .send_set_atf_cmd = send_set_atf_cmd_tlv,
22457 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22458 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022459 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22460 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22461 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22462 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022463 .send_periodic_chan_stats_config_cmd =
22464 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022465 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22466 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22467 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022468 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22469 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22470 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22471 .send_vdev_spectral_configure_cmd =
22472 send_vdev_spectral_configure_cmd_tlv,
22473 .send_vdev_spectral_enable_cmd =
22474 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022475 .send_thermal_mitigation_param_cmd =
22476 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022477 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22478 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022479 .send_process_update_edca_param_cmd =
22480 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022481 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022482 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022483 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022484 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22485 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022486 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022487 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22488 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22489 .extract_host_mem_req = extract_host_mem_req_tlv,
22490 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022491 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022492 .is_service_enabled = is_service_enabled_tlv,
22493 .save_fw_version = save_fw_version_in_service_ready_tlv,
22494 .ready_extract_init_status = ready_extract_init_status_tlv,
22495 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022496 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022497 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022498 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22499 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022500 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022501 .extract_tbttoffset_update_params =
22502 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022503 .extract_ext_tbttoffset_update_params =
22504 extract_ext_tbttoffset_update_params_tlv,
22505 .extract_tbttoffset_num_vdevs =
22506 extract_tbttoffset_num_vdevs_tlv,
22507 .extract_ext_tbttoffset_num_vdevs =
22508 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022509 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22510 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22511 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22512 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022513#ifdef CONVERGED_TDLS_ENABLE
22514 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22515#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022516 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022517 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022518 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22519 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022520#ifdef CONVERGED_P2P_ENABLE
22521 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22522 .extract_p2p_lo_stop_ev_param =
22523 extract_p2p_lo_stop_ev_param_tlv,
22524#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022525 .extract_offchan_data_tx_compl_param =
22526 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022527 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22528 .extract_all_stats_count = extract_all_stats_counts_tlv,
22529 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022530 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022531 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22532 .extract_vdev_stats = extract_vdev_stats_tlv,
22533 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022534 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022535 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22536 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22537 .extract_chan_stats = extract_chan_stats_tlv,
22538 .extract_profile_ctx = extract_profile_ctx_tlv,
22539 .extract_profile_data = extract_profile_data_tlv,
22540 .extract_chan_info_event = extract_chan_info_event_tlv,
22541 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022542 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022543#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022544 .send_encrypt_decrypt_send_cmd =
22545 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022546 .extract_encrypt_decrypt_resp_event =
22547 extract_encrypt_decrypt_resp_event_tlv,
22548#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022549 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022550 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22551 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022552 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022553 .send_multiple_vdev_restart_req_cmd =
22554 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022555 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22556 .extract_hw_mode_cap_service_ready_ext =
22557 extract_hw_mode_cap_service_ready_ext_tlv,
22558 .extract_mac_phy_cap_service_ready_ext =
22559 extract_mac_phy_cap_service_ready_ext_tlv,
22560 .extract_reg_cap_service_ready_ext =
22561 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022562 .extract_dbr_ring_cap_service_ready_ext =
22563 extract_dbr_ring_cap_service_ready_ext_tlv,
22564 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22565 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022566 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022567 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022568 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22569 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22570 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022571 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022572 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022573 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022574 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022575 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022576 .extract_pdev_csa_switch_count_status =
22577 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022578 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022579 .extract_pdev_tpc_config_ev_param =
22580 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022581 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022582 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22583 .extract_peer_sta_ps_statechange_ev =
22584 extract_peer_sta_ps_statechange_ev_tlv,
22585 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022586 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080022587 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22588 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022589 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022590 extract_reg_chan_list_update_event_tlv,
22591 .extract_chainmask_tables =
22592 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022593 .extract_thermal_stats = extract_thermal_stats_tlv,
22594 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022595 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22596 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022597#ifdef DFS_COMPONENT_ENABLE
22598 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22599 .extract_dfs_radar_detection_event =
22600 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022601 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022602#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022603 .convert_pdev_id_host_to_target =
22604 convert_host_pdev_id_to_target_pdev_id_legacy,
22605 .convert_pdev_id_target_to_host =
22606 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022607
22608 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22609 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22610 .extract_reg_11d_new_country_event =
22611 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022612 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022613 .send_limit_off_chan_cmd =
22614 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022615 .extract_reg_ch_avoid_event =
22616 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022617 .send_pdev_caldata_version_check_cmd =
22618 send_pdev_caldata_version_check_cmd_tlv,
22619 .extract_pdev_caldata_version_check_ev_param =
22620 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022621 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22622 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022623 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22624#if defined(WLAN_FEATURE_FILS_SK)
22625 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22626#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022627 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022628#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22629 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22630 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22631 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22632 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22633 .extract_ndp_ind = extract_ndp_ind_tlv,
22634 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22635 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22636 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22637 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
22638#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022639 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022640 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022641 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022642#ifdef WLAN_SUPPORT_FILS
22643 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22644 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22645 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22646#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022647 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22648 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022649 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22650 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22651 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22652 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022653 .send_bss_color_change_enable_cmd =
22654 send_bss_color_change_enable_cmd_tlv,
22655 .send_obss_color_collision_cfg_cmd =
22656 send_obss_color_collision_cfg_cmd_tlv,
22657 .extract_obss_color_collision_info =
22658 extract_obss_color_collision_info_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022659};
22660
Govind Singhe7f2f342016-05-23 12:12:52 +053022661/**
22662 * populate_tlv_event_id() - populates wmi event ids
22663 *
22664 * @param event_ids: Pointer to hold event ids
22665 * Return: None
22666 */
22667static void populate_tlv_events_id(uint32_t *event_ids)
22668{
22669 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22670 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22671 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22672 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22673 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22674 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22675 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22676 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22677 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22678 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22679 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22680 event_ids[wmi_service_ready_ext_event_id] =
22681 WMI_SERVICE_READY_EXT_EVENTID;
22682 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22683 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22684 event_ids[wmi_vdev_install_key_complete_event_id] =
22685 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22686 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22687 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22688
22689 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22690 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22691 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22692 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22693 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22694 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22695 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22696 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022697 event_ids[wmi_peer_delete_response_event_id] =
22698 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022699 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22700 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22701 event_ids[wmi_tbttoffset_update_event_id] =
22702 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022703 event_ids[wmi_ext_tbttoffset_update_event_id] =
22704 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022705 event_ids[wmi_offload_bcn_tx_status_event_id] =
22706 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22707 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22708 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22709 event_ids[wmi_mgmt_tx_completion_event_id] =
22710 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022711 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22712 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022713 event_ids[wmi_tx_delba_complete_event_id] =
22714 WMI_TX_DELBA_COMPLETE_EVENTID;
22715 event_ids[wmi_tx_addba_complete_event_id] =
22716 WMI_TX_ADDBA_COMPLETE_EVENTID;
22717 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22718
22719 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22720
22721 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22722 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22723
22724 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022725 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022726
22727 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22728
22729 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022730 event_ids[wmi_p2p_lo_stop_event_id] =
22731 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022732 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22733 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022734 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022735 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22736 event_ids[wmi_wow_initial_wakeup_event_id] =
22737 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22738
22739 event_ids[wmi_rtt_meas_report_event_id] =
22740 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22741 event_ids[wmi_tsf_meas_report_event_id] =
22742 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22743 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22744 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22745 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22746 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22747 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022748 event_ids[wmi_diag_event_id_log_supported_event_id] =
22749 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22750 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22751 event_ids[wmi_nlo_scan_complete_event_id] =
22752 WMI_NLO_SCAN_COMPLETE_EVENTID;
22753 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22754 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22755
22756 event_ids[wmi_gtk_offload_status_event_id] =
22757 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22758 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22759 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22760 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22761
22762 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22763
22764 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22765
22766 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22767 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22768 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22769 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22770 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22771 event_ids[wmi_wlan_profile_data_event_id] =
22772 WMI_WLAN_PROFILE_DATA_EVENTID;
22773 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22774 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22775 event_ids[wmi_vdev_get_keepalive_event_id] =
22776 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22777 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22778
22779 event_ids[wmi_diag_container_event_id] =
22780 WMI_DIAG_DATA_CONTAINER_EVENTID;
22781
22782 event_ids[wmi_host_auto_shutdown_event_id] =
22783 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22784
22785 event_ids[wmi_update_whal_mib_stats_event_id] =
22786 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22787
22788 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22789 event_ids[wmi_update_vdev_rate_stats_event_id] =
22790 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22791
22792 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022793 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022794
22795 /** Set OCB Sched Response, deprecated */
22796 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
22797
22798 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
22799 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
22800 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
22801
22802 /* GPIO Event */
22803 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
22804 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
22805
22806 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
22807 event_ids[wmi_rfkill_state_change_event_id] =
22808 WMI_RFKILL_STATE_CHANGE_EVENTID;
22809
22810 /* TDLS Event */
22811 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
22812
22813 event_ids[wmi_batch_scan_enabled_event_id] =
22814 WMI_BATCH_SCAN_ENABLED_EVENTID;
22815 event_ids[wmi_batch_scan_result_event_id] =
22816 WMI_BATCH_SCAN_RESULT_EVENTID;
22817 /* OEM Event */
22818 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
22819 event_ids[wmi_oem_meas_report_event_id] =
22820 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
22821 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
22822
22823 /* NAN Event */
22824 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
22825
22826 /* LPI Event */
22827 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
22828 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
22829 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
22830
22831 /* ExtScan events */
22832 event_ids[wmi_extscan_start_stop_event_id] =
22833 WMI_EXTSCAN_START_STOP_EVENTID;
22834 event_ids[wmi_extscan_operation_event_id] =
22835 WMI_EXTSCAN_OPERATION_EVENTID;
22836 event_ids[wmi_extscan_table_usage_event_id] =
22837 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
22838 event_ids[wmi_extscan_cached_results_event_id] =
22839 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
22840 event_ids[wmi_extscan_wlan_change_results_event_id] =
22841 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
22842 event_ids[wmi_extscan_hotlist_match_event_id] =
22843 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
22844 event_ids[wmi_extscan_capabilities_event_id] =
22845 WMI_EXTSCAN_CAPABILITIES_EVENTID;
22846 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
22847 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
22848
22849 /* mDNS offload events */
22850 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
22851
22852 /* SAP Authentication offload events */
22853 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
22854 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
22855
22856 /** Out-of-context-of-bss (OCB) events */
22857 event_ids[wmi_ocb_set_config_resp_event_id] =
22858 WMI_OCB_SET_CONFIG_RESP_EVENTID;
22859 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
22860 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
22861 event_ids[wmi_dcc_get_stats_resp_event_id] =
22862 WMI_DCC_GET_STATS_RESP_EVENTID;
22863 event_ids[wmi_dcc_update_ndl_resp_event_id] =
22864 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
22865 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
22866 /* System-On-Chip events */
22867 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
22868 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
22869 event_ids[wmi_soc_hw_mode_transition_event_id] =
22870 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
22871 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
22872 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022873 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053022874 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
22875 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022876 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053022877 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
22878 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22879 event_ids[wmi_peer_sta_ps_statechg_event_id] =
22880 WMI_PEER_STA_PS_STATECHG_EVENTID;
22881 event_ids[wmi_pdev_channel_hopping_event_id] =
22882 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022883 event_ids[wmi_offchan_data_tx_completion_event] =
22884 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022885 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
22886 event_ids[wmi_dfs_radar_detection_event_id] =
22887 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022888 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070022889 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053022890 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053022891 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022892 event_ids[wmi_service_available_event_id] =
22893 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022894 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022895 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022896 /* NDP events */
22897 event_ids[wmi_ndp_initiator_rsp_event_id] =
22898 WMI_NDP_INITIATOR_RSP_EVENTID;
22899 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
22900 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
22901 event_ids[wmi_ndp_responder_rsp_event_id] =
22902 WMI_NDP_RESPONDER_RSP_EVENTID;
22903 event_ids[wmi_ndp_end_indication_event_id] =
22904 WMI_NDP_END_INDICATION_EVENTID;
22905 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
22906
22907 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
22908 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
22909 event_ids[wmi_pdev_chip_power_stats_event_id] =
22910 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
22911 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
22912 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
22913 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
22914 event_ids[wmi_bpf_capability_info_event_id] =
22915 WMI_BPF_CAPABILIY_INFO_EVENTID;
22916 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
22917 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
22918 event_ids[wmi_report_rx_aggr_failure_event_id] =
22919 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
22920 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
22921 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
22922 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
22923 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
22924 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
22925 event_ids[wmi_pdev_hw_mode_transition_event_id] =
22926 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
22927 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
22928 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
22929 event_ids[wmi_coex_bt_activity_event_id] =
22930 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
22931 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
22932 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
22933 event_ids[wmi_radio_tx_power_level_stats_event_id] =
22934 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
22935 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053022936 event_ids[wmi_dma_buf_release_event_id] =
22937 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022938 event_ids[wmi_sap_obss_detection_report_event_id] =
22939 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022940 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080022941 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022942 event_ids[wmi_obss_color_collision_report_event_id] =
22943 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022944}
22945
Soumya Bhat488092d2017-03-22 14:41:01 +053022946/**
22947 * populate_tlv_service() - populates wmi services
22948 *
22949 * @param wmi_service: Pointer to hold wmi_service
22950 * Return: None
22951 */
22952static void populate_tlv_service(uint32_t *wmi_service)
22953{
22954 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022955 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022956 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
22957 wmi_service[wmi_service_roam_scan_offload] =
22958 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
22959 wmi_service[wmi_service_bcn_miss_offload] =
22960 WMI_SERVICE_BCN_MISS_OFFLOAD;
22961 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
22962 wmi_service[wmi_service_sta_advanced_pwrsave] =
22963 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
22964 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
22965 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
22966 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
22967 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
22968 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
22969 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
22970 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
22971 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
22972 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
22973 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
22974 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
22975 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
22976 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
22977 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
22978 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
22979 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
22980 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
22981 wmi_service[wmi_service_packet_power_save] =
22982 WMI_SERVICE_PACKET_POWER_SAVE;
22983 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
22984 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
22985 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
22986 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
22987 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
22988 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
22989 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
22990 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
22991 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
22992 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
22993 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
22994 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
22995 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
22996 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
22997 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
22998 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
22999 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
23000 wmi_service[wmi_service_mcc_bcn_interval_change] =
23001 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
23002 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
23003 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
23004 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
23005 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
23006 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
23007 wmi_service[wmi_service_lte_ant_share_support] =
23008 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
23009 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
23010 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
23011 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
23012 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
23013 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
23014 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
23015 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
23016 wmi_service[wmi_service_bcn_txrate_override] =
23017 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
23018 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
23019 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
23020 wmi_service[wmi_service_estimate_linkspeed] =
23021 WMI_SERVICE_ESTIMATE_LINKSPEED;
23022 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
23023 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
23024 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
23025 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
23026 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
23027 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
23028 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
23029 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
23030 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
23031 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
23032 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
23033 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
23034 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
23035 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
23036 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
23037 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
23038 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
23039 wmi_service[wmi_service_sap_auth_offload] =
23040 WMI_SERVICE_SAP_AUTH_OFFLOAD;
23041 wmi_service[wmi_service_dual_band_simultaneous_support] =
23042 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
23043 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
23044 wmi_service[wmi_service_ap_arpns_offload] =
23045 WMI_SERVICE_AP_ARPNS_OFFLOAD;
23046 wmi_service[wmi_service_per_band_chainmask_support] =
23047 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
23048 wmi_service[wmi_service_packet_filter_offload] =
23049 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
23050 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
23051 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
23052 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
23053 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
23054 wmi_service[wmi_service_multiple_vdev_restart] =
23055 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
23056
23057 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
23058 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
23059 wmi_service[wmi_service_smart_antenna_sw_support] =
23060 WMI_SERVICE_UNAVAILABLE;
23061 wmi_service[wmi_service_smart_antenna_hw_support] =
23062 WMI_SERVICE_UNAVAILABLE;
23063 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053023064 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023065 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053023066 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
23067 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
23068 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
23069 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
23070 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
23071 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
23072 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
23073 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053023074 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
23075 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
23076 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053023077 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023078 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
23079 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
23080 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
23081 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
23082 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
23083 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053023084 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
23085 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
23086 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
23087 wmi_service[wmi_service_unified_wow_capability] =
23088 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
23089 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
23090 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
23091 wmi_service[wmi_service_sync_delete_cmds] =
23092 WMI_SERVICE_SYNC_DELETE_CMDS;
23093 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
23094 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
23095 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
23096 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
23097 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
23098 wmi_service[wmi_service_deprecated_replace] =
23099 WMI_SERVICE_DEPRECATED_REPLACE;
23100 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
23101 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
23102 wmi_service[wmi_service_enhanced_mcast_filter] =
23103 WMI_SERVICE_ENHANCED_MCAST_FILTER;
23104 wmi_service[wmi_service_half_rate_quarter_rate_support] =
23105 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
23106 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
23107 wmi_service[wmi_service_p2p_listen_offload_support] =
23108 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
23109 wmi_service[wmi_service_mark_first_wakeup_packet] =
23110 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
23111 wmi_service[wmi_service_multiple_mcast_filter_set] =
23112 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
23113 wmi_service[wmi_service_host_managed_rx_reorder] =
23114 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
23115 wmi_service[wmi_service_flash_rdwr_support] =
23116 WMI_SERVICE_FLASH_RDWR_SUPPORT;
23117 wmi_service[wmi_service_wlan_stats_report] =
23118 WMI_SERVICE_WLAN_STATS_REPORT;
23119 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
23120 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
23121 wmi_service[wmi_service_dfs_phyerr_offload] =
23122 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
23123 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
23124 wmi_service[wmi_service_fw_mem_dump_support] =
23125 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
23126 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
23127 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
23128 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
23129 wmi_service[wmi_service_hw_data_filtering] =
23130 WMI_SERVICE_HW_DATA_FILTERING;
23131 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
23132 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053023133 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053023134 wmi_service[wmi_service_extended_nss_support] =
23135 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053023136 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053023137 wmi_service[wmi_service_bcn_offload_start_stop_support] =
23138 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053023139 wmi_service[wmi_service_offchan_data_tid_support] =
23140 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053023141 wmi_service[wmi_service_support_dma] =
23142 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023143 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
23144 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
23145 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053023146 wmi_service[wmi_service_11k_neighbour_report_support] =
23147 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080023148 wmi_service[wmi_service_ap_obss_detection_offload] =
23149 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
23150 wmi_service[wmi_service_bss_color_offload] =
23151 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053023152 wmi_service[wmi_service_gmac_offload_support] =
23153 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023154
Soumya Bhat488092d2017-03-22 14:41:01 +053023155}
23156
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023157#ifndef CONFIG_MCL
23158
Govind Singhe7f2f342016-05-23 12:12:52 +053023159/**
23160 * populate_pdev_param_tlv() - populates pdev params
23161 *
23162 * @param pdev_param: Pointer to hold pdev params
23163 * Return: None
23164 */
23165static void populate_pdev_param_tlv(uint32_t *pdev_param)
23166{
23167 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
23168 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
23169 pdev_param[wmi_pdev_param_txpower_limit2g] =
23170 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
23171 pdev_param[wmi_pdev_param_txpower_limit5g] =
23172 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
23173 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
23174 pdev_param[wmi_pdev_param_beacon_gen_mode] =
23175 WMI_PDEV_PARAM_BEACON_GEN_MODE;
23176 pdev_param[wmi_pdev_param_beacon_tx_mode] =
23177 WMI_PDEV_PARAM_BEACON_TX_MODE;
23178 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
23179 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
23180 pdev_param[wmi_pdev_param_protection_mode] =
23181 WMI_PDEV_PARAM_PROTECTION_MODE;
23182 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
23183 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
23184 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
23185 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
23186 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
23187 pdev_param[wmi_pdev_param_sta_kickout_th] =
23188 WMI_PDEV_PARAM_STA_KICKOUT_TH;
23189 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
23190 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
23191 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
23192 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
23193 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
23194 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
23195 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
23196 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
23197 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
23198 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
23199 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
23200 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
23201 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
23202 pdev_param[wmi_pdev_param_ltr_sleep_override] =
23203 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
23204 pdev_param[wmi_pdev_param_ltr_rx_override] =
23205 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
23206 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
23207 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
23208 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
23209 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
23210 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
23211 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
23212 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
23213 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
23214 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
23215 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
23216 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
23217 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
23218 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
23219 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
23220 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
23221 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
23222 pdev_param[wmi_pdev_param_peer_stats_update_period] =
23223 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
23224 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
23225 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
23226 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
23227 pdev_param[wmi_pdev_param_arp_ac_override] =
23228 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
23229 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
23230 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
23231 pdev_param[wmi_pdev_param_ani_poll_period] =
23232 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
23233 pdev_param[wmi_pdev_param_ani_listen_period] =
23234 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
23235 pdev_param[wmi_pdev_param_ani_ofdm_level] =
23236 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
23237 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
23238 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
23239 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
23240 pdev_param[wmi_pdev_param_idle_ps_config] =
23241 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
23242 pdev_param[wmi_pdev_param_power_gating_sleep] =
23243 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
23244 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
23245 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
23246 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
23247 pdev_param[wmi_pdev_param_hw_rfkill_config] =
23248 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
23249 pdev_param[wmi_pdev_param_low_power_rf_enable] =
23250 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
23251 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
23252 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
23253 pdev_param[wmi_pdev_param_power_collapse_enable] =
23254 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
23255 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
23256 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
23257 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
23258 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
23259 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
23260 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
23261 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
23262 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
23263 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
23264 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
23265 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
23266 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
23267 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
23268 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
23269 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
23270 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
23271 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
23272 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
23273 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
23274 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
23275 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
23276 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
23277 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
23278 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
23279 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
23280 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
23281 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
23282 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
23283 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
23284 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
23285 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
23286 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
23287 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
23288 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
23289 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
23290 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
23291 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
23292 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
23293 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23294 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23295 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23296 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23297 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23298 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023299 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23300 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23301 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023302 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23303 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023304 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023305 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023306 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23307 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23308 WMI_PDEV_PARAM_PROXY_STA_MODE;
23309 pdev_param[wmi_pdev_param_mu_group_policy] =
23310 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23311 pdev_param[wmi_pdev_param_noise_detection] =
23312 WMI_PDEV_PARAM_NOISE_DETECTION;
23313 pdev_param[wmi_pdev_param_noise_threshold] =
23314 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23315 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23316 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23317 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023318 pdev_param[wmi_pdev_param_atf_strict_sch] =
23319 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23320 pdev_param[wmi_pdev_param_atf_sched_duration] =
23321 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023322 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23323 pdev_param[wmi_pdev_param_sensitivity_level] =
23324 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23325 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23326 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23327 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23328 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023329 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23330 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23331 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23332 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023333 pdev_param[wmi_pdev_param_cca_threshold] =
23334 WMI_PDEV_PARAM_CCA_THRESHOLD;
23335 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23336 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023337 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023338 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23339 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23340 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23341 pdev_param[wmi_pdev_param_arp_srcaddr] =
23342 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23343 pdev_param[wmi_pdev_param_arp_dstaddr] =
23344 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23345 pdev_param[wmi_pdev_param_txpower_decr_db] =
23346 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023347 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23348 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023349 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23350 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023351 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023352 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023353 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23354 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023355 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23356 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023357 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23358 WMI_UNAVAILABLE_PARAM;
23359 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
23360 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023361 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23362 pdev_param[wmi_pdev_param_block_interbss] =
23363 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023364 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023365 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23366 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23367 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023368 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023369 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023370 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23371 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023372 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023373 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23374 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023375 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23376 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23377 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23378 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
23379 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
23380 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23381 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23382 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23383 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23384 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23385 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23386 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23387 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23388 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23389 pdev_param[wmi_pdev_param_fast_channel_reset] =
23390 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23391 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023392 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023393 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023394}
23395
23396/**
23397 * populate_vdev_param_tlv() - populates vdev params
23398 *
23399 * @param vdev_param: Pointer to hold vdev params
23400 * Return: None
23401 */
23402static void populate_vdev_param_tlv(uint32_t *vdev_param)
23403{
23404 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23405 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23406 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23407 vdev_param[wmi_vdev_param_beacon_interval] =
23408 WMI_VDEV_PARAM_BEACON_INTERVAL;
23409 vdev_param[wmi_vdev_param_listen_interval] =
23410 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23411 vdev_param[wmi_vdev_param_multicast_rate] =
23412 WMI_VDEV_PARAM_MULTICAST_RATE;
23413 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23414 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23415 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23416 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23417 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23418 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23419 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23420 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23421 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23422 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23423 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23424 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23425 vdev_param[wmi_vdev_param_bmiss_count_max] =
23426 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23427 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23428 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23429 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23430 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23431 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23432 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23433 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23434 vdev_param[wmi_vdev_param_disable_htprotection] =
23435 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23436 vdev_param[wmi_vdev_param_sta_quickkickout] =
23437 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23438 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23439 vdev_param[wmi_vdev_param_protection_mode] =
23440 WMI_VDEV_PARAM_PROTECTION_MODE;
23441 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23442 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23443 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23444 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23445 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23446 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23447 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23448 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23449 vdev_param[wmi_vdev_param_bcast_data_rate] =
23450 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23451 vdev_param[wmi_vdev_param_mcast_data_rate] =
23452 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23453 vdev_param[wmi_vdev_param_mcast_indicate] =
23454 WMI_VDEV_PARAM_MCAST_INDICATE;
23455 vdev_param[wmi_vdev_param_dhcp_indicate] =
23456 WMI_VDEV_PARAM_DHCP_INDICATE;
23457 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23458 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23459 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23460 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23461 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23462 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23463 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23464 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23465 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23466 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23467 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23468 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23469 vdev_param[wmi_vdev_param_packet_powersave] =
23470 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23471 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23472 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23473 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23474 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23475 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23476 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23477 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23478 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23479 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23480 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23481 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23482 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23483 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23484 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23485 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23486 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23487 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23488 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23489 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23490 vdev_param[wmi_vdev_param_roam_fw_offload] =
23491 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23492 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23493 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23494 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23495 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23496 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23497 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23498 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23499 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23500 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23501 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23502 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23503 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23504 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23505 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23506 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23507 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23508 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23509 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23510 vdev_param[wmi_vdev_param_inactivity_cnt] =
23511 WMI_VDEV_PARAM_INACTIVITY_CNT;
23512 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23513 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23514 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23515 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23516 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23517 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23518 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23519 vdev_param[wmi_vdev_param_rx_leak_window] =
23520 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23521 vdev_param[wmi_vdev_param_stats_avg_factor] =
23522 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23523 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23524 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23525 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23526 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23527 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23528 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023529 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23530 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023531 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023532 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23533 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23534 WMI_VDEV_PARAM_HE_RANGE_EXT;
23535 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23536 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023537 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023538 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23539 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23540 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23541 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23542 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23543 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23544 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023545 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23546 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23547 vdev_param[wmi_vdev_param_rc_num_retries] =
23548 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23549 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23550 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23551 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23552 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23553 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23554 vdev_param[wmi_vdev_param_vht80_ratemask] =
23555 WMI_VDEV_PARAM_VHT80_RATEMASK;
23556 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23557 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23558 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika88e11832017-09-18 15:59:34 -070023559 vdev_param[wmi_vdev_param_set_he_ltf] = WMI_VDEV_PARAM_HE_LTF;
Sathish Kumar6011c742017-11-08 14:49:58 +053023560 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23561 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023562 vdev_param[wmi_vdev_param_set_ba_mode] =
23563 WMI_VDEV_PARAM_BA_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023564}
23565#endif
23566
Govind Singh5eb51532016-03-09 11:34:12 +053023567/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023568 * populate_target_defines_tlv() - Populate target defines and params
23569 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023570 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023571 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023572 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023573#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023574static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023575{
Govind Singhe7f2f342016-05-23 12:12:52 +053023576 populate_pdev_param_tlv(wmi_handle->pdev_param);
23577 populate_vdev_param_tlv(wmi_handle->vdev_param);
23578}
23579#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023580static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23581{ }
23582#endif
23583
23584/**
Zhang Qian537fca62018-01-03 16:33:24 +080023585 * wmi_ocb_ut_attach() - Attach OCB test framework
23586 * @wmi_handle: wmi handle
23587 *
23588 * Return: None
23589 */
23590#ifdef WLAN_OCB_UT
23591void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23592#else
23593static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23594{
23595 return;
23596}
23597#endif
23598
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023599/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023600 * wmi_tlv_attach() - Attach TLV APIs
23601 *
23602 * Return: None
23603 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023604void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023605{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023606 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023607 wmi_ocb_ut_attach(wmi_handle);
Govind Singhecf03cd2016-05-12 12:45:51 +053023608#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023609 /* Skip saving WMI_CMD_HDR and TLV HDR */
23610 wmi_handle->log_info.buf_offset_command = 8;
23611 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023612 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023613#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023614 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023615 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023616 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023617}
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023618EXPORT_SYMBOL(wmi_tlv_attach);
23619
23620/**
23621 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23622 *
23623 * Return: None
23624 */
23625void wmi_tlv_init(void)
23626{
23627 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23628}