blob: 902e93cc2505678cc270a831d11f5eb3b3bf5f6b [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 *
Govind Singh5eb51532016-03-09 11:34:12 +05304 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Govind Singh5eb51532016-03-09 11:34:12 +053019#include "wmi_unified_api.h"
20#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053021#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053022#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053023#include "wmi_version_whitelist.h"
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080024#include <qdf_module.h>
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053025#include <wlan_defs.h>
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053026#include <htc_services.h>
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053027
Wu Gaocd3a8512017-03-13 20:17:34 +080028#ifdef CONVERGED_P2P_ENABLE
29#include "wlan_p2p_public_struct.h"
30#endif
Dustin Brownf31f88b2017-05-12 14:01:44 -070031#ifdef WLAN_PMO_ENABLE
32#include "wlan_pmo_hw_filter_public_struct.h"
33#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053034#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053035#ifdef WLAN_SUPPORT_GREEN_AP
36#include "wlan_green_ap_api.h"
37#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053038
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080039#ifdef WLAN_FEATURE_NAN_CONVERGENCE
40#include "nan_public_structs.h"
41#endif
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070042#include "wmi_unified_twt_api.h"
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080043
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080044#ifdef WLAN_POLICY_MGR_ENABLE
45#include "wlan_policy_mgr_public_struct.h"
46#endif
47
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053048/* HTC service ids for WMI for multi-radio */
49static const uint32_t multi_svc_ids[] = {WMI_CONTROL_SVC,
50 WMI_CONTROL_SVC_WMAC1,
51 WMI_CONTROL_SVC_WMAC2};
52
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053053/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
54 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053055 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053056 * @cmd: pointer target vdev create command buffer
57 * @param: pointer host params for vdev create
58 *
59 * Return: None
60 */
61#ifdef CONFIG_MCL
62static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053063 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053064 wmi_vdev_create_cmd_fixed_param * cmd,
65 struct vdev_create_params *param)
66{
67 cmd->pdev_id = WMI_PDEV_ID_SOC;
68}
69#else
70static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053071 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053072 wmi_vdev_create_cmd_fixed_param * cmd,
73 struct vdev_create_params *param)
74{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053075 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
76 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053077}
78#endif
79
Govind Singh5eb51532016-03-09 11:34:12 +053080/**
81 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
82 * @wmi_handle: wmi handle
83 * @param: pointer to hold vdev create parameter
84 * @macaddr: vdev mac address
85 *
Govind Singhe7f2f342016-05-23 12:12:52 +053086 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053087 */
Sathish Kumarfd347372017-02-13 12:29:09 +053088static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053089 uint8_t macaddr[IEEE80211_ADDR_LEN],
90 struct vdev_create_params *param)
91{
92 wmi_vdev_create_cmd_fixed_param *cmd;
93 wmi_buf_t buf;
94 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053095 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070096 int num_bands = 2;
97 uint8_t *buf_ptr;
98 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053099
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700100 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530101 buf = wmi_buf_alloc(wmi_handle, len);
102 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530103 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530104 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530105 }
106 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
107 WMITLV_SET_HDR(&cmd->tlv_header,
108 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
109 WMITLV_GET_STRUCT_TLVLEN
110 (wmi_vdev_create_cmd_fixed_param));
111 cmd->vdev_id = param->if_id;
112 cmd->vdev_type = param->type;
113 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700114 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530115 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530116 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700117 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
118 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530119 macaddr[0], macaddr[1], macaddr[2],
120 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700121 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
122 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
123 (num_bands * sizeof(wmi_vdev_txrx_streams)));
124 buf_ptr += WMI_TLV_HDR_SIZE;
125
Govind Singh224a7312016-06-21 14:33:26 +0530126 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700127 param->type, param->subtype,
128 param->nss_2g, param->nss_5g);
129 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
130 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
131 txrx_streams->supported_tx_streams = param->nss_2g;
132 txrx_streams->supported_rx_streams = param->nss_2g;
133 WMITLV_SET_HDR(&txrx_streams->tlv_header,
134 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
135 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
136
137 txrx_streams++;
138 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
139 txrx_streams->supported_tx_streams = param->nss_5g;
140 txrx_streams->supported_rx_streams = param->nss_5g;
141 WMITLV_SET_HDR(&txrx_streams->tlv_header,
142 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
143 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530144 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530145 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530146 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530147 wmi_buf_free(buf);
148 }
149
150 return ret;
151}
152
153/**
154 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
155 * @wmi_handle: wmi handle
156 * @if_id: vdev id
157 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530158 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530159 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530160static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530161 uint8_t if_id)
162{
163 wmi_vdev_delete_cmd_fixed_param *cmd;
164 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530165 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530166
167 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
168 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530169 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530170 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530171 }
172
173 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
174 WMITLV_SET_HDR(&cmd->tlv_header,
175 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
176 WMITLV_GET_STRUCT_TLVLEN
177 (wmi_vdev_delete_cmd_fixed_param));
178 cmd->vdev_id = if_id;
179 ret = wmi_unified_cmd_send(wmi_handle, buf,
180 sizeof(wmi_vdev_delete_cmd_fixed_param),
181 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530182 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530183 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530184 wmi_buf_free(buf);
185 }
Govind Singhb53420c2016-03-09 14:32:57 +0530186 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530187
188 return ret;
189}
190
191/**
192 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
193 * @wmi: wmi handle
194 * @vdev_id: vdev id
195 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530196 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530197 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530198static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530199 uint8_t vdev_id)
200{
201 wmi_vdev_stop_cmd_fixed_param *cmd;
202 wmi_buf_t buf;
203 int32_t len = sizeof(*cmd);
204
205 buf = wmi_buf_alloc(wmi, len);
206 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530207 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530208 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530209 }
210 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
211 WMITLV_SET_HDR(&cmd->tlv_header,
212 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
213 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
214 cmd->vdev_id = vdev_id;
215 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530216 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530217 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530218 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530219 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530220 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530221
222 return 0;
223}
224
225/**
226 * send_vdev_down_cmd_tlv() - send vdev down command to fw
227 * @wmi: wmi handle
228 * @vdev_id: vdev id
229 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530230 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530231 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530232static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530233{
234 wmi_vdev_down_cmd_fixed_param *cmd;
235 wmi_buf_t buf;
236 int32_t len = sizeof(*cmd);
237
238 buf = wmi_buf_alloc(wmi, len);
239 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530240 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530241 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530242 }
243 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
244 WMITLV_SET_HDR(&cmd->tlv_header,
245 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
246 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
247 cmd->vdev_id = vdev_id;
248 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530249 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530250 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530251 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530252 }
Govind Singhb53420c2016-03-09 14:32:57 +0530253 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530254
255 return 0;
256}
257
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530258#ifdef CONFIG_MCL
259static inline void copy_channel_info(
260 wmi_vdev_start_request_cmd_fixed_param * cmd,
261 wmi_channel *chan,
262 struct vdev_start_params *req)
263{
264 chan->mhz = req->chan_freq;
265
266 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
267
268 chan->band_center_freq1 = req->band_center_freq1;
269 chan->band_center_freq2 = req->band_center_freq2;
270
271 if (req->is_half_rate)
272 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
273 else if (req->is_quarter_rate)
274 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
275
Naveen Rawat44f2f432016-12-01 12:58:57 -0800276 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530277 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
278 cmd->disable_hw_ack = req->dis_hw_ack;
279 }
280
281 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
282 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
283
284}
285#else
286static inline void copy_channel_info(
287 wmi_vdev_start_request_cmd_fixed_param * cmd,
288 wmi_channel *chan,
289 struct vdev_start_params *req)
290{
291 chan->mhz = req->channel.mhz;
292
293 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
294
295 chan->band_center_freq1 = req->channel.cfreq1;
296 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800297 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530298
299 if (req->channel.half_rate)
300 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
301 else if (req->channel.quarter_rate)
302 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
303
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800304 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
305
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530306 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530307 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530308 cmd->disable_hw_ack = req->disable_hw_ack;
309 }
310
Krishna Rao0b952ea2017-03-20 13:30:10 +0530311 if (req->channel.dfs_set_cfreq2)
312 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
313
Kai Chen4710d462017-12-15 14:06:06 -0800314 /* According to firmware both reg power and max tx power
315 * on set channel power is used and set it to max reg
316 * power from regulatory.
317 */
318 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
319 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530320 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800321 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
322 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
323 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530324
325}
326#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530327/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530328 * send_vdev_start_cmd_tlv() - send vdev start request to fw
329 * @wmi_handle: wmi handle
330 * @req: vdev start params
331 *
332 * Return: QDF status
333 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530334static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530335 struct vdev_start_params *req)
336{
337 wmi_vdev_start_request_cmd_fixed_param *cmd;
338 wmi_buf_t buf;
339 wmi_channel *chan;
340 int32_t len, ret;
341 uint8_t *buf_ptr;
342
343 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
344 buf = wmi_buf_alloc(wmi_handle, len);
345 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530346 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530347 return QDF_STATUS_E_NOMEM;
348 }
349 buf_ptr = (uint8_t *) wmi_buf_data(buf);
350 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
351 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
352 WMITLV_SET_HDR(&cmd->tlv_header,
353 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
354 WMITLV_GET_STRUCT_TLVLEN
355 (wmi_vdev_start_request_cmd_fixed_param));
356 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
357 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
358 cmd->vdev_id = req->vdev_id;
359
360 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530361 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530362
363 cmd->beacon_interval = req->beacon_intval;
364 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530365
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800366 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
367 if (req->bcn_tx_rate_code)
368 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
369
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530370 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530371 cmd->beacon_interval = req->beacon_intval;
372 cmd->dtim_period = req->dtim_period;
373
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530374 /* Copy the SSID */
375 if (req->ssid.length) {
376 if (req->ssid.length < sizeof(cmd->ssid.ssid))
377 cmd->ssid.ssid_len = req->ssid.length;
378 else
379 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
380 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
381 cmd->ssid.ssid_len);
382 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530383
384 if (req->hidden_ssid)
385 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
386
387 if (req->pmf_enabled)
388 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530389 }
390
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700391 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530392 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530393 cmd->preferred_rx_streams = req->preferred_rx_streams;
394 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700395 cmd->cac_duration_ms = req->cac_duration_ms;
396 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700397 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530398
399 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
400 sizeof(wmi_channel));
401 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
402 cmd->num_noa_descriptors *
403 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800404 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530405 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
406 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800407 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
408 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
409 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530410 req->is_dfs, req->beacon_intval, cmd->dtim_period,
411 chan->band_center_freq1, chan->band_center_freq2,
412 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700413 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700414 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800415 req->regdomain, req->he_ops,
416 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530417
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530418 if (req->is_restart)
419 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
420 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530421 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530422 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
423 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530424 if (ret) {
425 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530426 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530427 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530428 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530429
430 return QDF_STATUS_SUCCESS;
431}
432
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530433/**
434 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
435 * @wmi_handle: wmi handle
436 * @restart_params: vdev restart params
437 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530438 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530439 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530440static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530441 struct hidden_ssid_vdev_restart_params *restart_params)
442{
443 wmi_vdev_start_request_cmd_fixed_param *cmd;
444 wmi_buf_t buf;
445 wmi_channel *chan;
446 int32_t len;
447 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530448 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530449
450 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
451 buf = wmi_buf_alloc(wmi_handle, len);
452 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530453 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530454 return QDF_STATUS_E_NOMEM;
455 }
456 buf_ptr = (uint8_t *) wmi_buf_data(buf);
457 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
458 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
459
460 WMITLV_SET_HDR(&cmd->tlv_header,
461 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
462 WMITLV_GET_STRUCT_TLVLEN
463 (wmi_vdev_start_request_cmd_fixed_param));
464
465 WMITLV_SET_HDR(&chan->tlv_header,
466 WMITLV_TAG_STRUC_wmi_channel,
467 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
468
469 cmd->vdev_id = restart_params->session_id;
470 cmd->ssid.ssid_len = restart_params->ssid_len;
471 qdf_mem_copy(cmd->ssid.ssid,
472 restart_params->ssid,
473 cmd->ssid.ssid_len);
474 cmd->flags = restart_params->flags;
475 cmd->requestor_id = restart_params->requestor_id;
476 cmd->disable_hw_ack = restart_params->disable_hw_ack;
477
478 chan->mhz = restart_params->mhz;
479 chan->band_center_freq1 =
480 restart_params->band_center_freq1;
481 chan->band_center_freq2 =
482 restart_params->band_center_freq2;
483 chan->info = restart_params->info;
484 chan->reg_info_1 = restart_params->reg_info_1;
485 chan->reg_info_2 = restart_params->reg_info_2;
486
487 cmd->num_noa_descriptors = 0;
488 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
489 sizeof(wmi_channel));
490 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
491 cmd->num_noa_descriptors *
492 sizeof(wmi_p2p_noa_descriptor));
493
494 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
495 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530496 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530497 wmi_buf_free(buf);
498 return QDF_STATUS_E_FAILURE;
499 }
500 return QDF_STATUS_SUCCESS;
501}
502
503
504/**
Govind Singh5eb51532016-03-09 11:34:12 +0530505 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
506 * @wmi: wmi handle
507 * @peer_addr: peer mac address
508 * @param: pointer to hold peer flush tid parameter
509 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -0700510 * Return: 0 for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530511 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530512static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530513 uint8_t peer_addr[IEEE80211_ADDR_LEN],
514 struct peer_flush_params *param)
515{
516 wmi_peer_flush_tids_cmd_fixed_param *cmd;
517 wmi_buf_t buf;
518 int32_t len = sizeof(*cmd);
519
520 buf = wmi_buf_alloc(wmi, len);
521 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530522 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530523 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530524 }
525 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
526 WMITLV_SET_HDR(&cmd->tlv_header,
527 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
528 WMITLV_GET_STRUCT_TLVLEN
529 (wmi_peer_flush_tids_cmd_fixed_param));
530 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
531 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
532 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530533 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530534 peer_addr, param->vdev_id,
535 param->peer_tid_bitmap);
536 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530537 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530538 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530539 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530540 }
541
542 return 0;
543}
544
545/**
546 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
547 * @wmi: wmi handle
548 * @peer_addr: peer mac addr
549 * @vdev_id: vdev id
550 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530551 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530552 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530553static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530554 uint8_t peer_addr[IEEE80211_ADDR_LEN],
555 uint8_t vdev_id)
556{
557 wmi_peer_delete_cmd_fixed_param *cmd;
558 wmi_buf_t buf;
559 int32_t len = sizeof(*cmd);
560 buf = wmi_buf_alloc(wmi, len);
561 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530562 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530563 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530564 }
565 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
566 WMITLV_SET_HDR(&cmd->tlv_header,
567 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
568 WMITLV_GET_STRUCT_TLVLEN
569 (wmi_peer_delete_cmd_fixed_param));
570 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
571 cmd->vdev_id = vdev_id;
572
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800573 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530574 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530575 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530576 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530577 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530578 }
Govind Singh5eb51532016-03-09 11:34:12 +0530579
580 return 0;
581}
582
583/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530584 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
585 * to target id.
586 * @targ_paramid: Target parameter id to hold the result.
587 * @peer_param_id: host param id.
588 *
589 * Return: QDF_STATUS_SUCCESS for success
590 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
591 */
592#ifdef CONFIG_MCL
593static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
594 uint32_t *targ_paramid,
595 uint32_t peer_param_id)
596{
597 *targ_paramid = peer_param_id;
598 return QDF_STATUS_SUCCESS;
599}
600#else
601static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
602 uint32_t *targ_paramid,
603 uint32_t peer_param_id)
604{
605 switch (peer_param_id) {
606 case WMI_HOST_PEER_MIMO_PS_STATE:
607 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
608 break;
609 case WMI_HOST_PEER_AMPDU:
610 *targ_paramid = WMI_PEER_AMPDU;
611 break;
612 case WMI_HOST_PEER_AUTHORIZE:
613 *targ_paramid = WMI_PEER_AUTHORIZE;
614 break;
615 case WMI_HOST_PEER_CHWIDTH:
616 *targ_paramid = WMI_PEER_CHWIDTH;
617 break;
618 case WMI_HOST_PEER_NSS:
619 *targ_paramid = WMI_PEER_NSS;
620 break;
621 case WMI_HOST_PEER_USE_4ADDR:
622 *targ_paramid = WMI_PEER_USE_4ADDR;
623 break;
624 case WMI_HOST_PEER_MEMBERSHIP:
625 *targ_paramid = WMI_PEER_MEMBERSHIP;
626 break;
627 case WMI_HOST_PEER_USERPOS:
628 *targ_paramid = WMI_PEER_USERPOS;
629 break;
630 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
631 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
632 break;
633 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
634 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
635 break;
636 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
637 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
638 break;
639 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
640 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
641 break;
642 case WMI_HOST_PEER_PHYMODE:
643 *targ_paramid = WMI_PEER_PHYMODE;
644 break;
645 case WMI_HOST_PEER_USE_FIXED_PWR:
646 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
647 break;
648 case WMI_HOST_PEER_PARAM_FIXED_RATE:
649 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
650 break;
651 case WMI_HOST_PEER_SET_MU_WHITELIST:
652 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
653 break;
654 case WMI_HOST_PEER_SET_MAC_TX_RATE:
655 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
656 break;
657 case WMI_HOST_PEER_SET_MIN_TX_RATE:
658 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
659 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530660 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
661 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
662 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530663 case WMI_HOST_PEER_NSS_VHT160:
664 *targ_paramid = WMI_PEER_NSS_VHT160;
665 break;
666 case WMI_HOST_PEER_NSS_VHT80_80:
667 *targ_paramid = WMI_PEER_NSS_VHT80_80;
668 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530669 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
670 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
671 break;
672 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
673 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
674 break;
675 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
676 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
677 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530678 case WMI_HOST_PEER_PARAM_MU_ENABLE:
679 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
680 break;
681 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
682 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
683 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530684 default:
685 return QDF_STATUS_E_NOSUPPORT;
686 }
687
688 return QDF_STATUS_SUCCESS;
689}
690#endif
691/**
Govind Singh5eb51532016-03-09 11:34:12 +0530692 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530693 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530694 * @peer_addr: peer mac address
695 * @param : pointer to hold peer set parameter
696 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530697 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530698 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530699static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530700 uint8_t peer_addr[IEEE80211_ADDR_LEN],
701 struct peer_set_params *param)
702{
703 wmi_peer_set_param_cmd_fixed_param *cmd;
704 wmi_buf_t buf;
705 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530706 uint32_t param_id;
707
708 if (convert_host_peer_id_to_target_id_tlv(&param_id,
709 param->param_id) != QDF_STATUS_SUCCESS)
710 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530711
712 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
713 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530714 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530715 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530716 }
717 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
718 WMITLV_SET_HDR(&cmd->tlv_header,
719 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
720 WMITLV_GET_STRUCT_TLVLEN
721 (wmi_peer_set_param_cmd_fixed_param));
722 cmd->vdev_id = param->vdev_id;
723 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530724 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530725 cmd->param_value = param->param_value;
726 err = wmi_unified_cmd_send(wmi, buf,
727 sizeof(wmi_peer_set_param_cmd_fixed_param),
728 WMI_PEER_SET_PARAM_CMDID);
729 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530730 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530731 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530732 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530733 }
734
735 return 0;
736}
737
738/**
739 * send_vdev_up_cmd_tlv() - send vdev up command in fw
740 * @wmi: wmi handle
741 * @bssid: bssid
742 * @vdev_up_params: pointer to hold vdev up parameter
743 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530744 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530745 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530746static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530747 uint8_t bssid[IEEE80211_ADDR_LEN],
748 struct vdev_up_params *params)
749{
750 wmi_vdev_up_cmd_fixed_param *cmd;
751 wmi_buf_t buf;
752 int32_t len = sizeof(*cmd);
753
Govind Singhb53420c2016-03-09 14:32:57 +0530754 WMI_LOGD("%s: VDEV_UP", __func__);
755 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530756 params->vdev_id, params->assoc_id, bssid);
757 buf = wmi_buf_alloc(wmi, len);
758 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530759 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530760 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530761 }
762 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
763 WMITLV_SET_HDR(&cmd->tlv_header,
764 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
765 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
766 cmd->vdev_id = params->vdev_id;
767 cmd->vdev_assoc_id = params->assoc_id;
768 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
769 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530770 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530771 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530772 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530773 }
774
775 return 0;
776}
777
778/**
779 * send_peer_create_cmd_tlv() - send peer create command to fw
780 * @wmi: wmi handle
781 * @peer_addr: peer mac address
782 * @peer_type: peer type
783 * @vdev_id: vdev id
784 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530785 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530786 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530787static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530788 struct peer_create_params *param)
789{
790 wmi_peer_create_cmd_fixed_param *cmd;
791 wmi_buf_t buf;
792 int32_t len = sizeof(*cmd);
793
794 buf = wmi_buf_alloc(wmi, len);
795 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530796 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530797 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530798 }
799 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
800 WMITLV_SET_HDR(&cmd->tlv_header,
801 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
802 WMITLV_GET_STRUCT_TLVLEN
803 (wmi_peer_create_cmd_fixed_param));
804 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
805 cmd->peer_type = param->peer_type;
806 cmd->vdev_id = param->vdev_id;
807
808 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530809 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530810 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530811 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530812 }
Govind Singhb53420c2016-03-09 14:32:57 +0530813 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530814 param->vdev_id);
815
816 return 0;
817}
818
819/**
Leo Changeee40872016-09-28 13:43:36 -0700820 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
821 * command to fw
822 * @wmi: wmi handle
823 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
824 *
825 * Return: 0 for success or error code
826 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700827static
Leo Changeee40872016-09-28 13:43:36 -0700828QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
829 struct rx_reorder_queue_setup_params *param)
830{
831 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
832 wmi_buf_t buf;
833 int32_t len = sizeof(*cmd);
834
835 buf = wmi_buf_alloc(wmi, len);
836 if (!buf) {
837 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
838 return QDF_STATUS_E_NOMEM;
839 }
840 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
841 WMITLV_SET_HDR(&cmd->tlv_header,
842 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
843 WMITLV_GET_STRUCT_TLVLEN
844 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
845 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
846 cmd->vdev_id = param->vdev_id;
847 cmd->tid = param->tid;
848 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
849 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
850 cmd->queue_no = param->queue_no;
851
852 if (wmi_unified_cmd_send(wmi, buf, len,
853 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
854 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
855 __func__);
856 qdf_nbuf_free(buf);
857 return QDF_STATUS_E_FAILURE;
858 }
859 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
860 param->peer_macaddr, param->vdev_id, param->tid);
861
862 return QDF_STATUS_SUCCESS;
863}
864
865/**
866 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
867 * command to fw
868 * @wmi: wmi handle
869 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
870 *
871 * Return: 0 for success or error code
872 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700873static
Leo Changeee40872016-09-28 13:43:36 -0700874QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
875 struct rx_reorder_queue_remove_params *param)
876{
877 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
878 wmi_buf_t buf;
879 int32_t len = sizeof(*cmd);
880
881 buf = wmi_buf_alloc(wmi, len);
882 if (!buf) {
883 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
884 return QDF_STATUS_E_NOMEM;
885 }
886 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
887 wmi_buf_data(buf);
888 WMITLV_SET_HDR(&cmd->tlv_header,
889 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
890 WMITLV_GET_STRUCT_TLVLEN
891 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
892 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
893 cmd->vdev_id = param->vdev_id;
894 cmd->tid_mask = param->peer_tid_bitmap;
895
896 if (wmi_unified_cmd_send(wmi, buf, len,
897 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
898 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
899 __func__);
900 qdf_nbuf_free(buf);
901 return QDF_STATUS_E_FAILURE;
902 }
903 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
904 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
905
906 return QDF_STATUS_SUCCESS;
907}
908
909/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530910 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
911 * @wmi_handle: wmi handle
912 * @param: pointer holding peer details
913 *
914 * Return: 0 for success or error code
915 */
916static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
917 struct peer_add_wds_entry_params *param)
918{
919 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
920 wmi_buf_t buf;
921 int len = sizeof(*cmd);
922
923 buf = wmi_buf_alloc(wmi_handle, len);
924 if (!buf) {
925 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
926 return QDF_STATUS_E_FAILURE;
927 }
928 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
929 WMITLV_SET_HDR(&cmd->tlv_header,
930 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
931 WMITLV_GET_STRUCT_TLVLEN
932 (wmi_peer_add_wds_entry_cmd_fixed_param));
933 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
934 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800935 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
936 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530937
938 return wmi_unified_cmd_send(wmi_handle, buf, len,
939 WMI_PEER_ADD_WDS_ENTRY_CMDID);
940}
941
942/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530943 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530944 * @wmi_handle: wmi handle
945 * @param: pointer holding peer details
946 *
947 * Return: 0 for success or error code
948 */
949static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
950 struct peer_del_wds_entry_params *param)
951{
952 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
953 wmi_buf_t buf;
954 int len = sizeof(*cmd);
955
956 buf = wmi_buf_alloc(wmi_handle, len);
957 if (!buf) {
958 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
959 return QDF_STATUS_E_NOMEM;
960 }
961 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
962 WMITLV_SET_HDR(&cmd->tlv_header,
963 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
964 WMITLV_GET_STRUCT_TLVLEN
965 (wmi_peer_remove_wds_entry_cmd_fixed_param));
966 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800967 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530968 return wmi_unified_cmd_send(wmi_handle, buf, len,
969 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
970}
971
972/**
973 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
974 * @wmi_handle: wmi handle
975 * @param: pointer holding peer details
976 *
977 * Return: 0 for success or error code
978 */
979static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
980 struct peer_update_wds_entry_params *param)
981{
982 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
983 wmi_buf_t buf;
984 int len = sizeof(*cmd);
985
986 buf = wmi_buf_alloc(wmi_handle, len);
987 if (!buf) {
988 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
989 return QDF_STATUS_E_NOMEM;
990 }
991
992 /* wmi_buf_alloc returns zeroed command buffer */
993 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
994 WMITLV_SET_HDR(&cmd->tlv_header,
995 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
996 WMITLV_GET_STRUCT_TLVLEN
997 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800998 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
999 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301000 if (param->wds_macaddr)
1001 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
1002 &cmd->wds_macaddr);
1003 if (param->peer_macaddr)
1004 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1005 &cmd->peer_macaddr);
1006 return wmi_unified_cmd_send(wmi_handle, buf, len,
1007 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1008}
1009
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001010/**
1011 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1012 * @wmi_handle: wmi handle
1013 * @param: pointer to get tpc config params
1014 *
1015 * Return: 0 for success or error code
1016 */
1017static QDF_STATUS
1018send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1019 uint32_t param)
1020{
1021 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1022 wmi_buf_t buf;
1023 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1024
1025 buf = wmi_buf_alloc(wmi_handle, len);
1026 if (!buf) {
1027 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1028 return QDF_STATUS_E_NOMEM;
1029 }
1030 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1031 WMITLV_SET_HDR(&cmd->tlv_header,
1032 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1033 WMITLV_GET_STRUCT_TLVLEN
1034 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1035
1036 cmd->param = param;
1037 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1038 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1039 WMI_LOGE("Send pdev get tpc config cmd failed");
1040 wmi_buf_free(buf);
1041 return QDF_STATUS_E_FAILURE;
1042
1043 }
1044 WMI_LOGD("%s:send success", __func__);
1045
1046 return QDF_STATUS_SUCCESS;
1047}
1048
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301049#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301050/**
Govind Singh5eb51532016-03-09 11:34:12 +05301051 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1052 * @wmi_handle: wmi handle
1053 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301054 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301055 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301056 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301057 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301058static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301059 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301060{
1061 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1062 wmi_buf_t buf;
1063 int32_t len = sizeof(*cmd);
1064
Govind Singhb53420c2016-03-09 14:32:57 +05301065 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301066
1067 buf = wmi_buf_alloc(wmi_handle, len);
1068 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301069 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301070 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301071 }
1072
1073 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1074 WMITLV_SET_HDR(&cmd->tlv_header,
1075 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1076 WMITLV_GET_STRUCT_TLVLEN
1077 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301078 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301079 cmd->enable = value;
1080
1081 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1082 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301083 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301084 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301085 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301086 }
1087
1088 return 0;
1089}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301090#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301091
1092/**
1093 * send_pdev_utf_cmd_tlv() - send utf command to fw
1094 * @wmi_handle: wmi handle
1095 * @param: pointer to pdev_utf_params
1096 * @mac_id: mac id to have radio context
1097 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301098 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301099 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301100static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301101send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1102 struct pdev_utf_params *param,
1103 uint8_t mac_id)
1104{
1105 wmi_buf_t buf;
1106 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001107 /* if param->len is 0 no data is sent, return error */
1108 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301109 static uint8_t msgref = 1;
1110 uint8_t segNumber = 0, segInfo, numSegments;
1111 uint16_t chunk_len, total_bytes;
1112 uint8_t *bufpos;
1113 struct seg_hdr_info segHdrInfo;
1114
1115 bufpos = param->utf_payload;
1116 total_bytes = param->len;
1117 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1118 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1119 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1120
1121 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1122 numSegments++;
1123
1124 while (param->len) {
1125 if (param->len > MAX_WMI_UTF_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -07001126 chunk_len = MAX_WMI_UTF_LEN; /* MAX message */
Govind Singh5eb51532016-03-09 11:34:12 +05301127 else
1128 chunk_len = param->len;
1129
1130 buf = wmi_buf_alloc(wmi_handle,
1131 (chunk_len + sizeof(segHdrInfo) +
1132 WMI_TLV_HDR_SIZE));
1133 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301134 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301135 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301136 }
1137
1138 cmd = (uint8_t *) wmi_buf_data(buf);
1139
1140 segHdrInfo.len = total_bytes;
1141 segHdrInfo.msgref = msgref;
1142 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1143 segHdrInfo.segmentInfo = segInfo;
1144 segHdrInfo.pad = 0;
1145
Govind Singhb53420c2016-03-09 14:32:57 +05301146 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301147 " segHdrInfo.segmentInfo = %d",
1148 __func__, segHdrInfo.len, segHdrInfo.msgref,
1149 segHdrInfo.segmentInfo);
1150
Govind Singhb53420c2016-03-09 14:32:57 +05301151 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301152 "chunk len %d", __func__, total_bytes, segNumber,
1153 numSegments, chunk_len);
1154
1155 segNumber++;
1156
1157 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1158 (chunk_len + sizeof(segHdrInfo)));
1159 cmd += WMI_TLV_HDR_SIZE;
1160 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1161 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1162
1163 ret = wmi_unified_cmd_send(wmi_handle, buf,
1164 (chunk_len + sizeof(segHdrInfo) +
1165 WMI_TLV_HDR_SIZE),
1166 WMI_PDEV_UTF_CMDID);
1167
Govind Singh67922e82016-04-01 16:48:57 +05301168 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301169 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301170 wmi_buf_free(buf);
1171 break;
1172 }
1173
1174 param->len -= chunk_len;
1175 bufpos += chunk_len;
1176 }
1177
1178 msgref++;
1179
1180 return ret;
1181}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301182#ifdef CONFIG_MCL
1183static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1184 uint32_t host_param)
1185{
1186 return host_param;
1187}
1188#else
1189static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1190 uint32_t host_param)
1191{
1192 if (host_param < wmi_pdev_param_max)
1193 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301194
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301195 return WMI_UNAVAILABLE_PARAM;
1196}
1197#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301198/**
1199 * send_pdev_param_cmd_tlv() - set pdev parameters
1200 * @wmi_handle: wmi handle
1201 * @param: pointer to pdev parameter
1202 * @mac_id: radio context
1203 *
1204 * Return: 0 on success, errno on failure
1205 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301206static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301207send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1208 struct pdev_params *param,
1209 uint8_t mac_id)
1210{
Govind Singh67922e82016-04-01 16:48:57 +05301211 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301212 wmi_pdev_set_param_cmd_fixed_param *cmd;
1213 wmi_buf_t buf;
1214 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301215 uint32_t pdev_param;
1216
1217 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1218 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1219 WMI_LOGW("%s: Unavailable param %d\n",
1220 __func__, param->param_id);
1221 return QDF_STATUS_E_INVAL;
1222 }
Govind Singh5eb51532016-03-09 11:34:12 +05301223
1224 buf = wmi_buf_alloc(wmi_handle, len);
1225 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301226 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301227 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301228 }
1229 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1230 WMITLV_SET_HDR(&cmd->tlv_header,
1231 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1232 WMITLV_GET_STRUCT_TLVLEN
1233 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301234 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301235 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301236 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301237 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301238 param->param_value);
1239 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1240 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301241 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301242 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301243 wmi_buf_free(buf);
1244 }
1245 return ret;
1246}
1247
1248/**
1249 * send_suspend_cmd_tlv() - WMI suspend function
1250 * @param wmi_handle : handle to WMI.
1251 * @param param : pointer to hold suspend parameter
1252 * @mac_id: radio context
1253 *
1254 * Return 0 on success and -ve on failure.
1255 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301256static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301257 struct suspend_params *param,
1258 uint8_t mac_id)
1259{
1260 wmi_pdev_suspend_cmd_fixed_param *cmd;
1261 wmi_buf_t wmibuf;
1262 uint32_t len = sizeof(*cmd);
1263 int32_t ret;
1264
1265 /*
Jeff Johnson19a59fe2018-05-06 16:10:43 -07001266 * send the command to Target to ignore the
Govind Singh5eb51532016-03-09 11:34:12 +05301267 * PCIE reset so as to ensure that Host and target
1268 * states are in sync
1269 */
1270 wmibuf = wmi_buf_alloc(wmi_handle, len);
1271 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301272 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301273
1274 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1275 WMITLV_SET_HDR(&cmd->tlv_header,
1276 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1277 WMITLV_GET_STRUCT_TLVLEN
1278 (wmi_pdev_suspend_cmd_fixed_param));
1279 if (param->disable_target_intr)
1280 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1281 else
1282 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301283
1284 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1285
Govind Singh5eb51532016-03-09 11:34:12 +05301286 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1287 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301288 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301289 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301290 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301291 }
1292
1293 return ret;
1294}
1295
1296/**
1297 * send_resume_cmd_tlv() - WMI resume function
1298 * @param wmi_handle : handle to WMI.
1299 * @mac_id: radio context
1300 *
1301 * Return: 0 on success and -ve on failure.
1302 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301303static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301304 uint8_t mac_id)
1305{
1306 wmi_buf_t wmibuf;
1307 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301308 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301309
1310 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1311 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301312 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301313 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1314 WMITLV_SET_HDR(&cmd->tlv_header,
1315 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1316 WMITLV_GET_STRUCT_TLVLEN
1317 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301318 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301319 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1320 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301321 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301322 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301323 wmi_buf_free(wmibuf);
1324 }
1325
1326 return ret;
1327}
1328
Will Huang422ac9a2017-11-17 13:19:16 +08001329#ifdef FEATURE_WLAN_D0WOW
1330/**
1331 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1332 * @param wmi_handle: handle to WMI.
1333 * @mac_id: radio context
1334 *
1335 * Return: 0 on success and error code on failure.
1336 */
1337static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1338 uint8_t mac_id)
1339{
1340 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1341 wmi_buf_t buf;
1342 int32_t len;
1343 QDF_STATUS status;
1344
1345 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1346
1347 buf = wmi_buf_alloc(wmi_handle, len);
1348 if (!buf) {
1349 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1350 return QDF_STATUS_E_NOMEM;
1351 }
1352 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1353 WMITLV_SET_HDR(&cmd->tlv_header,
1354 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1355 WMITLV_GET_STRUCT_TLVLEN
1356 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1357
1358 cmd->enable = true;
1359
1360 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1361 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1362 if (QDF_IS_STATUS_ERROR(status))
1363 wmi_buf_free(buf);
1364
1365 return status;
1366}
1367
1368/**
1369 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1370 * @param wmi_handle: handle to WMI.
1371 * @mac_id: radio context
1372 *
1373 * Return: 0 on success and error code on failure.
1374 */
1375static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1376 uint8_t mac_id)
1377{
1378 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1379 wmi_buf_t buf;
1380 int32_t len;
1381 QDF_STATUS status;
1382
1383 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1384
1385 buf = wmi_buf_alloc(wmi_handle, len);
1386 if (!buf) {
1387 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1388 return QDF_STATUS_E_NOMEM;
1389 }
1390 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1391 WMITLV_SET_HDR(&cmd->tlv_header,
1392 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1393 WMITLV_GET_STRUCT_TLVLEN
1394 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1395
1396 cmd->enable = false;
1397
1398 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1399 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1400 if (QDF_IS_STATUS_ERROR(status))
1401 wmi_buf_free(buf);
1402
1403 return status;
1404}
1405#endif
1406
Govind Singh5eb51532016-03-09 11:34:12 +05301407/**
1408 * send_wow_enable_cmd_tlv() - WMI wow enable function
1409 * @param wmi_handle : handle to WMI.
1410 * @param param : pointer to hold wow enable parameter
1411 * @mac_id: radio context
1412 *
1413 * Return: 0 on success and -ve on failure.
1414 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301415static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301416 struct wow_cmd_params *param,
1417 uint8_t mac_id)
1418{
1419 wmi_wow_enable_cmd_fixed_param *cmd;
1420 wmi_buf_t buf;
1421 int32_t len;
1422 int32_t ret;
1423
1424 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1425
1426 buf = wmi_buf_alloc(wmi_handle, len);
1427 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301428 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1429 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301430 }
1431 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1432 WMITLV_SET_HDR(&cmd->tlv_header,
1433 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1434 WMITLV_GET_STRUCT_TLVLEN
1435 (wmi_wow_enable_cmd_fixed_param));
1436 cmd->enable = param->enable;
1437 if (param->can_suspend_link)
1438 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1439 else
1440 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001441 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301442
Govind Singhb53420c2016-03-09 14:32:57 +05301443 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301444 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1445 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1446
1447 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1448 WMI_WOW_ENABLE_CMDID);
1449 if (ret)
1450 wmi_buf_free(buf);
1451
1452 return ret;
1453}
1454
1455/**
1456 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301457 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301458 * @peer_addr: peer mac address
1459 * @param: pointer to ap_ps parameter structure
1460 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301461 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301462 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301463static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301464 uint8_t *peer_addr,
1465 struct ap_ps_params *param)
1466{
1467 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1468 wmi_buf_t buf;
1469 int32_t err;
1470
1471 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1472 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301473 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301474 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301475 }
1476 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1477 WMITLV_SET_HDR(&cmd->tlv_header,
1478 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1479 WMITLV_GET_STRUCT_TLVLEN
1480 (wmi_ap_ps_peer_cmd_fixed_param));
1481 cmd->vdev_id = param->vdev_id;
1482 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1483 cmd->param = param->param;
1484 cmd->value = param->value;
1485 err = wmi_unified_cmd_send(wmi_handle, buf,
1486 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1487 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301488 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301489 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301490 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301491 }
1492
1493 return 0;
1494}
1495
1496/**
1497 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301498 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301499 * @peer_addr: peer mac address
1500 * @param: pointer to sta_ps parameter structure
1501 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301502 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301503 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301504static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301505 struct sta_ps_params *param)
1506{
1507 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1508 wmi_buf_t buf;
1509 int32_t len = sizeof(*cmd);
1510
1511 buf = wmi_buf_alloc(wmi_handle, len);
1512 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301513 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301514 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301515 }
1516
1517 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1518 WMITLV_SET_HDR(&cmd->tlv_header,
1519 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1520 WMITLV_GET_STRUCT_TLVLEN
1521 (wmi_sta_powersave_param_cmd_fixed_param));
1522 cmd->vdev_id = param->vdev_id;
1523 cmd->param = param->param;
1524 cmd->value = param->value;
1525
1526 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1527 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301528 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301529 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301530 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301531 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301532 }
1533
1534 return 0;
1535}
1536
1537/**
1538 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301539 * @wmi_handle: wmi handle
Jeff Johnsonbbd428c2018-05-06 17:02:16 -07001540 * @param: ponirt to crash inject parameter structure
Govind Singh5eb51532016-03-09 11:34:12 +05301541 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301542 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301543 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301544static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301545 struct crash_inject *param)
1546{
1547 int32_t ret = 0;
1548 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1549 uint16_t len = sizeof(*cmd);
1550 wmi_buf_t buf;
1551
1552 buf = wmi_buf_alloc(wmi_handle, len);
1553 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301554 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301555 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301556 }
1557
1558 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1559 WMITLV_SET_HDR(&cmd->tlv_header,
1560 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1561 WMITLV_GET_STRUCT_TLVLEN
1562 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1563 cmd->type = param->type;
1564 cmd->delay_time_ms = param->delay_time_ms;
1565
1566 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1567 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301568 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301569 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301570 __func__, ret);
1571 wmi_buf_free(buf);
1572 }
1573
1574 return ret;
1575}
1576
1577/**
1578 * send_dbglog_cmd_tlv() - set debug log level
1579 * @param wmi_handle : handle to WMI.
1580 * @param param : pointer to hold dbglog level parameter
1581 *
1582 * Return: 0 on success and -ve on failure.
1583 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301584 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301585send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1586 struct dbglog_params *dbglog_param)
1587{
1588 wmi_buf_t buf;
1589 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001590 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301591 int32_t i;
1592 int32_t len;
1593 int8_t *buf_ptr;
1594 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1595
Alok Kumar240afea2017-08-30 14:45:34 +05301596 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301597
1598 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1599 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1600 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1601 buf = wmi_buf_alloc(wmi_handle, len);
1602 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001603 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301604
1605 configmsg =
1606 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1607 buf_ptr = (int8_t *) configmsg;
1608 WMITLV_SET_HDR(&configmsg->tlv_header,
1609 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1610 WMITLV_GET_STRUCT_TLVLEN
1611 (wmi_debug_log_config_cmd_fixed_param));
1612 configmsg->dbg_log_param = dbglog_param->param;
1613 configmsg->value = dbglog_param->val;
1614 /* Filling in the data part of second tlv -- should
1615 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301616 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301617 sizeof
1618 (wmi_debug_log_config_cmd_fixed_param)
1619 + WMI_TLV_HDR_SIZE);
1620 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1621 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301622 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301623 if (dbglog_param->module_id_bitmap) {
1624 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1625 module_id_bitmap_array[i] =
1626 dbglog_param->module_id_bitmap[i];
1627 }
1628 }
1629
1630 status = wmi_unified_cmd_send(wmi_handle, buf,
1631 len, WMI_DBGLOG_CFG_CMDID);
1632
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001633 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301634 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301635
1636 return status;
1637}
1638
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301639#ifdef CONFIG_MCL
1640static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1641 uint32_t host_param)
1642{
1643 return host_param;
1644}
1645#else
1646static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1647 uint32_t host_param)
1648{
1649 if (host_param < wmi_vdev_param_max)
1650 return wmi_handle->vdev_param[host_param];
1651
1652 return WMI_UNAVAILABLE_PARAM;
1653}
1654#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301655/**
1656 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1657 * @param wmi_handle : handle to WMI.
1658 * @param macaddr : MAC address
1659 * @param param : pointer to hold vdev set parameter
1660 *
1661 * Return: 0 on success and -ve on failure.
1662 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301663static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301664 struct vdev_set_params *param)
1665{
Govind Singh67922e82016-04-01 16:48:57 +05301666 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301667 wmi_vdev_set_param_cmd_fixed_param *cmd;
1668 wmi_buf_t buf;
1669 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301670 uint32_t vdev_param;
1671
1672 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1673 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1674 WMI_LOGW("%s:Vdev param %d not available", __func__,
1675 param->param_id);
1676 return QDF_STATUS_E_INVAL;
1677
1678 }
Govind Singh5eb51532016-03-09 11:34:12 +05301679
1680 buf = wmi_buf_alloc(wmi_handle, len);
1681 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301682 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301683 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301684 }
1685 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1686 WMITLV_SET_HDR(&cmd->tlv_header,
1687 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1688 WMITLV_GET_STRUCT_TLVLEN
1689 (wmi_vdev_set_param_cmd_fixed_param));
1690 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301691 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301692 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301693 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001694 cmd->vdev_id, cmd->param_id, cmd->param_value);
Govind Singh5eb51532016-03-09 11:34:12 +05301695 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1696 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301697 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301698 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301699 wmi_buf_free(buf);
1700 }
1701
1702 return ret;
1703}
1704
1705/**
1706 * send_stats_request_cmd_tlv() - WMI request stats function
1707 * @param wmi_handle : handle to WMI.
1708 * @param macaddr : MAC address
1709 * @param param : pointer to hold stats request parameter
1710 *
1711 * Return: 0 on success and -ve on failure.
1712 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301713static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301714 uint8_t macaddr[IEEE80211_ADDR_LEN],
1715 struct stats_request_params *param)
1716{
Govind Singhd3156eb2016-02-26 17:50:39 +05301717 int32_t ret;
1718 wmi_request_stats_cmd_fixed_param *cmd;
1719 wmi_buf_t buf;
1720 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1721
1722 buf = wmi_buf_alloc(wmi_handle, len);
1723 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301724 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1725 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301726 }
1727
1728 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1729 WMITLV_SET_HDR(&cmd->tlv_header,
1730 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1731 WMITLV_GET_STRUCT_TLVLEN
1732 (wmi_request_stats_cmd_fixed_param));
1733 cmd->stats_id = param->stats_id;
1734 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301735 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1736 param->pdev_id);
1737 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001738
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301739 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1740 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001741
1742 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1743 WMI_REQUEST_STATS_CMDID);
1744
Govind Singhd3156eb2016-02-26 17:50:39 +05301745 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301746 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301747 wmi_buf_free(buf);
1748 }
1749
1750 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301751}
1752
Govind Singh87542482016-06-08 19:40:11 +05301753#ifdef CONFIG_WIN
1754/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001755 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301756 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001757 * @param PKTLOG_EVENT : packet log event
1758 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301759 *
1760 * Return: 0 on success and -ve on failure.
1761 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301762static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001763 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301764{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001765 int32_t ret;
1766 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1767 wmi_buf_t buf;
1768 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1769
1770 buf = wmi_buf_alloc(wmi_handle, len);
1771 if (!buf) {
1772 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1773 return -QDF_STATUS_E_NOMEM;
1774 }
1775
1776 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1777 WMITLV_SET_HDR(&cmd->tlv_header,
1778 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1779 WMITLV_GET_STRUCT_TLVLEN
1780 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1781 cmd->evlist = PKTLOG_EVENT;
1782 cmd->pdev_id = mac_id;
1783 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1784 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1785 if (ret) {
1786 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1787 wmi_buf_free(buf);
1788 }
1789
1790 return ret;
1791}
1792
1793/**
1794 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1795 * @param wmi_handle : handle to WMI.
1796 * @mac_id: mac id to have radio context
1797 *
1798 * Return: 0 on success and -ve on failure.
1799 */
1800static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001801 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001802{
1803 int32_t ret;
1804 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1805 wmi_buf_t buf;
1806 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1807
1808 buf = wmi_buf_alloc(wmi_handle, len);
1809 if (!buf) {
1810 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1811 return -QDF_STATUS_E_NOMEM;
1812 }
1813
1814 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1815 WMITLV_SET_HDR(&cmd->tlv_header,
1816 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1817 WMITLV_GET_STRUCT_TLVLEN
1818 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1819 cmd->pdev_id = mac_id;
1820 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1821 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1822 if (ret) {
1823 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1824 wmi_buf_free(buf);
1825 }
1826
1827 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301828}
1829#else
Govind Singh5eb51532016-03-09 11:34:12 +05301830/**
Keyur Parekhde522342017-08-18 14:01:05 -07001831 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1832 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301833 * @param wmi_handle : handle to WMI.
1834 * @param macaddr : MAC address
1835 * @param param : pointer to hold stats request parameter
1836 *
1837 * Return: 0 on success and -ve on failure.
1838 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301839static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301840 uint8_t macaddr[IEEE80211_ADDR_LEN],
1841 struct packet_enable_params *param)
1842{
1843 return 0;
1844}
Keyur Parekhde522342017-08-18 14:01:05 -07001845/**
1846 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1847 * packet-log
1848 * @param wmi_handle : handle to WMI.
1849 * @mac_id: mac id to have radio context
1850 *
1851 * Return: 0 on success and -ve on failure.
1852 */
1853static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1854 uint8_t mac_id)
1855{
1856 return 0;
1857}
Govind Singh87542482016-06-08 19:40:11 +05301858#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301859
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301860#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1861/**
1862 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1863 * sync time between bwtween host and firmware
1864 * @param wmi_handle : handle to WMI.
1865 *
1866 * Return: None
1867 */
1868static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1869{
1870 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07001871 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301872 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1873 int32_t len;
1874 qdf_time_t time_ms;
1875
1876 len = sizeof(*time_stamp);
1877 buf = wmi_buf_alloc(wmi_handle, len);
1878
1879 if (!buf) {
1880 WMI_LOGP(FL("wmi_buf_alloc failed"));
1881 return;
1882 }
1883 time_stamp =
1884 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1885 (wmi_buf_data(buf));
1886 WMITLV_SET_HDR(&time_stamp->tlv_header,
1887 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1888 WMITLV_GET_STRUCT_TLVLEN(
1889 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1890
1891 time_ms = qdf_get_time_of_the_day_ms();
1892 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1893 time_stamp->time_stamp_low = time_ms &
1894 WMI_FW_TIME_STAMP_LOW_MASK;
1895 /*
1896 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1897 * wont exceed 27 bit
1898 */
1899 time_stamp->time_stamp_high = 0;
1900 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1901 time_stamp->mode, time_stamp->time_stamp_low,
1902 time_stamp->time_stamp_high);
1903
1904 status = wmi_unified_cmd_send(wmi_handle, buf,
1905 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
1906 if (status) {
1907 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
1908 wmi_buf_free(buf);
1909 }
1910
1911}
1912
Subrat Mishrad7c7a562017-09-27 14:41:20 +05301913#ifdef WLAN_SUPPORT_FILS
1914/**
1915 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
1916 * @wmi_handle: wmi handle
1917 * @evt_buf: pointer to event buffer
1918 * @vdev_id: pointer to hold vdev id
1919 *
1920 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
1921 */
1922static QDF_STATUS
1923extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
1924 void *evt_buf, uint32_t *vdev_id)
1925{
1926 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
1927 wmi_host_swfda_event_fixed_param *swfda_event;
1928
1929 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
1930 if (!param_buf) {
1931 WMI_LOGE("Invalid swfda event buffer");
1932 return QDF_STATUS_E_INVAL;
1933 }
1934 swfda_event = param_buf->fixed_param;
1935 *vdev_id = swfda_event->vdev_id;
1936
1937 return QDF_STATUS_SUCCESS;
1938}
1939
1940/**
1941 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
1942 * @wmi_handle: wmi handle
1943 * @param: pointer to hold FILS discovery enable param
1944 *
1945 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
1946 */
1947static QDF_STATUS
1948send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
1949 struct config_fils_params *param)
1950{
1951 wmi_enable_fils_cmd_fixed_param *cmd;
1952 wmi_buf_t buf;
1953 QDF_STATUS status;
1954 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
1955
1956 buf = wmi_buf_alloc(wmi_handle, len);
1957 if (!buf) {
1958 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1959 return QDF_STATUS_E_NOMEM;
1960 }
1961 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
1962 WMITLV_SET_HDR(&cmd->tlv_header,
1963 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
1964 WMITLV_GET_STRUCT_TLVLEN(
1965 wmi_enable_fils_cmd_fixed_param));
1966 cmd->vdev_id = param->vdev_id;
1967 cmd->fd_period = param->fd_period;
1968 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
1969 param->fd_period, param->vdev_id);
1970
1971 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1972 WMI_ENABLE_FILS_CMDID);
1973 if (status != QDF_STATUS_SUCCESS) {
1974 wmi_buf_free(buf);
1975 return QDF_STATUS_E_FAILURE;
1976 }
1977
1978 return QDF_STATUS_SUCCESS;
1979}
1980
1981/**
1982 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
1983 * @wmi_handle: wmi handle
1984 * @param: pointer to hold FD send cmd parameter
1985 *
1986 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
1987 */
1988static QDF_STATUS
1989send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
1990 struct fd_params *param)
1991{
1992 QDF_STATUS ret;
1993 wmi_fd_send_from_host_cmd_fixed_param *cmd;
1994 wmi_buf_t wmi_buf;
1995 qdf_dma_addr_t dma_addr;
1996
1997 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1998 if (!wmi_buf) {
1999 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2000 return QDF_STATUS_E_NOMEM;
2001 }
2002 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2003 WMITLV_SET_HDR(&cmd->tlv_header,
2004 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2005 WMITLV_GET_STRUCT_TLVLEN(
2006 wmi_fd_send_from_host_cmd_fixed_param));
2007 cmd->vdev_id = param->vdev_id;
2008 cmd->data_len = qdf_nbuf_len(param->wbuf);
2009 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2010 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2011 cmd->frame_ctrl = param->frame_ctrl;
2012
2013 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2014 WMI_PDEV_SEND_FD_CMDID);
2015 if (ret != QDF_STATUS_SUCCESS) {
2016 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2017 __func__, ret);
2018 wmi_buf_free(wmi_buf);
2019 }
2020
2021 return ret;
2022}
2023#endif /* WLAN_SUPPORT_FILS */
2024
Sathish Kumarfd347372017-02-13 12:29:09 +05302025static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302026 struct beacon_params *param)
2027{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302028 QDF_STATUS ret;
2029 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2030 wmi_buf_t wmi_buf;
2031 qdf_dma_addr_t dma_addr;
2032 uint32_t dtim_flag = 0;
2033
2034 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2035 if (!wmi_buf) {
2036 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2037 return QDF_STATUS_E_NOMEM;
2038 }
2039 if (param->is_dtim_count_zero) {
2040 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2041 if (param->is_bitctl_reqd) {
2042 /* deliver CAB traffic in next DTIM beacon */
2043 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2044 }
2045 }
2046 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2047 WMITLV_SET_HDR(&cmd->tlv_header,
2048 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2049 WMITLV_GET_STRUCT_TLVLEN
2050 (wmi_bcn_send_from_host_cmd_fixed_param));
2051 cmd->vdev_id = param->vdev_id;
2052 cmd->data_len = qdf_nbuf_len(param->wbuf);
2053 cmd->frame_ctrl = param->frame_ctrl;
2054 cmd->dtim_flag = dtim_flag;
2055 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2056 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2057#if defined(HTT_PADDR64)
2058 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2059#endif
2060 cmd->bcn_antenna = param->bcn_txant;
2061
2062 ret = wmi_unified_cmd_send(wmi_handle,
2063 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2064 if (ret != QDF_STATUS_SUCCESS) {
2065 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2066 wmi_buf_free(wmi_buf);
2067 }
2068
2069 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302070}
2071
2072/**
2073 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2074 * @param wmi_handle : handle to WMI.
2075 * @param param : pointer to hold beacon send cmd parameter
2076 *
2077 * Return: 0 on success and -ve on failure.
2078 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302079static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302080 struct beacon_tmpl_params *param)
2081{
2082 int32_t ret;
2083 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2084 wmi_bcn_prb_info *bcn_prb_info;
2085 wmi_buf_t wmi_buf;
2086 uint8_t *buf_ptr;
2087 uint32_t wmi_buf_len;
2088
2089 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2090 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2091 param->tmpl_len_aligned;
2092 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2093 if (!wmi_buf) {
2094 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2095 return QDF_STATUS_E_NOMEM;
2096 }
2097 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2098 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2099 WMITLV_SET_HDR(&cmd->tlv_header,
2100 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2101 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2102 cmd->vdev_id = param->vdev_id;
2103 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302104 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2105 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05302106 cmd->buf_len = param->tmpl_len;
2107 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2108
2109 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2110 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2111 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2112 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2113 bcn_prb_info->caps = 0;
2114 bcn_prb_info->erp = 0;
2115 buf_ptr += sizeof(wmi_bcn_prb_info);
2116
2117 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2118 buf_ptr += WMI_TLV_HDR_SIZE;
2119 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2120
2121 ret = wmi_unified_cmd_send(wmi_handle,
2122 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2123 if (ret) {
2124 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2125 wmi_buf_free(wmi_buf);
2126 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302127
Govind Singh87542482016-06-08 19:40:11 +05302128 return 0;
2129}
Govind Singh5eb51532016-03-09 11:34:12 +05302130
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302131#ifdef CONFIG_MCL
2132static inline void copy_peer_flags_tlv(
2133 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2134 struct peer_assoc_params *param)
2135{
2136 cmd->peer_flags = param->peer_flags;
2137}
2138#else
2139static inline void copy_peer_flags_tlv(
2140 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2141 struct peer_assoc_params *param)
2142{
2143 /*
2144 * The target only needs a subset of the flags maintained in the host.
2145 * Just populate those flags and send it down
2146 */
2147 cmd->peer_flags = 0;
2148
2149 /*
2150 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2151 */
2152 if (param->is_wme_set) {
2153
2154 if (param->qos_flag)
2155 cmd->peer_flags |= WMI_PEER_QOS;
2156 if (param->apsd_flag)
2157 cmd->peer_flags |= WMI_PEER_APSD;
2158 if (param->ht_flag)
2159 cmd->peer_flags |= WMI_PEER_HT;
2160 if (param->bw_40)
2161 cmd->peer_flags |= WMI_PEER_40MHZ;
2162 if (param->bw_80)
2163 cmd->peer_flags |= WMI_PEER_80MHZ;
2164 if (param->bw_160)
2165 cmd->peer_flags |= WMI_PEER_160MHZ;
2166
2167 /* Typically if STBC is enabled for VHT it should be enabled
2168 * for HT as well
2169 **/
2170 if (param->stbc_flag)
2171 cmd->peer_flags |= WMI_PEER_STBC;
2172
2173 /* Typically if LDPC is enabled for VHT it should be enabled
2174 * for HT as well
2175 **/
2176 if (param->ldpc_flag)
2177 cmd->peer_flags |= WMI_PEER_LDPC;
2178
2179 if (param->static_mimops_flag)
2180 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2181 if (param->dynamic_mimops_flag)
2182 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2183 if (param->spatial_mux_flag)
2184 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2185 if (param->vht_flag)
2186 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002187 if (param->he_flag)
2188 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302189 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002190
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302191 if (param->is_pmf_enabled)
2192 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302193 /*
2194 * Suppress authorization for all AUTH modes that need 4-way handshake
2195 * (during re-association).
2196 * Authorization will be done for these modes on key installation.
2197 */
2198 if (param->auth_flag)
2199 cmd->peer_flags |= WMI_PEER_AUTH;
2200 if (param->need_ptk_4_way)
2201 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2202 else
2203 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2204 if (param->need_gtk_2_way)
2205 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2206 /* safe mode bypass the 4-way handshake */
2207 if (param->safe_mode_enabled)
2208 cmd->peer_flags &=
2209 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2210 /* Disable AMSDU for station transmit, if user configures it */
2211 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2212 * it
2213 * if (param->amsdu_disable) Add after FW support
2214 **/
2215
2216 /* Target asserts if node is marked HT and all MCS is set to 0.
2217 * Mark the node as non-HT if all the mcs rates are disabled through
2218 * iwpriv
2219 **/
2220 if (param->peer_ht_rates.num_rates == 0)
2221 cmd->peer_flags &= ~WMI_PEER_HT;
2222}
2223#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302224
2225#ifdef CONFIG_MCL
2226static inline void copy_peer_mac_addr_tlv(
2227 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2228 struct peer_assoc_params *param)
2229{
2230 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2231 sizeof(param->peer_macaddr));
2232}
2233#else
2234static inline void copy_peer_mac_addr_tlv(
2235 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2236 struct peer_assoc_params *param)
2237{
2238 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2239}
2240#endif
2241
Govind Singh5eb51532016-03-09 11:34:12 +05302242/**
2243 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2244 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302245 * @param param : pointer to peer assoc parameter
2246 *
2247 * Return: 0 on success and -ve on failure.
2248 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302249static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302250 struct peer_assoc_params *param)
2251{
Govind Singhd3156eb2016-02-26 17:50:39 +05302252 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2253 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002254 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302255 wmi_buf_t buf;
2256 int32_t len;
2257 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302258 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302259 uint32_t peer_legacy_rates_align;
2260 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002261 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302262
2263
2264 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2265 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302266
2267 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002268 (peer_legacy_rates_align * sizeof(uint8_t)) +
2269 WMI_TLV_HDR_SIZE +
2270 (peer_ht_rates_align * sizeof(uint8_t)) +
2271 sizeof(wmi_vht_rate_set) +
2272 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2273 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302274
2275 buf = wmi_buf_alloc(wmi_handle, len);
2276 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302277 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302278 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302279 }
2280
2281 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2282 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2283 WMITLV_SET_HDR(&cmd->tlv_header,
2284 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2285 WMITLV_GET_STRUCT_TLVLEN
2286 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302287
Govind Singhd3156eb2016-02-26 17:50:39 +05302288 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302289
Govind Singhd3156eb2016-02-26 17:50:39 +05302290 cmd->peer_new_assoc = param->peer_new_assoc;
2291 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302292
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302293 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302294 copy_peer_mac_addr_tlv(cmd, param);
2295
Govind Singhd3156eb2016-02-26 17:50:39 +05302296 cmd->peer_rate_caps = param->peer_rate_caps;
2297 cmd->peer_caps = param->peer_caps;
2298 cmd->peer_listen_intval = param->peer_listen_intval;
2299 cmd->peer_ht_caps = param->peer_ht_caps;
2300 cmd->peer_max_mpdu = param->peer_max_mpdu;
2301 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302302 cmd->peer_vht_caps = param->peer_vht_caps;
2303 cmd->peer_phymode = param->peer_phymode;
2304
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002305 /* Update 11ax capabilities */
2306 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2307 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002308 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2309 sizeof(param->peer_he_cap_phyinfo));
2310 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2311 sizeof(param->peer_ppet));
2312
Govind Singhd3156eb2016-02-26 17:50:39 +05302313 /* Update peer legacy rate information */
2314 buf_ptr += sizeof(*cmd);
2315 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302316 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302317 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302318 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302319 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302320 param->peer_legacy_rates.num_rates);
2321
2322 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002323 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302324 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302325 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302326 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302327 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302328 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302329 param->peer_ht_rates.num_rates);
2330
2331 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002332 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302333 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2334 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2335
2336 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302337
2338 /* Update bandwidth-NSS mapping */
2339 cmd->peer_bw_rxnss_override = 0;
2340 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2341
Govind Singhd3156eb2016-02-26 17:50:39 +05302342 mcs = (wmi_vht_rate_set *) buf_ptr;
2343 if (param->vht_capable) {
2344 mcs->rx_max_rate = param->rx_max_rate;
2345 mcs->rx_mcs_set = param->rx_mcs_set;
2346 mcs->tx_max_rate = param->tx_max_rate;
2347 mcs->tx_mcs_set = param->tx_mcs_set;
2348 }
2349
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002350 /* HE Rates */
2351 cmd->peer_he_mcs = param->peer_he_mcs_count;
2352 buf_ptr += sizeof(wmi_vht_rate_set);
2353 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2354 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2355 buf_ptr += WMI_TLV_HDR_SIZE;
2356
2357 /* Loop through the HE rate set */
2358 for (i = 0; i < param->peer_he_mcs_count; i++) {
2359 he_mcs = (wmi_he_rate_set *) buf_ptr;
2360 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2361 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2362
2363 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2364 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2365 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2366 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2367 buf_ptr += sizeof(wmi_he_rate_set);
2368 }
2369
2370
Govind Singhb53420c2016-03-09 14:32:57 +05302371 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302372 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2373 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002374 "cmd->peer_vht_caps %x "
2375 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302376 "HE phy %x %x %x "
2377 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302378 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2379 cmd->peer_rate_caps, cmd->peer_caps,
2380 cmd->peer_listen_intval, cmd->peer_ht_caps,
2381 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2382 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002383 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2384 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302385 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2386 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302387
2388 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2389 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302390 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302391 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302392 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302393 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302394 }
2395
2396 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302397}
2398
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302399/* copy_scan_notify_events() - Helper routine to copy scan notify events
2400 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302401static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302402 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302403 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302404{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302405
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302406 /* Scan events subscription */
2407 if (param->scan_ev_started)
2408 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2409 if (param->scan_ev_completed)
2410 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2411 if (param->scan_ev_bss_chan)
2412 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2413 if (param->scan_ev_foreign_chan)
2414 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2415 if (param->scan_ev_dequeued)
2416 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2417 if (param->scan_ev_preempted)
2418 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2419 if (param->scan_ev_start_failed)
2420 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2421 if (param->scan_ev_restarted)
2422 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2423 if (param->scan_ev_foreign_chn_exit)
2424 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2425 if (param->scan_ev_suspended)
2426 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2427 if (param->scan_ev_resumed)
2428 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302429
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302430 /** Set scan control flags */
2431 cmd->scan_ctrl_flags = 0;
2432 if (param->scan_f_passive)
2433 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2434 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302435 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302436 if (param->scan_f_promisc_mode)
2437 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2438 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302439 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302440 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302441 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302442 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302443 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302444 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302445 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302446 if (param->scan_f_ofdm_rates)
2447 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2448 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302449 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302450 if (param->scan_f_filter_prb_req)
2451 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2452 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302453 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302454 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302455 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302456 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302457 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302458 if (param->scan_f_force_active_dfs_chn)
2459 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2460 if (param->scan_f_add_tpc_ie_in_probe)
2461 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2462 if (param->scan_f_add_ds_ie_in_probe)
2463 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2464 if (param->scan_f_add_spoofed_mac_in_probe)
2465 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2466 if (param->scan_f_add_rand_seq_in_probe)
2467 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2468 if (param->scan_f_en_ie_whitelist_in_probe)
2469 cmd->scan_ctrl_flags |=
2470 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302471
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302472 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2473 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2474 param->adaptive_dwell_time_mode);
2475}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302476
2477/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302478static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302479 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302480{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302481 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302482}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302483
Govind Singh5eb51532016-03-09 11:34:12 +05302484/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302485 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2486 * @mac: random mac addr
2487 * @mask: random mac mask
2488 * @mac_addr: wmi random mac
2489 * @mac_mask: wmi random mac mask
2490 *
2491 * Return None.
2492 */
2493static inline
2494void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2495 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2496{
2497 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2498 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2499}
2500
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302501/*
2502 * wmi_fill_vendor_oui() - fill vendor OUIs
2503 * @buf_ptr: pointer to wmi tlv buffer
2504 * @num_vendor_oui: number of vendor OUIs to be filled
2505 * @param_voui: pointer to OUI buffer
2506 *
2507 * This function populates the wmi tlv buffer when vendor specific OUIs are
2508 * present.
2509 *
2510 * Return: None
2511 */
2512static inline
2513void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2514 uint32_t *pvoui)
2515{
2516 wmi_vendor_oui *voui = NULL;
2517 uint32_t i;
2518
2519 voui = (wmi_vendor_oui *)buf_ptr;
2520
2521 for (i = 0; i < num_vendor_oui; i++) {
2522 WMITLV_SET_HDR(&voui[i].tlv_header,
2523 WMITLV_TAG_STRUC_wmi_vendor_oui,
2524 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2525 voui[i].oui_type_subtype = pvoui[i];
2526 }
2527}
2528
2529/*
2530 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2531 * @ie_bitmap: output pointer to ie bit map in cmd
2532 * @num_vendor_oui: output pointer to num vendor OUIs
2533 * @ie_whitelist: input parameter
2534 *
2535 * This function populates the IE whitelist attrs of scan, pno and
2536 * scan oui commands for ie_whitelist parameter.
2537 *
2538 * Return: None
2539 */
2540static inline
2541void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2542 uint32_t *num_vendor_oui,
2543 struct probe_req_whitelist_attr *ie_whitelist)
2544{
2545 uint32_t i = 0;
2546
2547 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2548 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2549
2550 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2551}
2552
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302553/**
Govind Singh5eb51532016-03-09 11:34:12 +05302554 * send_scan_start_cmd_tlv() - WMI scan start function
2555 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302556 * @param param : pointer to hold scan start cmd parameter
2557 *
2558 * Return: 0 on success and -ve on failure.
2559 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302560static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302561 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302562{
Govind Singhd3156eb2016-02-26 17:50:39 +05302563 int32_t ret = 0;
2564 int32_t i;
2565 wmi_buf_t wmi_buf;
2566 wmi_start_scan_cmd_fixed_param *cmd;
2567 uint8_t *buf_ptr;
2568 uint32_t *tmp_ptr;
2569 wmi_ssid *ssid = NULL;
2570 wmi_mac_addr *bssid;
2571 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302572 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302573 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302574 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302575
2576 /* Length TLV placeholder for array of uint32_t */
2577 len += WMI_TLV_HDR_SIZE;
2578 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302579 if (params->chan_list.num_chan)
2580 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302581
2582 /* Length TLV placeholder for array of wmi_ssid structures */
2583 len += WMI_TLV_HDR_SIZE;
2584 if (params->num_ssids)
2585 len += params->num_ssids * sizeof(wmi_ssid);
2586
2587 /* Length TLV placeholder for array of wmi_mac_addr structures */
2588 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302589 if (params->num_bssid)
2590 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302591
2592 /* Length TLV placeholder for array of bytes */
2593 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302594 if (params->extraie.len)
2595 extraie_len_with_pad =
2596 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002597 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302598
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302599 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2600 if (ie_whitelist->num_vendor_oui)
2601 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2602
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302603 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2604 if (params->scan_f_wide_band)
2605 phymode_roundup =
2606 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2607 sizeof(uint32_t));
2608 len += phymode_roundup;
2609
Govind Singhd3156eb2016-02-26 17:50:39 +05302610 /* Allocate the memory */
2611 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2612 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302613 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302614 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302615 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302616 }
2617 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2618 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2619 WMITLV_SET_HDR(&cmd->tlv_header,
2620 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2621 WMITLV_GET_STRUCT_TLVLEN
2622 (wmi_start_scan_cmd_fixed_param));
2623
2624 cmd->scan_id = params->scan_id;
2625 cmd->scan_req_id = params->scan_req_id;
2626 cmd->vdev_id = params->vdev_id;
2627 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302628
2629 copy_scan_event_cntrl_flags(cmd, params);
2630
Govind Singhd3156eb2016-02-26 17:50:39 +05302631 cmd->dwell_time_active = params->dwell_time_active;
2632 cmd->dwell_time_passive = params->dwell_time_passive;
2633 cmd->min_rest_time = params->min_rest_time;
2634 cmd->max_rest_time = params->max_rest_time;
2635 cmd->repeat_probe_time = params->repeat_probe_time;
2636 cmd->probe_spacing_time = params->probe_spacing_time;
2637 cmd->idle_time = params->idle_time;
2638 cmd->max_scan_time = params->max_scan_time;
2639 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302640 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302641 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302642 cmd->num_bssid = params->num_bssid;
2643 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302644 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302645 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302646 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2647
2648 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2649
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302650 if (params->scan_random.randomize)
2651 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2652 params->scan_random.mac_mask,
2653 &cmd->mac_addr,
2654 &cmd->mac_mask);
2655
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302656 if (ie_whitelist->white_list)
2657 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2658 &cmd->num_vendor_oui,
2659 ie_whitelist);
2660
Govind Singhd3156eb2016-02-26 17:50:39 +05302661 buf_ptr += sizeof(*cmd);
2662 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302663 for (i = 0; i < params->chan_list.num_chan; ++i)
2664 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302665
2666 WMITLV_SET_HDR(buf_ptr,
2667 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302668 (params->chan_list.num_chan * sizeof(uint32_t)));
2669 buf_ptr += WMI_TLV_HDR_SIZE +
2670 (params->chan_list.num_chan * sizeof(uint32_t));
2671
Govind Singh4eacd2b2016-03-07 14:24:22 +05302672 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302673 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302674 goto error;
2675 }
2676
2677 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2678 (params->num_ssids * sizeof(wmi_ssid)));
2679
2680 if (params->num_ssids) {
2681 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2682 for (i = 0; i < params->num_ssids; ++i) {
2683 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302684 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302685 params->ssid[i].length);
2686 ssid++;
2687 }
2688 }
2689 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2690
2691 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2692 (params->num_bssid * sizeof(wmi_mac_addr)));
2693 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302694
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302695 if (params->num_bssid) {
2696 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302697 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2698 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302699 bssid++;
2700 }
2701 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302702
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302703 buf_ptr += WMI_TLV_HDR_SIZE +
2704 (params->num_bssid * sizeof(wmi_mac_addr));
2705
2706 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2707 if (params->extraie.len)
2708 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2709 params);
2710
2711 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302712
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302713 /* probe req ie whitelisting */
2714 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2715 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2716
2717 buf_ptr += WMI_TLV_HDR_SIZE;
2718
2719 if (cmd->num_vendor_oui) {
2720 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2721 ie_whitelist->voui);
2722 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2723 }
2724
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302725 /* Add phy mode TLV if it's a wide band scan */
2726 if (params->scan_f_wide_band) {
2727 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2728 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2729 for (i = 0; i < params->chan_list.num_chan; ++i)
2730 buf_ptr[i] =
2731 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2732 buf_ptr += phymode_roundup;
2733 } else {
2734 /* Add ZERO legth phy mode TLV */
2735 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2736 }
2737
Santosh Anbu1e11b472018-03-07 15:33:27 +05302738 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002739 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302740 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302741 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302742 wmi_buf_free(wmi_buf);
2743 }
2744 return ret;
2745error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302746 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302747 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302748}
2749
2750/**
2751 * send_scan_stop_cmd_tlv() - WMI scan start function
2752 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302753 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302754 *
2755 * Return: 0 on success and -ve on failure.
2756 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302757static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302758 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302759{
Govind Singhd3156eb2016-02-26 17:50:39 +05302760 wmi_stop_scan_cmd_fixed_param *cmd;
2761 int ret;
2762 int len = sizeof(*cmd);
2763 wmi_buf_t wmi_buf;
2764
2765 /* Allocate the memory */
2766 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2767 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302768 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302769 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302770 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302771 goto error;
2772 }
2773
2774 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2775 WMITLV_SET_HDR(&cmd->tlv_header,
2776 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2777 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2778 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302779 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302780 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302781 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2782 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302783 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302784 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2785 /* Cancelling all scans */
2786 cmd->req_type = WMI_SCAN_STOP_ALL;
2787 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2788 /* Cancelling VAP scans */
2789 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2790 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2791 /* Cancelling specific scan */
2792 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302793 } else {
2794 WMI_LOGE("%s: Invalid Command : ", __func__);
2795 wmi_buf_free(wmi_buf);
2796 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302797 }
2798
Santosh Anbu1e11b472018-03-07 15:33:27 +05302799 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002800 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302801 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302802 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302803 wmi_buf_free(wmi_buf);
2804 }
2805
2806error:
2807 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302808}
2809
Govind Singh87542482016-06-08 19:40:11 +05302810#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302811/**
2812 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2813 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302814 * @param param : pointer to hold scan channel list parameter
2815 *
2816 * Return: 0 on success and -ve on failure.
2817 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302818static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302819 struct scan_chan_list_params *chan_list)
2820{
2821 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302822 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302823 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302824 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302825 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302826 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302827 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2828
2829 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2830 buf = wmi_buf_alloc(wmi_handle, len);
2831 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302832 WMI_LOGE("Failed to allocate memory");
2833 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302834 goto end;
2835 }
2836
2837 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2838 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2839 WMITLV_SET_HDR(&cmd->tlv_header,
2840 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2841 WMITLV_GET_STRUCT_TLVLEN
2842 (wmi_scan_chan_list_cmd_fixed_param));
2843
Govind Singhb53420c2016-03-09 14:32:57 +05302844 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302845
2846 cmd->num_scan_chans = chan_list->num_scan_chans;
2847 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2848 WMITLV_TAG_ARRAY_STRUC,
2849 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302850 chan_info = (wmi_channel_param *)
2851 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302852 tchan_info = chan_list->chan_info;
2853
2854 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2855 WMITLV_SET_HDR(&chan_info->tlv_header,
2856 WMITLV_TAG_STRUC_wmi_channel,
2857 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2858 chan_info->mhz = tchan_info->mhz;
2859 chan_info->band_center_freq1 =
2860 tchan_info->band_center_freq1;
2861 chan_info->band_center_freq2 =
2862 tchan_info->band_center_freq2;
2863 chan_info->info = tchan_info->info;
2864 chan_info->reg_info_1 = tchan_info->reg_info_1;
2865 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302866 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302867
2868 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2869 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2870 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2871 tchan_info++;
2872 chan_info++;
2873 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302874 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2875 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302876
Anish Natarajdd855152017-03-20 12:49:08 +05302877 qdf_status = wmi_unified_cmd_send(wmi_handle,
2878 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302879
Govind Singh67922e82016-04-01 16:48:57 +05302880 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302881 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302882 wmi_buf_free(buf);
2883 }
Govind Singh67922e82016-04-01 16:48:57 +05302884
Govind Singhd3156eb2016-02-26 17:50:39 +05302885end:
Govind Singhb53420c2016-03-09 14:32:57 +05302886 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302887}
Govind Singh87542482016-06-08 19:40:11 +05302888#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302889static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302890 struct scan_chan_list_params *chan_list)
2891{
2892 wmi_buf_t buf;
2893 QDF_STATUS qdf_status;
2894 wmi_scan_chan_list_cmd_fixed_param *cmd;
2895 int i;
2896 uint8_t *buf_ptr;
2897 wmi_channel *chan_info;
2898 struct channel_param *tchan_info;
2899 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302900
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302901 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302902 buf = wmi_buf_alloc(wmi_handle, len);
2903 if (!buf) {
2904 WMI_LOGE("Failed to allocate memory");
2905 qdf_status = QDF_STATUS_E_NOMEM;
2906 goto end;
2907 }
2908
2909 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2910 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2911 WMITLV_SET_HDR(&cmd->tlv_header,
2912 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2913 WMITLV_GET_STRUCT_TLVLEN
2914 (wmi_scan_chan_list_cmd_fixed_param));
2915
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302916 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302917
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302918 if (chan_list->append)
2919 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2920
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302921 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2922 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302923 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302924 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2925 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302926 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302927 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2928 tchan_info = &(chan_list->ch_param[0]);
2929
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302930 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302931 WMITLV_SET_HDR(&chan_info->tlv_header,
2932 WMITLV_TAG_STRUC_wmi_channel,
2933 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2934 chan_info->mhz = tchan_info->mhz;
2935 chan_info->band_center_freq1 =
2936 tchan_info->cfreq1;
2937 chan_info->band_center_freq2 =
2938 tchan_info->cfreq2;
2939
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302940 if (tchan_info->is_chan_passive)
2941 WMI_SET_CHANNEL_FLAG(chan_info,
2942 WMI_CHAN_FLAG_PASSIVE);
2943
2944 if (tchan_info->allow_vht)
2945 WMI_SET_CHANNEL_FLAG(chan_info,
2946 WMI_CHAN_FLAG_ALLOW_VHT);
2947 else if (tchan_info->allow_ht)
2948 WMI_SET_CHANNEL_FLAG(chan_info,
2949 WMI_CHAN_FLAG_ALLOW_HT);
2950 WMI_SET_CHANNEL_MODE(chan_info,
2951 tchan_info->phy_mode);
2952
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05302953 if (tchan_info->half_rate)
2954 WMI_SET_CHANNEL_FLAG(chan_info,
2955 WMI_CHAN_FLAG_HALF_RATE);
2956
2957 if (tchan_info->quarter_rate)
2958 WMI_SET_CHANNEL_FLAG(chan_info,
2959 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302960
2961 /* also fill in power information */
2962 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2963 tchan_info->minpower);
2964 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2965 tchan_info->maxpower);
2966 WMI_SET_CHANNEL_REG_POWER(chan_info,
2967 tchan_info->maxregpower);
2968 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2969 tchan_info->antennamax);
2970 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2971 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08002972 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
2973 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302974
Govind Singh87542482016-06-08 19:40:11 +05302975 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2976
Govind Singh87542482016-06-08 19:40:11 +05302977 tchan_info++;
2978 chan_info++;
2979 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302980 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2981 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302982
Anish Natarajdd855152017-03-20 12:49:08 +05302983 qdf_status = wmi_unified_cmd_send(
2984 wmi_handle,
2985 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302986
2987 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2988 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2989 wmi_buf_free(buf);
2990 }
2991
2992end:
2993 return qdf_status;
2994}
2995#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302996
2997/**
2998 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
2999 *
3000 * @bufp: Pointer to buffer
3001 * @param: Pointer to tx param
3002 *
3003 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3004 */
3005static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3006 struct tx_send_params param)
3007{
3008 wmi_tx_send_params *tx_param;
3009 QDF_STATUS status = QDF_STATUS_SUCCESS;
3010
3011 if (!bufp) {
3012 status = QDF_STATUS_E_FAILURE;
3013 return status;
3014 }
3015 tx_param = (wmi_tx_send_params *)bufp;
3016 WMITLV_SET_HDR(&tx_param->tlv_header,
3017 WMITLV_TAG_STRUC_wmi_tx_send_params,
3018 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3019 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3020 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3021 param.mcs_mask);
3022 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3023 param.nss_mask);
3024 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3025 param.retry_limit);
3026 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3027 param.chain_mask);
3028 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3029 param.bw_mask);
3030 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3031 param.preamble_type);
3032 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3033 param.frame_type);
3034
3035 return status;
3036}
3037
Govind Singhd3156eb2016-02-26 17:50:39 +05303038/**
3039 * send_mgmt_cmd_tlv() - WMI scan start function
3040 * @wmi_handle : handle to WMI.
3041 * @param : pointer to hold mgmt cmd parameter
3042 *
3043 * Return: 0 on success and -ve on failure.
3044 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303045static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303046 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303047{
Govind Singh427ee5a2016-02-26 18:09:36 +05303048 wmi_buf_t buf;
3049 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3050 int32_t cmd_len;
3051 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303052 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303053 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303054 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303055 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3056 mgmt_tx_dl_frm_len;
3057
3058 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303059 WMI_TLV_HDR_SIZE +
3060 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303061
Sathish Kumar5b636932017-06-28 14:40:32 +05303062 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303063 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303064 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3065 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303066 }
3067
3068 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3069 bufp = (uint8_t *) cmd;
3070 WMITLV_SET_HDR(&cmd->tlv_header,
3071 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3072 WMITLV_GET_STRUCT_TLVLEN
3073 (wmi_mgmt_tx_send_cmd_fixed_param));
3074
3075 cmd->vdev_id = param->vdev_id;
3076
Govind Singh224a7312016-06-21 14:33:26 +05303077 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303078 cmd->chanfreq = param->chanfreq;
3079 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3080 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3081 sizeof(uint32_t)));
3082 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303083 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303084
3085 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3086 QDF_DMA_TO_DEVICE);
3087 if (status != QDF_STATUS_SUCCESS) {
3088 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303089 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303090 }
3091
Govind Singhb53420c2016-03-09 14:32:57 +05303092 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303093 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003094#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303095 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3096#endif
3097 cmd->frame_len = param->frm_len;
3098 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303099 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303100
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003101 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003102 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003103
Sathish Kumar5b636932017-06-28 14:40:32 +05303104 bufp += roundup(bufp_len, sizeof(uint32_t));
3105 if (param->tx_params_valid) {
3106 status = populate_tx_send_params(bufp, param->tx_param);
3107 if (status != QDF_STATUS_SUCCESS) {
3108 WMI_LOGE("%s: Populate TX send params failed",
3109 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303110 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303111 }
3112 cmd_len += sizeof(wmi_tx_send_params);
3113 }
3114
Govind Singh427ee5a2016-02-26 18:09:36 +05303115 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3116 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303117 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303118 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303119 }
Govind Singhb53420c2016-03-09 14:32:57 +05303120 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303121
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303122unmap_tx_frame:
3123 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3124 QDF_DMA_TO_DEVICE);
3125free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303126 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303127 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303128}
3129
3130/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303131 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3132 * @wmi_handle : handle to WMI.
3133 * @param : pointer to offchan data tx cmd parameter
3134 *
3135 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3136 */
3137static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3138 struct wmi_offchan_data_tx_params *param)
3139{
3140 wmi_buf_t buf;
3141 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3142 int32_t cmd_len;
3143 uint64_t dma_addr;
3144 void *qdf_ctx = param->qdf_ctx;
3145 uint8_t *bufp;
3146 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3147 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303148 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303149
3150 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303151 WMI_TLV_HDR_SIZE +
3152 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303153
Sathish Kumar5b636932017-06-28 14:40:32 +05303154 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303155 if (!buf) {
3156 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3157 return QDF_STATUS_E_NOMEM;
3158 }
3159
3160 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3161 bufp = (uint8_t *) cmd;
3162 WMITLV_SET_HDR(&cmd->tlv_header,
3163 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3164 WMITLV_GET_STRUCT_TLVLEN
3165 (wmi_offchan_data_tx_send_cmd_fixed_param));
3166
3167 cmd->vdev_id = param->vdev_id;
3168
3169 cmd->desc_id = param->desc_id;
3170 cmd->chanfreq = param->chanfreq;
3171 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3172 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3173 sizeof(uint32_t)));
3174 bufp += WMI_TLV_HDR_SIZE;
3175 qdf_mem_copy(bufp, param->pdata, bufp_len);
3176 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3177 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3178 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3179#if defined(HTT_PADDR64)
3180 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3181#endif
3182 cmd->frame_len = param->frm_len;
3183 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303184 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303185
3186 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3187 bufp, cmd->vdev_id, cmd->chanfreq);
3188
Sathish Kumar5b636932017-06-28 14:40:32 +05303189 bufp += roundup(bufp_len, sizeof(uint32_t));
3190 if (param->tx_params_valid) {
3191 status = populate_tx_send_params(bufp, param->tx_param);
3192 if (status != QDF_STATUS_SUCCESS) {
3193 WMI_LOGE("%s: Populate TX send params failed",
3194 __func__);
3195 goto err1;
3196 }
3197 cmd_len += sizeof(wmi_tx_send_params);
3198 }
3199
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303200 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3201 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3202 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303203 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303204 }
3205
3206 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303207
3208err1:
3209 wmi_buf_free(buf);
3210 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303211}
3212
3213/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303214 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3215 * @wmi_handle: wmi handle
3216 * @param_value: parameter value
3217 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303218 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303219 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303220static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303221 uint32_t param_value)
3222{
Govind Singh67922e82016-04-01 16:48:57 +05303223 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303224 wmi_modem_power_state_cmd_param *cmd;
3225 wmi_buf_t buf;
3226 uint16_t len = sizeof(*cmd);
3227
3228 buf = wmi_buf_alloc(wmi_handle, len);
3229 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303230 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303231 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303232 }
3233 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3234 WMITLV_SET_HDR(&cmd->tlv_header,
3235 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3236 WMITLV_GET_STRUCT_TLVLEN
3237 (wmi_modem_power_state_cmd_param));
3238 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303239 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303240 param_value);
3241 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3242 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303243 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303244 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303245 wmi_buf_free(buf);
3246 }
Govind Singh67922e82016-04-01 16:48:57 +05303247
Govind Singh427ee5a2016-02-26 18:09:36 +05303248 return ret;
3249}
3250
3251/**
3252 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3253 * @wmi_handle: wmi handle
3254 * @vdev_id: vdev id
3255 * @val: 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_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303260 uint32_t vdev_id, uint8_t val)
3261{
3262 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3263 wmi_buf_t buf;
3264 int32_t len = sizeof(*cmd);
3265
Govind Singhb53420c2016-03-09 14:32:57 +05303266 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303267
3268 buf = wmi_buf_alloc(wmi_handle, len);
3269 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303270 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303271 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303272 }
3273 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3274 WMITLV_SET_HDR(&cmd->tlv_header,
3275 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3276 WMITLV_GET_STRUCT_TLVLEN
3277 (wmi_sta_powersave_mode_cmd_fixed_param));
3278 cmd->vdev_id = vdev_id;
3279 if (val)
3280 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3281 else
3282 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3283
3284 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3285 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303286 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303287 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303288 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303289 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303290 }
Govind Singh5eb51532016-03-09 11:34:12 +05303291 return 0;
3292}
3293
Govind Singh427ee5a2016-02-26 18:09:36 +05303294/**
3295 * send_set_mimops_cmd_tlv() - set MIMO powersave
3296 * @wmi_handle: wmi handle
3297 * @vdev_id: vdev id
3298 * @value: value
3299 *
Govind Singhb53420c2016-03-09 14:32:57 +05303300 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303301 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303302static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303303 uint8_t vdev_id, int value)
3304{
Govind Singh67922e82016-04-01 16:48:57 +05303305 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303306 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3307 wmi_buf_t buf;
3308 uint16_t len = sizeof(*cmd);
3309
3310 buf = wmi_buf_alloc(wmi_handle, len);
3311 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303312 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303313 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303314 }
3315 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3316 WMITLV_SET_HDR(&cmd->tlv_header,
3317 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3318 WMITLV_GET_STRUCT_TLVLEN
3319 (wmi_sta_smps_force_mode_cmd_fixed_param));
3320
3321 cmd->vdev_id = vdev_id;
3322
Houston Hoffmanb5168052016-04-14 02:18:01 -07003323 /* WMI_SMPS_FORCED_MODE values do not directly map
3324 * to SM power save values defined in the specification.
3325 * Make sure to send the right mapping.
3326 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303327 switch (value) {
3328 case 0:
3329 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3330 break;
3331 case 1:
3332 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3333 break;
3334 case 2:
3335 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3336 break;
3337 case 3:
3338 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3339 break;
3340 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303341 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303342 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303343 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303344 }
3345
Govind Singhb53420c2016-03-09 14:32:57 +05303346 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303347
3348 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3349 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303350 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303351 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303352 wmi_buf_free(buf);
3353 }
3354
3355 return ret;
3356}
3357
3358/**
3359 * send_set_smps_params_cmd_tlv() - set smps params
3360 * @wmi_handle: wmi handle
3361 * @vdev_id: vdev id
3362 * @value: value
3363 *
Govind Singhb53420c2016-03-09 14:32:57 +05303364 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303365 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303366static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303367 int value)
3368{
Govind Singh67922e82016-04-01 16:48:57 +05303369 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303370 wmi_sta_smps_param_cmd_fixed_param *cmd;
3371 wmi_buf_t buf;
3372 uint16_t len = sizeof(*cmd);
3373
3374 buf = wmi_buf_alloc(wmi_handle, len);
3375 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303376 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303377 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303378 }
3379 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3380 WMITLV_SET_HDR(&cmd->tlv_header,
3381 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3382 WMITLV_GET_STRUCT_TLVLEN
3383 (wmi_sta_smps_param_cmd_fixed_param));
3384
3385 cmd->vdev_id = vdev_id;
3386 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3387 cmd->param =
3388 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3389
Govind Singhb53420c2016-03-09 14:32:57 +05303390 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303391 cmd->param);
3392
3393 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3394 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303395 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303396 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303397 wmi_buf_free(buf);
3398 }
3399
3400 return ret;
3401}
3402
3403/**
3404 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3405 * @wmi_handle: wmi handle
3406 * @noa: p2p power save parameters
3407 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303408 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303409 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303410static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303411 struct p2p_ps_params *noa)
3412{
3413 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3414 wmi_p2p_noa_descriptor *noa_discriptor;
3415 wmi_buf_t buf;
3416 uint8_t *buf_ptr;
3417 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303418 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303419 uint32_t duration;
3420
Govind Singhb53420c2016-03-09 14:32:57 +05303421 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303422 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3423 buf = wmi_buf_alloc(wmi_handle, len);
3424 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303425 WMI_LOGE("Failed to allocate memory");
3426 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303427 goto end;
3428 }
3429
3430 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3431 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3432 WMITLV_SET_HDR(&cmd->tlv_header,
3433 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3434 WMITLV_GET_STRUCT_TLVLEN
3435 (wmi_p2p_set_noa_cmd_fixed_param));
3436 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3437 cmd->vdev_id = noa->session_id;
3438 cmd->enable = (duration) ? true : false;
3439 cmd->num_noa = 1;
3440
3441 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3442 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3443 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3444 sizeof
3445 (wmi_p2p_set_noa_cmd_fixed_param)
3446 + WMI_TLV_HDR_SIZE);
3447 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3448 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3449 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3450 noa_discriptor->type_count = noa->count;
3451 noa_discriptor->duration = duration;
3452 noa_discriptor->interval = noa->interval;
3453 noa_discriptor->start_time = 0;
3454
Govind Singhb53420c2016-03-09 14:32:57 +05303455 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303456 cmd->vdev_id, noa->count, noa_discriptor->duration,
3457 noa->interval);
3458 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3459 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303460 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303461 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303462 wmi_buf_free(buf);
3463 }
3464
3465end:
Govind Singhb53420c2016-03-09 14:32:57 +05303466 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303467 return status;
3468}
3469
3470
3471/**
3472 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3473 * @wmi_handle: wmi handle
3474 * @noa: p2p opp power save parameters
3475 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303476 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303477 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303478static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303479 struct p2p_ps_params *oppps)
3480{
3481 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3482 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303483 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303484
Govind Singhb53420c2016-03-09 14:32:57 +05303485 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303486 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3487 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303488 WMI_LOGE("Failed to allocate memory");
3489 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303490 goto end;
3491 }
3492
3493 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3494 WMITLV_SET_HDR(&cmd->tlv_header,
3495 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3496 WMITLV_GET_STRUCT_TLVLEN
3497 (wmi_p2p_set_oppps_cmd_fixed_param));
3498 cmd->vdev_id = oppps->session_id;
3499 if (oppps->ctwindow)
3500 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3501
3502 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303503 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303504 cmd->vdev_id, oppps->ctwindow);
3505 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3506 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303507 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303508 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303509 wmi_buf_free(buf);
3510 }
3511
3512end:
Govind Singhb53420c2016-03-09 14:32:57 +05303513 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303514 return status;
3515}
3516
Wu Gaocd3a8512017-03-13 20:17:34 +08003517#ifdef CONVERGED_P2P_ENABLE
3518/**
3519 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3520 * @wmi_handle: wmi handle
3521 * @param: p2p listen offload start parameters
3522 *
3523 * Return: QDF status
3524 */
3525static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3526 struct p2p_lo_start *param)
3527{
3528 wmi_buf_t buf;
3529 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3530 int32_t len = sizeof(*cmd);
3531 uint8_t *buf_ptr;
3532 QDF_STATUS status;
3533 int device_types_len_aligned;
3534 int probe_resp_len_aligned;
3535
3536 if (!param) {
3537 WMI_LOGE("lo start param is null");
3538 return QDF_STATUS_E_INVAL;
3539 }
3540
3541 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3542
3543 device_types_len_aligned =
3544 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303545 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003546 probe_resp_len_aligned =
3547 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303548 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003549
3550 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3551 probe_resp_len_aligned;
3552
3553 buf = wmi_buf_alloc(wmi_handle, len);
3554 if (!buf) {
3555 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3556 __func__);
3557 return QDF_STATUS_E_NOMEM;
3558 }
3559
3560 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3561 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3562
3563 WMITLV_SET_HDR(&cmd->tlv_header,
3564 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3565 WMITLV_GET_STRUCT_TLVLEN(
3566 wmi_p2p_lo_start_cmd_fixed_param));
3567
3568 cmd->vdev_id = param->vdev_id;
3569 cmd->ctl_flags = param->ctl_flags;
3570 cmd->channel = param->freq;
3571 cmd->period = param->period;
3572 cmd->interval = param->interval;
3573 cmd->count = param->count;
3574 cmd->device_types_len = param->dev_types_len;
3575 cmd->prob_resp_len = param->probe_resp_len;
3576
3577 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3578 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3579 device_types_len_aligned);
3580 buf_ptr += WMI_TLV_HDR_SIZE;
3581 qdf_mem_copy(buf_ptr, param->device_types,
3582 param->dev_types_len);
3583
3584 buf_ptr += device_types_len_aligned;
3585 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3586 probe_resp_len_aligned);
3587 buf_ptr += WMI_TLV_HDR_SIZE;
3588 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3589 param->probe_resp_len);
3590
3591 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3592 cmd->channel, cmd->period, cmd->interval, cmd->count);
3593
3594 status = wmi_unified_cmd_send(wmi_handle,
3595 buf, len,
3596 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3597 if (status != QDF_STATUS_SUCCESS) {
3598 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3599 __func__, status);
3600 wmi_buf_free(buf);
3601 return status;
3602 }
3603
3604 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3605
3606 return QDF_STATUS_SUCCESS;
3607}
3608
3609/**
3610 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3611 * @wmi_handle: wmi handle
3612 * @param: p2p listen offload stop parameters
3613 *
3614 * Return: QDF status
3615 */
3616static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3617 uint8_t vdev_id)
3618{
3619 wmi_buf_t buf;
3620 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3621 int32_t len;
3622 QDF_STATUS status;
3623
3624 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3625
3626 len = sizeof(*cmd);
3627 buf = wmi_buf_alloc(wmi_handle, len);
3628 if (!buf) {
3629 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3630 __func__);
3631 return QDF_STATUS_E_NOMEM;
3632 }
3633 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3634
3635 WMITLV_SET_HDR(&cmd->tlv_header,
3636 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3637 WMITLV_GET_STRUCT_TLVLEN(
3638 wmi_p2p_lo_stop_cmd_fixed_param));
3639
3640 cmd->vdev_id = vdev_id;
3641
3642 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3643
3644 status = wmi_unified_cmd_send(wmi_handle,
3645 buf, len,
3646 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3647 if (status != QDF_STATUS_SUCCESS) {
3648 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3649 __func__, status);
3650 wmi_buf_free(buf);
3651 return status;
3652 }
3653
3654 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3655
3656 return QDF_STATUS_SUCCESS;
3657}
3658#endif /* End of CONVERGED_P2P_ENABLE */
3659
Govind Singh427ee5a2016-02-26 18:09:36 +05303660/**
3661 * send_get_temperature_cmd_tlv() - get pdev temperature req
3662 * @wmi_handle: wmi handle
3663 *
Govind Singhb53420c2016-03-09 14:32:57 +05303664 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303665 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303666static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303667{
3668 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3669 wmi_buf_t wmi_buf;
3670 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3671 uint8_t *buf_ptr;
3672
3673 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303674 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3675 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303676 }
3677
3678 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3679 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303680 WMI_LOGE(FL("wmi_buf_alloc failed"));
3681 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303682 }
3683
3684 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3685
3686 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3687 WMITLV_SET_HDR(&cmd->tlv_header,
3688 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3689 WMITLV_GET_STRUCT_TLVLEN
3690 (wmi_pdev_get_temperature_cmd_fixed_param));
3691
3692 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3693 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303694 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303695 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303696 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303697 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303698
Govind Singhb53420c2016-03-09 14:32:57 +05303699 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303700}
3701
3702/**
3703 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3704 * @wmi_handle: wmi handle
3705 * @vdevid: vdev id
3706 * @peer_addr: peer mac address
3707 * @auto_triggerparam: auto trigger parameters
3708 * @num_ac: number of access category
3709 *
3710 * This function sets the trigger
3711 * uapsd params such as service interval, delay interval
3712 * and suspend interval which will be used by the firmware
3713 * to send trigger frames periodically when there is no
3714 * traffic on the transmit side.
3715 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303716 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303717 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303718static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303719 struct sta_uapsd_trig_params *param)
3720{
3721 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303722 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303723 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3724 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3725 uint32_t i;
3726 wmi_buf_t buf;
3727 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003728 struct sta_uapsd_params *uapsd_param;
3729 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303730
3731 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3732 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303733 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303734 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303735 }
3736
3737 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3738 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3739 WMITLV_SET_HDR(&cmd->tlv_header,
3740 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3741 WMITLV_GET_STRUCT_TLVLEN
3742 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3743 cmd->vdev_id = param->vdevid;
3744 cmd->num_ac = param->num_ac;
3745 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3746
3747 /* TLV indicating array of structures to follow */
3748 buf_ptr += sizeof(*cmd);
3749 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3750
3751 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303752
3753 /*
3754 * Update tag and length for uapsd auto trigger params (this will take
3755 * care of updating tag and length if it is not pre-filled by caller).
3756 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003757 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3758 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303759 for (i = 0; i < param->num_ac; i++) {
3760 WMITLV_SET_HDR((buf_ptr +
3761 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3762 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3763 WMITLV_GET_STRUCT_TLVLEN
3764 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003765 trig_param->wmm_ac = uapsd_param->wmm_ac;
3766 trig_param->user_priority = uapsd_param->user_priority;
3767 trig_param->service_interval = uapsd_param->service_interval;
3768 trig_param->suspend_interval = uapsd_param->suspend_interval;
3769 trig_param->delay_interval = uapsd_param->delay_interval;
3770 trig_param++;
3771 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303772 }
3773
3774 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3775 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303776 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303777 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303778 wmi_buf_free(buf);
3779 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303780
Govind Singh427ee5a2016-02-26 18:09:36 +05303781 return ret;
3782}
3783
Zhang Qian11c0de32018-01-05 16:50:53 +08003784#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303785/**
3786 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3787 * @wmi_handle: pointer to the wmi handle
3788 * @utc: pointer to the UTC time struct
3789 *
3790 * Return: 0 on succes
3791 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303792static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303793 struct ocb_utc_param *utc)
3794{
Govind Singh67922e82016-04-01 16:48:57 +05303795 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303796 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3797 uint8_t *buf_ptr;
3798 uint32_t len, i;
3799 wmi_buf_t buf;
3800
3801 len = sizeof(*cmd);
3802 buf = wmi_buf_alloc(wmi_handle, len);
3803 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303804 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303805 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303806 }
3807
3808 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3809 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3810 WMITLV_SET_HDR(&cmd->tlv_header,
3811 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3812 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3813 cmd->vdev_id = utc->vdev_id;
3814
3815 for (i = 0; i < SIZE_UTC_TIME; i++)
3816 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3817
3818 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3819 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3820
3821 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3822 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303823 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303824 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303825 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303826 }
3827
Govind Singh67922e82016-04-01 16:48:57 +05303828 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303829}
3830
3831/**
3832 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3833 * frames on a channel
3834 * @wmi_handle: pointer to the wmi handle
3835 * @timing_advert: pointer to the timing advertisement struct
3836 *
3837 * Return: 0 on succes
3838 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303839static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303840 struct ocb_timing_advert_param *timing_advert)
3841{
Govind Singh67922e82016-04-01 16:48:57 +05303842 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303843 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3844 uint8_t *buf_ptr;
3845 uint32_t len, len_template;
3846 wmi_buf_t buf;
3847
3848 len = sizeof(*cmd) +
3849 WMI_TLV_HDR_SIZE;
3850
3851 len_template = timing_advert->template_length;
3852 /* Add padding to the template if needed */
3853 if (len_template % 4 != 0)
3854 len_template += 4 - (len_template % 4);
3855 len += len_template;
3856
3857 buf = wmi_buf_alloc(wmi_handle, len);
3858 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303859 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303860 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303861 }
3862
3863 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3864 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3865 WMITLV_SET_HDR(&cmd->tlv_header,
3866 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3867 WMITLV_GET_STRUCT_TLVLEN(
3868 wmi_ocb_start_timing_advert_cmd_fixed_param));
3869 cmd->vdev_id = timing_advert->vdev_id;
3870 cmd->repeat_rate = timing_advert->repeat_rate;
3871 cmd->channel_freq = timing_advert->chan_freq;
3872 cmd->timestamp_offset = timing_advert->timestamp_offset;
3873 cmd->time_value_offset = timing_advert->time_value_offset;
3874 cmd->timing_advert_template_length = timing_advert->template_length;
3875 buf_ptr += sizeof(*cmd);
3876
3877 /* Add the timing advert template */
3878 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3879 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303880 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303881 (uint8_t *)timing_advert->template_value,
3882 timing_advert->template_length);
3883
3884 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3885 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303886 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303887 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303888 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303889 }
3890
Govind Singh67922e82016-04-01 16:48:57 +05303891 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303892}
3893
3894/**
3895 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3896 * on a channel
3897 * @wmi_handle: pointer to the wmi handle
3898 * @timing_advert: pointer to the timing advertisement struct
3899 *
3900 * Return: 0 on succes
3901 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303902static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303903 struct ocb_timing_advert_param *timing_advert)
3904{
Govind Singh67922e82016-04-01 16:48:57 +05303905 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303906 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3907 uint8_t *buf_ptr;
3908 uint32_t len;
3909 wmi_buf_t buf;
3910
3911 len = sizeof(*cmd);
3912 buf = wmi_buf_alloc(wmi_handle, len);
3913 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303914 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303915 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303916 }
3917
3918 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3919 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3920 WMITLV_SET_HDR(&cmd->tlv_header,
3921 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3922 WMITLV_GET_STRUCT_TLVLEN(
3923 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3924 cmd->vdev_id = timing_advert->vdev_id;
3925 cmd->channel_freq = timing_advert->chan_freq;
3926
3927 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3928 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303929 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303930 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303931 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303932 }
3933
Govind Singh67922e82016-04-01 16:48:57 +05303934 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303935}
3936
3937/**
3938 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3939 * @wmi_handle: pointer to the wmi handle
3940 * @request: pointer to the request
3941 *
3942 * Return: 0 on succes
3943 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303944static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303945 uint8_t vdev_id)
3946{
Govind Singhb53420c2016-03-09 14:32:57 +05303947 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303948 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3949 uint8_t *buf_ptr;
3950 wmi_buf_t buf;
3951 int32_t len;
3952
3953 len = sizeof(*cmd);
3954 buf = wmi_buf_alloc(wmi_handle, len);
3955 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303956 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303957 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303958 }
3959 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3960
3961 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303962 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303963 WMITLV_SET_HDR(&cmd->tlv_header,
3964 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3965 WMITLV_GET_STRUCT_TLVLEN(
3966 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3967 cmd->vdev_id = vdev_id;
3968
3969 /* Send the WMI command */
3970 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3971 WMI_OCB_GET_TSF_TIMER_CMDID);
3972 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303973 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303974 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303975 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303976 }
3977
Govind Singh67922e82016-04-01 16:48:57 +05303978 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303979}
3980
3981/**
3982 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3983 * @wmi_handle: pointer to the wmi handle
3984 * @get_stats_param: pointer to the dcc stats
3985 *
3986 * Return: 0 on succes
3987 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303988static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08003989 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05303990{
Govind Singh67922e82016-04-01 16:48:57 +05303991 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303992 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3993 wmi_dcc_channel_stats_request *channel_stats_array;
3994 wmi_buf_t buf;
3995 uint8_t *buf_ptr;
3996 uint32_t len;
3997 uint32_t i;
3998
3999 /* Validate the input */
4000 if (get_stats_param->request_array_len !=
4001 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304002 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304003 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304004 }
4005
4006 /* Allocate memory for the WMI command */
4007 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4008 get_stats_param->request_array_len;
4009
4010 buf = wmi_buf_alloc(wmi_handle, len);
4011 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304012 WMI_LOGE(FL("wmi_buf_alloc failed"));
4013 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304014 }
4015
4016 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304017 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304018
4019 /* Populate the WMI command */
4020 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4021 buf_ptr += sizeof(*cmd);
4022
4023 WMITLV_SET_HDR(&cmd->tlv_header,
4024 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4025 WMITLV_GET_STRUCT_TLVLEN(
4026 wmi_dcc_get_stats_cmd_fixed_param));
4027 cmd->vdev_id = get_stats_param->vdev_id;
4028 cmd->num_channels = get_stats_param->channel_count;
4029
4030 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4031 get_stats_param->request_array_len);
4032 buf_ptr += WMI_TLV_HDR_SIZE;
4033
4034 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304035 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304036 get_stats_param->request_array_len);
4037 for (i = 0; i < cmd->num_channels; i++)
4038 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4039 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4040 WMITLV_GET_STRUCT_TLVLEN(
4041 wmi_dcc_channel_stats_request));
4042
4043 /* Send the WMI command */
4044 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4045 WMI_DCC_GET_STATS_CMDID);
4046
Govind Singh67922e82016-04-01 16:48:57 +05304047 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304048 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304049 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304050 }
4051
Govind Singh67922e82016-04-01 16:48:57 +05304052 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304053}
4054
4055/**
4056 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4057 * @wmi_handle: pointer to the wmi handle
4058 * @vdev_id: vdev id
4059 * @dcc_stats_bitmap: dcc status bitmap
4060 *
4061 * Return: 0 on succes
4062 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304063static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304064 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4065{
Govind Singh67922e82016-04-01 16:48:57 +05304066 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304067 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4068 wmi_buf_t buf;
4069 uint8_t *buf_ptr;
4070 uint32_t len;
4071
4072 /* Allocate memory for the WMI command */
4073 len = sizeof(*cmd);
4074
4075 buf = wmi_buf_alloc(wmi_handle, len);
4076 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304077 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304078 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304079 }
4080
4081 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304082 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304083
4084 /* Populate the WMI command */
4085 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4086
4087 WMITLV_SET_HDR(&cmd->tlv_header,
4088 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4089 WMITLV_GET_STRUCT_TLVLEN(
4090 wmi_dcc_clear_stats_cmd_fixed_param));
4091 cmd->vdev_id = vdev_id;
4092 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4093
4094 /* Send the WMI command */
4095 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4096 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304097 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304098 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304099 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304100 }
4101
Govind Singh67922e82016-04-01 16:48:57 +05304102 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304103}
4104
4105/**
4106 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4107 * @wmi_handle: pointer to the wmi handle
4108 * @update_ndl_param: pointer to the request parameters
4109 *
4110 * Return: 0 on success
4111 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304112static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004113 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304114{
Govind Singhb53420c2016-03-09 14:32:57 +05304115 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304116 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4117 wmi_dcc_ndl_chan *ndl_chan_array;
4118 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4119 uint32_t active_state_count;
4120 wmi_buf_t buf;
4121 uint8_t *buf_ptr;
4122 uint32_t len;
4123 uint32_t i;
4124
4125 /* validate the input */
4126 if (update_ndl_param->dcc_ndl_chan_list_len !=
4127 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304128 WMI_LOGE(FL("Invalid parameter"));
4129 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304130 }
4131 active_state_count = 0;
4132 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4133 for (i = 0; i < update_ndl_param->channel_count; i++)
4134 active_state_count +=
4135 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4136 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4137 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304138 WMI_LOGE(FL("Invalid parameter"));
4139 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304140 }
4141
4142 /* Allocate memory for the WMI command */
4143 len = sizeof(*cmd) +
4144 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4145 WMI_TLV_HDR_SIZE +
4146 update_ndl_param->dcc_ndl_active_state_list_len;
4147
4148 buf = wmi_buf_alloc(wmi_handle, len);
4149 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304150 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304151 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304152 }
4153
4154 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304155 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304156
4157 /* Populate the WMI command */
4158 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4159 buf_ptr += sizeof(*cmd);
4160
4161 WMITLV_SET_HDR(&cmd->tlv_header,
4162 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4163 WMITLV_GET_STRUCT_TLVLEN(
4164 wmi_dcc_update_ndl_cmd_fixed_param));
4165 cmd->vdev_id = update_ndl_param->vdev_id;
4166 cmd->num_channel = update_ndl_param->channel_count;
4167
4168 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4169 update_ndl_param->dcc_ndl_chan_list_len);
4170 buf_ptr += WMI_TLV_HDR_SIZE;
4171
4172 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304173 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304174 update_ndl_param->dcc_ndl_chan_list_len);
4175 for (i = 0; i < cmd->num_channel; i++)
4176 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4177 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4178 WMITLV_GET_STRUCT_TLVLEN(
4179 wmi_dcc_ndl_chan));
4180 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4181
4182 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4183 update_ndl_param->dcc_ndl_active_state_list_len);
4184 buf_ptr += WMI_TLV_HDR_SIZE;
4185
4186 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304187 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304188 update_ndl_param->dcc_ndl_active_state_list,
4189 update_ndl_param->dcc_ndl_active_state_list_len);
4190 for (i = 0; i < active_state_count; i++) {
4191 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4192 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4193 WMITLV_GET_STRUCT_TLVLEN(
4194 wmi_dcc_ndl_active_state_config));
4195 }
4196 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4197
4198 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304199 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304200 WMI_DCC_UPDATE_NDL_CMDID);
4201 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304202 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304203 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304204 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304205 }
4206
Govind Singh67922e82016-04-01 16:48:57 +05304207 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304208}
4209
4210/**
4211 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4212 * @wmi_handle: pointer to the wmi handle
4213 * @config: the OCB configuration
4214 *
4215 * Return: 0 on success
4216 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304217static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004218 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304219{
Govind Singh67922e82016-04-01 16:48:57 +05304220 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304221 wmi_ocb_set_config_cmd_fixed_param *cmd;
4222 wmi_channel *chan;
4223 wmi_ocb_channel *ocb_chan;
4224 wmi_qos_parameter *qos_param;
4225 wmi_dcc_ndl_chan *ndl_chan;
4226 wmi_dcc_ndl_active_state_config *ndl_active_config;
4227 wmi_ocb_schedule_element *sched_elem;
4228 uint8_t *buf_ptr;
4229 wmi_buf_t buf;
4230 int32_t len;
4231 int32_t i, j, active_state_count;
4232
4233 /*
4234 * Validate the dcc_ndl_chan_list_len and count the number of active
4235 * states. Validate dcc_ndl_active_state_list_len.
4236 */
4237 active_state_count = 0;
4238 if (config->dcc_ndl_chan_list_len) {
4239 if (!config->dcc_ndl_chan_list ||
4240 config->dcc_ndl_chan_list_len !=
4241 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304242 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304243 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304244 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304245 }
4246
4247 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4248 i < config->channel_count; ++i, ++ndl_chan)
4249 active_state_count +=
4250 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4251
4252 if (active_state_count) {
4253 if (!config->dcc_ndl_active_state_list ||
4254 config->dcc_ndl_active_state_list_len !=
4255 active_state_count *
4256 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304257 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304258 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304259 }
4260 }
4261 }
4262
4263 len = sizeof(*cmd) +
4264 WMI_TLV_HDR_SIZE + config->channel_count *
4265 sizeof(wmi_channel) +
4266 WMI_TLV_HDR_SIZE + config->channel_count *
4267 sizeof(wmi_ocb_channel) +
4268 WMI_TLV_HDR_SIZE + config->channel_count *
4269 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4270 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4271 WMI_TLV_HDR_SIZE + active_state_count *
4272 sizeof(wmi_dcc_ndl_active_state_config) +
4273 WMI_TLV_HDR_SIZE + config->schedule_size *
4274 sizeof(wmi_ocb_schedule_element);
4275 buf = wmi_buf_alloc(wmi_handle, len);
4276 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304277 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304278 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304279 }
4280
4281 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4282 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4283 WMITLV_SET_HDR(&cmd->tlv_header,
4284 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4285 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004286 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304287 cmd->channel_count = config->channel_count;
4288 cmd->schedule_size = config->schedule_size;
4289 cmd->flags = config->flags;
4290 buf_ptr += sizeof(*cmd);
4291
4292 /* Add the wmi_channel info */
4293 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4294 config->channel_count*sizeof(wmi_channel));
4295 buf_ptr += WMI_TLV_HDR_SIZE;
4296 for (i = 0; i < config->channel_count; i++) {
4297 chan = (wmi_channel *)buf_ptr;
4298 WMITLV_SET_HDR(&chan->tlv_header,
4299 WMITLV_TAG_STRUC_wmi_channel,
4300 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4301 chan->mhz = config->channels[i].chan_freq;
4302 chan->band_center_freq1 = config->channels[i].chan_freq;
4303 chan->band_center_freq2 = 0;
4304 chan->info = 0;
4305
Zhang Qian11c0de32018-01-05 16:50:53 +08004306 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304307 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4308 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4309 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4310 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4311 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4312 config->channels[i].antenna_max);
4313
4314 if (config->channels[i].bandwidth < 10)
4315 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4316 else if (config->channels[i].bandwidth < 20)
4317 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4318 buf_ptr += sizeof(*chan);
4319 }
4320
4321 /* Add the wmi_ocb_channel info */
4322 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4323 config->channel_count*sizeof(wmi_ocb_channel));
4324 buf_ptr += WMI_TLV_HDR_SIZE;
4325 for (i = 0; i < config->channel_count; i++) {
4326 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4327 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4328 WMITLV_TAG_STRUC_wmi_ocb_channel,
4329 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4330 ocb_chan->bandwidth = config->channels[i].bandwidth;
4331 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4332 config->channels[i].mac_address.bytes,
4333 &ocb_chan->mac_address);
4334 buf_ptr += sizeof(*ocb_chan);
4335 }
4336
4337 /* Add the wmi_qos_parameter info */
4338 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4339 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4340 buf_ptr += WMI_TLV_HDR_SIZE;
4341 /* WMI_MAX_NUM_AC parameters for each channel */
4342 for (i = 0; i < config->channel_count; i++) {
4343 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4344 qos_param = (wmi_qos_parameter *)buf_ptr;
4345 WMITLV_SET_HDR(&qos_param->tlv_header,
4346 WMITLV_TAG_STRUC_wmi_qos_parameter,
4347 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4348 qos_param->aifsn =
4349 config->channels[i].qos_params[j].aifsn;
4350 qos_param->cwmin =
4351 config->channels[i].qos_params[j].cwmin;
4352 qos_param->cwmax =
4353 config->channels[i].qos_params[j].cwmax;
4354 buf_ptr += sizeof(*qos_param);
4355 }
4356 }
4357
4358 /* Add the wmi_dcc_ndl_chan (per channel) */
4359 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4360 config->dcc_ndl_chan_list_len);
4361 buf_ptr += WMI_TLV_HDR_SIZE;
4362 if (config->dcc_ndl_chan_list_len) {
4363 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304364 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304365 config->dcc_ndl_chan_list_len);
4366 for (i = 0; i < config->channel_count; i++)
4367 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4368 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4369 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4370 buf_ptr += config->dcc_ndl_chan_list_len;
4371 }
4372
4373 /* Add the wmi_dcc_ndl_active_state_config */
4374 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4375 sizeof(wmi_dcc_ndl_active_state_config));
4376 buf_ptr += WMI_TLV_HDR_SIZE;
4377 if (active_state_count) {
4378 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304379 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304380 config->dcc_ndl_active_state_list,
4381 active_state_count * sizeof(*ndl_active_config));
4382 for (i = 0; i < active_state_count; ++i)
4383 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4384 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4385 WMITLV_GET_STRUCT_TLVLEN(
4386 wmi_dcc_ndl_active_state_config));
4387 buf_ptr += active_state_count *
4388 sizeof(*ndl_active_config);
4389 }
4390
4391 /* Add the wmi_ocb_schedule_element info */
4392 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4393 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4394 buf_ptr += WMI_TLV_HDR_SIZE;
4395 for (i = 0; i < config->schedule_size; i++) {
4396 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4397 WMITLV_SET_HDR(&sched_elem->tlv_header,
4398 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4399 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4400 sched_elem->channel_freq = config->schedule[i].chan_freq;
4401 sched_elem->total_duration = config->schedule[i].total_duration;
4402 sched_elem->guard_interval = config->schedule[i].guard_interval;
4403 buf_ptr += sizeof(*sched_elem);
4404 }
4405
4406
4407 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4408 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304409 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304410 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304411 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304412 }
4413
Govind Singh67922e82016-04-01 16:48:57 +05304414 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304415}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304416
4417/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004418 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4419 * @wmi_handle: wmi handle
4420 * @evt_buf: wmi event buffer
4421 * @status: status buffer
4422 *
4423 * Return: QDF_STATUS_SUCCESS on success
4424 */
4425static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4426 void *evt_buf,
4427 uint32_t *status)
4428{
4429 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4430 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4431
4432 param_tlvs = evt_buf;
4433 fix_param = param_tlvs->fixed_param;
4434
4435 *status = fix_param->status;
4436 return QDF_STATUS_SUCCESS;
4437}
4438
4439/**
4440 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4441 * @wmi_handle: wmi handle
4442 * @evt_buf: wmi event buffer
4443 * @resp: response buffer
4444 *
4445 * Return: QDF_STATUS_SUCCESS on success
4446 */
4447static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4448 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4449{
4450 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4451 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4452
4453 param_tlvs = evt_buf;
4454 fix_param = param_tlvs->fixed_param;
4455 resp->vdev_id = fix_param->vdev_id;
4456 resp->timer_high = fix_param->tsf_timer_high;
4457 resp->timer_low = fix_param->tsf_timer_low;
4458
4459 return QDF_STATUS_SUCCESS;
4460}
4461
4462/**
4463 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4464 * @wmi_handle: wmi handle
4465 * @evt_buf: wmi event buffer
4466 * @resp: response buffer
4467 *
4468 * Return: QDF_STATUS_SUCCESS on success
4469 */
4470static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4471 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4472{
4473 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4474 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4475
4476 param_tlvs = evt_buf;
4477 fix_param = param_tlvs->fixed_param;
4478 resp->vdev_id = fix_param->vdev_id;
4479 resp->status = fix_param->status;
4480 return QDF_STATUS_SUCCESS;
4481}
4482
4483/**
4484 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4485 * @wmi_handle: wmi handle
4486 * @evt_buf: wmi event buffer
4487 * @resp: response buffer
4488 *
4489 * Since length of stats is variable, buffer for DCC stats will be allocated
4490 * in this function. The caller must free the buffer.
4491 *
4492 * Return: QDF_STATUS_SUCCESS on success
4493 */
4494static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4495 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4496{
4497 struct ocb_dcc_get_stats_response *response;
4498 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4499 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4500
4501 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4502 fix_param = param_tlvs->fixed_param;
4503
4504 /* Allocate and populate the response */
4505 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4506 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4507 WMI_LOGE("%s: too many channels:%d", __func__,
4508 fix_param->num_channels);
4509 QDF_ASSERT(0);
4510 *resp = NULL;
4511 return QDF_STATUS_E_INVAL;
4512 }
4513 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4514 sizeof(wmi_dcc_ndl_stats_per_channel));
4515 *resp = response;
4516 if (!response)
4517 return QDF_STATUS_E_NOMEM;
4518
4519 response->vdev_id = fix_param->vdev_id;
4520 response->num_channels = fix_param->num_channels;
4521 response->channel_stats_array_len =
4522 fix_param->num_channels *
4523 sizeof(wmi_dcc_ndl_stats_per_channel);
4524 response->channel_stats_array = ((uint8_t *)response) +
4525 sizeof(*response);
4526 qdf_mem_copy(response->channel_stats_array,
4527 param_tlvs->stats_per_channel_list,
4528 response->channel_stats_array_len);
4529
4530 return QDF_STATUS_SUCCESS;
4531}
4532#endif
4533
4534/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304535 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4536 * @wmi_handle: wmi handle
4537 * @mcc_adaptive_scheduler: enable/disable
4538 *
4539 * This function enable/disable mcc adaptive scheduler in fw.
4540 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -07004541 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304542 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304543static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004544 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4545 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304546{
Govind Singh67922e82016-04-01 16:48:57 +05304547 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304548 wmi_buf_t buf = 0;
4549 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4550 uint16_t len =
4551 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4552
4553 buf = wmi_buf_alloc(wmi_handle, len);
4554 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304555 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4556 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304557 }
4558 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4559 wmi_buf_data(buf);
4560
4561 WMITLV_SET_HDR(&cmd->tlv_header,
4562 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4563 WMITLV_GET_STRUCT_TLVLEN
4564 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4565 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304566 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304567
4568 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4569 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304570 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304571 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304572 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304573 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304574 }
Govind Singh67922e82016-04-01 16:48:57 +05304575
4576 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304577}
4578
4579/**
4580 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4581 * @wmi: wmi handle
4582 * @mcc_channel: mcc channel
4583 * @mcc_channel_time_latency: MCC channel time latency.
4584 *
4585 * Currently used to set time latency for an MCC vdev/adapter using operating
4586 * channel of it and channel number. The info is provided run time using
4587 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4588 *
4589 * Return: CDF status
4590 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304591static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304592 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4593{
Govind Singh67922e82016-04-01 16:48:57 +05304594 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304595 wmi_buf_t buf = 0;
4596 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4597 uint16_t len = 0;
4598 uint8_t *buf_ptr = NULL;
4599 wmi_resmgr_chan_latency chan_latency;
4600 /* Note: we only support MCC time latency for a single channel */
4601 uint32_t num_channels = 1;
4602 uint32_t chan1_freq = mcc_channel_freq;
4603 uint32_t latency_chan1 = mcc_channel_time_latency;
4604
4605
4606 /* If 0ms latency is provided, then FW will set to a default.
4607 * Otherwise, latency must be at least 30ms.
4608 */
4609 if ((latency_chan1 > 0) &&
4610 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304611 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304612 "Minimum is 30ms (or 0 to use default value by "
4613 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304614 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304615 }
4616
4617 /* Set WMI CMD for channel time latency here */
4618 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4619 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4620 num_channels * sizeof(wmi_resmgr_chan_latency);
4621 buf = wmi_buf_alloc(wmi_handle, len);
4622 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304623 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4624 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304625 }
4626 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4627 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4628 wmi_buf_data(buf);
4629 WMITLV_SET_HDR(&cmdTL->tlv_header,
4630 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4631 WMITLV_GET_STRUCT_TLVLEN
4632 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4633 cmdTL->num_chans = num_channels;
4634 /* Update channel time latency information for home channel(s) */
4635 buf_ptr += sizeof(*cmdTL);
4636 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4637 num_channels * sizeof(wmi_resmgr_chan_latency));
4638 buf_ptr += WMI_TLV_HDR_SIZE;
4639 chan_latency.chan_mhz = chan1_freq;
4640 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304641 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304642 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4643 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304644 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304645 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304646 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304647 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304648 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304649 }
Govind Singh67922e82016-04-01 16:48:57 +05304650
4651 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304652}
4653
4654/**
4655 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4656 * @wmi: wmi handle
4657 * @adapter_1_chan_number: adapter 1 channel number
4658 * @adapter_1_quota: adapter 1 quota
4659 * @adapter_2_chan_number: adapter 2 channel number
4660 *
4661 * Return: CDF status
4662 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304663static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304664 uint32_t adapter_1_chan_freq,
4665 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4666{
Govind Singh67922e82016-04-01 16:48:57 +05304667 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304668 wmi_buf_t buf = 0;
4669 uint16_t len = 0;
4670 uint8_t *buf_ptr = NULL;
4671 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4672 wmi_resmgr_chan_time_quota chan_quota;
4673 uint32_t quota_chan1 = adapter_1_quota;
4674 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4675 uint32_t quota_chan2 = 100 - quota_chan1;
4676 /* Note: setting time quota for MCC requires info for 2 channels */
4677 uint32_t num_channels = 2;
4678 uint32_t chan1_freq = adapter_1_chan_freq;
4679 uint32_t chan2_freq = adapter_2_chan_freq;
4680
Govind Singhb53420c2016-03-09 14:32:57 +05304681 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304682 "freq2:%dMHz, Quota2:%dms", __func__,
4683 chan1_freq, quota_chan1, chan2_freq,
4684 quota_chan2);
4685
4686 /*
4687 * Perform sanity check on time quota values provided.
4688 */
4689 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4690 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304691 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304692 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304693 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304694 }
4695 /* Set WMI CMD for channel time quota here */
4696 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4697 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4698 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4699 buf = wmi_buf_alloc(wmi_handle, len);
4700 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304701 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4702 QDF_ASSERT(0);
4703 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304704 }
4705 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4706 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4707 wmi_buf_data(buf);
4708 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4709 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4710 WMITLV_GET_STRUCT_TLVLEN
4711 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4712 cmdTQ->num_chans = num_channels;
4713
4714 /* Update channel time quota information for home channel(s) */
4715 buf_ptr += sizeof(*cmdTQ);
4716 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4717 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4718 buf_ptr += WMI_TLV_HDR_SIZE;
4719 chan_quota.chan_mhz = chan1_freq;
4720 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304721 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304722 /* Construct channel and quota record for the 2nd MCC mode. */
4723 buf_ptr += sizeof(chan_quota);
4724 chan_quota.chan_mhz = chan2_freq;
4725 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304726 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304727
4728 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4729 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304730 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304731 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304732 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304733 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304734 }
Govind Singh67922e82016-04-01 16:48:57 +05304735
4736 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304737}
4738
4739/**
4740 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4741 * @wmi_handle: Pointer to wmi handle
4742 * @thermal_info: Thermal command information
4743 *
4744 * This function sends the thermal management command
4745 * to the firmware
4746 *
Govind Singhb53420c2016-03-09 14:32:57 +05304747 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304748 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304749static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304750 struct thermal_cmd_params *thermal_info)
4751{
4752 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4753 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304754 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304755 uint32_t len = 0;
4756
4757 len = sizeof(*cmd);
4758
4759 buf = wmi_buf_alloc(wmi_handle, len);
4760 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304761 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4762 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304763 }
4764
4765 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4766
4767 WMITLV_SET_HDR(&cmd->tlv_header,
4768 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4769 WMITLV_GET_STRUCT_TLVLEN
4770 (wmi_thermal_mgmt_cmd_fixed_param));
4771
4772 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4773 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4774 cmd->enable = thermal_info->thermal_enable;
4775
Govind Singhb53420c2016-03-09 14:32:57 +05304776 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304777 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4778
4779 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4780 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304781 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304782 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304783 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304784 }
4785
Govind Singh67922e82016-04-01 16:48:57 +05304786 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304787}
4788
4789
4790/**
4791 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304792 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304793 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4794 *
4795 * This function sends down the LRO configuration parameters to
4796 * the firmware to enable LRO, sets the TCP flags and sets the
4797 * seed values for the toeplitz hash generation
4798 *
Govind Singhb53420c2016-03-09 14:32:57 +05304799 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304800 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304801static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304802 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4803{
4804 wmi_lro_info_cmd_fixed_param *cmd;
4805 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304806 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304807
4808
4809 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4810 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304811 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4812 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304813 }
4814
4815 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4816
4817 WMITLV_SET_HDR(&cmd->tlv_header,
4818 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4819 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4820
4821 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4822 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4823 wmi_lro_cmd->tcp_flag);
4824 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4825 wmi_lro_cmd->tcp_flag_mask);
4826 cmd->toeplitz_hash_ipv4_0_3 =
4827 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4828 cmd->toeplitz_hash_ipv4_4_7 =
4829 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4830 cmd->toeplitz_hash_ipv4_8_11 =
4831 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4832 cmd->toeplitz_hash_ipv4_12_15 =
4833 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4834 cmd->toeplitz_hash_ipv4_16 =
4835 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4836
4837 cmd->toeplitz_hash_ipv6_0_3 =
4838 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4839 cmd->toeplitz_hash_ipv6_4_7 =
4840 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4841 cmd->toeplitz_hash_ipv6_8_11 =
4842 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4843 cmd->toeplitz_hash_ipv6_12_15 =
4844 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4845 cmd->toeplitz_hash_ipv6_16_19 =
4846 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4847 cmd->toeplitz_hash_ipv6_20_23 =
4848 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4849 cmd->toeplitz_hash_ipv6_24_27 =
4850 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4851 cmd->toeplitz_hash_ipv6_28_31 =
4852 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4853 cmd->toeplitz_hash_ipv6_32_35 =
4854 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4855 cmd->toeplitz_hash_ipv6_36_39 =
4856 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4857 cmd->toeplitz_hash_ipv6_40 =
4858 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4859
Govind Singhb53420c2016-03-09 14:32:57 +05304860 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304861 cmd->lro_enable, cmd->tcp_flag_u32);
4862
4863 status = wmi_unified_cmd_send(wmi_handle, buf,
4864 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304865 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304866 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304867 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304868 }
4869
Govind Singh67922e82016-04-01 16:48:57 +05304870 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304871}
4872
Govind Singh4eacd2b2016-03-07 14:24:22 +05304873/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304874 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4875 * @wmi_handle: Pointer to wmi handle
4876 * @rate_report_params: Pointer to peer rate report parameters
4877 *
4878 *
4879 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4880 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304881static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304882 struct wmi_peer_rate_report_params *rate_report_params)
4883{
4884 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4885 wmi_buf_t buf = NULL;
4886 QDF_STATUS status = 0;
4887 uint32_t len = 0;
4888 uint32_t i, j;
4889
4890 len = sizeof(*cmd);
4891
4892 buf = wmi_buf_alloc(wmi_handle, len);
4893 if (!buf) {
4894 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4895 return QDF_STATUS_E_FAILURE;
4896 }
4897
4898 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4899 wmi_buf_data(buf);
4900
4901 WMITLV_SET_HDR(
4902 &cmd->tlv_header,
4903 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4904 WMITLV_GET_STRUCT_TLVLEN(
4905 wmi_peer_set_rate_report_condition_fixed_param));
4906
4907 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4908 cmd->report_backoff_time = rate_report_params->backoff_time;
4909 cmd->report_timer_period = rate_report_params->timer_period;
4910 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4911 cmd->cond_per_phy[i].val_cond_flags =
4912 rate_report_params->report_per_phy[i].cond_flags;
4913 cmd->cond_per_phy[i].rate_delta.min_delta =
4914 rate_report_params->report_per_phy[i].delta.delta_min;
4915 cmd->cond_per_phy[i].rate_delta.percentage =
4916 rate_report_params->report_per_phy[i].delta.percent;
4917 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4918 cmd->cond_per_phy[i].rate_threshold[j] =
4919 rate_report_params->report_per_phy[i].
4920 report_rate_threshold[j];
4921 }
4922 }
4923
4924 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4925 cmd->enable_rate_report,
4926 cmd->report_backoff_time, cmd->report_timer_period);
4927
4928 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4929 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4930 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304931 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304932 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4933 __func__);
4934 }
4935 return status;
4936}
4937
4938/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304939 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4940 * @wmi_handle: wmi handle
4941 * @param: bcn ll cmd parameter
4942 *
Govind Singhb53420c2016-03-09 14:32:57 +05304943 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304944 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304945static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304946 wmi_bcn_send_from_host_cmd_fixed_param *param)
4947{
4948 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4949 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304950 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304951
4952 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4953 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304954 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4955 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304956 }
4957
4958 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4959 WMITLV_SET_HDR(&cmd->tlv_header,
4960 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4961 WMITLV_GET_STRUCT_TLVLEN
4962 (wmi_bcn_send_from_host_cmd_fixed_param));
4963 cmd->vdev_id = param->vdev_id;
4964 cmd->data_len = param->data_len;
4965 cmd->frame_ctrl = param->frame_ctrl;
4966 cmd->frag_ptr = param->frag_ptr;
4967 cmd->dtim_flag = param->dtim_flag;
4968
4969 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4970 WMI_PDEV_SEND_BCN_CMDID);
4971
Govind Singh67922e82016-04-01 16:48:57 +05304972 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304973 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304974 wmi_buf_free(wmi_buf);
4975 }
4976
4977 return ret;
4978}
4979
4980/**
4981 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4982 * @wmi_handle: wmi handle
4983 * @vdev_id: vdev id
4984 * @max_retries: max retries
4985 * @retry_interval: retry interval
4986 * This function sets sta query related parameters in fw.
4987 *
Govind Singhb53420c2016-03-09 14:32:57 +05304988 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304989 */
4990
Sathish Kumarfd347372017-02-13 12:29:09 +05304991static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304992 uint8_t vdev_id, uint32_t max_retries,
4993 uint32_t retry_interval)
4994{
4995 wmi_buf_t buf;
4996 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4997 int len;
4998
4999 len = sizeof(*cmd);
5000 buf = wmi_buf_alloc(wmi_handle, len);
5001 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305002 WMI_LOGE(FL("wmi_buf_alloc failed"));
5003 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305004 }
5005
5006 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5007 WMITLV_SET_HDR(&cmd->tlv_header,
5008 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5009 WMITLV_GET_STRUCT_TLVLEN
5010 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5011
5012
5013 cmd->vdev_id = vdev_id;
5014 cmd->sa_query_max_retry_count = max_retries;
5015 cmd->sa_query_retry_interval = retry_interval;
5016
Govind Singhb53420c2016-03-09 14:32:57 +05305017 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305018 vdev_id, retry_interval, max_retries);
5019
5020 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5021 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305022 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305023 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305024 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305025 }
5026
Govind Singhb53420c2016-03-09 14:32:57 +05305027 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305028 return 0;
5029}
5030
5031/**
5032 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5033 * @wmi_handle: wmi handle
5034 * @params: sta keep alive parameter
5035 *
5036 * This function sets keep alive related parameters in fw.
5037 *
5038 * Return: CDF status
5039 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305040static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305041 struct sta_params *params)
5042{
5043 wmi_buf_t buf;
5044 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5045 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5046 uint8_t *buf_ptr;
5047 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305048 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305049
Govind Singhb53420c2016-03-09 14:32:57 +05305050 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305051
Govind Singh4eacd2b2016-03-07 14:24:22 +05305052 len = sizeof(*cmd) + sizeof(*arp_rsp);
5053 buf = wmi_buf_alloc(wmi_handle, len);
5054 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305055 WMI_LOGE("wmi_buf_alloc failed");
5056 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305057 }
5058
5059 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5060 buf_ptr = (uint8_t *) cmd;
5061 WMITLV_SET_HDR(&cmd->tlv_header,
5062 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5063 WMITLV_GET_STRUCT_TLVLEN
5064 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5065 cmd->interval = params->timeperiod;
5066 cmd->enable = (params->timeperiod) ? 1 : 0;
5067 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305068 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305069 params->timeperiod, params->method);
5070 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5071 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5072 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5073 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5074
c_manjee2772b9c2017-01-23 15:14:13 +05305075 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5076 (params->method ==
5077 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305078 if ((NULL == params->hostv4addr) ||
5079 (NULL == params->destv4addr) ||
5080 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005081 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5082 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305083 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305084 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305085 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305086 }
c_manjee2772b9c2017-01-23 15:14:13 +05305087 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305088 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305089 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305090 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305091 WMI_IPV4_ADDR_LEN);
5092 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5093 } else {
5094 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5095 }
5096
Govind Singh67922e82016-04-01 16:48:57 +05305097 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5098 WMI_STA_KEEPALIVE_CMDID);
5099 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305100 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305101 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305102 }
5103
Govind Singhb53420c2016-03-09 14:32:57 +05305104 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305105 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305106}
5107
5108/**
5109 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5110 * @wmi_handle: wmi handle
5111 * @if_id: vdev id
5112 * @gtx_info: GTX config params
5113 *
5114 * This function set GTX related params in firmware.
5115 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305116 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305117 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305118static 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 +05305119 struct wmi_gtx_config *gtx_info)
5120{
5121 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5122 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305123 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305124 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305125
Govind Singh4eacd2b2016-03-07 14:24:22 +05305126 buf = wmi_buf_alloc(wmi_handle, len);
5127 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305128 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305129 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305130 }
5131 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5132 WMITLV_SET_HDR(&cmd->tlv_header,
5133 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5134 WMITLV_GET_STRUCT_TLVLEN
5135 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5136 cmd->vdev_id = if_id;
5137
5138 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5139 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5140 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5141 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5142 cmd->gtxPERMargin = gtx_info->gtx_margin;
5143 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5144 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5145 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5146
Govind Singhb53420c2016-03-09 14:32:57 +05305147 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305148 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5149 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5150 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5151 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5152
Abhishek Singh716c46c2016-05-04 16:24:07 +05305153 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305154 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305155 if (QDF_IS_STATUS_ERROR(ret)) {
5156 WMI_LOGE("Failed to set GTX PARAMS");
5157 wmi_buf_free(buf);
5158 }
5159 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305160}
5161
5162/**
5163 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5164 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305165 * @vdev_id: vdev id.
5166 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305167 *
5168 * This function updates EDCA parameters to the target
5169 *
5170 * Return: CDF Status
5171 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305172static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005173 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305174 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305175{
5176 uint8_t *buf_ptr;
5177 wmi_buf_t buf;
5178 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305179 wmi_wmm_vparams *wmm_param;
5180 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305181 int len = sizeof(*cmd);
5182 int ac;
5183
5184 buf = wmi_buf_alloc(wmi_handle, len);
5185
5186 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305187 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5188 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305189 }
5190
5191 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5192 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5193 WMITLV_SET_HDR(&cmd->tlv_header,
5194 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5195 WMITLV_GET_STRUCT_TLVLEN
5196 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5197 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005198 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305199
5200 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5201 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305202 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305203 WMITLV_SET_HDR(&wmm_param->tlv_header,
5204 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5205 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5206 wmm_param->cwmin = twmm_param->cwmin;
5207 wmm_param->cwmax = twmm_param->cwmax;
5208 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005209 if (mu_edca_param)
5210 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5211 else
5212 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305213 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305214 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305215 }
5216
5217 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5218 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5219 goto fail;
5220
Govind Singhb53420c2016-03-09 14:32:57 +05305221 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305222
5223fail:
5224 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305225 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5226 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305227}
5228
5229/**
5230 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5231 * @wmi_handle: wmi handle
5232 * @vdev_id: vdev id
5233 * @probe_rsp_info: probe response info
5234 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305235 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305236 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305237static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305238 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005239 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305240{
5241 wmi_prb_tmpl_cmd_fixed_param *cmd;
5242 wmi_bcn_prb_info *bcn_prb_info;
5243 wmi_buf_t wmi_buf;
5244 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5245 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305246 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305247
Govind Singhb53420c2016-03-09 14:32:57 +05305248 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305249
Krunal Soni89426862017-11-14 15:42:48 -08005250 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305251 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305252
5253 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5254 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5255 tmpl_len_aligned;
5256
5257 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305258 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305259 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305260 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305261 }
5262
5263 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5264 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305265 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305266 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305267 }
5268
5269 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5270
5271 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5272 WMITLV_SET_HDR(&cmd->tlv_header,
5273 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5274 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5275 cmd->vdev_id = vdev_id;
5276 cmd->buf_len = tmpl_len;
5277 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5278
5279 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5280 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5281 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5282 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5283 bcn_prb_info->caps = 0;
5284 bcn_prb_info->erp = 0;
5285 buf_ptr += sizeof(wmi_bcn_prb_info);
5286
5287 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5288 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005289 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305290
5291 ret = wmi_unified_cmd_send(wmi_handle,
5292 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305293 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305294 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305295 wmi_buf_free(wmi_buf);
5296 }
5297
5298 return ret;
5299}
5300
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305301#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305302#define WPI_IV_LEN 16
5303
5304/**
5305 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5306 *
5307 * @dest_tx: destination address of tsc key counter
5308 * @src_tx: source address of tsc key counter
5309 * @dest_rx: destination address of rsc key counter
5310 * @src_rx: source address of rsc key counter
5311 *
5312 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5313 *
5314 * Return: None
5315 *
5316 */
5317static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5318 uint8_t *dest_rx, uint8_t *src_rx)
5319{
5320 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5321 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5322}
5323#else
5324static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5325 uint8_t *dest_rx, uint8_t *src_rx)
5326{
5327 return;
5328}
5329#endif
5330
5331/**
5332 * send_setup_install_key_cmd_tlv() - set key parameters
5333 * @wmi_handle: wmi handle
5334 * @key_params: key parameters
5335 *
5336 * This function fills structure from information
5337 * passed in key_params.
5338 *
5339 * Return: QDF_STATUS_SUCCESS - success
5340 * QDF_STATUS_E_FAILURE - failure
5341 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5342 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305343static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305344 struct set_key_params *key_params)
5345{
5346 wmi_vdev_install_key_cmd_fixed_param *cmd;
5347 wmi_buf_t buf;
5348 uint8_t *buf_ptr;
5349 uint32_t len;
5350 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305351 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305352
5353 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5354 WMI_TLV_HDR_SIZE;
5355
5356 buf = wmi_buf_alloc(wmi_handle, len);
5357 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305358 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305359 return QDF_STATUS_E_NOMEM;
5360 }
5361
5362 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5363 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5364 WMITLV_SET_HDR(&cmd->tlv_header,
5365 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5366 WMITLV_GET_STRUCT_TLVLEN
5367 (wmi_vdev_install_key_cmd_fixed_param));
5368 cmd->vdev_id = key_params->vdev_id;
5369 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305370
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305371
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305372 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5373 cmd->key_flags |= key_params->key_flags;
5374 cmd->key_cipher = key_params->key_cipher;
5375 if ((key_params->key_txmic_len) &&
5376 (key_params->key_rxmic_len)) {
5377 cmd->key_txmic_len = key_params->key_txmic_len;
5378 cmd->key_rxmic_len = key_params->key_rxmic_len;
5379 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305380#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305381 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5382 key_params->tx_iv,
5383 cmd->wpi_key_rsc_counter,
5384 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305385#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305386 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5387 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5388 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305389 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305390 qdf_mem_copy((void *)key_data,
5391 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005392 if (key_params->key_rsc_counter)
5393 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5394 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305395 cmd->key_len = key_params->key_len;
5396
5397 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5398 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305399 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305400 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305401
Govind Singh67922e82016-04-01 16:48:57 +05305402 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305403}
5404
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305405/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005406 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5407 * @wmi_handle: wmi handle
5408 * @params: sar limit params
5409 *
5410 * Return: QDF_STATUS_SUCCESS for success or error code
5411 */
5412static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5413 struct sar_limit_cmd_params *sar_limit_params)
5414{
5415 wmi_buf_t buf;
5416 QDF_STATUS qdf_status;
5417 wmi_sar_limits_cmd_fixed_param *cmd;
5418 int i;
5419 uint8_t *buf_ptr;
5420 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5421 struct sar_limit_cmd_row *sar_rows_list;
5422 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5423
5424 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5425 buf = wmi_buf_alloc(wmi_handle, len);
5426 if (!buf) {
5427 WMI_LOGE("Failed to allocate memory");
5428 qdf_status = QDF_STATUS_E_NOMEM;
5429 goto end;
5430 }
5431
5432 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5433 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5434 WMITLV_SET_HDR(&cmd->tlv_header,
5435 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5436 WMITLV_GET_STRUCT_TLVLEN
5437 (wmi_sar_limits_cmd_fixed_param));
5438 cmd->sar_enable = sar_limit_params->sar_enable;
5439 cmd->commit_limits = sar_limit_params->commit_limits;
5440 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5441
5442 WMI_LOGD("no of sar rows = %d, len = %d",
5443 sar_limit_params->num_limit_rows, len);
5444 buf_ptr += sizeof(*cmd);
5445 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5446 sizeof(wmi_sar_limit_cmd_row) *
5447 sar_limit_params->num_limit_rows);
5448 if (cmd->num_limit_rows == 0)
5449 goto send_sar_limits;
5450
5451 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5452 (buf_ptr + WMI_TLV_HDR_SIZE);
5453 sar_rows_list = sar_limit_params->sar_limit_row_list;
5454
5455 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5456 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5457 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5458 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5459 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5460 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5461 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5462 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5463 wmi_sar_rows_list->validity_bitmap =
5464 sar_rows_list->validity_bitmap;
5465 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5466 i, wmi_sar_rows_list->band_id,
5467 wmi_sar_rows_list->chain_id,
5468 wmi_sar_rows_list->mod_id,
5469 wmi_sar_rows_list->limit_value,
5470 wmi_sar_rows_list->validity_bitmap);
5471 sar_rows_list++;
5472 wmi_sar_rows_list++;
5473 }
5474send_sar_limits:
5475 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5476 WMI_SAR_LIMITS_CMDID);
5477
5478 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5479 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5480 wmi_buf_free(buf);
5481 }
5482
5483end:
5484 return qdf_status;
5485}
5486
Jeff Johnson4783f902017-12-14 15:50:16 -08005487static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5488{
5489 wmi_sar_get_limits_cmd_fixed_param *cmd;
5490 wmi_buf_t wmi_buf;
5491 uint32_t len;
5492 QDF_STATUS status;
5493
5494 WMI_LOGD(FL("Enter"));
5495
5496 len = sizeof(*cmd);
5497 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5498 if (!wmi_buf) {
5499 WMI_LOGP(FL("failed to allocate memory for msg"));
5500 return QDF_STATUS_E_NOMEM;
5501 }
5502
5503 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5504
5505 WMITLV_SET_HDR(&cmd->tlv_header,
5506 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5507 WMITLV_GET_STRUCT_TLVLEN
5508 (wmi_sar_get_limits_cmd_fixed_param));
5509
5510 cmd->reserved = 0;
5511
5512 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5513 WMI_SAR_GET_LIMITS_CMDID);
5514 if (QDF_IS_STATUS_ERROR(status)) {
5515 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5516 wmi_buf_free(wmi_buf);
5517 }
5518
5519 WMI_LOGD(FL("Exit"));
5520
5521 return status;
5522}
5523
5524static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5525 uint8_t *evt_buf,
5526 struct sar_limit_event *event)
5527{
5528 wmi_sar_get_limits_event_fixed_param *fixed_param;
5529 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5530 wmi_sar_get_limit_event_row *row_in;
5531 struct sar_limit_event_row *row_out;
5532 uint32_t row;
5533
5534 if (!evt_buf) {
5535 WMI_LOGE(FL("input event is NULL"));
5536 return QDF_STATUS_E_INVAL;
5537 }
5538 if (!event) {
5539 WMI_LOGE(FL("output event is NULL"));
5540 return QDF_STATUS_E_INVAL;
5541 }
5542
5543 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5544
5545 fixed_param = param_buf->fixed_param;
5546 if (!fixed_param) {
5547 WMI_LOGE(FL("Invalid fixed param"));
5548 return QDF_STATUS_E_INVAL;
5549 }
5550
5551 event->sar_enable = fixed_param->sar_enable;
5552 event->num_limit_rows = fixed_param->num_limit_rows;
5553
5554 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5555 QDF_ASSERT(0);
5556 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5557 event->num_limit_rows,
5558 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5559 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5560 }
5561
5562 row_in = param_buf->sar_get_limits;
5563 row_out = &event->sar_limit_row[0];
5564 for (row = 0; row < event->num_limit_rows; row++) {
5565 row_out->band_id = row_in->band_id;
5566 row_out->chain_id = row_in->chain_id;
5567 row_out->mod_id = row_in->mod_id;
5568 row_out->limit_value = row_in->limit_value;
5569 row_out++;
5570 row_in++;
5571 }
5572
5573 return QDF_STATUS_SUCCESS;
5574}
5575
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305576#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005577/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305578 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5579 * @wmi_handle: wmi handle
5580 * @params: encrypt/decrypt params
5581 *
5582 * Return: QDF_STATUS_SUCCESS for success or error code
5583 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005584static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305585QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305586 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305587{
5588 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5589 wmi_buf_t wmi_buf;
5590 uint8_t *buf_ptr;
5591 QDF_STATUS ret;
5592 uint32_t len;
5593
5594 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5595
5596 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305597 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305598 WMI_TLV_HDR_SIZE;
5599 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5600 if (!wmi_buf) {
5601 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5602 __func__);
5603 return QDF_STATUS_E_NOMEM;
5604 }
5605
5606 buf_ptr = wmi_buf_data(wmi_buf);
5607 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5608
5609 WMITLV_SET_HDR(&cmd->tlv_header,
5610 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5611 WMITLV_GET_STRUCT_TLVLEN(
5612 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5613
5614 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5615 cmd->key_flag = encrypt_decrypt_params->key_flag;
5616 cmd->key_idx = encrypt_decrypt_params->key_idx;
5617 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5618 cmd->key_len = encrypt_decrypt_params->key_len;
5619 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5620 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5621
5622 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5623 encrypt_decrypt_params->key_len);
5624
5625 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5626 MAX_MAC_HEADER_LEN);
5627
5628 cmd->data_len = encrypt_decrypt_params->data_len;
5629
5630 if (cmd->data_len) {
5631 buf_ptr += sizeof(*cmd);
5632 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5633 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305634 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305635 buf_ptr += WMI_TLV_HDR_SIZE;
5636 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5637 encrypt_decrypt_params->data_len);
5638 }
5639
5640 /* This conversion is to facilitate data to FW in little endian */
5641 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5642 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5643 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5644 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5645 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5646 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5647
5648 ret = wmi_unified_cmd_send(wmi_handle,
5649 wmi_buf, len,
5650 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5651 if (QDF_IS_STATUS_ERROR(ret)) {
5652 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5653 wmi_buf_free(wmi_buf);
5654 }
5655
5656 return ret;
5657}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305658
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305659/**
5660 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5661 * params from event
5662 * @wmi_handle: wmi handle
5663 * @evt_buf: pointer to event buffer
5664 * @resp: Pointer to hold resp parameters
5665 *
5666 * Return: QDF_STATUS_SUCCESS for success or error code
5667 */
5668static
5669QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5670 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5671{
5672 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5673 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5674
5675 param_buf = evt_buf;
5676 if (!param_buf) {
5677 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5678 return QDF_STATUS_E_INVAL;
5679 }
5680
5681 data_event = param_buf->fixed_param;
5682
5683 resp->vdev_id = data_event->vdev_id;
5684 resp->status = data_event->status;
5685
5686 if (data_event->data_length > param_buf->num_enc80211_frame) {
5687 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5688 data_event->data_length,
5689 param_buf->num_enc80211_frame);
5690 return QDF_STATUS_E_INVAL;
5691 }
5692
5693 resp->data_len = data_event->data_length;
5694
5695 if (resp->data_len)
5696 resp->data = (uint8_t *)param_buf->enc80211_frame;
5697
5698 return QDF_STATUS_SUCCESS;
5699}
5700#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305701
Govind Singh4eacd2b2016-03-07 14:24:22 +05305702/**
5703 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5704 * @wmi_handle: wmi handle
5705 * @vdev_id: vdev id
5706 * @p2p_ie: p2p IE
5707 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305708 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305709 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305710static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05305711 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305712{
Govind Singh67922e82016-04-01 16:48:57 +05305713 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305714 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5715 wmi_buf_t wmi_buf;
5716 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5717 uint8_t *buf_ptr;
5718
5719 ie_len = (uint32_t) (p2p_ie[1] + 2);
5720
5721 /* More than one P2P IE may be included in a single frame.
5722 If multiple P2P IEs are present, the complete P2P attribute
5723 data consists of the concatenation of the P2P Attribute
5724 fields of the P2P IEs. The P2P Attributes field of each
5725 P2P IE may be any length up to the maximum (251 octets).
5726 In this case host sends one P2P IE to firmware so the length
5727 should not exceed more than 251 bytes
5728 */
5729 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305730 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305731 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305732 }
5733
Vivekc5823092018-03-22 23:27:21 +05305734 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305735
5736 wmi_buf_len =
5737 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5738 WMI_TLV_HDR_SIZE;
5739
5740 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5741 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305742 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305743 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305744 }
5745
5746 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5747
5748 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5749 WMITLV_SET_HDR(&cmd->tlv_header,
5750 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5751 WMITLV_GET_STRUCT_TLVLEN
5752 (wmi_p2p_go_set_beacon_ie_fixed_param));
5753 cmd->vdev_id = vdev_id;
5754 cmd->ie_buf_len = ie_len;
5755
5756 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5757 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5758 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305759 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305760
Govind Singhb53420c2016-03-09 14:32:57 +05305761 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305762
5763 ret = wmi_unified_cmd_send(wmi_handle,
5764 wmi_buf, wmi_buf_len,
5765 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305766 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305767 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305768 wmi_buf_free(wmi_buf);
5769 }
5770
Govind Singhb53420c2016-03-09 14:32:57 +05305771 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305772 return ret;
5773}
5774
5775/**
5776 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5777 * @wmi_handle: wmi handle
5778 * @req: gateway parameter update request structure
5779 *
5780 * This function reads the incoming @req and fill in the destination
5781 * WMI structure and sends down the gateway configs down to the firmware
5782 *
Govind Singhb53420c2016-03-09 14:32:57 +05305783 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305784 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305785static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305786 struct gateway_update_req_param *req)
5787{
5788 wmi_roam_subnet_change_config_fixed_param *cmd;
5789 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305790 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305791 int len = sizeof(*cmd);
5792
5793 buf = wmi_buf_alloc(wmi_handle, len);
5794 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305795 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5796 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305797 }
5798
5799 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5800 WMITLV_SET_HDR(&cmd->tlv_header,
5801 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5802 WMITLV_GET_STRUCT_TLVLEN(
5803 wmi_roam_subnet_change_config_fixed_param));
5804
5805 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305806 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5807 QDF_IPV4_ADDR_SIZE);
5808 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5809 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305810 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5811 &cmd->inet_gw_mac_addr);
5812 cmd->max_retries = req->max_retries;
5813 cmd->timeout = req->timeout;
5814 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5815 cmd->flag = 0;
5816 if (req->ipv4_addr_type)
5817 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5818
5819 if (req->ipv6_addr_type)
5820 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5821
5822 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5823 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305824 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305825 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305826 ret);
5827 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305828 }
5829
Govind Singh67922e82016-04-01 16:48:57 +05305830 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305831}
5832
5833/**
5834 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5835 * @wmi_handle: wmi handle
5836 * @req: rssi monitoring request structure
5837 *
5838 * This function reads the incoming @req and fill in the destination
5839 * WMI structure and send down the rssi monitoring configs down to the firmware
5840 *
5841 * Return: 0 on success; error number otherwise
5842 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305843static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305844 struct rssi_monitor_param *req)
5845{
5846 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5847 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305848 QDF_STATUS ret;
5849 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305850
5851 buf = wmi_buf_alloc(wmi_handle, len);
5852 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305853 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5854 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305855 }
5856
5857 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5858 WMITLV_SET_HDR(&cmd->tlv_header,
5859 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5860 WMITLV_GET_STRUCT_TLVLEN(
5861 wmi_rssi_breach_monitor_config_fixed_param));
5862
5863 cmd->vdev_id = req->session_id;
5864 cmd->request_id = req->request_id;
5865 cmd->lo_rssi_reenable_hysteresis = 0;
5866 cmd->hi_rssi_reenable_histeresis = 0;
5867 cmd->min_report_interval = 0;
5868 cmd->max_num_report = 1;
5869 if (req->control) {
5870 /* enable one threshold for each min/max */
5871 cmd->enabled_bitmap = 0x09;
5872 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5873 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5874 } else {
5875 cmd->enabled_bitmap = 0;
5876 cmd->low_rssi_breach_threshold[0] = 0;
5877 cmd->hi_rssi_breach_threshold[0] = 0;
5878 }
5879
5880 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5881 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305882 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305883 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305884 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305885 }
5886
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005887 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5888
Govind Singh67922e82016-04-01 16:48:57 +05305889 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305890}
5891
5892/**
5893 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5894 * @wmi_handle: wmi handle
5895 * @psetoui: OUI parameters
5896 *
5897 * set scan probe OUI parameters in firmware
5898 *
5899 * Return: CDF status
5900 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305901static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305902 struct scan_mac_oui *psetoui)
5903{
5904 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5905 wmi_buf_t wmi_buf;
5906 uint32_t len;
5907 uint8_t *buf_ptr;
5908 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305909 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305910
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305911 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5912 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5913
Govind Singh4eacd2b2016-03-07 14:24:22 +05305914 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5915 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305916 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5917 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305918 }
5919 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5920 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5921 WMITLV_SET_HDR(&cmd->tlv_header,
5922 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5923 WMITLV_GET_STRUCT_TLVLEN
5924 (wmi_scan_prob_req_oui_cmd_fixed_param));
5925
5926 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305927 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305928 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5929 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305930 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305931 cmd->prob_req_oui);
5932
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305933 cmd->vdev_id = psetoui->vdev_id;
5934 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5935 if (psetoui->enb_probe_req_sno_randomization)
5936 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5937
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305938 if (ie_whitelist->white_list) {
5939 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5940 &cmd->num_vendor_oui,
5941 ie_whitelist);
5942 cmd->flags |=
5943 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5944 }
5945
5946 buf_ptr += sizeof(*cmd);
5947 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5948 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5949 buf_ptr += WMI_TLV_HDR_SIZE;
5950
5951 if (cmd->num_vendor_oui != 0) {
5952 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5953 ie_whitelist->voui);
5954 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5955 }
5956
Govind Singh4eacd2b2016-03-07 14:24:22 +05305957 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5958 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305959 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305960 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305961 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305962 }
Govind Singhb53420c2016-03-09 14:32:57 +05305963 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305964}
5965
5966/**
5967 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5968 * @wmi_handle: wmi handle
5969 * @req: passpoint network request structure
5970 *
5971 * This function sends down WMI command with network id set to wildcard id.
5972 * firmware shall clear all the config entries
5973 *
Govind Singhb53420c2016-03-09 14:32:57 +05305974 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305975 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305976static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305977 struct wifi_passpoint_req_param *req)
5978{
5979 wmi_passpoint_config_cmd_fixed_param *cmd;
5980 wmi_buf_t buf;
5981 uint32_t len;
5982 int ret;
5983
5984 len = sizeof(*cmd);
5985 buf = wmi_buf_alloc(wmi_handle, len);
5986 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305987 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5988 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305989 }
5990
5991 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5992
5993 WMITLV_SET_HDR(&cmd->tlv_header,
5994 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5995 WMITLV_GET_STRUCT_TLVLEN(
5996 wmi_passpoint_config_cmd_fixed_param));
5997 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5998
5999 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6000 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6001 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306002 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306003 __func__);
6004 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306005 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306006 }
6007
Govind Singhb53420c2016-03-09 14:32:57 +05306008 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306009}
6010
6011/**
6012 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
6013 * @wmi_handle: wmi handle
6014 * @req: passpoint network request structure
6015 *
6016 * This function reads the incoming @req and fill in the destination
6017 * WMI structure and send down the passpoint configs down to the firmware
6018 *
Govind Singhb53420c2016-03-09 14:32:57 +05306019 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05306020 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306021static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306022 struct wifi_passpoint_req_param *req)
6023{
6024 wmi_passpoint_config_cmd_fixed_param *cmd;
6025 u_int8_t i, j, *bytes;
6026 wmi_buf_t buf;
6027 uint32_t len;
6028 int ret;
6029
6030 len = sizeof(*cmd);
6031 for (i = 0; i < req->num_networks; i++) {
6032 buf = wmi_buf_alloc(wmi_handle, len);
6033 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306034 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6035 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306036 }
6037
6038 cmd = (wmi_passpoint_config_cmd_fixed_param *)
6039 wmi_buf_data(buf);
6040
6041 WMITLV_SET_HDR(&cmd->tlv_header,
6042 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
6043 WMITLV_GET_STRUCT_TLVLEN(
6044 wmi_passpoint_config_cmd_fixed_param));
6045 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05306046 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
6047 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306048 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05306049 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306050 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
6051 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05306052 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306053 j, bytes[0], bytes[1], bytes[2], bytes[3],
6054 bytes[4], bytes[5], bytes[6], bytes[7]);
6055
Govind Singhb53420c2016-03-09 14:32:57 +05306056 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05306057 &req->networks[i].roaming_consortium_ids[j],
6058 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
6059 }
Govind Singhb53420c2016-03-09 14:32:57 +05306060 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306061 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05306062 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306063 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
6064
6065 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6066 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6067 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306068 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306069 __func__);
6070 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306071 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306072 }
6073 }
6074
Govind Singhb53420c2016-03-09 14:32:57 +05306075 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306076}
6077
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306078#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306079/**
6080 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6081 * @wmi_handle: wmi handle
6082 * @roam_req: Roam scan offload params
6083 * @buf_ptr: command buffer to send
6084 * @fils_tlv_len: fils tlv length
6085 *
6086 * Return: Updated buffer pointer
6087 */
6088static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6089 struct roam_offload_scan_params *roam_req,
6090 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6091{
6092 wmi_roam_fils_offload_tlv_param *fils_tlv;
6093 wmi_erp_info *erp_info;
6094 struct roam_fils_params *roam_fils_params;
6095
6096 if (!roam_req->add_fils_tlv)
6097 return buf_ptr;
6098
6099 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6100 sizeof(*fils_tlv));
6101 buf_ptr += WMI_TLV_HDR_SIZE;
6102
6103 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6104 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6105 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6106 WMITLV_GET_STRUCT_TLVLEN
6107 (wmi_roam_fils_offload_tlv_param));
6108
6109 roam_fils_params = &roam_req->roam_fils_params;
6110 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6111
6112 erp_info->username_length = roam_fils_params->username_length;
6113 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6114 erp_info->username_length);
6115
6116 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6117
6118 erp_info->rRk_length = roam_fils_params->rrk_length;
6119 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6120 erp_info->rRk_length);
6121
6122 erp_info->rIk_length = roam_fils_params->rik_length;
6123 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6124 erp_info->rIk_length);
6125
6126 erp_info->realm_len = roam_fils_params->realm_len;
6127 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6128 erp_info->realm_len);
6129
6130 buf_ptr += sizeof(*fils_tlv);
6131 return buf_ptr;
6132}
6133#else
6134static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6135 struct roam_offload_scan_params *roam_req,
6136 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6137{
6138 return buf_ptr;
6139}
6140#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306141/**
6142 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6143 * @wmi_handle: wmi handle
6144 * @scan_cmd_fp: start scan command ptr
6145 * @roam_req: roam request param
6146 *
6147 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6148 * of WMI_ROAM_SCAN_MODE.
6149 *
6150 * Return: QDF status
6151 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306152static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306153 wmi_start_scan_cmd_fixed_param *
6154 scan_cmd_fp,
6155 struct roam_offload_scan_params *roam_req)
6156{
6157 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306158 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306159 int len;
6160 uint8_t *buf_ptr;
6161 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306162
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306163#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6164 int auth_mode = roam_req->auth_mode;
6165 wmi_roam_offload_tlv_param *roam_offload_params;
6166 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6167 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6168 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306169 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306170 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306171#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6172 /* Need to create a buf with roam_scan command at
6173 * front and piggyback with scan command */
6174 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6175#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6176 (2 * WMI_TLV_HDR_SIZE) +
6177#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6178 sizeof(wmi_start_scan_cmd_fixed_param);
6179#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006180 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306181 if (roam_req->is_roam_req_valid &&
6182 roam_req->roam_offload_enabled) {
6183 len += sizeof(wmi_roam_offload_tlv_param);
6184 len += WMI_TLV_HDR_SIZE;
6185 if ((auth_mode != WMI_AUTH_NONE) &&
6186 ((auth_mode != WMI_AUTH_OPEN) ||
6187 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306188 roam_req->mdid.mdie_present &&
6189 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306190 roam_req->is_ese_assoc)) {
6191 len += WMI_TLV_HDR_SIZE;
6192 if (roam_req->is_ese_assoc)
6193 len +=
6194 sizeof(wmi_roam_ese_offload_tlv_param);
6195 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6196 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6197 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306198 roam_req->mdid.mdie_present &&
6199 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306200 len +=
6201 sizeof(wmi_roam_11r_offload_tlv_param);
6202 else
6203 len +=
6204 sizeof(wmi_roam_11i_offload_tlv_param);
6205 } else {
6206 len += WMI_TLV_HDR_SIZE;
6207 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306208
6209 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6210 + roundup(roam_req->assoc_ie_length,
6211 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306212
6213 if (roam_req->add_fils_tlv) {
6214 fils_tlv_len = sizeof(
6215 wmi_roam_fils_offload_tlv_param);
6216 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6217 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306218 } else {
6219 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306220 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306221 __func__, roam_req->roam_offload_enabled);
6222 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306223 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306224 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306225 }
6226 if (roam_req->is_roam_req_valid &&
6227 roam_req->roam_offload_enabled) {
6228 roam_req->mode = roam_req->mode |
6229 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6230 }
6231#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6232
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306233 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6234 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6235 len = sizeof(wmi_roam_scan_mode_fixed_param);
6236
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306237 buf = wmi_buf_alloc(wmi_handle, len);
6238 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306239 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306240 return QDF_STATUS_E_NOMEM;
6241 }
6242
6243 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6244 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6245 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6246 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6247 WMITLV_GET_STRUCT_TLVLEN
6248 (wmi_roam_scan_mode_fixed_param));
6249
Abhinav Kumar334355f2018-04-06 17:18:52 +05306250 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6251 roam_req->roam_trigger_reason_bitmask;
6252 roam_scan_mode_fp->min_delay_btw_scans =
6253 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306254 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6255 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306256 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6257 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6258 roam_scan_mode_fp->flags |=
6259 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306260 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306261 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306262
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306263 /* Fill in scan parameters suitable for roaming scan */
6264 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306265
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306266 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6267 sizeof(wmi_start_scan_cmd_fixed_param));
6268 /* Ensure there is no additional IEs */
6269 scan_cmd_fp->ie_len = 0;
6270 WMITLV_SET_HDR(buf_ptr,
6271 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6272 WMITLV_GET_STRUCT_TLVLEN
6273 (wmi_start_scan_cmd_fixed_param));
6274#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6275 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6276 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6277 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6278 sizeof(wmi_roam_offload_tlv_param));
6279 buf_ptr += WMI_TLV_HDR_SIZE;
6280 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6281 WMITLV_SET_HDR(buf_ptr,
6282 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6283 WMITLV_GET_STRUCT_TLVLEN
6284 (wmi_roam_offload_tlv_param));
6285 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6286 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6287 roam_offload_params->select_5g_margin =
6288 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306289 roam_offload_params->handoff_delay_for_rx =
6290 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306291 roam_offload_params->reassoc_failure_timeout =
6292 roam_req->reassoc_failure_timeout;
6293
6294 /* Fill the capabilities */
6295 roam_offload_params->capability =
6296 roam_req->roam_offload_params.capability;
6297 roam_offload_params->ht_caps_info =
6298 roam_req->roam_offload_params.ht_caps_info;
6299 roam_offload_params->ampdu_param =
6300 roam_req->roam_offload_params.ampdu_param;
6301 roam_offload_params->ht_ext_cap =
6302 roam_req->roam_offload_params.ht_ext_cap;
6303 roam_offload_params->ht_txbf =
6304 roam_req->roam_offload_params.ht_txbf;
6305 roam_offload_params->asel_cap =
6306 roam_req->roam_offload_params.asel_cap;
6307 roam_offload_params->qos_caps =
6308 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006309 roam_offload_params->qos_enabled =
6310 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306311 roam_offload_params->wmm_caps =
6312 roam_req->roam_offload_params.wmm_caps;
6313 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6314 (uint8_t *)roam_req->roam_offload_params.mcsset,
6315 ROAM_OFFLOAD_NUM_MCS_SET);
6316
6317 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6318 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6319 * they are filled in the same order.Depending on the
6320 * authentication type, the other mode TLV's are nullified
6321 * and only headers are filled.*/
6322 if ((auth_mode != WMI_AUTH_NONE) &&
6323 ((auth_mode != WMI_AUTH_OPEN) ||
6324 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306325 && roam_req->mdid.mdie_present &&
6326 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306327 roam_req->is_ese_assoc)) {
6328 if (roam_req->is_ese_assoc) {
6329 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6330 WMITLV_GET_STRUCT_TLVLEN(0));
6331 buf_ptr += WMI_TLV_HDR_SIZE;
6332 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6333 WMITLV_GET_STRUCT_TLVLEN(0));
6334 buf_ptr += WMI_TLV_HDR_SIZE;
6335 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6336 sizeof(wmi_roam_ese_offload_tlv_param));
6337 buf_ptr += WMI_TLV_HDR_SIZE;
6338 roam_offload_ese =
6339 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6340 qdf_mem_copy(roam_offload_ese->krk,
6341 roam_req->krk,
6342 sizeof(roam_req->krk));
6343 qdf_mem_copy(roam_offload_ese->btk,
6344 roam_req->btk,
6345 sizeof(roam_req->btk));
6346 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6347 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6348 WMITLV_GET_STRUCT_TLVLEN
6349 (wmi_roam_ese_offload_tlv_param));
6350 buf_ptr +=
6351 sizeof(wmi_roam_ese_offload_tlv_param);
6352 } else if (auth_mode == WMI_AUTH_FT_RSNA
6353 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6354 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306355 && roam_req->mdid.mdie_present &&
6356 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306357 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6358 0);
6359 buf_ptr += WMI_TLV_HDR_SIZE;
6360 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6361 sizeof(wmi_roam_11r_offload_tlv_param));
6362 buf_ptr += WMI_TLV_HDR_SIZE;
6363 roam_offload_11r =
6364 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6365 roam_offload_11r->r0kh_id_len =
6366 roam_req->rokh_id_length;
6367 qdf_mem_copy(roam_offload_11r->r0kh_id,
6368 roam_req->rokh_id,
6369 roam_offload_11r->r0kh_id_len);
6370 qdf_mem_copy(roam_offload_11r->psk_msk,
6371 roam_req->psk_pmk,
6372 sizeof(roam_req->psk_pmk));
6373 roam_offload_11r->psk_msk_len =
6374 roam_req->pmk_len;
6375 roam_offload_11r->mdie_present =
6376 roam_req->mdid.mdie_present;
6377 roam_offload_11r->mdid =
6378 roam_req->mdid.mobility_domain;
6379 if (auth_mode == WMI_AUTH_OPEN) {
6380 /* If FT-Open ensure pmk length
6381 and r0khid len are zero */
6382 roam_offload_11r->r0kh_id_len = 0;
6383 roam_offload_11r->psk_msk_len = 0;
6384 }
6385 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6386 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6387 WMITLV_GET_STRUCT_TLVLEN
6388 (wmi_roam_11r_offload_tlv_param));
6389 buf_ptr +=
6390 sizeof(wmi_roam_11r_offload_tlv_param);
6391 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6392 WMITLV_GET_STRUCT_TLVLEN(0));
6393 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006394 WMI_LOGD("psk_msk_len = %d",
6395 roam_offload_11r->psk_msk_len);
6396 if (roam_offload_11r->psk_msk_len)
6397 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6398 QDF_TRACE_LEVEL_DEBUG,
6399 roam_offload_11r->psk_msk,
6400 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306401 } else {
6402 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6403 sizeof(wmi_roam_11i_offload_tlv_param));
6404 buf_ptr += WMI_TLV_HDR_SIZE;
6405 roam_offload_11i =
6406 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006407
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006408 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006409 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306410 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6411 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006412 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306413 } else {
6414 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6415 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006416 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006417 }
6418 if (roam_req->roam_key_mgmt_offload_enabled &&
6419 roam_req->fw_pmksa_cache) {
6420 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6421 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006422 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006423 } else {
6424 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6425 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006426 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306427 }
6428
6429 qdf_mem_copy(roam_offload_11i->pmk,
6430 roam_req->psk_pmk,
6431 sizeof(roam_req->psk_pmk));
6432 roam_offload_11i->pmk_len = roam_req->pmk_len;
6433 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6434 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6435 WMITLV_GET_STRUCT_TLVLEN
6436 (wmi_roam_11i_offload_tlv_param));
6437 buf_ptr +=
6438 sizeof(wmi_roam_11i_offload_tlv_param);
6439 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6440 0);
6441 buf_ptr += WMI_TLV_HDR_SIZE;
6442 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6443 0);
6444 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006445 WMI_LOGD("pmk_len = %d",
6446 roam_offload_11i->pmk_len);
6447 if (roam_offload_11i->pmk_len)
6448 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6449 QDF_TRACE_LEVEL_DEBUG,
6450 roam_offload_11i->pmk,
6451 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306452 }
6453 } else {
6454 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6455 WMITLV_GET_STRUCT_TLVLEN(0));
6456 buf_ptr += WMI_TLV_HDR_SIZE;
6457 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6458 WMITLV_GET_STRUCT_TLVLEN(0));
6459 buf_ptr += WMI_TLV_HDR_SIZE;
6460 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6461 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306462 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306463 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306464
6465 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6466 sizeof(*assoc_ies));
6467 buf_ptr += WMI_TLV_HDR_SIZE;
6468
6469 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6470 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6471 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6472 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6473 assoc_ies->buf_len = roam_req->assoc_ie_length;
6474
6475 buf_ptr += sizeof(*assoc_ies);
6476
6477 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6478 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6479 buf_ptr += WMI_TLV_HDR_SIZE;
6480
6481 if (assoc_ies->buf_len != 0) {
6482 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6483 assoc_ies->buf_len);
6484 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306485 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6486 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6487 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306488 } else {
6489 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6490 WMITLV_GET_STRUCT_TLVLEN(0));
6491 buf_ptr += WMI_TLV_HDR_SIZE;
6492 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6493 WMITLV_GET_STRUCT_TLVLEN(0));
6494 buf_ptr += WMI_TLV_HDR_SIZE;
6495 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6496 WMITLV_GET_STRUCT_TLVLEN(0));
6497 buf_ptr += WMI_TLV_HDR_SIZE;
6498 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6499 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306500 buf_ptr += WMI_TLV_HDR_SIZE;
6501 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6502 WMITLV_GET_STRUCT_TLVLEN(0));
6503 buf_ptr += WMI_TLV_HDR_SIZE;
6504 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6505 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306506 }
6507#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306508
6509send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306510 status = wmi_unified_cmd_send(wmi_handle, buf,
6511 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306512 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306513 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306514 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6515 status);
6516 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306517 }
6518
Govind Singh67922e82016-04-01 16:48:57 +05306519 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306520}
6521
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006522static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6523 struct wmi_mawc_roam_params *params)
6524{
6525 wmi_buf_t buf = NULL;
6526 QDF_STATUS status;
6527 int len;
6528 uint8_t *buf_ptr;
6529 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6530
6531 len = sizeof(*wmi_roam_mawc_params);
6532 buf = wmi_buf_alloc(wmi_handle, len);
6533 if (!buf) {
6534 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6535 return QDF_STATUS_E_NOMEM;
6536 }
6537
6538 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6539 wmi_roam_mawc_params =
6540 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6541 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6542 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6543 WMITLV_GET_STRUCT_TLVLEN
6544 (wmi_roam_configure_mawc_cmd_fixed_param));
6545 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6546 if (params->enable)
6547 wmi_roam_mawc_params->enable = 1;
6548 else
6549 wmi_roam_mawc_params->enable = 0;
6550 wmi_roam_mawc_params->traffic_load_threshold =
6551 params->traffic_load_threshold;
6552 wmi_roam_mawc_params->best_ap_rssi_threshold =
6553 params->best_ap_rssi_threshold;
6554 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6555 params->rssi_stationary_high_adjust;
6556 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6557 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006558 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6559 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6560 wmi_roam_mawc_params->traffic_load_threshold,
6561 wmi_roam_mawc_params->best_ap_rssi_threshold,
6562 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6563 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006564
6565 status = wmi_unified_cmd_send(wmi_handle, buf,
6566 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6567 if (QDF_IS_STATUS_ERROR(status)) {
6568 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6569 status);
6570 wmi_buf_free(buf);
6571 return status;
6572 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006573
6574 return QDF_STATUS_SUCCESS;
6575}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306576
6577/**
6578 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6579 * rssi threashold
6580 * @wmi_handle: wmi handle
6581 * @roam_req: Roaming request buffer
6582 *
6583 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6584 *
6585 * Return: QDF status
6586 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306587static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306588 struct roam_offload_scan_rssi_params *roam_req)
6589{
6590 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306591 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306592 int len;
6593 uint8_t *buf_ptr;
6594 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6595 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6596 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306597 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006598 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306599
6600 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6601 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6602 len += sizeof(wmi_roam_scan_extended_threshold_param);
6603 len += WMI_TLV_HDR_SIZE;
6604 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306605 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6606 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006607 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6608 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306609 buf = wmi_buf_alloc(wmi_handle, len);
6610 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306611 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306612 return QDF_STATUS_E_NOMEM;
6613 }
6614
6615 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6616 rssi_threshold_fp =
6617 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6618 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6619 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6620 WMITLV_GET_STRUCT_TLVLEN
6621 (wmi_roam_scan_rssi_threshold_fixed_param));
6622 /* fill in threshold values */
6623 rssi_threshold_fp->vdev_id = roam_req->session_id;
6624 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6625 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6626 rssi_threshold_fp->hirssi_scan_max_count =
6627 roam_req->hi_rssi_scan_max_count;
6628 rssi_threshold_fp->hirssi_scan_delta =
6629 roam_req->hi_rssi_scan_rssi_delta;
6630 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006631 rssi_threshold_fp->rssi_thresh_offset_5g =
6632 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306633
6634 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6635 WMITLV_SET_HDR(buf_ptr,
6636 WMITLV_TAG_ARRAY_STRUC,
6637 sizeof(wmi_roam_scan_extended_threshold_param));
6638 buf_ptr += WMI_TLV_HDR_SIZE;
6639 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6640
6641 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6642 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6643 ext_thresholds->boost_threshold_5g =
6644 roam_req->boost_threshold_5g;
6645
6646 ext_thresholds->boost_algorithm_5g =
6647 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6648 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6649 ext_thresholds->penalty_algorithm_5g =
6650 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6651 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6652 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6653 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6654 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6655
6656 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6657 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6658 WMITLV_GET_STRUCT_TLVLEN
6659 (wmi_roam_scan_extended_threshold_param));
6660 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6661 WMITLV_SET_HDR(buf_ptr,
6662 WMITLV_TAG_ARRAY_STRUC,
6663 sizeof(wmi_roam_earlystop_rssi_thres_param));
6664 buf_ptr += WMI_TLV_HDR_SIZE;
6665 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6666 early_stop_thresholds->roam_earlystop_thres_min =
6667 roam_req->roam_earlystop_thres_min;
6668 early_stop_thresholds->roam_earlystop_thres_max =
6669 roam_req->roam_earlystop_thres_max;
6670 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6671 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6672 WMITLV_GET_STRUCT_TLVLEN
6673 (wmi_roam_earlystop_rssi_thres_param));
6674
Gupta, Kapil7e652922016-04-12 15:02:00 +05306675 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6676 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6677 sizeof(wmi_roam_dense_thres_param));
6678 buf_ptr += WMI_TLV_HDR_SIZE;
6679 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6680 dense_thresholds->roam_dense_rssi_thres_offset =
6681 roam_req->dense_rssi_thresh_offset;
6682 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6683 dense_thresholds->roam_dense_traffic_thres =
6684 roam_req->traffic_threshold;
6685 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6686 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6687 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6688 WMITLV_GET_STRUCT_TLVLEN
6689 (wmi_roam_dense_thres_param));
6690
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006691 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6692 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6693 sizeof(wmi_roam_bg_scan_roaming_param));
6694 buf_ptr += WMI_TLV_HDR_SIZE;
6695 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6696 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6697 roam_req->bg_scan_bad_rssi_thresh;
6698 bg_scan_params->roam_bg_scan_client_bitmap =
6699 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306700 bg_scan_params->bad_rssi_thresh_offset_2g =
6701 roam_req->roam_bad_rssi_thresh_offset_2g;
6702 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006703 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6704 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6705 WMITLV_GET_STRUCT_TLVLEN
6706 (wmi_roam_bg_scan_roaming_param));
6707
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306708 status = wmi_unified_cmd_send(wmi_handle, buf,
6709 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306710 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306711 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306712 status);
6713 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306714 }
6715
Govind Singh67922e82016-04-01 16:48:57 +05306716 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306717}
6718
6719/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306720 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6721 * configuration params
6722 * @wma_handle: wma handler
6723 * @dwelltime_params: pointer to dwelltime_params
6724 *
6725 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6726 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006727static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306728QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6729 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6730{
6731 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6732 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6733 wmi_buf_t buf;
6734 uint8_t *buf_ptr;
6735 int32_t err;
6736 int len;
6737
6738 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6739 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6740 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6741 buf = wmi_buf_alloc(wmi_handle, len);
6742 if (!buf) {
6743 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6744 __func__);
6745 return QDF_STATUS_E_NOMEM;
6746 }
6747 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6748 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6749 WMITLV_SET_HDR(&dwell_param->tlv_header,
6750 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6751 WMITLV_GET_STRUCT_TLVLEN
6752 (wmi_scan_adaptive_dwell_config_fixed_param));
6753
6754 dwell_param->enable = dwelltime_params->is_enabled;
6755 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6756 WMITLV_SET_HDR(buf_ptr,
6757 WMITLV_TAG_ARRAY_STRUC,
6758 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6759 buf_ptr += WMI_TLV_HDR_SIZE;
6760
6761 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6762 WMITLV_SET_HDR(&cmd->tlv_header,
6763 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6764 WMITLV_GET_STRUCT_TLVLEN(
6765 wmi_scan_adaptive_dwell_parameters_tlv));
6766
6767 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6768 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6769 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6770 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6771 err = wmi_unified_cmd_send(wmi_handle, buf,
6772 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6773 if (err) {
6774 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6775 wmi_buf_free(buf);
6776 return QDF_STATUS_E_FAILURE;
6777 }
6778
6779 return QDF_STATUS_SUCCESS;
6780}
6781
Nitesh Shah52323d02017-05-22 15:49:00 +05306782/**
6783 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6784 * configuration params
6785 * @wmi_handle: wmi handler
6786 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6787 *
6788 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6789 */
6790static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6791 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6792{
6793 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6794 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6795 wmi_buf_t buf;
6796 uint8_t *buf_ptr;
6797 QDF_STATUS err;
6798 uint32_t i;
6799 int len;
6800
6801 len = sizeof(*dbs_scan_param);
6802 len += WMI_TLV_HDR_SIZE;
6803 len += dbs_scan_params->num_clients * sizeof(*cmd);
6804
6805 buf = wmi_buf_alloc(wmi_handle, len);
6806 if (!buf) {
6807 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6808 return QDF_STATUS_E_NOMEM;
6809 }
6810
6811 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6812 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6813 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6814 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6815 WMITLV_GET_STRUCT_TLVLEN
6816 (wmi_scan_dbs_duty_cycle_fixed_param));
6817
6818 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6819 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6820 buf_ptr += sizeof(*dbs_scan_param);
6821 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6822 (sizeof(*cmd) * dbs_scan_params->num_clients));
6823 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6824
6825 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6826 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6827 WMITLV_SET_HDR(&cmd->tlv_header,
6828 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6829 WMITLV_GET_STRUCT_TLVLEN(
6830 wmi_scan_dbs_duty_cycle_tlv_param));
6831 cmd->module_id = dbs_scan_params->module_id[i];
6832 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6833 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6834 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6835 }
6836
6837 err = wmi_unified_cmd_send(wmi_handle, buf,
6838 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6839 if (QDF_IS_STATUS_ERROR(err)) {
6840 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6841 wmi_buf_free(buf);
6842 return QDF_STATUS_E_FAILURE;
6843 }
6844
6845 return QDF_STATUS_SUCCESS;
6846}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306847
6848/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306849 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6850 * @wmi_handle: wmi handle
6851 * @roam_req: Request which contains the filters
6852 *
6853 * There are filters such as whitelist, blacklist and preferred
6854 * list that need to be applied to the scan results to form the
6855 * probable candidates for roaming.
6856 *
Jeff Johnsonda263992018-05-12 14:22:00 -07006857 * Return: Return success upon successfully passing the
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306858 * parameters to the firmware, otherwise failure.
6859 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306860static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306861 struct roam_scan_filter_params *roam_req)
6862{
6863 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306864 QDF_STATUS status;
6865 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306866 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306867 uint8_t *buf_ptr;
6868 wmi_roam_filter_fixed_param *roam_filter;
6869 uint8_t *bssid_src_ptr = NULL;
6870 wmi_mac_addr *bssid_dst_ptr = NULL;
6871 wmi_ssid *ssid_ptr = NULL;
6872 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306873 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306874 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306875
6876 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306877
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306878 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306879 if (roam_req->num_bssid_black_list)
6880 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6881 len += WMI_TLV_HDR_SIZE;
6882 if (roam_req->num_ssid_white_list)
6883 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6884 len += 2 * WMI_TLV_HDR_SIZE;
6885 if (roam_req->num_bssid_preferred_list) {
6886 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05306887 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306888 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306889 len += WMI_TLV_HDR_SIZE;
6890 if (roam_req->lca_disallow_config_present) {
6891 len += sizeof(*blist_param);
6892 blist_len = sizeof(*blist_param);
6893 }
6894
6895 len += WMI_TLV_HDR_SIZE;
6896 if (roam_req->num_rssi_rejection_ap)
6897 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306898
6899 buf = wmi_buf_alloc(wmi_handle, len);
6900 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306901 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306902 return QDF_STATUS_E_NOMEM;
6903 }
6904
6905 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6906 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6907 WMITLV_SET_HDR(&roam_filter->tlv_header,
6908 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6909 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6910 /* fill in fixed values */
6911 roam_filter->vdev_id = roam_req->session_id;
6912 roam_filter->flags = 0;
6913 roam_filter->op_bitmap = roam_req->op_bitmap;
6914 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6915 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6916 roam_filter->num_bssid_preferred_list =
6917 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306918 roam_filter->num_rssi_rejection_ap =
6919 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306920 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6921
6922 WMITLV_SET_HDR((buf_ptr),
6923 WMITLV_TAG_ARRAY_FIXED_STRUC,
6924 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6925 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6926 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6927 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6928 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6929 bssid_src_ptr += ATH_MAC_LEN;
6930 bssid_dst_ptr++;
6931 }
6932 buf_ptr += WMI_TLV_HDR_SIZE +
6933 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6934 WMITLV_SET_HDR((buf_ptr),
6935 WMITLV_TAG_ARRAY_FIXED_STRUC,
6936 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6937 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6938 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6939 qdf_mem_copy(&ssid_ptr->ssid,
6940 &roam_req->ssid_allowed_list[i].mac_ssid,
6941 roam_req->ssid_allowed_list[i].length);
6942 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6943 ssid_ptr++;
6944 }
6945 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6946 sizeof(wmi_ssid));
6947 WMITLV_SET_HDR((buf_ptr),
6948 WMITLV_TAG_ARRAY_FIXED_STRUC,
6949 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6950 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6951 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6952 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6953 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6954 (wmi_mac_addr *)bssid_dst_ptr);
6955 bssid_src_ptr += ATH_MAC_LEN;
6956 bssid_dst_ptr++;
6957 }
6958 buf_ptr += WMI_TLV_HDR_SIZE +
6959 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6960 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6961 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6962 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6963 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6964 *bssid_preferred_factor_ptr =
6965 roam_req->bssid_favored_factor[i];
6966 bssid_preferred_factor_ptr++;
6967 }
6968 buf_ptr += WMI_TLV_HDR_SIZE +
6969 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6970
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306971 WMITLV_SET_HDR(buf_ptr,
6972 WMITLV_TAG_ARRAY_STRUC, blist_len);
6973 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306974 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306975 blist_param =
6976 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6977 WMITLV_SET_HDR(&blist_param->tlv_header,
6978 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6979 WMITLV_GET_STRUCT_TLVLEN(
6980 wmi_roam_lca_disallow_config_tlv_param));
6981
6982 blist_param->disallow_duration = roam_req->disallow_duration;
6983 blist_param->rssi_channel_penalization =
6984 roam_req->rssi_channel_penalization;
6985 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05306986 blist_param->disallow_lca_enable_source_bitmap =
6987 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
6988 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306989 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6990 }
6991
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306992 WMITLV_SET_HDR(buf_ptr,
6993 WMITLV_TAG_ARRAY_STRUC,
6994 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
6995 buf_ptr += WMI_TLV_HDR_SIZE;
6996 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
6997 rssi_rej =
6998 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
6999 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7000 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7001 WMITLV_GET_STRUCT_TLVLEN(
7002 wmi_roam_rssi_rejection_oce_config_param));
7003 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7004 roam_req->rssi_rejection_ap[i].bssid.bytes,
7005 &rssi_rej->bssid);
7006 rssi_rej->remaining_disallow_duration =
7007 roam_req->rssi_rejection_ap[i].remaining_duration;
7008 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05307009 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307010 buf_ptr +=
7011 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7012 }
7013
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307014 status = wmi_unified_cmd_send(wmi_handle, buf,
7015 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307016 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307017 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307018 status);
7019 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307020 }
Govind Singh67922e82016-04-01 16:48:57 +05307021
7022 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307023}
7024
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307025#if defined(WLAN_FEATURE_FILS_SK)
7026static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7027 struct hlp_params *params)
7028{
7029 uint32_t len;
7030 uint8_t *buf_ptr;
7031 wmi_buf_t buf = NULL;
7032 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7033
7034 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7035 len += WMI_TLV_HDR_SIZE;
7036 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7037
7038 buf = wmi_buf_alloc(wmi_handle, len);
7039 if (!buf) {
7040 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7041 return QDF_STATUS_E_NOMEM;
7042 }
7043
7044 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7045 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7046 WMITLV_SET_HDR(&hlp_params->tlv_header,
7047 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7048 WMITLV_GET_STRUCT_TLVLEN(
7049 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7050
7051 hlp_params->vdev_id = params->vdev_id;
7052 hlp_params->size = params->hlp_ie_len;
7053 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7054
7055 buf_ptr += sizeof(*hlp_params);
7056
7057 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7058 round_up(params->hlp_ie_len,
7059 sizeof(uint32_t)));
7060 buf_ptr += WMI_TLV_HDR_SIZE;
7061 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7062
7063 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7064 hlp_params->vdev_id, hlp_params->size);
7065 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7066 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7067 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7068 wmi_buf_free(buf);
7069 return QDF_STATUS_E_FAILURE;
7070 }
7071
7072 return QDF_STATUS_SUCCESS;
7073}
7074#endif
7075
Govind Singh4eacd2b2016-03-07 14:24:22 +05307076/** send_set_epno_network_list_cmd_tlv() - set epno network list
7077 * @wmi_handle: wmi handle
7078 * @req: epno config params request structure
7079 *
7080 * This function reads the incoming epno config request structure
7081 * and constructs the WMI message to the firmware.
7082 *
7083 * Returns: 0 on success, error number otherwise
7084 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307085static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307086 struct wifi_enhanched_pno_params *req)
7087{
7088 wmi_nlo_config_cmd_fixed_param *cmd;
7089 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307090 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307091 u_int8_t i, *buf_ptr;
7092 wmi_buf_t buf;
7093 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307094 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307095
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307096 /* Fixed Params */
7097 len = sizeof(*cmd);
7098 if (req->num_networks) {
7099 /* TLV place holder for array of structures
7100 * then each nlo_configured_parameters(nlo_list) TLV.
7101 */
7102 len += WMI_TLV_HDR_SIZE;
7103 len += (sizeof(nlo_configured_parameters)
7104 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
7105 /* TLV for array of uint32 channel_list */
7106 len += WMI_TLV_HDR_SIZE;
7107 /* TLV for nlo_channel_prediction_cfg */
7108 len += WMI_TLV_HDR_SIZE;
7109 /* TLV for candidate score params */
7110 len += sizeof(enlo_candidate_score_params);
7111 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05307112
7113 buf = wmi_buf_alloc(wmi_handle, len);
7114 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307115 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7116 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307117 }
7118
7119 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7120
7121 buf_ptr = (u_int8_t *) cmd;
7122 WMITLV_SET_HDR(&cmd->tlv_header,
7123 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7124 WMITLV_GET_STRUCT_TLVLEN(
7125 wmi_nlo_config_cmd_fixed_param));
7126 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307127
7128 /* set flag to reset if num of networks are 0 */
7129 cmd->flags = (req->num_networks == 0 ?
7130 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307131
7132 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7133
Govind Singhb53420c2016-03-09 14:32:57 +05307134 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307135 WMI_LOGD("SSID count: %d flags: %d",
7136 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307137
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307138 /* Fill nlo_config only when num_networks are non zero */
7139 if (cmd->no_of_ssids) {
7140 /* Fill networks */
7141 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7142 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7143 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307144
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307145 nlo_list = (nlo_configured_parameters *) buf_ptr;
7146 for (i = 0; i < cmd->no_of_ssids; i++) {
7147 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7148 WMITLV_TAG_ARRAY_BYTE,
7149 WMITLV_GET_STRUCT_TLVLEN(
7150 nlo_configured_parameters));
7151 /* Copy ssid and it's length */
7152 nlo_list[i].ssid.valid = true;
7153 nlo_list[i].ssid.ssid.ssid_len =
7154 req->networks[i].ssid.length;
7155 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
7156 req->networks[i].ssid.mac_ssid,
7157 nlo_list[i].ssid.ssid.ssid_len);
7158 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
7159 nlo_list[i].ssid.ssid.ssid_len,
7160 (char *) nlo_list[i].ssid.ssid.ssid,
7161 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307162
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307163 /* Copy pno flags */
7164 nlo_list[i].bcast_nw_type.valid = true;
7165 nlo_list[i].bcast_nw_type.bcast_nw_type =
7166 req->networks[i].flags;
7167 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307168 nlo_list[i].bcast_nw_type.bcast_nw_type);
7169
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307170 /* Copy auth bit field */
7171 nlo_list[i].auth_type.valid = true;
7172 nlo_list[i].auth_type.auth_type =
7173 req->networks[i].auth_bit_field;
7174 WMI_LOGD("Auth bit field (%u)",
7175 nlo_list[i].auth_type.auth_type);
7176 }
7177
7178 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7179 /* Fill the channel list */
7180 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7181 buf_ptr += WMI_TLV_HDR_SIZE;
7182
7183 /* Fill prediction_param */
7184 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7185 buf_ptr += WMI_TLV_HDR_SIZE;
7186
7187 /* Fill epno candidate score params */
7188 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
7189 WMITLV_SET_HDR(buf_ptr,
7190 WMITLV_TAG_STRUC_enlo_candidate_score_param,
7191 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7192 cand_score_params->min5GHz_rssi =
7193 req->min_5ghz_rssi;
7194 cand_score_params->min24GHz_rssi =
7195 req->min_24ghz_rssi;
7196 cand_score_params->initial_score_max =
7197 req->initial_score_max;
7198 cand_score_params->current_connection_bonus =
7199 req->current_connection_bonus;
7200 cand_score_params->same_network_bonus =
7201 req->same_network_bonus;
7202 cand_score_params->secure_bonus =
7203 req->secure_bonus;
7204 cand_score_params->band5GHz_bonus =
7205 req->band_5ghz_bonus;
7206 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307207 }
7208
Govind Singh4eacd2b2016-03-07 14:24:22 +05307209 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307210 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307211 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307212 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307213 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307214 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307215 }
7216
Govind Singhb53420c2016-03-09 14:32:57 +05307217 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307218 req->session_id);
7219
Govind Singh67922e82016-04-01 16:48:57 +05307220 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307221}
7222
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307223#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307224/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7225 * @wmi_handle: wmi handle
7226 * @ipa_offload: ipa offload control parameter
7227 *
7228 * Returns: 0 on success, error number otherwise
7229 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307230static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307231 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307232{
7233 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7234 wmi_buf_t wmi_buf;
7235 uint32_t len;
7236 u_int8_t *buf_ptr;
7237
7238 len = sizeof(*cmd);
7239 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7240 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307241 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7242 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307243 }
7244
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007245 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307246 ipa_offload->offload_type, ipa_offload->enable);
7247
7248 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7249
7250 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7251 WMITLV_SET_HDR(&cmd->tlv_header,
7252 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7253 WMITLV_GET_STRUCT_TLVLEN(
7254 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7255
7256 cmd->offload_type = ipa_offload->offload_type;
7257 cmd->vdev_id = ipa_offload->vdev_id;
7258 cmd->enable = ipa_offload->enable;
7259
7260 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7261 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307262 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307263 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307264 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307265 }
7266
Govind Singhb53420c2016-03-09 14:32:57 +05307267 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307268}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307269#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307270
7271/**
7272 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
7273 * @wmi_handle: wmi handle
7274 * @pgetcapab: get capabilities params
7275 *
7276 * This function send request to fw to get extscan capabilities.
7277 *
7278 * Return: CDF status
7279 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307280static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307281 struct extscan_capabilities_params *pgetcapab)
7282{
7283 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
7284 wmi_buf_t wmi_buf;
7285 uint32_t len;
7286 uint8_t *buf_ptr;
7287
7288 len = sizeof(*cmd);
7289 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7290 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307291 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7292 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307293 }
7294 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7295
7296 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
7297 WMITLV_SET_HDR(&cmd->tlv_header,
7298 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
7299 WMITLV_GET_STRUCT_TLVLEN
7300 (wmi_extscan_get_capabilities_cmd_fixed_param));
7301
7302 cmd->request_id = pgetcapab->request_id;
7303
7304 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7305 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307306 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307307 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307308 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307309 }
Govind Singhb53420c2016-03-09 14:32:57 +05307310 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307311}
7312
7313/**
7314 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
7315 * @wmi_handle: wmi handle
7316 * @pcached_results: cached results parameters
7317 *
7318 * This function send request to fw to get cached results.
7319 *
7320 * Return: CDF status
7321 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307322static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307323 struct extscan_cached_result_params *pcached_results)
7324{
7325 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
7326 wmi_buf_t wmi_buf;
7327 uint32_t len;
7328 uint8_t *buf_ptr;
7329
7330 len = sizeof(*cmd);
7331 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7332 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307333 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7334 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307335 }
7336 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7337
7338 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
7339 WMITLV_SET_HDR(&cmd->tlv_header,
7340 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
7341 WMITLV_GET_STRUCT_TLVLEN
7342 (wmi_extscan_get_cached_results_cmd_fixed_param));
7343
7344 cmd->request_id = pcached_results->request_id;
7345 cmd->vdev_id = pcached_results->session_id;
7346 cmd->control_flags = pcached_results->flush;
7347
7348 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7349 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307350 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307351 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307352 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307353 }
Govind Singhb53420c2016-03-09 14:32:57 +05307354 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307355}
7356
7357/**
7358 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
7359 * @wmi_handle: wmi handle
7360 * @reset_req: Reset change request params
7361 *
7362 * This function sends stop change monitor request to fw.
7363 *
7364 * Return: CDF status
7365 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307366static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307367 struct extscan_capabilities_reset_params *reset_req)
7368{
7369 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7370 wmi_buf_t wmi_buf;
7371 uint32_t len;
7372 uint8_t *buf_ptr;
7373 int change_list = 0;
7374
7375 len = sizeof(*cmd);
7376
7377 /* reset significant change tlv is set to 0 */
7378 len += WMI_TLV_HDR_SIZE;
7379 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
7380 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7381 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307382 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7383 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307384 }
7385 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7386
7387 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7388 buf_ptr;
7389 WMITLV_SET_HDR(&cmd->tlv_header,
7390 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7391 WMITLV_GET_STRUCT_TLVLEN
7392 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7393
7394 cmd->request_id = reset_req->request_id;
7395 cmd->vdev_id = reset_req->session_id;
7396 cmd->mode = 0;
7397
7398 buf_ptr += sizeof(*cmd);
7399 WMITLV_SET_HDR(buf_ptr,
7400 WMITLV_TAG_ARRAY_STRUC,
7401 change_list *
7402 sizeof(wmi_extscan_wlan_change_bssid_param));
7403 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
7404 sizeof
7405 (wmi_extscan_wlan_change_bssid_param));
7406
7407 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7408 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307409 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307410 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307411 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307412 }
Govind Singhb53420c2016-03-09 14:32:57 +05307413 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307414}
7415
7416/**
7417 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
7418 * @wmi_handle: wmi handle
7419 * @psigchange: change monitor request params
7420 * @buf: wmi buffer
7421 * @buf_len: buffer length
7422 *
7423 * This function fills elements of change monitor request buffer.
7424 *
7425 * Return: CDF status
7426 */
Govind Singhb53420c2016-03-09 14:32:57 +05307427static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307428 struct extscan_set_sig_changereq_params
7429 *psigchange, wmi_buf_t *buf, int *buf_len)
7430{
7431 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7432 wmi_extscan_wlan_change_bssid_param *dest_chglist;
7433 uint8_t *buf_ptr;
7434 int j;
7435 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007436 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307437 struct ap_threshold_params *src_ap = psigchange->ap;
7438
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007439 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307440 WMI_LOGE("%s: Invalid number of bssid's", __func__);
7441 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307442 }
7443 len += WMI_TLV_HDR_SIZE;
7444 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
7445
7446 *buf = wmi_buf_alloc(wmi_handle, len);
7447 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307448 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307449 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307450 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307451 }
7452 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7453 cmd =
7454 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7455 buf_ptr;
7456 WMITLV_SET_HDR(&cmd->tlv_header,
7457 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7458 WMITLV_GET_STRUCT_TLVLEN
7459 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7460
7461 cmd->request_id = psigchange->request_id;
7462 cmd->vdev_id = psigchange->session_id;
7463 cmd->total_entries = numap;
7464 cmd->mode = 1;
7465 cmd->num_entries_in_page = numap;
7466 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
7467 cmd->max_rssi_samples = psigchange->rssi_sample_size;
7468 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
7469 cmd->max_out_of_range_count = psigchange->min_breaching;
7470
7471 buf_ptr += sizeof(*cmd);
7472 WMITLV_SET_HDR(buf_ptr,
7473 WMITLV_TAG_ARRAY_STRUC,
7474 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7475 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
7476 (buf_ptr + WMI_TLV_HDR_SIZE);
7477
7478 for (j = 0; j < numap; j++) {
7479 WMITLV_SET_HDR(dest_chglist,
7480 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7481 WMITLV_GET_STRUCT_TLVLEN
7482 (wmi_extscan_wlan_change_bssid_param));
7483
7484 dest_chglist->lower_rssi_limit = src_ap->low;
7485 dest_chglist->upper_rssi_limit = src_ap->high;
7486 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
7487 &dest_chglist->bssid);
7488
Govind Singhb53420c2016-03-09 14:32:57 +05307489 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307490 dest_chglist->lower_rssi_limit);
7491 dest_chglist++;
7492 src_ap++;
7493 }
7494 buf_ptr += WMI_TLV_HDR_SIZE +
7495 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7496 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307497 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307498}
7499
7500/**
7501 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
7502 * @wmi_handle: wmi handle
7503 * @psigchange: change monitor request params
7504 *
7505 * This function sends start change monitor request to fw.
7506 *
7507 * Return: CDF status
7508 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307509static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307510 struct extscan_set_sig_changereq_params *
7511 psigchange)
7512{
Govind Singhb53420c2016-03-09 14:32:57 +05307513 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307514 wmi_buf_t buf;
7515 int len;
7516
7517
Govind Singhb53420c2016-03-09 14:32:57 +05307518 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307519 psigchange, &buf,
7520 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307521 if (qdf_status != QDF_STATUS_SUCCESS) {
7522 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307523 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307524 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307525 }
7526 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307527 WMI_LOGE("%s: Failed to get buffer", __func__);
7528 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307529 }
7530 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7531 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307532 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307533 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307534 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307535 }
Govind Singhb53420c2016-03-09 14:32:57 +05307536 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307537}
7538
7539/**
7540 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
7541 * @wmi_handle: wmi handle
7542 * @photlist_reset: hotlist reset params
7543 *
7544 * This function configures hotlist monitor to stop in fw.
7545 *
7546 * Return: CDF status
7547 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307548static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307549 struct extscan_bssid_hotlist_reset_params *photlist_reset)
7550{
7551 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
7552 wmi_buf_t wmi_buf;
7553 uint32_t len;
7554 uint8_t *buf_ptr;
7555 int hotlist_entries = 0;
7556
7557 len = sizeof(*cmd);
7558
7559 /* reset bssid hotlist with tlv set to 0 */
7560 len += WMI_TLV_HDR_SIZE;
7561 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
7562
7563 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7564 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307565 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7566 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307567 }
7568
7569 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7570 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
7571 buf_ptr;
7572 WMITLV_SET_HDR(&cmd->tlv_header,
7573 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
7574 WMITLV_GET_STRUCT_TLVLEN
7575 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
7576
7577 cmd->request_id = photlist_reset->request_id;
7578 cmd->vdev_id = photlist_reset->session_id;
7579 cmd->mode = 0;
7580
7581 buf_ptr += sizeof(*cmd);
7582 WMITLV_SET_HDR(buf_ptr,
7583 WMITLV_TAG_ARRAY_STRUC,
7584 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7585 buf_ptr += WMI_TLV_HDR_SIZE +
7586 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7587
7588 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7589 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307590 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307591 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307592 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307593 }
Govind Singhb53420c2016-03-09 14:32:57 +05307594 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307595}
7596
7597/**
7598 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
7599 * @wmi_handle: wmi handle
7600 * @pstopcmd: stop scan command request params
7601 *
7602 * This function sends stop extscan request to fw.
7603 *
7604 * Return: CDF Status.
7605 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307606static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307607 struct extscan_stop_req_params *pstopcmd)
7608{
7609 wmi_extscan_stop_cmd_fixed_param *cmd;
7610 wmi_buf_t wmi_buf;
7611 uint32_t len;
7612 uint8_t *buf_ptr;
7613
7614 len = sizeof(*cmd);
7615 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7616 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307617 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7618 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307619 }
7620 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7621 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
7622 WMITLV_SET_HDR(&cmd->tlv_header,
7623 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
7624 WMITLV_GET_STRUCT_TLVLEN
7625 (wmi_extscan_stop_cmd_fixed_param));
7626
7627 cmd->request_id = pstopcmd->request_id;
7628 cmd->vdev_id = pstopcmd->session_id;
7629
7630 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7631 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307632 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307633 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307634 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307635 }
7636
Govind Singhb53420c2016-03-09 14:32:57 +05307637 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307638}
7639
7640/**
7641 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
7642 * @wmi_handle: wmi handle
7643 * @pstart: scan command request params
7644 * @buf: event buffer
7645 * @buf_len: length of buffer
7646 *
7647 * This function fills individual elements of extscan request and
7648 * TLV for buckets, channel list.
7649 *
7650 * Return: CDF Status.
7651 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007652static
Govind Singhb53420c2016-03-09 14:32:57 +05307653QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307654 struct wifi_scan_cmd_req_params *pstart,
7655 wmi_buf_t *buf, int *buf_len)
7656{
7657 wmi_extscan_start_cmd_fixed_param *cmd;
7658 wmi_extscan_bucket *dest_blist;
7659 wmi_extscan_bucket_channel *dest_clist;
7660 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
7661 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
7662 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
7663
7664 uint8_t *buf_ptr;
7665 int i, k, count = 0;
7666 int len = sizeof(*cmd);
7667 int nbuckets = pstart->numBuckets;
7668 int nchannels = 0;
7669
7670 /* These TLV's are are NULL by default */
7671 uint32_t ie_len_with_pad = 0;
7672 int num_ssid = 0;
7673 int num_bssid = 0;
7674 int ie_len = 0;
7675
7676 uint32_t base_period = pstart->basePeriod;
7677
7678 /* TLV placeholder for ssid_list (NULL) */
7679 len += WMI_TLV_HDR_SIZE;
7680 len += num_ssid * sizeof(wmi_ssid);
7681
7682 /* TLV placeholder for bssid_list (NULL) */
7683 len += WMI_TLV_HDR_SIZE;
7684 len += num_bssid * sizeof(wmi_mac_addr);
7685
7686 /* TLV placeholder for ie_data (NULL) */
7687 len += WMI_TLV_HDR_SIZE;
7688 len += ie_len * sizeof(uint32_t);
7689
7690 /* TLV placeholder for bucket */
7691 len += WMI_TLV_HDR_SIZE;
7692 len += nbuckets * sizeof(wmi_extscan_bucket);
7693
7694 /* TLV channel placeholder */
7695 len += WMI_TLV_HDR_SIZE;
7696 for (i = 0; i < nbuckets; i++) {
7697 nchannels += src_bucket->numChannels;
7698 src_bucket++;
7699 }
7700
Govind Singhb53420c2016-03-09 14:32:57 +05307701 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307702 __func__, nbuckets, nchannels);
7703 len += nchannels * sizeof(wmi_extscan_bucket_channel);
7704 /* Allocate the memory */
7705 *buf = wmi_buf_alloc(wmi_handle, len);
7706 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307707 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307708 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307709 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307710 }
7711 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7712 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
7713 WMITLV_SET_HDR(&cmd->tlv_header,
7714 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
7715 WMITLV_GET_STRUCT_TLVLEN
7716 (wmi_extscan_start_cmd_fixed_param));
7717
7718 cmd->request_id = pstart->requestId;
7719 cmd->vdev_id = pstart->sessionId;
7720 cmd->base_period = pstart->basePeriod;
7721 cmd->num_buckets = nbuckets;
7722 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05307723 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307724 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05307725 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307726 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05307727#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05307728 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
7729 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05307730 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
7731 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
7732#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307733 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7734
7735 /* The max dwell time is retrieved from the first channel
7736 * of the first bucket and kept common for all channels.
7737 */
7738 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
7739 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
7740 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
7741 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
7742 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7743 cmd->max_table_usage = pstart->report_threshold_percent;
7744 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
7745
7746 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05307747 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307748 cmd->probe_delay = 0;
7749 cmd->probe_spacing_time = 0;
7750 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307751 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
7752 WMI_SCAN_ADD_CCK_RATES |
7753 WMI_SCAN_ADD_OFDM_RATES |
7754 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
7755 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05307756 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
7757 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05307758 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307759 cmd->num_ssids = 0;
7760 cmd->num_bssid = 0;
7761 cmd->ie_len = 0;
7762 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
7763 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
7764
7765 buf_ptr += sizeof(*cmd);
7766 WMITLV_SET_HDR(buf_ptr,
7767 WMITLV_TAG_ARRAY_FIXED_STRUC,
7768 num_ssid * sizeof(wmi_ssid));
7769 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
7770
7771 WMITLV_SET_HDR(buf_ptr,
7772 WMITLV_TAG_ARRAY_FIXED_STRUC,
7773 num_bssid * sizeof(wmi_mac_addr));
7774 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7775
7776 ie_len_with_pad = 0;
7777 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7778 ie_len_with_pad);
7779 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7780
7781 WMITLV_SET_HDR(buf_ptr,
7782 WMITLV_TAG_ARRAY_STRUC,
7783 nbuckets * sizeof(wmi_extscan_bucket));
7784 dest_blist = (wmi_extscan_bucket *)
7785 (buf_ptr + WMI_TLV_HDR_SIZE);
7786 src_bucket = pstart->buckets;
7787
7788 /* Retrieve scanning information from each bucket and
7789 * channels and send it to the target
7790 */
7791 for (i = 0; i < nbuckets; i++) {
7792 WMITLV_SET_HDR(dest_blist,
7793 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7794 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7795
7796 dest_blist->bucket_id = src_bucket->bucket;
7797 dest_blist->base_period_multiplier =
7798 src_bucket->period / base_period;
7799 dest_blist->min_period = src_bucket->period;
7800 dest_blist->max_period = src_bucket->max_period;
7801 dest_blist->exp_backoff = src_bucket->exponent;
7802 dest_blist->exp_max_step_count = src_bucket->step_count;
7803 dest_blist->channel_band = src_bucket->band;
7804 dest_blist->num_channels = src_bucket->numChannels;
7805 dest_blist->notify_extscan_events = 0;
7806
7807 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7808 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007809 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7810 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307811
7812 if (src_bucket->reportEvents &
7813 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7814 dest_blist->forwarding_flags =
7815 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7816 dest_blist->notify_extscan_events |=
7817 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7818 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7819 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7820 } else {
7821 dest_blist->forwarding_flags =
7822 WMI_EXTSCAN_NO_FORWARDING;
7823 }
7824
7825 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7826 dest_blist->configuration_flags = 0;
7827 else
7828 dest_blist->configuration_flags =
7829 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7830
Govind Singhb53420c2016-03-09 14:32:57 +05307831 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307832 __func__, dest_blist->notify_extscan_events,
7833 dest_blist->configuration_flags,
7834 dest_blist->forwarding_flags);
7835
7836 dest_blist->min_dwell_time_active =
7837 src_bucket->min_dwell_time_active;
7838 dest_blist->max_dwell_time_active =
7839 src_bucket->max_dwell_time_active;
7840 dest_blist->min_dwell_time_passive =
7841 src_bucket->min_dwell_time_passive;
7842 dest_blist->max_dwell_time_passive =
7843 src_bucket->max_dwell_time_passive;
7844 src_channel = src_bucket->channels;
7845
7846 /* save the channel info to later populate
7847 * the channel TLV
7848 */
7849 for (k = 0; k < src_bucket->numChannels; k++) {
7850 save_channel[count++].channel = src_channel->channel;
7851 src_channel++;
7852 }
7853 dest_blist++;
7854 src_bucket++;
7855 }
7856 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7857 WMITLV_SET_HDR(buf_ptr,
7858 WMITLV_TAG_ARRAY_STRUC,
7859 nchannels * sizeof(wmi_extscan_bucket_channel));
7860 dest_clist = (wmi_extscan_bucket_channel *)
7861 (buf_ptr + WMI_TLV_HDR_SIZE);
7862
7863 /* Active or passive scan is based on the bucket dwell time
7864 * and channel specific active,passive scans are not
7865 * supported yet
7866 */
7867 for (i = 0; i < nchannels; i++) {
7868 WMITLV_SET_HDR(dest_clist,
7869 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7870 WMITLV_GET_STRUCT_TLVLEN
7871 (wmi_extscan_bucket_channel));
7872 dest_clist->channel = save_channel[i].channel;
7873 dest_clist++;
7874 }
7875 buf_ptr += WMI_TLV_HDR_SIZE +
7876 (nchannels * sizeof(wmi_extscan_bucket_channel));
7877 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307878 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307879}
7880
7881/**
7882 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7883 * @wmi_handle: wmi handle
7884 * @pstart: scan command request params
7885 *
7886 * This function sends start extscan request to fw.
7887 *
7888 * Return: CDF Status.
7889 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307890static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307891 struct wifi_scan_cmd_req_params *pstart)
7892{
Govind Singhb53420c2016-03-09 14:32:57 +05307893 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307894 wmi_buf_t buf;
7895 int len;
7896
7897 /* Fill individual elements of extscan request and
7898 * TLV for buckets, channel list.
7899 */
Govind Singhb53420c2016-03-09 14:32:57 +05307900 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307901 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307902 if (qdf_status != QDF_STATUS_SUCCESS) {
7903 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7904 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307905 }
7906 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307907 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307908 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307909 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307910 }
7911 if (wmi_unified_cmd_send(wmi_handle, buf,
7912 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307913 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307914 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307915 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307916 }
7917
Govind Singhb53420c2016-03-09 14:32:57 +05307918 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307919}
7920
7921/**
7922 * send_plm_stop_cmd_tlv() - plm stop request
7923 * @wmi_handle: wmi handle
7924 * @plm: plm request parameters
7925 *
7926 * This function request FW to stop PLM.
7927 *
7928 * Return: CDF status
7929 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307930static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307931 const struct plm_req_params *plm)
7932{
7933 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7934 int32_t len;
7935 wmi_buf_t buf;
7936 uint8_t *buf_ptr;
7937 int ret;
7938
7939 len = sizeof(*cmd);
7940 buf = wmi_buf_alloc(wmi_handle, len);
7941 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307942 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7943 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307944 }
7945
7946 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7947
7948 buf_ptr = (uint8_t *) cmd;
7949
7950 WMITLV_SET_HDR(&cmd->tlv_header,
7951 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7952 WMITLV_GET_STRUCT_TLVLEN
7953 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7954
7955 cmd->vdev_id = plm->session_id;
7956
7957 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307958 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307959
7960 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7961 WMI_VDEV_PLMREQ_STOP_CMDID);
7962 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307963 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307964 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307965 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307966 }
7967
Govind Singhb53420c2016-03-09 14:32:57 +05307968 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307969}
7970
7971/**
7972 * send_plm_start_cmd_tlv() - plm start request
7973 * @wmi_handle: wmi handle
7974 * @plm: plm request parameters
7975 *
7976 * This function request FW to start PLM.
7977 *
7978 * Return: CDF status
7979 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307980static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307981 const struct plm_req_params *plm,
7982 uint32_t *gchannel_list)
7983{
7984 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7985 uint32_t *channel_list;
7986 int32_t len;
7987 wmi_buf_t buf;
7988 uint8_t *buf_ptr;
7989 uint8_t count;
7990 int ret;
7991
7992 /* TLV place holder for channel_list */
7993 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7994 len += sizeof(uint32_t) * plm->plm_num_ch;
7995
7996 buf = wmi_buf_alloc(wmi_handle, len);
7997 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307998 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7999 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308000 }
8001 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
8002
8003 buf_ptr = (uint8_t *) cmd;
8004
8005 WMITLV_SET_HDR(&cmd->tlv_header,
8006 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
8007 WMITLV_GET_STRUCT_TLVLEN
8008 (wmi_vdev_plmreq_start_cmd_fixed_param));
8009
8010 cmd->vdev_id = plm->session_id;
8011
8012 cmd->meas_token = plm->meas_token;
8013 cmd->dialog_token = plm->diag_token;
8014 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05308015 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308016 cmd->off_duration = plm->meas_duration;
8017 cmd->burst_cycle = plm->burst_len;
8018 cmd->tx_power = plm->desired_tx_pwr;
8019 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
8020 cmd->num_chans = plm->plm_num_ch;
8021
8022 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
8023
Govind Singhb53420c2016-03-09 14:32:57 +05308024 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
8025 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
8026 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
8027 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
8028 WMI_LOGD("off_duration: %d", cmd->off_duration);
8029 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
8030 WMI_LOGD("tx_power: %d", cmd->tx_power);
8031 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308032
8033 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8034 (cmd->num_chans * sizeof(uint32_t)));
8035
8036 buf_ptr += WMI_TLV_HDR_SIZE;
8037 if (cmd->num_chans) {
8038 channel_list = (uint32_t *) buf_ptr;
8039 for (count = 0; count < cmd->num_chans; count++) {
8040 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308041 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308042 channel_list[count] =
8043 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308044 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308045 }
8046 buf_ptr += cmd->num_chans * sizeof(uint32_t);
8047 }
8048
8049 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8050 WMI_VDEV_PLMREQ_START_CMDID);
8051 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308052 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308053 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308054 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308055 }
8056
Govind Singhb53420c2016-03-09 14:32:57 +05308057 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308058}
8059
8060/**
8061 * send_pno_stop_cmd_tlv() - PNO stop request
8062 * @wmi_handle: wmi handle
8063 * @vdev_id: vdev id
8064 *
8065 * This function request FW to stop ongoing PNO operation.
8066 *
8067 * Return: CDF status
8068 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308069static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308070{
8071 wmi_nlo_config_cmd_fixed_param *cmd;
8072 int32_t len = sizeof(*cmd);
8073 wmi_buf_t buf;
8074 uint8_t *buf_ptr;
8075 int ret;
8076
8077 /*
8078 * TLV place holder for array of structures nlo_configured_parameters
8079 * TLV place holder for array of uint32_t channel_list
8080 * TLV place holder for chnl prediction cfg
8081 */
8082 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
8083 buf = wmi_buf_alloc(wmi_handle, len);
8084 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308085 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8086 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308087 }
8088
8089 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8090 buf_ptr = (uint8_t *) cmd;
8091
8092 WMITLV_SET_HDR(&cmd->tlv_header,
8093 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8094 WMITLV_GET_STRUCT_TLVLEN
8095 (wmi_nlo_config_cmd_fixed_param));
8096
8097 cmd->vdev_id = vdev_id;
8098 cmd->flags = WMI_NLO_CONFIG_STOP;
8099 buf_ptr += sizeof(*cmd);
8100
8101 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8102 buf_ptr += WMI_TLV_HDR_SIZE;
8103
8104 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
8105 buf_ptr += WMI_TLV_HDR_SIZE;
8106
8107 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8108 buf_ptr += WMI_TLV_HDR_SIZE;
8109
8110
8111 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8112 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8113 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308114 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308115 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308116 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308117 }
8118
Govind Singhb53420c2016-03-09 14:32:57 +05308119 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308120}
8121
8122/**
Govind Singhccb0c272016-04-01 16:30:08 +05308123 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
8124 * @buf_ptr: Buffer passed by upper layers
8125 * @pno: Buffer to be sent to the firmware
8126 *
8127 * Copy the PNO Channel prediction configuration parameters
8128 * passed by the upper layers to a WMI format TLV and send it
8129 * down to the firmware.
8130 *
8131 * Return: None
8132 */
8133static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
8134 struct pno_scan_req_params *pno)
8135{
8136 nlo_channel_prediction_cfg *channel_prediction_cfg =
8137 (nlo_channel_prediction_cfg *) buf_ptr;
8138 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
8139 WMITLV_TAG_ARRAY_BYTE,
8140 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05308141#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05308142 channel_prediction_cfg->enable = pno->pno_channel_prediction;
8143 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
8144 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
8145 channel_prediction_cfg->full_scan_period_ms =
8146 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05308147#endif
Govind Singhccb0c272016-04-01 16:30:08 +05308148 buf_ptr += sizeof(nlo_channel_prediction_cfg);
8149 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
8150 channel_prediction_cfg->enable,
8151 channel_prediction_cfg->top_k_num,
8152 channel_prediction_cfg->stationary_threshold,
8153 channel_prediction_cfg->full_scan_period_ms);
8154}
8155
8156/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008157 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
8158 * @wmi_handle: wmi handle
8159 * @params: configuration parameters
8160 *
8161 * Return: QDF_STATUS
8162 */
8163static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
8164 struct nlo_mawc_params *params)
8165{
8166 wmi_buf_t buf = NULL;
8167 QDF_STATUS status;
8168 int len;
8169 uint8_t *buf_ptr;
8170 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
8171
8172 len = sizeof(*wmi_nlo_mawc_params);
8173 buf = wmi_buf_alloc(wmi_handle, len);
8174 if (!buf) {
8175 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8176 return QDF_STATUS_E_NOMEM;
8177 }
8178
8179 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8180 wmi_nlo_mawc_params =
8181 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
8182 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
8183 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
8184 WMITLV_GET_STRUCT_TLVLEN
8185 (wmi_nlo_configure_mawc_cmd_fixed_param));
8186 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
8187 if (params->enable)
8188 wmi_nlo_mawc_params->enable = 1;
8189 else
8190 wmi_nlo_mawc_params->enable = 0;
8191 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
8192 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
8193 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07008194 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
8195 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
8196 wmi_nlo_mawc_params->exp_backoff_ratio,
8197 wmi_nlo_mawc_params->init_scan_interval,
8198 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008199
8200 status = wmi_unified_cmd_send(wmi_handle, buf,
8201 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
8202 if (QDF_IS_STATUS_ERROR(status)) {
8203 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
8204 status);
8205 wmi_buf_free(buf);
8206 return QDF_STATUS_E_FAILURE;
8207 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008208
8209 return QDF_STATUS_SUCCESS;
8210}
8211
8212/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05308213 * send_pno_start_cmd_tlv() - PNO start request
8214 * @wmi_handle: wmi handle
8215 * @pno: PNO request
8216 *
8217 * This function request FW to start PNO request.
8218 * Request: CDF status
8219 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308220static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05308221 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308222{
8223 wmi_nlo_config_cmd_fixed_param *cmd;
8224 nlo_configured_parameters *nlo_list;
8225 uint32_t *channel_list;
8226 int32_t len;
8227 wmi_buf_t buf;
8228 uint8_t *buf_ptr;
8229 uint8_t i;
8230 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308231 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308232 connected_nlo_rssi_params *nlo_relative_rssi;
8233 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308234
8235 /*
8236 * TLV place holder for array nlo_configured_parameters(nlo_list)
8237 * TLV place holder for array of uint32_t channel_list
8238 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308239 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308240 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05308241 */
8242 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308243 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308244 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308245
Abhishek Singh5987b632017-03-03 22:09:07 +05308246 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308247 WMI_NLO_MAX_CHAN);
8248 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05308249 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308250 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308251 len += sizeof(enlo_candidate_score_params);
8252 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308253 len += sizeof(connected_nlo_rssi_params);
8254 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308255
8256 buf = wmi_buf_alloc(wmi_handle, len);
8257 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308258 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8259 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308260 }
8261
8262 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8263
8264 buf_ptr = (uint8_t *) cmd;
8265 WMITLV_SET_HDR(&cmd->tlv_header,
8266 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8267 WMITLV_GET_STRUCT_TLVLEN
8268 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05308269 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308270 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
8271
Govind Singh87542482016-06-08 19:40:11 +05308272#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05308273 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05308274 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05308275#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05308276 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05308277 cmd->active_dwell_time = pno->active_dwell_time;
8278 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308279
Manjeet Singhcd2dc062016-08-11 15:31:34 +05308280 if (pno->do_passive_scan)
8281 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308282 /* Copy scan interval */
8283 cmd->fast_scan_period = pno->fast_scan_period;
8284 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08008285 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308286 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07008287 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05308288 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308289 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05308290 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308291
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05308292 /* mac randomization attributes */
8293 if (pno->scan_random.randomize) {
8294 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
8295 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
8296 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
8297 pno->scan_random.mac_mask,
8298 &cmd->mac_addr,
8299 &cmd->mac_mask);
8300 }
8301
Govind Singh4eacd2b2016-03-07 14:24:22 +05308302 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
8303
Abhishek Singh5987b632017-03-03 22:09:07 +05308304 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05308305 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308306 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8307 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
8308 buf_ptr += WMI_TLV_HDR_SIZE;
8309
8310 nlo_list = (nlo_configured_parameters *) buf_ptr;
8311 for (i = 0; i < cmd->no_of_ssids; i++) {
8312 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
8313 WMITLV_TAG_ARRAY_BYTE,
8314 WMITLV_GET_STRUCT_TLVLEN
8315 (nlo_configured_parameters));
8316 /* Copy ssid and it's length */
8317 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05308318 nlo_list[i].ssid.ssid.ssid_len =
8319 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05308320 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05308321 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308322 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05308323 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308324 nlo_list[i].ssid.ssid.ssid_len,
8325 (char *)nlo_list[i].ssid.ssid.ssid,
8326 nlo_list[i].ssid.ssid.ssid_len);
8327
8328 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05308329 if (pno->networks_list[i].rssi_thresh &&
8330 pno->networks_list[i].rssi_thresh >
8331 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05308332 nlo_list[i].rssi_cond.valid = true;
8333 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05308334 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05308335 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308336 nlo_list[i].rssi_cond.rssi);
8337 }
8338 nlo_list[i].bcast_nw_type.valid = true;
8339 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05308340 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07008341 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308342 nlo_list[i].bcast_nw_type.bcast_nw_type);
8343 }
8344 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
8345
8346 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05308347 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308348 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05308349 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308350 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8351 (cmd->num_of_channels * sizeof(uint32_t)));
8352 buf_ptr += WMI_TLV_HDR_SIZE;
8353
8354 channel_list = (uint32_t *) buf_ptr;
8355 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05308356 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05308357
8358 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05308359 channel_list[i] =
8360 wlan_chan_to_freq(pno->
8361 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308362
Govind Singhb53420c2016-03-09 14:32:57 +05308363 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308364 }
8365 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
8366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8367 sizeof(nlo_channel_prediction_cfg));
8368 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05308369 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308370 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308371 /** TODO: Discrete firmware doesn't have command/option to configure
8372 * App IE which comes from wpa_supplicant as of part PNO start request.
8373 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308374 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
8375 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
8376 buf_ptr += sizeof(enlo_candidate_score_params);
8377
8378 if (ie_whitelist->white_list) {
8379 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
8380 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
8381 &cmd->num_vendor_oui,
8382 ie_whitelist);
8383 }
8384
8385 /* ie white list */
8386 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8387 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
8388 buf_ptr += WMI_TLV_HDR_SIZE;
8389 if (cmd->num_vendor_oui != 0) {
8390 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
8391 ie_whitelist->voui);
8392 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
8393 }
8394
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308395 if (pno->relative_rssi_set)
8396 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
8397
8398 /*
8399 * Firmware calculation using connected PNO params:
8400 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
8401 * deduction of rssi_pref for chosen band_pref and
8402 * addition of rssi_pref for remaining bands (other than chosen band).
8403 */
8404 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
8405 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
8406 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
8407 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
8408 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
8409 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
8410 buf_ptr += sizeof(*nlo_relative_rssi);
8411
8412 /*
8413 * As of now Kernel and Host supports one band and rssi preference.
8414 * Firmware supports array of band and rssi preferences
8415 */
8416 cmd->num_cnlo_band_pref = 1;
8417 WMITLV_SET_HDR(buf_ptr,
8418 WMITLV_TAG_ARRAY_STRUC,
8419 cmd->num_cnlo_band_pref *
8420 sizeof(connected_nlo_bss_band_rssi_pref));
8421 buf_ptr += WMI_TLV_HDR_SIZE;
8422
8423 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
8424 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
8425 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
8426 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
8427 WMITLV_GET_STRUCT_TLVLEN(
8428 connected_nlo_bss_band_rssi_pref));
8429 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
8430 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
8431 WMI_LOGI("band_pref %d, rssi_pref %d",
8432 nlo_band_rssi[i].band,
8433 nlo_band_rssi[i].rssi_pref);
8434 }
8435 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
8436
Govind Singh4eacd2b2016-03-07 14:24:22 +05308437 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8438 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8439 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308440 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308441 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308442 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308443 }
8444
Govind Singhb53420c2016-03-09 14:32:57 +05308445 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308446}
8447
8448/* send_set_ric_req_cmd_tlv() - set ric request element
8449 * @wmi_handle: wmi handle
8450 * @msg: message
8451 * @is_add_ts: is addts required
8452 *
8453 * This function sets ric request element for 11r roaming.
8454 *
8455 * Return: CDF status
8456 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308457static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308458 void *msg, uint8_t is_add_ts)
8459{
8460 wmi_ric_request_fixed_param *cmd;
8461 wmi_ric_tspec *tspec_param;
8462 wmi_buf_t buf;
8463 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05308464 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308465 int32_t len = sizeof(wmi_ric_request_fixed_param) +
8466 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
8467
8468 buf = wmi_buf_alloc(wmi_handle, len);
8469 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308470 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8471 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308472 }
8473
8474 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8475
8476 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
8477 WMITLV_SET_HDR(&cmd->tlv_header,
8478 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
8479 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
8480 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07008481 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308482 else
8483 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
8484 cmd->num_ric_request = 1;
8485 cmd->is_add_ric = is_add_ts;
8486
8487 buf_ptr += sizeof(wmi_ric_request_fixed_param);
8488 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
8489
8490 buf_ptr += WMI_TLV_HDR_SIZE;
8491 tspec_param = (wmi_ric_tspec *) buf_ptr;
8492 WMITLV_SET_HDR(&tspec_param->tlv_header,
8493 WMITLV_TAG_STRUC_wmi_ric_tspec,
8494 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
8495
8496 if (is_add_ts)
8497 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05308498#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05308499 else
8500 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05308501#endif
8502 if (ptspecIE) {
8503 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308504#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05308505 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
8506 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308507#else
Govind Singh87542482016-06-08 19:40:11 +05308508 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
8509 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308510#endif /* ANI_LITTLE_BIT_ENDIAN */
8511
Govind Singh87542482016-06-08 19:40:11 +05308512 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
8513 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
8514 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
8515 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
8516 tspec_param->inactivity_interval = ptspecIE->inactInterval;
8517 tspec_param->suspension_interval = ptspecIE->suspendInterval;
8518 tspec_param->svc_start_time = ptspecIE->svcStartTime;
8519 tspec_param->min_data_rate = ptspecIE->minDataRate;
8520 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
8521 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
8522 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
8523 tspec_param->delay_bound = ptspecIE->delayBound;
8524 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
8525 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
8526 tspec_param->medium_time = 0;
8527 }
Govind Singhb53420c2016-03-09 14:32:57 +05308528 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308529
8530 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8531 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308532 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308533 __func__);
8534 if (is_add_ts)
8535 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05308536 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308537 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308538 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308539 }
8540
Govind Singhb53420c2016-03-09 14:32:57 +05308541 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308542}
8543
8544/**
8545 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
8546 * @wmi_handle: wmi handle
8547 * @clear_req: ll stats clear request command params
8548 *
Govind Singhb53420c2016-03-09 14:32:57 +05308549 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308550 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308551static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308552 const struct ll_stats_clear_params *clear_req,
8553 uint8_t addr[IEEE80211_ADDR_LEN])
8554{
8555 wmi_clear_link_stats_cmd_fixed_param *cmd;
8556 int32_t len;
8557 wmi_buf_t buf;
8558 uint8_t *buf_ptr;
8559 int ret;
8560
8561 len = sizeof(*cmd);
8562 buf = wmi_buf_alloc(wmi_handle, len);
8563
8564 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308565 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8566 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308567 }
8568
8569 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308570 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308571 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
8572
8573 WMITLV_SET_HDR(&cmd->tlv_header,
8574 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
8575 WMITLV_GET_STRUCT_TLVLEN
8576 (wmi_clear_link_stats_cmd_fixed_param));
8577
8578 cmd->stop_stats_collection_req = clear_req->stop_req;
8579 cmd->vdev_id = clear_req->sta_id;
8580 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
8581
8582 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8583 &cmd->peer_macaddr);
8584
Govind Singhb53420c2016-03-09 14:32:57 +05308585 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
8586 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
8587 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
8588 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
8589 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308590 cmd->peer_macaddr); */
8591
8592 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8593 WMI_CLEAR_LINK_STATS_CMDID);
8594 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308595 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308596 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308597 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308598 }
8599
Govind Singhb53420c2016-03-09 14:32:57 +05308600 WMI_LOGD("Clear Link Layer Stats request sent successfully");
8601 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308602}
8603
8604/**
8605 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
8606 * @wmi_handle: wmi handle
8607 * @setReq: ll stats set request command params
8608 *
Govind Singhb53420c2016-03-09 14:32:57 +05308609 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308610 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308611static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308612 const struct ll_stats_set_params *set_req)
8613{
8614 wmi_start_link_stats_cmd_fixed_param *cmd;
8615 int32_t len;
8616 wmi_buf_t buf;
8617 uint8_t *buf_ptr;
8618 int ret;
8619
8620 len = sizeof(*cmd);
8621 buf = wmi_buf_alloc(wmi_handle, len);
8622
8623 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308624 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8625 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308626 }
8627
8628 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308629 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308630 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
8631
8632 WMITLV_SET_HDR(&cmd->tlv_header,
8633 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
8634 WMITLV_GET_STRUCT_TLVLEN
8635 (wmi_start_link_stats_cmd_fixed_param));
8636
8637 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
8638 cmd->aggressive_statistics_gathering =
8639 set_req->aggressive_statistics_gathering;
8640
Govind Singhb53420c2016-03-09 14:32:57 +05308641 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
8642 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
8643 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308644
8645 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8646 WMI_START_LINK_STATS_CMDID);
8647 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308648 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308649 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308650 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308651 }
8652
Govind Singhb53420c2016-03-09 14:32:57 +05308653 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308654}
8655
8656/**
8657 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
8658 * @wmi_handle:wmi handle
8659 * @get_req:ll stats get request command params
8660 * @addr: mac address
8661 *
Govind Singhb53420c2016-03-09 14:32:57 +05308662 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308663 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308664static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308665 const struct ll_stats_get_params *get_req,
8666 uint8_t addr[IEEE80211_ADDR_LEN])
8667{
8668 wmi_request_link_stats_cmd_fixed_param *cmd;
8669 int32_t len;
8670 wmi_buf_t buf;
8671 uint8_t *buf_ptr;
8672 int ret;
8673
8674 len = sizeof(*cmd);
8675 buf = wmi_buf_alloc(wmi_handle, len);
8676
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308677 if (!buf) {
8678 WMI_LOGE("%s: buf allocation failed", __func__);
8679 return QDF_STATUS_E_NOMEM;
8680 }
8681
Govind Singh4eacd2b2016-03-07 14:24:22 +05308682 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308683 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308684 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8685
8686 WMITLV_SET_HDR(&cmd->tlv_header,
8687 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8688 WMITLV_GET_STRUCT_TLVLEN
8689 (wmi_request_link_stats_cmd_fixed_param));
8690
8691 cmd->request_id = get_req->req_id;
8692 cmd->stats_type = get_req->param_id_mask;
8693 cmd->vdev_id = get_req->sta_id;
8694
8695 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8696 &cmd->peer_macaddr);
8697
Govind Singhb53420c2016-03-09 14:32:57 +05308698 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008699 WMI_LOGD("Request ID : %u", cmd->request_id);
8700 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308701 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8702 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308703
8704 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8705 WMI_REQUEST_LINK_STATS_CMDID);
8706 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308707 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308708 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308709 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308710 }
8711
Govind Singhb53420c2016-03-09 14:32:57 +05308712 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308713}
8714
Govind Singh4eacd2b2016-03-07 14:24:22 +05308715
Govind Singh20c5dac2016-03-07 15:33:31 +05308716/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308717 * send_congestion_cmd_tlv() - send request to fw to get CCA
8718 * @wmi_handle: wmi handle
8719 * @vdev_id: vdev id
8720 *
8721 * Return: CDF status
8722 */
8723static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05308724 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308725{
8726 wmi_buf_t buf;
8727 wmi_request_stats_cmd_fixed_param *cmd;
8728 uint8_t len;
8729 uint8_t *buf_ptr;
8730
8731 len = sizeof(*cmd);
8732 buf = wmi_buf_alloc(wmi_handle, len);
8733 if (!buf) {
8734 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8735 return QDF_STATUS_E_FAILURE;
8736 }
8737
8738 buf_ptr = wmi_buf_data(buf);
8739 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8740 WMITLV_SET_HDR(&cmd->tlv_header,
8741 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8742 WMITLV_GET_STRUCT_TLVLEN
8743 (wmi_request_stats_cmd_fixed_param));
8744
8745 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8746 cmd->vdev_id = vdev_id;
8747 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8748 cmd->vdev_id, cmd->stats_id);
8749
8750 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8751 WMI_REQUEST_STATS_CMDID)) {
8752 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8753 __func__);
8754 wmi_buf_free(buf);
8755 return QDF_STATUS_E_FAILURE;
8756 }
8757
8758 return QDF_STATUS_SUCCESS;
8759}
8760
8761/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308762 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8763 * @wmi_handle: wmi handle
8764 * @rssi_req: get RSSI request
8765 *
8766 * Return: CDF status
8767 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308768static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308769{
8770 wmi_buf_t buf;
8771 wmi_request_stats_cmd_fixed_param *cmd;
8772 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8773
8774 buf = wmi_buf_alloc(wmi_handle, len);
8775 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308776 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8777 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308778 }
8779
8780 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8781 WMITLV_SET_HDR(&cmd->tlv_header,
8782 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8783 WMITLV_GET_STRUCT_TLVLEN
8784 (wmi_request_stats_cmd_fixed_param));
8785 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8786 if (wmi_unified_cmd_send
8787 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308788 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308789 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308790 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308791 }
8792
Govind Singhb53420c2016-03-09 14:32:57 +05308793 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308794}
8795
8796/**
8797 * send_snr_cmd_tlv() - get RSSI from fw
8798 * @wmi_handle: wmi handle
8799 * @vdev_id: vdev id
8800 *
8801 * Return: CDF status
8802 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308803static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308804{
8805 wmi_buf_t buf;
8806 wmi_request_stats_cmd_fixed_param *cmd;
8807 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8808
8809 buf = wmi_buf_alloc(wmi_handle, len);
8810 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308811 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8812 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308813 }
8814
8815 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8816 cmd->vdev_id = vdev_id;
8817
8818 WMITLV_SET_HDR(&cmd->tlv_header,
8819 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8820 WMITLV_GET_STRUCT_TLVLEN
8821 (wmi_request_stats_cmd_fixed_param));
8822 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8823 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8824 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308825 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308826 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308827 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308828 }
8829
Govind Singhb53420c2016-03-09 14:32:57 +05308830 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308831}
8832
8833/**
8834 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8835 * @wmi_handle: wmi handle
8836 * @link_status: get link params
8837 *
8838 * Return: CDF status
8839 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308840static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308841 struct link_status_params *link_status)
8842{
8843 wmi_buf_t buf;
8844 wmi_request_stats_cmd_fixed_param *cmd;
8845 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8846
8847 buf = wmi_buf_alloc(wmi_handle, len);
8848 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308849 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8850 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308851 }
8852
8853 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8854 WMITLV_SET_HDR(&cmd->tlv_header,
8855 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8856 WMITLV_GET_STRUCT_TLVLEN
8857 (wmi_request_stats_cmd_fixed_param));
8858 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8859 cmd->vdev_id = link_status->session_id;
8860 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8861 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308862 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308863 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308864 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308865 }
8866
Govind Singhb53420c2016-03-09 14:32:57 +05308867 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308868}
8869
Govind Singh20c5dac2016-03-07 15:33:31 +05308870/**
8871 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8872 * @wmi_handle: wmi handle
8873 * @ta_dhcp_ind: DHCP indication parameter
8874 *
8875 * Return: CDF Status
8876 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308877static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308878 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8879{
Govind Singh67922e82016-04-01 16:48:57 +05308880 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308881 wmi_buf_t buf = NULL;
8882 uint8_t *buf_ptr;
8883 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8884 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8885
8886
8887 buf = wmi_buf_alloc(wmi_handle, len);
8888 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308889 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8890 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308891 }
8892
8893 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8894 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8895 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8896 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8897 WMITLV_GET_STRUCT_TLVLEN
8898 (wmi_peer_set_param_cmd_fixed_param));
8899
8900 /* fill in values */
8901 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8902 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8903 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308904 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308905 &ta_dhcp_ind->peer_macaddr,
8906 sizeof(ta_dhcp_ind->peer_macaddr));
8907
8908 status = wmi_unified_cmd_send(wmi_handle, buf,
8909 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308910 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308911 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308912 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308913 wmi_buf_free(buf);
8914 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308915
Govind Singh67922e82016-04-01 16:48:57 +05308916 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308917}
8918
8919/**
8920 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8921 * @wmi_handle: wmi handle
8922 * @pLinkSpeed: link speed info
8923 *
8924 * Return: CDF status
8925 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308926static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308927 wmi_mac_addr peer_macaddr)
8928{
8929 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8930 wmi_buf_t wmi_buf;
8931 uint32_t len;
8932 uint8_t *buf_ptr;
8933
8934 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8935 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8936 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308937 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8938 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308939 }
8940 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8941
8942 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8943 WMITLV_SET_HDR(&cmd->tlv_header,
8944 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8945 WMITLV_GET_STRUCT_TLVLEN
8946 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8947
8948 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308949 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308950 &peer_macaddr,
8951 sizeof(peer_macaddr));
8952
8953
8954 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8955 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308956 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308957 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308958 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308959 }
Govind Singhb53420c2016-03-09 14:32:57 +05308960 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308961}
8962
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308963#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308964/**
8965 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8966 * @wmi_handle: wmi handler
8967 * @egap_params: pointer to egap_params
8968 *
8969 * Return: 0 for success, otherwise appropriate error code
8970 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308971static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308972 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308973{
8974 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8975 wmi_buf_t buf;
8976 int32_t err;
8977
8978 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8979 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308980 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8981 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308982 }
8983 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8984 WMITLV_SET_HDR(&cmd->tlv_header,
8985 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8986 WMITLV_GET_STRUCT_TLVLEN(
8987 wmi_ap_ps_egap_param_cmd_fixed_param));
8988
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308989 cmd->enable = egap_params->host_enable_egap;
8990 cmd->inactivity_time = egap_params->egap_inactivity_time;
8991 cmd->wait_time = egap_params->egap_wait_time;
8992 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308993 err = wmi_unified_cmd_send(wmi_handle, buf,
8994 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8995 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308996 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308997 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308998 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308999 }
9000
Govind Singhb53420c2016-03-09 14:32:57 +05309001 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309002}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05309003#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05309004
9005/**
9006 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
9007 * @wmi_handl: wmi handle
9008 * @cmd: Profiling command index
9009 * @value1: parameter1 value
9010 * @value2: parameter2 value
9011 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309012 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309013 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309014static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309015 uint32_t cmd, uint32_t value1, uint32_t value2)
9016{
9017 wmi_buf_t buf;
9018 int32_t len = 0;
9019 int ret;
9020 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
9021 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
9022 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
9023 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
9024
9025 switch (cmd) {
9026 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
9027 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
9028 buf = wmi_buf_alloc(wmi_handle, len);
9029 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309030 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309031 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309032 }
9033 prof_trig_cmd =
9034 (wmi_wlan_profile_trigger_cmd_fixed_param *)
9035 wmi_buf_data(buf);
9036 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
9037 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
9038 WMITLV_GET_STRUCT_TLVLEN
9039 (wmi_wlan_profile_trigger_cmd_fixed_param));
9040 prof_trig_cmd->enable = value1;
9041 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9042 WMI_WLAN_PROFILE_TRIGGER_CMDID);
9043 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309044 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309045 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309046 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309047 return ret;
9048 }
9049 break;
9050
9051 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
9052 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
9053 buf = wmi_buf_alloc(wmi_handle, len);
9054 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309055 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309056 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309057 }
9058 profile_getdata_cmd =
9059 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
9060 wmi_buf_data(buf);
9061 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
9062 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
9063 WMITLV_GET_STRUCT_TLVLEN
9064 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
9065 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9066 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
9067 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309068 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309069 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309070 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309071 return ret;
9072 }
9073 break;
9074
9075 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
9076 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
9077 buf = wmi_buf_alloc(wmi_handle, len);
9078 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309079 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309080 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309081 }
9082 hist_intvl_cmd =
9083 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
9084 wmi_buf_data(buf);
9085 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
9086 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
9087 WMITLV_GET_STRUCT_TLVLEN
9088 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
9089 hist_intvl_cmd->profile_id = value1;
9090 hist_intvl_cmd->value = value2;
9091 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9092 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
9093 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309094 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309095 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309096 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309097 return ret;
9098 }
9099 break;
9100
9101 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
9102 len =
9103 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
9104 buf = wmi_buf_alloc(wmi_handle, len);
9105 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309106 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309107 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309108 }
9109 profile_enable_cmd =
9110 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
9111 wmi_buf_data(buf);
9112 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
9113 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
9114 WMITLV_GET_STRUCT_TLVLEN
9115 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
9116 profile_enable_cmd->profile_id = value1;
9117 profile_enable_cmd->enable = value2;
9118 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9119 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
9120 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309121 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309122 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309123 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309124 return ret;
9125 }
9126 break;
9127
9128 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309129 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309130 break;
9131 }
9132
9133 return 0;
9134}
9135
Paul Zhang92ab8d32017-12-08 16:08:00 +08009136static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
9137 struct wlm_latency_level_param *params)
9138{
9139 wmi_wlm_config_cmd_fixed_param *cmd;
9140 wmi_buf_t buf;
9141 uint32_t len = sizeof(*cmd);
9142 static uint32_t ll[4] = {100, 60, 40, 20};
9143
9144 buf = wmi_buf_alloc(wmi_handle, len);
9145 if (!buf) {
9146 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9147 return QDF_STATUS_E_NOMEM;
9148 }
9149 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
9150 WMITLV_SET_HDR(&cmd->tlv_header,
9151 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
9152 WMITLV_GET_STRUCT_TLVLEN
9153 (wmi_wlm_config_cmd_fixed_param));
9154 cmd->vdev_id = params->vdev_id;
9155 cmd->latency_level = params->wlm_latency_level;
9156 cmd->ul_latency = ll[params->wlm_latency_level];
9157 cmd->dl_latency = ll[params->wlm_latency_level];
9158 cmd->flags = params->wlm_latency_flags;
9159 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9160 WMI_WLM_CONFIG_CMDID)) {
9161 WMI_LOGE("%s: Failed to send setting latency config command",
9162 __func__);
9163 wmi_buf_free(buf);
9164 return QDF_STATUS_E_FAILURE;
9165 }
9166
9167 return 0;
9168}
Govind Singh20c5dac2016-03-07 15:33:31 +05309169/**
9170 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
9171 * @wmi_handle: wmi handle
9172 * @vdev_id: vdev id
9173 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309174 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309175 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309176static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309177{
9178 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
9179 wmi_buf_t buf;
9180 int32_t len = sizeof(*cmd);
9181
Govind Singhb53420c2016-03-09 14:32:57 +05309182 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309183 buf = wmi_buf_alloc(wmi_handle, len);
9184 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309185 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309186 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309187 }
9188 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
9189 wmi_buf_data(buf);
9190 WMITLV_SET_HDR(&cmd->tlv_header,
9191 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
9192 WMITLV_GET_STRUCT_TLVLEN
9193 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
9194 cmd->vdev_id = vdev_id;
9195 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
9196 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9197 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309198 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309199 __func__);
9200 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309201 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309202 }
9203
9204 return 0;
9205}
9206
9207/**
9208 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
9209 * @wmi_handle: wmi handle
9210 * @vdev_id: vdev id
9211 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309212 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309213 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309214static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309215 uint8_t vdev_id)
9216{
9217 wmi_csa_offload_enable_cmd_fixed_param *cmd;
9218 wmi_buf_t buf;
9219 int32_t len = sizeof(*cmd);
9220
Govind Singhb53420c2016-03-09 14:32:57 +05309221 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309222 buf = wmi_buf_alloc(wmi_handle, len);
9223 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309224 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309225 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309226 }
9227 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
9228 WMITLV_SET_HDR(&cmd->tlv_header,
9229 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
9230 WMITLV_GET_STRUCT_TLVLEN
9231 (wmi_csa_offload_enable_cmd_fixed_param));
9232 cmd->vdev_id = vdev_id;
9233 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
9234 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9235 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309236 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309237 __func__);
9238 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309239 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309240 }
9241
9242 return 0;
9243}
9244
Naveen Rawat42cd1e62017-05-13 15:56:57 -07009245#ifdef WLAN_FEATURE_CIF_CFR
9246/**
9247 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
9248 * @wmi_handle: wmi handle
9249 * @data_len: len of dma cfg req
9250 * @data: dma cfg req
9251 *
9252 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9253 */
9254static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9255 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
9256{
9257 wmi_buf_t buf;
9258 uint8_t *cmd;
9259 QDF_STATUS ret;
9260
9261 WMITLV_SET_HDR(cfg,
9262 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
9263 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
9264
9265 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
9266 if (!buf) {
9267 WMI_LOGE(FL("wmi_buf_alloc failed"));
9268 return QDF_STATUS_E_FAILURE;
9269 }
9270
9271 cmd = (uint8_t *) wmi_buf_data(buf);
9272 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
9273 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
9274 sizeof(*cfg));
9275 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
9276 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
9277 if (QDF_IS_STATUS_ERROR(ret)) {
9278 WMI_LOGE(FL(":wmi cmd send failed"));
9279 wmi_buf_free(buf);
9280 }
9281
9282 return ret;
9283}
9284#endif
9285
Govind Singh20c5dac2016-03-07 15:33:31 +05309286/**
Sathish Kumarf396c722017-11-17 17:30:41 +05309287 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
9288 * @wmi_handle: wmi handle
9289 * @data_len: len of dma cfg req
9290 * @data: dma cfg req
9291 *
9292 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9293 */
9294static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9295 struct direct_buf_rx_cfg_req *cfg)
9296{
9297 wmi_buf_t buf;
9298 wmi_dma_ring_cfg_req_fixed_param *cmd;
9299 QDF_STATUS ret;
9300 int32_t len = sizeof(*cmd);
9301
9302 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9303 if (!buf) {
9304 WMI_LOGE(FL("wmi_buf_alloc failed"));
9305 return QDF_STATUS_E_FAILURE;
9306 }
9307
9308 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
9309
9310 WMITLV_SET_HDR(&cmd->tlv_header,
9311 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
9312 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
9313
9314 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9315 cfg->pdev_id);
9316 cmd->mod_id = cfg->mod_id;
9317 cmd->base_paddr_lo = cfg->base_paddr_lo;
9318 cmd->base_paddr_hi = cfg->base_paddr_hi;
9319 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
9320 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
9321 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
9322 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
9323 cmd->num_elems = cfg->num_elems;
9324 cmd->buf_size = cfg->buf_size;
9325 cmd->num_resp_per_event = cfg->num_resp_per_event;
9326 cmd->event_timeout_ms = cfg->event_timeout_ms;
9327
9328 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
9329 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
9330 "head idx paddr hi %x tail idx paddr lo %x"
9331 "tail idx addr hi %x num elems %d buf size %d num resp %d"
9332 "event timeout %d\n", __func__, cmd->pdev_id,
9333 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
9334 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
9335 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
9336 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
9337 cmd->event_timeout_ms);
9338 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9339 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
9340 if (QDF_IS_STATUS_ERROR(ret)) {
9341 WMI_LOGE(FL(":wmi cmd send failed"));
9342 wmi_buf_free(buf);
9343 }
9344
9345 return ret;
9346}
9347
9348/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009349 * send_start_11d_scan_cmd_tlv() - start 11d scan request
9350 * @wmi_handle: wmi handle
9351 * @start_11d_scan: 11d scan start request parameters
9352 *
9353 * This function request FW to start 11d scan.
9354 *
9355 * Return: QDF status
9356 */
9357static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9358 struct reg_start_11d_scan_req *start_11d_scan)
9359{
9360 wmi_11d_scan_start_cmd_fixed_param *cmd;
9361 int32_t len;
9362 wmi_buf_t buf;
9363 int ret;
9364
9365 len = sizeof(*cmd);
9366 buf = wmi_buf_alloc(wmi_handle, len);
9367 if (!buf) {
9368 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9369 return QDF_STATUS_E_NOMEM;
9370 }
9371
9372 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
9373
9374 WMITLV_SET_HDR(&cmd->tlv_header,
9375 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
9376 WMITLV_GET_STRUCT_TLVLEN
9377 (wmi_11d_scan_start_cmd_fixed_param));
9378
9379 cmd->vdev_id = start_11d_scan->vdev_id;
9380 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
9381 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
9382
9383 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
9384
9385 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9386 WMI_11D_SCAN_START_CMDID);
9387 if (ret) {
9388 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
9389 wmi_buf_free(buf);
9390 return QDF_STATUS_E_FAILURE;
9391 }
9392
9393 return QDF_STATUS_SUCCESS;
9394}
9395
9396/**
9397 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
9398 * @wmi_handle: wmi handle
9399 * @start_11d_scan: 11d scan stop request parameters
9400 *
9401 * This function request FW to stop 11d scan.
9402 *
9403 * Return: QDF status
9404 */
9405static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9406 struct reg_stop_11d_scan_req *stop_11d_scan)
9407{
9408 wmi_11d_scan_stop_cmd_fixed_param *cmd;
9409 int32_t len;
9410 wmi_buf_t buf;
9411 int ret;
9412
9413 len = sizeof(*cmd);
9414 buf = wmi_buf_alloc(wmi_handle, len);
9415 if (!buf) {
9416 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9417 return QDF_STATUS_E_NOMEM;
9418 }
9419
9420 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
9421
9422 WMITLV_SET_HDR(&cmd->tlv_header,
9423 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
9424 WMITLV_GET_STRUCT_TLVLEN
9425 (wmi_11d_scan_stop_cmd_fixed_param));
9426
9427 cmd->vdev_id = stop_11d_scan->vdev_id;
9428
9429 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
9430
9431 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9432 WMI_11D_SCAN_STOP_CMDID);
9433 if (ret) {
9434 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
9435 wmi_buf_free(buf);
9436 return QDF_STATUS_E_FAILURE;
9437 }
9438
9439 return QDF_STATUS_SUCCESS;
9440}
9441
9442/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309443 * send_start_oem_data_cmd_tlv() - start OEM data request to target
9444 * @wmi_handle: wmi handle
9445 * @startOemDataReq: start request params
9446 *
9447 * Return: CDF status
9448 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309449static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07009450 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05309451 uint8_t *data)
9452{
9453 wmi_buf_t buf;
9454 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309455 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309456
9457 buf = wmi_buf_alloc(wmi_handle,
9458 (data_len + WMI_TLV_HDR_SIZE));
9459 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309460 WMI_LOGE(FL("wmi_buf_alloc failed"));
9461 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309462 }
9463
9464 cmd = (uint8_t *) wmi_buf_data(buf);
9465
9466 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
9467 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309468 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05309469 data_len);
9470
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08009471 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309472 data_len);
9473
9474 ret = wmi_unified_cmd_send(wmi_handle, buf,
9475 (data_len +
9476 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
9477
Govind Singh67922e82016-04-01 16:48:57 +05309478 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309479 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309480 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309481 }
9482
Govind Singh67922e82016-04-01 16:48:57 +05309483 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309484}
9485
9486/**
9487 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
9488 * @wmi_handle: wmi handle
9489 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
9490 *
9491 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
9492 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
9493 * to firmware based on phyerr filtering
9494 * offload status.
9495 *
9496 * Return: 1 success, 0 failure
9497 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309498static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05309499send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
9500 bool dfs_phyerr_filter_offload)
9501{
9502 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
9503 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
9504 wmi_buf_t buf;
9505 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05309506 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309507
9508
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07009509 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05309510 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309511 __func__);
9512 len = sizeof(*disable_phyerr_offload_cmd);
9513 buf = wmi_buf_alloc(wmi_handle, len);
9514 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309515 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309516 return 0;
9517 }
9518 disable_phyerr_offload_cmd =
9519 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
9520 wmi_buf_data(buf);
9521
9522 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
9523 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
9524 WMITLV_GET_STRUCT_TLVLEN
9525 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
9526
9527 /*
9528 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
9529 * to the firmware to disable the phyerror
9530 * filtering offload.
9531 */
9532 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9533 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309534 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309535 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309536 __func__, ret);
9537 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309538 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309539 }
Govind Singhb53420c2016-03-09 14:32:57 +05309540 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309541 __func__);
9542 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05309543 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309544 __func__);
9545
9546 len = sizeof(*enable_phyerr_offload_cmd);
9547 buf = wmi_buf_alloc(wmi_handle, len);
9548 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309549 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9550 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309551 }
9552
9553 enable_phyerr_offload_cmd =
9554 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
9555 wmi_buf_data(buf);
9556
9557 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
9558 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
9559 WMITLV_GET_STRUCT_TLVLEN
9560 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
9561
9562 /*
9563 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
9564 * to the firmware to enable the phyerror
9565 * filtering offload.
9566 */
9567 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9568 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
9569
Govind Singh67922e82016-04-01 16:48:57 +05309570 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309571 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309572 __func__, ret);
9573 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309574 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309575 }
Govind Singhb53420c2016-03-09 14:32:57 +05309576 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309577 __func__);
9578 }
9579
Govind Singhb53420c2016-03-09 14:32:57 +05309580 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309581}
9582
Naveen Rawata5817e72017-10-26 18:50:19 -07009583/**
9584 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
9585 * will wake up host after specified time is elapsed
9586 * @wmi_handle: wmi handle
9587 * @vdev_id: vdev id
9588 * @cookie: value to identify reason why host set up wake call.
9589 * @time: time in ms
9590 *
9591 * Return: QDF status
9592 */
9593static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9594 uint8_t vdev_id, uint32_t cookie, uint32_t time)
9595{
9596 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
9597 wmi_buf_t buf;
9598 uint8_t *buf_ptr;
9599 int32_t len;
9600 int ret;
9601
9602 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
9603 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
9604 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
9605 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
9606 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05309607 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
9608 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07009609
9610 buf = wmi_buf_alloc(wmi_handle, len);
9611 if (!buf) {
9612 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9613 return QDF_STATUS_E_NOMEM;
9614 }
9615
9616 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9617 buf_ptr = (uint8_t *) cmd;
9618
9619 WMITLV_SET_HDR(&cmd->tlv_header,
9620 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
9621 WMITLV_GET_STRUCT_TLVLEN
9622 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
9623 cmd->vdev_id = vdev_id;
9624 cmd->pattern_id = cookie,
9625 cmd->pattern_type = WOW_TIMER_PATTERN;
9626 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
9627
9628 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
9629 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9630 buf_ptr += WMI_TLV_HDR_SIZE;
9631
9632 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
9633 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9634 buf_ptr += WMI_TLV_HDR_SIZE;
9635
9636 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
9637 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9638 buf_ptr += WMI_TLV_HDR_SIZE;
9639
9640 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
9641 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9642 buf_ptr += WMI_TLV_HDR_SIZE;
9643
9644 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05309645 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07009646 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05309647 *((uint32_t *) buf_ptr) = time;
9648 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07009649
9650 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05309651 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07009652 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05309653 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07009654
9655 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
9656 __func__, time, vdev_id);
9657
9658 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9659 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9660 if (ret) {
9661 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9662 __func__);
9663 wmi_buf_free(buf);
9664 return QDF_STATUS_E_FAILURE;
9665 }
9666
9667 return QDF_STATUS_SUCCESS;
9668}
9669
Govind Singh20c5dac2016-03-07 15:33:31 +05309670#if !defined(REMOVE_PKT_LOG)
9671/**
9672 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9673 * @wmi_handle: wmi handle
9674 * @pktlog_event: pktlog event
9675 * @cmd_id: pktlog cmd id
9676 *
9677 * Return: CDF status
9678 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309679static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309680 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309681 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309682{
9683 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9684 WMI_CMD_ID CMD_ID;
9685 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9686 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9687 int len = 0;
9688 wmi_buf_t buf;
9689
9690 PKTLOG_EVENT = pktlog_event;
9691 CMD_ID = cmd_id;
9692
9693 switch (CMD_ID) {
9694 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9695 len = sizeof(*cmd);
9696 buf = wmi_buf_alloc(wmi_handle, len);
9697 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309698 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9699 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309700 }
9701 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9702 wmi_buf_data(buf);
9703 WMITLV_SET_HDR(&cmd->tlv_header,
9704 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9705 WMITLV_GET_STRUCT_TLVLEN
9706 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9707 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309708 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9709 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309710 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9711 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309712 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9713 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309714 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309715 goto wmi_send_failed;
9716 }
9717 break;
9718 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9719 len = sizeof(*disable_cmd);
9720 buf = wmi_buf_alloc(wmi_handle, len);
9721 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309722 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9723 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309724 }
9725 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9726 wmi_buf_data(buf);
9727 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9728 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9729 WMITLV_GET_STRUCT_TLVLEN
9730 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309731 disable_cmd->pdev_id =
9732 wmi_handle->ops->convert_pdev_id_host_to_target(
9733 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309734 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9735 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309736 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309737 goto wmi_send_failed;
9738 }
9739 break;
9740 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309741 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309742 break;
9743 }
9744
Govind Singhb53420c2016-03-09 14:32:57 +05309745 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309746
9747wmi_send_failed:
9748 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309749 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309750}
9751#endif /* REMOVE_PKT_LOG */
9752
9753/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309754 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9755 * @wmi_handle: wmi handle
9756 * @ptrn_id: pattern id
9757 * @vdev_id: vdev id
9758 *
9759 * Return: CDF status
9760 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309761static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9762 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309763{
9764 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9765 wmi_buf_t buf;
9766 int32_t len;
9767 int ret;
9768
9769 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9770
9771
9772 buf = wmi_buf_alloc(wmi_handle, len);
9773 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309774 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9775 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309776 }
9777
9778 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9779
9780 WMITLV_SET_HDR(&cmd->tlv_header,
9781 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9782 WMITLV_GET_STRUCT_TLVLEN(
9783 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9784 cmd->vdev_id = vdev_id;
9785 cmd->pattern_id = ptrn_id;
9786 cmd->pattern_type = WOW_BITMAP_PATTERN;
9787
Govind Singhb53420c2016-03-09 14:32:57 +05309788 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309789 cmd->pattern_id, vdev_id);
9790
9791 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9792 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9793 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309794 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309795 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309796 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309797 }
9798
Govind Singhb53420c2016-03-09 14:32:57 +05309799 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309800}
9801
9802/**
9803 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9804 * @wmi_handle: wmi handle
9805 *
9806 * Sends host wakeup indication to FW. On receiving this indication,
9807 * FW will come out of WOW.
9808 *
9809 * Return: CDF status
9810 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309811static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309812{
9813 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9814 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309815 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309816 int32_t len;
9817 int ret;
9818
9819 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9820
9821 buf = wmi_buf_alloc(wmi_handle, len);
9822 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309823 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9824 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309825 }
9826
9827 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9828 wmi_buf_data(buf);
9829 WMITLV_SET_HDR(&cmd->tlv_header,
9830 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9831 WMITLV_GET_STRUCT_TLVLEN
9832 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9833
9834
9835 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9836 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9837 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309838 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309839 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309840 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309841 }
9842
Govind Singhb53420c2016-03-09 14:32:57 +05309843 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309844}
9845
9846/**
9847 * send_del_ts_cmd_tlv() - send DELTS request to fw
9848 * @wmi_handle: wmi handle
9849 * @msg: delts params
9850 *
9851 * Return: CDF status
9852 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309853static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309854 uint8_t ac)
9855{
9856 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9857 wmi_buf_t buf;
9858 int32_t len = sizeof(*cmd);
9859
9860 buf = wmi_buf_alloc(wmi_handle, len);
9861 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309862 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9863 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309864 }
9865 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9866 WMITLV_SET_HDR(&cmd->tlv_header,
9867 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9868 WMITLV_GET_STRUCT_TLVLEN
9869 (wmi_vdev_wmm_delts_cmd_fixed_param));
9870 cmd->vdev_id = vdev_id;
9871 cmd->ac = ac;
9872
Govind Singhb53420c2016-03-09 14:32:57 +05309873 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309874 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9875 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9876 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309877 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309878 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309879 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309880 }
9881
Govind Singhb53420c2016-03-09 14:32:57 +05309882 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309883}
9884
9885/**
9886 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9887 * @wmi_handle: handle to wmi
9888 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9889 *
Govind Singhb53420c2016-03-09 14:32:57 +05309890 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309891 * ADD_TS requestes to firmware in loop for all the ACs with
9892 * active flow.
9893 *
9894 * Return: CDF status
9895 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309896static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309897 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9898{
9899 int i = 0;
9900 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9901 wmi_buf_t buf;
9902 int32_t len = sizeof(*cmd);
9903
9904 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9905 /* if flow in this AC is active */
9906 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9907 /*
9908 * as per implementation of wma_add_ts_req() we
9909 * are not waiting any response from firmware so
9910 * apart from sending ADDTS to firmware just send
9911 * success to upper layers
9912 */
Govind Singhb53420c2016-03-09 14:32:57 +05309913 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309914
9915 buf = wmi_buf_alloc(wmi_handle, len);
9916 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309917 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9918 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309919 }
9920 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9921 wmi_buf_data(buf);
9922 WMITLV_SET_HDR(&cmd->tlv_header,
9923 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9924 WMITLV_GET_STRUCT_TLVLEN
9925 (wmi_vdev_wmm_addts_cmd_fixed_param));
9926 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9927 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309928 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309929 traffic.userPrio);
9930 cmd->medium_time_us =
9931 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9932 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309933 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309934 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9935 cmd->medium_time_us, cmd->downgrade_type);
9936 if (wmi_unified_cmd_send
9937 (wmi_handle, buf, len,
9938 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309939 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309940 __func__);
9941 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309942 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309943 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309944 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309945 }
9946 }
9947 }
9948
Govind Singhb53420c2016-03-09 14:32:57 +05309949 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309950}
9951
9952/**
9953 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9954 * @wmi_handle: wmi handle
9955 * @msg: ADDTS params
9956 *
9957 * Return: CDF status
9958 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309959static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309960 struct add_ts_param *msg)
9961{
9962 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9963 wmi_buf_t buf;
9964 int32_t len = sizeof(*cmd);
9965
Govind Singhb53420c2016-03-09 14:32:57 +05309966 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309967
9968 buf = wmi_buf_alloc(wmi_handle, len);
9969 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309970 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9971 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309972 }
9973 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9974 WMITLV_SET_HDR(&cmd->tlv_header,
9975 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9976 WMITLV_GET_STRUCT_TLVLEN
9977 (wmi_vdev_wmm_addts_cmd_fixed_param));
9978 cmd->vdev_id = msg->sme_session_id;
9979 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9980 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9981 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309982 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309983 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9984 cmd->downgrade_type, __func__, __LINE__);
9985 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9986 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309987 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9988 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309989 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309990 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309991 }
9992
Govind Singhb53420c2016-03-09 14:32:57 +05309993 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309994}
9995
9996/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309997 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9998 * @wmi_handle: wmi handle
9999 * @pAddPeriodicTxPtrnParams: tx ptrn params
10000 *
10001 * Retrun: CDF status
10002 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010003static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010004 struct periodic_tx_pattern *
10005 pAddPeriodicTxPtrnParams,
10006 uint8_t vdev_id)
10007{
10008 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10009 wmi_buf_t wmi_buf;
10010 uint32_t len;
10011 uint8_t *buf_ptr;
10012 uint32_t ptrn_len, ptrn_len_aligned;
10013 int j;
10014
10015 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
10016 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
10017 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
10018 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
10019
10020 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10021 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010022 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10023 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010024 }
10025
10026 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10027
10028 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
10029 WMITLV_SET_HDR(&cmd->tlv_header,
10030 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10031 WMITLV_GET_STRUCT_TLVLEN
10032 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10033
10034 /* Pass the pattern id to delete for the corresponding vdev id */
10035 cmd->vdev_id = vdev_id;
10036 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
10037 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
10038 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
10039
10040 /* Pattern info */
10041 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10042 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
10043 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010044 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010045 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +053010046 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +053010047
Govind Singhb53420c2016-03-09 14:32:57 +053010048 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010049 __func__, cmd->pattern_id, cmd->vdev_id);
10050
10051 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10052 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010053 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010054 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010055 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010056 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010057 }
Govind Singhb53420c2016-03-09 14:32:57 +053010058 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010059}
10060
10061/**
10062 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
10063 * @wmi_handle: wmi handle
10064 * @vdev_id: vdev id
10065 * @pattern_id: pattern id
10066 *
10067 * Retrun: CDF status
10068 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010069static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010070 uint8_t vdev_id,
10071 uint8_t pattern_id)
10072{
10073 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10074 wmi_buf_t wmi_buf;
10075 uint32_t len =
10076 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10077
10078 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10079 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010080 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10081 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010082 }
10083
10084 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
10085 wmi_buf_data(wmi_buf);
10086 WMITLV_SET_HDR(&cmd->tlv_header,
10087 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10088 WMITLV_GET_STRUCT_TLVLEN
10089 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10090
10091 /* Pass the pattern id to delete for the corresponding vdev id */
10092 cmd->vdev_id = vdev_id;
10093 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +053010094 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010095 __func__, cmd->pattern_id, cmd->vdev_id);
10096
10097 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10098 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010099 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010100 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010101 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010102 }
Govind Singhb53420c2016-03-09 14:32:57 +053010103 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010104}
10105
10106/**
10107 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
10108 * @wmi_handle: wmi handle
10109 * @preq: stats ext params
10110 *
10111 * Return: CDF status
10112 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010113static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010114 struct stats_ext_params *preq)
10115{
Govind Singh67922e82016-04-01 16:48:57 +053010116 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010117 wmi_req_stats_ext_cmd_fixed_param *cmd;
10118 wmi_buf_t buf;
10119 uint16_t len;
10120 uint8_t *buf_ptr;
10121
10122 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
10123
10124 buf = wmi_buf_alloc(wmi_handle, len);
10125 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010126 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010127 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010128 }
10129
10130 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10131 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
10132
10133 WMITLV_SET_HDR(&cmd->tlv_header,
10134 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
10135 WMITLV_GET_STRUCT_TLVLEN
10136 (wmi_req_stats_ext_cmd_fixed_param));
10137 cmd->vdev_id = preq->vdev_id;
10138 cmd->data_len = preq->request_data_len;
10139
Govind Singhb53420c2016-03-09 14:32:57 +053010140 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +053010141 __func__, preq->request_data_len, preq->vdev_id);
10142
10143 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
10144 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
10145
10146 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010147 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010148
10149 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10150 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010151 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010152 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +053010153 ret);
10154 wmi_buf_free(buf);
10155 }
10156
10157 return ret;
10158}
10159
10160/**
10161 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
10162 * @wmi_handle: wmi handle
10163 * @params: ext wow params
10164 *
10165 * Return:0 for success or error code
10166 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010167static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010168 struct ext_wow_params *params)
10169{
10170 wmi_extwow_enable_cmd_fixed_param *cmd;
10171 wmi_buf_t buf;
10172 int32_t len;
10173 int ret;
10174
10175 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
10176 buf = wmi_buf_alloc(wmi_handle, len);
10177 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010178 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10179 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010180 }
10181
10182 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
10183
10184 WMITLV_SET_HDR(&cmd->tlv_header,
10185 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
10186 WMITLV_GET_STRUCT_TLVLEN
10187 (wmi_extwow_enable_cmd_fixed_param));
10188
10189 cmd->vdev_id = params->vdev_id;
10190 cmd->type = params->type;
10191 cmd->wakeup_pin_num = params->wakeup_pin_num;
10192
Govind Singhb53420c2016-03-09 14:32:57 +053010193 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +053010194 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
10195
10196 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10197 WMI_EXTWOW_ENABLE_CMDID);
10198 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010199 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010200 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010201 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010202 }
10203
Govind Singhb53420c2016-03-09 14:32:57 +053010204 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010205
10206}
10207
10208/**
10209 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
10210 * @wmi_handle: wmi handle
10211 * @app_type1_params: app type1 params
10212 *
10213 * Return: CDF status
10214 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010215static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010216 struct app_type1_params *app_type1_params)
10217{
10218 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
10219 wmi_buf_t buf;
10220 int32_t len;
10221 int ret;
10222
10223 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
10224 buf = wmi_buf_alloc(wmi_handle, len);
10225 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010226 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10227 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010228 }
10229
10230 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
10231 wmi_buf_data(buf);
10232
10233 WMITLV_SET_HDR(&cmd->tlv_header,
10234 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
10235 WMITLV_GET_STRUCT_TLVLEN
10236 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
10237
10238 cmd->vdev_id = app_type1_params->vdev_id;
10239 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
10240 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +053010241 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +053010242 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +053010243 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010244 cmd->passwd_len = app_type1_params->pass_length;
10245
Govind Singhb53420c2016-03-09 14:32:57 +053010246 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010247 "identification_id %.8s id_length %u "
10248 "password %.16s pass_length %u",
10249 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
10250 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
10251
10252 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10253 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
10254 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010255 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010256 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010257 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010258 }
10259
Govind Singhb53420c2016-03-09 14:32:57 +053010260 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010261}
10262
10263/**
10264 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
10265 * @wmi_handle: wmi handle
10266 * @appType2Params: app type2 params
10267 *
10268 * Return: CDF status
10269 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010270static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010271 struct app_type2_params *appType2Params)
10272{
10273 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
10274 wmi_buf_t buf;
10275 int32_t len;
10276 int ret;
10277
10278 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
10279 buf = wmi_buf_alloc(wmi_handle, len);
10280 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010281 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10282 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010283 }
10284
10285 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
10286 wmi_buf_data(buf);
10287
10288 WMITLV_SET_HDR(&cmd->tlv_header,
10289 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
10290 WMITLV_GET_STRUCT_TLVLEN
10291 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
10292
10293 cmd->vdev_id = appType2Params->vdev_id;
10294
Govind Singhb53420c2016-03-09 14:32:57 +053010295 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010296 cmd->rc4_key_len = appType2Params->rc4_key_len;
10297
10298 cmd->ip_id = appType2Params->ip_id;
10299 cmd->ip_device_ip = appType2Params->ip_device_ip;
10300 cmd->ip_server_ip = appType2Params->ip_server_ip;
10301
10302 cmd->tcp_src_port = appType2Params->tcp_src_port;
10303 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
10304 cmd->tcp_seq = appType2Params->tcp_seq;
10305 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
10306
10307 cmd->keepalive_init = appType2Params->keepalive_init;
10308 cmd->keepalive_min = appType2Params->keepalive_min;
10309 cmd->keepalive_max = appType2Params->keepalive_max;
10310 cmd->keepalive_inc = appType2Params->keepalive_inc;
10311
10312 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
10313 &cmd->gateway_mac);
10314 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
10315 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
10316
Govind Singhb53420c2016-03-09 14:32:57 +053010317 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010318 "rc4_key %.16s rc4_key_len %u "
10319 "ip_id %x ip_device_ip %x ip_server_ip %x "
10320 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
10321 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
10322 "keepalive_max %u keepalive_inc %u "
10323 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
10324 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
10325 cmd->rc4_key, cmd->rc4_key_len,
10326 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
10327 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
10328 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
10329 cmd->keepalive_max, cmd->keepalive_inc,
10330 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
10331
10332 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10333 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
10334 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010335 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010336 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010337 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010338 }
10339
Govind Singhb53420c2016-03-09 14:32:57 +053010340 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010341
10342}
10343
10344/**
10345 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
10346 * @wmi_handle: wmi handle
10347 * @timer_val: auto shutdown timer value
10348 *
10349 * Return: CDF status
10350 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010351static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010352 uint32_t timer_val)
10353{
Govind Singh67922e82016-04-01 16:48:57 +053010354 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010355 wmi_buf_t buf = NULL;
10356 uint8_t *buf_ptr;
10357 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
10358 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
10359
Govind Singhb53420c2016-03-09 14:32:57 +053010360 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010361 __func__, timer_val);
10362
10363 buf = wmi_buf_alloc(wmi_handle, len);
10364 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010365 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10366 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010367 }
10368
10369 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10370 wmi_auto_sh_cmd =
10371 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
10372 wmi_auto_sh_cmd->timer_value = timer_val;
10373
10374 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
10375 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
10376 WMITLV_GET_STRUCT_TLVLEN
10377 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
10378
10379 status = wmi_unified_cmd_send(wmi_handle, buf,
10380 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010381 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010382 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010383 __func__, status);
10384 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010385 }
10386
Govind Singh67922e82016-04-01 16:48:57 +053010387 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010388}
10389
10390/**
10391 * send_nan_req_cmd_tlv() - to send nan request to target
10392 * @wmi_handle: wmi handle
10393 * @nan_req: request data which will be non-null
10394 *
10395 * Return: CDF status
10396 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010397static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010398 struct nan_req_params *nan_req)
10399{
Govind Singh67922e82016-04-01 16:48:57 +053010400 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010401 wmi_nan_cmd_param *cmd;
10402 wmi_buf_t buf;
10403 uint16_t len = sizeof(*cmd);
10404 uint16_t nan_data_len, nan_data_len_aligned;
10405 uint8_t *buf_ptr;
10406
10407 /*
10408 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
10409 * +------------+----------+-----------------------+--------------+
10410 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
10411 * +------------+----------+-----------------------+--------------+
10412 */
10413 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +053010414 WMI_LOGE("%s:nan req is not valid", __func__);
10415 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010416 }
10417 nan_data_len = nan_req->request_data_len;
10418 nan_data_len_aligned = roundup(nan_req->request_data_len,
10419 sizeof(uint32_t));
Naveen Rawatd30dad62018-05-08 09:40:10 -070010420 if (nan_data_len_aligned < nan_req->request_data_len) {
10421 WMI_LOGE("%s: integer overflow while rounding up data_len",
10422 __func__);
10423 return QDF_STATUS_E_FAILURE;
10424 }
10425
10426 if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
10427 WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen",
10428 __func__);
10429 return QDF_STATUS_E_FAILURE;
10430 }
10431
Govind Singh20c5dac2016-03-07 15:33:31 +053010432 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
10433 buf = wmi_buf_alloc(wmi_handle, len);
10434 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010435 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
10436 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010437 }
10438 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10439 cmd = (wmi_nan_cmd_param *) buf_ptr;
10440 WMITLV_SET_HDR(&cmd->tlv_header,
10441 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
10442 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
10443 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +053010444 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +053010445 __func__, nan_req->request_data_len);
10446 buf_ptr += sizeof(wmi_nan_cmd_param);
10447 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
10448 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010449 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010450
10451 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10452 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010453 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010454 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010455 __func__, ret);
10456 wmi_buf_free(buf);
10457 }
10458
10459 return ret;
10460}
10461
10462/**
10463 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
10464 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -070010465 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +053010466 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010467 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010468 */
Jeff Johnsona87370f2017-10-04 19:19:20 -070010469static QDF_STATUS
10470send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
10471 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +053010472{
10473 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
10474 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +053010475 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010476
10477 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10478 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010479 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +053010480 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010481 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010482 }
10483
10484 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010485
10486 WMITLV_SET_HDR(&cmd->tlv_header,
10487 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
10488 WMITLV_GET_STRUCT_TLVLEN
10489 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -070010490 cmd->vdev_id = params->vdev_id;
10491 cmd->enable = params->dhcp_offload_enabled;
10492 cmd->num_client = params->dhcp_client_num;
10493 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +053010494 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +053010495 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +053010496 sizeof(*cmd),
10497 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010498 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010499 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +053010500 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010501 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010502 }
Govind Singhb53420c2016-03-09 14:32:57 +053010503 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -070010504 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +053010505
10506 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010507}
10508
10509/**
10510 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
10511 * @wmi_handle: wmi handle
10512 * @flashing: flashing request
10513 *
10514 * Return: CDF status
10515 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010516static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010517 struct flashing_req_params *flashing)
10518{
10519 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +053010520 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010521 wmi_buf_t buf;
10522 uint8_t *buf_ptr;
10523 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
10524
10525 buf = wmi_buf_alloc(wmi_handle, len);
10526 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010527 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +053010528 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010529 }
10530 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10531 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
10532 WMITLV_SET_HDR(&cmd->tlv_header,
10533 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
10534 WMITLV_GET_STRUCT_TLVLEN
10535 (wmi_set_led_flashing_cmd_fixed_param));
10536 cmd->pattern_id = flashing->pattern_id;
10537 cmd->led_x0 = flashing->led_x0;
10538 cmd->led_x1 = flashing->led_x1;
10539
10540 status = wmi_unified_cmd_send(wmi_handle, buf, len,
10541 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010542 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010543 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +053010544 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010545 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010546 }
Govind Singh67922e82016-04-01 16:48:57 +053010547
10548 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010549}
10550
10551/**
10552 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
10553 * @wmi_handle: wmi handle
10554 * @ch_avoid_update_req: channel avoid update params
10555 *
10556 * Return: CDF status
10557 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010558static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +053010559{
Govind Singh67922e82016-04-01 16:48:57 +053010560 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010561 wmi_buf_t buf = NULL;
10562 uint8_t *buf_ptr;
10563 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
10564 int len = sizeof(wmi_chan_avoid_update_cmd_param);
10565
10566
10567 buf = wmi_buf_alloc(wmi_handle, len);
10568 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010569 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10570 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010571 }
10572
10573 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10574 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
10575 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
10576 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
10577 WMITLV_GET_STRUCT_TLVLEN
10578 (wmi_chan_avoid_update_cmd_param));
10579
10580 status = wmi_unified_cmd_send(wmi_handle, buf,
10581 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010582 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010583 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +053010584 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
10585 " returned Error %d", status);
10586 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010587 }
10588
Govind Singh67922e82016-04-01 16:48:57 +053010589 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010590}
10591
10592/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010593 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
10594 * @wmi_handle: wmi handle
10595 * @param: pointer to pdev regdomain params
10596 *
10597 * Return: 0 for success or error code
10598 */
10599static QDF_STATUS
10600send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
10601 struct pdev_set_regdomain_params *param)
10602{
10603 wmi_buf_t buf;
10604 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10605 int32_t len = sizeof(*cmd);
10606
10607
10608 buf = wmi_buf_alloc(wmi_handle, len);
10609 if (!buf) {
10610 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10611 return QDF_STATUS_E_NOMEM;
10612 }
10613 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10614 WMITLV_SET_HDR(&cmd->tlv_header,
10615 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10616 WMITLV_GET_STRUCT_TLVLEN
10617 (wmi_pdev_set_regdomain_cmd_fixed_param));
10618
10619 cmd->reg_domain = param->currentRDinuse;
10620 cmd->reg_domain_2G = param->currentRD2G;
10621 cmd->reg_domain_5G = param->currentRD5G;
10622 cmd->conformance_test_limit_2G = param->ctl_2G;
10623 cmd->conformance_test_limit_5G = param->ctl_5G;
10624 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010625 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10626 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010627
10628 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10629 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
10630 WMI_LOGE("%s: Failed to send pdev set regdomain command",
10631 __func__);
10632 wmi_buf_free(buf);
10633 return QDF_STATUS_E_FAILURE;
10634 }
10635
10636 return QDF_STATUS_SUCCESS;
10637}
10638
10639/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010640 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
10641 * @wmi_handle: wmi handle
10642 * @reg_dmn: reg domain
10643 * @regdmn2G: 2G reg domain
10644 * @regdmn5G: 5G reg domain
10645 * @ctl2G: 2G test limit
10646 * @ctl5G: 5G test limit
10647 *
10648 * Return: none
10649 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010650static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010651 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +053010652 uint16_t regdmn5G, uint8_t ctl2G,
10653 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +053010654{
10655 wmi_buf_t buf;
10656 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10657 int32_t len = sizeof(*cmd);
10658
10659
10660 buf = wmi_buf_alloc(wmi_handle, len);
10661 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010662 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10663 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010664 }
10665 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10666 WMITLV_SET_HDR(&cmd->tlv_header,
10667 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10668 WMITLV_GET_STRUCT_TLVLEN
10669 (wmi_pdev_set_regdomain_cmd_fixed_param));
10670 cmd->reg_domain = reg_dmn;
10671 cmd->reg_domain_2G = regdmn2G;
10672 cmd->reg_domain_5G = regdmn5G;
10673 cmd->conformance_test_limit_2G = ctl2G;
10674 cmd->conformance_test_limit_5G = ctl5G;
10675
10676 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10677 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010678 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010679 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010680 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010681 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010682 }
10683
Govind Singhb53420c2016-03-09 14:32:57 +053010684 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010685}
10686
10687
10688/**
10689 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10690 * @wmi_handle: wmi handle
10691 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10692 *
10693 * This function sets tdls off channel mode
10694 *
10695 * Return: 0 on success; Negative errno otherwise
10696 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010697static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010698 struct tdls_channel_switch_params *chan_switch_params)
10699{
10700 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10701 wmi_buf_t wmi_buf;
10702 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10703
10704 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10705 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010706 WMI_LOGE(FL("wmi_buf_alloc failed"));
10707 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010708 }
10709 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10710 wmi_buf_data(wmi_buf);
10711 WMITLV_SET_HDR(&cmd->tlv_header,
10712 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10713 WMITLV_GET_STRUCT_TLVLEN(
10714 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10715
10716 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10717 &cmd->peer_macaddr);
10718 cmd->vdev_id = chan_switch_params->vdev_id;
10719 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10720 cmd->is_peer_responder = chan_switch_params->is_responder;
10721 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10722 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10723 cmd->offchan_oper_class = chan_switch_params->oper_class;
10724
Govind Singhb53420c2016-03-09 14:32:57 +053010725 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010726 cmd->peer_macaddr.mac_addr31to0,
10727 cmd->peer_macaddr.mac_addr47to32);
10728
Govind Singhb53420c2016-03-09 14:32:57 +053010729 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010730 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10731 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10732 ),
10733 cmd->vdev_id,
10734 cmd->offchan_mode,
10735 cmd->offchan_num,
10736 cmd->offchan_bw_bitmap,
10737 cmd->is_peer_responder,
10738 cmd->offchan_oper_class);
10739
10740 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10741 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010742 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010743 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010744 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010745 }
10746
10747
Govind Singhb53420c2016-03-09 14:32:57 +053010748 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010749}
10750
10751/**
10752 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10753 * @wmi_handle: wmi handle
10754 * @pwmaTdlsparams: TDLS params
10755 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -070010756 * Return: 0 for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010757 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010758static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010759 void *tdls_param, uint8_t tdls_state)
10760{
10761 wmi_tdls_set_state_cmd_fixed_param *cmd;
10762 wmi_buf_t wmi_buf;
10763
10764 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10765 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10766
10767 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10768 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010769 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10770 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010771 }
10772 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10773 WMITLV_SET_HDR(&cmd->tlv_header,
10774 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10775 WMITLV_GET_STRUCT_TLVLEN
10776 (wmi_tdls_set_state_cmd_fixed_param));
10777 cmd->vdev_id = wmi_tdls->vdev_id;
10778 cmd->state = tdls_state;
10779 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10780 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10781 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10782 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10783 cmd->rssi_delta = wmi_tdls->rssi_delta;
10784 cmd->tdls_options = wmi_tdls->tdls_options;
10785 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10786 cmd->tdls_peer_traffic_response_timeout_ms =
10787 wmi_tdls->peer_traffic_response_timeout;
10788 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10789 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10790 cmd->tdls_puapsd_rx_frame_threshold =
10791 wmi_tdls->puapsd_rx_frame_threshold;
10792 cmd->teardown_notification_ms =
10793 wmi_tdls->teardown_notification_ms;
10794 cmd->tdls_peer_kickout_threshold =
10795 wmi_tdls->tdls_peer_kickout_threshold;
10796
Govind Singhb53420c2016-03-09 14:32:57 +053010797 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010798 "notification_interval_ms: %d, "
10799 "tx_discovery_threshold: %d, "
10800 "tx_teardown_threshold: %d, "
10801 "rssi_teardown_threshold: %d, "
10802 "rssi_delta: %d, "
10803 "tdls_options: 0x%x, "
10804 "tdls_peer_traffic_ind_window: %d, "
10805 "tdls_peer_traffic_response_timeout: %d, "
10806 "tdls_puapsd_mask: 0x%x, "
10807 "tdls_puapsd_inactivity_time: %d, "
10808 "tdls_puapsd_rx_frame_threshold: %d, "
10809 "teardown_notification_ms: %d, "
10810 "tdls_peer_kickout_threshold: %d",
10811 __func__, tdls_state, cmd->state,
10812 cmd->notification_interval_ms,
10813 cmd->tx_discovery_threshold,
10814 cmd->tx_teardown_threshold,
10815 cmd->rssi_teardown_threshold,
10816 cmd->rssi_delta,
10817 cmd->tdls_options,
10818 cmd->tdls_peer_traffic_ind_window,
10819 cmd->tdls_peer_traffic_response_timeout_ms,
10820 cmd->tdls_puapsd_mask,
10821 cmd->tdls_puapsd_inactivity_time_ms,
10822 cmd->tdls_puapsd_rx_frame_threshold,
10823 cmd->teardown_notification_ms,
10824 cmd->tdls_peer_kickout_threshold);
10825
10826 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10827 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010828 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010829 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010830 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010831 }
Govind Singhb53420c2016-03-09 14:32:57 +053010832 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010833
Govind Singhb53420c2016-03-09 14:32:57 +053010834 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010835}
10836
10837/**
10838 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10839 * @wmi_handle: wmi handle
10840 * @peerStateParams: TDLS peer state params
10841 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010842 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010843 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010844static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010845 struct tdls_peer_state_params *peerStateParams,
10846 uint32_t *ch_mhz)
10847{
10848 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10849 wmi_tdls_peer_capabilities *peer_cap;
10850 wmi_channel *chan_info;
10851 wmi_buf_t wmi_buf;
10852 uint8_t *buf_ptr;
10853 uint32_t i;
10854 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10855 sizeof(wmi_tdls_peer_capabilities);
10856
10857
10858 len += WMI_TLV_HDR_SIZE +
10859 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10860
10861 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10862 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010863 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10864 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010865 }
10866
10867 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10868 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10869 WMITLV_SET_HDR(&cmd->tlv_header,
10870 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10871 WMITLV_GET_STRUCT_TLVLEN
10872 (wmi_tdls_peer_update_cmd_fixed_param));
10873
10874 cmd->vdev_id = peerStateParams->vdevId;
10875 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10876 &cmd->peer_macaddr);
10877
10878
10879 cmd->peer_state = peerStateParams->peerState;
10880
Govind Singhb53420c2016-03-09 14:32:57 +053010881 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010882 "peer_macaddr.mac_addr31to0: 0x%x, "
10883 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10884 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10885 cmd->peer_macaddr.mac_addr31to0,
10886 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10887
10888 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10889 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10890 WMITLV_SET_HDR(&peer_cap->tlv_header,
10891 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10892 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10893
10894 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10895 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10896 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10897 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10898 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10899 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10900 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10901 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10902
10903 /* Ack and More Data Ack are sent as 0, so no need to set
10904 * but fill SP
10905 */
10906 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10907 peerStateParams->peerCap.peerMaxSp);
10908
10909 peer_cap->buff_sta_support =
10910 peerStateParams->peerCap.peerBuffStaSupport;
10911 peer_cap->off_chan_support =
10912 peerStateParams->peerCap.peerOffChanSupport;
10913 peer_cap->peer_curr_operclass =
10914 peerStateParams->peerCap.peerCurrOperClass;
10915 /* self curr operclass is not being used and so pass op class for
10916 * preferred off chan in it.
10917 */
10918 peer_cap->self_curr_operclass =
10919 peerStateParams->peerCap.opClassForPrefOffChan;
10920 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10921 peer_cap->peer_operclass_len =
10922 peerStateParams->peerCap.peerOperClassLen;
10923
Govind Singhb53420c2016-03-09 14:32:57 +053010924 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010925 __func__, peer_cap->peer_operclass_len);
10926 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10927 peer_cap->peer_operclass[i] =
10928 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010929 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010930 __func__, i, peer_cap->peer_operclass[i]);
10931 }
10932
10933 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10934 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10935 peer_cap->pref_offchan_bw =
10936 peerStateParams->peerCap.prefOffChanBandwidth;
10937
Govind Singhb53420c2016-03-09 14:32:57 +053010938 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010939 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10940 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10941 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10942 " %d, pref_offchan_bw: %d",
10943 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10944 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10945 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10946 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10947 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10948
10949 /* next fill variable size array of peer chan info */
10950 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10951 WMITLV_SET_HDR(buf_ptr,
10952 WMITLV_TAG_ARRAY_STRUC,
10953 sizeof(wmi_channel) *
10954 peerStateParams->peerCap.peerChanLen);
10955 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10956
10957 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10958 WMITLV_SET_HDR(&chan_info->tlv_header,
10959 WMITLV_TAG_STRUC_wmi_channel,
10960 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10961 chan_info->mhz = ch_mhz[i];
10962 chan_info->band_center_freq1 = chan_info->mhz;
10963 chan_info->band_center_freq2 = 0;
10964
Govind Singhb53420c2016-03-09 14:32:57 +053010965 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010966
10967 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10968 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010969 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010970 peerStateParams->peerCap.peerChan[i].chanId,
10971 peerStateParams->peerCap.peerChan[i].dfsSet);
10972 }
10973
10974 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10975 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10976 else
10977 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10978
10979 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10980 peerStateParams->peerCap.
10981 peerChan[i].pwr);
10982
10983 WMI_SET_CHANNEL_REG_POWER(chan_info,
10984 peerStateParams->peerCap.peerChan[i].
10985 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010986 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010987 peerStateParams->peerCap.peerChan[i].pwr);
10988
10989 chan_info++;
10990 }
10991
10992 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10993 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010994 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010995 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010996 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010997 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010998 }
10999
11000
Govind Singhb53420c2016-03-09 14:32:57 +053011001 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053011002}
11003
11004/*
Govind Singh20c5dac2016-03-07 15:33:31 +053011005 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
11006 * @wmi_handle: Pointer to WMi handle
11007 * @ie_data: Pointer for ie data
11008 *
11009 * This function sends IE information to firmware
11010 *
Govind Singhb53420c2016-03-09 14:32:57 +053011011 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053011012 *
11013 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011014static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053011015 struct vdev_ie_info_param *ie_info)
11016{
11017 wmi_vdev_set_ie_cmd_fixed_param *cmd;
11018 wmi_buf_t buf;
11019 uint8_t *buf_ptr;
11020 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053011021 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053011022
11023
11024 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
11025 /* Allocate memory for the WMI command */
11026 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
11027
11028 buf = wmi_buf_alloc(wmi_handle, len);
11029 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011030 WMI_LOGE(FL("wmi_buf_alloc failed"));
11031 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053011032 }
11033
11034 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011035 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011036
11037 /* Populate the WMI command */
11038 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
11039
11040 WMITLV_SET_HDR(&cmd->tlv_header,
11041 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
11042 WMITLV_GET_STRUCT_TLVLEN(
11043 wmi_vdev_set_ie_cmd_fixed_param));
11044 cmd->vdev_id = ie_info->vdev_id;
11045 cmd->ie_id = ie_info->ie_id;
11046 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070011047 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053011048
Govind Singhb53420c2016-03-09 14:32:57 +053011049 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053011050 ie_info->length, ie_info->vdev_id);
11051
11052 buf_ptr += sizeof(*cmd);
11053 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
11054 buf_ptr += WMI_TLV_HDR_SIZE;
11055
Govind Singhb53420c2016-03-09 14:32:57 +053011056 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011057
11058 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11059 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011060 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011061 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053011062 wmi_buf_free(buf);
11063 }
11064
11065 return ret;
11066}
11067
Sathish Kumar497bef42017-03-01 14:02:36 +053011068/**
11069 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
11070 *
11071 * @param wmi_handle : handle to WMI.
11072 * @param param : pointer to antenna param
11073 *
11074 * This function sends smart antenna enable command to FW
11075 *
11076 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11077 */
11078static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
11079 struct smart_ant_enable_params *param)
11080{
11081 /* Send WMI COMMAND to Enable */
11082 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
11083 wmi_pdev_smart_ant_gpio_handle *gpio_param;
11084 wmi_buf_t buf;
11085 uint8_t *buf_ptr;
11086 int len = 0;
11087 QDF_STATUS ret;
11088 int loop = 0;
11089
11090 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11091 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
11092 buf = wmi_buf_alloc(wmi_handle, len);
11093
11094 if (!buf) {
11095 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11096 return QDF_STATUS_E_NOMEM;
11097 }
11098
11099 buf_ptr = wmi_buf_data(buf);
11100 qdf_mem_zero(buf_ptr, len);
11101 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
11102
11103 WMITLV_SET_HDR(&cmd->tlv_header,
11104 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
11105 WMITLV_GET_STRUCT_TLVLEN(
11106 wmi_pdev_smart_ant_enable_cmd_fixed_param));
11107
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011108 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11109 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011110 cmd->enable = param->enable;
11111 cmd->mode = param->mode;
11112 cmd->rx_antenna = param->rx_antenna;
11113 cmd->tx_default_antenna = param->rx_antenna;
11114
11115 /* TLV indicating array of structures to follow */
11116 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
11117 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11118 WMI_HAL_MAX_SANTENNA *
11119 sizeof(wmi_pdev_smart_ant_gpio_handle));
11120
11121 buf_ptr += WMI_TLV_HDR_SIZE;
11122 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
11123
11124 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
11125 WMITLV_SET_HDR(&gpio_param->tlv_header,
11126 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
11127 WMITLV_GET_STRUCT_TLVLEN(
11128 wmi_pdev_smart_ant_gpio_handle));
11129 if (param->mode == SMART_ANT_MODE_SERIAL) {
11130 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
11131 gpio_param->gpio_pin = param->gpio_pin[loop];
11132 gpio_param->gpio_func = param->gpio_func[loop];
11133 } else {
11134 gpio_param->gpio_pin = 0;
11135 gpio_param->gpio_func = 0;
11136 }
11137 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
11138 gpio_param->gpio_pin = param->gpio_pin[loop];
11139 gpio_param->gpio_func = param->gpio_func[loop];
11140 }
11141 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011142 gpio_param->pdev_id =
11143 wmi_handle->ops->convert_pdev_id_host_to_target(
11144 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011145 gpio_param++;
11146 }
11147
11148 ret = wmi_unified_cmd_send(wmi_handle,
11149 buf,
11150 len,
11151 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
11152
11153 if (ret != 0) {
11154 WMI_LOGE(" %s :WMI Failed\n", __func__);
11155 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
11156 cmd->enable,
11157 cmd->mode,
11158 cmd->rx_antenna,
11159 param->gpio_pin[0], param->gpio_pin[1],
11160 param->gpio_pin[2], param->gpio_pin[3],
11161 param->gpio_func[0], param->gpio_func[1],
11162 param->gpio_func[2], param->gpio_func[3],
11163 ret);
11164 wmi_buf_free(buf);
11165 }
11166
11167 return ret;
11168}
11169
11170/**
11171 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
11172 *
11173 * @param wmi_handle : handle to WMI.
11174 * @param param : pointer to rx antenna param
11175 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11176 */
11177static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11178 struct smart_ant_rx_ant_params *param)
11179{
11180 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
11181 wmi_buf_t buf;
11182 uint8_t *buf_ptr;
11183 uint32_t len;
11184 QDF_STATUS ret;
11185
11186 len = sizeof(*cmd);
11187 buf = wmi_buf_alloc(wmi_handle, len);
11188 WMI_LOGD("%s:\n", __func__);
11189 if (!buf) {
11190 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11191 return QDF_STATUS_E_NOMEM;
11192 }
11193
11194 buf_ptr = wmi_buf_data(buf);
11195 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
11196 WMITLV_SET_HDR(&cmd->tlv_header,
11197 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
11198 WMITLV_GET_STRUCT_TLVLEN(
11199 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
11200 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011201 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11202 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011203
11204 ret = wmi_unified_cmd_send(wmi_handle,
11205 buf,
11206 len,
11207 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
11208
11209 if (ret != 0) {
11210 WMI_LOGE(" %s :WMI Failed\n", __func__);
11211 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
11212 __func__,
11213 cmd->rx_antenna,
11214 ret);
11215 wmi_buf_free(buf);
11216 }
11217
11218 return ret;
11219}
11220
11221/**
11222 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
11223 * @wmi_handle: wmi handle
11224 * @param: pointer to hold ctl table param
11225 *
11226 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11227 */
11228static QDF_STATUS
11229send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
11230 struct ctl_table_params *param)
11231{
11232 uint16_t len, ctl_tlv_len;
11233 uint8_t *buf_ptr;
11234 wmi_buf_t buf;
11235 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
11236 uint32_t *ctl_array;
11237
11238 if (!param->ctl_array)
11239 return QDF_STATUS_E_FAILURE;
11240
Sathish Kumar497bef42017-03-01 14:02:36 +053011241 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053011242 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053011243 len = sizeof(*cmd) + ctl_tlv_len;
11244
11245 buf = wmi_buf_alloc(wmi_handle, len);
11246 if (!buf) {
11247 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11248 return QDF_STATUS_E_FAILURE;
11249 }
11250
11251 buf_ptr = wmi_buf_data(buf);
11252 qdf_mem_zero(buf_ptr, len);
11253
11254 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
11255
11256 WMITLV_SET_HDR(&cmd->tlv_header,
11257 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
11258 WMITLV_GET_STRUCT_TLVLEN(
11259 wmi_pdev_set_ctl_table_cmd_fixed_param));
11260 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011261 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11262 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011263
11264 buf_ptr += sizeof(*cmd);
11265 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11266 (cmd->ctl_len));
11267 buf_ptr += WMI_TLV_HDR_SIZE;
11268 ctl_array = (uint32_t *)buf_ptr;
11269
11270 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
11271 sizeof(param->ctl_band));
11272 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
11273 param->ctl_cmd_len -
11274 sizeof(param->ctl_band));
11275
11276 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11277 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
11278 WMI_LOGE("%s:Failed to send command\n", __func__);
11279 wmi_buf_free(buf);
11280 return QDF_STATUS_E_FAILURE;
11281 }
11282
11283 return QDF_STATUS_SUCCESS;
11284}
11285
11286/**
11287 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
11288 * @wmi_handle: wmi handle
11289 * @param: pointer to hold mimogain table param
11290 *
11291 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11292 */
11293static QDF_STATUS
11294send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
11295 struct mimogain_table_params *param)
11296{
11297 uint16_t len, table_tlv_len;
11298 wmi_buf_t buf;
11299 uint8_t *buf_ptr;
11300 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
11301 uint32_t *gain_table;
11302
11303 if (!param->array_gain)
11304 return QDF_STATUS_E_FAILURE;
11305
11306 /* len must be multiple of a single array gain table */
11307 if (param->tbl_len %
11308 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
11309 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
11310 WMI_LOGE("Array gain table len not correct\n");
11311 return QDF_STATUS_E_FAILURE;
11312 }
11313
11314 table_tlv_len = WMI_TLV_HDR_SIZE +
11315 roundup(param->tbl_len, sizeof(uint32_t));
11316 len = sizeof(*cmd) + table_tlv_len;
11317
11318 buf = wmi_buf_alloc(wmi_handle, len);
11319 if (!buf) {
11320 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11321 return QDF_STATUS_E_FAILURE;
11322 }
11323
11324 buf_ptr = wmi_buf_data(buf);
11325 qdf_mem_zero(buf_ptr, len);
11326
11327 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
11328
11329 WMITLV_SET_HDR(&cmd->tlv_header,
11330 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
11331 WMITLV_GET_STRUCT_TLVLEN(
11332 wmi_pdev_set_mimogain_table_cmd_fixed_param));
11333
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011334 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11335 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011336 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
11337 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
11338 param->multichain_gain_bypass);
11339
11340 buf_ptr += sizeof(*cmd);
11341 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11342 (param->tbl_len));
11343 buf_ptr += WMI_TLV_HDR_SIZE;
11344 gain_table = (uint32_t *)buf_ptr;
11345
11346 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
11347 param->array_gain,
11348 param->tbl_len);
11349
11350 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11351 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
11352 return QDF_STATUS_E_FAILURE;
11353 }
11354
11355 return QDF_STATUS_SUCCESS;
11356}
11357
11358/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011359 * enum packet_power_tlv_flags: target defined
11360 * packet power rate flags for TLV
11361 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
11362 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
11363 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
11364 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
11365 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
11366 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
11367 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
11368 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
11369 * @WMI_TLV_FLAG_STBC: STBC is set
11370 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
11371 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
11372 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
11373 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
11374 * @WMI_TLV_FLAG_RTSENA: RTS enabled
11375 * @WMI_TLV_FLAG_CTSENA: CTS enabled
11376 * @WMI_TLV_FLAG_LDPC: LDPC is set
11377 * @WMI_TLV_FLAG_SGI: Short gaurd interval
11378 * @WMI_TLV_FLAG_SU: SU Data
11379 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
11380 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
11381 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
11382 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
11383 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
11384 *
11385 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
11386 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
11387 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
11388 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
11389 */
11390enum packet_power_tlv_flags {
11391 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
11392 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
11393 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
11394 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
11395 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
11396 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
11397 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
11398 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
11399 WMI_TLV_FLAG_STBC = 0x00000100,
11400 WMI_TLV_FLAG_40MHZ = 0x00000200,
11401 WMI_TLV_FLAG_80MHZ = 0x00000300,
11402 WMI_TLV_FLAG_160MHZ = 0x00000400,
11403 WMI_TLV_FLAG_TXBF = 0x00000800,
11404 WMI_TLV_FLAG_RTSENA = 0x00001000,
11405 WMI_TLV_FLAG_CTSENA = 0x00002000,
11406 WMI_TLV_FLAG_LDPC = 0x00004000,
11407 WMI_TLV_FLAG_SGI = 0x00008000,
11408 WMI_TLV_FLAG_SU = 0x00100000,
11409 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
11410 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
11411 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
11412 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
11413 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
11414
11415 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
11416 WMI_TLV_FLAG_BW_MASK = 0x3,
11417 WMI_TLV_FLAG_BW_SHIFT = 9,
11418 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
11419 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
11420};
11421
11422/**
11423 * convert_to_power_info_rate_flags() - convert packet_power_info_params
11424 * to FW understandable format
11425 * @param: pointer to hold packet power info param
11426 *
11427 * @return FW understandable 32 bit rate flags
11428 */
11429static uint32_t
11430convert_to_power_info_rate_flags(struct packet_power_info_params *param)
11431{
11432 uint32_t rateflags = 0;
11433
11434 if (param->chainmask)
11435 rateflags |=
11436 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
11437 if (param->chan_width)
11438 rateflags |=
11439 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
11440 << WMI_TLV_FLAG_BW_SHIFT);
11441 if (param->su_mu_ofdma)
11442 rateflags |=
11443 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
11444 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
11445 if (param->rate_flags & WMI_HOST_FLAG_STBC)
11446 rateflags |= WMI_TLV_FLAG_STBC;
11447 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
11448 rateflags |= WMI_TLV_FLAG_LDPC;
11449 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
11450 rateflags |= WMI_TLV_FLAG_TXBF;
11451 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
11452 rateflags |= WMI_TLV_FLAG_RTSENA;
11453 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
11454 rateflags |= WMI_TLV_FLAG_CTSENA;
11455 if (param->rate_flags & WMI_HOST_FLAG_SGI)
11456 rateflags |= WMI_TLV_FLAG_SGI;
11457
11458 return rateflags;
11459}
11460
11461/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011462 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
11463 * info to fw
11464 * @wmi_handle: wmi handle
11465 * @param: pointer to hold packet power info param
11466 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011467 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053011468 */
11469static QDF_STATUS
11470send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
11471 struct packet_power_info_params *param)
11472{
11473 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
11474 wmi_buf_t wmibuf;
11475 uint8_t *buf_ptr;
11476 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
11477
11478 wmibuf = wmi_buf_alloc(wmi_handle, len);
11479 if (wmibuf == NULL)
11480 return QDF_STATUS_E_NOMEM;
11481
11482 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
11483
11484 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
11485 WMITLV_SET_HDR(&cmd->tlv_header,
11486 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
11487 WMITLV_GET_STRUCT_TLVLEN(
11488 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011489 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11490 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011491 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053011492 cmd->nss = param->nss;
11493 cmd->preamble = param->preamble;
11494 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011495
11496 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
11497 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
11498 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
11499 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
11500
Sathish Kumar497bef42017-03-01 14:02:36 +053011501 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
11502 WMI_PDEV_GET_TPC_CMDID)) {
11503 WMI_LOGE(FL("Failed to get tpc command\n"));
11504 wmi_buf_free(wmibuf);
11505 return QDF_STATUS_E_FAILURE;
11506 }
11507
11508 return QDF_STATUS_SUCCESS;
11509}
11510
11511/**
11512 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
11513 * @wmi_handle: wmi handle
11514 * @param: pointer to hold config ratemask params
11515 *
11516 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11517 */
11518static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
11519 struct config_ratemask_params *param)
11520{
11521 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
11522 wmi_buf_t buf;
11523 int32_t len = sizeof(*cmd);
11524
11525 buf = wmi_buf_alloc(wmi_handle, len);
11526 if (!buf) {
11527 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11528 return QDF_STATUS_E_FAILURE;
11529 }
11530 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
11531 WMITLV_SET_HDR(&cmd->tlv_header,
11532 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
11533 WMITLV_GET_STRUCT_TLVLEN(
11534 wmi_vdev_config_ratemask_cmd_fixed_param));
11535 cmd->vdev_id = param->vdev_id;
11536 cmd->type = param->type;
11537 cmd->mask_lower32 = param->lower32;
11538 cmd->mask_higher32 = param->higher32;
11539 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
11540 param->vdev_id, param->type, param->lower32, param->higher32);
11541
11542 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11543 WMI_VDEV_RATEMASK_CMDID)) {
11544 WMI_LOGE("Seting vdev ratemask failed\n");
11545 wmi_buf_free(buf);
11546 return QDF_STATUS_E_FAILURE;
11547 }
11548
11549 return QDF_STATUS_SUCCESS;
11550}
11551
11552/**
Sathish Kumar6011c742017-11-08 14:49:58 +053011553 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
11554 * @param: param sent from the host side
11555 * @cmd: param to be sent to the fw side
11556 */
11557static inline void copy_custom_aggr_bitmap(
11558 struct set_custom_aggr_size_params *param,
11559 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
11560{
11561 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
11562 param->ac);
11563 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
11564 param->aggr_type);
11565 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11566 param->tx_aggr_size_disable);
11567 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11568 param->rx_aggr_size_disable);
11569 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
11570 param->tx_ac_enable);
11571}
11572
11573/**
11574 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
11575 * @wmi_handle: wmi handle
11576 * @param: pointer to hold custom aggr size params
11577 *
11578 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11579 */
11580static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
11581 wmi_unified_t wmi_handle,
11582 struct set_custom_aggr_size_params *param)
11583{
11584 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
11585 wmi_buf_t buf;
11586 int32_t len = sizeof(*cmd);
11587
11588 buf = wmi_buf_alloc(wmi_handle, len);
11589 if (!buf) {
11590 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11591 return QDF_STATUS_E_FAILURE;
11592 }
11593 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
11594 wmi_buf_data(buf);
11595 WMITLV_SET_HDR(&cmd->tlv_header,
11596 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
11597 WMITLV_GET_STRUCT_TLVLEN(
11598 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
11599 cmd->vdev_id = param->vdev_id;
11600 cmd->tx_aggr_size = param->tx_aggr_size;
11601 cmd->rx_aggr_size = param->rx_aggr_size;
11602 copy_custom_aggr_bitmap(param, cmd);
11603
11604 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
11605 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
11606 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
11607 "tx_ac_enable=0x%X\n",
11608 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
11609 param->ac, param->aggr_type, param->tx_aggr_size_disable,
11610 param->rx_aggr_size_disable, param->tx_ac_enable);
11611
11612 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11613 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
11614 WMI_LOGE("Seting custom aggregation size failed\n");
11615 wmi_buf_free(buf);
11616 return QDF_STATUS_E_FAILURE;
11617 }
11618
11619 return QDF_STATUS_SUCCESS;
11620}
11621
11622/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011623 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
11624 * @param wmi_handle : handle to WMI.
11625 * @param param : pointer to tx antenna param
11626 *
11627 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11628 */
11629
11630static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
11631 struct set_qdepth_thresh_params *param)
11632{
11633 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
11634 wmi_msduq_qdepth_thresh_update *cmd_update;
11635 wmi_buf_t buf;
11636 int32_t len = 0;
11637 int i;
11638 uint8_t *buf_ptr;
11639 QDF_STATUS ret;
11640
11641 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
11642 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
11643 return QDF_STATUS_E_INVAL;
11644 }
11645
11646 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11647 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
11648 param->num_of_msduq_updates);
11649 buf = wmi_buf_alloc(wmi_handle, len);
11650
11651 if (!buf) {
11652 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11653 return QDF_STATUS_E_NOMEM;
11654 }
11655
11656 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11657 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11658 buf_ptr;
11659
11660 WMITLV_SET_HDR(&cmd->tlv_header,
11661 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11662 , WMITLV_GET_STRUCT_TLVLEN(
11663 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11664
11665 cmd->pdev_id =
11666 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11667 cmd->vdev_id = param->vdev_id;
11668 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11669 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11670
11671 buf_ptr += sizeof(
11672 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11673 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11674 param->num_of_msduq_updates *
11675 sizeof(wmi_msduq_qdepth_thresh_update));
11676 buf_ptr += WMI_TLV_HDR_SIZE;
11677 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11678
11679 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11680 WMITLV_SET_HDR(&cmd_update->tlv_header,
11681 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11682 WMITLV_GET_STRUCT_TLVLEN(
11683 wmi_msduq_qdepth_thresh_update));
11684 cmd_update->tid_num = param->update_params[i].tid_num;
11685 cmd_update->msduq_update_mask =
11686 param->update_params[i].msduq_update_mask;
11687 cmd_update->qdepth_thresh_value =
11688 param->update_params[i].qdepth_thresh_value;
11689 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11690 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11691 " update mask=0x%X thresh val=0x%X\n",
11692 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11693 cmd->peer_mac_address.mac_addr31to0,
11694 cmd->peer_mac_address.mac_addr47to32,
11695 cmd_update->msduq_update_mask,
11696 cmd_update->qdepth_thresh_value);
11697 cmd_update++;
11698 }
11699
11700 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11701 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11702
11703 if (ret != 0) {
11704 WMI_LOGE(" %s :WMI Failed\n", __func__);
11705 wmi_buf_free(buf);
11706 }
11707
11708 return ret;
11709}
11710
11711/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011712 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11713 * @wmi_handle: wmi handle
11714 * @param: pointer to hold vap dscp tid map param
11715 *
11716 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11717 */
11718static QDF_STATUS
11719send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11720 struct vap_dscp_tid_map_params *param)
11721{
11722 wmi_buf_t buf;
11723 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11724 int32_t len = sizeof(*cmd);
11725
11726 buf = wmi_buf_alloc(wmi_handle, len);
11727 if (!buf) {
11728 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11729 return QDF_STATUS_E_FAILURE;
11730 }
11731
11732 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11733 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053011734 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053011735
11736 cmd->vdev_id = param->vdev_id;
11737 cmd->enable_override = 0;
11738
11739 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11740 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11741 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11742 WMI_LOGE("Failed to set dscp cmd\n");
11743 wmi_buf_free(buf);
11744 return QDF_STATUS_E_FAILURE;
11745 }
11746
11747 return QDF_STATUS_SUCCESS;
11748}
11749
11750/**
11751 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11752 * @wmi_handle: wmi handle
11753 * @macaddr: vdev mac address
11754 * @param: pointer to hold neigbour rx param
11755 *
11756 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11757 */
11758static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11759 uint8_t macaddr[IEEE80211_ADDR_LEN],
11760 struct set_neighbour_rx_params *param)
11761{
11762 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11763 wmi_buf_t buf;
11764 int32_t len = sizeof(*cmd);
11765
11766 buf = wmi_buf_alloc(wmi_handle, len);
11767 if (!buf) {
11768 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11769 return QDF_STATUS_E_FAILURE;
11770 }
11771 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11772 WMITLV_SET_HDR(&cmd->tlv_header,
11773 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11774 WMITLV_GET_STRUCT_TLVLEN(
11775 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11776 cmd->vdev_id = param->vdev_id;
11777 cmd->bssid_idx = param->idx;
11778 cmd->action = param->action;
11779 cmd->type = param->type;
11780 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11781 cmd->flag = 0;
11782
11783 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11784 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11785 WMI_LOGE("Failed to set neighbour rx param\n");
11786 wmi_buf_free(buf);
11787 return QDF_STATUS_E_FAILURE;
11788 }
11789
11790 return QDF_STATUS_SUCCESS;
11791}
11792
11793/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011794 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011795 * @param wmi_handle : handle to WMI.
11796 * @param macaddr : vdev mac address
11797 * @param param : pointer to tx antenna param
11798 *
11799 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11800 */
11801static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11802 uint8_t macaddr[IEEE80211_ADDR_LEN],
11803 struct smart_ant_tx_ant_params *param)
11804{
11805 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11806 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11807 wmi_buf_t buf;
11808 int32_t len = 0;
11809 int i;
11810 uint8_t *buf_ptr;
11811 QDF_STATUS ret;
11812
11813 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11814 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11815 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11816 buf = wmi_buf_alloc(wmi_handle, len);
11817
11818 if (!buf) {
11819 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11820 return QDF_STATUS_E_NOMEM;
11821 }
11822
11823 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11824 qdf_mem_zero(buf_ptr, len);
11825 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11826
11827 WMITLV_SET_HDR(&cmd->tlv_header,
11828 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11829 WMITLV_GET_STRUCT_TLVLEN(
11830 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11831
11832 cmd->vdev_id = param->vdev_id;
11833 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11834
11835 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11836 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11837 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11838 buf_ptr += WMI_TLV_HDR_SIZE;
11839 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11840
11841 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11842 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11843 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11844 WMITLV_GET_STRUCT_TLVLEN(
11845 wmi_peer_smart_ant_set_tx_antenna_series));
11846 ant_tx_series->antenna_series = param->antenna_array[i];
11847 ant_tx_series++;
11848 }
11849
11850 ret = wmi_unified_cmd_send(wmi_handle,
11851 buf,
11852 len,
11853 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11854
11855 if (ret != 0) {
11856 WMI_LOGE(" %s :WMI Failed\n", __func__);
11857 wmi_buf_free(buf);
11858 }
11859
11860 return ret;
11861}
11862
Sathish Kumar02c3b542017-02-22 17:24:45 +053011863/**
11864 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11865 * @wmi_handle: wmi handle
11866 * @param: pointer to hold ant switch tbl param
11867 *
11868 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11869 */
11870static QDF_STATUS
11871send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11872 struct ant_switch_tbl_params *param)
11873{
11874 uint8_t len;
11875 wmi_buf_t buf;
11876 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11877 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11878 uint8_t *buf_ptr;
11879
11880 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11881 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11882 buf = wmi_buf_alloc(wmi_handle, len);
11883
11884 if (!buf) {
11885 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11886 return QDF_STATUS_E_NOMEM;
11887 }
11888
11889 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11890 qdf_mem_zero(buf_ptr, len);
11891 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11892
11893 WMITLV_SET_HDR(&cmd->tlv_header,
11894 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11895 WMITLV_GET_STRUCT_TLVLEN(
11896 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11897
11898 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11899 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011900 cmd->mac_id =
11901 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011902
11903 /* TLV indicating array of structures to follow */
11904 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11905 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11906 sizeof(wmi_pdev_set_ant_ctrl_chain));
11907 buf_ptr += WMI_TLV_HDR_SIZE;
11908 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11909
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011910 ctrl_chain->pdev_id =
11911 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011912 ctrl_chain->antCtrlChain = param->antCtrlChain;
11913
11914 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11915 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11916 wmi_buf_free(buf);
11917 return QDF_STATUS_E_FAILURE;
11918 }
11919
11920 return QDF_STATUS_SUCCESS;
11921}
11922
11923/**
11924 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11925 * training information function
11926 * @param wmi_handle : handle to WMI.
11927 * @macaddr : vdev mac address
11928 * @param param : pointer to tx antenna param
11929 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11930 */
11931static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11932 wmi_unified_t wmi_handle,
11933 uint8_t macaddr[IEEE80211_ADDR_LEN],
11934 struct smart_ant_training_info_params *param)
11935{
11936 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11937 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11938 wmi_buf_t buf;
11939 uint8_t *buf_ptr;
11940 int32_t len = 0;
11941 QDF_STATUS ret;
11942 int loop;
11943
11944 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11945 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11946 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11947 buf = wmi_buf_alloc(wmi_handle, len);
11948
11949 if (!buf) {
11950 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11951 return QDF_STATUS_E_NOMEM;
11952 }
11953
11954 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11955 qdf_mem_zero(buf_ptr, len);
11956 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11957
11958 WMITLV_SET_HDR(&cmd->tlv_header,
11959 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11960 WMITLV_GET_STRUCT_TLVLEN(
11961 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11962
11963 cmd->vdev_id = param->vdev_id;
11964 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11965 cmd->num_pkts = param->numpkts;
11966
11967 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11968 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11969 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11970 WMI_SMART_ANT_MAX_RATE_SERIES);
11971
11972 buf_ptr += WMI_TLV_HDR_SIZE;
11973 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11974
11975 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11976 WMITLV_SET_HDR(&train_param->tlv_header,
11977 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11978 WMITLV_GET_STRUCT_TLVLEN(
11979 wmi_peer_smart_ant_set_train_antenna_param));
11980 train_param->train_rate_series = param->rate_array[loop];
11981 train_param->train_antenna_series = param->antenna_array[loop];
11982 train_param->rc_flags = 0;
11983 WMI_LOGI(FL("Series number:%d\n"), loop);
11984 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11985 train_param->train_rate_series,
11986 train_param->train_antenna_series);
11987 train_param++;
11988 }
11989
11990 ret = wmi_unified_cmd_send(wmi_handle,
11991 buf,
11992 len,
11993 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11994
11995 if (ret != 0) {
11996 WMI_LOGE(" %s :WMI Failed\n", __func__);
11997 wmi_buf_free(buf);
11998 return QDF_STATUS_E_FAILURE;
11999 }
12000
12001 return ret;
12002}
12003
12004/**
12005 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
12006 * configuration function
12007 * @param wmi_handle : handle to WMI.
12008 * @macaddr : vdev mad address
12009 * @param param : pointer to tx antenna param
12010 *
12011 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12012 */
12013static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
12014 wmi_unified_t wmi_handle,
12015 uint8_t macaddr[IEEE80211_ADDR_LEN],
12016 struct smart_ant_node_config_params *param)
12017{
12018 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
12019 wmi_buf_t buf;
12020 uint8_t *buf_ptr;
12021 int32_t len = 0, args_tlv_len;
12022 int ret;
12023 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053012024 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053012025
Vivekc5823092018-03-22 23:27:21 +053012026 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053012027 len = sizeof(*cmd) + args_tlv_len;
12028
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070012029 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053012030 WMI_LOGE("%s: Can't send a command with %d arguments\n",
12031 __func__, param->args_count);
12032 return QDF_STATUS_E_FAILURE;
12033 }
12034
12035 buf = wmi_buf_alloc(wmi_handle, len);
12036 if (!buf) {
12037 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12038 return QDF_STATUS_E_NOMEM;
12039 }
12040
12041 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
12042 wmi_buf_data(buf);
12043 buf_ptr = (uint8_t *)cmd;
12044 WMITLV_SET_HDR(&cmd->tlv_header,
12045 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
12046 WMITLV_GET_STRUCT_TLVLEN(
12047 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
12048 cmd->vdev_id = param->vdev_id;
12049 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12050 cmd->cmd_id = param->cmd_id;
12051 cmd->args_count = param->args_count;
12052 buf_ptr += sizeof(
12053 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
12054 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053012055 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053012056 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053012057 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053012058
12059 for (i = 0; i < param->args_count; i++) {
12060 node_config_args[i] = param->args_arr[i];
12061 WMI_LOGI("%d", param->args_arr[i]);
12062 }
12063
12064 ret = wmi_unified_cmd_send(wmi_handle,
12065 buf,
12066 len,
12067 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
12068
12069 if (ret != 0) {
12070 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
12071 __func__, param->cmd_id, macaddr[0],
12072 macaddr[1], macaddr[2], macaddr[3],
12073 macaddr[4], macaddr[5], ret);
12074 wmi_buf_free(buf);
12075 }
12076
12077 return ret;
12078}
12079
12080/**
12081 * send_set_atf_cmd_tlv() - send set atf command to fw
12082 * @wmi_handle: wmi handle
12083 * @param: pointer to set atf param
12084 *
12085 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12086 */
12087static QDF_STATUS
12088send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
12089 struct set_atf_params *param)
12090{
12091 wmi_atf_peer_info *peer_info;
12092 wmi_peer_atf_request_fixed_param *cmd;
12093 wmi_buf_t buf;
12094 uint8_t *buf_ptr;
12095 int i;
12096 int32_t len = 0;
12097 QDF_STATUS retval;
12098
12099 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12100 len += param->num_peers * sizeof(wmi_atf_peer_info);
12101 buf = wmi_buf_alloc(wmi_handle, len);
12102 if (!buf) {
12103 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12104 return QDF_STATUS_E_FAILURE;
12105 }
12106 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12107 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
12108 WMITLV_SET_HDR(&cmd->tlv_header,
12109 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
12110 WMITLV_GET_STRUCT_TLVLEN(
12111 wmi_peer_atf_request_fixed_param));
12112 cmd->num_peers = param->num_peers;
12113
12114 buf_ptr += sizeof(*cmd);
12115 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12116 sizeof(wmi_atf_peer_info) *
12117 cmd->num_peers);
12118 buf_ptr += WMI_TLV_HDR_SIZE;
12119 peer_info = (wmi_atf_peer_info *)buf_ptr;
12120
12121 for (i = 0; i < cmd->num_peers; i++) {
12122 WMITLV_SET_HDR(&peer_info->tlv_header,
12123 WMITLV_TAG_STRUC_wmi_atf_peer_info,
12124 WMITLV_GET_STRUCT_TLVLEN(
12125 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012126 qdf_mem_copy(&(peer_info->peer_macaddr),
12127 &(param->peer_info[i].peer_macaddr),
12128 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053012129 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012130 peer_info->vdev_id = param->peer_info[i].vdev_id;
12131 peer_info->pdev_id =
12132 wmi_handle->ops->convert_pdev_id_host_to_target(
12133 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053012134 /*
12135 * TLV definition for peer atf request fixed param combines
12136 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
12137 * stats and atf extension stats as two different
12138 * implementations.
12139 * Need to discuss with FW on this.
12140 *
12141 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
12142 * peer_info->atf_units_reserved =
12143 * param->peer_ext_info[i].atf_index_reserved;
12144 */
12145 peer_info++;
12146 }
12147
12148 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12149 WMI_PEER_ATF_REQUEST_CMDID);
12150
12151 if (retval != QDF_STATUS_SUCCESS) {
12152 WMI_LOGE("%s : WMI Failed\n", __func__);
12153 wmi_buf_free(buf);
12154 }
12155
12156 return retval;
12157}
12158
12159/**
12160 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
12161 * @wmi_handle: wmi handle
12162 * @param: pointer to hold fwtest param
12163 *
12164 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12165 */
12166static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
12167 struct set_fwtest_params *param)
12168{
12169 wmi_fwtest_set_param_cmd_fixed_param *cmd;
12170 wmi_buf_t buf;
12171 int32_t len = sizeof(*cmd);
12172
12173 buf = wmi_buf_alloc(wmi_handle, len);
12174
12175 if (!buf) {
12176 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12177 return QDF_STATUS_E_FAILURE;
12178 }
12179
12180 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
12181 WMITLV_SET_HDR(&cmd->tlv_header,
12182 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
12183 WMITLV_GET_STRUCT_TLVLEN(
12184 wmi_fwtest_set_param_cmd_fixed_param));
12185 cmd->param_id = param->arg;
12186 cmd->param_value = param->value;
12187
12188 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
12189 WMI_LOGE("Setting FW test param failed\n");
12190 wmi_buf_free(buf);
12191 return QDF_STATUS_E_FAILURE;
12192 }
12193
12194 return QDF_STATUS_SUCCESS;
12195}
12196
12197/**
12198 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
12199 * @wmi_handle: wmi handle
12200 * @param: pointer to qboost params
12201 * @macaddr: vdev mac address
12202 *
12203 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12204 */
12205static QDF_STATUS
12206send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
12207 uint8_t macaddr[IEEE80211_ADDR_LEN],
12208 struct set_qboost_params *param)
12209{
12210 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
12211 wmi_buf_t buf;
12212 int32_t len;
12213 QDF_STATUS ret;
12214
12215 len = sizeof(*cmd);
12216
12217 buf = wmi_buf_alloc(wmi_handle, len);
12218 if (!buf) {
12219 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12220 return QDF_STATUS_E_FAILURE;
12221 }
12222
12223 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
12224 WMITLV_SET_HDR(&cmd->tlv_header,
12225 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
12226 WMITLV_GET_STRUCT_TLVLEN(
12227 WMI_QBOOST_CFG_CMD_fixed_param));
12228 cmd->vdev_id = param->vdev_id;
12229 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12230 cmd->qb_enable = param->value;
12231
12232 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12233 WMI_QBOOST_CFG_CMDID);
12234
12235 if (ret != 0) {
12236 WMI_LOGE("Setting qboost cmd failed\n");
12237 wmi_buf_free(buf);
12238 }
12239
12240 return ret;
12241}
12242
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012243/**
12244 * send_gpio_config_cmd_tlv() - send gpio config to fw
12245 * @wmi_handle: wmi handle
12246 * @param: pointer to hold gpio config param
12247 *
12248 * Return: 0 for success or error code
12249 */
12250static QDF_STATUS
12251send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
12252 struct gpio_config_params *param)
12253{
12254 wmi_gpio_config_cmd_fixed_param *cmd;
12255 wmi_buf_t buf;
12256 int32_t len;
12257 QDF_STATUS ret;
12258
12259 len = sizeof(*cmd);
12260
12261 /* Sanity Checks */
12262 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
12263 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
12264 return QDF_STATUS_E_FAILURE;
12265 }
12266
12267 buf = wmi_buf_alloc(wmi_handle, len);
12268 if (!buf) {
12269 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12270 return QDF_STATUS_E_FAILURE;
12271 }
12272
12273 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
12274 WMITLV_SET_HDR(&cmd->tlv_header,
12275 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
12276 WMITLV_GET_STRUCT_TLVLEN(
12277 wmi_gpio_config_cmd_fixed_param));
12278 cmd->gpio_num = param->gpio_num;
12279 cmd->input = param->input;
12280 cmd->pull_type = param->pull_type;
12281 cmd->intr_mode = param->intr_mode;
12282
12283 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12284 WMI_GPIO_CONFIG_CMDID);
12285
12286 if (ret != 0) {
12287 WMI_LOGE("Sending GPIO config cmd failed\n");
12288 wmi_buf_free(buf);
12289 }
12290
12291 return ret;
12292}
12293
12294/**
12295 * send_gpio_output_cmd_tlv() - send gpio output to fw
12296 * @wmi_handle: wmi handle
12297 * @param: pointer to hold gpio output param
12298 *
12299 * Return: 0 for success or error code
12300 */
12301static QDF_STATUS
12302send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
12303 struct gpio_output_params *param)
12304{
12305 wmi_gpio_output_cmd_fixed_param *cmd;
12306 wmi_buf_t buf;
12307 int32_t len;
12308 QDF_STATUS ret;
12309
12310 len = sizeof(*cmd);
12311
12312 buf = wmi_buf_alloc(wmi_handle, len);
12313 if (!buf) {
12314 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12315 return QDF_STATUS_E_FAILURE;
12316 }
12317
12318 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
12319 WMITLV_SET_HDR(&cmd->tlv_header,
12320 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
12321 WMITLV_GET_STRUCT_TLVLEN(
12322 wmi_gpio_output_cmd_fixed_param));
12323 cmd->gpio_num = param->gpio_num;
12324 cmd->set = param->set;
12325
12326 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12327 WMI_GPIO_OUTPUT_CMDID);
12328
12329 if (ret != 0) {
12330 WMI_LOGE("Sending GPIO output cmd failed\n");
12331 wmi_buf_free(buf);
12332 }
12333
12334 return ret;
12335
12336}
12337
12338/**
12339 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
12340 *
12341 * @param wmi_handle : handle to WMI.
12342 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12343 */
12344static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
12345{
12346 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
12347 wmi_buf_t buf;
12348 QDF_STATUS ret;
12349 int32_t len;
12350
12351 len = sizeof(*cmd);
12352
12353 buf = wmi_buf_alloc(wmi_handle, len);
12354 if (!buf) {
12355 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12356 return QDF_STATUS_E_FAILURE;
12357 }
12358
12359 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
12360 WMITLV_SET_HDR(&cmd->tlv_header,
12361 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
12362 WMITLV_GET_STRUCT_TLVLEN(
12363 wmi_pdev_dfs_disable_cmd_fixed_param));
12364 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012365 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12366 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012367
12368 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12369 WMI_PDEV_DFS_DISABLE_CMDID);
12370
12371 if (ret != 0) {
12372 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
12373 wmi_buf_free(buf);
12374 }
12375
12376 return ret;
12377}
12378
12379/**
12380 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
12381 *
12382 * @param wmi_handle : handle to WMI.
12383 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12384 */
12385static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
12386{
12387 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
12388 wmi_buf_t buf;
12389 QDF_STATUS ret;
12390 int32_t len;
12391
12392 len = sizeof(*cmd);
12393
12394 buf = wmi_buf_alloc(wmi_handle, len);
12395 if (!buf) {
12396 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12397 return QDF_STATUS_E_FAILURE;
12398 }
12399
12400 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
12401 WMITLV_SET_HDR(&cmd->tlv_header,
12402 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
12403 WMITLV_GET_STRUCT_TLVLEN(
12404 wmi_pdev_dfs_enable_cmd_fixed_param));
12405 /* Reserved for future use */
12406 cmd->reserved0 = 0;
12407
12408 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12409 WMI_PDEV_DFS_ENABLE_CMDID);
12410
12411 if (ret != 0) {
12412 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
12413 wmi_buf_free(buf);
12414 }
12415
12416 return ret;
12417}
12418
12419/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053012420 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
12421 * to fw
12422 * @wmi_handle: wmi handle
12423 * @param: pointer to hold periodic chan stats param
12424 *
12425 * Return: 0 for success or error code
12426 */
12427static QDF_STATUS
12428send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
12429 struct periodic_chan_stats_params *param)
12430{
12431 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
12432 wmi_buf_t buf;
12433 QDF_STATUS ret;
12434 int32_t len;
12435
12436 len = sizeof(*cmd);
12437
12438 buf = wmi_buf_alloc(wmi_handle, len);
12439 if (!buf) {
12440 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12441 return QDF_STATUS_E_FAILURE;
12442 }
12443
12444 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
12445 wmi_buf_data(buf);
12446 WMITLV_SET_HDR(&cmd->tlv_header,
12447 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
12448 WMITLV_GET_STRUCT_TLVLEN(
12449 wmi_set_periodic_channel_stats_config_fixed_param));
12450 cmd->enable = param->enable;
12451 cmd->stats_period = param->stats_period;
12452 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12453 param->pdev_id);
12454
12455 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12456 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
12457
12458 if (ret != 0) {
12459 WMI_LOGE("Sending periodic chan stats config failed");
12460 wmi_buf_free(buf);
12461 }
12462
12463 return ret;
12464}
12465
12466/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012467 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
12468 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080012469 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012470 *
12471 * Return: 0 for success or error code
12472 */
12473static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080012474send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012475{
12476 wmi_buf_t buf;
12477 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080012478 wmi_pdev_get_nfcal_power_fixed_param *cmd;
12479 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012480
nobeljf74583b2018-01-25 16:35:36 -080012481 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012482 if (buf == NULL)
12483 return QDF_STATUS_E_NOMEM;
12484
nobeljf74583b2018-01-25 16:35:36 -080012485 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
12486 WMITLV_SET_HDR(&cmd->tlv_header,
12487 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
12488 WMITLV_GET_STRUCT_TLVLEN
12489 (wmi_pdev_get_nfcal_power_fixed_param));
12490 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
12491
12492 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012493 WMI_PDEV_GET_NFCAL_POWER_CMDID);
12494 if (ret != 0) {
12495 WMI_LOGE("Sending get nfcal power cmd failed\n");
12496 wmi_buf_free(buf);
12497 }
12498
12499 return ret;
12500}
12501
12502/**
12503 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
12504 * @wmi_handle: wmi handle
12505 * @param: pointer to ht ie param
12506 *
12507 * Return: 0 for success or error code
12508 */
12509static QDF_STATUS
12510send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12511 struct ht_ie_params *param)
12512{
12513 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
12514 wmi_buf_t buf;
12515 QDF_STATUS ret;
12516 int32_t len;
12517 uint8_t *buf_ptr;
12518
12519 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12520 roundup(param->ie_len, sizeof(uint32_t));
12521
12522 buf = wmi_buf_alloc(wmi_handle, len);
12523 if (!buf) {
12524 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12525 return QDF_STATUS_E_FAILURE;
12526 }
12527
12528 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12529 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
12530 WMITLV_SET_HDR(&cmd->tlv_header,
12531 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
12532 WMITLV_GET_STRUCT_TLVLEN(
12533 wmi_pdev_set_ht_ie_cmd_fixed_param));
12534 cmd->reserved0 = 0;
12535 cmd->ie_len = param->ie_len;
12536 cmd->tx_streams = param->tx_streams;
12537 cmd->rx_streams = param->rx_streams;
12538
12539 buf_ptr += sizeof(*cmd);
12540 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12541 buf_ptr += WMI_TLV_HDR_SIZE;
12542 if (param->ie_len)
12543 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12544 cmd->ie_len);
12545
12546 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12547 WMI_PDEV_SET_HT_CAP_IE_CMDID);
12548
12549 if (ret != 0) {
12550 WMI_LOGE("Sending set ht ie cmd failed\n");
12551 wmi_buf_free(buf);
12552 }
12553
12554 return ret;
12555}
12556
12557/**
12558 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
12559 * @wmi_handle: wmi handle
12560 * @param: pointer to vht ie param
12561 *
12562 * Return: 0 for success or error code
12563 */
12564static QDF_STATUS
12565send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12566 struct vht_ie_params *param)
12567{
12568 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
12569 wmi_buf_t buf;
12570 QDF_STATUS ret;
12571 int32_t len;
12572 uint8_t *buf_ptr;
12573
12574 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12575 roundup(param->ie_len, sizeof(uint32_t));
12576
12577 buf = wmi_buf_alloc(wmi_handle, len);
12578 if (!buf) {
12579 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12580 return QDF_STATUS_E_FAILURE;
12581 }
12582
12583 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12584 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
12585 WMITLV_SET_HDR(&cmd->tlv_header,
12586 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
12587 WMITLV_GET_STRUCT_TLVLEN(
12588 wmi_pdev_set_vht_ie_cmd_fixed_param));
12589 cmd->reserved0 = 0;
12590 cmd->ie_len = param->ie_len;
12591 cmd->tx_streams = param->tx_streams;
12592 cmd->rx_streams = param->rx_streams;
12593
12594 buf_ptr += sizeof(*cmd);
12595 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12596 buf_ptr += WMI_TLV_HDR_SIZE;
12597 if (param->ie_len)
12598 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12599 cmd->ie_len);
12600
12601 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12602 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
12603
12604 if (ret != 0) {
12605 WMI_LOGE("Sending set vht ie cmd failed\n");
12606 wmi_buf_free(buf);
12607 }
12608
12609 return ret;
12610}
12611
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012612/**
12613 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
12614 * @wmi_handle: wmi handle
12615 * @param: pointer to quiet mode params
12616 *
12617 * Return: 0 for success or error code
12618 */
12619static QDF_STATUS
12620send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
12621 struct set_quiet_mode_params *param)
12622{
12623 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
12624 wmi_buf_t buf;
12625 QDF_STATUS ret;
12626 int32_t len;
12627
12628 len = sizeof(*quiet_cmd);
12629 buf = wmi_buf_alloc(wmi_handle, len);
12630 if (!buf) {
12631 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12632 return QDF_STATUS_E_FAILURE;
12633 }
12634
12635 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12636 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
12637 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
12638 WMITLV_GET_STRUCT_TLVLEN(
12639 wmi_pdev_set_quiet_cmd_fixed_param));
12640 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12641 quiet_cmd->enabled = param->enabled;
12642 quiet_cmd->period = (param->period)*(param->intval);
12643 quiet_cmd->duration = param->duration;
12644 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012645 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12646 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012647
12648 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12649 WMI_PDEV_SET_QUIET_MODE_CMDID);
12650
12651 if (ret != 0) {
12652 WMI_LOGE("Sending set quiet cmd failed\n");
12653 wmi_buf_free(buf);
12654 }
12655
12656 return ret;
12657}
12658
12659/**
12660 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12661 * @wmi_handle: wmi handle
12662 * @param: pointer to set bwf param
12663 *
12664 * Return: 0 for success or error code
12665 */
12666static QDF_STATUS
12667send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12668 struct set_bwf_params *param)
12669{
12670 wmi_bwf_peer_info *peer_info;
12671 wmi_peer_bwf_request_fixed_param *cmd;
12672 wmi_buf_t buf;
12673 QDF_STATUS retval;
12674 int32_t len;
12675 uint8_t *buf_ptr;
12676 int i;
12677
12678 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12679 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12680 buf = wmi_buf_alloc(wmi_handle, len);
12681 if (!buf) {
12682 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12683 return QDF_STATUS_E_FAILURE;
12684 }
12685 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12686 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12687 WMITLV_SET_HDR(&cmd->tlv_header,
12688 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12689 WMITLV_GET_STRUCT_TLVLEN(
12690 wmi_peer_bwf_request_fixed_param));
12691 cmd->num_peers = param->num_peers;
12692
12693 buf_ptr += sizeof(*cmd);
12694 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12695 sizeof(wmi_bwf_peer_info) *
12696 cmd->num_peers);
12697 buf_ptr += WMI_TLV_HDR_SIZE;
12698 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12699
12700 for (i = 0; i < cmd->num_peers; i++) {
12701 WMITLV_SET_HDR(&peer_info->tlv_header,
12702 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12703 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12704 peer_info->bwf_guaranteed_bandwidth =
12705 param->peer_info[i].throughput;
12706 peer_info->bwf_max_airtime =
12707 param->peer_info[i].max_airtime;
12708 peer_info->bwf_peer_priority =
12709 param->peer_info[i].priority;
12710 qdf_mem_copy(&peer_info->peer_macaddr,
12711 &param->peer_info[i].peer_macaddr,
12712 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012713 peer_info->vdev_id =
12714 param->peer_info[i].vdev_id;
12715 peer_info->pdev_id =
12716 wmi_handle->ops->convert_pdev_id_host_to_target(
12717 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012718 peer_info++;
12719 }
12720
12721 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12722 WMI_PEER_BWF_REQUEST_CMDID);
12723
12724 if (retval != QDF_STATUS_SUCCESS) {
12725 WMI_LOGE("%s : WMI Failed\n", __func__);
12726 wmi_buf_free(buf);
12727 }
12728
12729 return retval;
12730}
12731
12732/**
12733 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12734 * @wmi_handle: wmi handle
12735 * @param: pointer to hold mcast update param
12736 *
12737 * Return: 0 for success or error code
12738 */
12739static QDF_STATUS
12740send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12741 struct mcast_group_update_params *param)
12742{
12743 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12744 wmi_buf_t buf;
12745 QDF_STATUS ret;
12746 int32_t len;
12747 int offset = 0;
12748 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12749
12750 len = sizeof(*cmd);
12751 buf = wmi_buf_alloc(wmi_handle, len);
12752 if (!buf) {
12753 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12754 return QDF_STATUS_E_FAILURE;
12755 }
12756 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12757 WMITLV_SET_HDR(&cmd->tlv_header,
12758 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12759 WMITLV_GET_STRUCT_TLVLEN(
12760 wmi_peer_mcast_group_cmd_fixed_param));
12761 /* confirm the buffer is 4-byte aligned */
12762 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12763 qdf_mem_zero(cmd, sizeof(*cmd));
12764
12765 cmd->vdev_id = param->vap_id;
12766 /* construct the message assuming our endianness matches the target */
12767 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12768 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12769 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12770 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12771 if (param->is_action_delete)
12772 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12773
12774 if (param->is_mcast_addr_len)
12775 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12776
12777 if (param->is_filter_mode_snoop)
12778 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12779
12780 /* unicast address spec only applies for non-wildcard cases */
12781 if (!param->wildcard && param->ucast_mac_addr) {
12782 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12783 &cmd->ucast_mac_addr);
12784 }
Amar Singhal5593c902017-10-03 13:00:29 -070012785
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012786 if (param->mcast_ip_addr) {
12787 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12788 sizeof(cmd->mcast_ip_addr));
12789 offset = sizeof(cmd->mcast_ip_addr) -
12790 param->mcast_ip_addr_bytes;
12791 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12792 param->mcast_ip_addr,
12793 param->mcast_ip_addr_bytes);
12794 }
12795 if (!param->mask)
12796 param->mask = &dummymask[0];
12797
12798 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12799 param->mask,
12800 param->mcast_ip_addr_bytes);
12801
12802 if (param->srcs && param->nsrcs) {
12803 cmd->num_filter_addr = param->nsrcs;
12804 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12805 sizeof(cmd->filter_addr));
12806
12807 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12808 param->nsrcs * param->mcast_ip_addr_bytes);
12809 }
12810
12811 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12812 WMI_PEER_MCAST_GROUP_CMDID);
12813
12814 if (ret != QDF_STATUS_SUCCESS) {
12815 WMI_LOGE("%s : WMI Failed\n", __func__);
12816 wmi_buf_free(buf);
12817 }
12818
12819 return ret;
12820}
12821
12822/**
12823 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12824 * command to fw
12825 * @wmi_handle: wmi handle
12826 * @param: pointer to hold spectral config parameter
12827 *
12828 * Return: 0 for success or error code
12829 */
12830static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12831 struct vdev_spectral_configure_params *param)
12832{
12833 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12834 wmi_buf_t buf;
12835 QDF_STATUS ret;
12836 int32_t len;
12837
12838 len = sizeof(*cmd);
12839 buf = wmi_buf_alloc(wmi_handle, len);
12840 if (!buf) {
12841 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12842 return QDF_STATUS_E_FAILURE;
12843 }
12844
12845 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12846 WMITLV_SET_HDR(&cmd->tlv_header,
12847 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12848 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012849 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012850
12851 cmd->vdev_id = param->vdev_id;
12852 cmd->spectral_scan_count = param->count;
12853 cmd->spectral_scan_period = param->period;
12854 cmd->spectral_scan_priority = param->spectral_pri;
12855 cmd->spectral_scan_fft_size = param->fft_size;
12856 cmd->spectral_scan_gc_ena = param->gc_enable;
12857 cmd->spectral_scan_restart_ena = param->restart_enable;
12858 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12859 cmd->spectral_scan_init_delay = param->init_delay;
12860 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12861 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12862 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12863 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12864 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12865 cmd->spectral_scan_pwr_format = param->pwr_format;
12866 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12867 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012868 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012869 cmd->spectral_scan_chn_mask = param->chn_mask;
12870
12871 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12872 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12873
12874 if (ret != 0) {
12875 WMI_LOGE("Sending set quiet cmd failed\n");
12876 wmi_buf_free(buf);
12877 }
12878
12879 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12880 __func__);
12881
12882 WMI_LOGI("vdev_id = %u\n"
12883 "spectral_scan_count = %u\n"
12884 "spectral_scan_period = %u\n"
12885 "spectral_scan_priority = %u\n"
12886 "spectral_scan_fft_size = %u\n"
12887 "spectral_scan_gc_ena = %u\n"
12888 "spectral_scan_restart_ena = %u\n"
12889 "spectral_scan_noise_floor_ref = %u\n"
12890 "spectral_scan_init_delay = %u\n"
12891 "spectral_scan_nb_tone_thr = %u\n"
12892 "spectral_scan_str_bin_thr = %u\n"
12893 "spectral_scan_wb_rpt_mode = %u\n"
12894 "spectral_scan_rssi_rpt_mode = %u\n"
12895 "spectral_scan_rssi_thr = %u\n"
12896 "spectral_scan_pwr_format = %u\n"
12897 "spectral_scan_rpt_mode = %u\n"
12898 "spectral_scan_bin_scale = %u\n"
12899 "spectral_scan_dBm_adj = %u\n"
12900 "spectral_scan_chn_mask = %u\n",
12901 param->vdev_id,
12902 param->count,
12903 param->period,
12904 param->spectral_pri,
12905 param->fft_size,
12906 param->gc_enable,
12907 param->restart_enable,
12908 param->noise_floor_ref,
12909 param->init_delay,
12910 param->nb_tone_thr,
12911 param->str_bin_thr,
12912 param->wb_rpt_mode,
12913 param->rssi_rpt_mode,
12914 param->rssi_thr,
12915 param->pwr_format,
12916 param->rpt_mode,
12917 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012918 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012919 param->chn_mask);
12920 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12921
12922 return ret;
12923}
12924
12925/**
12926 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12927 * command to fw
12928 * @wmi_handle: wmi handle
12929 * @param: pointer to hold spectral enable parameter
12930 *
12931 * Return: 0 for success or error code
12932 */
12933static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12934 struct vdev_spectral_enable_params *param)
12935{
12936 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12937 wmi_buf_t buf;
12938 QDF_STATUS ret;
12939 int32_t len;
12940
12941 len = sizeof(*cmd);
12942 buf = wmi_buf_alloc(wmi_handle, len);
12943 if (!buf) {
12944 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12945 return QDF_STATUS_E_FAILURE;
12946 }
12947
12948 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12949 WMITLV_SET_HDR(&cmd->tlv_header,
12950 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12951 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012952 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012953
12954 cmd->vdev_id = param->vdev_id;
12955
12956 if (param->active_valid) {
12957 cmd->trigger_cmd = param->active ? 1 : 2;
12958 /* 1: Trigger, 2: Clear Trigger */
12959 } else {
12960 cmd->trigger_cmd = 0; /* 0: Ignore */
12961 }
12962
12963 if (param->enabled_valid) {
12964 cmd->enable_cmd = param->enabled ? 1 : 2;
12965 /* 1: Enable 2: Disable */
12966 } else {
12967 cmd->enable_cmd = 0; /* 0: Ignore */
12968 }
12969
12970 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12971 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12972
12973 if (ret != 0) {
12974 WMI_LOGE("Sending scan enable CMD failed\n");
12975 wmi_buf_free(buf);
12976 }
12977
12978 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12979
12980 WMI_LOGI("vdev_id = %u\n"
12981 "trigger_cmd = %u\n"
12982 "enable_cmd = %u\n",
12983 cmd->vdev_id,
12984 cmd->trigger_cmd,
12985 cmd->enable_cmd);
12986
12987 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12988
12989 return ret;
12990}
12991
12992/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012993 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12994 * @param wmi_handle : handle to WMI.
12995 * @param param : pointer to hold thermal mitigation param
12996 *
12997 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12998 */
12999static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
13000 wmi_unified_t wmi_handle,
13001 struct thermal_mitigation_params *param)
13002{
13003 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
13004 wmi_therm_throt_level_config_info *lvl_conf = NULL;
13005 wmi_buf_t buf = NULL;
13006 uint8_t *buf_ptr = NULL;
13007 int error;
13008 int32_t len;
13009 int i;
13010
13011 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
13012 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
13013
13014 buf = wmi_buf_alloc(wmi_handle, len);
13015 if (!buf) {
13016 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13017 return QDF_STATUS_E_NOMEM;
13018 }
13019 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
13020
13021 /* init fixed params */
13022 WMITLV_SET_HDR(tt_conf,
13023 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
13024 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
13025
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013026 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13027 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053013028 tt_conf->enable = param->enable;
13029 tt_conf->dc = param->dc;
13030 tt_conf->dc_per_event = param->dc_per_event;
13031 tt_conf->therm_throt_levels = THERMAL_LEVELS;
13032
13033 buf_ptr = (uint8_t *) ++tt_conf;
13034 /* init TLV params */
13035 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13036 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
13037
13038 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
13039 for (i = 0; i < THERMAL_LEVELS; i++) {
13040 WMITLV_SET_HDR(&lvl_conf->tlv_header,
13041 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
13042 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
13043 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
13044 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
13045 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
13046 lvl_conf->prio = param->levelconf[i].priority;
13047 lvl_conf++;
13048 }
13049
13050 error = wmi_unified_cmd_send(wmi_handle, buf, len,
13051 WMI_THERM_THROT_SET_CONF_CMDID);
13052 if (QDF_IS_STATUS_ERROR(error)) {
13053 wmi_buf_free(buf);
13054 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
13055 }
13056
13057 return error;
13058}
13059
13060/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013061 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
13062 * @wmi_handle: wmi handle
13063 * @param: pointer to pdev_qvit_params
13064 *
13065 * Return: 0 for success or error code
13066 */
13067static QDF_STATUS
13068send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
13069 struct pdev_qvit_params *param)
13070{
13071 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013072 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013073 uint8_t *cmd;
13074 static uint8_t msgref = 1;
13075 uint8_t segnumber = 0, seginfo, numsegments;
13076 uint16_t chunk_len, total_bytes;
13077 uint8_t *bufpos;
13078 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
13079
13080 bufpos = param->utf_payload;
13081 total_bytes = param->len;
13082 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
13083 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
13084 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
13085
13086 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
13087 numsegments++;
13088
13089 while (param->len) {
13090 if (param->len > MAX_WMI_QVIT_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -070013091 chunk_len = MAX_WMI_QVIT_LEN; /* MAX message */
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013092 else
13093 chunk_len = param->len;
13094
13095 buf = wmi_buf_alloc(wmi_handle,
13096 (chunk_len + sizeof(seghdrinfo) +
13097 WMI_TLV_HDR_SIZE));
13098 if (!buf) {
13099 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13100 return QDF_STATUS_E_NOMEM;
13101 }
13102
13103 cmd = (uint8_t *) wmi_buf_data(buf);
13104
13105 seghdrinfo.len = total_bytes;
13106 seghdrinfo.msgref = msgref;
13107 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
13108 seghdrinfo.segmentInfo = seginfo;
13109
13110 segnumber++;
13111
13112 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
13113 (chunk_len + sizeof(seghdrinfo)));
13114 cmd += WMI_TLV_HDR_SIZE;
13115 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
13116 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
13117
13118 ret = wmi_unified_cmd_send(wmi_handle, buf,
13119 (chunk_len + sizeof(seghdrinfo) +
13120 WMI_TLV_HDR_SIZE),
13121 WMI_PDEV_QVIT_CMDID);
13122
13123 if (ret != 0) {
13124 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
13125 wmi_buf_free(buf);
13126 break;
13127 }
13128
13129 param->len -= chunk_len;
13130 bufpos += chunk_len;
13131 }
13132 msgref++;
13133
13134 return ret;
13135}
13136
13137/**
13138 * send_wmm_update_cmd_tlv() - send wmm update command to fw
13139 * @wmi_handle: wmi handle
13140 * @param: pointer to wmm update param
13141 *
13142 * Return: 0 for success or error code
13143 */
13144static QDF_STATUS
13145send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
13146 struct wmm_update_params *param)
13147{
13148 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
13149 wmi_wmm_params *wmm_param;
13150 wmi_buf_t buf;
13151 QDF_STATUS ret;
13152 int32_t len;
13153 int ac = 0;
13154 struct wmi_host_wmeParams *wmep;
13155 uint8_t *buf_ptr;
13156
13157 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
13158 buf = wmi_buf_alloc(wmi_handle, len);
13159 if (!buf) {
13160 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13161 return QDF_STATUS_E_FAILURE;
13162 }
13163
13164 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13165 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
13166 WMITLV_SET_HDR(&cmd->tlv_header,
13167 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
13168 WMITLV_GET_STRUCT_TLVLEN
13169 (wmi_pdev_set_wmm_params_cmd_fixed_param));
13170
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013171 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013172
13173 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
13174
13175 for (ac = 0; ac < WME_NUM_AC; ac++) {
13176 wmep = &param->wmep_array[ac];
13177 wmm_param = (wmi_wmm_params *)buf_ptr;
13178 WMITLV_SET_HDR(&wmm_param->tlv_header,
13179 WMITLV_TAG_STRUC_wmi_wmm_params,
13180 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
13181 wmm_param->aifs = wmep->wmep_aifsn;
13182 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
13183 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
13184 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
13185 wmm_param->acm = wmep->wmep_acm;
13186 wmm_param->no_ack = wmep->wmep_noackPolicy;
13187 buf_ptr += sizeof(wmi_wmm_params);
13188 }
13189 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13190 WMI_PDEV_SET_WMM_PARAMS_CMDID);
13191
13192 if (ret != 0) {
13193 WMI_LOGE("Sending WMM update CMD failed\n");
13194 wmi_buf_free(buf);
13195 }
13196
13197 return ret;
13198}
13199
Sathish Kumar80f4f382017-04-24 11:36:00 +053013200/**
13201 * send_coex_config_cmd_tlv() - send coex config command to fw
13202 * @wmi_handle: wmi handle
13203 * @param: pointer to coex config param
13204 *
13205 * Return: 0 for success or error code
13206 */
13207static QDF_STATUS
13208send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
13209 struct coex_config_params *param)
13210{
13211 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
13212 wmi_buf_t buf;
13213 QDF_STATUS ret;
13214 int32_t len;
13215
13216 len = sizeof(*cmd);
13217 buf = wmi_buf_alloc(wmi_handle, len);
13218 if (!buf) {
13219 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13220 return QDF_STATUS_E_FAILURE;
13221 }
13222
13223 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
13224 WMITLV_SET_HDR(&cmd->tlv_header,
13225 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
13226 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053013227 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053013228
13229 cmd->vdev_id = param->vdev_id;
13230 cmd->config_type = param->config_type;
13231 cmd->config_arg1 = param->config_arg1;
13232 cmd->config_arg2 = param->config_arg2;
13233 cmd->config_arg3 = param->config_arg3;
13234 cmd->config_arg4 = param->config_arg4;
13235 cmd->config_arg5 = param->config_arg5;
13236 cmd->config_arg6 = param->config_arg6;
13237
13238 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13239 WMI_COEX_CONFIG_CMDID);
13240
13241 if (ret != 0) {
13242 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
13243 wmi_buf_free(buf);
13244 }
13245
13246 return ret;
13247}
13248
Kiran Venkatappa3619e662018-04-04 14:31:43 +053013249
13250#ifdef WLAN_SUPPORT_TWT
13251static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
13252 target_resource_config *tgt_res_cfg)
13253{
13254 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
13255 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
13256}
13257#else
13258static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
13259 target_resource_config *tgt_res_cfg)
13260{
13261 resource_cfg->twt_ap_pdev_count = 0;
13262 resource_cfg->twt_ap_sta_count = 0;
13263}
13264#endif
13265
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013266static
Govind Singh9ddd5162016-03-07 16:30:32 +053013267void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053013268 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053013269{
Govind Singhe7f2f342016-05-23 12:12:52 +053013270 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053013271 resource_cfg->num_peers = tgt_res_cfg->num_peers;
13272 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
13273 resource_cfg->num_offload_reorder_buffs =
13274 tgt_res_cfg->num_offload_reorder_buffs;
13275 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
13276 resource_cfg->num_tids = tgt_res_cfg->num_tids;
13277 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
13278 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
13279 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
13280 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
13281 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
13282 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
13283 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
13284 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
13285 resource_cfg->scan_max_pending_req =
13286 tgt_res_cfg->scan_max_pending_req;
13287 resource_cfg->bmiss_offload_max_vdev =
13288 tgt_res_cfg->bmiss_offload_max_vdev;
13289 resource_cfg->roam_offload_max_vdev =
13290 tgt_res_cfg->roam_offload_max_vdev;
13291 resource_cfg->roam_offload_max_ap_profiles =
13292 tgt_res_cfg->roam_offload_max_ap_profiles;
13293 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
13294 resource_cfg->num_mcast_table_elems =
13295 tgt_res_cfg->num_mcast_table_elems;
13296 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
13297 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
13298 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
13299 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
13300 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
13301 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
13302 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
13303 resource_cfg->vow_config = tgt_res_cfg->vow_config;
13304 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
13305 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
13306 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
13307 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
13308 resource_cfg->num_tdls_conn_table_entries =
13309 tgt_res_cfg->num_tdls_conn_table_entries;
13310 resource_cfg->beacon_tx_offload_max_vdev =
13311 tgt_res_cfg->beacon_tx_offload_max_vdev;
13312 resource_cfg->num_multicast_filter_entries =
13313 tgt_res_cfg->num_multicast_filter_entries;
13314 resource_cfg->num_wow_filters =
13315 tgt_res_cfg->num_wow_filters;
13316 resource_cfg->num_keep_alive_pattern =
13317 tgt_res_cfg->num_keep_alive_pattern;
13318 resource_cfg->keep_alive_pattern_size =
13319 tgt_res_cfg->keep_alive_pattern_size;
13320 resource_cfg->max_tdls_concurrent_sleep_sta =
13321 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
13322 resource_cfg->max_tdls_concurrent_buffer_sta =
13323 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
13324 resource_cfg->wmi_send_separate =
13325 tgt_res_cfg->wmi_send_separate;
13326 resource_cfg->num_ocb_vdevs =
13327 tgt_res_cfg->num_ocb_vdevs;
13328 resource_cfg->num_ocb_channels =
13329 tgt_res_cfg->num_ocb_channels;
13330 resource_cfg->num_ocb_schedules =
13331 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013332 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
13333 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
13334 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013335 resource_cfg->max_num_dbs_scan_duty_cycle =
13336 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080013337 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080013338 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
13339 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053013340
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013341 if (tgt_res_cfg->atf_config)
13342 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
13343 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
13344 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
13345 resource_cfg->flag1, 1);
13346 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
13347 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
13348 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053013349 if (tgt_res_cfg->cce_disable)
13350 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Kiran Venkatappa3619e662018-04-04 14:31:43 +053013351
13352 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Govind Singh9ddd5162016-03-07 16:30:32 +053013353}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013354
13355/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13356 * @wmi_handle: pointer to wmi handle
13357 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -070013358 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013359 * @param: point host parameters for init command
13360 *
13361 * Return: Updated pointer of buf_ptr.
13362 */
13363static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
13364 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
13365{
13366 uint16_t idx;
13367
13368 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13369 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13370 wmi_pdev_band_to_mac *band_to_mac;
13371
13372 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13373 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13374 sizeof(wmi_resource_config) +
13375 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13376 sizeof(wlan_host_memory_chunk)));
13377
13378 WMITLV_SET_HDR(&hw_mode->tlv_header,
13379 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13380 (WMITLV_GET_STRUCT_TLVLEN
13381 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13382
13383 hw_mode->hw_mode_index = param->hw_mode_id;
13384 hw_mode->num_band_to_mac = param->num_band_to_mac;
13385
13386 buf_ptr = (uint8_t *) (hw_mode + 1);
13387 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13388 WMI_TLV_HDR_SIZE);
13389 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13390 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13391 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13392 WMITLV_GET_STRUCT_TLVLEN
13393 (wmi_pdev_band_to_mac));
13394 band_to_mac[idx].pdev_id =
13395 wmi_handle->ops->convert_pdev_id_host_to_target(
13396 param->band_to_mac[idx].pdev_id);
13397 band_to_mac[idx].start_freq =
13398 param->band_to_mac[idx].start_freq;
13399 band_to_mac[idx].end_freq =
13400 param->band_to_mac[idx].end_freq;
13401 }
13402 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13403 (param->num_band_to_mac *
13404 sizeof(wmi_pdev_band_to_mac)) +
13405 WMI_TLV_HDR_SIZE;
13406
13407 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13408 (param->num_band_to_mac *
13409 sizeof(wmi_pdev_band_to_mac)));
13410 }
13411
13412 return buf_ptr;
13413}
13414
13415static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
13416 wmi_init_cmd_fixed_param *cmd)
13417{
13418 int num_whitelist;
13419 wmi_abi_version my_vers;
13420
13421 num_whitelist = sizeof(version_whitelist) /
13422 sizeof(wmi_whitelist_version_info);
13423 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
13424 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
13425 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
13426 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13427 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13428 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13429
13430 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13431 &my_vers,
13432 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13433 &cmd->host_abi_vers);
13434
13435 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13436 __func__,
13437 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13438 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13439 cmd->host_abi_vers.abi_version_ns_0,
13440 cmd->host_abi_vers.abi_version_ns_1,
13441 cmd->host_abi_vers.abi_version_ns_2,
13442 cmd->host_abi_vers.abi_version_ns_3);
13443
13444 /* Save version sent from host -
13445 * Will be used to check ready event
13446 */
13447 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13448 sizeof(wmi_abi_version));
13449}
13450
Sathish Kumarfd347372017-02-13 12:29:09 +053013451static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053013452{
13453 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13454 wmi_service_ready_event_fixed_param *ev;
13455
13456
13457 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13458
13459 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13460 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053013461 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013462
13463 /*Save fw version from service ready message */
13464 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053013465 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013466 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013467
Govind Singhb53420c2016-03-09 14:32:57 +053013468 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013469}
13470
13471/**
13472 * wmi_unified_save_fw_version_cmd() - save fw version
13473 * @wmi_handle: pointer to wmi handle
13474 * @res_cfg: resource config
13475 * @num_mem_chunks: no of mem chunck
13476 * @mem_chunk: pointer to mem chunck structure
13477 *
13478 * This function sends IE information to firmware
13479 *
Govind Singhb53420c2016-03-09 14:32:57 +053013480 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053013481 *
13482 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013483static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053013484 void *evt_buf)
13485{
13486 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13487 wmi_ready_event_fixed_param *ev = NULL;
13488
13489 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13490 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013491 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
13492 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013493 &ev->fw_abi_vers)) {
13494 /*
13495 * Error: Our host version and the given firmware version
13496 * are incompatible.
13497 **/
Govind Singhb53420c2016-03-09 14:32:57 +053013498 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053013499 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
13500 __func__,
13501 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
13502 abi_version_0),
13503 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
13504 abi_version_0),
13505 wmi_handle->final_abi_vers.abi_version_ns_0,
13506 wmi_handle->final_abi_vers.abi_version_ns_1,
13507 wmi_handle->final_abi_vers.abi_version_ns_2,
13508 wmi_handle->final_abi_vers.abi_version_ns_3,
13509 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
13510 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
13511 ev->fw_abi_vers.abi_version_ns_0,
13512 ev->fw_abi_vers.abi_version_ns_1,
13513 ev->fw_abi_vers.abi_version_ns_2,
13514 ev->fw_abi_vers.abi_version_ns_3);
13515
Govind Singhb53420c2016-03-09 14:32:57 +053013516 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013517 }
Govind Singhb53420c2016-03-09 14:32:57 +053013518 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013519 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053013520 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013521 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053013522
Govind Singhb53420c2016-03-09 14:32:57 +053013523 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013524}
Govind Singha4836fd2016-03-07 16:45:38 +053013525
13526/**
13527 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
13528 * @wmi_handle: wmi handle
13529 * @custom_addr: base mac address
13530 *
Govind Singhe7f2f342016-05-23 12:12:52 +053013531 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053013532 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013533static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013534 uint8_t *custom_addr)
13535{
13536 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
13537 wmi_buf_t buf;
13538 int err;
13539
13540 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13541 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013542 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053013543 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013544 }
13545
13546 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013547 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053013548
13549 WMITLV_SET_HDR(&cmd->tlv_header,
13550 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
13551 WMITLV_GET_STRUCT_TLVLEN
13552 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
13553 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013554 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13555 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013556 err = wmi_unified_cmd_send(wmi_handle, buf,
13557 sizeof(*cmd),
13558 WMI_PDEV_SET_BASE_MACADDR_CMDID);
13559 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053013560 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053013561 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013562 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013563 }
13564
13565 return 0;
13566}
13567
13568/**
13569 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
13570 * @handle: wmi handle
13571 * @event: Event received from FW
13572 * @len: Length of the event
13573 *
13574 * Enables the low frequency events and disables the high frequency
13575 * events. Bit 17 indicates if the event if low/high frequency.
13576 * 1 - high frequency, 0 - low frequency
13577 *
13578 * Return: 0 on successfully enabling/disabling the events
13579 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013580static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013581 uint8_t *event,
13582 uint32_t len)
13583{
13584 uint32_t num_of_diag_events_logs;
13585 wmi_diag_event_log_config_fixed_param *cmd;
13586 wmi_buf_t buf;
13587 uint8_t *buf_ptr;
13588 uint32_t *cmd_args, *evt_args;
13589 uint32_t buf_len, i;
13590
13591 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
13592 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
13593
Govind Singhb53420c2016-03-09 14:32:57 +053013594 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053013595
13596 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
13597 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013598 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053013599 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013600 }
13601 wmi_event = param_buf->fixed_param;
13602 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070013603
13604 if (num_of_diag_events_logs >
13605 param_buf->num_diag_events_logs_list) {
13606 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
13607 num_of_diag_events_logs,
13608 param_buf->num_diag_events_logs_list);
13609 return QDF_STATUS_E_INVAL;
13610 }
13611
Govind Singha4836fd2016-03-07 16:45:38 +053013612 evt_args = param_buf->diag_events_logs_list;
13613 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053013614 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013615 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053013616 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013617 }
13618
Govind Singhb53420c2016-03-09 14:32:57 +053013619 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013620 __func__, num_of_diag_events_logs);
13621
13622 /* Free any previous allocation */
13623 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053013624 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013625
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070013626 if (num_of_diag_events_logs >
13627 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
13628 WMI_LOGE("%s: excess num of logs:%d", __func__,
13629 num_of_diag_events_logs);
13630 QDF_ASSERT(0);
13631 return QDF_STATUS_E_INVAL;
13632 }
Govind Singha4836fd2016-03-07 16:45:38 +053013633 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053013634 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053013635 sizeof(uint32_t));
13636 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013637 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013638 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013639 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013640 }
13641 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
13642
13643 /* Prepare the send buffer */
13644 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13645 (num_of_diag_events_logs * sizeof(uint32_t));
13646
13647 buf = wmi_buf_alloc(wmi_handle, buf_len);
13648 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013649 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13650 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013651 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013652 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013653 }
13654
13655 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13656 buf_ptr = (uint8_t *) cmd;
13657
13658 WMITLV_SET_HDR(&cmd->tlv_header,
13659 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13660 WMITLV_GET_STRUCT_TLVLEN(
13661 wmi_diag_event_log_config_fixed_param));
13662
13663 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13664
13665 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13666
13667 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13668 (num_of_diag_events_logs * sizeof(uint32_t)));
13669
13670 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13671
13672 /* Populate the events */
13673 for (i = 0; i < num_of_diag_events_logs; i++) {
13674 /* Low freq (0) - Enable (1) the event
13675 * High freq (1) - Disable (0) the event
13676 */
13677 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13678 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13679 /* Set the event ID */
13680 WMI_DIAG_ID_SET(cmd_args[i],
13681 WMI_DIAG_ID_GET(evt_args[i]));
13682 /* Set the type */
13683 WMI_DIAG_TYPE_SET(cmd_args[i],
13684 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013685 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013686 wmi_handle->events_logs_list[i] = evt_args[i];
13687 }
13688
13689 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13690 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013691 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013692 __func__);
13693 wmi_buf_free(buf);
13694 /* Not clearing events_logs_list, though wmi cmd failed.
13695 * Host can still have this list
13696 */
Govind Singh67922e82016-04-01 16:48:57 +053013697 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013698 }
13699
13700 return 0;
13701}
13702
13703/**
13704 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13705 * @wmi_handle: wmi handle
13706 * @start_log: Start logging related parameters
13707 *
13708 * Send the command to the FW based on which specific logging of diag
13709 * event/log id can be started/stopped
13710 *
13711 * Return: None
13712 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013713static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013714 struct wmi_wifi_start_log *start_log)
13715{
13716 wmi_diag_event_log_config_fixed_param *cmd;
13717 wmi_buf_t buf;
13718 uint8_t *buf_ptr;
13719 uint32_t len, count, log_level, i;
13720 uint32_t *cmd_args;
13721 uint32_t total_len;
13722 count = 0;
13723
13724 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013725 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013726 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013727 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013728 }
13729 /* total_len stores the number of events where BITS 17 and 18 are set.
13730 * i.e., events of high frequency (17) and for extended debugging (18)
13731 */
13732 total_len = 0;
13733 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13734 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13735 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13736 total_len++;
13737 }
13738
13739 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13740 (total_len * sizeof(uint32_t));
13741
13742 buf = wmi_buf_alloc(wmi_handle, len);
13743 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013744 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013745 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013746 }
13747 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13748 buf_ptr = (uint8_t *) cmd;
13749
13750 WMITLV_SET_HDR(&cmd->tlv_header,
13751 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13752 WMITLV_GET_STRUCT_TLVLEN(
13753 wmi_diag_event_log_config_fixed_param));
13754
13755 cmd->num_of_diag_events_logs = total_len;
13756
13757 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13758
13759 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13760 (total_len * sizeof(uint32_t)));
13761
13762 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13763
Govind Singh224a7312016-06-21 14:33:26 +053013764 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013765 log_level = 1;
13766 else
13767 log_level = 0;
13768
Govind Singhb53420c2016-03-09 14:32:57 +053013769 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013770 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13771 uint32_t val = wmi_handle->events_logs_list[i];
13772 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13773 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13774
13775 WMI_DIAG_ID_SET(cmd_args[count],
13776 WMI_DIAG_ID_GET(val));
13777 WMI_DIAG_TYPE_SET(cmd_args[count],
13778 WMI_DIAG_TYPE_GET(val));
13779 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13780 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013781 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013782 count++;
13783 }
13784 }
13785
13786 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13787 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013788 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013789 __func__);
13790 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013791 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013792 }
13793
Govind Singhb53420c2016-03-09 14:32:57 +053013794 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013795}
13796
13797/**
13798 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13799 * @wmi_handle: WMI handle
13800 *
13801 * This function is used to send the flush command to the FW,
13802 * that will flush the fw logs that are residue in the FW
13803 *
13804 * Return: None
13805 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013806static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013807{
13808 wmi_debug_mesg_flush_fixed_param *cmd;
13809 wmi_buf_t buf;
13810 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013811 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013812
13813 buf = wmi_buf_alloc(wmi_handle, len);
13814 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013815 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013816 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013817 }
13818
13819 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13820 WMITLV_SET_HDR(&cmd->tlv_header,
13821 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13822 WMITLV_GET_STRUCT_TLVLEN(
13823 wmi_debug_mesg_flush_fixed_param));
13824 cmd->reserved0 = 0;
13825
13826 ret = wmi_unified_cmd_send(wmi_handle,
13827 buf,
13828 len,
13829 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013830 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013831 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013832 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013833 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013834 }
Govind Singhb53420c2016-03-09 14:32:57 +053013835 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013836
Govind Singh67922e82016-04-01 16:48:57 +053013837 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013838}
13839
13840/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013841 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013842 * @wmi_handle: wmi handle
13843 * @msg: PCL structure containing the PCL and the number of channels
13844 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013845 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013846 * firmware. The DBS Manager is the consumer of this information in the WLAN
13847 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13848 * to migrate to a new channel without host driver involvement. An example of
13849 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13850 * manage the channel selection without firmware involvement.
13851 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013852 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13853 * channel list. The weights corresponds to the channels sent in
13854 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13855 * weightage compared to the non PCL channels.
13856 *
Govind Singha4836fd2016-03-07 16:45:38 +053013857 * Return: Success if the cmd is sent successfully to the firmware
13858 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013859static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013860 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013861{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013862 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013863 wmi_buf_t buf;
13864 uint8_t *buf_ptr;
13865 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013866 uint32_t chan_len;
13867
13868 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013869
13870 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013871 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013872
13873 buf = wmi_buf_alloc(wmi_handle, len);
13874 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013875 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13876 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013877 }
13878
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013879 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013880 buf_ptr = (uint8_t *) cmd;
13881 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013882 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13883 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013884
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013885 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13886 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013887 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013888 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013889
13890 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013891 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013892 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013893 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013894 for (i = 0; i < chan_len ; i++) {
13895 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013896 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013897 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013898 }
13899 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013900 WMI_PDEV_SET_PCL_CMDID)) {
13901 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013902 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013903 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013904 }
Govind Singhb53420c2016-03-09 14:32:57 +053013905 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013906}
13907
13908/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013909 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013910 * @wmi_handle: wmi handle
13911 * @msg: Structure containing the following parameters
13912 *
13913 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13914 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13915 *
13916 * Provides notification to the WLAN firmware that host driver is requesting a
13917 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13918 * configurations that include the Dual Band Simultaneous (DBS) feature.
13919 *
13920 * Return: Success if the cmd is sent successfully to the firmware
13921 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013922static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013923 uint32_t hw_mode_index)
13924{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013925 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013926 wmi_buf_t buf;
13927 uint32_t len;
13928
13929 len = sizeof(*cmd);
13930
13931 buf = wmi_buf_alloc(wmi_handle, len);
13932 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013933 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13934 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013935 }
13936
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013937 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013938 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013939 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13940 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13941
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013942 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13943 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013944 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013945 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013946
13947 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013948 WMI_PDEV_SET_HW_MODE_CMDID)) {
13949 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013950 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013951 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013952 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013953 }
13954
Govind Singhb53420c2016-03-09 14:32:57 +053013955 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013956}
13957
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013958#ifdef WLAN_POLICY_MGR_ENABLE
Govind Singha4836fd2016-03-07 16:45:38 +053013959/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013960 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013961 * @wmi_handle: wmi handle
13962 * @msg: Dual MAC config parameters
13963 *
13964 * Configures WLAN firmware with the dual MAC features
13965 *
Govind Singhb53420c2016-03-09 14:32:57 +053013966 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013967 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013968static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013969QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013970 struct policy_mgr_dual_mac_config *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013971{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013972 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013973 wmi_buf_t buf;
13974 uint32_t len;
13975
13976 len = sizeof(*cmd);
13977
13978 buf = wmi_buf_alloc(wmi_handle, len);
13979 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013980 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13981 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013982 }
13983
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013984 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013985 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013986 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013987 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013988 wmi_pdev_set_mac_config_cmd_fixed_param));
13989
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013990 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13991 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013992 cmd->concurrent_scan_config_bits = msg->scan_config;
13993 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013994 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013995 __func__, msg->scan_config, msg->fw_mode_config);
13996
13997 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013998 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13999 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053014000 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014001 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014002 }
Govind Singhb53420c2016-03-09 14:32:57 +053014003 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014004}
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080014005#endif
Govind Singha4836fd2016-03-07 16:45:38 +053014006
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014007#ifdef BIG_ENDIAN_HOST
14008/**
14009* fips_conv_data_be() - LE to BE conversion of FIPS ev data
14010* @param data_len - data length
14011* @param data - pointer to data
14012*
14013* Return: QDF_STATUS - success or error status
14014*/
14015static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14016 struct fips_params *param)
14017{
14018 unsigned char *key_unaligned, *data_unaligned;
14019 int c;
14020 u_int8_t *key_aligned = NULL;
14021 u_int8_t *data_aligned = NULL;
14022
14023 /* Assigning unaligned space to copy the key */
14024 key_unaligned = qdf_mem_malloc(
14025 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
14026 data_unaligned = qdf_mem_malloc(
14027 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
14028
Jeff Johnsonda263992018-05-12 14:22:00 -070014029 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014030 if (key_unaligned == NULL)
14031 return QDF_STATUS_SUCCESS;
14032 /* Checking if space is aligned */
14033 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
14034 /* align to 4 */
14035 key_aligned =
14036 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
14037 FIPS_ALIGN);
14038 } else {
14039 key_aligned = (u_int8_t *)key_unaligned;
14040 }
14041
14042 /* memset and copy content from key to key aligned */
14043 OS_MEMSET(key_aligned, 0, param->key_len);
14044 OS_MEMCPY(key_aligned, param->key, param->key_len);
14045
14046 /* print a hexdump for host debug */
14047 print_hex_dump(KERN_DEBUG,
14048 "\t Aligned and Copied Key:@@@@ ",
14049 DUMP_PREFIX_NONE,
14050 16, 1, key_aligned, param->key_len, true);
14051
Jeff Johnsonda263992018-05-12 14:22:00 -070014052 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014053 if (data_unaligned == NULL)
14054 return QDF_STATUS_SUCCESS;
14055 /* Checking of space is aligned */
14056 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
14057 /* align to 4 */
14058 data_aligned =
14059 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
14060 FIPS_ALIGN);
14061 } else {
14062 data_aligned = (u_int8_t *)data_unaligned;
14063 }
14064
14065 /* memset and copy content from data to data aligned */
14066 OS_MEMSET(data_aligned, 0, param->data_len);
14067 OS_MEMCPY(data_aligned, param->data, param->data_len);
14068
14069 /* print a hexdump for host debug */
14070 print_hex_dump(KERN_DEBUG,
14071 "\t Properly Aligned and Copied Data:@@@@ ",
14072 DUMP_PREFIX_NONE,
14073 16, 1, data_aligned, param->data_len, true);
14074
14075 /* converting to little Endian both key_aligned and
14076 * data_aligned*/
14077 for (c = 0; c < param->key_len/4; c++) {
14078 *((u_int32_t *)key_aligned+c) =
14079 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
14080 }
14081 for (c = 0; c < param->data_len/4; c++) {
14082 *((u_int32_t *)data_aligned+c) =
14083 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
14084 }
14085
14086 /* update endian data to key and data vectors */
14087 OS_MEMCPY(param->key, key_aligned, param->key_len);
14088 OS_MEMCPY(param->data, data_aligned, param->data_len);
14089
14090 /* clean up allocated spaces */
14091 qdf_mem_free(key_unaligned);
14092 key_unaligned = NULL;
14093 key_aligned = NULL;
14094
14095 qdf_mem_free(data_unaligned);
14096 data_unaligned = NULL;
14097 data_aligned = NULL;
14098
14099 return QDF_STATUS_SUCCESS;
14100}
14101#else
14102/**
14103* fips_align_data_be() - DUMMY for LE platform
14104*
14105* Return: QDF_STATUS - success
14106*/
14107static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14108 struct fips_params *param)
14109{
14110 return QDF_STATUS_SUCCESS;
14111}
14112#endif
14113
14114
14115/**
14116 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
14117 * @wmi_handle: wmi handle
14118 * @param: pointer to hold pdev fips param
14119 *
14120 * Return: 0 for success or error code
14121 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014122static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014123send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
14124 struct fips_params *param)
14125{
14126 wmi_pdev_fips_cmd_fixed_param *cmd;
14127 wmi_buf_t buf;
14128 uint8_t *buf_ptr;
14129 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
14130 QDF_STATUS retval = QDF_STATUS_SUCCESS;
14131
14132 /* Length TLV placeholder for array of bytes */
14133 len += WMI_TLV_HDR_SIZE;
14134 if (param->data_len)
14135 len += (param->data_len*sizeof(uint8_t));
14136
14137 /*
14138 * Data length must be multiples of 16 bytes - checked against 0xF -
14139 * and must be less than WMI_SVC_MSG_SIZE - static size of
14140 * wmi_pdev_fips_cmd structure
14141 */
14142
14143 /* do sanity on the input */
14144 if (!(((param->data_len & 0xF) == 0) &&
14145 ((param->data_len > 0) &&
14146 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
14147 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
14148 return QDF_STATUS_E_INVAL;
14149 }
14150
14151 buf = wmi_buf_alloc(wmi_handle, len);
14152 if (!buf) {
14153 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
14154 return QDF_STATUS_E_FAILURE;
14155 }
14156
14157 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14158 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
14159 WMITLV_SET_HDR(&cmd->tlv_header,
14160 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
14161 WMITLV_GET_STRUCT_TLVLEN
14162 (wmi_pdev_fips_cmd_fixed_param));
14163
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014164 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14165 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014166 if (param->key != NULL && param->data != NULL) {
14167 cmd->key_len = param->key_len;
14168 cmd->data_len = param->data_len;
14169 cmd->fips_cmd = !!(param->op);
14170
14171 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
14172 return QDF_STATUS_E_FAILURE;
14173
14174 qdf_mem_copy(cmd->key, param->key, param->key_len);
14175
14176 if (param->mode == FIPS_ENGINE_AES_CTR ||
14177 param->mode == FIPS_ENGINE_AES_MIC) {
14178 cmd->mode = param->mode;
14179 } else {
14180 cmd->mode = FIPS_ENGINE_AES_CTR;
14181 }
14182 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
14183 cmd->key_len, cmd->data_len);
14184
14185 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
14186 cmd->key, cmd->key_len, true);
14187 buf_ptr += sizeof(*cmd);
14188
14189 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
14190
14191 buf_ptr += WMI_TLV_HDR_SIZE;
14192 if (param->data_len)
14193 qdf_mem_copy(buf_ptr,
14194 (uint8_t *) param->data, param->data_len);
14195
14196 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
14197 16, 1, buf_ptr, cmd->data_len, true);
14198
14199 buf_ptr += param->data_len;
14200
14201 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
14202 WMI_PDEV_FIPS_CMDID);
14203 qdf_print("%s return value %d\n", __func__, retval);
14204 } else {
14205 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
14206 wmi_buf_free(buf);
14207 retval = -QDF_STATUS_E_BADMSG;
14208 }
14209
14210 return retval;
14211}
14212
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014213#ifdef WLAN_PMO_ENABLE
14214/**
14215 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
14216 * @wmi_handle: wmi handle
14217 * @vdev_id: vdev id
14218 * @bitmap: Event bitmap
14219 * @enable: enable/disable
14220 *
14221 * Return: CDF status
14222 */
14223static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
14224 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014225 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014226 bool enable)
14227{
14228 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
14229 uint16_t len;
14230 wmi_buf_t buf;
14231 int ret;
14232
14233 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
14234 buf = wmi_buf_alloc(wmi_handle, len);
14235 if (!buf) {
14236 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14237 return QDF_STATUS_E_NOMEM;
14238 }
14239 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
14240 WMITLV_SET_HDR(&cmd->tlv_header,
14241 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
14242 WMITLV_GET_STRUCT_TLVLEN
14243 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
14244 cmd->vdev_id = vdev_id;
14245 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014246 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
14247 WMI_WOW_MAX_EVENT_BM_LEN);
14248
14249 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
14250 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
14251 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014252
14253 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14254 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
14255 if (ret) {
14256 WMI_LOGE("Failed to config wow wakeup event");
14257 wmi_buf_free(buf);
14258 return QDF_STATUS_E_FAILURE;
14259 }
14260
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014261 return QDF_STATUS_SUCCESS;
14262}
14263
14264/**
14265 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
14266 * @wmi_handle: wmi handle
14267 * @vdev_id: vdev id
14268 * @ptrn_id: pattern id
14269 * @ptrn: pattern
14270 * @ptrn_len: pattern length
14271 * @ptrn_offset: pattern offset
14272 * @mask: mask
14273 * @mask_len: mask length
14274 * @user: true for user configured pattern and false for default pattern
14275 * @default_patterns: default patterns
14276 *
14277 * Return: CDF status
14278 */
14279static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
14280 uint8_t vdev_id, uint8_t ptrn_id,
14281 const uint8_t *ptrn, uint8_t ptrn_len,
14282 uint8_t ptrn_offset, const uint8_t *mask,
14283 uint8_t mask_len, bool user,
14284 uint8_t default_patterns)
14285{
14286 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14287 WOW_BITMAP_PATTERN_T *bitmap_pattern;
14288 wmi_buf_t buf;
14289 uint8_t *buf_ptr;
14290 int32_t len;
14291 int ret;
14292
14293 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14294 WMI_TLV_HDR_SIZE +
14295 1 * sizeof(WOW_BITMAP_PATTERN_T) +
14296 WMI_TLV_HDR_SIZE +
14297 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14298 WMI_TLV_HDR_SIZE +
14299 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14300 WMI_TLV_HDR_SIZE +
14301 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14302 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014303 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014304
14305 buf = wmi_buf_alloc(wmi_handle, len);
14306 if (!buf) {
14307 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14308 return QDF_STATUS_E_NOMEM;
14309 }
14310
14311 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14312 buf_ptr = (uint8_t *) cmd;
14313
14314 WMITLV_SET_HDR(&cmd->tlv_header,
14315 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14316 WMITLV_GET_STRUCT_TLVLEN
14317 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14318 cmd->vdev_id = vdev_id;
14319 cmd->pattern_id = ptrn_id;
14320
14321 cmd->pattern_type = WOW_BITMAP_PATTERN;
14322 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14323
14324 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14325 sizeof(WOW_BITMAP_PATTERN_T));
14326 buf_ptr += WMI_TLV_HDR_SIZE;
14327 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
14328
14329 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
14330 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
14331 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
14332
14333 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
14334 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
14335
14336 bitmap_pattern->pattern_offset = ptrn_offset;
14337 bitmap_pattern->pattern_len = ptrn_len;
14338
14339 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
14340 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
14341
14342 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
14343 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
14344
14345 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
14346 bitmap_pattern->pattern_id = ptrn_id;
14347
14348 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
14349 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
14350 bitmap_pattern->pattern_offset, user);
14351 WMI_LOGI("Pattern : ");
14352 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14353 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
14354
14355 WMI_LOGI("Mask : ");
14356 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14357 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
14358
14359 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
14360
14361 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14362 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14363 buf_ptr += WMI_TLV_HDR_SIZE;
14364
14365 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14367 buf_ptr += WMI_TLV_HDR_SIZE;
14368
14369 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14370 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14371 buf_ptr += WMI_TLV_HDR_SIZE;
14372
14373 /* Fill TLV for pattern_info_timeout but no data. */
14374 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14375 buf_ptr += WMI_TLV_HDR_SIZE;
14376
14377 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053014378 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014379 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053014380 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014381
14382 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14383 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14384 if (ret) {
14385 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
14386 wmi_buf_free(buf);
14387 return QDF_STATUS_E_FAILURE;
14388 }
14389
14390 return QDF_STATUS_SUCCESS;
14391}
14392
Govind Singha4836fd2016-03-07 16:45:38 +053014393/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014394 * fill_arp_offload_params_tlv() - Fill ARP offload data
14395 * @wmi_handle: wmi handle
14396 * @offload_req: offload request
14397 * @buf_ptr: buffer pointer
14398 *
14399 * To fill ARP offload data to firmware
14400 * when target goes to wow mode.
14401 *
14402 * Return: None
14403 */
14404static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014405 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014406{
14407
14408 int i;
14409 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014410 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014411
14412 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14413 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
14414 *buf_ptr += WMI_TLV_HDR_SIZE;
14415 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
14416 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
14417 WMITLV_SET_HDR(&arp_tuple->tlv_header,
14418 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
14419 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
14420
14421 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014422 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014423 /* Copy the target ip addr and flags */
14424 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
14425 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014426 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014427 WMI_IPV4_ADDR_LEN);
14428 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014429 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014430 }
14431 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
14432 }
14433}
14434
14435#ifdef WLAN_NS_OFFLOAD
14436/**
14437 * fill_ns_offload_params_tlv() - Fill NS offload data
14438 * @wmi|_handle: wmi handle
14439 * @offload_req: offload request
14440 * @buf_ptr: buffer pointer
14441 *
14442 * To fill NS offload data to firmware
14443 * when target goes to wow mode.
14444 *
14445 * Return: None
14446 */
14447static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014448 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014449{
14450
14451 int i;
14452 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014453
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014454 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14455 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14456 *buf_ptr += WMI_TLV_HDR_SIZE;
14457 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
14458 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14459 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14460 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14461 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
14462
14463 /*
14464 * Fill data only for NS offload in the first ARP tuple for LA
14465 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014466 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014467 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14468 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014469 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014470 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014471 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014472 sizeof(WMI_IPV6_ADDR));
14473 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014474 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014475 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014476 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014477 ns_tuple->flags |=
14478 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14479 }
14480 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014481 i, &ns_req->self_ipv6_addr[i],
14482 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014483
14484 /* target MAC is optional, check if it is valid,
14485 * if this is not valid, the target will use the known
14486 * local MAC address rather than the tuple
14487 */
14488 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014489 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014490 &ns_tuple->target_mac);
14491 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14492 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14493 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14494 }
14495 }
14496 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14497 }
14498}
14499
14500
14501/**
14502 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
14503 * @wmi: wmi handle
14504 * @offload_req: offload request
14505 * @buf_ptr: buffer pointer
14506 *
14507 * To fill extended NS offload extended data to firmware
14508 * when target goes to wow mode.
14509 *
14510 * Return: None
14511 */
14512static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014513 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014514{
14515 int i;
14516 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
14517 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014518
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014519 count = ns_req->num_ns_offload_count;
14520 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014521 WMI_MAX_NS_OFFLOADS;
14522
14523 /* Populate extended NS offload tuples */
14524 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14525 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14526 *buf_ptr += WMI_TLV_HDR_SIZE;
14527 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
14528 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14529 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14530 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14531 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
14532
14533 /*
14534 * Fill data only for NS offload in the first ARP tuple for LA
14535 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014536 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014537 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14538 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014539 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014540 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014541 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014542 sizeof(WMI_IPV6_ADDR));
14543 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014544 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014545 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014546 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014547 ns_tuple->flags |=
14548 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14549 }
14550 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014551 i, &ns_req->self_ipv6_addr[i],
14552 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014553
14554 /* target MAC is optional, check if it is valid,
14555 * if this is not valid, the target will use the
14556 * known local MAC address rather than the tuple
14557 */
14558 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014559 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014560 &ns_tuple->target_mac);
14561 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14562 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14563 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14564 }
14565 }
14566 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14567 }
14568}
14569#else
14570static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014571 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014572{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014573}
14574
14575static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014576 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014577{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014578}
14579#endif
14580
14581/**
Govind Singha4836fd2016-03-07 16:45:38 +053014582 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
14583 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014584 * @arp_offload_req: arp offload request
14585 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053014586 * @arp_only: flag
14587 *
14588 * To configure ARP NS off load data to firmware
14589 * when target goes to wow mode.
14590 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014591 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053014592 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014593static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014594 struct pmo_arp_offload_params *arp_offload_req,
14595 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053014596 uint8_t vdev_id)
14597{
Govind Singha4836fd2016-03-07 16:45:38 +053014598 int32_t res;
14599 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053014600 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053014601 wmi_buf_t buf;
14602 int32_t len;
14603 uint32_t count = 0, num_ns_ext_tuples = 0;
14604
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014605 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053014606
Govind Singha4836fd2016-03-07 16:45:38 +053014607 /*
14608 * TLV place holder size for array of NS tuples
14609 * TLV place holder size for array of ARP tuples
14610 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014611 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
14612 WMI_TLV_HDR_SIZE +
14613 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
14614 WMI_TLV_HDR_SIZE +
14615 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014616
14617 /*
14618 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
14619 * extra length for extended NS offload tuples which follows ARP offload
14620 * tuples. Host needs to fill this structure in following format:
14621 * 2 NS ofload tuples
14622 * 2 ARP offload tuples
14623 * N numbers of extended NS offload tuples if HDD has given more than
14624 * 2 NS offload addresses
14625 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014626 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053014627 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014628 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
14629 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014630 }
14631
14632 buf = wmi_buf_alloc(wmi_handle, len);
14633 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014634 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014635 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014636 }
14637
Vivekc5823092018-03-22 23:27:21 +053014638 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014639 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
14640 WMITLV_SET_HDR(&cmd->tlv_header,
14641 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
14642 WMITLV_GET_STRUCT_TLVLEN
14643 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
14644 cmd->flags = 0;
14645 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014646 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053014647
Govind Singhb53420c2016-03-09 14:32:57 +053014648 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053014649
Govind Singha4836fd2016-03-07 16:45:38 +053014650 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014651 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
14652 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14653 if (num_ns_ext_tuples)
14654 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014655
14656 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14657 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14658 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014659 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014660 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014661 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014662 }
14663
Govind Singhb53420c2016-03-09 14:32:57 +053014664 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014665}
14666
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014667/**
14668 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14669 * @wmi_handle: wmi handle
14670 * @vdev_id: vdev id
14671 * @action: true for enable else false
14672 *
14673 * To enable enhance multicast offload to firmware
14674 * when target goes to wow mode.
14675 *
14676 * Return: QDF Status
14677 */
14678
14679static
14680QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14681 wmi_unified_t wmi_handle,
14682 uint8_t vdev_id, bool action)
14683{
14684 QDF_STATUS status;
14685 wmi_buf_t buf;
14686 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14687
14688 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14689 if (!buf) {
14690 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14691 return QDF_STATUS_E_NOMEM;
14692 }
14693
14694 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14695 wmi_buf_data(buf);
14696
14697 WMITLV_SET_HDR(&cmd->tlv_header,
14698 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14699 WMITLV_GET_STRUCT_TLVLEN(
14700 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14701
14702 cmd->vdev_id = vdev_id;
14703 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14704 ENHANCED_MCAST_FILTER_ENABLED);
14705 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14706 __func__, action, vdev_id);
14707 status = wmi_unified_cmd_send(wmi_handle, buf,
14708 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14709 if (status != QDF_STATUS_SUCCESS) {
14710 qdf_nbuf_free(buf);
14711 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14712 __func__);
14713 }
14714
14715 return status;
14716}
14717
14718/**
14719 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14720 * @wmi_handle: wmi handle
14721 * @param evt_buf: pointer to event buffer
14722 * @param hdr: Pointer to hold header
14723 * @param bufp: Pointer to hold pointer to rx param buffer
14724 *
14725 * Return: QDF_STATUS_SUCCESS for success or error code
14726 */
14727static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14728 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14729{
14730 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14731 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14732
14733 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14734 if (!param_buf) {
14735 WMI_LOGE("gtk param_buf is NULL");
14736 return QDF_STATUS_E_INVAL;
14737 }
14738
14739 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14740 WMI_LOGE("Invalid length for GTK status");
14741 return QDF_STATUS_E_INVAL;
14742 }
14743
14744 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14745 param_buf->fixed_param;
14746 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14747 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14748 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14749 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14750 &fixed_param->replay_counter,
14751 GTK_REPLAY_COUNTER_BYTES);
14752
14753 return QDF_STATUS_SUCCESS;
14754
14755}
14756
14757#ifdef FEATURE_WLAN_RA_FILTERING
14758/**
14759 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14760 * @wmi_handle: wmi handle
14761 * @vdev_id: vdev id
14762 *
14763 * Return: CDF status
14764 */
14765static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14766 uint8_t vdev_id, uint8_t default_pattern,
14767 uint16_t rate_limit_interval)
14768{
14769
14770 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14771 wmi_buf_t buf;
14772 uint8_t *buf_ptr;
14773 int32_t len;
14774 int ret;
14775
14776 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14777 WMI_TLV_HDR_SIZE +
14778 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14779 WMI_TLV_HDR_SIZE +
14780 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14781 WMI_TLV_HDR_SIZE +
14782 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14783 WMI_TLV_HDR_SIZE +
14784 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14785 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014786 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014787
14788 buf = wmi_buf_alloc(wmi_handle, len);
14789 if (!buf) {
14790 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14791 return QDF_STATUS_E_NOMEM;
14792 }
14793
14794 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14795 buf_ptr = (uint8_t *) cmd;
14796
14797 WMITLV_SET_HDR(&cmd->tlv_header,
14798 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14799 WMITLV_GET_STRUCT_TLVLEN
14800 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14801 cmd->vdev_id = vdev_id;
14802 cmd->pattern_id = default_pattern,
14803 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14804 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14805
14806 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T 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 WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14811 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14812 buf_ptr += WMI_TLV_HDR_SIZE;
14813
14814 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14815 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14816 buf_ptr += WMI_TLV_HDR_SIZE;
14817
14818 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14819 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14820 buf_ptr += WMI_TLV_HDR_SIZE;
14821
14822 /* Fill TLV for pattern_info_timeout but no data. */
14823 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14824 buf_ptr += WMI_TLV_HDR_SIZE;
14825
14826 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014827 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014828 buf_ptr += WMI_TLV_HDR_SIZE;
14829
Vivekc5823092018-03-22 23:27:21 +053014830 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014831
14832 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14833 rate_limit_interval, vdev_id);
14834
14835 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14836 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14837 if (ret) {
14838 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14839 wmi_buf_free(buf);
14840 return QDF_STATUS_E_FAILURE;
14841 }
14842
14843 return QDF_STATUS_SUCCESS;
14844
14845}
14846#endif /* FEATURE_WLAN_RA_FILTERING */
14847
14848/**
14849 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14850 * @wmi_handle: wmi handle
14851 * @vdev_id: vdev id
14852 * @multicastAddr: mcast address
14853 * @clearList: clear list flag
14854 *
14855 * Return: QDF_STATUS_SUCCESS for success or error code
14856 */
14857static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14858 uint8_t vdev_id,
14859 struct qdf_mac_addr multicast_addr,
14860 bool clearList)
14861{
14862 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14863 wmi_buf_t buf;
14864 int err;
14865
14866 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14867 if (!buf) {
14868 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14869 return QDF_STATUS_E_NOMEM;
14870 }
14871
14872 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14873 qdf_mem_zero(cmd, sizeof(*cmd));
14874
14875 WMITLV_SET_HDR(&cmd->tlv_header,
14876 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14877 WMITLV_GET_STRUCT_TLVLEN
14878 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14879 cmd->action =
14880 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14881 cmd->vdev_id = vdev_id;
14882 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14883
14884 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14885 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14886
14887 err = wmi_unified_cmd_send(wmi_handle, buf,
14888 sizeof(*cmd),
14889 WMI_SET_MCASTBCAST_FILTER_CMDID);
14890 if (err) {
14891 WMI_LOGE("Failed to send set_param cmd");
14892 wmi_buf_free(buf);
14893 return QDF_STATUS_E_FAILURE;
14894 }
14895
14896 return QDF_STATUS_SUCCESS;
14897}
14898
14899/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014900 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14901 * command to fw
14902 * @wmi_handle: wmi handle
14903 * @vdev_id: vdev id
14904 * @mcast_filter_params: mcast filter params
14905 *
14906 * Return: QDF_STATUS_SUCCESS for success or error code
14907 */
14908static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14909 wmi_unified_t wmi_handle,
14910 uint8_t vdev_id,
14911 struct pmo_mcast_filter_params *filter_param)
14912
14913{
14914 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14915 uint8_t *buf_ptr;
14916 wmi_buf_t buf;
14917 int err;
14918 int i;
14919 uint8_t *mac_addr_src_ptr = NULL;
14920 wmi_mac_addr *mac_addr_dst_ptr;
14921 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14922 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14923
14924 buf = wmi_buf_alloc(wmi_handle, len);
14925 if (!buf) {
14926 WMI_LOGE("Failed to allocate memory");
14927 return QDF_STATUS_E_NOMEM;
14928 }
14929
Vivekc5823092018-03-22 23:27:21 +053014930 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014931 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14932 wmi_buf_data(buf);
14933 qdf_mem_zero(cmd, sizeof(*cmd));
14934
14935 WMITLV_SET_HDR(&cmd->tlv_header,
14936 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14937 WMITLV_GET_STRUCT_TLVLEN
14938 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14939 cmd->operation =
14940 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14941 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14942 cmd->vdev_id = vdev_id;
14943 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14944
14945 buf_ptr += sizeof(*cmd);
14946 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14947 sizeof(wmi_mac_addr) *
14948 filter_param->multicast_addr_cnt);
14949
14950 if (filter_param->multicast_addr_cnt == 0)
14951 goto send_cmd;
14952
14953 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14954 mac_addr_dst_ptr = (wmi_mac_addr *)
14955 (buf_ptr + WMI_TLV_HDR_SIZE);
14956
14957 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14958 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14959 mac_addr_src_ptr += ATH_MAC_LEN;
14960 mac_addr_dst_ptr++;
14961 }
14962
14963send_cmd:
14964 err = wmi_unified_cmd_send(wmi_handle, buf,
14965 len,
14966 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14967 if (err) {
14968 WMI_LOGE("Failed to send set_param cmd");
14969 wmi_buf_free(buf);
14970 return QDF_STATUS_E_FAILURE;
14971 }
14972
14973 return QDF_STATUS_SUCCESS;
14974}
14975
14976
14977/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014978 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14979 * @wmi_handle: wmi handle
14980 * @vdev_id: vdev id
14981 * @params: GTK offload parameters
14982 *
14983 * Return: CDF status
14984 */
14985static
14986QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14987 struct pmo_gtk_req *params,
14988 bool enable_offload,
14989 uint32_t gtk_offload_opcode)
14990{
14991 int len;
14992 wmi_buf_t buf;
14993 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014994 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014995 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014996 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014997
14998 WMI_LOGD("%s Enter", __func__);
14999
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015000 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015001
15002 /* alloc wmi buffer */
15003 buf = wmi_buf_alloc(wmi_handle, len);
15004 if (!buf) {
15005 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
15006 status = QDF_STATUS_E_NOMEM;
15007 goto out;
15008 }
15009
15010 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015011 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015012 WMITLV_SET_HDR(&cmd->tlv_header,
15013 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15014 WMITLV_GET_STRUCT_TLVLEN
15015 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15016
15017 cmd->vdev_id = vdev_id;
15018
15019 /* Request target to enable GTK offload */
15020 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
15021 cmd->flags = gtk_offload_opcode;
15022
15023 /* Copy the keys and replay counter */
15024 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015025 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015026 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
15027 GTK_REPLAY_COUNTER_BYTES);
15028 } else {
15029 cmd->flags = gtk_offload_opcode;
15030 }
15031
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015032 buf_ptr += sizeof(*cmd);
15033 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
15034 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015035
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015036 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
15037 WMITLV_SET_HDR(&ext_param->tlv_header,
15038 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
15039 WMITLV_GET_STRUCT_TLVLEN(
15040 wmi_gtk_offload_fils_tlv_param));
15041 ext_param->vdev_id = vdev_id;
15042 ext_param->flags = cmd->flags;
15043 ext_param->kek_len = params->kek_len;
15044 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
15045 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
15046 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
15047 GTK_REPLAY_COUNTER_BYTES);
15048
15049 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 +053015050 /* send the wmi command */
15051 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15052 WMI_GTK_OFFLOAD_CMDID)) {
15053 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
15054 wmi_buf_free(buf);
15055 status = QDF_STATUS_E_FAILURE;
15056 }
15057
15058out:
15059 WMI_LOGD("%s Exit", __func__);
15060 return status;
15061}
15062
15063/**
15064 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
15065 * @wmi_handle: wmi handle
15066 * @params: GTK offload params
15067 *
15068 * Return: CDF status
15069 */
15070static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
15071 wmi_unified_t wmi_handle,
15072 uint8_t vdev_id,
15073 uint64_t offload_req_opcode)
15074{
15075 int len;
15076 wmi_buf_t buf;
15077 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
15078 QDF_STATUS status = QDF_STATUS_SUCCESS;
15079
15080 len = sizeof(*cmd);
15081
15082 /* alloc wmi buffer */
15083 buf = wmi_buf_alloc(wmi_handle, len);
15084 if (!buf) {
15085 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
15086 status = QDF_STATUS_E_NOMEM;
15087 goto out;
15088 }
15089
15090 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
15091 WMITLV_SET_HDR(&cmd->tlv_header,
15092 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15093 WMITLV_GET_STRUCT_TLVLEN
15094 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15095
15096 /* Request for GTK offload status */
15097 cmd->flags = offload_req_opcode;
15098 cmd->vdev_id = vdev_id;
15099
15100 /* send the wmi command */
15101 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15102 WMI_GTK_OFFLOAD_CMDID)) {
15103 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
15104 wmi_buf_free(buf);
15105 status = QDF_STATUS_E_FAILURE;
15106 }
15107
15108out:
15109 return status;
15110}
15111
15112/**
15113 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
15114 * @wmi_handle: wmi handler
15115 * @action_params: pointer to action_params
15116 *
15117 * Return: 0 for success, otherwise appropriate error code
15118 */
15119static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
15120 struct pmo_action_wakeup_set_params *action_params)
15121{
15122 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
15123 wmi_buf_t buf;
15124 int i;
15125 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015126 uint32_t len = 0, *cmd_args;
15127 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015128
Vivekc5823092018-03-22 23:27:21 +053015129 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015130 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
15131 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015132 if (!buf) {
15133 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
15134 return QDF_STATUS_E_NOMEM;
15135 }
15136 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015137 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015138 WMITLV_SET_HDR(&cmd->tlv_header,
15139 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
15140 WMITLV_GET_STRUCT_TLVLEN(
15141 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
15142
15143 cmd->vdev_id = action_params->vdev_id;
15144 cmd->operation = action_params->operation;
15145
15146 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
15147 cmd->action_category_map[i] =
15148 action_params->action_category_map[i];
15149
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015150 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
15151 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015152 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015153 buf_ptr += WMI_TLV_HDR_SIZE;
15154 cmd_args = (uint32_t *) buf_ptr;
15155 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
15156 cmd_args[i] = action_params->action_per_category[i];
15157
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015158 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015159 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015160 if (err) {
15161 WMI_LOGE("Failed to send ap_ps_egap cmd");
15162 wmi_buf_free(buf);
15163 return QDF_STATUS_E_FAILURE;
15164 }
15165
15166 return QDF_STATUS_SUCCESS;
15167}
15168
15169#ifdef FEATURE_WLAN_LPHB
15170
15171/**
15172 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
15173 * @wmi_handle: wmi handle
15174 * @lphb_conf_req: configuration info
15175 *
15176 * Return: CDF status
15177 */
15178static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
15179 wmi_hb_set_enable_cmd_fixed_param *params)
15180{
15181 QDF_STATUS status;
15182 wmi_buf_t buf = NULL;
15183 uint8_t *buf_ptr;
15184 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
15185 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
15186
15187
15188 buf = wmi_buf_alloc(wmi_handle, len);
15189 if (!buf) {
15190 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15191 return QDF_STATUS_E_NOMEM;
15192 }
15193
15194 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15195 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
15196 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
15197 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
15198 WMITLV_GET_STRUCT_TLVLEN
15199 (wmi_hb_set_enable_cmd_fixed_param));
15200
15201 /* fill in values */
15202 hb_enable_fp->vdev_id = params->session;
15203 hb_enable_fp->enable = params->enable;
15204 hb_enable_fp->item = params->item;
15205 hb_enable_fp->session = params->session;
15206
15207 status = wmi_unified_cmd_send(wmi_handle, buf,
15208 len, WMI_HB_SET_ENABLE_CMDID);
15209 if (QDF_IS_STATUS_ERROR(status)) {
15210 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
15211 status);
15212 wmi_buf_free(buf);
15213 }
15214
15215 return status;
15216}
15217
15218/**
15219 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
15220 * @wmi_handle: wmi handle
15221 * @lphb_conf_req: lphb config request
15222 *
15223 * Return: CDF status
15224 */
15225static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
15226 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
15227{
15228 QDF_STATUS status;
15229 wmi_buf_t buf = NULL;
15230 uint8_t *buf_ptr;
15231 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
15232 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
15233
15234 buf = wmi_buf_alloc(wmi_handle, len);
15235 if (!buf) {
15236 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15237 return QDF_STATUS_E_NOMEM;
15238 }
15239
15240 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15241 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
15242 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
15243 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
15244 WMITLV_GET_STRUCT_TLVLEN
15245 (wmi_hb_set_tcp_params_cmd_fixed_param));
15246
15247 /* fill in values */
15248 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15249 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15250 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15251 hb_tcp_params_fp->seq = lphb_conf_req->seq;
15252 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
15253 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
15254 hb_tcp_params_fp->interval = lphb_conf_req->interval;
15255 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
15256 hb_tcp_params_fp->session = lphb_conf_req->session;
15257 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
15258 &lphb_conf_req->gateway_mac,
15259 sizeof(hb_tcp_params_fp->gateway_mac));
15260
15261 status = wmi_unified_cmd_send(wmi_handle, buf,
15262 len, WMI_HB_SET_TCP_PARAMS_CMDID);
15263 if (QDF_IS_STATUS_ERROR(status)) {
15264 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
15265 status);
15266 wmi_buf_free(buf);
15267 }
15268
15269 return status;
15270}
15271
15272/**
15273 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
15274 * @wmi_handle: wmi handle
15275 * @lphb_conf_req: lphb config request
15276 *
15277 * Return: CDF status
15278 */
15279static
15280QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15281 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
15282{
15283 QDF_STATUS status;
15284 wmi_buf_t buf = NULL;
15285 uint8_t *buf_ptr;
15286 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
15287 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
15288
15289 buf = wmi_buf_alloc(wmi_handle, len);
15290 if (!buf) {
15291 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15292 return QDF_STATUS_E_NOMEM;
15293 }
15294
15295 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15296 hb_tcp_filter_fp =
15297 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
15298 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
15299 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
15300 WMITLV_GET_STRUCT_TLVLEN
15301 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
15302
15303 /* fill in values */
15304 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
15305 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
15306 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
15307 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
15308 memcpy((void *)&hb_tcp_filter_fp->filter,
15309 (void *)&g_hb_tcp_filter_fp->filter,
15310 WMI_WLAN_HB_MAX_FILTER_SIZE);
15311
15312 status = wmi_unified_cmd_send(wmi_handle, buf,
15313 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
15314 if (QDF_IS_STATUS_ERROR(status)) {
15315 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
15316 status);
15317 wmi_buf_free(buf);
15318 }
15319
15320 return status;
15321}
15322
15323/**
15324 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
15325 * @wmi_handle: wmi handle
15326 * @lphb_conf_req: lphb config request
15327 *
15328 * Return: CDF status
15329 */
15330static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
15331 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
15332{
15333 QDF_STATUS status;
15334 wmi_buf_t buf = NULL;
15335 uint8_t *buf_ptr;
15336 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
15337 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
15338
15339 buf = wmi_buf_alloc(wmi_handle, len);
15340 if (!buf) {
15341 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15342 return QDF_STATUS_E_NOMEM;
15343 }
15344
15345 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15346 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
15347 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
15348 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
15349 WMITLV_GET_STRUCT_TLVLEN
15350 (wmi_hb_set_udp_params_cmd_fixed_param));
15351
15352 /* fill in values */
15353 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15354 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15355 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15356 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
15357 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
15358 hb_udp_params_fp->interval = lphb_conf_req->interval;
15359 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
15360 hb_udp_params_fp->session = lphb_conf_req->session;
15361 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
15362 &lphb_conf_req->gateway_mac,
15363 sizeof(lphb_conf_req->gateway_mac));
15364
15365 status = wmi_unified_cmd_send(wmi_handle, buf,
15366 len, WMI_HB_SET_UDP_PARAMS_CMDID);
15367 if (QDF_IS_STATUS_ERROR(status)) {
15368 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
15369 status);
15370 wmi_buf_free(buf);
15371 }
15372
15373 return status;
15374}
15375
15376/**
15377 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
15378 * @wmi_handle: wmi handle
15379 * @lphb_conf_req: lphb config request
15380 *
15381 * Return: CDF status
15382 */
15383static
15384QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15385 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
15386{
15387 QDF_STATUS status;
15388 wmi_buf_t buf = NULL;
15389 uint8_t *buf_ptr;
15390 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
15391 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
15392
15393 buf = wmi_buf_alloc(wmi_handle, len);
15394 if (!buf) {
15395 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15396 return QDF_STATUS_E_NOMEM;
15397 }
15398
15399 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15400 hb_udp_filter_fp =
15401 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
15402 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
15403 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
15404 WMITLV_GET_STRUCT_TLVLEN
15405 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
15406
15407 /* fill in values */
15408 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
15409 hb_udp_filter_fp->length = lphb_conf_req->length;
15410 hb_udp_filter_fp->offset = lphb_conf_req->offset;
15411 hb_udp_filter_fp->session = lphb_conf_req->session;
15412 memcpy((void *)&hb_udp_filter_fp->filter,
15413 (void *)&lphb_conf_req->filter,
15414 WMI_WLAN_HB_MAX_FILTER_SIZE);
15415
15416 status = wmi_unified_cmd_send(wmi_handle, buf,
15417 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
15418 if (QDF_IS_STATUS_ERROR(status)) {
15419 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
15420 status);
15421 wmi_buf_free(buf);
15422 }
15423
15424 return status;
15425}
15426#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015427
Dustin Brownf31f88b2017-05-12 14:01:44 -070015428static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
15429 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015430{
Dustin Brownf31f88b2017-05-12 14:01:44 -070015431 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015432 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070015433 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015434
Dustin Brownf31f88b2017-05-12 14:01:44 -070015435 if (!req) {
15436 WMI_LOGE("req is null");
15437 return QDF_STATUS_E_INVAL;
15438 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015439
Dustin Brownf31f88b2017-05-12 14:01:44 -070015440 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
15441 if (!wmi_buf) {
15442 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015443 return QDF_STATUS_E_NOMEM;
15444 }
15445
Dustin Brownf31f88b2017-05-12 14:01:44 -070015446 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015447 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070015448 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
15449 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
15450 cmd->vdev_id = req->vdev_id;
15451 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
15452 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015453
Dustin Brownf31f88b2017-05-12 14:01:44 -070015454 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
15455 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015456
Dustin Brownf31f88b2017-05-12 14:01:44 -070015457 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
15458 WMI_HW_DATA_FILTER_CMDID);
15459 if (QDF_IS_STATUS_ERROR(status)) {
15460 WMI_LOGE("Failed to configure hw filter");
15461 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015462 }
15463
Dustin Brownf31f88b2017-05-12 14:01:44 -070015464 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015465}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015466
15467/**
15468 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
15469 * @wmi_handle: wmi handle
15470 * @vdev_id: vdev id
15471 * @enable: Flag to enable/disable packet filter
15472 *
15473 * Return: QDF_STATUS_SUCCESS for success or error code
15474 */
15475static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
15476 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
15477{
15478 int32_t len;
15479 int ret = 0;
15480 wmi_buf_t buf;
15481 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
15482
15483 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
15484
15485 buf = wmi_buf_alloc(wmi_handle, len);
15486 if (!buf) {
15487 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
15488 return QDF_STATUS_E_NOMEM;
15489 }
15490
15491 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
15492 WMITLV_SET_HDR(&cmd->tlv_header,
15493 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
15494 WMITLV_GET_STRUCT_TLVLEN(
15495 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
15496
15497 cmd->vdev_id = vdev_id;
15498 if (enable)
15499 cmd->enable = PACKET_FILTER_SET_ENABLE;
15500 else
15501 cmd->enable = PACKET_FILTER_SET_DISABLE;
15502
15503 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
15504 __func__, cmd->enable, vdev_id);
15505
15506 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15507 WMI_PACKET_FILTER_ENABLE_CMDID);
15508 if (ret) {
15509 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
15510 wmi_buf_free(buf);
15511 }
15512
15513 return ret;
15514}
15515
15516/**
15517 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
15518 * @wmi_handle: wmi handle
15519 * @vdev_id: vdev id
15520 * @rcv_filter_param: Packet filter parameters
15521 * @filter_id: Filter id
15522 * @enable: Flag to add/delete packet filter configuration
15523 *
15524 * Return: QDF_STATUS_SUCCESS for success or error code
15525 */
15526static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
15527 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
15528 uint8_t filter_id, bool enable)
15529{
15530 int len, i;
15531 int err = 0;
15532 wmi_buf_t buf;
15533 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
15534
15535
15536 /* allocate the memory */
15537 len = sizeof(*cmd);
15538 buf = wmi_buf_alloc(wmi_handle, len);
15539 if (!buf) {
15540 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
15541 return QDF_STATUS_E_NOMEM;
15542 }
15543
15544 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
15545 WMITLV_SET_HDR(&cmd->tlv_header,
15546 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
15547 WMITLV_GET_STRUCT_TLVLEN
15548 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
15549
15550 cmd->vdev_id = vdev_id;
15551 cmd->filter_id = filter_id;
15552 if (enable)
15553 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
15554 else
15555 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
15556
15557 if (enable) {
15558 cmd->num_params = QDF_MIN(
15559 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
15560 rcv_filter_param->num_params);
15561 cmd->filter_type = rcv_filter_param->filter_type;
15562 cmd->coalesce_time = rcv_filter_param->coalesce_time;
15563
15564 for (i = 0; i < cmd->num_params; i++) {
15565 cmd->paramsData[i].proto_type =
15566 rcv_filter_param->params_data[i].protocol_layer;
15567 cmd->paramsData[i].cmp_type =
15568 rcv_filter_param->params_data[i].compare_flag;
15569 cmd->paramsData[i].data_length =
15570 rcv_filter_param->params_data[i].data_length;
15571 cmd->paramsData[i].data_offset =
15572 rcv_filter_param->params_data[i].data_offset;
15573 memcpy(&cmd->paramsData[i].compareData,
15574 rcv_filter_param->params_data[i].compare_data,
15575 sizeof(cmd->paramsData[i].compareData));
15576 memcpy(&cmd->paramsData[i].dataMask,
15577 rcv_filter_param->params_data[i].data_mask,
15578 sizeof(cmd->paramsData[i].dataMask));
15579 }
15580 }
15581
15582 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
15583 cmd->filter_action, cmd->filter_id, cmd->num_params);
15584 /* send the command along with data */
15585 err = wmi_unified_cmd_send(wmi_handle, buf, len,
15586 WMI_PACKET_FILTER_CONFIG_CMDID);
15587 if (err) {
15588 WMI_LOGE("Failed to send pkt_filter cmd");
15589 wmi_buf_free(buf);
15590 return QDF_STATUS_E_FAILURE;
15591 }
15592
15593 return QDF_STATUS_SUCCESS;
15594}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053015595#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015596
Govind Singha4836fd2016-03-07 16:45:38 +053015597/**
15598 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
15599 * @wmi_handle: wmi handle
15600 * @request: SSID hotlist set request
15601 *
Govind Singhb53420c2016-03-09 14:32:57 +053015602 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053015603 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015604static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053015605send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
15606 struct ssid_hotlist_request_params *request)
15607{
15608 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
15609 wmi_buf_t wmi_buf;
15610 uint32_t len;
15611 uint32_t array_size;
15612 uint8_t *buf_ptr;
15613
15614 /* length of fixed portion */
15615 len = sizeof(*cmd);
15616
15617 /* length of variable portion */
15618 array_size =
15619 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
15620 len += WMI_TLV_HDR_SIZE + array_size;
15621
15622 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15623 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015624 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15625 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015626 }
15627
15628 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
15629 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
15630 buf_ptr;
15631 WMITLV_SET_HDR
15632 (&cmd->tlv_header,
15633 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15634 WMITLV_GET_STRUCT_TLVLEN
15635 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15636
15637 cmd->request_id = request->request_id;
15638 cmd->requestor_id = 0;
15639 cmd->vdev_id = request->session_id;
15640 cmd->table_id = 0;
15641 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15642 cmd->total_entries = request->ssid_count;
15643 cmd->num_entries_in_page = request->ssid_count;
15644 cmd->first_entry_index = 0;
15645
15646 buf_ptr += sizeof(*cmd);
15647 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15648
15649 if (request->ssid_count) {
15650 wmi_extscan_hotlist_ssid_entry *entry;
15651 int i;
15652
15653 buf_ptr += WMI_TLV_HDR_SIZE;
15654 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15655 for (i = 0; i < request->ssid_count; i++) {
15656 WMITLV_SET_HDR
15657 (entry,
15658 WMITLV_TAG_ARRAY_STRUC,
15659 WMITLV_GET_STRUCT_TLVLEN
15660 (wmi_extscan_hotlist_ssid_entry));
15661 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015662 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015663 request->ssids[i].ssid.mac_ssid,
15664 request->ssids[i].ssid.length);
15665 entry->band = request->ssids[i].band;
15666 entry->min_rssi = request->ssids[i].rssi_low;
15667 entry->max_rssi = request->ssids[i].rssi_high;
15668 entry++;
15669 }
15670 cmd->mode = WMI_EXTSCAN_MODE_START;
15671 } else {
15672 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15673 }
15674
15675 if (wmi_unified_cmd_send
15676 (wmi_handle, wmi_buf, len,
15677 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015678 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015679 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015680 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015681 }
15682
Govind Singhb53420c2016-03-09 14:32:57 +053015683 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015684}
15685
15686/**
15687 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15688 * @wmi_handle: wmi handle
15689 * @vdev_id: vdev id
15690 *
15691 * This function sends roam synch complete event to fw.
15692 *
15693 * Return: CDF STATUS
15694 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015695static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015696 uint8_t vdev_id)
15697{
15698 wmi_roam_synch_complete_fixed_param *cmd;
15699 wmi_buf_t wmi_buf;
15700 uint8_t *buf_ptr;
15701 uint16_t len;
15702 len = sizeof(wmi_roam_synch_complete_fixed_param);
15703
15704 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15705 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015706 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15707 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015708 }
15709 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15710 buf_ptr = (uint8_t *) cmd;
15711 WMITLV_SET_HDR(&cmd->tlv_header,
15712 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15713 WMITLV_GET_STRUCT_TLVLEN
15714 (wmi_roam_synch_complete_fixed_param));
15715 cmd->vdev_id = vdev_id;
15716 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15717 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015718 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015719 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015720 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015721 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015722 }
15723
Govind Singhb53420c2016-03-09 14:32:57 +053015724 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015725}
15726
15727/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015728 * send_fw_test_cmd_tlv() - send fw test command to fw.
15729 * @wmi_handle: wmi handle
15730 * @wmi_fwtest: fw test command
15731 *
15732 * This function sends fw test command to fw.
15733 *
15734 * Return: CDF STATUS
15735 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015736static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015737QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15738 struct set_fwtest_params *wmi_fwtest)
15739{
15740 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15741 wmi_buf_t wmi_buf;
15742 uint16_t len;
15743
15744 len = sizeof(*cmd);
15745
15746 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15747 if (!wmi_buf) {
15748 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15749 return QDF_STATUS_E_NOMEM;
15750 }
15751
15752 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15753 WMITLV_SET_HDR(&cmd->tlv_header,
15754 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15755 WMITLV_GET_STRUCT_TLVLEN(
15756 wmi_fwtest_set_param_cmd_fixed_param));
15757 cmd->param_id = wmi_fwtest->arg;
15758 cmd->param_value = wmi_fwtest->value;
15759
15760 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15761 WMI_FWTEST_CMDID)) {
15762 WMI_LOGP("%s: failed to send fw test command", __func__);
15763 qdf_nbuf_free(wmi_buf);
15764 return QDF_STATUS_E_FAILURE;
15765 }
15766
15767 return QDF_STATUS_SUCCESS;
15768}
15769
15770/**
Govind Singha4836fd2016-03-07 16:45:38 +053015771 * send_unit_test_cmd_tlv() - send unit test command to fw.
15772 * @wmi_handle: wmi handle
15773 * @wmi_utest: unit test command
15774 *
15775 * This function send unit test command to fw.
15776 *
15777 * Return: CDF STATUS
15778 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015779static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015780 struct wmi_unit_test_cmd *wmi_utest)
15781{
15782 wmi_unit_test_cmd_fixed_param *cmd;
15783 wmi_buf_t wmi_buf;
15784 uint8_t *buf_ptr;
15785 int i;
15786 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015787 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015788
15789 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015790 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015791 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15792
15793 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15794 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015795 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15796 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015797 }
15798
15799 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15800 buf_ptr = (uint8_t *) cmd;
15801 WMITLV_SET_HDR(&cmd->tlv_header,
15802 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15803 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15804 cmd->vdev_id = wmi_utest->vdev_id;
15805 cmd->module_id = wmi_utest->module_id;
15806 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015807 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015808 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15809 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15810 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015811 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015812 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15813 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15814 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015815 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015816 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015817 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015818 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015819 }
15820 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15821 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015822 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015823 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015824 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015825 }
15826
Govind Singhb53420c2016-03-09 14:32:57 +053015827 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015828}
15829
15830/**
15831 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15832 * @wmi_handle: wma handle
15833 * @roaminvoke: roam invoke command
15834 *
15835 * Send roam invoke command to fw for fastreassoc.
15836 *
15837 * Return: CDF STATUS
15838 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015839static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015840 struct wmi_roam_invoke_cmd *roaminvoke,
15841 uint32_t ch_hz)
15842{
15843 wmi_roam_invoke_cmd_fixed_param *cmd;
15844 wmi_buf_t wmi_buf;
15845 u_int8_t *buf_ptr;
15846 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015847 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015848 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015849 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015850
15851 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015852 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015853 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15854 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015855 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15856 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15857 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015858 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15859 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015860 }
15861
15862 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15863 buf_ptr = (u_int8_t *) cmd;
15864 WMITLV_SET_HDR(&cmd->tlv_header,
15865 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15866 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15867 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015868 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015869 if (roaminvoke->is_same_bssid)
15870 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15871 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015872
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015873 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015874 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015875 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15876 cmd->num_buf = 1;
15877 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015878 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015879 cmd->num_buf = 0;
15880 }
Naveen Rawat77797922017-01-20 17:00:07 -080015881
Govind Singha4836fd2016-03-07 16:45:38 +053015882 cmd->roam_ap_sel_mode = 0;
15883 cmd->roam_delay = 0;
15884 cmd->num_chan = 1;
15885 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015886
Govind Singha4836fd2016-03-07 16:45:38 +053015887 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15888 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15889 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015890 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015891 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015892 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015893 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15894 (sizeof(wmi_mac_addr)));
15895 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15896 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015897
15898 /* move to next tlv i.e. bcn_prb_buf_list */
15899 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15900
15901 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15902 sizeof(wmi_tlv_buf_len_param));
15903
15904 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15905 buf_len_tlv->buf_len = roaminvoke->frame_len;
15906
15907 /* move to next tlv i.e. bcn_prb_frm */
15908 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15909 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15910 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15911
15912 /* copy frame after the header */
15913 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15914 roaminvoke->frame_buf,
15915 roaminvoke->frame_len);
15916
15917 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
15918 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
15919 buf_ptr + WMI_TLV_HDR_SIZE,
15920 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015921 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15922 cmd->flags, cmd->roam_scan_mode,
15923 cmd->roam_ap_sel_mode, cmd->roam_delay,
15924 cmd->num_chan, cmd->num_bssid);
15925 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015926
Govind Singha4836fd2016-03-07 16:45:38 +053015927 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15928 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015929 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015930 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015931 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015932 }
15933
Govind Singhb53420c2016-03-09 14:32:57 +053015934 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015935}
15936
15937/**
15938 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15939 * @wmi_handle: wmi handle
15940 * @command: command
15941 * @vdev_id: vdev id
15942 *
15943 * This function set roam offload command to fw.
15944 *
15945 * Return: CDF status
15946 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015947static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015948 uint32_t command, uint32_t vdev_id)
15949{
Govind Singh67922e82016-04-01 16:48:57 +053015950 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015951 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15952 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015953 int len;
15954 uint8_t *buf_ptr;
15955
15956 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15957 buf = wmi_buf_alloc(wmi_handle, len);
15958 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015959 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15960 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015961 }
15962
15963 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15964
15965 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15966 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15967 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15968 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15969 cmd_fp->vdev_id = vdev_id;
15970 cmd_fp->command_arg = command;
15971
15972 status = wmi_unified_cmd_send(wmi_handle, buf,
15973 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015974 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015975 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015976 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015977 goto error;
15978 }
15979
Govind Singhb53420c2016-03-09 14:32:57 +053015980 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15981 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015982
15983error:
15984 wmi_buf_free(buf);
15985
Govind Singh67922e82016-04-01 16:48:57 +053015986 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015987}
15988
15989/**
15990 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15991 * @wmi_handle: wmi handle
15992 * @ap_profile_p: ap profile
15993 * @vdev_id: vdev id
15994 *
15995 * Send WMI_ROAM_AP_PROFILE to firmware
15996 *
15997 * Return: CDF status
15998 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015999static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016000 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053016001{
Govind Singha4836fd2016-03-07 16:45:38 +053016002 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016003 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016004 int len;
16005 uint8_t *buf_ptr;
16006 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016007 wmi_roam_cnd_scoring_param *score_param;
16008 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053016009
16010 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016011 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053016012 buf = wmi_buf_alloc(wmi_handle, len);
16013 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016014 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16015 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016016 }
16017
16018 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16019 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
16020 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
16021 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
16022 WMITLV_GET_STRUCT_TLVLEN
16023 (wmi_roam_ap_profile_fixed_param));
16024 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016025 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053016026 roam_ap_profile_fp->id = 0;
16027 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
16028
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016029 profile = (wmi_ap_profile *)buf_ptr;
16030 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053016031 WMITLV_TAG_STRUC_wmi_ap_profile,
16032 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016033 profile->flags = ap_profile->profile.flags;
16034 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
16035 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
16036 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
16037 profile->ssid.ssid_len);
16038 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
16039 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
16040 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
16041 profile->rsn_mcastmgmtcipherset =
16042 ap_profile->profile.rsn_mcastmgmtcipherset;
16043 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
16044
16045 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",
16046 profile->flags, profile->rssi_threshold,
16047 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
16048 profile->rsn_authmode, profile->rsn_ucastcipherset,
16049 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
16050 profile->rssi_abs_thresh);
16051
16052 buf_ptr += sizeof(wmi_ap_profile);
16053
16054 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
16055 WMITLV_SET_HDR(&score_param->tlv_header,
16056 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
16057 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
16058 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
16059 score_param->rssi_weightage_pcnt =
16060 ap_profile->param.rssi_weightage;
16061 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
16062 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
16063 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
16064 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
16065 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
16066 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
16067 score_param->esp_qbss_weightage_pcnt =
16068 ap_profile->param.esp_qbss_weightage;
16069 score_param->beamforming_weightage_pcnt =
16070 ap_profile->param.beamforming_weightage;
16071 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
16072 score_param->oce_wan_weightage_pcnt =
16073 ap_profile->param.oce_wan_weightage;
16074
16075 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",
16076 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
16077 score_param->ht_weightage_pcnt,
16078 score_param->vht_weightage_pcnt,
16079 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
16080 score_param->band_weightage_pcnt,
16081 score_param->nss_weightage_pcnt,
16082 score_param->esp_qbss_weightage_pcnt,
16083 score_param->beamforming_weightage_pcnt,
16084 score_param->pcl_weightage_pcnt,
16085 score_param->oce_wan_weightage_pcnt);
16086
16087 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
16088 score_param->band_scoring.score_pcnt =
16089 ap_profile->param.band_index_score;
16090 score_param->nss_scoring.score_pcnt =
16091 ap_profile->param.nss_index_score;
16092
16093 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
16094 score_param->bw_scoring.score_pcnt,
16095 score_param->band_scoring.score_pcnt,
16096 score_param->nss_scoring.score_pcnt);
16097
16098 score_param->rssi_scoring.best_rssi_threshold =
16099 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
16100 score_param->rssi_scoring.good_rssi_threshold =
16101 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
16102 score_param->rssi_scoring.bad_rssi_threshold =
16103 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
16104 score_param->rssi_scoring.good_rssi_pcnt =
16105 ap_profile->param.rssi_scoring.good_rssi_pcnt;
16106 score_param->rssi_scoring.bad_rssi_pcnt =
16107 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
16108 score_param->rssi_scoring.good_bucket_size =
16109 ap_profile->param.rssi_scoring.good_bucket_size;
16110 score_param->rssi_scoring.bad_bucket_size =
16111 ap_profile->param.rssi_scoring.bad_bucket_size;
16112 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
16113 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
16114
16115 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
16116 score_param->rssi_scoring.best_rssi_threshold,
16117 score_param->rssi_scoring.good_rssi_threshold,
16118 score_param->rssi_scoring.bad_rssi_threshold,
16119 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
16120 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
16121 score_param->rssi_scoring.good_rssi_pcnt,
16122 score_param->rssi_scoring.bad_rssi_pcnt,
16123 score_param->rssi_scoring.good_bucket_size,
16124 score_param->rssi_scoring.bad_bucket_size);
16125
16126 score_param->esp_qbss_scoring.num_slot =
16127 ap_profile->param.esp_qbss_scoring.num_slot;
16128 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
16129 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
16130 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
16131 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
16132 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
16133 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
16134 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
16135 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
16136
16137 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16138 score_param->esp_qbss_scoring.num_slot,
16139 score_param->esp_qbss_scoring.score_pcnt3_to_0,
16140 score_param->esp_qbss_scoring.score_pcnt7_to_4,
16141 score_param->esp_qbss_scoring.score_pcnt11_to_8,
16142 score_param->esp_qbss_scoring.score_pcnt15_to_12);
16143
16144 score_param->oce_wan_scoring.num_slot =
16145 ap_profile->param.oce_wan_scoring.num_slot;
16146 score_param->oce_wan_scoring.score_pcnt3_to_0 =
16147 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
16148 score_param->oce_wan_scoring.score_pcnt7_to_4 =
16149 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
16150 score_param->oce_wan_scoring.score_pcnt11_to_8 =
16151 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
16152 score_param->oce_wan_scoring.score_pcnt15_to_12 =
16153 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
16154
16155 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16156 score_param->oce_wan_scoring.num_slot,
16157 score_param->oce_wan_scoring.score_pcnt3_to_0,
16158 score_param->oce_wan_scoring.score_pcnt7_to_4,
16159 score_param->oce_wan_scoring.score_pcnt11_to_8,
16160 score_param->oce_wan_scoring.score_pcnt15_to_12);
16161
Govind Singha4836fd2016-03-07 16:45:38 +053016162 status = wmi_unified_cmd_send(wmi_handle, buf,
16163 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053016164 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016165 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016166 status);
Govind Singh67922e82016-04-01 16:48:57 +053016167 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053016168 }
16169
Govind Singhb53420c2016-03-09 14:32:57 +053016170 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053016171
Govind Singh67922e82016-04-01 16:48:57 +053016172 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016173}
16174
16175/**
16176 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
16177 * @wmi_handle: wmi handle
16178 * @scan_period: scan period
16179 * @scan_age: scan age
16180 * @vdev_id: vdev id
16181 *
16182 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
16183 *
16184 * Return: CDF status
16185 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016186static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016187 uint32_t scan_period,
16188 uint32_t scan_age,
16189 uint32_t vdev_id)
16190{
Govind Singh67922e82016-04-01 16:48:57 +053016191 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016192 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053016193 int len;
16194 uint8_t *buf_ptr;
16195 wmi_roam_scan_period_fixed_param *scan_period_fp;
16196
16197 /* Send scan period values */
16198 len = sizeof(wmi_roam_scan_period_fixed_param);
16199 buf = wmi_buf_alloc(wmi_handle, len);
16200 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016201 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16202 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016203 }
16204
16205 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16206 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
16207 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
16208 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
16209 WMITLV_GET_STRUCT_TLVLEN
16210 (wmi_roam_scan_period_fixed_param));
16211 /* fill in scan period values */
16212 scan_period_fp->vdev_id = vdev_id;
16213 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
16214 scan_period_fp->roam_scan_age = scan_age;
16215
16216 status = wmi_unified_cmd_send(wmi_handle, buf,
16217 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053016218 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016219 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016220 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016221 goto error;
16222 }
16223
Govind Singhb53420c2016-03-09 14:32:57 +053016224 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053016225 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053016226 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016227error:
16228 wmi_buf_free(buf);
16229
Govind Singh67922e82016-04-01 16:48:57 +053016230 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016231}
16232
16233/**
16234 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
16235 * @wmi_handle: wmi handle
16236 * @chan_count: channel count
16237 * @chan_list: channel list
16238 * @list_type: list type
16239 * @vdev_id: vdev id
16240 *
16241 * Set roam offload channel list.
16242 *
16243 * Return: CDF status
16244 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016245static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016246 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070016247 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053016248 uint8_t list_type, uint32_t vdev_id)
16249{
Govind Singha4836fd2016-03-07 16:45:38 +053016250 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016251 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016252 int len, list_tlv_len;
16253 int i;
16254 uint8_t *buf_ptr;
16255 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053016256 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053016257
16258 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053016259 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053016260 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053016261 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053016262 }
16263 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053016264 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053016265 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
16266 buf = wmi_buf_alloc(wmi_handle, len);
16267 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016268 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16269 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016270 }
16271
16272 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16273 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
16274 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
16275 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
16276 WMITLV_GET_STRUCT_TLVLEN
16277 (wmi_roam_chan_list_fixed_param));
16278 chan_list_fp->vdev_id = vdev_id;
16279 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053016280 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053016281 /* external app is controlling channel list */
16282 chan_list_fp->chan_list_type =
16283 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
16284 } else {
16285 /* umac supplied occupied channel list in LFR */
16286 chan_list_fp->chan_list_type =
16287 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
16288 }
16289
16290 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
16291 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16292 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053016293 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016294 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053016295 for (i = 0; ((i < chan_list_fp->num_chan) &&
16296 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
16297 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053016298 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053016299 }
16300
16301 status = wmi_unified_cmd_send(wmi_handle, buf,
16302 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053016303 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016304 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016305 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016306 goto error;
16307 }
16308
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016309 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053016310 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016311error:
16312 wmi_buf_free(buf);
16313
Govind Singh67922e82016-04-01 16:48:57 +053016314 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016315}
16316
16317/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016318 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
16319 * @wmi_handle: wmi handle
16320 * @req_buf: per roam config buffer
16321 *
16322 * Return: QDF status
16323 */
16324static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
16325 struct wmi_per_roam_config_req *req_buf)
16326{
16327 wmi_buf_t buf = NULL;
16328 QDF_STATUS status;
16329 int len;
16330 uint8_t *buf_ptr;
16331 wmi_roam_per_config_fixed_param *wmi_per_config;
16332
16333 len = sizeof(wmi_roam_per_config_fixed_param);
16334 buf = wmi_buf_alloc(wmi_handle, len);
16335 if (!buf) {
16336 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16337 return QDF_STATUS_E_NOMEM;
16338 }
16339
16340 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16341 wmi_per_config =
16342 (wmi_roam_per_config_fixed_param *) buf_ptr;
16343 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
16344 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
16345 WMITLV_GET_STRUCT_TLVLEN
16346 (wmi_roam_per_config_fixed_param));
16347
16348 /* fill in per roam config values */
16349 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016350
16351 wmi_per_config->enable = req_buf->per_config.enable;
16352 wmi_per_config->high_rate_thresh =
16353 (req_buf->per_config.tx_high_rate_thresh << 16) |
16354 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
16355 wmi_per_config->low_rate_thresh =
16356 (req_buf->per_config.tx_low_rate_thresh << 16) |
16357 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
16358 wmi_per_config->pkt_err_rate_thresh_pct =
16359 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
16360 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
16361 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053016362 wmi_per_config->pkt_err_rate_mon_time =
16363 (req_buf->per_config.tx_per_mon_time << 16) |
16364 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053016365 wmi_per_config->min_candidate_rssi =
16366 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016367
16368 /* Send per roam config parameters */
16369 status = wmi_unified_cmd_send(wmi_handle, buf,
16370 len, WMI_ROAM_PER_CONFIG_CMDID);
16371 if (QDF_IS_STATUS_ERROR(status)) {
16372 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
16373 status);
16374 wmi_buf_free(buf);
16375 return status;
16376 }
16377
16378 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
16379 req_buf->per_config.enable, req_buf->vdev_id);
16380 return QDF_STATUS_SUCCESS;
16381}
16382
16383/**
Govind Singha4836fd2016-03-07 16:45:38 +053016384 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
16385 * @wmi_handle: wmi handle
16386 * @rssi_change_thresh: RSSI Change threshold
16387 * @bcn_rssi_weight: beacon RSSI weight
16388 * @vdev_id: vdev id
16389 *
16390 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
16391 *
16392 * Return: CDF status
16393 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016394static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016395 uint32_t vdev_id,
16396 int32_t rssi_change_thresh,
16397 uint32_t bcn_rssi_weight,
16398 uint32_t hirssi_delay_btw_scans)
16399{
Govind Singha4836fd2016-03-07 16:45:38 +053016400 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016401 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016402 int len;
16403 uint8_t *buf_ptr;
16404 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
16405
16406 /* Send rssi change parameters */
16407 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
16408 buf = wmi_buf_alloc(wmi_handle, len);
16409 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016410 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16411 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016412 }
16413
16414 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16415 rssi_change_fp =
16416 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
16417 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
16418 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
16419 WMITLV_GET_STRUCT_TLVLEN
16420 (wmi_roam_scan_rssi_change_threshold_fixed_param));
16421 /* fill in rssi change threshold (hysteresis) values */
16422 rssi_change_fp->vdev_id = vdev_id;
16423 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
16424 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
16425 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
16426
16427 status = wmi_unified_cmd_send(wmi_handle, buf,
16428 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053016429 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016430 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016431 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016432 goto error;
16433 }
16434
Govind Singhb53420c2016-03-09 14:32:57 +053016435 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053016436 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053016437 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
16438 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016439error:
16440 wmi_buf_free(buf);
16441
Govind Singh67922e82016-04-01 16:48:57 +053016442 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016443}
16444
16445/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
16446 * @wmi_handle: wmi handle.
16447 * @cmd: size of command structure.
16448 * @per_entry_size: per entry size.
16449 *
16450 * This utility function calculates how many hotlist entries can
16451 * fit in one page.
16452 *
16453 * Return: number of entries
16454 */
16455static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
16456 size_t cmd_size,
16457 size_t per_entry_size)
16458{
16459 uint32_t avail_space = 0;
16460 int num_entries = 0;
16461 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
16462
16463 /* Calculate number of hotlist entries that can
16464 * be passed in wma message request.
16465 */
16466 avail_space = max_msg_len - cmd_size;
16467 num_entries = avail_space / per_entry_size;
16468 return num_entries;
16469}
16470
16471/**
16472 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
16473 * @wmi_handle: wmi handle
16474 * @photlist: hotlist command params
16475 * @buf_len: buffer length
16476 *
16477 * This function fills individual elements for hotlist request and
16478 * TLV for bssid entries
16479 *
16480 * Return: CDF Status.
16481 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016482static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016483 struct ext_scan_setbssi_hotlist_params *
16484 photlist, int *buf_len)
16485{
16486 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
16487 wmi_extscan_hotlist_entry *dest_hotlist;
16488 struct ap_threshold_params *src_ap = photlist->ap;
16489 wmi_buf_t buf;
16490 uint8_t *buf_ptr;
16491
16492 int j, index = 0;
16493 int cmd_len = 0;
16494 int num_entries;
16495 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016496 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053016497 int len = sizeof(*cmd);
16498
16499 len += WMI_TLV_HDR_SIZE;
16500 cmd_len = len;
16501
16502 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
16503 cmd_len,
16504 sizeof(*dest_hotlist));
16505 /* setbssid hotlist expects the bssid list
16506 * to be non zero value
16507 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016508 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080016509 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053016510 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053016511 }
16512
16513 /* Split the hot list entry pages and send multiple command
16514 * requests if the buffer reaches the maximum request size
16515 */
16516 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053016517 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053016518 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
16519 buf = wmi_buf_alloc(wmi_handle, len);
16520 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016521 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
16522 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016523 }
16524 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16525 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
16526 buf_ptr;
16527 WMITLV_SET_HDR(&cmd->tlv_header,
16528 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
16529 WMITLV_GET_STRUCT_TLVLEN
16530 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
16531
16532 /* Multiple requests are sent until the num_entries_in_page
16533 * matches the total_entries
16534 */
16535 cmd->request_id = photlist->requestId;
16536 cmd->vdev_id = photlist->sessionId;
16537 cmd->total_entries = numap;
16538 cmd->mode = 1;
16539 cmd->num_entries_in_page = min_entries;
16540 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
16541 cmd->first_entry_index = index;
16542
Govind Singhb53420c2016-03-09 14:32:57 +053016543 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016544 __func__, cmd->vdev_id, cmd->total_entries,
16545 cmd->num_entries_in_page,
16546 cmd->lost_ap_scan_count);
16547
16548 buf_ptr += sizeof(*cmd);
16549 WMITLV_SET_HDR(buf_ptr,
16550 WMITLV_TAG_ARRAY_STRUC,
16551 min_entries * sizeof(wmi_extscan_hotlist_entry));
16552 dest_hotlist = (wmi_extscan_hotlist_entry *)
16553 (buf_ptr + WMI_TLV_HDR_SIZE);
16554
16555 /* Populate bssid, channel info and rssi
16556 * for the bssid's that are sent as hotlists.
16557 */
16558 for (j = 0; j < min_entries; j++) {
16559 WMITLV_SET_HDR(dest_hotlist,
16560 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
16561 WMITLV_GET_STRUCT_TLVLEN
16562 (wmi_extscan_hotlist_entry));
16563
16564 dest_hotlist->min_rssi = src_ap->low;
16565 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
16566 &dest_hotlist->bssid);
16567
Govind Singhb53420c2016-03-09 14:32:57 +053016568 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016569 __func__, dest_hotlist->channel,
16570 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053016571 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053016572 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16573 __func__, dest_hotlist->bssid.mac_addr31to0,
16574 dest_hotlist->bssid.mac_addr47to32);
16575 dest_hotlist++;
16576 src_ap++;
16577 }
16578 buf_ptr += WMI_TLV_HDR_SIZE +
16579 (min_entries * sizeof(wmi_extscan_hotlist_entry));
16580
16581 if (wmi_unified_cmd_send(wmi_handle, buf, len,
16582 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016583 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053016584 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053016585 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016586 }
16587 index = index + min_entries;
16588 num_entries = numap - min_entries;
16589 len = cmd_len;
16590 }
Govind Singhb53420c2016-03-09 14:32:57 +053016591 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016592}
16593
Govind Singhbca3b1b2016-05-02 17:59:24 +053016594/**
Dustin Brown4423f632017-01-13 15:24:07 -080016595 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
16596 * @wmi_handle: the WMI handle
16597 * @vdev_id: the Id of the vdev to apply the configuration to
16598 * @ucast_mode: the active BPF mode to configure for unicast packets
16599 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
16600 * packets
16601 *
16602 * Return: QDF status
16603 */
16604static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
16605 uint8_t vdev_id,
16606 enum wmi_host_active_bpf_mode ucast_mode,
16607 enum wmi_host_active_bpf_mode mcast_bcast_mode)
16608{
16609 const WMITLV_TAG_ID tag_id =
16610 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
16611 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
16612 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
16613 QDF_STATUS status;
16614 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
16615 wmi_buf_t buf;
16616
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016617 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080016618 vdev_id, ucast_mode, mcast_bcast_mode);
16619
16620 /* allocate command buffer */
16621 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
16622 if (!buf) {
16623 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
16624 return QDF_STATUS_E_NOMEM;
16625 }
16626
16627 /* set TLV header */
16628 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
16629 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
16630
16631 /* populate data */
16632 cmd->vdev_id = vdev_id;
16633 cmd->uc_mode = ucast_mode;
16634 cmd->mcbc_mode = mcast_bcast_mode;
16635
16636 /* send to FW */
16637 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
16638 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
16639 if (QDF_IS_STATUS_ERROR(status)) {
16640 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
16641 status);
16642 wmi_buf_free(buf);
16643 return status;
16644 }
16645
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016646 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080016647
16648 return QDF_STATUS_SUCCESS;
16649}
16650
16651/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053016652 * send_power_dbg_cmd_tlv() - send power debug commands
16653 * @wmi_handle: wmi handle
16654 * @param: wmi power debug parameter
16655 *
16656 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
16657 *
16658 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16659 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016660static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
16661 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053016662{
16663 wmi_buf_t buf = NULL;
16664 QDF_STATUS status;
16665 int len, args_tlv_len;
16666 uint8_t *buf_ptr;
16667 uint8_t i;
16668 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
16669 uint32_t *cmd_args;
16670
16671 /* Prepare and send power debug cmd parameters */
16672 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
16673 len = sizeof(*cmd) + args_tlv_len;
16674 buf = wmi_buf_alloc(wmi_handle, len);
16675 if (!buf) {
16676 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16677 return QDF_STATUS_E_NOMEM;
16678 }
16679
16680 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16681 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
16682 WMITLV_SET_HDR(&cmd->tlv_header,
16683 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
16684 WMITLV_GET_STRUCT_TLVLEN
16685 (wmi_pdev_wal_power_debug_cmd_fixed_param));
16686
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016687 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16688 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016689 cmd->module_id = param->module_id;
16690 cmd->num_args = param->num_args;
16691 buf_ptr += sizeof(*cmd);
16692 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16693 (param->num_args * sizeof(uint32_t)));
16694 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
16695 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080016696 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053016697 cmd_args[i] = param->args[i];
16698 WMI_LOGI("%d,", param->args[i]);
16699 }
16700
16701 status = wmi_unified_cmd_send(wmi_handle, buf,
16702 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
16703 if (QDF_IS_STATUS_ERROR(status)) {
16704 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
16705 status);
16706 goto error;
16707 }
16708
16709 return QDF_STATUS_SUCCESS;
16710error:
16711 wmi_buf_free(buf);
16712
16713 return status;
16714}
16715
Govind Singhe7f2f342016-05-23 12:12:52 +053016716/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016717 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
16718 * @wmi_handle: wmi handle
16719 * @param: wmi multiple vdev restart req param
16720 *
16721 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
16722 *
16723 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16724 */
16725static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
16726 wmi_unified_t wmi_handle,
16727 struct multiple_vdev_restart_params *param)
16728{
16729 wmi_buf_t buf;
16730 QDF_STATUS qdf_status;
16731 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
16732 int i;
16733 uint8_t *buf_ptr;
16734 uint32_t *vdev_ids;
16735 wmi_channel *chan_info;
16736 struct channel_param *tchan_info;
16737 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
16738
16739 len += sizeof(wmi_channel);
16740 if (param->num_vdevs)
16741 len += sizeof(uint32_t) * param->num_vdevs;
16742
16743 buf = wmi_buf_alloc(wmi_handle, len);
16744 if (!buf) {
16745 WMI_LOGE("Failed to allocate memory\n");
16746 qdf_status = QDF_STATUS_E_NOMEM;
16747 goto end;
16748 }
16749
16750 buf_ptr = (uint8_t *)wmi_buf_data(buf);
16751 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
16752 buf_ptr;
16753
16754 WMITLV_SET_HDR(&cmd->tlv_header,
16755 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
16756 WMITLV_GET_STRUCT_TLVLEN
16757 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016758 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16759 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016760 cmd->requestor_id = param->requestor_id;
16761 cmd->disable_hw_ack = param->disable_hw_ack;
16762 cmd->cac_duration_ms = param->cac_duration_ms;
16763 cmd->num_vdevs = param->num_vdevs;
16764
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016765 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
16766 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
16767 " cmd->num_vdevs: %d ",
16768 __func__, cmd->pdev_id, cmd->requestor_id,
16769 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016770 buf_ptr += sizeof(*cmd);
16771
16772 WMITLV_SET_HDR(buf_ptr,
16773 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053016774 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016775 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
16776 for (i = 0; i < param->num_vdevs; i++) {
16777 vdev_ids[i] = param->vdev_ids[i];
16778 }
16779
Vivekc5823092018-03-22 23:27:21 +053016780 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016781
16782 WMITLV_SET_HDR(buf_ptr,
16783 WMITLV_TAG_STRUC_wmi_channel,
16784 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053016785 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016786 tchan_info = &(param->ch_param);
16787 chan_info->mhz = tchan_info->mhz;
16788 chan_info->band_center_freq1 = tchan_info->cfreq1;
16789 chan_info->band_center_freq2 = tchan_info->cfreq2;
16790 if (tchan_info->is_chan_passive)
16791 WMI_SET_CHANNEL_FLAG(chan_info,
16792 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016793 if (tchan_info->dfs_set)
16794 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
16795
Sathish Kumar45e991b2017-02-27 10:35:40 +053016796 if (tchan_info->allow_vht)
16797 WMI_SET_CHANNEL_FLAG(chan_info,
16798 WMI_CHAN_FLAG_ALLOW_VHT);
16799 else if (tchan_info->allow_ht)
16800 WMI_SET_CHANNEL_FLAG(chan_info,
16801 WMI_CHAN_FLAG_ALLOW_HT);
16802 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
16803 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
16804 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
16805 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
16806 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
16807 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080016808 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016809
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016810 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
16811 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
16812 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
16813 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
16814 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
16815 "tchan_info->reg_class_id: %d ,"
16816 "tchan_info->maxregpower : %d ", __func__,
16817 tchan_info->is_chan_passive, tchan_info->dfs_set,
16818 tchan_info->allow_vht, tchan_info->allow_ht,
16819 tchan_info->antennamax, tchan_info->phy_mode,
16820 tchan_info->minpower, tchan_info->maxpower,
16821 tchan_info->maxregpower, tchan_info->reg_class_id,
16822 tchan_info->maxregpower);
16823
Sathish Kumar45e991b2017-02-27 10:35:40 +053016824 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
16825 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
16826
16827 if (QDF_IS_STATUS_ERROR(qdf_status)) {
16828 WMI_LOGE("%s: Failed to send\n", __func__);
16829 wmi_buf_free(buf);
16830 }
16831
16832end:
16833 return qdf_status;
16834}
16835
16836/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080016837 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
16838 * @wmi_handle: wmi handle
16839 * @pdev_id: pdev id
16840 *
16841 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16842 *
16843 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16844 */
16845static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16846 uint32_t pdev_id)
16847{
16848 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16849 wmi_buf_t buf;
16850 uint16_t len;
16851 QDF_STATUS ret;
16852
16853 len = sizeof(*cmd);
16854 buf = wmi_buf_alloc(wmi_handle, len);
16855
16856 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16857
16858 if (!buf) {
16859 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16860 return QDF_STATUS_E_NOMEM;
16861 }
16862
16863 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16864 wmi_buf_data(buf);
16865
16866 WMITLV_SET_HDR(&cmd->tlv_header,
16867 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16868 WMITLV_GET_STRUCT_TLVLEN(
16869 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16870
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016871 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016872 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16873 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16874 if (QDF_IS_STATUS_ERROR(ret)) {
16875 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16876 __func__, ret, pdev_id);
16877 wmi_buf_free(buf);
16878 return QDF_STATUS_E_FAILURE;
16879 }
16880
16881 return QDF_STATUS_SUCCESS;
16882}
16883
16884/**
16885 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16886 * @wmi_handle: wmi handle
16887 * @pdev_id: pdev id
16888 *
16889 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16890 *
16891 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16892 */
16893static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16894 uint32_t pdev_id)
16895{
16896 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16897 wmi_buf_t buf;
16898 uint16_t len;
16899 QDF_STATUS ret;
16900
16901 len = sizeof(*cmd);
16902 buf = wmi_buf_alloc(wmi_handle, len);
16903
16904 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16905
16906 if (!buf) {
16907 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16908 return QDF_STATUS_E_NOMEM;
16909 }
16910
16911 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16912 wmi_buf_data(buf);
16913
16914 WMITLV_SET_HDR(&cmd->tlv_header,
16915 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16916 WMITLV_GET_STRUCT_TLVLEN(
16917 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16918
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016919 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016920 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16921 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16922 if (QDF_IS_STATUS_ERROR(ret)) {
16923 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16924 __func__, ret, pdev_id);
16925 wmi_buf_free(buf);
16926 return QDF_STATUS_E_FAILURE;
16927 }
16928
16929 return QDF_STATUS_SUCCESS;
16930}
16931
16932/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016933 * init_cmd_send_tlv() - send initialization cmd to fw
16934 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016935 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016936 *
16937 * Return: QDF_STATUS_SUCCESS for success or error code
16938 */
16939static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016940 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016941{
16942 wmi_buf_t buf;
16943 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016944 uint8_t *buf_ptr;
16945 wmi_resource_config *resource_cfg;
16946 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016947 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016948 uint16_t idx;
16949 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016950 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016951
Kiran Venkatappa26117052016-12-23 19:58:54 +053016952 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16953 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016954 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016955
16956 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16957 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16958 WMI_TLV_HDR_SIZE +
16959 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16960
16961 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016962 if (!buf) {
16963 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16964 return QDF_STATUS_E_FAILURE;
16965 }
16966
16967 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16968 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16969 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16970
16971 host_mem_chunks = (wlan_host_memory_chunk *)
16972 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16973 + WMI_TLV_HDR_SIZE);
16974
16975 WMITLV_SET_HDR(&cmd->tlv_header,
16976 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16977 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16978
Kiran Venkatappa26117052016-12-23 19:58:54 +053016979 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016980 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16981 WMITLV_TAG_STRUC_wmi_resource_config,
16982 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16983
Kiran Venkatappa26117052016-12-23 19:58:54 +053016984 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016985 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16986 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16987 WMITLV_GET_STRUCT_TLVLEN
16988 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016989 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16990 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16991 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016992 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16993 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016994 idx, host_mem_chunks[idx].size,
16995 host_mem_chunks[idx].ptr);
16996 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016997 cmd->num_host_mem_chunks = param->num_mem_chunks;
16998 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16999
Govind Singhe7f2f342016-05-23 12:12:52 +053017000 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
17001 WMITLV_TAG_ARRAY_STRUC,
17002 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053017003 param->num_mem_chunks));
17004
17005 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017006 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053017007
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017008 /* Fill fw_abi_vers */
17009 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053017010
Abhishek Singh716c46c2016-05-04 16:24:07 +053017011 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
17012 if (QDF_IS_STATUS_ERROR(ret)) {
17013 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
17014 ret);
17015 wmi_buf_free(buf);
17016 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017017
Abhishek Singh716c46c2016-05-04 16:24:07 +053017018 return ret;
17019
Govind Singhe7f2f342016-05-23 12:12:52 +053017020}
17021
17022/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080017023 * send_addba_send_cmd_tlv() - send addba send command to fw
17024 * @wmi_handle: wmi handle
17025 * @param: pointer to delba send params
17026 * @macaddr: peer mac address
17027 *
17028 * Send WMI_ADDBA_SEND_CMDID command to firmware
17029 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17030 */
17031static QDF_STATUS
17032send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
17033 uint8_t macaddr[IEEE80211_ADDR_LEN],
17034 struct addba_send_params *param)
17035{
17036 wmi_addba_send_cmd_fixed_param *cmd;
17037 wmi_buf_t buf;
17038 uint16_t len;
17039 QDF_STATUS ret;
17040
17041 len = sizeof(*cmd);
17042
17043 buf = wmi_buf_alloc(wmi_handle, len);
17044 if (!buf) {
17045 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17046 return QDF_STATUS_E_NOMEM;
17047 }
17048
17049 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
17050
17051 WMITLV_SET_HDR(&cmd->tlv_header,
17052 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
17053 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
17054
17055 cmd->vdev_id = param->vdev_id;
17056 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17057 cmd->tid = param->tidno;
17058 cmd->buffersize = param->buffersize;
17059
17060 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
17061 if (QDF_IS_STATUS_ERROR(ret)) {
17062 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17063 wmi_buf_free(buf);
17064 return QDF_STATUS_E_FAILURE;
17065 }
17066
17067 return QDF_STATUS_SUCCESS;
17068}
17069
17070/**
17071 * send_delba_send_cmd_tlv() - send delba send command to fw
17072 * @wmi_handle: wmi handle
17073 * @param: pointer to delba send params
17074 * @macaddr: peer mac address
17075 *
17076 * Send WMI_DELBA_SEND_CMDID command to firmware
17077 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17078 */
17079static QDF_STATUS
17080send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
17081 uint8_t macaddr[IEEE80211_ADDR_LEN],
17082 struct delba_send_params *param)
17083{
17084 wmi_delba_send_cmd_fixed_param *cmd;
17085 wmi_buf_t buf;
17086 uint16_t len;
17087 QDF_STATUS ret;
17088
17089 len = sizeof(*cmd);
17090
17091 buf = wmi_buf_alloc(wmi_handle, len);
17092 if (!buf) {
17093 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17094 return QDF_STATUS_E_NOMEM;
17095 }
17096
17097 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
17098
17099 WMITLV_SET_HDR(&cmd->tlv_header,
17100 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
17101 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
17102
17103 cmd->vdev_id = param->vdev_id;
17104 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17105 cmd->tid = param->tidno;
17106 cmd->initiator = param->initiator;
17107 cmd->reasoncode = param->reasoncode;
17108
17109 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
17110 if (QDF_IS_STATUS_ERROR(ret)) {
17111 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17112 wmi_buf_free(buf);
17113 return QDF_STATUS_E_FAILURE;
17114 }
17115
17116 return QDF_STATUS_SUCCESS;
17117}
17118
17119/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080017120 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
17121 * to fw
17122 * @wmi_handle: wmi handle
17123 * @param: pointer to addba clearresp params
17124 * @macaddr: peer mac address
17125 * Return: 0 for success or error code
17126 */
17127static QDF_STATUS
17128send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
17129 uint8_t macaddr[IEEE80211_ADDR_LEN],
17130 struct addba_clearresponse_params *param)
17131{
17132 wmi_addba_clear_resp_cmd_fixed_param *cmd;
17133 wmi_buf_t buf;
17134 uint16_t len;
17135 QDF_STATUS ret;
17136
17137 len = sizeof(*cmd);
17138
17139 buf = wmi_buf_alloc(wmi_handle, len);
17140 if (!buf) {
17141 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
17142 return QDF_STATUS_E_FAILURE;
17143 }
17144 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
17145
17146 WMITLV_SET_HDR(&cmd->tlv_header,
17147 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
17148 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
17149
17150 cmd->vdev_id = param->vdev_id;
17151 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17152
17153 ret = wmi_unified_cmd_send(wmi_handle,
17154 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
17155 if (QDF_IS_STATUS_ERROR(ret)) {
17156 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17157 wmi_buf_free(buf);
17158 return QDF_STATUS_E_FAILURE;
17159 }
17160
17161 return QDF_STATUS_SUCCESS;
17162}
17163
17164/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017165 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
17166 * @wmi_handle: wmi handle
17167 * @bcn_ctrl_param: pointer to bcn_offload_control param
17168 *
17169 * Return: QDF_STATUS_SUCCESS for success or error code
17170 */
17171static
17172QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
17173 struct bcn_offload_control *bcn_ctrl_param)
17174{
17175 wmi_buf_t buf;
17176 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
17177 QDF_STATUS ret;
17178 uint32_t len;
17179
17180 len = sizeof(*cmd);
17181
17182 buf = wmi_buf_alloc(wmi_handle, len);
17183 if (!buf) {
17184 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17185 return QDF_STATUS_E_FAILURE;
17186 }
17187
17188 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
17189 WMITLV_SET_HDR(&cmd->tlv_header,
17190 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
17191 WMITLV_GET_STRUCT_TLVLEN
17192 (wmi_bcn_offload_ctrl_cmd_fixed_param));
17193 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053017194 switch (bcn_ctrl_param->bcn_ctrl_op) {
17195 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017196 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053017197 break;
17198 case BCN_OFFLD_CTRL_TX_ENABLE:
17199 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
17200 break;
17201 case BCN_OFFLD_CTRL_SWBA_DISABLE:
17202 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
17203 break;
17204 case BCN_OFFLD_CTRL_SWBA_ENABLE:
17205 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
17206 break;
17207 default:
17208 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
17209 bcn_ctrl_param->bcn_ctrl_op);
17210 wmi_buf_free(buf);
17211 return QDF_STATUS_E_FAILURE;
17212 break;
17213 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017214 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
17215 WMI_BCN_OFFLOAD_CTRL_CMDID);
17216
17217 if (QDF_IS_STATUS_ERROR(ret)) {
17218 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
17219 ret);
17220 wmi_buf_free(buf);
17221 }
17222
17223 return ret;
17224}
17225
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017226#ifdef WLAN_FEATURE_NAN_CONVERGENCE
17227static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
17228 struct nan_datapath_initiator_req *ndp_req)
17229{
17230 uint16_t len;
17231 wmi_buf_t buf;
17232 uint8_t *tlv_ptr;
17233 QDF_STATUS status;
17234 wmi_channel *ch_tlv;
17235 wmi_ndp_initiator_req_fixed_param *cmd;
17236 uint32_t passphrase_len, service_name_len;
17237 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
17238
17239 /*
17240 * WMI command expects 4 byte alligned len:
17241 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17242 */
17243 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
17244 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
17245 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
17246 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
17247 service_name_len =
17248 qdf_roundup(ndp_req->service_name.service_name_len, 4);
17249 /* allocated memory for fixed params as well as variable size data */
17250 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
17251 + ndp_cfg_len + ndp_app_info_len + pmk_len
17252 + passphrase_len + service_name_len;
17253
17254 buf = wmi_buf_alloc(wmi_handle, len);
17255 if (!buf) {
17256 WMI_LOGE("wmi_buf_alloc failed");
17257 return QDF_STATUS_E_NOMEM;
17258 }
17259
17260 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
17261 WMITLV_SET_HDR(&cmd->tlv_header,
17262 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
17263 WMITLV_GET_STRUCT_TLVLEN(
17264 wmi_ndp_initiator_req_fixed_param));
17265 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
17266 cmd->transaction_id = ndp_req->transaction_id;
17267 cmd->service_instance_id = ndp_req->service_instance_id;
17268 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
17269 &cmd->peer_discovery_mac_addr);
17270
17271 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
17272 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
17273 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
17274 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
17275 cmd->nan_csid = ndp_req->ncs_sk_type;
17276 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
17277 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
17278
17279 ch_tlv = (wmi_channel *)&cmd[1];
17280 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
17281 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
17282 ch_tlv->mhz = ndp_req->channel;
17283 tlv_ptr = (uint8_t *)&ch_tlv[1];
17284
17285 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17286 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17287 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17288 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17289
17290 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17291 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17292 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
17293 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17294
17295 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17296 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
17297 cmd->nan_pmk_len);
17298 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17299
17300 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17301 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
17302 cmd->nan_passphrase_len);
17303 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17304
17305 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17306 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17307 ndp_req->service_name.service_name,
17308 cmd->nan_servicename_len);
17309 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17310
17311 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
17312 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
17313 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
17314 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
17315 cmd->peer_discovery_mac_addr.mac_addr31to0,
17316 cmd->peer_discovery_mac_addr.mac_addr47to32);
17317
17318 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
17319 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17320 ndp_req->ndp_config.ndp_cfg,
17321 ndp_req->ndp_config.ndp_cfg_len);
17322
17323 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
17324 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17325 ndp_req->ndp_info.ndp_app_info,
17326 ndp_req->ndp_info.ndp_app_info_len);
17327
17328 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17329 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17330 ndp_req->pmk.pmk, cmd->nan_pmk_len);
17331
17332 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17333 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17334 ndp_req->passphrase.passphrase,
17335 cmd->nan_passphrase_len);
17336
17337 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17338 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17339 ndp_req->service_name.service_name,
17340 cmd->nan_servicename_len);
17341
17342 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
17343 WMI_NDP_INITIATOR_REQ_CMDID);
17344
17345 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17346 WMI_NDP_INITIATOR_REQ_CMDID);
17347 if (QDF_IS_STATUS_ERROR(status)) {
17348 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
17349 wmi_buf_free(buf);
17350 }
17351
17352 return status;
17353}
17354
17355static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
17356 struct nan_datapath_responder_req *req)
17357{
17358 uint16_t len;
17359 wmi_buf_t buf;
17360 uint8_t *tlv_ptr;
17361 QDF_STATUS status;
17362 wmi_ndp_responder_req_fixed_param *cmd;
17363 uint32_t passphrase_len, service_name_len;
17364 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
17365
17366 vdev_id = wlan_vdev_get_id(req->vdev);
17367 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
17368 vdev_id, req->transaction_id,
17369 req->ndp_rsp,
17370 req->ndp_instance_id,
17371 req->ndp_info.ndp_app_info_len);
17372
17373 /*
17374 * WMI command expects 4 byte alligned len:
17375 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17376 */
17377 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
17378 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
17379 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
17380 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
17381 service_name_len =
17382 qdf_roundup(req->service_name.service_name_len, 4);
17383
17384 /* allocated memory for fixed params as well as variable size data */
17385 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
17386 + pmk_len + passphrase_len + service_name_len;
17387
17388 buf = wmi_buf_alloc(wmi_handle, len);
17389 if (!buf) {
17390 WMI_LOGE("wmi_buf_alloc failed");
17391 return QDF_STATUS_E_NOMEM;
17392 }
17393 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
17394 WMITLV_SET_HDR(&cmd->tlv_header,
17395 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
17396 WMITLV_GET_STRUCT_TLVLEN(
17397 wmi_ndp_responder_req_fixed_param));
17398 cmd->vdev_id = vdev_id;
17399 cmd->transaction_id = req->transaction_id;
17400 cmd->ndp_instance_id = req->ndp_instance_id;
17401 cmd->rsp_code = req->ndp_rsp;
17402 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
17403 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
17404 cmd->nan_pmk_len = req->pmk.pmk_len;
17405 cmd->nan_csid = req->ncs_sk_type;
17406 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
17407 cmd->nan_servicename_len = req->service_name.service_name_len;
17408
17409 tlv_ptr = (uint8_t *)&cmd[1];
17410 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17411 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17412 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17413
17414 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17415 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17416 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17417 req->ndp_info.ndp_app_info,
17418 req->ndp_info.ndp_app_info_len);
17419
17420 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17421 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17422 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
17423 cmd->nan_pmk_len);
17424
17425 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17426 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17427 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17428 req->passphrase.passphrase,
17429 cmd->nan_passphrase_len);
17430 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17431
17432 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17433 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17434 req->service_name.service_name,
17435 cmd->nan_servicename_len);
17436
17437 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17438
17439 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
17440 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
17441
17442 WMI_LOGD("ndp_config len: %d",
17443 req->ndp_config.ndp_cfg_len);
17444 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17445 req->ndp_config.ndp_cfg,
17446 req->ndp_config.ndp_cfg_len);
17447
17448 WMI_LOGD("ndp_app_info len: %d",
17449 req->ndp_info.ndp_app_info_len);
17450 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17451 req->ndp_info.ndp_app_info,
17452 req->ndp_info.ndp_app_info_len);
17453
17454 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17455 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17456 req->pmk.pmk, cmd->nan_pmk_len);
17457
17458 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17459 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17460 req->passphrase.passphrase,
17461 cmd->nan_passphrase_len);
17462
17463 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17464 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17465 req->service_name.service_name,
17466 cmd->nan_servicename_len);
17467
17468 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
17469 WMI_NDP_RESPONDER_REQ_CMDID);
17470 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17471 WMI_NDP_RESPONDER_REQ_CMDID);
17472 if (QDF_IS_STATUS_ERROR(status)) {
17473 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
17474 wmi_buf_free(buf);
17475 }
17476 return status;
17477}
17478
17479static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
17480 struct nan_datapath_end_req *req)
17481{
17482 uint16_t len;
17483 wmi_buf_t buf;
17484 QDF_STATUS status;
17485 uint32_t ndp_end_req_len, i;
17486 wmi_ndp_end_req *ndp_end_req_lst;
17487 wmi_ndp_end_req_fixed_param *cmd;
17488
17489 /* len of tlv following fixed param */
17490 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
17491 /* above comes out to 4 byte alligned already, no need of padding */
17492 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
17493 buf = wmi_buf_alloc(wmi_handle, len);
17494 if (!buf) {
17495 WMI_LOGE("Malloc failed");
17496 return QDF_STATUS_E_NOMEM;
17497 }
17498
17499 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
17500 WMITLV_SET_HDR(&cmd->tlv_header,
17501 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
17502 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
17503
17504 cmd->transaction_id = req->transaction_id;
17505
17506 /* set tlv pointer to end of fixed param */
17507 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
17508 ndp_end_req_len);
17509
17510 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
17511 WMI_TLV_HDR_SIZE);
17512 for (i = 0; i < req->num_ndp_instances; i++) {
17513 WMITLV_SET_HDR(&ndp_end_req_lst[i],
17514 WMITLV_TAG_ARRAY_FIXED_STRUC,
17515 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
17516
17517 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
17518 }
17519
17520 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
17521 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17522 WMI_NDP_END_REQ_CMDID);
17523 if (QDF_IS_STATUS_ERROR(status)) {
17524 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
17525 wmi_buf_free(buf);
17526 }
17527
17528 return status;
17529}
17530
17531static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017532 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017533{
17534 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
17535 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
17536
17537 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
17538 fixed_params = event->fixed_param;
17539
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017540 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017541 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17542 fixed_params->vdev_id,
17543 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017544 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017545 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017546 return QDF_STATUS_E_INVAL;
17547 }
17548
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017549 rsp->transaction_id = fixed_params->transaction_id;
17550 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17551 rsp->status = fixed_params->rsp_status;
17552 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017553
17554 return QDF_STATUS_SUCCESS;
17555}
17556
17557static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017558 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017559{
17560 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
17561 wmi_ndp_indication_event_fixed_param *fixed_params;
17562
17563 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
17564 fixed_params =
17565 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
17566
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017567 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17568 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17569 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17570 return QDF_STATUS_E_INVAL;
17571 }
17572
17573 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17574 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17575 fixed_params->ndp_app_info_len,
17576 event->num_ndp_app_info);
17577 return QDF_STATUS_E_INVAL;
17578 }
17579
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017580 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017581 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17582 fixed_params->vdev_id,
17583 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017584 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017585 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017586 return QDF_STATUS_E_INVAL;
17587 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017588 rsp->service_instance_id = fixed_params->service_instance_id;
17589 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17590 rsp->role = fixed_params->self_ndp_role;
17591 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017592
17593 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017594 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017595 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017596 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017597
17598 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
17599 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
17600 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
17601 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
17602 fixed_params->service_instance_id,
17603 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
17604 fixed_params->accept_policy,
17605 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017606 rsp->peer_mac_addr.bytes,
17607 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017608
17609 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17610 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17611 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17612
17613 WMI_LOGD("ndp_app_info - %d bytes",
17614 fixed_params->ndp_app_info_len);
17615 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17616 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17617
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017618 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
17619 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17620 rsp->ncs_sk_type = fixed_params->nan_csid;
17621 rsp->scid.scid_len = fixed_params->nan_scid_len;
17622 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
17623 rsp->ndp_config.ndp_cfg_len);
17624 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
17625 rsp->ndp_info.ndp_app_info_len);
17626 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017627 WMI_LOGD("scid hex dump:");
17628 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017629 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017630
17631 return QDF_STATUS_SUCCESS;
17632}
17633
17634static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017635 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017636{
17637 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
17638 wmi_ndp_confirm_event_fixed_param *fixed_params;
17639
17640 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
17641 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017642 WMI_LOGD("WMI_NDP_CONFIRM_EVENTID(0x%X) received. vdev %d, ndp_instance %d, rsp_code %d, reason_code: %d, num_active_ndps_on_peer: %d",
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017643 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
17644 fixed_params->ndp_instance_id, fixed_params->rsp_code,
17645 fixed_params->reason_code,
17646 fixed_params->num_active_ndps_on_peer);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017647
17648 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17649 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17650 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17651 return QDF_STATUS_E_INVAL;
17652 }
17653
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017654 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17655 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17656 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17657
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017658 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17659 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17660 fixed_params->ndp_app_info_len,
17661 event->num_ndp_app_info);
17662 return QDF_STATUS_E_INVAL;
17663 }
17664
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017665 WMI_LOGD("ndp_app_info - %d bytes",
17666 fixed_params->ndp_app_info_len);
17667 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17668 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17669
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017670 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017671 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17672 fixed_params->vdev_id,
17673 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017674 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017675 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017676 return QDF_STATUS_E_INVAL;
17677 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017678 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17679 rsp->rsp_code = fixed_params->rsp_code;
17680 rsp->reason_code = fixed_params->reason_code;
17681 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017682 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017683 rsp->peer_ndi_mac_addr.bytes);
17684 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17685 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
17686 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017687
17688 return QDF_STATUS_SUCCESS;
17689}
17690
17691static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017692 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017693{
17694 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17695 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17696
17697 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17698 fixed_params = event->fixed_param;
17699
17700 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",
17701 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017702 rsp->peer_mac_addr.bytes, rsp->transaction_id,
17703 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017704
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017705 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017706 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17707 fixed_params->vdev_id,
17708 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017709 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017710 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017711 return QDF_STATUS_E_INVAL;
17712 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017713 rsp->transaction_id = fixed_params->transaction_id;
17714 rsp->reason = fixed_params->reason_code;
17715 rsp->status = fixed_params->rsp_status;
17716 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017717 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017718 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017719
17720 return QDF_STATUS_SUCCESS;
17721}
17722
17723static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017724 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017725{
17726 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17727 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17728
17729 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17730 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017731 WMI_LOGD("WMI_NDP_END_RSP_EVENTID(0x%X) received. transaction_id: %d, rsp_status: %d, reason_code: %d",
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017732 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17733 fixed_params->rsp_status, fixed_params->reason_code);
17734
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017735 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017736 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017737 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017738 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017739 return QDF_STATUS_E_INVAL;
17740 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017741 rsp->transaction_id = fixed_params->transaction_id;
17742 rsp->reason = fixed_params->reason_code;
17743 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017744
17745 return QDF_STATUS_SUCCESS;
17746}
17747
17748static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17749 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17750{
17751 uint32_t i, buf_size;
17752 wmi_ndp_end_indication *ind;
17753 struct qdf_mac_addr peer_addr;
17754 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17755
17756 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17757 ind = event->ndp_end_indication_list;
17758
17759 if (event->num_ndp_end_indication_list == 0) {
17760 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017761 return QDF_STATUS_E_INVAL;
17762 }
17763
17764 WMI_LOGD("number of ndp instances = %d",
17765 event->num_ndp_end_indication_list);
17766
17767 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17768 sizeof((*rsp)->ndp_map[0]))) {
17769 WMI_LOGE("num_ndp_end_ind_list %d too large",
17770 event->num_ndp_end_indication_list);
17771 return QDF_STATUS_E_INVAL;
17772 }
17773
17774 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17775 sizeof((*rsp)->ndp_map[0]);
17776 *rsp = qdf_mem_malloc(buf_size);
17777 if (!(*rsp)) {
17778 WMI_LOGE("Failed to allocate memory");
17779 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017780 }
17781
17782 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17783 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17784 if (!(*rsp)->vdev) {
17785 WMI_LOGE("vdev is null");
17786 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017787 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017788 return QDF_STATUS_E_INVAL;
17789 }
17790
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017791 (*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
Naveen Rawat963ee942018-04-13 16:38:36 -070017814#ifdef QCA_SUPPORT_CP_STATS
17815/**
17816 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
17817 * @wmi_handle: wma handle
17818 * @evt_buf: event buffer
17819 * @out_buff: buffer to populated after stats extraction
17820 *
17821 * Return: status of operation
17822 */
17823static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
17824 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
17825{
17826 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17827 wmi_congestion_stats *congestion_stats;
17828
17829 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
17830 congestion_stats = param_buf->congestion_stats;
17831 if (!congestion_stats) {
17832 WMI_LOGD("%s: no cca stats in event buffer", __func__);
17833 return QDF_STATUS_E_INVAL;
17834 }
17835
17836 out_buff->vdev_id = congestion_stats->vdev_id;
17837 out_buff->congestion = congestion_stats->congestion;
17838
17839 WMI_LOGD("%s: cca stats event processed", __func__);
17840 return QDF_STATUS_SUCCESS;
17841}
17842#endif /* QCA_SUPPORT_CP_STATS */
17843
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017844/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017845 * save_service_bitmap_tlv() - save service bitmap
17846 * @wmi_handle: wmi handle
17847 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017848 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017849 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017850 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017851 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017852static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017853QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017854 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017855{
17856 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017857 struct wmi_soc *soc = wmi_handle->soc;
17858
Govind Singhe7f2f342016-05-23 12:12:52 +053017859 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17860
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017861 /* If it is already allocated, use that buffer. This can happen
17862 * during target stop/start scenarios where host allocation is skipped.
17863 */
17864 if (!soc->wmi_service_bitmap) {
17865 soc->wmi_service_bitmap =
17866 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17867 if (!soc->wmi_service_bitmap) {
17868 WMI_LOGE("Failed memory allocation for service bitmap");
17869 return QDF_STATUS_E_NOMEM;
17870 }
17871 }
17872
17873 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017874 param_buf->wmi_service_bitmap,
17875 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017876
17877 if (bitmap_buf)
17878 qdf_mem_copy(bitmap_buf,
17879 param_buf->wmi_service_bitmap,
17880 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017881
17882 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017883}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017884
17885/**
17886 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17887 * @wmi_handle: wmi handle
17888 * @param evt_buf: pointer to event buffer
17889 * @param bitmap_buf: bitmap buffer, for converged legacy support
17890 *
17891 * Return: QDF_STATUS
17892 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017893static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017894QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017895 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017896{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017897 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17898 wmi_service_available_event_fixed_param *ev;
17899 struct wmi_soc *soc = wmi_handle->soc;
17900
17901 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17902
17903 ev = param_buf->fixed_param;
17904
17905 /* If it is already allocated, use that buffer. This can happen
17906 * during target stop/start scenarios where host allocation is skipped.
17907 */
17908 if (!soc->wmi_ext_service_bitmap) {
17909 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17910 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17911 if (!soc->wmi_ext_service_bitmap) {
17912 WMI_LOGE("Failed memory allocation for service bitmap");
17913 return QDF_STATUS_E_NOMEM;
17914 }
17915 }
17916
17917 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17918 ev->wmi_service_segment_bitmap,
17919 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017920
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017921 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17922 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17923 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17924
Rajeev Kumar77901472017-02-12 02:12:17 -080017925 if (bitmap_buf)
17926 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017927 soc->wmi_ext_service_bitmap,
17928 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017929
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017930 return QDF_STATUS_SUCCESS;
17931}
Govind Singhe7f2f342016-05-23 12:12:52 +053017932/**
17933 * is_service_enabled_tlv() - Check if service enabled
17934 * @param wmi_handle: wmi handle
17935 * @param service_id: service identifier
17936 *
17937 * Return: 1 enabled, 0 disabled
17938 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017939static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17940 uint32_t service_id)
17941{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017942 struct wmi_soc *soc = wmi_handle->soc;
17943
17944 if (!soc->wmi_service_bitmap) {
17945 WMI_LOGE("WMI service bit map is not saved yet\n");
17946 return false;
17947 }
17948
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017949 /* if wmi_service_enabled was received with extended bitmap,
17950 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017951 */
17952 if (soc->wmi_ext_service_bitmap)
17953 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17954 soc->wmi_ext_service_bitmap,
17955 service_id);
17956
17957 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17958 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017959}
Govind Singhe7f2f342016-05-23 12:12:52 +053017960
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017961static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17962 struct wlan_psoc_target_capability_info *cap)
17963{
17964 /* except LDPC all flags are common betwen legacy and here
17965 * also IBFEER is not defined for TLV
17966 */
17967 cap->ht_cap_info |= ev_target_cap & (
17968 WMI_HT_CAP_ENABLED
17969 | WMI_HT_CAP_HT20_SGI
17970 | WMI_HT_CAP_DYNAMIC_SMPS
17971 | WMI_HT_CAP_TX_STBC
17972 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17973 | WMI_HT_CAP_RX_STBC
17974 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17975 | WMI_HT_CAP_LDPC
17976 | WMI_HT_CAP_L_SIG_TXOP_PROT
17977 | WMI_HT_CAP_MPDU_DENSITY
17978 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17979 | WMI_HT_CAP_HT40_SGI);
17980 if (ev_target_cap & WMI_HT_CAP_LDPC)
17981 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17982 WMI_HOST_HT_CAP_TX_LDPC;
17983}
Govind Singhe7f2f342016-05-23 12:12:52 +053017984/**
17985 * extract_service_ready_tlv() - extract service ready event
17986 * @wmi_handle: wmi handle
17987 * @param evt_buf: pointer to received event buffer
17988 * @param cap: pointer to hold target capability information extracted from even
17989 *
17990 * Return: QDF_STATUS_SUCCESS for success or error code
17991 */
17992static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017993 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017994{
17995 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17996 wmi_service_ready_event_fixed_param *ev;
17997
17998
17999 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18000
18001 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18002 if (!ev) {
18003 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18004 return QDF_STATUS_E_FAILURE;
18005 }
18006
18007 cap->phy_capability = ev->phy_capability;
18008 cap->max_frag_entry = ev->max_frag_entry;
18009 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053018010 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053018011 cap->vht_cap_info = ev->vht_cap_info;
18012 cap->vht_supp_mcs = ev->vht_supp_mcs;
18013 cap->hw_min_tx_power = ev->hw_min_tx_power;
18014 cap->hw_max_tx_power = ev->hw_max_tx_power;
18015 cap->sys_cap_info = ev->sys_cap_info;
18016 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
18017 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
18018 cap->max_num_scan_channels = ev->max_num_scan_channels;
18019 cap->max_supported_macs = ev->max_supported_macs;
18020 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
18021 cap->txrx_chainmask = ev->txrx_chainmask;
18022 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
18023 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053018024 cap->fw_version = ev->fw_build_vers;
18025 /* fw_version_1 is not available in TLV. */
18026 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053018027
18028 return QDF_STATUS_SUCCESS;
18029}
18030
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018031/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
18032 * to host internal WMI_HOST_REGDMN_MODE values.
18033 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
18034 * host currently. Add this in the future if required.
18035 * 11AX (Phase II) : 11ax related values are not currently
18036 * advertised separately by FW. As part of phase II regulatory bring-up,
18037 * finalize the advertisement mechanism.
18038 * @target_wireless_mode: target wireless mode received in message
18039 *
18040 * Return: returns the host internal wireless mode.
18041 */
18042static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
18043{
18044
18045 uint32_t wireless_modes = 0;
18046
18047 if (target_wireless_mode & REGDMN_MODE_11A)
18048 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
18049
18050 if (target_wireless_mode & REGDMN_MODE_TURBO)
18051 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
18052
18053 if (target_wireless_mode & REGDMN_MODE_11B)
18054 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
18055
18056 if (target_wireless_mode & REGDMN_MODE_PUREG)
18057 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
18058
18059 if (target_wireless_mode & REGDMN_MODE_11G)
18060 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
18061
18062 if (target_wireless_mode & REGDMN_MODE_108G)
18063 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
18064
18065 if (target_wireless_mode & REGDMN_MODE_108A)
18066 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
18067
18068 if (target_wireless_mode & REGDMN_MODE_XR)
18069 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
18070
18071 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
18072 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
18073
18074 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
18075 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
18076
18077 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
18078 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
18079
18080 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
18081 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
18082
18083 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
18084 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
18085
18086 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
18087 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
18088
18089 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
18090 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
18091
18092 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
18093 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
18094
18095 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
18096 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
18097
18098 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
18099 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
18100
18101 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
18102 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
18103
18104 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
18105 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
18106
18107 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
18108 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
18109
18110 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
18111 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
18112
18113 return wireless_modes;
18114}
18115
Govind Singhe7f2f342016-05-23 12:12:52 +053018116/**
18117 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
18118 * @wmi_handle: wmi handle
18119 * @param evt_buf: Pointer to event buffer
18120 * @param cap: pointer to hold HAL reg capabilities
18121 *
18122 * Return: QDF_STATUS_SUCCESS for success or error code
18123 */
18124static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018125 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053018126{
18127 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18128
18129 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18130
18131 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
18132 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080018133 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053018134
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018135 cap->wireless_modes = convert_wireless_modes_tlv(
18136 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053018137
Govind Singhe7f2f342016-05-23 12:12:52 +053018138 return QDF_STATUS_SUCCESS;
18139}
18140
18141/**
18142 * extract_host_mem_req_tlv() - Extract host memory request event
18143 * @wmi_handle: wmi handle
18144 * @param evt_buf: pointer to event buffer
18145 * @param num_entries: pointer to hold number of entries requested
18146 *
18147 * Return: Number of entries requested
18148 */
18149static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
18150 void *evt_buf, uint8_t *num_entries)
18151{
18152 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18153 wmi_service_ready_event_fixed_param *ev;
18154
18155 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18156
18157 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18158 if (!ev) {
18159 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18160 return NULL;
18161 }
18162
18163 *num_entries = ev->num_mem_reqs;
18164
18165 return (host_mem_req *)param_buf->mem_reqs;
18166}
18167
18168/**
18169 * save_fw_version_in_service_ready_tlv() - Save fw version in service
18170 * ready function
18171 * @wmi_handle: wmi handle
18172 * @param evt_buf: pointer to event buffer
18173 *
18174 * Return: QDF_STATUS_SUCCESS for success or error code
18175 */
18176static QDF_STATUS
18177save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
18178{
18179 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18180 wmi_service_ready_event_fixed_param *ev;
18181
18182
18183 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18184
18185 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18186 if (!ev) {
18187 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18188 return QDF_STATUS_E_FAILURE;
18189 }
18190
18191 /*Save fw version from service ready message */
18192 /*This will be used while sending INIT message */
18193 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
18194 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053018195
Govind Singhe7f2f342016-05-23 12:12:52 +053018196 return QDF_STATUS_SUCCESS;
18197}
18198
18199/**
18200 * ready_extract_init_status_tlv() - Extract init status from ready event
18201 * @wmi_handle: wmi handle
18202 * @param evt_buf: Pointer to event buffer
18203 *
18204 * Return: ready status
18205 */
18206static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
18207 void *evt_buf)
18208{
18209 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18210 wmi_ready_event_fixed_param *ev = NULL;
18211
Govind Singhe7f2f342016-05-23 12:12:52 +053018212 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18213 ev = param_buf->fixed_param;
18214
18215 qdf_print("%s:%d\n", __func__, ev->status);
18216
18217 return ev->status;
18218}
18219
18220/**
18221 * ready_extract_mac_addr_tlv() - extract mac address from ready event
18222 * @wmi_handle: wmi handle
18223 * @param evt_buf: pointer to event buffer
18224 * @param macaddr: Pointer to hold MAC address
18225 *
18226 * Return: QDF_STATUS_SUCCESS for success or error code
18227 */
18228static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
18229 void *evt_buf, uint8_t *macaddr)
18230{
18231 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18232 wmi_ready_event_fixed_param *ev = NULL;
18233
18234
18235 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18236 ev = param_buf->fixed_param;
18237
18238 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
18239
18240 return QDF_STATUS_SUCCESS;
18241}
18242
18243/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070018244 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
18245 * @wmi_handle: wmi handle
18246 * @param evt_buf: pointer to event buffer
18247 * @param macaddr: Pointer to hold number of MAC addresses
18248 *
18249 * Return: Pointer to addr list
18250 */
18251static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
18252 void *evt_buf, uint8_t *num_mac)
18253{
18254 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18255 wmi_ready_event_fixed_param *ev = NULL;
18256
18257 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18258 ev = param_buf->fixed_param;
18259
18260 *num_mac = ev->num_extra_mac_addr;
18261
18262 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
18263}
18264
18265/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018266 * extract_ready_params_tlv() - Extract data from ready event apart from
18267 * status, macaddr and version.
18268 * @wmi_handle: Pointer to WMI handle.
18269 * @evt_buf: Pointer to Ready event buffer.
18270 * @ev_param: Pointer to host defined struct to copy the data from event.
18271 *
18272 * Return: QDF_STATUS_SUCCESS on success.
18273 */
18274static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
18275 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
18276{
18277 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18278 wmi_ready_event_fixed_param *ev = NULL;
18279
18280 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18281 ev = param_buf->fixed_param;
18282
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018283 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018284 ev_param->num_dscp_table = ev->num_dscp_table;
18285 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
18286 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018287 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018288 /* Agile_cap in ready event is not supported in TLV target */
18289 ev_param->agile_capability = false;
18290
18291 return QDF_STATUS_SUCCESS;
18292}
18293
18294/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018295 * extract_dbglog_data_len_tlv() - extract debuglog data length
18296 * @wmi_handle: wmi handle
18297 * @param evt_buf: pointer to event buffer
18298 *
18299 * Return: length
18300 */
18301static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080018302 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053018303{
18304 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
18305
18306 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
18307
18308 *len = param_buf->num_bufp;
18309
18310 return param_buf->bufp;
18311}
18312
18313/**
18314 * extract_vdev_start_resp_tlv() - extract vdev start response
18315 * @wmi_handle: wmi handle
18316 * @param evt_buf: pointer to event buffer
18317 * @param vdev_rsp: Pointer to hold vdev response
18318 *
18319 * Return: QDF_STATUS_SUCCESS for success or error code
18320 */
18321static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
18322 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
18323{
18324 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
18325 wmi_vdev_start_response_event_fixed_param *ev;
18326
18327 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
18328 if (!param_buf) {
18329 qdf_print("Invalid start response event buffer\n");
18330 return QDF_STATUS_E_INVAL;
18331 }
18332
18333 ev = param_buf->fixed_param;
18334 if (!ev) {
18335 qdf_print("Invalid start response event buffer\n");
18336 return QDF_STATUS_E_INVAL;
18337 }
18338
18339 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
18340
18341 vdev_rsp->vdev_id = ev->vdev_id;
18342 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070018343 switch (ev->resp_type) {
18344 case WMI_VDEV_START_RESP_EVENT:
18345 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
18346 break;
18347 case WMI_VDEV_RESTART_RESP_EVENT:
18348 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
18349 break;
18350 default:
18351 qdf_print("Invalid start response event buffer\n");
18352 break;
18353 };
Govind Singhe7f2f342016-05-23 12:12:52 +053018354 vdev_rsp->status = ev->status;
18355 vdev_rsp->chain_mask = ev->chain_mask;
18356 vdev_rsp->smps_mode = ev->smps_mode;
18357 vdev_rsp->mac_id = ev->mac_id;
18358 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
18359 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
18360
18361 return QDF_STATUS_SUCCESS;
18362}
18363
18364/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053018365 * extract_vdev_delete_resp_tlv() - extract vdev delete response
18366 * @wmi_handle: wmi handle
18367 * @param evt_buf: pointer to event buffer
18368 * @param delete_rsp: Pointer to hold vdev delete response
18369 *
18370 * Return: QDF_STATUS_SUCCESS for success or error code
18371 */
18372static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
18373 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
18374{
18375 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
18376 wmi_vdev_delete_resp_event_fixed_param *ev;
18377
18378 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
18379 if (!param_buf) {
18380 WMI_LOGE("Invalid vdev delete response event buffer\n");
18381 return QDF_STATUS_E_INVAL;
18382 }
18383
18384 ev = param_buf->fixed_param;
18385 if (!ev) {
18386 WMI_LOGE("Invalid vdev delete response event\n");
18387 return QDF_STATUS_E_INVAL;
18388 }
18389
18390 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
18391 delete_rsp->vdev_id = ev->vdev_id;
18392
18393 return QDF_STATUS_SUCCESS;
18394}
18395
18396
18397/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018398 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053018399 * @wmi_handle: wmi handle
18400 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018401 * @param num_vdevs: Pointer to hold num vdev
18402 *
18403 * Return: QDF_STATUS_SUCCESS for success or error code
18404 */
18405static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18406 void *evt_buf, uint32_t *num_vdevs)
18407{
18408 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18409 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
18410 uint32_t vdev_map;
18411
18412 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
18413 if (!param_buf) {
18414 qdf_print("Invalid tbtt update ext event buffer\n");
18415 return QDF_STATUS_E_INVAL;
18416 }
18417 tbtt_offset_event = param_buf->fixed_param;
18418 vdev_map = tbtt_offset_event->vdev_map;
18419 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18420
18421 return QDF_STATUS_SUCCESS;
18422}
18423
18424/**
18425 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
18426 * @wmi_handle: wmi handle
18427 * @param evt_buf: pointer to event buffer
18428 * @param num_vdevs: Pointer to hold num vdev
18429 *
18430 * Return: QDF_STATUS_SUCCESS for success or error code
18431 */
18432static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18433 void *evt_buf, uint32_t *num_vdevs)
18434{
18435 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18436 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
18437
18438 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18439 if (!param_buf) {
18440 qdf_print("Invalid tbtt update ext event buffer\n");
18441 return QDF_STATUS_E_INVAL;
18442 }
18443 tbtt_offset_ext_event = param_buf->fixed_param;
18444
18445 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
18446
18447 return QDF_STATUS_SUCCESS;
18448}
18449
18450/**
18451 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
18452 * @wmi_handle: wmi handle
18453 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070018454 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018455 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053018456 *
18457 * Return: QDF_STATUS_SUCCESS for success or error code
18458 */
18459static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018460 void *evt_buf, uint8_t idx,
18461 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018462{
18463 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18464 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018465 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018466
18467 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
18468 if (!param_buf) {
18469 qdf_print("Invalid tbtt update event buffer\n");
18470 return QDF_STATUS_E_INVAL;
18471 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018472
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018473 tbtt_offset_event = param_buf->fixed_param;
18474 vdev_map = tbtt_offset_event->vdev_map;
18475 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
18476 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
18477 return QDF_STATUS_E_INVAL;
18478 tbtt_param->tbttoffset =
18479 param_buf->tbttoffset_list[tbtt_param->vdev_id];
18480
18481 return QDF_STATUS_SUCCESS;
18482}
18483
18484/**
18485 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
18486 * @wmi_handle: wmi handle
18487 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070018488 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018489 * @param tbtt_param: Pointer to tbttoffset event param
18490 *
18491 * Return: QDF_STATUS_SUCCESS for success or error code
18492 */
18493static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
18494 void *evt_buf, uint8_t idx,
18495 struct tbttoffset_params *tbtt_param)
18496{
18497 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18498 wmi_tbtt_offset_info *tbtt_offset_info;
18499
18500 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18501 if (!param_buf) {
18502 qdf_print("Invalid tbtt update event buffer\n");
18503 return QDF_STATUS_E_INVAL;
18504 }
18505 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
18506
18507 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
18508 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053018509
18510 return QDF_STATUS_SUCCESS;
18511}
18512
18513/**
18514 * extract_mgmt_rx_params_tlv() - extract management rx params from event
18515 * @wmi_handle: wmi handle
18516 * @param evt_buf: pointer to event buffer
18517 * @param hdr: Pointer to hold header
18518 * @param bufp: Pointer to hold pointer to rx param buffer
18519 *
18520 * Return: QDF_STATUS_SUCCESS for success or error code
18521 */
18522static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053018523 void *evt_buf, struct mgmt_rx_event_params *hdr,
18524 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053018525{
18526 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
18527 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018528 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053018529
18530 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
18531 if (!param_tlvs) {
18532 WMI_LOGE("Get NULL point message from FW");
18533 return QDF_STATUS_E_INVAL;
18534 }
18535
18536 ev_hdr = param_tlvs->hdr;
18537 if (!hdr) {
18538 WMI_LOGE("Rx event is NULL");
18539 return QDF_STATUS_E_INVAL;
18540 }
18541
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018542 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18543 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018544
18545 hdr->channel = ev_hdr->channel;
18546 hdr->snr = ev_hdr->snr;
18547 hdr->rate = ev_hdr->rate;
18548 hdr->phy_mode = ev_hdr->phy_mode;
18549 hdr->buf_len = ev_hdr->buf_len;
18550 hdr->status = ev_hdr->status;
18551 hdr->flags = ev_hdr->flags;
18552 hdr->rssi = ev_hdr->rssi;
18553 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018554 for (i = 0; i < ATH_MAX_ANTENNA; i++)
18555 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053018556
18557 *bufp = param_tlvs->bufp;
18558
18559 return QDF_STATUS_SUCCESS;
18560}
18561
18562/**
18563 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
18564 * @wmi_handle: wmi handle
18565 * @param evt_buf: pointer to event buffer
18566 * @param vdev_id: Pointer to hold vdev identifier
18567 *
18568 * Return: QDF_STATUS_SUCCESS for success or error code
18569 */
18570static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
18571 void *evt_buf, uint32_t *vdev_id)
18572{
18573 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
18574 wmi_vdev_stopped_event_fixed_param *resp_event;
18575
18576 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
18577 if (!param_buf) {
18578 WMI_LOGE("Invalid event buffer");
18579 return QDF_STATUS_E_INVAL;
18580 }
18581 resp_event = param_buf->fixed_param;
18582 *vdev_id = resp_event->vdev_id;
18583
18584 return QDF_STATUS_SUCCESS;
18585}
18586
18587/**
18588 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
18589 * @wmi_handle: wmi handle
18590 * @param evt_buf: pointer to event buffer
18591 * @param param: Pointer to hold roam param
18592 *
18593 * Return: QDF_STATUS_SUCCESS for success or error code
18594 */
18595static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
18596 void *evt_buf, wmi_host_roam_event *param)
18597{
18598 WMI_ROAM_EVENTID_param_tlvs *param_buf;
18599 wmi_roam_event_fixed_param *evt;
18600
18601 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18602 if (!param_buf) {
18603 WMI_LOGE("Invalid roam event buffer");
18604 return QDF_STATUS_E_INVAL;
18605 }
18606
18607 evt = param_buf->fixed_param;
18608 qdf_mem_zero(param, sizeof(*param));
18609
18610 param->vdev_id = evt->vdev_id;
18611 param->reason = evt->reason;
18612 param->rssi = evt->rssi;
18613
18614 return QDF_STATUS_SUCCESS;
18615}
18616
18617/**
18618 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18619 * @wmi_handle: wmi handle
18620 * @param evt_buf: pointer to event buffer
18621 * @param param: Pointer to hold vdev scan param
18622 *
18623 * Return: QDF_STATUS_SUCCESS for success or error code
18624 */
18625static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018626 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018627{
18628 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18629 wmi_scan_event_fixed_param *evt = NULL;
18630
18631 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18632 evt = param_buf->fixed_param;
18633
18634 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018635
Govind Singhe7f2f342016-05-23 12:12:52 +053018636 switch (evt->event) {
18637 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018638 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018639 break;
18640 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018641 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018642 break;
18643 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018644 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018645 break;
18646 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018647 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018648 break;
18649 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018650 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018651 break;
18652 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018653 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018654 break;
18655 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018656 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018657 break;
18658 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018659 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018660 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018661 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018662 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018663 break;
18664 case WMI_SCAN_EVENT_MAX:
18665 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018666 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018667 break;
18668 };
18669
18670 switch (evt->reason) {
18671 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018672 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018673 break;
18674 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018675 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018676 break;
18677 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018678 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018679 break;
18680 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018681 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018682 break;
18683 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018684 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018685 break;
18686 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018687 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018688 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018689 case WMI_SCAN_REASON_SUSPENDED:
18690 param->reason = SCAN_REASON_SUSPENDED;
18691 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018692 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018693 param->reason = SCAN_REASON_MAX;
18694 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018695 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018696 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018697 break;
18698 };
18699
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018700 param->chan_freq = evt->channel_freq;
18701 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018702 param->scan_id = evt->scan_id;
18703 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018704 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018705
18706 return QDF_STATUS_SUCCESS;
18707}
18708
Frank Liu3d5e9992017-03-15 17:51:43 +080018709#ifdef CONVERGED_TDLS_ENABLE
18710/**
18711 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18712 * @wmi_handle: wmi handle
18713 * @param evt_buf: pointer to event buffer
18714 * @param param: Pointer to hold vdev tdls param
18715 *
18716 * Return: QDF_STATUS_SUCCESS for success or error code
18717 */
18718static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18719 void *evt_buf, struct tdls_event_info *param)
18720{
18721 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18722 wmi_tdls_peer_event_fixed_param *evt;
18723
18724 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18725 if (!param_buf) {
18726 WMI_LOGE("%s: NULL param_buf", __func__);
18727 return QDF_STATUS_E_NULL_VALUE;
18728 }
18729
18730 evt = param_buf->fixed_param;
18731
18732 qdf_mem_zero(param, sizeof(*param));
18733
18734 param->vdev_id = evt->vdev_id;
18735 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18736 param->peermac.bytes);
18737 switch (evt->peer_status) {
18738 case WMI_TDLS_SHOULD_DISCOVER:
18739 param->message_type = TDLS_SHOULD_DISCOVER;
18740 break;
18741 case WMI_TDLS_SHOULD_TEARDOWN:
18742 param->message_type = TDLS_SHOULD_TEARDOWN;
18743 break;
18744 case WMI_TDLS_PEER_DISCONNECTED:
18745 param->message_type = TDLS_PEER_DISCONNECTED;
18746 break;
18747 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18748 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18749 break;
18750 default:
18751 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18752 __func__, evt->peer_status);
18753 return QDF_STATUS_E_INVAL;
18754 };
18755
18756 switch (evt->peer_reason) {
18757 case WMI_TDLS_TEARDOWN_REASON_TX:
18758 param->peer_reason = TDLS_TEARDOWN_TX;
18759 break;
18760 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18761 param->peer_reason = TDLS_TEARDOWN_RSSI;
18762 break;
18763 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18764 param->peer_reason = TDLS_TEARDOWN_SCAN;
18765 break;
18766 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18767 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18768 break;
18769 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18770 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18771 break;
18772 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18773 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18774 break;
18775 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18776 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18777 break;
18778 case WMI_TDLS_ENTER_BUF_STA:
18779 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18780 break;
18781 case WMI_TDLS_EXIT_BUF_STA:
18782 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18783 break;
18784 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18785 param->peer_reason = TDLS_ENTER_BT_BUSY;
18786 break;
18787 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18788 param->peer_reason = TDLS_EXIT_BT_BUSY;
18789 break;
18790 case WMI_TDLS_SCAN_STARTED_EVENT:
18791 param->peer_reason = TDLS_SCAN_STARTED;
18792 break;
18793 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18794 param->peer_reason = TDLS_SCAN_COMPLETED;
18795 break;
18796
18797 default:
18798 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18799 __func__, evt->peer_reason, evt->peer_status);
18800 return QDF_STATUS_E_INVAL;
18801 };
18802
18803 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18804 __func__, param->peermac.bytes, param->message_type,
18805 param->peer_reason, param->vdev_id);
18806
18807 return QDF_STATUS_SUCCESS;
18808}
18809#endif
18810
Govind Singhe7f2f342016-05-23 12:12:52 +053018811/**
18812 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18813 * @wmi_handle: wmi handle
18814 * @param evt_buf: pointer to event buffer
18815 * @param param: Pointer to hold MGMT TX completion params
18816 *
18817 * Return: QDF_STATUS_SUCCESS for success or error code
18818 */
18819static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18820 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18821{
18822 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18823 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18824
18825 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18826 evt_buf;
18827 if (!param_buf) {
18828 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18829 return QDF_STATUS_E_INVAL;
18830 }
18831 cmpl_params = param_buf->fixed_param;
18832
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018833 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18834 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018835 param->desc_id = cmpl_params->desc_id;
18836 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018837 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018838
18839 return QDF_STATUS_SUCCESS;
18840}
18841
18842/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018843 * extract_offchan_data_tx_compl_param_tlv() -
18844 * extract Offchan data tx completion event params
18845 * @wmi_handle: wmi handle
18846 * @param evt_buf: pointer to event buffer
18847 * @param param: Pointer to hold offchan data TX completion params
18848 *
18849 * Return: QDF_STATUS_SUCCESS for success or error code
18850 */
18851static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18852 wmi_unified_t wmi_handle, void *evt_buf,
18853 struct wmi_host_offchan_data_tx_compl_event *param)
18854{
18855 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18856 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18857
18858 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18859 evt_buf;
18860 if (!param_buf) {
18861 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18862 return QDF_STATUS_E_INVAL;
18863 }
18864 cmpl_params = param_buf->fixed_param;
18865
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018866 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18867 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018868 param->desc_id = cmpl_params->desc_id;
18869 param->status = cmpl_params->status;
18870
18871 return QDF_STATUS_SUCCESS;
18872}
18873
18874/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018875 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18876 * status tlv
18877 * @wmi_handle: wmi handle
18878 * @param evt_buf: pointer to event buffer
18879 * @param param: Pointer to hold csa switch count status event param
18880 *
18881 * Return: QDF_STATUS_SUCCESS for success or error code
18882 */
18883static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18884 wmi_unified_t wmi_handle,
18885 void *evt_buf,
18886 struct pdev_csa_switch_count_status *param)
18887{
18888 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18889 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18890
18891 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18892 evt_buf;
18893 if (!param_buf) {
18894 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18895 return QDF_STATUS_E_INVAL;
18896 }
18897
18898 csa_status = param_buf->fixed_param;
18899
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018900 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18901 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018902 param->current_switch_count = csa_status->current_switch_count;
18903 param->num_vdevs = csa_status->num_vdevs;
18904 param->vdev_ids = param_buf->vdev_ids;
18905
18906 return QDF_STATUS_SUCCESS;
18907}
18908
18909/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018910 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18911 * param from event
18912 * @wmi_handle: wmi handle
18913 * @param evt_buf: pointer to event buffer
18914 * @param param: Pointer to hold tpc configuration
18915 *
18916 * Return: 0 for success or error code
18917 */
18918static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18919 void *evt_buf,
18920 wmi_host_pdev_tpc_config_event *param)
18921{
18922 wmi_pdev_tpc_config_event_fixed_param *event =
18923 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18924
18925 if (!event) {
18926 WMI_LOGE("Invalid event buffer");
18927 return QDF_STATUS_E_INVAL;
18928 }
18929
18930 param->pdev_id = event->pdev_id;
18931 param->regDomain = event->regDomain;
18932 param->chanFreq = event->chanFreq;
18933 param->phyMode = event->phyMode;
18934 param->twiceAntennaReduction = event->twiceAntennaReduction;
18935 param->twiceMaxRDPower = event->twiceMaxRDPower;
18936 param->powerLimit = event->powerLimit;
18937 param->rateMax = event->rateMax;
18938 param->numTxChain = event->numTxChain;
18939 param->ctl = event->ctl;
18940 param->flags = event->flags;
18941
18942 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18943 sizeof(param->maxRegAllowedPower));
18944 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18945 event->maxRegAllowedPowerAGCDD,
18946 sizeof(param->maxRegAllowedPowerAGCDD));
18947 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18948 event->maxRegAllowedPowerAGSTBC,
18949 sizeof(param->maxRegAllowedPowerAGSTBC));
18950 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18951 event->maxRegAllowedPowerAGTXBF,
18952 sizeof(param->maxRegAllowedPowerAGTXBF));
18953 WMI_LOGD("%s:extract success", __func__);
18954
18955 return QDF_STATUS_SUCCESS;
18956}
18957
18958/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018959 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018960 * @wmi_handle: wmi handle
18961 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018962 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018963 *
18964 * Return: QDF_STATUS_SUCCESS for success or error code
18965 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018966static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18967 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018968{
18969 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18970 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018971 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018972
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 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018978
Govind Singhe7f2f342016-05-23 12:12:52 +053018979 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018980 *num_vdevs = swba_event->num_vdevs;
18981 if (!(*num_vdevs)) {
18982 vdev_map = swba_event->vdev_map;
18983 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18984 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018985
18986 return QDF_STATUS_SUCCESS;
18987}
18988
18989/**
18990 * extract_swba_tim_info_tlv() - extract swba tim info from event
18991 * @wmi_handle: wmi handle
18992 * @param evt_buf: pointer to event buffer
18993 * @param idx: Index to bcn info
18994 * @param tim_info: Pointer to hold tim info
18995 *
18996 * Return: QDF_STATUS_SUCCESS for success or error code
18997 */
18998static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18999 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
19000{
19001 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
19002 wmi_tim_info *tim_info_ev;
19003
19004 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
19005 if (!param_buf) {
19006 WMI_LOGE("Invalid swba event buffer");
19007 return QDF_STATUS_E_INVAL;
19008 }
19009
19010 tim_info_ev = &param_buf->tim_info[idx];
19011
19012 tim_info->tim_len = tim_info_ev->tim_len;
19013 tim_info->tim_mcast = tim_info_ev->tim_mcast;
19014 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
19015 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
19016 tim_info->tim_changed = tim_info_ev->tim_changed;
19017 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019018 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019019
19020 return QDF_STATUS_SUCCESS;
19021}
19022
19023/**
19024 * extract_swba_noa_info_tlv() - extract swba NoA information from event
19025 * @wmi_handle: wmi handle
19026 * @param evt_buf: pointer to event buffer
19027 * @param idx: Index to bcn info
19028 * @param p2p_desc: Pointer to hold p2p NoA info
19029 *
19030 * Return: QDF_STATUS_SUCCESS for success or error code
19031 */
19032static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
19033 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
19034{
19035 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
19036 wmi_p2p_noa_info *p2p_noa_info;
19037 uint8_t i = 0;
19038
19039 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
19040 if (!param_buf) {
19041 WMI_LOGE("Invalid swba event buffer");
19042 return QDF_STATUS_E_INVAL;
19043 }
19044
19045 p2p_noa_info = &param_buf->p2p_noa_info[idx];
19046
19047 p2p_desc->modified = false;
19048 p2p_desc->num_descriptors = 0;
19049 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
19050 p2p_desc->modified = true;
19051 p2p_desc->index =
19052 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
19053 p2p_desc->oppPS =
19054 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
19055 p2p_desc->ctwindow =
19056 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
19057 p2p_desc->num_descriptors =
19058 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
19059 (p2p_noa_info);
19060 for (i = 0; i < p2p_desc->num_descriptors; i++) {
19061 p2p_desc->noa_descriptors[i].type_count =
19062 (uint8_t) p2p_noa_info->noa_descriptors[i].
19063 type_count;
19064 p2p_desc->noa_descriptors[i].duration =
19065 p2p_noa_info->noa_descriptors[i].duration;
19066 p2p_desc->noa_descriptors[i].interval =
19067 p2p_noa_info->noa_descriptors[i].interval;
19068 p2p_desc->noa_descriptors[i].start_time =
19069 p2p_noa_info->noa_descriptors[i].start_time;
19070 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019071 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019072 }
19073
19074 return QDF_STATUS_SUCCESS;
19075}
19076
Wu Gaocd3a8512017-03-13 20:17:34 +080019077#ifdef CONVERGED_P2P_ENABLE
19078/**
19079 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
19080 * @wmi_handle: wmi handle
19081 * @param evt_buf: pointer to event buffer
19082 * @param param: Pointer to hold p2p noa info
19083 *
19084 * Return: QDF_STATUS_SUCCESS for success or error code
19085 */
19086static QDF_STATUS extract_p2p_noa_ev_param_tlv(
19087 wmi_unified_t wmi_handle, void *evt_buf,
19088 struct p2p_noa_info *param)
19089{
19090 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
19091 wmi_p2p_noa_event_fixed_param *fixed_param;
19092 uint8_t i;
19093 wmi_p2p_noa_info *wmi_noa_info;
19094 uint8_t *buf_ptr;
19095 uint32_t descriptors;
19096
19097 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
19098 if (!param_tlvs) {
19099 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
19100 return QDF_STATUS_E_INVAL;
19101 }
19102
19103 if (!param) {
19104 WMI_LOGE("noa information param is null");
19105 return QDF_STATUS_E_INVAL;
19106 }
19107
19108 fixed_param = param_tlvs->fixed_param;
19109 buf_ptr = (uint8_t *) fixed_param;
19110 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
19111 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
19112
19113 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
19114 WMI_LOGE("%s: noa attr is not modified", __func__);
19115 return QDF_STATUS_E_INVAL;
19116 }
19117
19118 param->vdev_id = fixed_param->vdev_id;
19119 param->index =
19120 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
19121 param->opps_ps =
19122 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
19123 param->ct_window =
19124 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
19125 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
19126 param->num_desc = (uint8_t) descriptors;
19127
19128 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
19129 param->index, param->opps_ps, param->ct_window,
19130 param->num_desc);
19131 for (i = 0; i < param->num_desc; i++) {
19132 param->noa_desc[i].type_count =
19133 (uint8_t) wmi_noa_info->noa_descriptors[i].
19134 type_count;
19135 param->noa_desc[i].duration =
19136 wmi_noa_info->noa_descriptors[i].duration;
19137 param->noa_desc[i].interval =
19138 wmi_noa_info->noa_descriptors[i].interval;
19139 param->noa_desc[i].start_time =
19140 wmi_noa_info->noa_descriptors[i].start_time;
19141 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
19142 __func__, i, param->noa_desc[i].type_count,
19143 param->noa_desc[i].duration,
19144 param->noa_desc[i].interval,
19145 param->noa_desc[i].start_time);
19146 }
19147
19148 return QDF_STATUS_SUCCESS;
19149}
19150
19151/**
19152 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
19153 * information from event
19154 * @wmi_handle: wmi handle
19155 * @param evt_buf: pointer to event buffer
19156 * @param param: Pointer to hold p2p lo stop event information
19157 *
19158 * Return: QDF_STATUS_SUCCESS for success or error code
19159 */
19160static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
19161 wmi_unified_t wmi_handle, void *evt_buf,
19162 struct p2p_lo_event *param)
19163{
19164 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
19165 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
19166
19167 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
19168 evt_buf;
19169 if (!param_tlvs) {
19170 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
19171 return QDF_STATUS_E_INVAL;
19172 }
19173
19174 if (!param) {
19175 WMI_LOGE("lo stop event param is null");
19176 return QDF_STATUS_E_INVAL;
19177 }
19178
19179 lo_param = param_tlvs->fixed_param;
19180 param->vdev_id = lo_param->vdev_id;
19181 param->reason_code = lo_param->reason;
19182 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
19183 param->vdev_id, param->reason_code);
19184
19185 return QDF_STATUS_SUCCESS;
19186}
19187#endif /* End of CONVERGED_P2P_ENABLE */
19188
Govind Singhe7f2f342016-05-23 12:12:52 +053019189/**
19190 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
19191 * @wmi_handle: wmi handle
19192 * @param evt_buf: pointer to event buffer
19193 * @param ev: Pointer to hold peer param
19194 *
19195 * Return: QDF_STATUS_SUCCESS for success or error code
19196 */
19197static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
19198 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
19199{
19200 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
19201 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
19202
19203 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
19204 kickout_event = param_buf->fixed_param;
19205
19206 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
19207 ev->peer_macaddr);
19208
19209 ev->reason = kickout_event->reason;
19210 ev->rssi = kickout_event->rssi;
19211
19212 return QDF_STATUS_SUCCESS;
19213}
19214
19215/**
19216 * extract_all_stats_counts_tlv() - extract all stats count from event
19217 * @wmi_handle: wmi handle
19218 * @param evt_buf: pointer to event buffer
19219 * @param stats_param: Pointer to hold stats count
19220 *
19221 * Return: QDF_STATUS_SUCCESS for success or error code
19222 */
19223static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
19224 void *evt_buf, wmi_host_stats_event *stats_param)
19225{
Govind Singhe7f2f342016-05-23 12:12:52 +053019226 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019227 wmi_per_chain_rssi_stats *rssi_event;
19228 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053019229
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019230 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053019231 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053019232 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019233 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053019234 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019235 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053019236 return QDF_STATUS_E_FAILURE;
19237 }
19238
19239 switch (ev->stats_id) {
19240 case WMI_REQUEST_PEER_STAT:
19241 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
19242 break;
19243
19244 case WMI_REQUEST_AP_STAT:
19245 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
19246 break;
19247
19248 case WMI_REQUEST_PDEV_STAT:
19249 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
19250 break;
19251
19252 case WMI_REQUEST_VDEV_STAT:
19253 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
19254 break;
19255
19256 case WMI_REQUEST_BCNFLT_STAT:
19257 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
19258 break;
19259
19260 case WMI_REQUEST_VDEV_RATE_STAT:
19261 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
19262 break;
19263
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019264 case WMI_REQUEST_BCN_STAT:
19265 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
19266 break;
19267
Govind Singhe7f2f342016-05-23 12:12:52 +053019268 default:
19269 stats_param->stats_id = 0;
19270 break;
19271
19272 }
19273
19274 stats_param->num_pdev_stats = ev->num_pdev_stats;
19275 stats_param->num_pdev_ext_stats = 0;
19276 stats_param->num_vdev_stats = ev->num_vdev_stats;
19277 stats_param->num_peer_stats = ev->num_peer_stats;
19278 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
19279 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019280 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053019281 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19282 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053019283
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019284 /* if chain_stats is not populated */
19285 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
19286 return QDF_STATUS_SUCCESS;
19287
19288 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
19289 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
19290 return QDF_STATUS_SUCCESS;
19291
19292 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
19293 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
19294 return QDF_STATUS_SUCCESS;
19295
19296 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
19297
Govind Singhe7f2f342016-05-23 12:12:52 +053019298 return QDF_STATUS_SUCCESS;
19299}
19300
19301/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019302 * extract_pdev_tx_stats() - extract pdev tx stats from event
19303 */
19304static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
19305{
19306 /* Tx Stats */
19307 tx->comp_queued = tx_stats->comp_queued;
19308 tx->comp_delivered = tx_stats->comp_delivered;
19309 tx->msdu_enqued = tx_stats->msdu_enqued;
19310 tx->mpdu_enqued = tx_stats->mpdu_enqued;
19311 tx->wmm_drop = tx_stats->wmm_drop;
19312 tx->local_enqued = tx_stats->local_enqued;
19313 tx->local_freed = tx_stats->local_freed;
19314 tx->hw_queued = tx_stats->hw_queued;
19315 tx->hw_reaped = tx_stats->hw_reaped;
19316 tx->underrun = tx_stats->underrun;
19317 tx->tx_abort = tx_stats->tx_abort;
19318 tx->mpdus_requed = tx_stats->mpdus_requed;
19319 tx->data_rc = tx_stats->data_rc;
19320 tx->self_triggers = tx_stats->self_triggers;
19321 tx->sw_retry_failure = tx_stats->sw_retry_failure;
19322 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
19323 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
19324 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
19325 tx->pdev_resets = tx_stats->pdev_resets;
19326 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
19327 tx->phy_underrun = tx_stats->phy_underrun;
19328 tx->txop_ovf = tx_stats->txop_ovf;
19329
19330 return;
19331}
19332
19333
19334/**
19335 * extract_pdev_rx_stats() - extract pdev rx stats from event
19336 */
19337static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
19338{
19339 /* Rx Stats */
19340 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
19341 rx->status_rcvd = rx_stats->status_rcvd;
19342 rx->r0_frags = rx_stats->r0_frags;
19343 rx->r1_frags = rx_stats->r1_frags;
19344 rx->r2_frags = rx_stats->r2_frags;
19345 /* Only TLV */
19346 rx->r3_frags = 0;
19347 rx->htt_msdus = rx_stats->htt_msdus;
19348 rx->htt_mpdus = rx_stats->htt_mpdus;
19349 rx->loc_msdus = rx_stats->loc_msdus;
19350 rx->loc_mpdus = rx_stats->loc_mpdus;
19351 rx->oversize_amsdu = rx_stats->oversize_amsdu;
19352 rx->phy_errs = rx_stats->phy_errs;
19353 rx->phy_err_drop = rx_stats->phy_err_drop;
19354 rx->mpdu_errs = rx_stats->mpdu_errs;
19355
19356 return;
19357}
19358
19359/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019360 * extract_pdev_stats_tlv() - extract pdev stats from event
19361 * @wmi_handle: wmi handle
19362 * @param evt_buf: pointer to event buffer
19363 * @param index: Index into pdev stats
19364 * @param pdev_stats: Pointer to hold pdev stats
19365 *
19366 * Return: QDF_STATUS_SUCCESS for success or error code
19367 */
19368static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
19369 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
19370{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019371 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19372 wmi_stats_event_fixed_param *ev_param;
19373 uint8_t *data;
19374
19375 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19376 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19377
19378 data = param_buf->data;
19379
19380 if (index < ev_param->num_pdev_stats) {
19381 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
19382 (index * sizeof(wmi_pdev_stats)));
19383
19384 pdev_stats->chan_nf = ev->chan_nf;
19385 pdev_stats->tx_frame_count = ev->tx_frame_count;
19386 pdev_stats->rx_frame_count = ev->rx_frame_count;
19387 pdev_stats->rx_clear_count = ev->rx_clear_count;
19388 pdev_stats->cycle_count = ev->cycle_count;
19389 pdev_stats->phy_err_count = ev->phy_err_count;
19390 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
19391
19392 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
19393 &(ev->pdev_stats.tx));
19394 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
19395 &(ev->pdev_stats.rx));
19396 }
19397
Govind Singhe7f2f342016-05-23 12:12:52 +053019398 return QDF_STATUS_SUCCESS;
19399}
19400
19401/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070019402 * extract_unit_test_tlv() - extract unit test data
19403 * @wmi_handle: wmi handle
19404 * @param evt_buf: pointer to event buffer
19405 * @param unit_test: pointer to hold unit test data
19406 * @param maxspace: Amount of space in evt_buf
19407 *
19408 * Return: QDF_STATUS_SUCCESS for success or error code
19409 */
19410static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
19411 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
19412{
19413 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
19414 wmi_unit_test_event_fixed_param *ev_param;
19415 uint32_t num_bufp;
19416 uint32_t copy_size;
19417 uint8_t *bufp;
19418
19419 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
19420 ev_param = param_buf->fixed_param;
19421 bufp = param_buf->bufp;
19422 num_bufp = param_buf->num_bufp;
19423 unit_test->vdev_id = ev_param->vdev_id;
19424 unit_test->module_id = ev_param->module_id;
19425 unit_test->diag_token = ev_param->diag_token;
19426 unit_test->flag = ev_param->flag;
19427 unit_test->payload_len = ev_param->payload_len;
19428 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
19429 ev_param->vdev_id,
19430 ev_param->module_id,
19431 ev_param->diag_token,
19432 ev_param->flag);
19433 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
19434 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
19435 bufp, num_bufp);
19436 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
19437 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
19438 unit_test->buffer_len = copy_size;
19439
19440 return QDF_STATUS_SUCCESS;
19441}
19442
19443/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019444 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
19445 * @wmi_handle: wmi handle
19446 * @param evt_buf: pointer to event buffer
19447 * @param index: Index into extended pdev stats
19448 * @param pdev_ext_stats: Pointer to hold extended pdev stats
19449 *
19450 * Return: QDF_STATUS_SUCCESS for success or error code
19451 */
19452static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
19453 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
19454{
19455 return QDF_STATUS_SUCCESS;
19456}
19457
19458/**
19459 * extract_vdev_stats_tlv() - extract vdev stats from event
19460 * @wmi_handle: wmi handle
19461 * @param evt_buf: pointer to event buffer
19462 * @param index: Index into vdev stats
19463 * @param vdev_stats: Pointer to hold vdev stats
19464 *
19465 * Return: QDF_STATUS_SUCCESS for success or error code
19466 */
19467static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
19468 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
19469{
19470 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19471 wmi_stats_event_fixed_param *ev_param;
19472 uint8_t *data;
19473
19474 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19475 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19476 data = (uint8_t *) param_buf->data;
19477
19478 if (index < ev_param->num_vdev_stats) {
19479 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
19480 ((ev_param->num_pdev_stats) *
19481 sizeof(wmi_pdev_stats)) +
19482 (index * sizeof(wmi_vdev_stats)));
19483
19484 vdev_stats->vdev_id = ev->vdev_id;
19485 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
19486 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
19487
19488 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
19489 sizeof(ev->tx_frm_cnt));
19490 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
19491 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
19492 ev->multiple_retry_cnt,
19493 sizeof(ev->multiple_retry_cnt));
19494 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
19495 sizeof(ev->fail_cnt));
19496 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
19497 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
19498 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
19499 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
19500 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
19501 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
19502 sizeof(ev->tx_rate_history));
19503 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
19504 sizeof(ev->bcn_rssi_history));
19505
19506 }
19507
19508 return QDF_STATUS_SUCCESS;
19509}
19510
19511/**
Naveen Rawatd2115722018-04-12 08:17:55 -070019512 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
19513 * buffer
19514 * @wmi_handle: wmi handle
19515 * @evt_buf: pointer to event buffer
19516 * @index: Index into vdev stats
19517 * @rssi_stats: Pointer to hold rssi stats
19518 *
19519 * Return: QDF_STATUS_SUCCESS for success or error code
19520 */
19521static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
19522 void *evt_buf, uint32_t index,
19523 struct wmi_host_per_chain_rssi_stats *rssi_stats)
19524{
19525 uint8_t *data;
19526 wmi_rssi_stats *fw_rssi_stats;
19527 wmi_per_chain_rssi_stats *rssi_event;
19528 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19529
19530 if (!evt_buf) {
19531 WMI_LOGE("evt_buf is null");
19532 return QDF_STATUS_E_NULL_VALUE;
19533 }
19534
19535 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19536 rssi_event = param_buf->chain_stats;
19537
19538 if (index >= rssi_event->num_per_chain_rssi_stats) {
19539 WMI_LOGE("invalid index");
19540 return QDF_STATUS_E_INVAL;
19541 }
19542
19543 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
19544 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
19545
19546 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
19547 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
19548 fw_rssi_stats->rssi_avg_beacon,
19549 sizeof(fw_rssi_stats->rssi_avg_beacon));
19550 qdf_mem_copy(rssi_stats->rssi_avg_data,
19551 fw_rssi_stats->rssi_avg_data,
19552 sizeof(fw_rssi_stats->rssi_avg_data));
19553 qdf_mem_copy(&rssi_stats->peer_macaddr,
19554 &fw_rssi_stats->peer_macaddr,
19555 sizeof(fw_rssi_stats->peer_macaddr));
19556
19557 return QDF_STATUS_SUCCESS;
19558}
19559
19560
19561
19562/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019563 * extract_bcn_stats_tlv() - extract bcn stats from event
19564 * @wmi_handle: wmi handle
19565 * @param evt_buf: pointer to event buffer
19566 * @param index: Index into vdev stats
19567 * @param bcn_stats: Pointer to hold bcn stats
19568 *
19569 * Return: QDF_STATUS_SUCCESS for success or error code
19570 */
19571static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
19572 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
19573{
19574 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19575 wmi_stats_event_fixed_param *ev_param;
19576 uint8_t *data;
19577
19578 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19579 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19580 data = (uint8_t *) param_buf->data;
19581
19582 if (index < ev_param->num_bcn_stats) {
19583 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
19584 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19585 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19586 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19587 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
19588 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
19589 (index * sizeof(wmi_bcn_stats)));
19590
19591 bcn_stats->vdev_id = ev->vdev_id;
19592 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
19593 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
19594 }
19595
19596 return QDF_STATUS_SUCCESS;
19597}
19598
19599/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019600 * extract_peer_stats_tlv() - extract peer stats from event
19601 * @wmi_handle: wmi handle
19602 * @param evt_buf: pointer to event buffer
19603 * @param index: Index into peer stats
19604 * @param peer_stats: Pointer to hold peer stats
19605 *
19606 * Return: QDF_STATUS_SUCCESS for success or error code
19607 */
19608static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19609 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19610{
19611 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19612 wmi_stats_event_fixed_param *ev_param;
19613 uint8_t *data;
19614
19615 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19616 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19617 data = (uint8_t *) param_buf->data;
19618
19619 if (index < ev_param->num_peer_stats) {
19620 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19621 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19622 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19623 (index * sizeof(wmi_peer_stats)));
19624
19625 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19626
19627 OS_MEMCPY(&(peer_stats->peer_macaddr),
19628 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19629
19630 peer_stats->peer_rssi = ev->peer_rssi;
19631 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19632 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19633 }
19634
19635 return QDF_STATUS_SUCCESS;
19636}
19637
19638/**
19639 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19640 * @wmi_handle: wmi handle
19641 * @param evt_buf: pointer to event buffer
19642 * @param index: Index into bcn fault stats
19643 * @param bcnflt_stats: Pointer to hold bcn fault stats
19644 *
19645 * Return: QDF_STATUS_SUCCESS for success or error code
19646 */
19647static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19648 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19649{
19650 return QDF_STATUS_SUCCESS;
19651}
19652
19653/**
19654 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19655 * @wmi_handle: wmi handle
19656 * @param evt_buf: pointer to event buffer
19657 * @param index: Index into extended peer stats
19658 * @param peer_extd_stats: Pointer to hold extended peer stats
19659 *
19660 * Return: QDF_STATUS_SUCCESS for success or error code
19661 */
19662static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19663 void *evt_buf, uint32_t index,
19664 wmi_host_peer_extd_stats *peer_extd_stats)
19665{
19666 return QDF_STATUS_SUCCESS;
19667}
19668
19669/**
19670 * extract_chan_stats_tlv() - extract chan stats from event
19671 * @wmi_handle: wmi handle
19672 * @param evt_buf: pointer to event buffer
19673 * @param index: Index into chan stats
19674 * @param vdev_extd_stats: Pointer to hold chan stats
19675 *
19676 * Return: QDF_STATUS_SUCCESS for success or error code
19677 */
19678static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19679 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19680{
19681 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19682 wmi_stats_event_fixed_param *ev_param;
19683 uint8_t *data;
19684
19685 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19686 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19687 data = (uint8_t *) param_buf->data;
19688
19689 if (index < ev_param->num_chan_stats) {
19690 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19691 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19692 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19693 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19694 (index * sizeof(wmi_chan_stats)));
19695
19696
Jeff Johnson79eaacb2018-05-06 17:53:18 -070019697 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +053019698 chan_stats->chan_mhz = ev->chan_mhz;
19699 chan_stats->sampling_period_us = ev->sampling_period_us;
19700 chan_stats->rx_clear_count = ev->rx_clear_count;
19701 chan_stats->tx_duration_us = ev->tx_duration_us;
19702 chan_stats->rx_duration_us = ev->rx_duration_us;
19703 }
19704
19705 return QDF_STATUS_SUCCESS;
19706}
19707
19708/**
19709 * extract_profile_ctx_tlv() - extract profile context from event
19710 * @wmi_handle: wmi handle
19711 * @param evt_buf: pointer to event buffer
19712 * @idx: profile stats index to extract
19713 * @param profile_ctx: Pointer to hold profile context
19714 *
19715 * Return: QDF_STATUS_SUCCESS for success or error code
19716 */
19717static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19718 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19719{
19720 return QDF_STATUS_SUCCESS;
19721}
19722
19723/**
19724 * extract_profile_data_tlv() - extract profile data from event
19725 * @wmi_handle: wmi handle
19726 * @param evt_buf: pointer to event buffer
19727 * @param profile_data: Pointer to hold profile data
19728 *
19729 * Return: QDF_STATUS_SUCCESS for success or error code
19730 */
19731static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19732 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19733{
19734
19735 return QDF_STATUS_SUCCESS;
19736}
19737
19738/**
19739 * extract_chan_info_event_tlv() - extract chan information from event
19740 * @wmi_handle: wmi handle
19741 * @param evt_buf: pointer to event buffer
19742 * @param chan_info: Pointer to hold chan information
19743 *
19744 * Return: QDF_STATUS_SUCCESS for success or error code
19745 */
19746static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19747 void *evt_buf, wmi_host_chan_info_event *chan_info)
19748{
19749 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19750 wmi_chan_info_event_fixed_param *ev;
19751
19752 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19753
19754 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19755 if (!ev) {
19756 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19757 return QDF_STATUS_E_FAILURE;
19758 }
19759
19760 chan_info->err_code = ev->err_code;
19761 chan_info->freq = ev->freq;
19762 chan_info->cmd_flags = ev->cmd_flags;
19763 chan_info->noise_floor = ev->noise_floor;
19764 chan_info->rx_clear_count = ev->rx_clear_count;
19765 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019766 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19767 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019768 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19769 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19770 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019771 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19772 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19773 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19774 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19775 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19776 chan_info->rx_frame_count = ev->rx_frame_count;
19777 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19778 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019779
19780 return QDF_STATUS_SUCCESS;
19781}
19782
19783/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019784 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19785 * @wmi_handle: WMI handle
19786 * @param evt_buf: Pointer to event buffer
19787 * @param param: Pointer to hold data
19788 *
19789 * Return : QDF_STATUS_SUCCESS for success or error code
19790 */
19791static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19792 uint8_t *evt_buf,
19793 struct wmi_host_pdev_utf_event *event)
19794{
19795 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019796 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019797
19798 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19799 event->data = param_buf->data;
19800 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019801 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019802 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019803 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019804 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019805
19806 return QDF_STATUS_SUCCESS;
19807}
Govind Singhe7f2f342016-05-23 12:12:52 +053019808
Kiran Venkatappa06520822016-08-10 23:55:40 +053019809/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019810 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19811 * @wmi_handle: wmi handle
19812 * @param evt_buf: pointer to event buffer
19813 * @param param: Pointer to hold evt buf
19814 *
19815 * Return: QDF_STATUS_SUCCESS for success or error code
19816 */
19817static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19818 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19819{
19820 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19821 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19822 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19823 uint8_t i = 0, j = 0;
19824
19825 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19826 if (!param_buf)
19827 return QDF_STATUS_E_INVAL;
19828
19829 hw_caps = param_buf->soc_hw_mode_caps;
19830 if (!hw_caps)
19831 return QDF_STATUS_E_INVAL;
19832
19833 if (!hw_caps->num_chainmask_tables)
19834 return QDF_STATUS_E_INVAL;
19835
19836 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19837
19838 if (chainmask_caps == NULL)
19839 return QDF_STATUS_E_INVAL;
19840
19841 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19842
19843 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19844 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19845
19846 chainmask_table[i].cap_list[j].chainmask =
19847 chainmask_caps->chainmask;
19848
19849 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19850 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19851
19852 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19853 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19854
19855 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19856 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19857
19858 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19859 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19860
19861 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19862 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19863
19864 chainmask_table[i].cap_list[j].chain_mask_2G =
19865 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19866
19867 chainmask_table[i].cap_list[j].chain_mask_5G =
19868 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19869
19870 chainmask_table[i].cap_list[j].chain_mask_tx =
19871 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19872
19873 chainmask_table[i].cap_list[j].chain_mask_rx =
19874 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19875
19876 chainmask_table[i].cap_list[j].supports_aDFS =
19877 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19878
19879 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19880 chainmask_caps->supported_flags,
19881 chainmask_caps->chainmask
19882 );
19883 chainmask_caps++;
19884 }
19885 }
19886
19887 return QDF_STATUS_SUCCESS;
19888}
19889
19890/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019891 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19892 * from event
19893 * @wmi_handle: wmi handle
19894 * @param evt_buf: pointer to event buffer
19895 * @param param: Pointer to hold evt buf
19896 *
19897 * Return: QDF_STATUS_SUCCESS for success or error code
19898 */
19899static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019900 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019901{
19902 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19903 wmi_service_ready_ext_event_fixed_param *ev;
19904 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19905 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019906 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19907 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019908
19909 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19910 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019911 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019912
19913 ev = param_buf->fixed_param;
19914 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019915 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019916
19917 /* Move this to host based bitmap */
19918 param->default_conc_scan_config_bits =
19919 ev->default_conc_scan_config_bits;
19920 param->default_fw_config_bits = ev->default_fw_config_bits;
19921 param->he_cap_info = ev->he_cap_info;
19922 param->mpdu_density = ev->mpdu_density;
19923 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019924 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019925 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019926 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19927
19928 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019929 if (hw_caps)
19930 param->num_hw_modes = hw_caps->num_hw_modes;
19931 else
19932 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019933
19934 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019935 if (reg_caps)
19936 param->num_phy = reg_caps->num_phy;
19937 else
19938 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019939
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019940 if (hw_caps) {
19941 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
19942 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
19943 } else
19944 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019945
19946 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19947
19948 if (chain_mask_combo == NULL)
19949 return QDF_STATUS_SUCCESS;
19950
19951 qdf_print("Dumping chain mask combo data\n");
19952
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019953 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019954
19955 qdf_print("table_id : %d Num valid chainmasks: %d\n",
19956 chain_mask_combo->chainmask_table_id,
19957 chain_mask_combo->num_valid_chainmask
19958 );
19959
19960 param->chainmask_table[i].table_id =
19961 chain_mask_combo->chainmask_table_id;
19962 param->chainmask_table[i].num_valid_chainmasks =
19963 chain_mask_combo->num_valid_chainmask;
19964 chain_mask_combo++;
19965 }
19966 qdf_print("chain mask combo end\n");
19967
Kiran Venkatappa06520822016-08-10 23:55:40 +053019968 return QDF_STATUS_SUCCESS;
19969}
19970
19971/**
19972 * extract_hw_mode_cap_service_ready_ext_tlv() -
19973 * extract HW mode cap from service ready event
19974 * @wmi_handle: wmi handle
19975 * @param evt_buf: pointer to event buffer
19976 * @param param: Pointer to hold evt buf
19977 * @param hw_mode_idx: hw mode idx should be less than num_mode
19978 *
19979 * Return: QDF_STATUS_SUCCESS for success or error code
19980 */
19981static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19982 wmi_unified_t wmi_handle,
19983 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019984 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019985{
19986 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19987 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19988
19989 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19990 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019991 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019992
19993 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019994 if (!hw_caps)
19995 return QDF_STATUS_E_INVAL;
19996
Kiran Venkatappa06520822016-08-10 23:55:40 +053019997 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019998 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019999
20000 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
20001 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
20002
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020003 param->hw_mode_config_type =
20004 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
20005
Kiran Venkatappa06520822016-08-10 23:55:40 +053020006 return QDF_STATUS_SUCCESS;
20007}
20008
20009/**
20010 * extract_mac_phy_cap_service_ready_ext_tlv() -
20011 * extract MAC phy cap from service ready event
20012 * @wmi_handle: wmi handle
20013 * @param evt_buf: pointer to event buffer
20014 * @param param: Pointer to hold evt buf
20015 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020016 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053020017 *
20018 * Return: QDF_STATUS_SUCCESS for success or error code
20019 */
20020static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
20021 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020022 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080020023 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053020024{
20025 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020026 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020027 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
20028 uint32_t phy_map;
20029 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020030
20031 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
20032 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020033 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020034
20035 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020036 if (!hw_caps)
20037 return QDF_STATUS_E_INVAL;
20038
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020039 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
20040 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
20041 break;
20042
20043 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
20044 while (phy_map) {
20045 phy_map >>= 1;
20046 phy_idx++;
20047 }
20048 }
20049
20050 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020051 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020052
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020053 phy_idx += phy_id;
20054 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020055 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020056
20057 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053020058
20059 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020060 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20061 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053020062 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020063 param->supports_11b =
20064 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
20065 param->supports_11g =
20066 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
20067 param->supports_11a =
20068 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
20069 param->supports_11n =
20070 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
20071 param->supports_11ac =
20072 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
20073 param->supports_11ax =
20074 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053020075
20076 param->supported_bands = mac_phy_caps->supported_bands;
20077 param->ampdu_density = mac_phy_caps->ampdu_density;
20078 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
20079 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
20080 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
20081 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
20082 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
20083 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
20084 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
20085 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
20086 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
20087 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
20088 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
20089 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
20090 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
20091 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
20092 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
20093 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080020094 qdf_mem_copy(&param->he_cap_phy_info_2G,
20095 &mac_phy_caps->he_cap_phy_info_2G,
20096 sizeof(param->he_cap_phy_info_2G));
20097 qdf_mem_copy(&param->he_cap_phy_info_5G,
20098 &mac_phy_caps->he_cap_phy_info_5G,
20099 sizeof(param->he_cap_phy_info_5G));
20100 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
20101 sizeof(param->he_ppet2G));
20102 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
20103 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053020104 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020105
20106 return QDF_STATUS_SUCCESS;
20107}
20108
20109/**
20110 * extract_reg_cap_service_ready_ext_tlv() -
20111 * extract REG cap from service ready event
20112 * @wmi_handle: wmi handle
20113 * @param evt_buf: pointer to event buffer
20114 * @param param: Pointer to hold evt buf
20115 * @param phy_idx: phy idx should be less than num_mode
20116 *
20117 * Return: QDF_STATUS_SUCCESS for success or error code
20118 */
20119static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
20120 wmi_unified_t wmi_handle,
20121 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080020122 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053020123{
20124 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20125 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
20126 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
20127
20128 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
20129 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020130 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020131
20132 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020133 if (!reg_caps)
20134 return QDF_STATUS_E_INVAL;
20135
Kiran Venkatappa06520822016-08-10 23:55:40 +053020136 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020137 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020138
20139 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
20140
20141 param->phy_id = ext_reg_cap->phy_id;
20142 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
20143 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
20144 param->regcap1 = ext_reg_cap->regcap1;
20145 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053020146 param->wireless_modes = convert_wireless_modes_tlv(
20147 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053020148 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
20149 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
20150 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
20151 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
20152
20153 return QDF_STATUS_SUCCESS;
20154}
20155
Sathish Kumarf396c722017-11-17 17:30:41 +053020156static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
20157 wmi_unified_t wmi_handle,
20158 uint8_t *event, uint8_t idx,
20159 struct wlan_psoc_host_dbr_ring_caps *param)
20160{
20161 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20162 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
20163
20164 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
20165 if (!param_buf)
20166 return QDF_STATUS_E_INVAL;
20167
20168 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
20169
20170 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20171 dbr_ring_caps->pdev_id);
20172 param->mod_id = dbr_ring_caps->mod_id;
20173 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
20174 param->min_buf_size = dbr_ring_caps->min_buf_size;
20175 param->min_buf_align = dbr_ring_caps->min_buf_align;
20176
20177 return QDF_STATUS_SUCCESS;
20178}
20179
20180static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
20181 uint8_t *event, struct direct_buf_rx_rsp *param)
20182{
20183 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20184 wmi_dma_buf_release_fixed_param *ev;
20185
20186 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20187 if (!param_buf)
20188 return QDF_STATUS_E_INVAL;
20189
20190 ev = param_buf->fixed_param;
20191 if (!ev)
20192 return QDF_STATUS_E_INVAL;
20193
20194 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20195 ev->pdev_id);
20196 param->mod_id = ev->mod_id;
20197 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053020198 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053020199 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
20200 param->pdev_id, param->mod_id, param->num_buf_release_entry);
20201
20202 return QDF_STATUS_SUCCESS;
20203}
20204
20205static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
20206 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
20207{
20208 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20209 wmi_dma_buf_release_entry *entry;
20210
20211 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20212 if (!param_buf)
20213 return QDF_STATUS_E_INVAL;
20214
20215 entry = &param_buf->entries[idx];
20216
20217 if (!entry) {
20218 WMI_LOGE("%s: Entry is NULL\n", __func__);
20219 return QDF_STATUS_E_FAILURE;
20220 }
20221
20222 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
20223
20224 param->paddr_lo = entry->paddr_lo;
20225 param->paddr_hi = entry->paddr_hi;
20226
20227 return QDF_STATUS_SUCCESS;
20228}
20229
Edayilliam Jayadev92651222018-04-06 16:37:17 +053020230static QDF_STATUS extract_dbr_buf_metadata_tlv(
20231 wmi_unified_t wmi_handle, uint8_t *event,
20232 uint8_t idx, struct direct_buf_rx_metadata *param)
20233{
20234 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20235 wmi_dma_buf_release_spectral_meta_data *entry;
20236
20237 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20238 if (!param_buf)
20239 return QDF_STATUS_E_INVAL;
20240
20241 entry = &param_buf->meta_data[idx];
20242
20243 if (!entry) {
20244 WMI_LOGE("%s: Entry is NULL\n", __func__);
20245 return QDF_STATUS_E_FAILURE;
20246 }
20247
20248 qdf_mem_copy(param->noisefloor, entry->noise_floor,
20249 sizeof(entry->noise_floor));
20250 return QDF_STATUS_SUCCESS;
20251}
20252
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020253/**
20254 * extract_dcs_interference_type_tlv() - extract dcs interference type
20255 * from event
20256 * @wmi_handle: wmi handle
20257 * @param evt_buf: pointer to event buffer
20258 * @param param: Pointer to hold dcs interference param
20259 *
20260 * Return: 0 for success or error code
20261 */
20262static QDF_STATUS extract_dcs_interference_type_tlv(
20263 wmi_unified_t wmi_handle,
20264 void *evt_buf, struct wmi_host_dcs_interference_param *param)
20265{
20266 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20267
20268 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20269 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020270 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020271
20272 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020273 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20274 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020275
20276 return QDF_STATUS_SUCCESS;
20277}
20278
20279/*
20280 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
20281 * @wmi_handle: wmi handle
20282 * @param evt_buf: pointer to event buffer
20283 * @param cw_int: Pointer to hold cw interference
20284 *
20285 * Return: 0 for success or error code
20286 */
20287static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
20288 void *evt_buf,
20289 wmi_host_ath_dcs_cw_int *cw_int)
20290{
20291 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20292 wlan_dcs_cw_int *ev;
20293
20294 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20295 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020296 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020297
20298 ev = param_buf->cw_int;
20299
20300 cw_int->channel = ev->channel;
20301
20302 return QDF_STATUS_SUCCESS;
20303}
20304
20305/**
20306 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
20307 * @wmi_handle: wmi handle
20308 * @param evt_buf: pointer to event buffer
20309 * @param wlan_stat: Pointer to hold wlan stats
20310 *
20311 * Return: 0 for success or error code
20312 */
20313static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
20314 void *evt_buf,
20315 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
20316{
20317 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20318 wlan_dcs_im_tgt_stats_t *ev;
20319
20320 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20321 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020322 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020323
20324 ev = param_buf->wlan_stat;
20325 wlan_stat->reg_tsf32 = ev->reg_tsf32;
20326 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
20327 wlan_stat->tx_waste_time = ev->tx_waste_time;
20328 wlan_stat->rx_time = ev->rx_time;
20329 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
20330 wlan_stat->mib_stats.listen_time = ev->listen_time;
20331 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
20332 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
20333 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
20334 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
20335 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
20336 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
20337 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
20338 wlan_stat->chan_nf = ev->chan_nf;
20339 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
20340
20341 return QDF_STATUS_SUCCESS;
20342}
20343
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020344/**
20345 * extract_thermal_stats_tlv() - extract thermal stats from event
20346 * @wmi_handle: wmi handle
20347 * @param evt_buf: Pointer to event buffer
20348 * @param temp: Pointer to hold extracted temperature
20349 * @param level: Pointer to hold extracted level
20350 *
20351 * Return: 0 for success or error code
20352 */
20353static QDF_STATUS
20354extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
20355 void *evt_buf, uint32_t *temp,
20356 uint32_t *level, uint32_t *pdev_id)
20357{
20358 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20359 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
20360
20361 param_buf =
20362 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20363 if (!param_buf)
20364 return QDF_STATUS_E_INVAL;
20365
20366 tt_stats_event = param_buf->fixed_param;
20367
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020368 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20369 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020370 *temp = tt_stats_event->temp;
20371 *level = tt_stats_event->level;
20372
20373 return QDF_STATUS_SUCCESS;
20374}
20375
20376/**
20377 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
20378 * @wmi_handle: wmi handle
20379 * @param evt_buf: pointer to event buffer
20380 * @param idx: Index to level stats
20381 * @param levelcount: Pointer to hold levelcount
20382 * @param dccount: Pointer to hold dccount
20383 *
20384 * Return: 0 for success or error code
20385 */
20386static QDF_STATUS
20387extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
20388 void *evt_buf, uint8_t idx, uint32_t *levelcount,
20389 uint32_t *dccount)
20390{
20391 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20392 wmi_therm_throt_level_stats_info *tt_level_info;
20393
20394 param_buf =
20395 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20396 if (!param_buf)
20397 return QDF_STATUS_E_INVAL;
20398
20399 tt_level_info = param_buf->therm_throt_level_stats_info;
20400
20401 if (idx < THERMAL_LEVELS) {
20402 *levelcount = tt_level_info[idx].level_count;
20403 *dccount = tt_level_info[idx].dc_count;
20404 return QDF_STATUS_SUCCESS;
20405 }
20406
20407 return QDF_STATUS_E_FAILURE;
20408}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020409#ifdef BIG_ENDIAN_HOST
20410/**
20411 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
20412 * @param data_len - data length
20413 * @param data - pointer to data
20414 *
20415 * Return: QDF_STATUS - success or error status
20416 */
20417static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20418{
20419 uint8_t *data_aligned = NULL;
20420 int c;
20421 unsigned char *data_unaligned;
20422
20423 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
20424 FIPS_ALIGN));
20425 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -070020426 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020427 if (data_unaligned == NULL)
20428 return QDF_STATUS_E_FAILURE;
20429
20430 /* Checking if space is alligned */
20431 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
20432 /* align the data space */
20433 data_aligned =
20434 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
20435 } else {
20436 data_aligned = (u_int8_t *)data_unaligned;
20437 }
20438
20439 /* memset and copy content from data to data aligned */
20440 OS_MEMSET(data_aligned, 0, data_len);
20441 OS_MEMCPY(data_aligned, data, data_len);
20442 /* Endianness to LE */
20443 for (c = 0; c < data_len/4; c++) {
20444 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020445 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020446 }
20447
20448 /* Copy content to event->data */
20449 OS_MEMCPY(data, data_aligned, data_len);
20450
20451 /* clean up allocated space */
20452 qdf_mem_free(data_unaligned);
20453 data_aligned = NULL;
20454 data_unaligned = NULL;
20455
20456 /*************************************************************/
20457
20458 return QDF_STATUS_SUCCESS;
20459}
20460#else
20461/**
20462 * fips_conv_data_be() - DUMMY for LE platform
20463 *
20464 * Return: QDF_STATUS - success
20465 */
20466static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20467{
20468 return QDF_STATUS_SUCCESS;
20469}
20470#endif
20471
20472/**
20473 * extract_fips_event_data_tlv() - extract fips event data
20474 * @wmi_handle: wmi handle
20475 * @param evt_buf: pointer to event buffer
20476 * @param param: pointer FIPS event params
20477 *
20478 * Return: 0 for success or error code
20479 */
20480static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
20481 void *evt_buf, struct wmi_host_fips_event_param *param)
20482{
20483 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
20484 wmi_pdev_fips_event_fixed_param *event;
20485
20486 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
20487 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
20488
20489 if (fips_conv_data_be(event->data_len, param_buf->data) !=
20490 QDF_STATUS_SUCCESS)
20491 return QDF_STATUS_E_FAILURE;
20492
20493 param->data = (uint32_t *)param_buf->data;
20494 param->data_len = event->data_len;
20495 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020496 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20497 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020498
20499 return QDF_STATUS_SUCCESS;
20500}
20501
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020502/*
20503 * extract_peer_delete_response_event_tlv() - extract peer delete response event
20504 * @wmi_handle: wmi handle
20505 * @param evt_buf: pointer to event buffer
20506 * @param vdev_id: Pointer to hold vdev_id
20507 * @param mac_addr: Pointer to hold peer mac address
20508 *
20509 * Return: QDF_STATUS_SUCCESS for success or error code
20510 */
20511static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
20512 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
20513{
20514 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
20515 wmi_peer_delete_resp_event_fixed_param *ev;
20516
20517 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
20518
20519 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
20520 if (!ev) {
20521 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
20522 return QDF_STATUS_E_FAILURE;
20523 }
20524
20525 param->vdev_id = ev->vdev_id;
20526 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
20527 &param->mac_address.bytes[0]);
20528
20529 return QDF_STATUS_SUCCESS;
20530}
20531
Govind Singhecf03cd2016-05-12 12:45:51 +053020532static bool is_management_record_tlv(uint32_t cmd_id)
20533{
jiad36c94d22018-01-22 15:37:03 +080020534 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
20535 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
20536 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053020537 return true;
jiad36c94d22018-01-22 15:37:03 +080020538 }
Govind Singhe7f2f342016-05-23 12:12:52 +053020539
Govind Singhecf03cd2016-05-12 12:45:51 +053020540 return false;
20541}
20542
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053020543static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20544{
20545 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
20546
20547 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
20548
20549 switch (set_cmd->param_id) {
20550 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
20551 case WMI_VDEV_PARAM_DTIM_POLICY:
20552 return HTC_TX_PACKET_TAG_AUTO_PM;
20553 default:
20554 break;
20555 }
20556
20557 return 0;
20558}
20559
20560static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20561{
20562 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
20563
20564 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20565
20566 switch (ps_cmd->param) {
20567 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20568 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20569 case WMI_STA_PS_ENABLE_QPOWER:
20570 return HTC_TX_PACKET_TAG_AUTO_PM;
20571 default:
20572 break;
20573 }
20574
20575 return 0;
20576}
20577
20578static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20579 uint32_t cmd_id)
20580{
20581 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20582 return 0;
20583
20584 switch (cmd_id) {
20585 case WMI_VDEV_SET_PARAM_CMDID:
20586 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20587 case WMI_STA_POWERSAVE_PARAM_CMDID:
20588 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20589 default:
20590 break;
20591 }
20592
20593 return 0;
20594}
20595
20596static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20597{
20598 uint16_t tag = 0;
20599
20600 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20601 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20602 __func__);
20603 return tag;
20604 }
20605
20606 if (wmi_handle->tag_crash_inject)
20607 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20608
20609 wmi_handle->tag_crash_inject = false;
20610 return tag;
20611}
20612
20613/**
20614 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20615 * @wmi_handle: WMI handle
20616 * @buf: WMI buffer
20617 * @cmd_id: WMI command Id
20618 *
20619 * Return htc_tx_tag
20620 */
20621static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20622 wmi_buf_t buf,
20623 uint32_t cmd_id)
20624{
20625 uint16_t htc_tx_tag = 0;
20626
20627 switch (cmd_id) {
20628 case WMI_WOW_ENABLE_CMDID:
20629 case WMI_PDEV_SUSPEND_CMDID:
20630 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20631 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20632 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20633 case WMI_PDEV_RESUME_CMDID:
20634 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20635 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20636#ifdef FEATURE_WLAN_D0WOW
20637 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20638#endif
20639 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20640 break;
20641 case WMI_FORCE_FW_HANG_CMDID:
20642 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20643 break;
20644 case WMI_VDEV_SET_PARAM_CMDID:
20645 case WMI_STA_POWERSAVE_PARAM_CMDID:
20646 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20647 default:
20648 break;
20649 }
20650
20651 return htc_tx_tag;
20652}
20653
Sathish Kumard3ab1002017-02-07 17:10:59 +053020654/**
20655 * extract_channel_hopping_event_tlv() - extract channel hopping param
20656 * from event
20657 * @wmi_handle: wmi handle
20658 * @param evt_buf: pointer to event buffer
20659 * @param ch_hopping: Pointer to hold channel hopping param
20660 *
20661 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20662 */
20663static QDF_STATUS extract_channel_hopping_event_tlv(
20664 wmi_unified_t wmi_handle, void *evt_buf,
20665 wmi_host_pdev_channel_hopping_event *ch_hopping)
20666{
20667 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20668 wmi_pdev_channel_hopping_event_fixed_param *event;
20669
20670 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20671 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20672 param_buf->fixed_param;
20673
20674 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20675 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020676 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20677 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020678
20679 return QDF_STATUS_SUCCESS;
20680}
20681
20682/**
20683 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20684 * @wmi_handle: wmi handle
20685 * @param evt_buf: pointer to event buffer
20686 * @param param: Pointer to hold tpc param
20687 *
20688 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20689 */
20690static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20691 void *evt_buf,
20692 wmi_host_pdev_tpc_event *param)
20693{
20694 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20695 wmi_pdev_tpc_event_fixed_param *event;
20696
20697 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20698 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20699
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020700 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20701 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020702 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20703
20704 return QDF_STATUS_SUCCESS;
20705}
20706
nobeljf74583b2018-01-25 16:35:36 -080020707/**
20708 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20709 * power param from event
20710 * @wmi_handle: wmi handle
20711 * @param evt_buf: pointer to event buffer
20712 * @param param: Pointer to hold nf cal power param
20713 *
20714 * Return: 0 for success or error code
20715 */
20716static QDF_STATUS
20717extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20718 void *evt_buf,
20719 wmi_host_pdev_nfcal_power_all_channels_event *param)
20720{
20721 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20722 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20723 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20724 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20725 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20726 uint32_t i;
20727
20728 param_buf =
20729 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20730 event = param_buf->fixed_param;
20731 ch_nfdbr = param_buf->nfdbr;
20732 ch_nfdbm = param_buf->nfdbm;
20733 ch_freqnum = param_buf->freqnum;
20734
20735 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20736 event->pdev_id, param_buf->num_nfdbr,
20737 param_buf->num_nfdbm, param_buf->num_freqnum);
20738
20739 if (param_buf->num_nfdbr >
20740 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20741 WMI_LOGE("invalid number of nfdBr");
20742 return QDF_STATUS_E_FAILURE;
20743 }
20744
20745 if (param_buf->num_nfdbm >
20746 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20747 WMI_LOGE("invalid number of nfdBm");
20748 return QDF_STATUS_E_FAILURE;
20749 }
20750
20751 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20752 WMI_LOGE("invalid number of freqNum");
20753 return QDF_STATUS_E_FAILURE;
20754 }
20755
20756 for (i = 0; i < param_buf->num_nfdbr; i++) {
20757 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20758 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20759 ch_nfdbr++;
20760 ch_nfdbm++;
20761 }
20762
20763 for (i = 0; i < param_buf->num_freqnum; i++) {
20764 param->freqnum[i] = ch_freqnum->freqNum;
20765 ch_freqnum++;
20766 }
20767
20768 param->pdev_id = event->pdev_id;
20769
20770 return QDF_STATUS_SUCCESS;
20771}
20772
Sathish Kumard3ab1002017-02-07 17:10:59 +053020773
20774#ifdef BIG_ENDIAN_HOST
20775/**
20776 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20777 * @param data_len - data length
20778 * @param data - pointer to data
20779 *
20780 * Return: QDF_STATUS - success or error status
20781 */
20782static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20783{
20784 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020785 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020786 /* Skip swapping the first word */
20787 datap += sizeof(uint32_t);
20788 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20789 i++, datap += sizeof(uint32_t)) {
20790 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20791 }
20792
20793 return QDF_STATUS_SUCCESS;
20794}
20795#else
20796/**
20797 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20798 * @param data_len - data length
20799 * @param data - pointer to data
20800 *
20801 * Return: QDF_STATUS - success or error status
20802 */
20803static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20804{
20805 return QDF_STATUS_SUCCESS;
20806}
20807#endif
20808
20809/**
20810 * extract_wds_addr_event_tlv() - extract wds address from event
20811 * @wmi_handle: wmi handle
20812 * @param evt_buf: pointer to event buffer
20813 * @param wds_ev: Pointer to hold wds address
20814 *
20815 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20816 */
20817static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20818 void *evt_buf,
20819 uint16_t len, wds_addr_event_t *wds_ev)
20820{
20821 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20822 wmi_wds_addr_event_fixed_param *ev;
20823 int i;
20824
20825 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20826 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20827
20828 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20829 return QDF_STATUS_E_FAILURE;
20830
20831 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20832 sizeof(wds_ev->event_type));
20833 for (i = 0; i < 4; i++) {
20834 wds_ev->peer_mac[i] =
20835 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20836 wds_ev->dest_mac[i] =
20837 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20838 }
20839 for (i = 0; i < 2; i++) {
20840 wds_ev->peer_mac[4+i] =
20841 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20842 wds_ev->dest_mac[4+i] =
20843 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20844 }
20845 return QDF_STATUS_SUCCESS;
20846}
20847
20848/**
20849 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20850 * from event
20851 * @wmi_handle: wmi handle
20852 * @param evt_buf: pointer to event buffer
20853 * @param ev: Pointer to hold peer param and ps state
20854 *
20855 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20856 */
20857static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20858 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20859{
20860 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20861 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20862
20863 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20864 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20865 param_buf->fixed_param;
20866
20867 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20868 ev->peer_ps_state = event->peer_ps_state;
20869
20870 return QDF_STATUS_SUCCESS;
20871}
20872
20873/**
20874 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20875 * @wmi_handle: wmi handle
20876 * @param evt_buf: pointer to event buffer
20877 * @param inst_rssi_resp: Pointer to hold inst rssi response
20878 *
20879 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20880 */
20881static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20882 wmi_unified_t wmi_handle, void *evt_buf,
20883 wmi_host_inst_stats_resp *inst_rssi_resp)
20884{
20885 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20886 wmi_inst_rssi_stats_resp_fixed_param *event;
20887
20888 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20889 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20890
20891 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20892 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20893 inst_rssi_resp->iRSSI = event->iRSSI;
20894
20895 return QDF_STATUS_SUCCESS;
20896}
20897
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020898static struct cur_reg_rule
20899*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20900 wmi_regulatory_rule_struct *wmi_reg_rule)
20901{
20902 struct cur_reg_rule *reg_rule_ptr;
20903 uint32_t count;
20904
20905 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20906
20907 if (NULL == reg_rule_ptr) {
20908 WMI_LOGE("memory allocation failure");
20909 return NULL;
20910 }
20911
20912 for (count = 0; count < num_reg_rules; count++) {
20913 reg_rule_ptr[count].start_freq =
20914 WMI_REG_RULE_START_FREQ_GET(
20915 wmi_reg_rule[count].freq_info);
20916 reg_rule_ptr[count].end_freq =
20917 WMI_REG_RULE_END_FREQ_GET(
20918 wmi_reg_rule[count].freq_info);
20919 reg_rule_ptr[count].max_bw =
20920 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020921 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020922 reg_rule_ptr[count].reg_power =
20923 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020924 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020925 reg_rule_ptr[count].ant_gain =
20926 WMI_REG_RULE_ANTENNA_GAIN_GET(
20927 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020928 reg_rule_ptr[count].flags =
20929 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020930 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020931 }
20932
20933 return reg_rule_ptr;
20934}
20935
20936static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20937 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20938 struct cur_regulatory_info *reg_info, uint32_t len)
20939{
20940 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20941 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20942 wmi_regulatory_rule_struct *wmi_reg_rule;
20943 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20944
20945 WMI_LOGD("processing regulatory channel list");
20946
20947 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20948 if (!param_buf) {
20949 WMI_LOGE("invalid channel list event buf");
20950 return QDF_STATUS_E_FAILURE;
20951 }
20952
20953 chan_list_event_hdr = param_buf->fixed_param;
20954
20955 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20956 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20957 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020958 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020959 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20960 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020961 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020962 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020963 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020964 reg_info->ctry_code = chan_list_event_hdr->country_id;
20965 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20966 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20967 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20968 else if (chan_list_event_hdr->status_code ==
20969 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20970 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20971 else if (chan_list_event_hdr->status_code ==
20972 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20973 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20974 else if (chan_list_event_hdr->status_code ==
20975 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20976 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20977 else if (chan_list_event_hdr->status_code ==
20978 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20979 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20980 else if (chan_list_event_hdr->status_code ==
20981 WMI_REG_SET_CC_STATUS_FAIL)
20982 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20983
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020984 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20985 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20986 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20987 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20988
20989 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20990 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20991
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020992 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20993 __func__, reg_info->alpha2, reg_info->dfs_region,
20994 reg_info->min_bw_2g, reg_info->max_bw_2g,
20995 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020996
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020997 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20998 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020999 wmi_reg_rule =
21000 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
21001 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
21002 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053021003 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
21004 wmi_reg_rule);
21005 wmi_reg_rule += num_2g_reg_rules;
21006
21007 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
21008 wmi_reg_rule);
21009
21010 WMI_LOGD("processed regulatory channel list");
21011
21012 return QDF_STATUS_SUCCESS;
21013}
21014
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070021015static QDF_STATUS extract_reg_11d_new_country_event_tlv(
21016 wmi_unified_t wmi_handle, uint8_t *evt_buf,
21017 struct reg_11d_new_country *reg_11d_country, uint32_t len)
21018{
21019 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
21020 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
21021
21022 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
21023 if (!param_buf) {
21024 WMI_LOGE("invalid 11d country event buf");
21025 return QDF_STATUS_E_FAILURE;
21026 }
21027
21028 reg_11d_country_event = param_buf->fixed_param;
21029
21030 qdf_mem_copy(reg_11d_country->alpha2,
21031 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
21032
21033 WMI_LOGD("processed 11d country event, new cc %s",
21034 reg_11d_country->alpha2);
21035
21036 return QDF_STATUS_SUCCESS;
21037}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070021038
21039static QDF_STATUS extract_reg_ch_avoid_event_tlv(
21040 wmi_unified_t wmi_handle, uint8_t *evt_buf,
21041 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
21042{
21043 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
21044 wmi_avoid_freq_range_desc *afr_desc;
21045 uint32_t num_freq_ranges, freq_range_idx;
21046 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
21047 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
21048
21049 if (!param_buf) {
21050 WMI_LOGE("Invalid channel avoid event buffer");
21051 return QDF_STATUS_E_INVAL;
21052 }
21053
21054 afr_fixed_param = param_buf->fixed_param;
21055 if (!afr_fixed_param) {
21056 WMI_LOGE("Invalid channel avoid event fixed param buffer");
21057 return QDF_STATUS_E_INVAL;
21058 }
21059
21060 if (!ch_avoid_ind) {
21061 WMI_LOGE("Invalid channel avoid indication buffer");
21062 return QDF_STATUS_E_INVAL;
21063 }
21064 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
21065 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
21066 afr_fixed_param->num_freq_ranges;
21067
21068 WMI_LOGD("Channel avoid event received with %d ranges",
21069 num_freq_ranges);
21070
21071 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
21072 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
21073 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
21074 freq_range_idx++) {
21075 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
21076 afr_desc->start_freq;
21077 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
21078 afr_desc->end_freq;
21079 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
21080 freq_range_idx, afr_desc->tlv_header,
21081 afr_desc->start_freq, afr_desc->end_freq);
21082 afr_desc++;
21083 }
21084
21085 return QDF_STATUS_SUCCESS;
21086}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021087#ifdef DFS_COMPONENT_ENABLE
21088/**
21089 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
21090 * @wmi_handle: wma handle
21091 * @evt_buf: event buffer
21092 * @vdev_id: vdev id
21093 * @len: length of buffer
21094 *
21095 * Return: 0 for success or error code
21096 */
21097static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
21098 uint8_t *evt_buf,
21099 uint32_t *vdev_id,
21100 uint32_t len)
21101{
21102 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
21103 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
21104
21105 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
21106 if (!param_tlvs) {
21107 WMI_LOGE("invalid cac complete event buf");
21108 return QDF_STATUS_E_FAILURE;
21109 }
21110
21111 cac_event = param_tlvs->fixed_param;
21112 *vdev_id = cac_event->vdev_id;
21113 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
21114
21115 return QDF_STATUS_SUCCESS;
21116}
21117
21118/**
21119 * extract_dfs_radar_detection_event_tlv() - extract radar found event
21120 * @wmi_handle: wma handle
21121 * @evt_buf: event buffer
21122 * @radar_found: radar found event info
21123 * @len: length of buffer
21124 *
21125 * Return: 0 for success or error code
21126 */
21127static QDF_STATUS extract_dfs_radar_detection_event_tlv(
21128 wmi_unified_t wmi_handle,
21129 uint8_t *evt_buf,
21130 struct radar_found_info *radar_found,
21131 uint32_t len)
21132{
21133 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
21134 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
21135
21136 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
21137 if (!param_tlv) {
21138 WMI_LOGE("invalid radar detection event buf");
21139 return QDF_STATUS_E_FAILURE;
21140 }
21141
21142 radar_event = param_tlv->fixed_param;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021143 radar_found->pdev_id = wmi_handle->ops->
21144 convert_pdev_id_target_to_host(radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021145 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021146 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021147 radar_found->chan_width = radar_event->chan_width;
21148 radar_found->detector_id = radar_event->detector_id;
21149 radar_found->segment_id = radar_event->segment_id;
21150 radar_found->timestamp = radar_event->timestamp;
21151 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021152 radar_found->freq_offset = radar_event->freq_offset;
21153 radar_found->sidx = radar_event->sidx;
21154
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080021155 WMI_LOGI("processed radar found event pdev %d,"
21156 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
21157 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
21158 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
21159 "is_chirp %d,detection mode %d\n",
21160 radar_event->pdev_id, radar_event->pdev_id,
21161 radar_event->timestamp, radar_event->chan_freq,
21162 radar_event->chan_width, radar_event->detector_id,
21163 radar_event->freq_offset, radar_event->segment_id,
21164 radar_event->sidx, radar_event->is_chirp,
21165 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021166
21167 return QDF_STATUS_SUCCESS;
21168}
bings1ea12532017-12-18 16:56:53 +080021169
21170#ifdef QCA_MCL_DFS_SUPPORT
21171/**
21172 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
21173 * @wmi_handle: wma handle
21174 * @evt_buf: event buffer
21175 * @wlan_radar_event: Pointer to struct radar_event_info
21176 * @len: length of buffer
21177 *
21178 * Return: QDF_STATUS
21179 */
21180static QDF_STATUS extract_wlan_radar_event_info_tlv(
21181 wmi_unified_t wmi_handle,
21182 uint8_t *evt_buf,
21183 struct radar_event_info *wlan_radar_event,
21184 uint32_t len)
21185{
21186 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
21187 wmi_dfs_radar_event_fixed_param *radar_event;
21188
21189 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
21190 if (!param_tlv) {
21191 WMI_LOGE("invalid wlan radar event buf");
21192 return QDF_STATUS_E_FAILURE;
21193 }
21194
21195 radar_event = param_tlv->fixed_param;
21196 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
21197 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
21198 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
21199 wlan_radar_event->rssi = radar_event->rssi;
21200 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
21201 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
21202 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
21203 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080021204 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
21205 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +080021206 if (radar_event->pulse_flags &
21207 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
21208 wlan_radar_event->is_psidx_diff_valid = true;
21209 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
21210 } else {
21211 wlan_radar_event->is_psidx_diff_valid = false;
21212 }
21213
bings1ea12532017-12-18 16:56:53 +080021214 wlan_radar_event->pdev_id = radar_event->pdev_id;
21215
21216 return QDF_STATUS_SUCCESS;
21217}
21218#else
21219static QDF_STATUS extract_wlan_radar_event_info_tlv(
21220 wmi_unified_t wmi_handle,
21221 uint8_t *evt_buf,
21222 struct radar_event_info *wlan_radar_event,
21223 uint32_t len)
21224{
21225 return QDF_STATUS_SUCCESS;
21226}
21227#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021228#endif
21229
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021230/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021231 * send_get_rcpi_cmd_tlv() - send request for rcpi value
21232 * @wmi_handle: wmi handle
21233 * @get_rcpi_param: rcpi params
21234 *
21235 * Return: QDF status
21236 */
21237static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
21238 struct rcpi_req *get_rcpi_param)
21239{
21240 wmi_buf_t buf;
21241 wmi_request_rcpi_cmd_fixed_param *cmd;
21242 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
21243
21244 buf = wmi_buf_alloc(wmi_handle, len);
21245 if (!buf) {
21246 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21247 return QDF_STATUS_E_NOMEM;
21248 }
21249
21250 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
21251 WMITLV_SET_HDR(&cmd->tlv_header,
21252 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
21253 WMITLV_GET_STRUCT_TLVLEN
21254 (wmi_request_rcpi_cmd_fixed_param));
21255
21256 cmd->vdev_id = get_rcpi_param->vdev_id;
21257 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
21258 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070021259
21260 switch (get_rcpi_param->measurement_type) {
21261
21262 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21263 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21264 break;
21265
21266 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
21267 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
21268 break;
21269
21270 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21271 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21272 break;
21273
21274 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
21275 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
21276 break;
21277
21278 default:
21279 /*
21280 * invalid rcpi measurement type, fall back to
21281 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
21282 */
21283 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21284 break;
21285 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021286 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
21287 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21288 WMI_REQUEST_RCPI_CMDID)) {
21289
21290 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
21291 __func__);
21292 wmi_buf_free(buf);
21293 return QDF_STATUS_E_FAILURE;
21294 }
21295
21296 return QDF_STATUS_SUCCESS;
21297}
21298
21299/**
21300 * extract_rcpi_response_event_tlv() - Extract RCPI event params
21301 * @wmi_handle: wmi handle
21302 * @evt_buf: pointer to event buffer
21303 * @res: pointer to hold rcpi response from firmware
21304 *
21305 * Return: QDF_STATUS_SUCCESS for successful event parse
21306 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
21307 */
21308static QDF_STATUS
21309extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
21310 void *evt_buf, struct rcpi_res *res)
21311{
21312 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
21313 wmi_update_rcpi_event_fixed_param *event;
21314
21315 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
21316 if (!param_buf) {
21317 WMI_LOGE(FL("Invalid rcpi event"));
21318 return QDF_STATUS_E_INVAL;
21319 }
21320
21321 event = param_buf->fixed_param;
21322 res->vdev_id = event->vdev_id;
21323 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
21324
21325 switch (event->measurement_type) {
21326
21327 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21328 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21329 break;
21330
21331 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
21332 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
21333 break;
21334
21335 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21336 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21337 break;
21338
21339 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
21340 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
21341 break;
21342
21343 default:
21344 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
21345 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
21346 return QDF_STATUS_E_FAILURE;
21347 }
21348
21349 if (event->status)
21350 return QDF_STATUS_E_FAILURE;
21351 else
21352 return QDF_STATUS_SUCCESS;
21353}
21354
21355/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053021356 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
21357 * host to target defines. For legacy there is not conversion
21358 * required. Just return pdev_id as it is.
21359 * @param pdev_id: host pdev_id to be converted.
21360 * Return: target pdev_id after conversion.
21361 */
21362static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
21363 uint32_t pdev_id)
21364{
21365 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
21366 return WMI_PDEV_ID_SOC;
21367
21368 /*No conversion required*/
21369 return pdev_id;
21370}
21371
21372/**
21373 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
21374 * target to host defines. For legacy there is not conversion
21375 * required. Just return pdev_id as it is.
21376 * @param pdev_id: target pdev_id to be converted.
21377 * Return: host pdev_id after conversion.
21378 */
21379static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
21380 uint32_t pdev_id)
21381{
21382 /*No conversion required*/
21383 return pdev_id;
21384}
21385
21386/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021387 * send_set_country_cmd_tlv() - WMI scan channel list function
21388 * @param wmi_handle : handle to WMI.
21389 * @param param : pointer to hold scan channel list parameter
21390 *
21391 * Return: 0 on success and -ve on failure.
21392 */
21393static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
21394 struct set_country *params)
21395{
21396 wmi_buf_t buf;
21397 QDF_STATUS qdf_status;
21398 wmi_set_current_country_cmd_fixed_param *cmd;
21399 uint16_t len = sizeof(*cmd);
21400
21401 buf = wmi_buf_alloc(wmi_handle, len);
21402 if (!buf) {
21403 WMI_LOGE("Failed to allocate memory");
21404 qdf_status = QDF_STATUS_E_NOMEM;
21405 goto end;
21406 }
21407
21408 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
21409 WMITLV_SET_HDR(&cmd->tlv_header,
21410 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
21411 WMITLV_GET_STRUCT_TLVLEN
21412 (wmi_set_current_country_cmd_fixed_param));
21413
21414 WMI_LOGD("setting cuurnet country to %s", params->country);
21415
21416 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
21417
21418 cmd->pdev_id = params->pdev_id;
21419
21420 qdf_status = wmi_unified_cmd_send(wmi_handle,
21421 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
21422
21423 if (QDF_IS_STATUS_ERROR(qdf_status)) {
21424 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
21425 wmi_buf_free(buf);
21426 }
21427
21428end:
21429 return qdf_status;
21430}
21431
Abhijit Pradhand38a2692017-06-29 12:32:20 +053021432#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
21433 WMI_SET_BITS(alpha, 0, 8, val0); \
21434 WMI_SET_BITS(alpha, 8, 8, val1); \
21435 WMI_SET_BITS(alpha, 16, 8, val2); \
21436 } while (0)
21437
21438static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
21439 uint8_t pdev_id, struct cc_regdmn_s *rd)
21440{
21441 wmi_set_init_country_cmd_fixed_param *cmd;
21442 uint16_t len;
21443 wmi_buf_t buf;
21444 int ret;
21445
21446 len = sizeof(wmi_set_init_country_cmd_fixed_param);
21447 buf = wmi_buf_alloc(wmi_handle, len);
21448 if (!buf) {
21449 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
21450 return QDF_STATUS_E_NOMEM;
21451 }
21452 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
21453 WMITLV_SET_HDR(&cmd->tlv_header,
21454 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
21455 WMITLV_GET_STRUCT_TLVLEN
21456 (wmi_set_init_country_cmd_fixed_param));
21457
21458 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
21459
21460 if (rd->flags == CC_IS_SET) {
21461 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
21462 cmd->country_code.country_id = rd->cc.country_code;
21463 } else if (rd->flags == ALPHA_IS_SET) {
21464 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
21465 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
21466 rd->cc.alpha[0],
21467 rd->cc.alpha[1],
21468 rd->cc.alpha[2]);
21469 } else if (rd->flags == REGDMN_IS_SET) {
21470 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
21471 cmd->country_code.domain_code = rd->cc.regdmn_id;
21472 }
21473
21474 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
21475 WMI_SET_INIT_COUNTRY_CMDID);
21476 if (ret) {
21477 WMI_LOGE("Failed to config wow wakeup event");
21478 wmi_buf_free(buf);
21479 return QDF_STATUS_E_FAILURE;
21480 }
21481
21482 return QDF_STATUS_SUCCESS;
21483}
21484
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053021485/**
21486 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
21487 * configuration params
21488 * @wmi_handle: wmi handler
21489 * @limit_off_chan_param: pointer to wmi_off_chan_param
21490 *
21491 * Return: 0 for success and non zero for failure
21492 */
21493static
21494QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
21495 struct wmi_limit_off_chan_param *limit_off_chan_param)
21496{
21497 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
21498 wmi_buf_t buf;
21499 uint32_t len = sizeof(*cmd);
21500 int err;
21501
21502 buf = wmi_buf_alloc(wmi_handle, len);
21503 if (!buf) {
21504 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
21505 __func__);
21506 return QDF_STATUS_E_NOMEM;
21507 }
21508
21509 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
21510
21511 WMITLV_SET_HDR(&cmd->tlv_header,
21512 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
21513 WMITLV_GET_STRUCT_TLVLEN(
21514 wmi_vdev_limit_offchan_cmd_fixed_param));
21515
21516 cmd->vdev_id = limit_off_chan_param->vdev_id;
21517
21518 cmd->flags &= 0;
21519 if (limit_off_chan_param->status)
21520 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
21521 if (limit_off_chan_param->skip_dfs_chans)
21522 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
21523
21524 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
21525 cmd->rest_time = limit_off_chan_param->rest_time;
21526
21527 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
21528 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
21529 cmd->rest_time);
21530
21531 err = wmi_unified_cmd_send(wmi_handle, buf,
21532 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
21533 if (QDF_IS_STATUS_ERROR(err)) {
21534 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
21535 wmi_buf_free(buf);
21536 return QDF_STATUS_E_FAILURE;
21537 }
21538
21539 return QDF_STATUS_SUCCESS;
21540}
21541
Anurag Chouhan97f00422017-09-11 14:56:30 +053021542/**
21543 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
21544 * @wmi_handle: wmi handler
21545 * @req_buf: set arp stats request buffer
21546 *
21547 * Return: 0 for success and non zero for failure
21548 */
21549static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21550 struct set_arp_stats *req_buf)
21551{
21552 wmi_buf_t buf = NULL;
21553 QDF_STATUS status;
21554 int len;
21555 uint8_t *buf_ptr;
21556 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
21557
21558 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021559 if (req_buf->pkt_type_bitmap) {
21560 len += WMI_TLV_HDR_SIZE;
21561 len += sizeof(wmi_vdev_set_connectivity_check_stats);
21562 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053021563 buf = wmi_buf_alloc(wmi_handle, len);
21564 if (!buf) {
21565 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21566 return QDF_STATUS_E_NOMEM;
21567 }
21568
21569 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21570 wmi_set_arp =
21571 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
21572 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
21573 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
21574 WMITLV_GET_STRUCT_TLVLEN
21575 (wmi_vdev_set_arp_stats_cmd_fixed_param));
21576
21577 /* fill in per roam config values */
21578 wmi_set_arp->vdev_id = req_buf->vdev_id;
21579
21580 wmi_set_arp->set_clr = req_buf->flag;
21581 wmi_set_arp->pkt_type = req_buf->pkt_type;
21582 wmi_set_arp->ipv4 = req_buf->ip_addr;
21583
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021584 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
21585 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
21586 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
21587
21588 /*
21589 * pkt_type_bitmap should be non-zero to ensure
21590 * presence of additional stats.
21591 */
21592 if (req_buf->pkt_type_bitmap) {
21593 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
21594
21595 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21596 WMITLV_SET_HDR(buf_ptr,
21597 WMITLV_TAG_ARRAY_STRUC,
21598 sizeof(wmi_vdev_set_connectivity_check_stats));
21599 buf_ptr += WMI_TLV_HDR_SIZE;
21600 wmi_set_connect_stats =
21601 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
21602 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
21603 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
21604 WMITLV_GET_STRUCT_TLVLEN(
21605 wmi_vdev_set_connectivity_check_stats));
21606 wmi_set_connect_stats->pkt_type_bitmap =
21607 req_buf->pkt_type_bitmap;
21608 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
21609 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
21610 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
21611
21612 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
21613 wmi_set_connect_stats->pkt_type_bitmap,
21614 wmi_set_connect_stats->tcp_src_port,
21615 wmi_set_connect_stats->tcp_dst_port,
21616 wmi_set_connect_stats->icmp_ipv4);
21617 }
21618
Anurag Chouhan97f00422017-09-11 14:56:30 +053021619 /* Send per roam config parameters */
21620 status = wmi_unified_cmd_send(wmi_handle, buf,
21621 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21622 if (QDF_IS_STATUS_ERROR(status)) {
21623 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21624 status);
21625 goto error;
21626 }
21627
21628 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
21629 req_buf->flag, req_buf->vdev_id);
21630 return QDF_STATUS_SUCCESS;
21631error:
21632 wmi_buf_free(buf);
21633
21634 return status;
21635}
21636
21637/**
21638 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21639 * @wmi_handle: wmi handler
21640 * @req_buf: get arp stats request buffer
21641 *
21642 * Return: 0 for success and non zero for failure
21643 */
21644static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21645 struct get_arp_stats *req_buf)
21646{
21647 wmi_buf_t buf = NULL;
21648 QDF_STATUS status;
21649 int len;
21650 uint8_t *buf_ptr;
21651 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21652
21653 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21654 buf = wmi_buf_alloc(wmi_handle, len);
21655 if (!buf) {
21656 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21657 return QDF_STATUS_E_NOMEM;
21658 }
21659
21660 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21661 get_arp_stats =
21662 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21663 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21664 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21665 WMITLV_GET_STRUCT_TLVLEN
21666 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21667
21668 /* fill in arp stats req cmd values */
21669 get_arp_stats->vdev_id = req_buf->vdev_id;
21670
21671 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21672 /* Send per roam config parameters */
21673 status = wmi_unified_cmd_send(wmi_handle, buf,
21674 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21675 if (QDF_IS_STATUS_ERROR(status)) {
21676 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21677 status);
21678 goto error;
21679 }
21680
21681 return QDF_STATUS_SUCCESS;
21682error:
21683 wmi_buf_free(buf);
21684
21685 return status;
21686}
21687
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021688/**
21689 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21690 * @wmi_handle: wmi handler
21691 * @pmk_info: pointer to PMK cache entry
21692 * @vdev_id: vdev id
21693 *
21694 * Return: 0 for success and non zero for failure
21695 */
21696static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21697 struct wmi_unified_pmk_cache *pmk_info)
21698{
21699 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21700 wmi_buf_t buf;
21701 QDF_STATUS status;
21702 uint8_t *buf_ptr;
21703 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021704 uint32_t len = sizeof(*cmd);
21705
21706 if (pmk_info->pmk_len)
21707 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021708
21709 buf = wmi_buf_alloc(wmi_handle, len);
21710 if (!buf) {
21711 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21712 __func__);
21713 return QDF_STATUS_E_NOMEM;
21714 }
21715
21716 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21717 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21718
21719 WMITLV_SET_HDR(&cmd->tlv_header,
21720 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21721 WMITLV_GET_STRUCT_TLVLEN(
21722 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21723
21724 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021725
21726 /* If pmk_info->pmk_len is 0, this is a flush request */
21727 if (!pmk_info->pmk_len) {
21728 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21729 cmd->num_cache = 0;
21730 goto send_cmd;
21731 }
21732
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021733 cmd->num_cache = 1;
21734 buf_ptr += sizeof(*cmd);
21735
21736 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21737 sizeof(*pmksa));
21738 buf_ptr += WMI_TLV_HDR_SIZE;
21739
21740 pmksa = (wmi_pmk_cache *)buf_ptr;
21741 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21742 WMITLV_GET_STRUCT_TLVLEN
21743 (wmi_pmk_cache));
21744 pmksa->pmk_len = pmk_info->pmk_len;
21745 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21746 pmksa->pmkid_len = pmk_info->pmkid_len;
21747 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21748 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21749 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21750 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21751 pmksa->ssid.ssid_len);
21752 pmksa->cache_id = pmk_info->cache_id;
21753 pmksa->cat_flag = pmk_info->cat_flag;
21754 pmksa->action_flag = pmk_info->action_flag;
21755
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021756send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021757 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21758 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21759 if (status != QDF_STATUS_SUCCESS) {
21760 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21761 __func__, status);
21762 wmi_buf_free(buf);
21763 }
21764
21765 return status;
21766}
21767
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021768/**
21769 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21770 * @wmi_handle: wmi handle
21771 * @param: reserved param
21772 *
21773 * Return: 0 for success or error code
21774 */
21775static QDF_STATUS
21776send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21777 uint32_t param)
21778{
21779 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21780 wmi_buf_t buf;
21781 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21782
21783 buf = wmi_buf_alloc(wmi_handle, len);
21784 if (!buf) {
21785 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21786 return QDF_STATUS_E_FAILURE;
21787 }
21788 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21789 WMITLV_SET_HDR(&cmd->tlv_header,
21790 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21791 WMITLV_GET_STRUCT_TLVLEN
21792 (wmi_pdev_check_cal_version_cmd_fixed_param));
21793 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21794 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21795 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21796 wmi_buf_free(buf);
21797 return QDF_STATUS_E_FAILURE;
21798 }
21799
21800 return QDF_STATUS_SUCCESS;
21801}
21802
21803/**
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053021804 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
21805 * host to target defines.
21806 * @param pdev_id: host pdev_id to be converted.
21807 * Return: target pdev_id after conversion.
21808 */
21809static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
21810{
21811 switch (pdev_id) {
21812 case WMI_HOST_PDEV_ID_SOC:
21813 return WMI_PDEV_ID_SOC;
21814 case WMI_HOST_PDEV_ID_0:
21815 return WMI_PDEV_ID_1ST;
21816 case WMI_HOST_PDEV_ID_1:
21817 return WMI_PDEV_ID_2ND;
21818 case WMI_HOST_PDEV_ID_2:
21819 return WMI_PDEV_ID_3RD;
21820 }
21821
21822 QDF_ASSERT(0);
21823
21824 return WMI_PDEV_ID_SOC;
21825}
21826
21827/**
21828 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
21829 * target to host defines.
21830 * @param pdev_id: target pdev_id to be converted.
21831 * Return: host pdev_id after conversion.
21832 */
21833static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
21834{
21835 switch (pdev_id) {
21836 case WMI_PDEV_ID_SOC:
21837 return WMI_HOST_PDEV_ID_SOC;
21838 case WMI_PDEV_ID_1ST:
21839 return WMI_HOST_PDEV_ID_0;
21840 case WMI_PDEV_ID_2ND:
21841 return WMI_HOST_PDEV_ID_1;
21842 case WMI_PDEV_ID_3RD:
21843 return WMI_HOST_PDEV_ID_2;
21844 }
21845
21846 QDF_ASSERT(0);
21847
21848 return WMI_HOST_PDEV_ID_SOC;
21849}
21850
21851/**
21852 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
21853 *
21854 * Return None.
21855 */
21856static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
21857{
21858 wmi_handle->ops->convert_pdev_id_host_to_target =
21859 convert_host_pdev_id_to_target_pdev_id;
21860 wmi_handle->ops->convert_pdev_id_target_to_host =
21861 convert_target_pdev_id_to_host_pdev_id;
21862}
21863
21864/**
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021865 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21866 * @wmi_handle: wmi handle
21867 * @param evt_buf: pointer to event buffer
21868 * @param param: Pointer to hold peer caldata version data
21869 *
21870 * Return: 0 for success or error code
21871 */
21872static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21873 wmi_unified_t wmi_handle,
21874 void *evt_buf,
21875 wmi_host_pdev_check_cal_version_event *param)
21876{
21877 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21878 wmi_pdev_check_cal_version_event_fixed_param *event;
21879
21880 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21881 if (!param_tlvs) {
21882 WMI_LOGE("invalid cal version event buf");
21883 return QDF_STATUS_E_FAILURE;
21884 }
21885 event = param_tlvs->fixed_param;
21886 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21887 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21888 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21889 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21890
21891 param->software_cal_version = event->software_cal_version;
21892 param->board_cal_version = event->board_cal_version;
21893 param->cal_ok = event->cal_status;
21894
21895 return QDF_STATUS_SUCCESS;
21896}
21897
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021898/*
21899 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21900 * @wmi_handle: wmi handle
21901 * @params: pointer to wmi_btm_config
21902 *
21903 * Return: QDF_STATUS
21904 */
21905static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21906 struct wmi_btm_config *params)
21907{
21908
21909 wmi_btm_config_fixed_param *cmd;
21910 wmi_buf_t buf;
21911 uint32_t len;
21912
21913 len = sizeof(*cmd);
21914 buf = wmi_buf_alloc(wmi_handle, len);
21915 if (!buf) {
21916 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21917 return QDF_STATUS_E_NOMEM;
21918 }
21919
21920 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21921 WMITLV_SET_HDR(&cmd->tlv_header,
21922 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21923 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21924 cmd->vdev_id = params->vdev_id;
21925 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021926 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21927 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21928 cmd->stick_time_seconds = params->btm_sticky_time;
21929
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021930 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21931 WMI_ROAM_BTM_CONFIG_CMDID)) {
21932 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21933 __func__);
21934 wmi_buf_free(buf);
21935 return QDF_STATUS_E_FAILURE;
21936 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021937
21938 return QDF_STATUS_SUCCESS;
21939}
21940
21941/**
21942 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21943 * configurations to firmware.
21944 * @wmi_handle: wmi handle
21945 * @obss_cfg_param: obss detection configurations
21946 *
21947 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21948 *
21949 * Return: QDF_STATUS
21950 */
21951static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21952 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21953{
21954 wmi_buf_t buf;
21955 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21956 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21957
21958 buf = wmi_buf_alloc(wmi_handle, len);
21959 if (!buf) {
21960 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21961 return QDF_STATUS_E_NOMEM;
21962 }
21963
21964 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21965 WMITLV_SET_HDR(&cmd->tlv_header,
21966 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21967 WMITLV_GET_STRUCT_TLVLEN
21968 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21969
21970 cmd->vdev_id = obss_cfg_param->vdev_id;
21971 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21972 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21973 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21974 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21975 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21976 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21977 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21978 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021979
21980 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21981 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21982 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21983 wmi_buf_free(buf);
21984 return QDF_STATUS_E_FAILURE;
21985 }
21986
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021987 return QDF_STATUS_SUCCESS;
21988}
21989
Arif Hussain33d98502018-01-12 13:15:04 -080021990/**
21991 * extract_obss_detection_info_tlv() - Extract obss detection info
21992 * received from firmware.
21993 * @evt_buf: pointer to event buffer
21994 * @obss_detection: Pointer to hold obss detection info
21995 *
21996 * Return: QDF_STATUS
21997 */
21998static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21999 struct wmi_obss_detect_info
22000 *obss_detection)
22001{
22002 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
22003 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
22004
22005 if (!obss_detection) {
22006 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
22007 return QDF_STATUS_E_INVAL;
22008 }
22009
22010 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
22011 if (!param_buf) {
22012 WMI_LOGE("%s: Invalid evt_buf", __func__);
22013 return QDF_STATUS_E_INVAL;
22014 }
22015
22016 fix_param = param_buf->fixed_param;
22017 obss_detection->vdev_id = fix_param->vdev_id;
22018 obss_detection->matched_detection_masks =
22019 fix_param->matched_detection_masks;
22020 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
22021 &obss_detection->matched_bssid_addr[0]);
22022 switch (fix_param->reason) {
22023 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
22024 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
22025 break;
22026 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
22027 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
22028 break;
22029 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
22030 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
22031 break;
22032 default:
22033 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
22034 return QDF_STATUS_E_INVAL;
22035 }
22036
22037 return QDF_STATUS_SUCCESS;
22038}
22039
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022040/**
22041 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
22042 * @wmi_handle: wmi handler
22043 * @params: pointer to 11k offload params
22044 *
22045 * Return: 0 for success and non zero for failure
22046 */
22047static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
22048 struct wmi_11k_offload_params *params)
22049{
22050 wmi_11k_offload_report_fixed_param *cmd;
22051 wmi_buf_t buf;
22052 QDF_STATUS status;
22053 uint8_t *buf_ptr;
22054 wmi_neighbor_report_11k_offload_tlv_param
22055 *neighbor_report_offload_params;
22056 wmi_neighbor_report_offload *neighbor_report_offload;
22057
22058 uint32_t len = sizeof(*cmd);
22059
22060 if (params->offload_11k_bitmask &
22061 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
22062 len += WMI_TLV_HDR_SIZE +
22063 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
22064
22065 buf = wmi_buf_alloc(wmi_handle, len);
22066 if (!buf) {
22067 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
22068 __func__);
22069 return QDF_STATUS_E_NOMEM;
22070 }
22071
22072 buf_ptr = (uint8_t *) wmi_buf_data(buf);
22073 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
22074
22075 WMITLV_SET_HDR(&cmd->tlv_header,
22076 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
22077 WMITLV_GET_STRUCT_TLVLEN(
22078 wmi_11k_offload_report_fixed_param));
22079
22080 cmd->vdev_id = params->vdev_id;
22081 cmd->offload_11k = params->offload_11k_bitmask;
22082
22083 if (params->offload_11k_bitmask &
22084 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
22085 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
22086
22087 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
22088 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
22089 buf_ptr += WMI_TLV_HDR_SIZE;
22090
22091 neighbor_report_offload_params =
22092 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
22093 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
22094 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
22095 WMITLV_GET_STRUCT_TLVLEN(
22096 wmi_neighbor_report_11k_offload_tlv_param));
22097
22098 neighbor_report_offload = &neighbor_report_offload_params->
22099 neighbor_rep_ofld_params;
22100
22101 neighbor_report_offload->time_offset =
22102 params->neighbor_report_params.time_offset;
22103 neighbor_report_offload->low_rssi_offset =
22104 params->neighbor_report_params.low_rssi_offset;
22105 neighbor_report_offload->bmiss_count_trigger =
22106 params->neighbor_report_params.bmiss_count_trigger;
22107 neighbor_report_offload->per_threshold_offset =
22108 params->neighbor_report_params.per_threshold_offset;
22109 neighbor_report_offload->neighbor_report_cache_timeout =
22110 params->neighbor_report_params.
22111 neighbor_report_cache_timeout;
22112 neighbor_report_offload->max_neighbor_report_req_cap =
22113 params->neighbor_report_params.
22114 max_neighbor_report_req_cap;
22115 neighbor_report_offload->ssid.ssid_len =
22116 params->neighbor_report_params.ssid.length;
22117 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
22118 &params->neighbor_report_params.ssid.mac_ssid,
22119 neighbor_report_offload->ssid.ssid_len);
22120 }
22121
22122 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22123 WMI_11K_OFFLOAD_REPORT_CMDID);
22124 if (status != QDF_STATUS_SUCCESS) {
22125 WMI_LOGE("%s: failed to send 11k offload command %d",
22126 __func__, status);
22127 wmi_buf_free(buf);
22128 }
22129
22130 return status;
22131}
22132
22133/**
22134 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
22135 * command
22136 * @wmi_handle: wmi handler
22137 * @params: pointer to neighbor report invoke params
22138 *
22139 * Return: 0 for success and non zero for failure
22140 */
22141static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
22142 struct wmi_invoke_neighbor_report_params *params)
22143{
22144 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
22145 wmi_buf_t buf;
22146 QDF_STATUS status;
22147 uint8_t *buf_ptr;
22148 uint32_t len = sizeof(*cmd);
22149
22150 buf = wmi_buf_alloc(wmi_handle, len);
22151 if (!buf) {
22152 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
22153 __func__);
22154 return QDF_STATUS_E_NOMEM;
22155 }
22156
22157 buf_ptr = (uint8_t *) wmi_buf_data(buf);
22158 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
22159
22160 WMITLV_SET_HDR(&cmd->tlv_header,
22161 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
22162 WMITLV_GET_STRUCT_TLVLEN(
22163 wmi_11k_offload_invoke_neighbor_report_fixed_param));
22164
22165 cmd->vdev_id = params->vdev_id;
22166 cmd->flags = params->send_resp_to_host;
22167
22168 cmd->ssid.ssid_len = params->ssid.length;
22169 qdf_mem_copy(cmd->ssid.ssid,
22170 &params->ssid.mac_ssid,
22171 cmd->ssid.ssid_len);
22172
22173 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22174 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
22175 if (status != QDF_STATUS_SUCCESS) {
22176 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
22177 __func__, status);
22178 wmi_buf_free(buf);
22179 }
22180
22181 return status;
22182}
22183
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022184#ifdef WLAN_SUPPORT_GREEN_AP
22185static QDF_STATUS extract_green_ap_egap_status_info_tlv(
22186 uint8_t *evt_buf,
22187 struct wlan_green_ap_egap_status_info *egap_status_info_params)
22188{
22189 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
22190 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
22191 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
22192
22193 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
22194 if (!param_buf) {
22195 WMI_LOGE("Invalid EGAP Info status event buffer");
22196 return QDF_STATUS_E_INVAL;
22197 }
22198
22199 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
22200 param_buf->fixed_param;
22201 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
22202 param_buf->chainmask_list;
22203
22204 egap_status_info_params->status = egap_info_event->status;
22205 egap_status_info_params->mac_id = chainmask_event->mac_id;
22206 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
22207 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
22208
22209 return QDF_STATUS_SUCCESS;
22210}
22211#endif
22212
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022213/*
22214 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
22215 * updating bss color change within firmware when AP announces bss color change.
22216 * @wmi_handle: wmi handle
22217 * @vdev_id: vdev ID
22218 * @enable: enable bss color change within firmware
22219 *
22220 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
22221 *
22222 * Return: QDF_STATUS
22223 */
22224static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
22225 uint32_t vdev_id,
22226 bool enable)
22227{
22228 wmi_buf_t buf;
22229 wmi_bss_color_change_enable_fixed_param *cmd;
22230 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
22231
22232 buf = wmi_buf_alloc(wmi_handle, len);
22233 if (!buf) {
22234 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22235 return QDF_STATUS_E_NOMEM;
22236 }
22237
22238 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
22239 WMITLV_SET_HDR(&cmd->tlv_header,
22240 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
22241 WMITLV_GET_STRUCT_TLVLEN
22242 (wmi_bss_color_change_enable_fixed_param));
22243 cmd->vdev_id = vdev_id;
22244 cmd->enable = enable;
22245 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22246 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
22247 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
22248 wmi_buf_free(buf);
22249 return QDF_STATUS_E_FAILURE;
22250 }
22251
22252 return QDF_STATUS_SUCCESS;
22253}
22254
22255/**
22256 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
22257 * configurations to firmware.
22258 * @wmi_handle: wmi handle
22259 * @cfg_param: obss detection configurations
22260 *
22261 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
22262 *
22263 * Return: QDF_STATUS
22264 */
22265static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
22266 wmi_unified_t wmi_handle,
22267 struct wmi_obss_color_collision_cfg_param *cfg_param)
22268{
22269 wmi_buf_t buf;
22270 wmi_obss_color_collision_det_config_fixed_param *cmd;
22271 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
22272
22273 buf = wmi_buf_alloc(wmi_handle, len);
22274 if (!buf) {
22275 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22276 return QDF_STATUS_E_NOMEM;
22277 }
22278
22279 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
22280 buf);
22281 WMITLV_SET_HDR(&cmd->tlv_header,
22282 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
22283 WMITLV_GET_STRUCT_TLVLEN
22284 (wmi_obss_color_collision_det_config_fixed_param));
22285 cmd->vdev_id = cfg_param->vdev_id;
22286 cmd->flags = cfg_param->flags;
22287 cmd->current_bss_color = cfg_param->current_bss_color;
22288 cmd->detection_period_ms = cfg_param->detection_period_ms;
22289 cmd->scan_period_ms = cfg_param->scan_period_ms;
22290 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
22291
22292 switch (cfg_param->evt_type) {
22293 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
22294 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
22295 break;
22296 case OBSS_COLOR_COLLISION_DETECTION:
22297 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
22298 break;
22299 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22300 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22301 break;
22302 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
22303 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
22304 break;
22305 default:
22306 WMI_LOGE("%s: invalid event type: %d",
22307 __func__, cfg_param->evt_type);
22308 wmi_buf_free(buf);
22309 return QDF_STATUS_E_FAILURE;
22310 }
22311
22312 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22313 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
22314 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
22315 __func__, cfg_param->vdev_id);
22316 wmi_buf_free(buf);
22317 return QDF_STATUS_E_FAILURE;
22318 }
22319
22320 return QDF_STATUS_SUCCESS;
22321}
22322
22323/**
22324 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
22325 * received from firmware.
22326 * @evt_buf: pointer to event buffer
22327 * @info: Pointer to hold bss collision info
22328 *
22329 * Return: QDF_STATUS
22330 */
22331static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
22332 struct wmi_obss_color_collision_info *info)
22333{
22334 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
22335 wmi_obss_color_collision_evt_fixed_param *fix_param;
22336
22337 if (!info) {
22338 WMI_LOGE("%s: Invalid obss color buffer", __func__);
22339 return QDF_STATUS_E_INVAL;
22340 }
22341
22342 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
22343 evt_buf;
22344 if (!param_buf) {
22345 WMI_LOGE("%s: Invalid evt_buf", __func__);
22346 return QDF_STATUS_E_INVAL;
22347 }
22348
22349 fix_param = param_buf->fixed_param;
22350 info->vdev_id = fix_param->vdev_id;
22351 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
22352 info->obss_color_bitmap_bit32to63 =
22353 fix_param->bss_color_bitmap_bit32to63;
22354
22355 switch (fix_param->evt_type) {
22356 case WMI_BSS_COLOR_COLLISION_DISABLE:
22357 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
22358 break;
22359 case WMI_BSS_COLOR_COLLISION_DETECTION:
22360 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
22361 break;
22362 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22363 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22364 break;
22365 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
22366 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
22367 break;
22368 default:
22369 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
22370 __func__, fix_param->evt_type, fix_param->vdev_id);
22371 return QDF_STATUS_E_FAILURE;
22372 }
22373
22374 return QDF_STATUS_SUCCESS;
22375}
22376
Arif Hussaine0eb7302018-03-01 14:40:59 -080022377/*
22378 * extract_comb_phyerr_tlv() - extract comb phy error from event
22379 * @wmi_handle: wmi handle
22380 * @evt_buf: pointer to event buffer
22381 * @datalen: data length of event buffer
22382 * @buf_offset: Pointer to hold value of current event buffer offset
22383 * post extraction
22384 * @phyerr: Pointer to hold phyerr
22385 *
22386 * Return: QDF_STATUS
22387 */
22388static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
22389 void *evt_buf,
22390 uint16_t datalen,
22391 uint16_t *buf_offset,
22392 wmi_host_phyerr_t *phyerr)
22393{
22394 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
22395 wmi_comb_phyerr_rx_hdr *pe_hdr;
22396
22397 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
22398 if (!param_tlvs) {
22399 WMI_LOGD("%s: Received null data from FW", __func__);
22400 return QDF_STATUS_E_FAILURE;
22401 }
22402
22403 pe_hdr = param_tlvs->hdr;
22404 if (!pe_hdr) {
22405 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
22406 return QDF_STATUS_E_FAILURE;
22407 }
22408
22409 /* Ensure it's at least the size of the header */
22410 if (datalen < sizeof(*pe_hdr)) {
22411 WMI_LOGD("%s: Expected minimum size %zu, received %d",
22412 __func__, sizeof(*pe_hdr), datalen);
22413 return QDF_STATUS_E_FAILURE;
22414 }
22415
22416 phyerr->pdev_id = wmi_handle->ops->
22417 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
22418 phyerr->tsf64 = pe_hdr->tsf_l32;
22419 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
22420 phyerr->bufp = param_tlvs->bufp;
22421 phyerr->buf_len = pe_hdr->buf_len;
22422 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
22423 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
22424 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
22425
22426 return QDF_STATUS_SUCCESS;
22427}
22428
22429/**
22430 * extract_single_phyerr_tlv() - extract single phy error from event
22431 * @wmi_handle: wmi handle
22432 * @evt_buf: pointer to event buffer
22433 * @datalen: data length of event buffer
22434 * @buf_offset: Pointer to hold value of current event buffer offset
22435 * post extraction
22436 * @phyerr: Pointer to hold phyerr
22437 *
22438 * Return: QDF_STATUS
22439 */
22440static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
22441 void *evt_buf,
22442 uint16_t datalen,
22443 uint16_t *buf_offset,
22444 wmi_host_phyerr_t *phyerr)
22445{
22446 wmi_single_phyerr_rx_event *ev;
22447 uint16_t n = *buf_offset;
22448 uint8_t *data = (uint8_t *)evt_buf;
22449
22450 if (n < datalen) {
22451 if ((datalen - n) < sizeof(ev->hdr)) {
22452 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
22453 __func__, datalen, n, sizeof(ev->hdr));
22454 return QDF_STATUS_E_FAILURE;
22455 }
22456
22457 /*
22458 * Obtain a pointer to the beginning of the current event.
22459 * data[0] is the beginning of the WMI payload.
22460 */
22461 ev = (wmi_single_phyerr_rx_event *)&data[n];
22462
22463 /*
22464 * Sanity check the buffer length of the event against
22465 * what we currently have.
22466 *
22467 * Since buf_len is 32 bits, we check if it overflows
22468 * a large 32 bit value. It's not 0x7fffffff because
22469 * we increase n by (buf_len + sizeof(hdr)), which would
22470 * in itself cause n to overflow.
22471 *
22472 * If "int" is 64 bits then this becomes a moot point.
22473 */
22474 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
22475 WMI_LOGD("%s: buf_len is garbage 0x%x",
22476 __func__, ev->hdr.buf_len);
22477 return QDF_STATUS_E_FAILURE;
22478 }
22479
22480 if ((n + ev->hdr.buf_len) > datalen) {
22481 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
22482 __func__, n, ev->hdr.buf_len, datalen);
22483 return QDF_STATUS_E_FAILURE;
22484 }
22485
22486 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
22487 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
22488 phyerr->bufp = &ev->bufp[0];
22489 phyerr->buf_len = ev->hdr.buf_len;
22490 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
22491
22492 /*
22493 * Advance the buffer pointer to the next PHY error.
22494 * buflen is the length of this payload, so we need to
22495 * advance past the current header _AND_ the payload.
22496 */
22497 n += sizeof(*ev) + ev->hdr.buf_len;
22498 }
22499 *buf_offset = n;
22500
22501 return QDF_STATUS_SUCCESS;
22502}
22503
Govind Singh5eb51532016-03-09 11:34:12 +053022504struct wmi_ops tlv_ops = {
22505 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
22506 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
22507 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053022508 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
22509 .send_hidden_ssid_vdev_restart_cmd =
22510 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022511 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
22512 .send_peer_param_cmd = send_peer_param_cmd_tlv,
22513 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022514 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022515 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022516 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070022517 .send_peer_rx_reorder_queue_setup_cmd =
22518 send_peer_rx_reorder_queue_setup_cmd_tlv,
22519 .send_peer_rx_reorder_queue_remove_cmd =
22520 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053022521 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
22522 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
22523 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022524 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
22525 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022526 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022527 .send_suspend_cmd = send_suspend_cmd_tlv,
22528 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080022529#ifdef FEATURE_WLAN_D0WOW
22530 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
22531 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
22532#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022533 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
22534 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
22535 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
22536 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
22537 .send_dbglog_cmd = send_dbglog_cmd_tlv,
22538 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
22539 .send_stats_request_cmd = send_stats_request_cmd_tlv,
22540 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053022541 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070022542 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022543 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022544 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022545 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
22546 .send_scan_start_cmd = send_scan_start_cmd_tlv,
22547 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
22548 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022549 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022550 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022551 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
22552 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022553 .send_set_sta_uapsd_auto_trig_cmd =
22554 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022555 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
22556 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
22557 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022558#ifdef CONVERGED_P2P_ENABLE
22559 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
22560 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
22561#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053022562 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
22563 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022564#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053022565 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
22566 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
22567 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
22568 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
22569 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
22570 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
22571 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022572 .send_ocb_start_timing_advert_cmd =
22573 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022574 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
22575 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
22576 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
22577 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
22578#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053022579 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
22580 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
22581 .send_set_mcc_channel_time_latency_cmd =
22582 send_set_mcc_channel_time_latency_cmd_tlv,
22583 .send_set_mcc_channel_time_quota_cmd =
22584 send_set_mcc_channel_time_quota_cmd_tlv,
22585 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
22586 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053022587 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022588 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
22589 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
22590 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022591 .send_probe_rsp_tmpl_send_cmd =
22592 send_probe_rsp_tmpl_send_cmd_tlv,
22593 .send_p2p_go_set_beacon_ie_cmd =
22594 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053022595 .send_setup_install_key_cmd =
22596 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022597 .send_set_gateway_params_cmd =
22598 send_set_gateway_params_cmd_tlv,
22599 .send_set_rssi_monitoring_cmd =
22600 send_set_rssi_monitoring_cmd_tlv,
22601 .send_scan_probe_setoui_cmd =
22602 send_scan_probe_setoui_cmd_tlv,
22603 .send_reset_passpoint_network_list_cmd =
22604 send_reset_passpoint_network_list_cmd_tlv,
22605 .send_set_passpoint_network_list_cmd =
22606 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022607 .send_roam_scan_offload_rssi_thresh_cmd =
22608 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070022609 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022610 .send_roam_scan_filter_cmd =
22611 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022612 .send_set_epno_network_list_cmd =
22613 send_set_epno_network_list_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022614#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053022615 .send_ipa_offload_control_cmd =
22616 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022617#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053022618 .send_extscan_get_capabilities_cmd =
22619 send_extscan_get_capabilities_cmd_tlv,
22620 .send_extscan_get_cached_results_cmd =
22621 send_extscan_get_cached_results_cmd_tlv,
22622 .send_extscan_stop_change_monitor_cmd =
22623 send_extscan_stop_change_monitor_cmd_tlv,
22624 .send_extscan_start_change_monitor_cmd =
22625 send_extscan_start_change_monitor_cmd_tlv,
22626 .send_extscan_stop_hotlist_monitor_cmd =
22627 send_extscan_stop_hotlist_monitor_cmd_tlv,
22628 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
22629 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
22630 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
22631 .send_plm_start_cmd = send_plm_start_cmd_tlv,
22632 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
22633 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070022634 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022635 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
22636 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
22637 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
22638 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053022639 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022640 .send_snr_request_cmd = send_snr_request_cmd_tlv,
22641 .send_snr_cmd = send_snr_cmd_tlv,
22642 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022643#ifdef WLAN_PMO_ENABLE
22644 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
22645 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
22646 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
22647 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053022648 .send_multiple_add_clear_mcbc_filter_cmd =
22649 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070022650 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022651 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
22652 .send_process_gtk_offload_getinfo_cmd =
22653 send_process_gtk_offload_getinfo_cmd_tlv,
22654 .send_enable_enhance_multicast_offload_cmd =
22655 send_enable_enhance_multicast_offload_tlv,
22656 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
22657#ifdef FEATURE_WLAN_RA_FILTERING
22658 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
22659#endif
22660 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022661 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
22662 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022663 .send_lphb_config_tcp_pkt_filter_cmd =
22664 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022665 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22666 .send_lphb_config_udp_pkt_filter_cmd =
22667 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022668 .send_enable_disable_packet_filter_cmd =
22669 send_enable_disable_packet_filter_cmd_tlv,
22670 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022671#endif /* End of WLAN_PMO_ENABLE */
22672#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022673 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22674 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022675 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022676 .send_roam_scan_offload_mode_cmd =
22677 send_roam_scan_offload_mode_cmd_tlv,
22678 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
22679 .send_roam_scan_offload_ap_profile_cmd =
22680 send_roam_scan_offload_ap_profile_cmd_tlv,
22681#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022682#ifdef WLAN_SUPPORT_GREEN_AP
22683 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22684 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022685 .extract_green_ap_egap_status_info =
22686 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022687#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022688 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22689 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022690 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022691 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022692 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022693#ifdef WLAN_FEATURE_CIF_CFR
22694 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22695#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022696 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022697 .send_dfs_phyerr_filter_offload_en_cmd =
22698 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022699 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22700 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22701 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22702 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22703 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022704 .send_process_add_periodic_tx_ptrn_cmd =
22705 send_process_add_periodic_tx_ptrn_cmd_tlv,
22706 .send_process_del_periodic_tx_ptrn_cmd =
22707 send_process_del_periodic_tx_ptrn_cmd_tlv,
22708 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22709 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22710 .send_set_app_type2_params_in_fw_cmd =
22711 send_set_app_type2_params_in_fw_cmd_tlv,
22712 .send_set_auto_shutdown_timer_cmd =
22713 send_set_auto_shutdown_timer_cmd_tlv,
22714 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22715 .send_process_dhcpserver_offload_cmd =
22716 send_process_dhcpserver_offload_cmd_tlv,
22717 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22718 .send_process_ch_avoid_update_cmd =
22719 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022720 .send_pdev_set_regdomain_cmd =
22721 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022722 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22723 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22724 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22725 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022726 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022727 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022728 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022729 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022730 .send_set_base_macaddr_indicate_cmd =
22731 send_set_base_macaddr_indicate_cmd_tlv,
22732 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22733 .send_enable_specific_fw_logs_cmd =
22734 send_enable_specific_fw_logs_cmd_tlv,
22735 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022736 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022737 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022738#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022739 .send_pdev_set_dual_mac_config_cmd =
22740 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022741#endif
Govind Singha4836fd2016-03-07 16:45:38 +053022742 .send_app_type1_params_in_fw_cmd =
22743 send_app_type1_params_in_fw_cmd_tlv,
22744 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22745 .send_process_roam_synch_complete_cmd =
22746 send_process_roam_synch_complete_cmd_tlv,
22747 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22748 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22749 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022750 .send_roam_scan_offload_scan_period_cmd =
22751 send_roam_scan_offload_scan_period_cmd_tlv,
22752 .send_roam_scan_offload_chan_list_cmd =
22753 send_roam_scan_offload_chan_list_cmd_tlv,
22754 .send_roam_scan_offload_rssi_change_cmd =
22755 send_roam_scan_offload_rssi_change_cmd_tlv,
22756 .send_get_buf_extscan_hotlist_cmd =
22757 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080022758 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053022759 .send_adapt_dwelltime_params_cmd =
22760 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022761 .send_dbs_scan_sel_params_cmd =
22762 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022763 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022764 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22765 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22766 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22767 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22768 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22769 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022770 .send_vdev_set_custom_aggr_size_cmd =
22771 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022772 .send_vdev_set_qdepth_thresh_cmd =
22773 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022774 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22775 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22776 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022777 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22778 .send_smart_ant_set_training_info_cmd =
22779 send_smart_ant_set_training_info_cmd_tlv,
22780 .send_smart_ant_set_node_config_cmd =
22781 send_smart_ant_set_node_config_cmd_tlv,
22782 .send_set_atf_cmd = send_set_atf_cmd_tlv,
22783 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22784 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022785 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22786 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22787 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22788 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022789 .send_periodic_chan_stats_config_cmd =
22790 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022791 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22792 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22793 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022794 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22795 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22796 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22797 .send_vdev_spectral_configure_cmd =
22798 send_vdev_spectral_configure_cmd_tlv,
22799 .send_vdev_spectral_enable_cmd =
22800 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022801 .send_thermal_mitigation_param_cmd =
22802 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022803 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22804 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022805 .send_process_update_edca_param_cmd =
22806 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022807 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022808 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022809 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022810 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22811 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022812 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022813 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22814 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22815 .extract_host_mem_req = extract_host_mem_req_tlv,
22816 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022817 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022818 .is_service_enabled = is_service_enabled_tlv,
22819 .save_fw_version = save_fw_version_in_service_ready_tlv,
22820 .ready_extract_init_status = ready_extract_init_status_tlv,
22821 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022822 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022823 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022824 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22825 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022826 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022827 .extract_tbttoffset_update_params =
22828 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022829 .extract_ext_tbttoffset_update_params =
22830 extract_ext_tbttoffset_update_params_tlv,
22831 .extract_tbttoffset_num_vdevs =
22832 extract_tbttoffset_num_vdevs_tlv,
22833 .extract_ext_tbttoffset_num_vdevs =
22834 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022835 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22836 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22837 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22838 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022839#ifdef CONVERGED_TDLS_ENABLE
22840 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22841#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022842 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022843 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022844 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22845 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022846#ifdef CONVERGED_P2P_ENABLE
22847 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22848 .extract_p2p_lo_stop_ev_param =
22849 extract_p2p_lo_stop_ev_param_tlv,
22850#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022851 .extract_offchan_data_tx_compl_param =
22852 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022853 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22854 .extract_all_stats_count = extract_all_stats_counts_tlv,
22855 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022856 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022857 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22858 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070022859 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022860 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022861 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022862 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22863 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22864 .extract_chan_stats = extract_chan_stats_tlv,
22865 .extract_profile_ctx = extract_profile_ctx_tlv,
22866 .extract_profile_data = extract_profile_data_tlv,
22867 .extract_chan_info_event = extract_chan_info_event_tlv,
22868 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022869 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022870#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022871 .send_encrypt_decrypt_send_cmd =
22872 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022873 .extract_encrypt_decrypt_resp_event =
22874 extract_encrypt_decrypt_resp_event_tlv,
22875#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022876 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022877 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22878 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022879 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022880 .send_multiple_vdev_restart_req_cmd =
22881 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022882 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22883 .extract_hw_mode_cap_service_ready_ext =
22884 extract_hw_mode_cap_service_ready_ext_tlv,
22885 .extract_mac_phy_cap_service_ready_ext =
22886 extract_mac_phy_cap_service_ready_ext_tlv,
22887 .extract_reg_cap_service_ready_ext =
22888 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022889 .extract_dbr_ring_cap_service_ready_ext =
22890 extract_dbr_ring_cap_service_ready_ext_tlv,
22891 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22892 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022893 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022894 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022895 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022896 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22897 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22898 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022899 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022900 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022901 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022902 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022903 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022904 .extract_pdev_csa_switch_count_status =
22905 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022906 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022907 .extract_pdev_tpc_config_ev_param =
22908 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022909 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022910 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22911 .extract_peer_sta_ps_statechange_ev =
22912 extract_peer_sta_ps_statechange_ev_tlv,
22913 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022914 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080022915 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22916 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022917 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022918 extract_reg_chan_list_update_event_tlv,
22919 .extract_chainmask_tables =
22920 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022921 .extract_thermal_stats = extract_thermal_stats_tlv,
22922 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022923 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22924 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022925#ifdef DFS_COMPONENT_ENABLE
22926 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22927 .extract_dfs_radar_detection_event =
22928 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022929 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022930#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022931 .convert_pdev_id_host_to_target =
22932 convert_host_pdev_id_to_target_pdev_id_legacy,
22933 .convert_pdev_id_target_to_host =
22934 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022935
22936 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22937 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22938 .extract_reg_11d_new_country_event =
22939 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022940 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022941 .send_limit_off_chan_cmd =
22942 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022943 .extract_reg_ch_avoid_event =
22944 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022945 .send_pdev_caldata_version_check_cmd =
22946 send_pdev_caldata_version_check_cmd_tlv,
22947 .extract_pdev_caldata_version_check_ev_param =
22948 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022949 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22950 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022951 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22952#if defined(WLAN_FEATURE_FILS_SK)
22953 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22954#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022955 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022956#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22957 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22958 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22959 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22960 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22961 .extract_ndp_ind = extract_ndp_ind_tlv,
22962 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22963 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22964 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22965 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
22966#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022967 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022968 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022969 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022970#ifdef WLAN_SUPPORT_FILS
22971 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22972 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22973 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22974#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022975 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22976 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022977 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22978 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22979 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22980 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022981 .send_bss_color_change_enable_cmd =
22982 send_bss_color_change_enable_cmd_tlv,
22983 .send_obss_color_collision_cfg_cmd =
22984 send_obss_color_collision_cfg_cmd_tlv,
22985 .extract_obss_color_collision_info =
22986 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022987 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22988 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070022989#ifdef QCA_SUPPORT_CP_STATS
22990 .extract_cca_stats = extract_cca_stats_tlv,
22991#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022992};
22993
Govind Singhe7f2f342016-05-23 12:12:52 +053022994/**
22995 * populate_tlv_event_id() - populates wmi event ids
22996 *
22997 * @param event_ids: Pointer to hold event ids
22998 * Return: None
22999 */
23000static void populate_tlv_events_id(uint32_t *event_ids)
23001{
23002 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
23003 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
23004 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
23005 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
23006 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
23007 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
23008 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
23009 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
23010 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
23011 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
23012 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
23013 event_ids[wmi_service_ready_ext_event_id] =
23014 WMI_SERVICE_READY_EXT_EVENTID;
23015 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
23016 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
23017 event_ids[wmi_vdev_install_key_complete_event_id] =
23018 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
23019 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
23020 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
23021
23022 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
23023 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
23024 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
23025 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
23026 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
23027 event_ids[wmi_peer_estimated_linkspeed_event_id] =
23028 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
23029 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053023030 event_ids[wmi_peer_delete_response_event_id] =
23031 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023032 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
23033 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
23034 event_ids[wmi_tbttoffset_update_event_id] =
23035 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053023036 event_ids[wmi_ext_tbttoffset_update_event_id] =
23037 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023038 event_ids[wmi_offload_bcn_tx_status_event_id] =
23039 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
23040 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
23041 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
23042 event_ids[wmi_mgmt_tx_completion_event_id] =
23043 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080023044 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
23045 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023046 event_ids[wmi_tx_delba_complete_event_id] =
23047 WMI_TX_DELBA_COMPLETE_EVENTID;
23048 event_ids[wmi_tx_addba_complete_event_id] =
23049 WMI_TX_ADDBA_COMPLETE_EVENTID;
23050 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
23051
23052 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
23053
23054 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
23055 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
23056
23057 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053023058 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023059
23060 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
23061
23062 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080023063 event_ids[wmi_p2p_lo_stop_event_id] =
23064 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023065 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
23066 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080023067 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053023068 WMI_D0_WOW_DISABLE_ACK_EVENTID;
23069 event_ids[wmi_wow_initial_wakeup_event_id] =
23070 WMI_WOW_INITIAL_WAKEUP_EVENTID;
23071
23072 event_ids[wmi_rtt_meas_report_event_id] =
23073 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
23074 event_ids[wmi_tsf_meas_report_event_id] =
23075 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
23076 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
23077 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
23078 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
23079 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
23080 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023081 event_ids[wmi_diag_event_id_log_supported_event_id] =
23082 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
23083 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
23084 event_ids[wmi_nlo_scan_complete_event_id] =
23085 WMI_NLO_SCAN_COMPLETE_EVENTID;
23086 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
23087 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
23088
23089 event_ids[wmi_gtk_offload_status_event_id] =
23090 WMI_GTK_OFFLOAD_STATUS_EVENTID;
23091 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
23092 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
23093 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
23094
23095 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
23096
23097 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
23098
23099 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
23100 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
23101 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
23102 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
23103 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
23104 event_ids[wmi_wlan_profile_data_event_id] =
23105 WMI_WLAN_PROFILE_DATA_EVENTID;
23106 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
23107 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
23108 event_ids[wmi_vdev_get_keepalive_event_id] =
23109 WMI_VDEV_GET_KEEPALIVE_EVENTID;
23110 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
23111
23112 event_ids[wmi_diag_container_event_id] =
23113 WMI_DIAG_DATA_CONTAINER_EVENTID;
23114
23115 event_ids[wmi_host_auto_shutdown_event_id] =
23116 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
23117
23118 event_ids[wmi_update_whal_mib_stats_event_id] =
23119 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
23120
23121 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
23122 event_ids[wmi_update_vdev_rate_stats_event_id] =
23123 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
23124
23125 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070023126 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023127
23128 /** Set OCB Sched Response, deprecated */
23129 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
23130
23131 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
23132 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
23133 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
23134
23135 /* GPIO Event */
23136 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
23137 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
23138
23139 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
23140 event_ids[wmi_rfkill_state_change_event_id] =
23141 WMI_RFKILL_STATE_CHANGE_EVENTID;
23142
23143 /* TDLS Event */
23144 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
23145
23146 event_ids[wmi_batch_scan_enabled_event_id] =
23147 WMI_BATCH_SCAN_ENABLED_EVENTID;
23148 event_ids[wmi_batch_scan_result_event_id] =
23149 WMI_BATCH_SCAN_RESULT_EVENTID;
23150 /* OEM Event */
23151 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
23152 event_ids[wmi_oem_meas_report_event_id] =
23153 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
23154 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
23155
23156 /* NAN Event */
23157 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
23158
23159 /* LPI Event */
23160 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
23161 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
23162 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
23163
23164 /* ExtScan events */
23165 event_ids[wmi_extscan_start_stop_event_id] =
23166 WMI_EXTSCAN_START_STOP_EVENTID;
23167 event_ids[wmi_extscan_operation_event_id] =
23168 WMI_EXTSCAN_OPERATION_EVENTID;
23169 event_ids[wmi_extscan_table_usage_event_id] =
23170 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
23171 event_ids[wmi_extscan_cached_results_event_id] =
23172 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
23173 event_ids[wmi_extscan_wlan_change_results_event_id] =
23174 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
23175 event_ids[wmi_extscan_hotlist_match_event_id] =
23176 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
23177 event_ids[wmi_extscan_capabilities_event_id] =
23178 WMI_EXTSCAN_CAPABILITIES_EVENTID;
23179 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
23180 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
23181
23182 /* mDNS offload events */
23183 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
23184
23185 /* SAP Authentication offload events */
23186 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
23187 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
23188
23189 /** Out-of-context-of-bss (OCB) events */
23190 event_ids[wmi_ocb_set_config_resp_event_id] =
23191 WMI_OCB_SET_CONFIG_RESP_EVENTID;
23192 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
23193 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
23194 event_ids[wmi_dcc_get_stats_resp_event_id] =
23195 WMI_DCC_GET_STATS_RESP_EVENTID;
23196 event_ids[wmi_dcc_update_ndl_resp_event_id] =
23197 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
23198 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
23199 /* System-On-Chip events */
23200 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
23201 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
23202 event_ids[wmi_soc_hw_mode_transition_event_id] =
23203 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
23204 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
23205 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053023206 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053023207 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
23208 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053023209 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053023210 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
23211 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
23212 event_ids[wmi_peer_sta_ps_statechg_event_id] =
23213 WMI_PEER_STA_PS_STATECHG_EVENTID;
23214 event_ids[wmi_pdev_channel_hopping_event_id] =
23215 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053023216 event_ids[wmi_offchan_data_tx_completion_event] =
23217 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070023218 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
23219 event_ids[wmi_dfs_radar_detection_event_id] =
23220 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053023221 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070023222 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053023223 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053023224 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053023225 event_ids[wmi_service_available_event_id] =
23226 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053023227 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053023228 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053023229 /* NDP events */
23230 event_ids[wmi_ndp_initiator_rsp_event_id] =
23231 WMI_NDP_INITIATOR_RSP_EVENTID;
23232 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
23233 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
23234 event_ids[wmi_ndp_responder_rsp_event_id] =
23235 WMI_NDP_RESPONDER_RSP_EVENTID;
23236 event_ids[wmi_ndp_end_indication_event_id] =
23237 WMI_NDP_END_INDICATION_EVENTID;
23238 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
23239
23240 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
23241 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
23242 event_ids[wmi_pdev_chip_power_stats_event_id] =
23243 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
23244 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
23245 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
23246 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
23247 event_ids[wmi_bpf_capability_info_event_id] =
23248 WMI_BPF_CAPABILIY_INFO_EVENTID;
23249 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
23250 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
23251 event_ids[wmi_report_rx_aggr_failure_event_id] =
23252 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
23253 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
23254 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
23255 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
23256 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
23257 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
23258 event_ids[wmi_pdev_hw_mode_transition_event_id] =
23259 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
23260 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
23261 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
23262 event_ids[wmi_coex_bt_activity_event_id] =
23263 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
23264 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
23265 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
23266 event_ids[wmi_radio_tx_power_level_stats_event_id] =
23267 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
23268 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053023269 event_ids[wmi_dma_buf_release_event_id] =
23270 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080023271 event_ids[wmi_sap_obss_detection_report_event_id] =
23272 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053023273 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080023274 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080023275 event_ids[wmi_obss_color_collision_report_event_id] =
23276 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080023277 event_ids[wmi_pdev_div_rssi_antid_event_id] =
23278 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070023279 event_ids[wmi_twt_enable_complete_event_id] =
23280 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023281}
23282
Soumya Bhat488092d2017-03-22 14:41:01 +053023283/**
23284 * populate_tlv_service() - populates wmi services
23285 *
23286 * @param wmi_service: Pointer to hold wmi_service
23287 * Return: None
23288 */
23289static void populate_tlv_service(uint32_t *wmi_service)
23290{
23291 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023292 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023293 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
23294 wmi_service[wmi_service_roam_scan_offload] =
23295 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
23296 wmi_service[wmi_service_bcn_miss_offload] =
23297 WMI_SERVICE_BCN_MISS_OFFLOAD;
23298 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
23299 wmi_service[wmi_service_sta_advanced_pwrsave] =
23300 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
23301 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
23302 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
23303 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
23304 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
23305 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
23306 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
23307 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
23308 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
23309 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
23310 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
23311 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
23312 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
23313 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
23314 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
23315 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
23316 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
23317 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
23318 wmi_service[wmi_service_packet_power_save] =
23319 WMI_SERVICE_PACKET_POWER_SAVE;
23320 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
23321 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
23322 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
23323 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
23324 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
23325 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
23326 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
23327 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
23328 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
23329 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
23330 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
23331 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
23332 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
23333 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
23334 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
23335 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
23336 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
23337 wmi_service[wmi_service_mcc_bcn_interval_change] =
23338 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
23339 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
23340 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
23341 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
23342 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
23343 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
23344 wmi_service[wmi_service_lte_ant_share_support] =
23345 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
23346 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
23347 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
23348 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
23349 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
23350 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
23351 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
23352 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
23353 wmi_service[wmi_service_bcn_txrate_override] =
23354 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
23355 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
23356 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
23357 wmi_service[wmi_service_estimate_linkspeed] =
23358 WMI_SERVICE_ESTIMATE_LINKSPEED;
23359 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
23360 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
23361 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
23362 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
23363 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
23364 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
23365 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
23366 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
23367 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
23368 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
23369 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
23370 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
23371 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
23372 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
23373 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
23374 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
23375 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
23376 wmi_service[wmi_service_sap_auth_offload] =
23377 WMI_SERVICE_SAP_AUTH_OFFLOAD;
23378 wmi_service[wmi_service_dual_band_simultaneous_support] =
23379 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
23380 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
23381 wmi_service[wmi_service_ap_arpns_offload] =
23382 WMI_SERVICE_AP_ARPNS_OFFLOAD;
23383 wmi_service[wmi_service_per_band_chainmask_support] =
23384 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
23385 wmi_service[wmi_service_packet_filter_offload] =
23386 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
23387 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
23388 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
23389 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
23390 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
23391 wmi_service[wmi_service_multiple_vdev_restart] =
23392 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
23393
23394 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
23395 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
23396 wmi_service[wmi_service_smart_antenna_sw_support] =
23397 WMI_SERVICE_UNAVAILABLE;
23398 wmi_service[wmi_service_smart_antenna_hw_support] =
23399 WMI_SERVICE_UNAVAILABLE;
23400 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053023401 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023402 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053023403 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
23404 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
23405 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
23406 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
23407 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
23408 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
23409 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
23410 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053023411 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
23412 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
23413 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053023414 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023415 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
23416 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
23417 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
23418 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
23419 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
23420 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053023421 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
23422 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
23423 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
23424 wmi_service[wmi_service_unified_wow_capability] =
23425 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
23426 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
23427 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
23428 wmi_service[wmi_service_sync_delete_cmds] =
23429 WMI_SERVICE_SYNC_DELETE_CMDS;
23430 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
23431 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
23432 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
23433 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
23434 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
23435 wmi_service[wmi_service_deprecated_replace] =
23436 WMI_SERVICE_DEPRECATED_REPLACE;
23437 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
23438 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
23439 wmi_service[wmi_service_enhanced_mcast_filter] =
23440 WMI_SERVICE_ENHANCED_MCAST_FILTER;
23441 wmi_service[wmi_service_half_rate_quarter_rate_support] =
23442 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
23443 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
23444 wmi_service[wmi_service_p2p_listen_offload_support] =
23445 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
23446 wmi_service[wmi_service_mark_first_wakeup_packet] =
23447 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
23448 wmi_service[wmi_service_multiple_mcast_filter_set] =
23449 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
23450 wmi_service[wmi_service_host_managed_rx_reorder] =
23451 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
23452 wmi_service[wmi_service_flash_rdwr_support] =
23453 WMI_SERVICE_FLASH_RDWR_SUPPORT;
23454 wmi_service[wmi_service_wlan_stats_report] =
23455 WMI_SERVICE_WLAN_STATS_REPORT;
23456 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
23457 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
23458 wmi_service[wmi_service_dfs_phyerr_offload] =
23459 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
23460 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
23461 wmi_service[wmi_service_fw_mem_dump_support] =
23462 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
23463 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
23464 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
23465 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
23466 wmi_service[wmi_service_hw_data_filtering] =
23467 WMI_SERVICE_HW_DATA_FILTERING;
23468 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
23469 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053023470 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053023471 wmi_service[wmi_service_extended_nss_support] =
23472 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053023473 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053023474 wmi_service[wmi_service_bcn_offload_start_stop_support] =
23475 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053023476 wmi_service[wmi_service_offchan_data_tid_support] =
23477 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053023478 wmi_service[wmi_service_support_dma] =
23479 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023480 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
23481 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
23482 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053023483 wmi_service[wmi_service_11k_neighbour_report_support] =
23484 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080023485 wmi_service[wmi_service_ap_obss_detection_offload] =
23486 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
23487 wmi_service[wmi_service_bss_color_offload] =
23488 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053023489 wmi_service[wmi_service_gmac_offload_support] =
23490 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023491
Soumya Bhat488092d2017-03-22 14:41:01 +053023492}
23493
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023494#ifndef CONFIG_MCL
23495
Govind Singhe7f2f342016-05-23 12:12:52 +053023496/**
23497 * populate_pdev_param_tlv() - populates pdev params
23498 *
23499 * @param pdev_param: Pointer to hold pdev params
23500 * Return: None
23501 */
23502static void populate_pdev_param_tlv(uint32_t *pdev_param)
23503{
23504 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
23505 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
23506 pdev_param[wmi_pdev_param_txpower_limit2g] =
23507 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
23508 pdev_param[wmi_pdev_param_txpower_limit5g] =
23509 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
23510 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
23511 pdev_param[wmi_pdev_param_beacon_gen_mode] =
23512 WMI_PDEV_PARAM_BEACON_GEN_MODE;
23513 pdev_param[wmi_pdev_param_beacon_tx_mode] =
23514 WMI_PDEV_PARAM_BEACON_TX_MODE;
23515 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
23516 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
23517 pdev_param[wmi_pdev_param_protection_mode] =
23518 WMI_PDEV_PARAM_PROTECTION_MODE;
23519 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
23520 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
23521 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
23522 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
23523 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
23524 pdev_param[wmi_pdev_param_sta_kickout_th] =
23525 WMI_PDEV_PARAM_STA_KICKOUT_TH;
23526 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
23527 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
23528 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
23529 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
23530 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
23531 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
23532 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
23533 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
23534 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
23535 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
23536 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
23537 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
23538 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
23539 pdev_param[wmi_pdev_param_ltr_sleep_override] =
23540 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
23541 pdev_param[wmi_pdev_param_ltr_rx_override] =
23542 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
23543 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
23544 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
23545 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
23546 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
23547 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
23548 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
23549 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
23550 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
23551 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
23552 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
23553 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
23554 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
23555 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
23556 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
23557 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
23558 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
23559 pdev_param[wmi_pdev_param_peer_stats_update_period] =
23560 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
23561 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
23562 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
23563 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
23564 pdev_param[wmi_pdev_param_arp_ac_override] =
23565 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
23566 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
23567 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
23568 pdev_param[wmi_pdev_param_ani_poll_period] =
23569 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
23570 pdev_param[wmi_pdev_param_ani_listen_period] =
23571 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
23572 pdev_param[wmi_pdev_param_ani_ofdm_level] =
23573 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
23574 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
23575 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
23576 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
23577 pdev_param[wmi_pdev_param_idle_ps_config] =
23578 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
23579 pdev_param[wmi_pdev_param_power_gating_sleep] =
23580 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
23581 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
23582 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
23583 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
23584 pdev_param[wmi_pdev_param_hw_rfkill_config] =
23585 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
23586 pdev_param[wmi_pdev_param_low_power_rf_enable] =
23587 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
23588 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
23589 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
23590 pdev_param[wmi_pdev_param_power_collapse_enable] =
23591 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
23592 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
23593 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
23594 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
23595 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
23596 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
23597 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
23598 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
23599 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
23600 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
23601 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
23602 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
23603 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
23604 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
23605 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
23606 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
23607 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
23608 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
23609 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
23610 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
23611 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
23612 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
23613 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
23614 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
23615 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
23616 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
23617 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
23618 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
23619 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
23620 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
23621 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
23622 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
23623 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
23624 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
23625 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
23626 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
23627 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
23628 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
23629 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
23630 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23631 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23632 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23633 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23634 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23635 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023636 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23637 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23638 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023639 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23640 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023641 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023642 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023643 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23644 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23645 WMI_PDEV_PARAM_PROXY_STA_MODE;
23646 pdev_param[wmi_pdev_param_mu_group_policy] =
23647 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23648 pdev_param[wmi_pdev_param_noise_detection] =
23649 WMI_PDEV_PARAM_NOISE_DETECTION;
23650 pdev_param[wmi_pdev_param_noise_threshold] =
23651 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23652 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23653 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23654 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023655 pdev_param[wmi_pdev_param_atf_strict_sch] =
23656 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23657 pdev_param[wmi_pdev_param_atf_sched_duration] =
23658 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023659 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23660 pdev_param[wmi_pdev_param_sensitivity_level] =
23661 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23662 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23663 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23664 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23665 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023666 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23667 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23668 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23669 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023670 pdev_param[wmi_pdev_param_cca_threshold] =
23671 WMI_PDEV_PARAM_CCA_THRESHOLD;
23672 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23673 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023674 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023675 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23676 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23677 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23678 pdev_param[wmi_pdev_param_arp_srcaddr] =
23679 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23680 pdev_param[wmi_pdev_param_arp_dstaddr] =
23681 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23682 pdev_param[wmi_pdev_param_txpower_decr_db] =
23683 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023684 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23685 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023686 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23687 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023688 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023689 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023690 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23691 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023692 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23693 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023694 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23695 WMI_UNAVAILABLE_PARAM;
23696 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
23697 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023698 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23699 pdev_param[wmi_pdev_param_block_interbss] =
23700 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023701 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023702 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23703 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23704 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023705 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023706 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023707 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23708 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023709 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023710 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23711 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023712 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23713 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23714 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23715 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
23716 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
23717 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23718 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23719 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23720 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23721 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23722 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23723 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23724 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23725 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23726 pdev_param[wmi_pdev_param_fast_channel_reset] =
23727 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23728 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023729 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023730 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023731}
23732
23733/**
23734 * populate_vdev_param_tlv() - populates vdev params
23735 *
23736 * @param vdev_param: Pointer to hold vdev params
23737 * Return: None
23738 */
23739static void populate_vdev_param_tlv(uint32_t *vdev_param)
23740{
23741 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23742 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23743 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23744 vdev_param[wmi_vdev_param_beacon_interval] =
23745 WMI_VDEV_PARAM_BEACON_INTERVAL;
23746 vdev_param[wmi_vdev_param_listen_interval] =
23747 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23748 vdev_param[wmi_vdev_param_multicast_rate] =
23749 WMI_VDEV_PARAM_MULTICAST_RATE;
23750 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23751 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23752 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23753 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23754 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23755 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23756 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23757 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23758 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23759 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23760 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23761 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23762 vdev_param[wmi_vdev_param_bmiss_count_max] =
23763 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23764 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23765 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23766 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23767 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23768 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23769 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23770 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23771 vdev_param[wmi_vdev_param_disable_htprotection] =
23772 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23773 vdev_param[wmi_vdev_param_sta_quickkickout] =
23774 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23775 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23776 vdev_param[wmi_vdev_param_protection_mode] =
23777 WMI_VDEV_PARAM_PROTECTION_MODE;
23778 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23779 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23780 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23781 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23782 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23783 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23784 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23785 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23786 vdev_param[wmi_vdev_param_bcast_data_rate] =
23787 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23788 vdev_param[wmi_vdev_param_mcast_data_rate] =
23789 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23790 vdev_param[wmi_vdev_param_mcast_indicate] =
23791 WMI_VDEV_PARAM_MCAST_INDICATE;
23792 vdev_param[wmi_vdev_param_dhcp_indicate] =
23793 WMI_VDEV_PARAM_DHCP_INDICATE;
23794 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23795 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23796 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23797 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23798 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23799 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23800 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23801 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23802 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23803 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23804 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23805 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23806 vdev_param[wmi_vdev_param_packet_powersave] =
23807 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23808 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23809 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23810 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23811 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23812 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23813 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23814 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23815 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23816 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23817 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23818 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23819 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23820 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23821 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23822 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23823 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23824 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23825 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23826 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23827 vdev_param[wmi_vdev_param_roam_fw_offload] =
23828 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23829 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23830 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23831 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23832 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23833 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23834 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23835 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23836 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23837 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23838 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23839 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23840 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23841 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23842 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23843 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23844 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23845 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23846 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23847 vdev_param[wmi_vdev_param_inactivity_cnt] =
23848 WMI_VDEV_PARAM_INACTIVITY_CNT;
23849 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23850 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23851 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23852 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23853 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23854 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23855 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23856 vdev_param[wmi_vdev_param_rx_leak_window] =
23857 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23858 vdev_param[wmi_vdev_param_stats_avg_factor] =
23859 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23860 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23861 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23862 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23863 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23864 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23865 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023866 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23867 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023868 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023869 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23870 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23871 WMI_VDEV_PARAM_HE_RANGE_EXT;
23872 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23873 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023874 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023875 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23876 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23877 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23878 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23879 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23880 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23881 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023882 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23883 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23884 vdev_param[wmi_vdev_param_rc_num_retries] =
23885 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23886 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23887 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23888 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23889 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23890 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23891 vdev_param[wmi_vdev_param_vht80_ratemask] =
23892 WMI_VDEV_PARAM_VHT80_RATEMASK;
23893 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23894 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23895 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023896 vdev_param[wmi_vdev_param_set_he_ltf] =
23897 WMI_VDEV_PARAM_HE_LTF;
Sathish Kumar6011c742017-11-08 14:49:58 +053023898 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23899 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023900 vdev_param[wmi_vdev_param_set_ba_mode] =
23901 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023902 vdev_param[wmi_vdev_param_capabilities] =
23903 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023904 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23905 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023906}
23907#endif
23908
Govind Singh5eb51532016-03-09 11:34:12 +053023909/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023910 * populate_target_defines_tlv() - Populate target defines and params
23911 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023912 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023913 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023914 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023915#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023916static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023917{
Govind Singhe7f2f342016-05-23 12:12:52 +053023918 populate_pdev_param_tlv(wmi_handle->pdev_param);
23919 populate_vdev_param_tlv(wmi_handle->vdev_param);
23920}
23921#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023922static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23923{ }
23924#endif
23925
23926/**
Zhang Qian537fca62018-01-03 16:33:24 +080023927 * wmi_ocb_ut_attach() - Attach OCB test framework
23928 * @wmi_handle: wmi handle
23929 *
23930 * Return: None
23931 */
23932#ifdef WLAN_OCB_UT
23933void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23934#else
23935static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23936{
23937 return;
23938}
23939#endif
23940
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023941/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023942 * wmi_tlv_attach() - Attach TLV APIs
23943 *
23944 * Return: None
23945 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023946void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023947{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023948 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023949 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023950 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023951#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023952 /* Skip saving WMI_CMD_HDR and TLV HDR */
23953 wmi_handle->log_info.buf_offset_command = 8;
23954 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023955 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023956#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023957 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023958 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023959 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023960 wmi_twt_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023961}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023962qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023963
23964/**
23965 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23966 *
23967 * Return: None
23968 */
23969void wmi_tlv_init(void)
23970{
23971 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23972}