blob: 2211dd6667a44374e65cf2272dffaceaf9f62707 [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
Wen Gongca174012018-04-20 16:56:28 +08001577#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +05301578/**
1579 * send_dbglog_cmd_tlv() - set debug log level
1580 * @param wmi_handle : handle to WMI.
1581 * @param param : pointer to hold dbglog level parameter
1582 *
1583 * Return: 0 on success and -ve on failure.
1584 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301585 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301586send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1587 struct dbglog_params *dbglog_param)
1588{
1589 wmi_buf_t buf;
1590 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001591 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301592 int32_t i;
1593 int32_t len;
1594 int8_t *buf_ptr;
1595 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1596
Alok Kumar240afea2017-08-30 14:45:34 +05301597 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301598
1599 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1600 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1601 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1602 buf = wmi_buf_alloc(wmi_handle, len);
1603 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001604 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301605
1606 configmsg =
1607 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1608 buf_ptr = (int8_t *) configmsg;
1609 WMITLV_SET_HDR(&configmsg->tlv_header,
1610 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1611 WMITLV_GET_STRUCT_TLVLEN
1612 (wmi_debug_log_config_cmd_fixed_param));
1613 configmsg->dbg_log_param = dbglog_param->param;
1614 configmsg->value = dbglog_param->val;
1615 /* Filling in the data part of second tlv -- should
1616 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301617 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301618 sizeof
1619 (wmi_debug_log_config_cmd_fixed_param)
1620 + WMI_TLV_HDR_SIZE);
1621 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1622 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301623 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301624 if (dbglog_param->module_id_bitmap) {
1625 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1626 module_id_bitmap_array[i] =
1627 dbglog_param->module_id_bitmap[i];
1628 }
1629 }
1630
1631 status = wmi_unified_cmd_send(wmi_handle, buf,
1632 len, WMI_DBGLOG_CFG_CMDID);
1633
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001634 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301635 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301636
1637 return status;
1638}
Wen Gongca174012018-04-20 16:56:28 +08001639#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301640
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301641#ifdef CONFIG_MCL
1642static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1643 uint32_t host_param)
1644{
1645 return host_param;
1646}
1647#else
1648static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1649 uint32_t host_param)
1650{
1651 if (host_param < wmi_vdev_param_max)
1652 return wmi_handle->vdev_param[host_param];
1653
1654 return WMI_UNAVAILABLE_PARAM;
1655}
1656#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301657/**
1658 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1659 * @param wmi_handle : handle to WMI.
1660 * @param macaddr : MAC address
1661 * @param param : pointer to hold vdev set parameter
1662 *
1663 * Return: 0 on success and -ve on failure.
1664 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301665static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301666 struct vdev_set_params *param)
1667{
Govind Singh67922e82016-04-01 16:48:57 +05301668 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301669 wmi_vdev_set_param_cmd_fixed_param *cmd;
1670 wmi_buf_t buf;
1671 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301672 uint32_t vdev_param;
1673
1674 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1675 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1676 WMI_LOGW("%s:Vdev param %d not available", __func__,
1677 param->param_id);
1678 return QDF_STATUS_E_INVAL;
1679
1680 }
Govind Singh5eb51532016-03-09 11:34:12 +05301681
1682 buf = wmi_buf_alloc(wmi_handle, len);
1683 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301684 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301685 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301686 }
1687 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1688 WMITLV_SET_HDR(&cmd->tlv_header,
1689 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1690 WMITLV_GET_STRUCT_TLVLEN
1691 (wmi_vdev_set_param_cmd_fixed_param));
1692 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301693 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301694 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301695 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001696 cmd->vdev_id, cmd->param_id, cmd->param_value);
Govind Singh5eb51532016-03-09 11:34:12 +05301697 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1698 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301699 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301700 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301701 wmi_buf_free(buf);
1702 }
1703
1704 return ret;
1705}
1706
1707/**
1708 * send_stats_request_cmd_tlv() - WMI request stats function
1709 * @param wmi_handle : handle to WMI.
1710 * @param macaddr : MAC address
1711 * @param param : pointer to hold stats request parameter
1712 *
1713 * Return: 0 on success and -ve on failure.
1714 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301715static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301716 uint8_t macaddr[IEEE80211_ADDR_LEN],
1717 struct stats_request_params *param)
1718{
Govind Singhd3156eb2016-02-26 17:50:39 +05301719 int32_t ret;
1720 wmi_request_stats_cmd_fixed_param *cmd;
1721 wmi_buf_t buf;
1722 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1723
1724 buf = wmi_buf_alloc(wmi_handle, len);
1725 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301726 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1727 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301728 }
1729
1730 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1731 WMITLV_SET_HDR(&cmd->tlv_header,
1732 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1733 WMITLV_GET_STRUCT_TLVLEN
1734 (wmi_request_stats_cmd_fixed_param));
1735 cmd->stats_id = param->stats_id;
1736 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301737 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1738 param->pdev_id);
1739 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001740
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301741 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1742 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001743
1744 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1745 WMI_REQUEST_STATS_CMDID);
1746
Govind Singhd3156eb2016-02-26 17:50:39 +05301747 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301748 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301749 wmi_buf_free(buf);
1750 }
1751
1752 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301753}
1754
Govind Singh87542482016-06-08 19:40:11 +05301755#ifdef CONFIG_WIN
1756/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001757 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301758 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001759 * @param PKTLOG_EVENT : packet log event
1760 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301761 *
1762 * Return: 0 on success and -ve on failure.
1763 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301764static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001765 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301766{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001767 int32_t ret;
1768 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1769 wmi_buf_t buf;
1770 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1771
1772 buf = wmi_buf_alloc(wmi_handle, len);
1773 if (!buf) {
1774 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1775 return -QDF_STATUS_E_NOMEM;
1776 }
1777
1778 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1779 WMITLV_SET_HDR(&cmd->tlv_header,
1780 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1781 WMITLV_GET_STRUCT_TLVLEN
1782 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1783 cmd->evlist = PKTLOG_EVENT;
1784 cmd->pdev_id = mac_id;
1785 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1786 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1787 if (ret) {
1788 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1789 wmi_buf_free(buf);
1790 }
1791
1792 return ret;
1793}
1794
1795/**
1796 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1797 * @param wmi_handle : handle to WMI.
1798 * @mac_id: mac id to have radio context
1799 *
1800 * Return: 0 on success and -ve on failure.
1801 */
1802static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001803 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001804{
1805 int32_t ret;
1806 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1807 wmi_buf_t buf;
1808 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1809
1810 buf = wmi_buf_alloc(wmi_handle, len);
1811 if (!buf) {
1812 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1813 return -QDF_STATUS_E_NOMEM;
1814 }
1815
1816 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1817 WMITLV_SET_HDR(&cmd->tlv_header,
1818 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1819 WMITLV_GET_STRUCT_TLVLEN
1820 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1821 cmd->pdev_id = mac_id;
1822 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1823 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1824 if (ret) {
1825 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1826 wmi_buf_free(buf);
1827 }
1828
1829 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301830}
1831#else
Govind Singh5eb51532016-03-09 11:34:12 +05301832/**
Keyur Parekhde522342017-08-18 14:01:05 -07001833 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1834 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301835 * @param wmi_handle : handle to WMI.
1836 * @param macaddr : MAC address
1837 * @param param : pointer to hold stats request parameter
1838 *
1839 * Return: 0 on success and -ve on failure.
1840 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301841static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301842 uint8_t macaddr[IEEE80211_ADDR_LEN],
1843 struct packet_enable_params *param)
1844{
1845 return 0;
1846}
Keyur Parekhde522342017-08-18 14:01:05 -07001847/**
1848 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1849 * packet-log
1850 * @param wmi_handle : handle to WMI.
1851 * @mac_id: mac id to have radio context
1852 *
1853 * Return: 0 on success and -ve on failure.
1854 */
1855static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1856 uint8_t mac_id)
1857{
1858 return 0;
1859}
Govind Singh87542482016-06-08 19:40:11 +05301860#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301861
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301862#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1863/**
1864 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1865 * sync time between bwtween host and firmware
1866 * @param wmi_handle : handle to WMI.
1867 *
1868 * Return: None
1869 */
1870static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1871{
1872 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07001873 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301874 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1875 int32_t len;
1876 qdf_time_t time_ms;
1877
1878 len = sizeof(*time_stamp);
1879 buf = wmi_buf_alloc(wmi_handle, len);
1880
1881 if (!buf) {
1882 WMI_LOGP(FL("wmi_buf_alloc failed"));
1883 return;
1884 }
1885 time_stamp =
1886 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1887 (wmi_buf_data(buf));
1888 WMITLV_SET_HDR(&time_stamp->tlv_header,
1889 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1890 WMITLV_GET_STRUCT_TLVLEN(
1891 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1892
1893 time_ms = qdf_get_time_of_the_day_ms();
1894 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1895 time_stamp->time_stamp_low = time_ms &
1896 WMI_FW_TIME_STAMP_LOW_MASK;
1897 /*
1898 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1899 * wont exceed 27 bit
1900 */
1901 time_stamp->time_stamp_high = 0;
1902 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1903 time_stamp->mode, time_stamp->time_stamp_low,
1904 time_stamp->time_stamp_high);
1905
1906 status = wmi_unified_cmd_send(wmi_handle, buf,
1907 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
1908 if (status) {
1909 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
1910 wmi_buf_free(buf);
1911 }
1912
1913}
1914
Subrat Mishrad7c7a562017-09-27 14:41:20 +05301915#ifdef WLAN_SUPPORT_FILS
1916/**
1917 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
1918 * @wmi_handle: wmi handle
1919 * @evt_buf: pointer to event buffer
1920 * @vdev_id: pointer to hold vdev id
1921 *
1922 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
1923 */
1924static QDF_STATUS
1925extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
1926 void *evt_buf, uint32_t *vdev_id)
1927{
1928 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
1929 wmi_host_swfda_event_fixed_param *swfda_event;
1930
1931 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
1932 if (!param_buf) {
1933 WMI_LOGE("Invalid swfda event buffer");
1934 return QDF_STATUS_E_INVAL;
1935 }
1936 swfda_event = param_buf->fixed_param;
1937 *vdev_id = swfda_event->vdev_id;
1938
1939 return QDF_STATUS_SUCCESS;
1940}
1941
1942/**
1943 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
1944 * @wmi_handle: wmi handle
1945 * @param: pointer to hold FILS discovery enable param
1946 *
1947 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
1948 */
1949static QDF_STATUS
1950send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
1951 struct config_fils_params *param)
1952{
1953 wmi_enable_fils_cmd_fixed_param *cmd;
1954 wmi_buf_t buf;
1955 QDF_STATUS status;
1956 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
1957
1958 buf = wmi_buf_alloc(wmi_handle, len);
1959 if (!buf) {
1960 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1961 return QDF_STATUS_E_NOMEM;
1962 }
1963 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
1964 WMITLV_SET_HDR(&cmd->tlv_header,
1965 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
1966 WMITLV_GET_STRUCT_TLVLEN(
1967 wmi_enable_fils_cmd_fixed_param));
1968 cmd->vdev_id = param->vdev_id;
1969 cmd->fd_period = param->fd_period;
1970 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
1971 param->fd_period, param->vdev_id);
1972
1973 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1974 WMI_ENABLE_FILS_CMDID);
1975 if (status != QDF_STATUS_SUCCESS) {
1976 wmi_buf_free(buf);
1977 return QDF_STATUS_E_FAILURE;
1978 }
1979
1980 return QDF_STATUS_SUCCESS;
1981}
1982
1983/**
1984 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
1985 * @wmi_handle: wmi handle
1986 * @param: pointer to hold FD send cmd parameter
1987 *
1988 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
1989 */
1990static QDF_STATUS
1991send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
1992 struct fd_params *param)
1993{
1994 QDF_STATUS ret;
1995 wmi_fd_send_from_host_cmd_fixed_param *cmd;
1996 wmi_buf_t wmi_buf;
1997 qdf_dma_addr_t dma_addr;
1998
1999 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2000 if (!wmi_buf) {
2001 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2002 return QDF_STATUS_E_NOMEM;
2003 }
2004 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2005 WMITLV_SET_HDR(&cmd->tlv_header,
2006 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2007 WMITLV_GET_STRUCT_TLVLEN(
2008 wmi_fd_send_from_host_cmd_fixed_param));
2009 cmd->vdev_id = param->vdev_id;
2010 cmd->data_len = qdf_nbuf_len(param->wbuf);
2011 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2012 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2013 cmd->frame_ctrl = param->frame_ctrl;
2014
2015 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2016 WMI_PDEV_SEND_FD_CMDID);
2017 if (ret != QDF_STATUS_SUCCESS) {
2018 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2019 __func__, ret);
2020 wmi_buf_free(wmi_buf);
2021 }
2022
2023 return ret;
2024}
2025#endif /* WLAN_SUPPORT_FILS */
2026
Sathish Kumarfd347372017-02-13 12:29:09 +05302027static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302028 struct beacon_params *param)
2029{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302030 QDF_STATUS ret;
2031 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2032 wmi_buf_t wmi_buf;
2033 qdf_dma_addr_t dma_addr;
2034 uint32_t dtim_flag = 0;
2035
2036 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2037 if (!wmi_buf) {
2038 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2039 return QDF_STATUS_E_NOMEM;
2040 }
2041 if (param->is_dtim_count_zero) {
2042 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2043 if (param->is_bitctl_reqd) {
2044 /* deliver CAB traffic in next DTIM beacon */
2045 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2046 }
2047 }
2048 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2049 WMITLV_SET_HDR(&cmd->tlv_header,
2050 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2051 WMITLV_GET_STRUCT_TLVLEN
2052 (wmi_bcn_send_from_host_cmd_fixed_param));
2053 cmd->vdev_id = param->vdev_id;
2054 cmd->data_len = qdf_nbuf_len(param->wbuf);
2055 cmd->frame_ctrl = param->frame_ctrl;
2056 cmd->dtim_flag = dtim_flag;
2057 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2058 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2059#if defined(HTT_PADDR64)
2060 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2061#endif
2062 cmd->bcn_antenna = param->bcn_txant;
2063
2064 ret = wmi_unified_cmd_send(wmi_handle,
2065 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2066 if (ret != QDF_STATUS_SUCCESS) {
2067 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2068 wmi_buf_free(wmi_buf);
2069 }
2070
2071 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302072}
2073
2074/**
2075 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2076 * @param wmi_handle : handle to WMI.
2077 * @param param : pointer to hold beacon send cmd parameter
2078 *
2079 * Return: 0 on success and -ve on failure.
2080 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302081static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302082 struct beacon_tmpl_params *param)
2083{
2084 int32_t ret;
2085 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2086 wmi_bcn_prb_info *bcn_prb_info;
2087 wmi_buf_t wmi_buf;
2088 uint8_t *buf_ptr;
2089 uint32_t wmi_buf_len;
2090
2091 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2092 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2093 param->tmpl_len_aligned;
2094 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2095 if (!wmi_buf) {
2096 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2097 return QDF_STATUS_E_NOMEM;
2098 }
2099 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2100 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2101 WMITLV_SET_HDR(&cmd->tlv_header,
2102 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2103 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2104 cmd->vdev_id = param->vdev_id;
2105 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302106 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2107 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05302108 cmd->buf_len = param->tmpl_len;
2109 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2110
2111 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2112 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2113 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2114 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2115 bcn_prb_info->caps = 0;
2116 bcn_prb_info->erp = 0;
2117 buf_ptr += sizeof(wmi_bcn_prb_info);
2118
2119 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2120 buf_ptr += WMI_TLV_HDR_SIZE;
2121 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2122
2123 ret = wmi_unified_cmd_send(wmi_handle,
2124 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2125 if (ret) {
2126 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2127 wmi_buf_free(wmi_buf);
2128 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302129
Govind Singh87542482016-06-08 19:40:11 +05302130 return 0;
2131}
Govind Singh5eb51532016-03-09 11:34:12 +05302132
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302133#ifdef CONFIG_MCL
2134static inline void copy_peer_flags_tlv(
2135 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2136 struct peer_assoc_params *param)
2137{
2138 cmd->peer_flags = param->peer_flags;
2139}
2140#else
2141static inline void copy_peer_flags_tlv(
2142 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2143 struct peer_assoc_params *param)
2144{
2145 /*
2146 * The target only needs a subset of the flags maintained in the host.
2147 * Just populate those flags and send it down
2148 */
2149 cmd->peer_flags = 0;
2150
2151 /*
2152 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2153 */
2154 if (param->is_wme_set) {
2155
2156 if (param->qos_flag)
2157 cmd->peer_flags |= WMI_PEER_QOS;
2158 if (param->apsd_flag)
2159 cmd->peer_flags |= WMI_PEER_APSD;
2160 if (param->ht_flag)
2161 cmd->peer_flags |= WMI_PEER_HT;
2162 if (param->bw_40)
2163 cmd->peer_flags |= WMI_PEER_40MHZ;
2164 if (param->bw_80)
2165 cmd->peer_flags |= WMI_PEER_80MHZ;
2166 if (param->bw_160)
2167 cmd->peer_flags |= WMI_PEER_160MHZ;
2168
2169 /* Typically if STBC is enabled for VHT it should be enabled
2170 * for HT as well
2171 **/
2172 if (param->stbc_flag)
2173 cmd->peer_flags |= WMI_PEER_STBC;
2174
2175 /* Typically if LDPC is enabled for VHT it should be enabled
2176 * for HT as well
2177 **/
2178 if (param->ldpc_flag)
2179 cmd->peer_flags |= WMI_PEER_LDPC;
2180
2181 if (param->static_mimops_flag)
2182 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2183 if (param->dynamic_mimops_flag)
2184 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2185 if (param->spatial_mux_flag)
2186 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2187 if (param->vht_flag)
2188 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002189 if (param->he_flag)
2190 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302191 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002192
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302193 if (param->is_pmf_enabled)
2194 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302195 /*
2196 * Suppress authorization for all AUTH modes that need 4-way handshake
2197 * (during re-association).
2198 * Authorization will be done for these modes on key installation.
2199 */
2200 if (param->auth_flag)
2201 cmd->peer_flags |= WMI_PEER_AUTH;
2202 if (param->need_ptk_4_way)
2203 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2204 else
2205 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2206 if (param->need_gtk_2_way)
2207 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2208 /* safe mode bypass the 4-way handshake */
2209 if (param->safe_mode_enabled)
2210 cmd->peer_flags &=
2211 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2212 /* Disable AMSDU for station transmit, if user configures it */
2213 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2214 * it
2215 * if (param->amsdu_disable) Add after FW support
2216 **/
2217
2218 /* Target asserts if node is marked HT and all MCS is set to 0.
2219 * Mark the node as non-HT if all the mcs rates are disabled through
2220 * iwpriv
2221 **/
2222 if (param->peer_ht_rates.num_rates == 0)
2223 cmd->peer_flags &= ~WMI_PEER_HT;
2224}
2225#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302226
2227#ifdef CONFIG_MCL
2228static inline void copy_peer_mac_addr_tlv(
2229 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2230 struct peer_assoc_params *param)
2231{
2232 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2233 sizeof(param->peer_macaddr));
2234}
2235#else
2236static inline void copy_peer_mac_addr_tlv(
2237 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2238 struct peer_assoc_params *param)
2239{
2240 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2241}
2242#endif
2243
Govind Singh5eb51532016-03-09 11:34:12 +05302244/**
2245 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2246 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302247 * @param param : pointer to peer assoc parameter
2248 *
2249 * Return: 0 on success and -ve on failure.
2250 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302251static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302252 struct peer_assoc_params *param)
2253{
Govind Singhd3156eb2016-02-26 17:50:39 +05302254 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2255 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002256 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302257 wmi_buf_t buf;
2258 int32_t len;
2259 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302260 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302261 uint32_t peer_legacy_rates_align;
2262 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002263 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302264
2265
2266 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2267 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302268
2269 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002270 (peer_legacy_rates_align * sizeof(uint8_t)) +
2271 WMI_TLV_HDR_SIZE +
2272 (peer_ht_rates_align * sizeof(uint8_t)) +
2273 sizeof(wmi_vht_rate_set) +
2274 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2275 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302276
2277 buf = wmi_buf_alloc(wmi_handle, len);
2278 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302279 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302280 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302281 }
2282
2283 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2284 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2285 WMITLV_SET_HDR(&cmd->tlv_header,
2286 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2287 WMITLV_GET_STRUCT_TLVLEN
2288 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302289
Govind Singhd3156eb2016-02-26 17:50:39 +05302290 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302291
Govind Singhd3156eb2016-02-26 17:50:39 +05302292 cmd->peer_new_assoc = param->peer_new_assoc;
2293 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302294
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302295 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302296 copy_peer_mac_addr_tlv(cmd, param);
2297
Govind Singhd3156eb2016-02-26 17:50:39 +05302298 cmd->peer_rate_caps = param->peer_rate_caps;
2299 cmd->peer_caps = param->peer_caps;
2300 cmd->peer_listen_intval = param->peer_listen_intval;
2301 cmd->peer_ht_caps = param->peer_ht_caps;
2302 cmd->peer_max_mpdu = param->peer_max_mpdu;
2303 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302304 cmd->peer_vht_caps = param->peer_vht_caps;
2305 cmd->peer_phymode = param->peer_phymode;
2306
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002307 /* Update 11ax capabilities */
2308 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2309 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002310 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2311 sizeof(param->peer_he_cap_phyinfo));
2312 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2313 sizeof(param->peer_ppet));
2314
Govind Singhd3156eb2016-02-26 17:50:39 +05302315 /* Update peer legacy rate information */
2316 buf_ptr += sizeof(*cmd);
2317 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302318 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302319 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302320 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302321 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302322 param->peer_legacy_rates.num_rates);
2323
2324 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002325 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302326 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302327 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302328 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302329 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302330 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302331 param->peer_ht_rates.num_rates);
2332
2333 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002334 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302335 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2336 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2337
2338 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302339
2340 /* Update bandwidth-NSS mapping */
2341 cmd->peer_bw_rxnss_override = 0;
2342 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2343
Govind Singhd3156eb2016-02-26 17:50:39 +05302344 mcs = (wmi_vht_rate_set *) buf_ptr;
2345 if (param->vht_capable) {
2346 mcs->rx_max_rate = param->rx_max_rate;
2347 mcs->rx_mcs_set = param->rx_mcs_set;
2348 mcs->tx_max_rate = param->tx_max_rate;
2349 mcs->tx_mcs_set = param->tx_mcs_set;
2350 }
2351
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002352 /* HE Rates */
2353 cmd->peer_he_mcs = param->peer_he_mcs_count;
2354 buf_ptr += sizeof(wmi_vht_rate_set);
2355 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2356 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2357 buf_ptr += WMI_TLV_HDR_SIZE;
2358
2359 /* Loop through the HE rate set */
2360 for (i = 0; i < param->peer_he_mcs_count; i++) {
2361 he_mcs = (wmi_he_rate_set *) buf_ptr;
2362 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2363 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2364
2365 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2366 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2367 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2368 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2369 buf_ptr += sizeof(wmi_he_rate_set);
2370 }
2371
2372
Govind Singhb53420c2016-03-09 14:32:57 +05302373 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302374 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2375 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002376 "cmd->peer_vht_caps %x "
2377 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302378 "HE phy %x %x %x "
2379 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302380 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2381 cmd->peer_rate_caps, cmd->peer_caps,
2382 cmd->peer_listen_intval, cmd->peer_ht_caps,
2383 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2384 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002385 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2386 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302387 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2388 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302389
2390 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2391 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302392 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302393 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302394 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302395 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302396 }
2397
2398 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302399}
2400
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302401/* copy_scan_notify_events() - Helper routine to copy scan notify events
2402 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302403static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302404 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302405 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302406{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302407
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302408 /* Scan events subscription */
2409 if (param->scan_ev_started)
2410 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2411 if (param->scan_ev_completed)
2412 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2413 if (param->scan_ev_bss_chan)
2414 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2415 if (param->scan_ev_foreign_chan)
2416 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2417 if (param->scan_ev_dequeued)
2418 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2419 if (param->scan_ev_preempted)
2420 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2421 if (param->scan_ev_start_failed)
2422 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2423 if (param->scan_ev_restarted)
2424 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2425 if (param->scan_ev_foreign_chn_exit)
2426 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2427 if (param->scan_ev_suspended)
2428 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2429 if (param->scan_ev_resumed)
2430 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302431
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302432 /** Set scan control flags */
2433 cmd->scan_ctrl_flags = 0;
2434 if (param->scan_f_passive)
2435 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2436 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302437 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302438 if (param->scan_f_promisc_mode)
2439 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2440 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302441 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302442 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302443 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302444 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302445 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302446 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302447 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302448 if (param->scan_f_ofdm_rates)
2449 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2450 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302451 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302452 if (param->scan_f_filter_prb_req)
2453 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2454 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302455 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302456 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302457 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302458 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302459 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302460 if (param->scan_f_force_active_dfs_chn)
2461 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2462 if (param->scan_f_add_tpc_ie_in_probe)
2463 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2464 if (param->scan_f_add_ds_ie_in_probe)
2465 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2466 if (param->scan_f_add_spoofed_mac_in_probe)
2467 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2468 if (param->scan_f_add_rand_seq_in_probe)
2469 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2470 if (param->scan_f_en_ie_whitelist_in_probe)
2471 cmd->scan_ctrl_flags |=
2472 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302473
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302474 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2475 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2476 param->adaptive_dwell_time_mode);
2477}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302478
2479/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302480static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302481 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302482{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302483 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302484}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302485
Govind Singh5eb51532016-03-09 11:34:12 +05302486/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302487 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2488 * @mac: random mac addr
2489 * @mask: random mac mask
2490 * @mac_addr: wmi random mac
2491 * @mac_mask: wmi random mac mask
2492 *
2493 * Return None.
2494 */
2495static inline
2496void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2497 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2498{
2499 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2500 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2501}
2502
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302503/*
2504 * wmi_fill_vendor_oui() - fill vendor OUIs
2505 * @buf_ptr: pointer to wmi tlv buffer
2506 * @num_vendor_oui: number of vendor OUIs to be filled
2507 * @param_voui: pointer to OUI buffer
2508 *
2509 * This function populates the wmi tlv buffer when vendor specific OUIs are
2510 * present.
2511 *
2512 * Return: None
2513 */
2514static inline
2515void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2516 uint32_t *pvoui)
2517{
2518 wmi_vendor_oui *voui = NULL;
2519 uint32_t i;
2520
2521 voui = (wmi_vendor_oui *)buf_ptr;
2522
2523 for (i = 0; i < num_vendor_oui; i++) {
2524 WMITLV_SET_HDR(&voui[i].tlv_header,
2525 WMITLV_TAG_STRUC_wmi_vendor_oui,
2526 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2527 voui[i].oui_type_subtype = pvoui[i];
2528 }
2529}
2530
2531/*
2532 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2533 * @ie_bitmap: output pointer to ie bit map in cmd
2534 * @num_vendor_oui: output pointer to num vendor OUIs
2535 * @ie_whitelist: input parameter
2536 *
2537 * This function populates the IE whitelist attrs of scan, pno and
2538 * scan oui commands for ie_whitelist parameter.
2539 *
2540 * Return: None
2541 */
2542static inline
2543void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2544 uint32_t *num_vendor_oui,
2545 struct probe_req_whitelist_attr *ie_whitelist)
2546{
2547 uint32_t i = 0;
2548
2549 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2550 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2551
2552 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2553}
2554
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302555/**
Govind Singh5eb51532016-03-09 11:34:12 +05302556 * send_scan_start_cmd_tlv() - WMI scan start function
2557 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302558 * @param param : pointer to hold scan start cmd parameter
2559 *
2560 * Return: 0 on success and -ve on failure.
2561 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302562static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302563 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302564{
Govind Singhd3156eb2016-02-26 17:50:39 +05302565 int32_t ret = 0;
2566 int32_t i;
2567 wmi_buf_t wmi_buf;
2568 wmi_start_scan_cmd_fixed_param *cmd;
2569 uint8_t *buf_ptr;
2570 uint32_t *tmp_ptr;
2571 wmi_ssid *ssid = NULL;
2572 wmi_mac_addr *bssid;
2573 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302574 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302575 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302576 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302577
2578 /* Length TLV placeholder for array of uint32_t */
2579 len += WMI_TLV_HDR_SIZE;
2580 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302581 if (params->chan_list.num_chan)
2582 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302583
2584 /* Length TLV placeholder for array of wmi_ssid structures */
2585 len += WMI_TLV_HDR_SIZE;
2586 if (params->num_ssids)
2587 len += params->num_ssids * sizeof(wmi_ssid);
2588
2589 /* Length TLV placeholder for array of wmi_mac_addr structures */
2590 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302591 if (params->num_bssid)
2592 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302593
2594 /* Length TLV placeholder for array of bytes */
2595 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302596 if (params->extraie.len)
2597 extraie_len_with_pad =
2598 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002599 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302600
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302601 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2602 if (ie_whitelist->num_vendor_oui)
2603 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2604
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302605 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2606 if (params->scan_f_wide_band)
2607 phymode_roundup =
2608 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2609 sizeof(uint32_t));
2610 len += phymode_roundup;
2611
Govind Singhd3156eb2016-02-26 17:50:39 +05302612 /* Allocate the memory */
2613 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2614 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302615 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302616 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302617 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302618 }
2619 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2620 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2621 WMITLV_SET_HDR(&cmd->tlv_header,
2622 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2623 WMITLV_GET_STRUCT_TLVLEN
2624 (wmi_start_scan_cmd_fixed_param));
2625
2626 cmd->scan_id = params->scan_id;
2627 cmd->scan_req_id = params->scan_req_id;
2628 cmd->vdev_id = params->vdev_id;
2629 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302630
2631 copy_scan_event_cntrl_flags(cmd, params);
2632
Govind Singhd3156eb2016-02-26 17:50:39 +05302633 cmd->dwell_time_active = params->dwell_time_active;
2634 cmd->dwell_time_passive = params->dwell_time_passive;
2635 cmd->min_rest_time = params->min_rest_time;
2636 cmd->max_rest_time = params->max_rest_time;
2637 cmd->repeat_probe_time = params->repeat_probe_time;
2638 cmd->probe_spacing_time = params->probe_spacing_time;
2639 cmd->idle_time = params->idle_time;
2640 cmd->max_scan_time = params->max_scan_time;
2641 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302642 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302643 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302644 cmd->num_bssid = params->num_bssid;
2645 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302646 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302647 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302648 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2649
2650 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2651
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302652 if (params->scan_random.randomize)
2653 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2654 params->scan_random.mac_mask,
2655 &cmd->mac_addr,
2656 &cmd->mac_mask);
2657
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302658 if (ie_whitelist->white_list)
2659 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2660 &cmd->num_vendor_oui,
2661 ie_whitelist);
2662
Govind Singhd3156eb2016-02-26 17:50:39 +05302663 buf_ptr += sizeof(*cmd);
2664 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302665 for (i = 0; i < params->chan_list.num_chan; ++i)
2666 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302667
2668 WMITLV_SET_HDR(buf_ptr,
2669 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302670 (params->chan_list.num_chan * sizeof(uint32_t)));
2671 buf_ptr += WMI_TLV_HDR_SIZE +
2672 (params->chan_list.num_chan * sizeof(uint32_t));
2673
Govind Singh4eacd2b2016-03-07 14:24:22 +05302674 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302675 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302676 goto error;
2677 }
2678
2679 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2680 (params->num_ssids * sizeof(wmi_ssid)));
2681
2682 if (params->num_ssids) {
2683 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2684 for (i = 0; i < params->num_ssids; ++i) {
2685 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302686 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302687 params->ssid[i].length);
2688 ssid++;
2689 }
2690 }
2691 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2692
2693 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2694 (params->num_bssid * sizeof(wmi_mac_addr)));
2695 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302696
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302697 if (params->num_bssid) {
2698 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302699 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2700 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302701 bssid++;
2702 }
2703 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302704
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302705 buf_ptr += WMI_TLV_HDR_SIZE +
2706 (params->num_bssid * sizeof(wmi_mac_addr));
2707
2708 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2709 if (params->extraie.len)
2710 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2711 params);
2712
2713 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302714
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302715 /* probe req ie whitelisting */
2716 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2717 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2718
2719 buf_ptr += WMI_TLV_HDR_SIZE;
2720
2721 if (cmd->num_vendor_oui) {
2722 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2723 ie_whitelist->voui);
2724 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2725 }
2726
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302727 /* Add phy mode TLV if it's a wide band scan */
2728 if (params->scan_f_wide_band) {
2729 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2730 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2731 for (i = 0; i < params->chan_list.num_chan; ++i)
2732 buf_ptr[i] =
2733 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2734 buf_ptr += phymode_roundup;
2735 } else {
2736 /* Add ZERO legth phy mode TLV */
2737 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2738 }
2739
Santosh Anbu1e11b472018-03-07 15:33:27 +05302740 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002741 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302742 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302743 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302744 wmi_buf_free(wmi_buf);
2745 }
2746 return ret;
2747error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302748 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302749 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302750}
2751
2752/**
2753 * send_scan_stop_cmd_tlv() - WMI scan start function
2754 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302755 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302756 *
2757 * Return: 0 on success and -ve on failure.
2758 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302759static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302760 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302761{
Govind Singhd3156eb2016-02-26 17:50:39 +05302762 wmi_stop_scan_cmd_fixed_param *cmd;
2763 int ret;
2764 int len = sizeof(*cmd);
2765 wmi_buf_t wmi_buf;
2766
2767 /* Allocate the memory */
2768 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2769 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302770 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302771 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302772 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302773 goto error;
2774 }
2775
2776 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2777 WMITLV_SET_HDR(&cmd->tlv_header,
2778 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2779 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2780 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302781 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302782 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302783 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2784 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302785 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302786 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2787 /* Cancelling all scans */
2788 cmd->req_type = WMI_SCAN_STOP_ALL;
2789 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2790 /* Cancelling VAP scans */
2791 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2792 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2793 /* Cancelling specific scan */
2794 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302795 } else {
2796 WMI_LOGE("%s: Invalid Command : ", __func__);
2797 wmi_buf_free(wmi_buf);
2798 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302799 }
2800
Santosh Anbu1e11b472018-03-07 15:33:27 +05302801 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002802 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302803 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302804 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302805 wmi_buf_free(wmi_buf);
2806 }
2807
2808error:
2809 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302810}
2811
Govind Singh87542482016-06-08 19:40:11 +05302812#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302813/**
2814 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2815 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302816 * @param param : pointer to hold scan channel list parameter
2817 *
2818 * Return: 0 on success and -ve on failure.
2819 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302820static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302821 struct scan_chan_list_params *chan_list)
2822{
2823 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302824 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302825 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302826 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302827 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302828 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302829 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2830
2831 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2832 buf = wmi_buf_alloc(wmi_handle, len);
2833 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302834 WMI_LOGE("Failed to allocate memory");
2835 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302836 goto end;
2837 }
2838
2839 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2840 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2841 WMITLV_SET_HDR(&cmd->tlv_header,
2842 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2843 WMITLV_GET_STRUCT_TLVLEN
2844 (wmi_scan_chan_list_cmd_fixed_param));
2845
Govind Singhb53420c2016-03-09 14:32:57 +05302846 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302847
2848 cmd->num_scan_chans = chan_list->num_scan_chans;
2849 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2850 WMITLV_TAG_ARRAY_STRUC,
2851 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302852 chan_info = (wmi_channel_param *)
2853 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302854 tchan_info = chan_list->chan_info;
2855
2856 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2857 WMITLV_SET_HDR(&chan_info->tlv_header,
2858 WMITLV_TAG_STRUC_wmi_channel,
2859 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2860 chan_info->mhz = tchan_info->mhz;
2861 chan_info->band_center_freq1 =
2862 tchan_info->band_center_freq1;
2863 chan_info->band_center_freq2 =
2864 tchan_info->band_center_freq2;
2865 chan_info->info = tchan_info->info;
2866 chan_info->reg_info_1 = tchan_info->reg_info_1;
2867 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302868 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302869
2870 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2871 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2872 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2873 tchan_info++;
2874 chan_info++;
2875 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302876 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2877 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302878
Anish Natarajdd855152017-03-20 12:49:08 +05302879 qdf_status = wmi_unified_cmd_send(wmi_handle,
2880 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302881
Govind Singh67922e82016-04-01 16:48:57 +05302882 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302883 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302884 wmi_buf_free(buf);
2885 }
Govind Singh67922e82016-04-01 16:48:57 +05302886
Govind Singhd3156eb2016-02-26 17:50:39 +05302887end:
Govind Singhb53420c2016-03-09 14:32:57 +05302888 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302889}
Govind Singh87542482016-06-08 19:40:11 +05302890#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302891static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302892 struct scan_chan_list_params *chan_list)
2893{
2894 wmi_buf_t buf;
2895 QDF_STATUS qdf_status;
2896 wmi_scan_chan_list_cmd_fixed_param *cmd;
2897 int i;
2898 uint8_t *buf_ptr;
2899 wmi_channel *chan_info;
2900 struct channel_param *tchan_info;
2901 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302902
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302903 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302904 buf = wmi_buf_alloc(wmi_handle, len);
2905 if (!buf) {
2906 WMI_LOGE("Failed to allocate memory");
2907 qdf_status = QDF_STATUS_E_NOMEM;
2908 goto end;
2909 }
2910
2911 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2912 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2913 WMITLV_SET_HDR(&cmd->tlv_header,
2914 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2915 WMITLV_GET_STRUCT_TLVLEN
2916 (wmi_scan_chan_list_cmd_fixed_param));
2917
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302918 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302919
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302920 if (chan_list->append)
2921 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2922
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302923 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2924 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302925 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302926 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2927 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302928 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302929 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2930 tchan_info = &(chan_list->ch_param[0]);
2931
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302932 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302933 WMITLV_SET_HDR(&chan_info->tlv_header,
2934 WMITLV_TAG_STRUC_wmi_channel,
2935 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2936 chan_info->mhz = tchan_info->mhz;
2937 chan_info->band_center_freq1 =
2938 tchan_info->cfreq1;
2939 chan_info->band_center_freq2 =
2940 tchan_info->cfreq2;
2941
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302942 if (tchan_info->is_chan_passive)
2943 WMI_SET_CHANNEL_FLAG(chan_info,
2944 WMI_CHAN_FLAG_PASSIVE);
2945
2946 if (tchan_info->allow_vht)
2947 WMI_SET_CHANNEL_FLAG(chan_info,
2948 WMI_CHAN_FLAG_ALLOW_VHT);
2949 else if (tchan_info->allow_ht)
2950 WMI_SET_CHANNEL_FLAG(chan_info,
2951 WMI_CHAN_FLAG_ALLOW_HT);
2952 WMI_SET_CHANNEL_MODE(chan_info,
2953 tchan_info->phy_mode);
2954
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05302955 if (tchan_info->half_rate)
2956 WMI_SET_CHANNEL_FLAG(chan_info,
2957 WMI_CHAN_FLAG_HALF_RATE);
2958
2959 if (tchan_info->quarter_rate)
2960 WMI_SET_CHANNEL_FLAG(chan_info,
2961 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302962
2963 /* also fill in power information */
2964 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2965 tchan_info->minpower);
2966 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2967 tchan_info->maxpower);
2968 WMI_SET_CHANNEL_REG_POWER(chan_info,
2969 tchan_info->maxregpower);
2970 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2971 tchan_info->antennamax);
2972 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2973 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08002974 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
2975 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302976
Govind Singh87542482016-06-08 19:40:11 +05302977 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2978
Govind Singh87542482016-06-08 19:40:11 +05302979 tchan_info++;
2980 chan_info++;
2981 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302982 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2983 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302984
Anish Natarajdd855152017-03-20 12:49:08 +05302985 qdf_status = wmi_unified_cmd_send(
2986 wmi_handle,
2987 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302988
2989 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2990 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2991 wmi_buf_free(buf);
2992 }
2993
2994end:
2995 return qdf_status;
2996}
2997#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302998
2999/**
3000 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3001 *
3002 * @bufp: Pointer to buffer
3003 * @param: Pointer to tx param
3004 *
3005 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3006 */
3007static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3008 struct tx_send_params param)
3009{
3010 wmi_tx_send_params *tx_param;
3011 QDF_STATUS status = QDF_STATUS_SUCCESS;
3012
3013 if (!bufp) {
3014 status = QDF_STATUS_E_FAILURE;
3015 return status;
3016 }
3017 tx_param = (wmi_tx_send_params *)bufp;
3018 WMITLV_SET_HDR(&tx_param->tlv_header,
3019 WMITLV_TAG_STRUC_wmi_tx_send_params,
3020 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3021 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3022 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3023 param.mcs_mask);
3024 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3025 param.nss_mask);
3026 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3027 param.retry_limit);
3028 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3029 param.chain_mask);
3030 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3031 param.bw_mask);
3032 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3033 param.preamble_type);
3034 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3035 param.frame_type);
3036
3037 return status;
3038}
3039
Govind Singhd3156eb2016-02-26 17:50:39 +05303040/**
3041 * send_mgmt_cmd_tlv() - WMI scan start function
3042 * @wmi_handle : handle to WMI.
3043 * @param : pointer to hold mgmt cmd parameter
3044 *
3045 * Return: 0 on success and -ve on failure.
3046 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303047static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303048 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303049{
Govind Singh427ee5a2016-02-26 18:09:36 +05303050 wmi_buf_t buf;
3051 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3052 int32_t cmd_len;
3053 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303054 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303055 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303056 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303057 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3058 mgmt_tx_dl_frm_len;
3059
3060 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303061 WMI_TLV_HDR_SIZE +
3062 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303063
Sathish Kumar5b636932017-06-28 14:40:32 +05303064 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303065 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303066 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3067 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303068 }
3069
3070 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3071 bufp = (uint8_t *) cmd;
3072 WMITLV_SET_HDR(&cmd->tlv_header,
3073 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3074 WMITLV_GET_STRUCT_TLVLEN
3075 (wmi_mgmt_tx_send_cmd_fixed_param));
3076
3077 cmd->vdev_id = param->vdev_id;
3078
Govind Singh224a7312016-06-21 14:33:26 +05303079 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303080 cmd->chanfreq = param->chanfreq;
3081 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3082 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3083 sizeof(uint32_t)));
3084 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303085 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303086
3087 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3088 QDF_DMA_TO_DEVICE);
3089 if (status != QDF_STATUS_SUCCESS) {
3090 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303091 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303092 }
3093
Govind Singhb53420c2016-03-09 14:32:57 +05303094 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303095 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003096#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303097 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3098#endif
3099 cmd->frame_len = param->frm_len;
3100 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303101 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303102
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003103 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003104 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003105
Sathish Kumar5b636932017-06-28 14:40:32 +05303106 bufp += roundup(bufp_len, sizeof(uint32_t));
3107 if (param->tx_params_valid) {
3108 status = populate_tx_send_params(bufp, param->tx_param);
3109 if (status != QDF_STATUS_SUCCESS) {
3110 WMI_LOGE("%s: Populate TX send params failed",
3111 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303112 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303113 }
3114 cmd_len += sizeof(wmi_tx_send_params);
3115 }
3116
Govind Singh427ee5a2016-02-26 18:09:36 +05303117 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3118 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303119 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303120 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303121 }
Govind Singhb53420c2016-03-09 14:32:57 +05303122 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303123
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303124unmap_tx_frame:
3125 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3126 QDF_DMA_TO_DEVICE);
3127free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303128 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303129 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303130}
3131
3132/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303133 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3134 * @wmi_handle : handle to WMI.
3135 * @param : pointer to offchan data tx cmd parameter
3136 *
3137 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3138 */
3139static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3140 struct wmi_offchan_data_tx_params *param)
3141{
3142 wmi_buf_t buf;
3143 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3144 int32_t cmd_len;
3145 uint64_t dma_addr;
3146 void *qdf_ctx = param->qdf_ctx;
3147 uint8_t *bufp;
3148 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3149 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303150 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303151
3152 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303153 WMI_TLV_HDR_SIZE +
3154 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303155
Sathish Kumar5b636932017-06-28 14:40:32 +05303156 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303157 if (!buf) {
3158 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3159 return QDF_STATUS_E_NOMEM;
3160 }
3161
3162 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3163 bufp = (uint8_t *) cmd;
3164 WMITLV_SET_HDR(&cmd->tlv_header,
3165 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3166 WMITLV_GET_STRUCT_TLVLEN
3167 (wmi_offchan_data_tx_send_cmd_fixed_param));
3168
3169 cmd->vdev_id = param->vdev_id;
3170
3171 cmd->desc_id = param->desc_id;
3172 cmd->chanfreq = param->chanfreq;
3173 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3174 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3175 sizeof(uint32_t)));
3176 bufp += WMI_TLV_HDR_SIZE;
3177 qdf_mem_copy(bufp, param->pdata, bufp_len);
3178 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3179 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3180 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3181#if defined(HTT_PADDR64)
3182 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3183#endif
3184 cmd->frame_len = param->frm_len;
3185 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303186 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303187
3188 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3189 bufp, cmd->vdev_id, cmd->chanfreq);
3190
Sathish Kumar5b636932017-06-28 14:40:32 +05303191 bufp += roundup(bufp_len, sizeof(uint32_t));
3192 if (param->tx_params_valid) {
3193 status = populate_tx_send_params(bufp, param->tx_param);
3194 if (status != QDF_STATUS_SUCCESS) {
3195 WMI_LOGE("%s: Populate TX send params failed",
3196 __func__);
3197 goto err1;
3198 }
3199 cmd_len += sizeof(wmi_tx_send_params);
3200 }
3201
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303202 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3203 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3204 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303205 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303206 }
3207
3208 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303209
3210err1:
3211 wmi_buf_free(buf);
3212 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303213}
3214
3215/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303216 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3217 * @wmi_handle: wmi handle
3218 * @param_value: parameter value
3219 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303220 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303221 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303222static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303223 uint32_t param_value)
3224{
Govind Singh67922e82016-04-01 16:48:57 +05303225 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303226 wmi_modem_power_state_cmd_param *cmd;
3227 wmi_buf_t buf;
3228 uint16_t len = sizeof(*cmd);
3229
3230 buf = wmi_buf_alloc(wmi_handle, len);
3231 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303232 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303233 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303234 }
3235 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3236 WMITLV_SET_HDR(&cmd->tlv_header,
3237 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3238 WMITLV_GET_STRUCT_TLVLEN
3239 (wmi_modem_power_state_cmd_param));
3240 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303241 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303242 param_value);
3243 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3244 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303245 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303246 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303247 wmi_buf_free(buf);
3248 }
Govind Singh67922e82016-04-01 16:48:57 +05303249
Govind Singh427ee5a2016-02-26 18:09:36 +05303250 return ret;
3251}
3252
3253/**
3254 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3255 * @wmi_handle: wmi handle
3256 * @vdev_id: vdev id
3257 * @val: value
3258 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303259 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303260 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303261static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303262 uint32_t vdev_id, uint8_t val)
3263{
3264 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3265 wmi_buf_t buf;
3266 int32_t len = sizeof(*cmd);
3267
Govind Singhb53420c2016-03-09 14:32:57 +05303268 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303269
3270 buf = wmi_buf_alloc(wmi_handle, len);
3271 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303272 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303273 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303274 }
3275 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3276 WMITLV_SET_HDR(&cmd->tlv_header,
3277 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3278 WMITLV_GET_STRUCT_TLVLEN
3279 (wmi_sta_powersave_mode_cmd_fixed_param));
3280 cmd->vdev_id = vdev_id;
3281 if (val)
3282 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3283 else
3284 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3285
3286 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3287 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303288 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303289 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303290 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303291 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303292 }
Govind Singh5eb51532016-03-09 11:34:12 +05303293 return 0;
3294}
3295
Govind Singh427ee5a2016-02-26 18:09:36 +05303296/**
3297 * send_set_mimops_cmd_tlv() - set MIMO powersave
3298 * @wmi_handle: wmi handle
3299 * @vdev_id: vdev id
3300 * @value: value
3301 *
Govind Singhb53420c2016-03-09 14:32:57 +05303302 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303303 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303304static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303305 uint8_t vdev_id, int value)
3306{
Govind Singh67922e82016-04-01 16:48:57 +05303307 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303308 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3309 wmi_buf_t buf;
3310 uint16_t len = sizeof(*cmd);
3311
3312 buf = wmi_buf_alloc(wmi_handle, len);
3313 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303314 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303315 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303316 }
3317 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3318 WMITLV_SET_HDR(&cmd->tlv_header,
3319 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3320 WMITLV_GET_STRUCT_TLVLEN
3321 (wmi_sta_smps_force_mode_cmd_fixed_param));
3322
3323 cmd->vdev_id = vdev_id;
3324
Houston Hoffmanb5168052016-04-14 02:18:01 -07003325 /* WMI_SMPS_FORCED_MODE values do not directly map
3326 * to SM power save values defined in the specification.
3327 * Make sure to send the right mapping.
3328 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303329 switch (value) {
3330 case 0:
3331 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3332 break;
3333 case 1:
3334 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3335 break;
3336 case 2:
3337 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3338 break;
3339 case 3:
3340 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3341 break;
3342 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303343 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303344 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303345 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303346 }
3347
Govind Singhb53420c2016-03-09 14:32:57 +05303348 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303349
3350 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3351 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303352 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303353 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303354 wmi_buf_free(buf);
3355 }
3356
3357 return ret;
3358}
3359
3360/**
3361 * send_set_smps_params_cmd_tlv() - set smps params
3362 * @wmi_handle: wmi handle
3363 * @vdev_id: vdev id
3364 * @value: value
3365 *
Govind Singhb53420c2016-03-09 14:32:57 +05303366 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303367 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303368static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303369 int value)
3370{
Govind Singh67922e82016-04-01 16:48:57 +05303371 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303372 wmi_sta_smps_param_cmd_fixed_param *cmd;
3373 wmi_buf_t buf;
3374 uint16_t len = sizeof(*cmd);
3375
3376 buf = wmi_buf_alloc(wmi_handle, len);
3377 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303378 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303379 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303380 }
3381 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3382 WMITLV_SET_HDR(&cmd->tlv_header,
3383 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3384 WMITLV_GET_STRUCT_TLVLEN
3385 (wmi_sta_smps_param_cmd_fixed_param));
3386
3387 cmd->vdev_id = vdev_id;
3388 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3389 cmd->param =
3390 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3391
Govind Singhb53420c2016-03-09 14:32:57 +05303392 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303393 cmd->param);
3394
3395 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3396 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303397 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303398 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303399 wmi_buf_free(buf);
3400 }
3401
3402 return ret;
3403}
3404
3405/**
3406 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3407 * @wmi_handle: wmi handle
3408 * @noa: p2p power save parameters
3409 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303410 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303411 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303412static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303413 struct p2p_ps_params *noa)
3414{
3415 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3416 wmi_p2p_noa_descriptor *noa_discriptor;
3417 wmi_buf_t buf;
3418 uint8_t *buf_ptr;
3419 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303420 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303421 uint32_t duration;
3422
Govind Singhb53420c2016-03-09 14:32:57 +05303423 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303424 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3425 buf = wmi_buf_alloc(wmi_handle, len);
3426 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303427 WMI_LOGE("Failed to allocate memory");
3428 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303429 goto end;
3430 }
3431
3432 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3433 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3434 WMITLV_SET_HDR(&cmd->tlv_header,
3435 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3436 WMITLV_GET_STRUCT_TLVLEN
3437 (wmi_p2p_set_noa_cmd_fixed_param));
3438 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3439 cmd->vdev_id = noa->session_id;
3440 cmd->enable = (duration) ? true : false;
3441 cmd->num_noa = 1;
3442
3443 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3444 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3445 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3446 sizeof
3447 (wmi_p2p_set_noa_cmd_fixed_param)
3448 + WMI_TLV_HDR_SIZE);
3449 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3450 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3451 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3452 noa_discriptor->type_count = noa->count;
3453 noa_discriptor->duration = duration;
3454 noa_discriptor->interval = noa->interval;
3455 noa_discriptor->start_time = 0;
3456
Govind Singhb53420c2016-03-09 14:32:57 +05303457 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303458 cmd->vdev_id, noa->count, noa_discriptor->duration,
3459 noa->interval);
3460 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3461 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303462 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303463 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303464 wmi_buf_free(buf);
3465 }
3466
3467end:
Govind Singhb53420c2016-03-09 14:32:57 +05303468 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303469 return status;
3470}
3471
3472
3473/**
3474 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3475 * @wmi_handle: wmi handle
3476 * @noa: p2p opp power save parameters
3477 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303478 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303479 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303480static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303481 struct p2p_ps_params *oppps)
3482{
3483 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3484 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303485 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303486
Govind Singhb53420c2016-03-09 14:32:57 +05303487 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303488 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3489 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303490 WMI_LOGE("Failed to allocate memory");
3491 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303492 goto end;
3493 }
3494
3495 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3496 WMITLV_SET_HDR(&cmd->tlv_header,
3497 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3498 WMITLV_GET_STRUCT_TLVLEN
3499 (wmi_p2p_set_oppps_cmd_fixed_param));
3500 cmd->vdev_id = oppps->session_id;
3501 if (oppps->ctwindow)
3502 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3503
3504 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303505 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303506 cmd->vdev_id, oppps->ctwindow);
3507 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3508 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303509 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303510 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303511 wmi_buf_free(buf);
3512 }
3513
3514end:
Govind Singhb53420c2016-03-09 14:32:57 +05303515 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303516 return status;
3517}
3518
Wu Gaocd3a8512017-03-13 20:17:34 +08003519#ifdef CONVERGED_P2P_ENABLE
3520/**
3521 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3522 * @wmi_handle: wmi handle
3523 * @param: p2p listen offload start parameters
3524 *
3525 * Return: QDF status
3526 */
3527static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3528 struct p2p_lo_start *param)
3529{
3530 wmi_buf_t buf;
3531 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3532 int32_t len = sizeof(*cmd);
3533 uint8_t *buf_ptr;
3534 QDF_STATUS status;
3535 int device_types_len_aligned;
3536 int probe_resp_len_aligned;
3537
3538 if (!param) {
3539 WMI_LOGE("lo start param is null");
3540 return QDF_STATUS_E_INVAL;
3541 }
3542
3543 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3544
3545 device_types_len_aligned =
3546 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303547 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003548 probe_resp_len_aligned =
3549 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303550 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003551
3552 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3553 probe_resp_len_aligned;
3554
3555 buf = wmi_buf_alloc(wmi_handle, len);
3556 if (!buf) {
3557 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3558 __func__);
3559 return QDF_STATUS_E_NOMEM;
3560 }
3561
3562 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3563 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3564
3565 WMITLV_SET_HDR(&cmd->tlv_header,
3566 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3567 WMITLV_GET_STRUCT_TLVLEN(
3568 wmi_p2p_lo_start_cmd_fixed_param));
3569
3570 cmd->vdev_id = param->vdev_id;
3571 cmd->ctl_flags = param->ctl_flags;
3572 cmd->channel = param->freq;
3573 cmd->period = param->period;
3574 cmd->interval = param->interval;
3575 cmd->count = param->count;
3576 cmd->device_types_len = param->dev_types_len;
3577 cmd->prob_resp_len = param->probe_resp_len;
3578
3579 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3580 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3581 device_types_len_aligned);
3582 buf_ptr += WMI_TLV_HDR_SIZE;
3583 qdf_mem_copy(buf_ptr, param->device_types,
3584 param->dev_types_len);
3585
3586 buf_ptr += device_types_len_aligned;
3587 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3588 probe_resp_len_aligned);
3589 buf_ptr += WMI_TLV_HDR_SIZE;
3590 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3591 param->probe_resp_len);
3592
3593 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3594 cmd->channel, cmd->period, cmd->interval, cmd->count);
3595
3596 status = wmi_unified_cmd_send(wmi_handle,
3597 buf, len,
3598 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3599 if (status != QDF_STATUS_SUCCESS) {
3600 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3601 __func__, status);
3602 wmi_buf_free(buf);
3603 return status;
3604 }
3605
3606 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3607
3608 return QDF_STATUS_SUCCESS;
3609}
3610
3611/**
3612 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3613 * @wmi_handle: wmi handle
3614 * @param: p2p listen offload stop parameters
3615 *
3616 * Return: QDF status
3617 */
3618static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3619 uint8_t vdev_id)
3620{
3621 wmi_buf_t buf;
3622 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3623 int32_t len;
3624 QDF_STATUS status;
3625
3626 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3627
3628 len = sizeof(*cmd);
3629 buf = wmi_buf_alloc(wmi_handle, len);
3630 if (!buf) {
3631 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3632 __func__);
3633 return QDF_STATUS_E_NOMEM;
3634 }
3635 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3636
3637 WMITLV_SET_HDR(&cmd->tlv_header,
3638 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3639 WMITLV_GET_STRUCT_TLVLEN(
3640 wmi_p2p_lo_stop_cmd_fixed_param));
3641
3642 cmd->vdev_id = vdev_id;
3643
3644 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3645
3646 status = wmi_unified_cmd_send(wmi_handle,
3647 buf, len,
3648 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3649 if (status != QDF_STATUS_SUCCESS) {
3650 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3651 __func__, status);
3652 wmi_buf_free(buf);
3653 return status;
3654 }
3655
3656 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3657
3658 return QDF_STATUS_SUCCESS;
3659}
3660#endif /* End of CONVERGED_P2P_ENABLE */
3661
Govind Singh427ee5a2016-02-26 18:09:36 +05303662/**
3663 * send_get_temperature_cmd_tlv() - get pdev temperature req
3664 * @wmi_handle: wmi handle
3665 *
Govind Singhb53420c2016-03-09 14:32:57 +05303666 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303667 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303668static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303669{
3670 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3671 wmi_buf_t wmi_buf;
3672 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3673 uint8_t *buf_ptr;
3674
3675 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303676 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3677 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303678 }
3679
3680 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3681 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303682 WMI_LOGE(FL("wmi_buf_alloc failed"));
3683 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303684 }
3685
3686 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3687
3688 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3689 WMITLV_SET_HDR(&cmd->tlv_header,
3690 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3691 WMITLV_GET_STRUCT_TLVLEN
3692 (wmi_pdev_get_temperature_cmd_fixed_param));
3693
3694 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3695 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303696 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303697 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303698 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303699 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303700
Govind Singhb53420c2016-03-09 14:32:57 +05303701 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303702}
3703
3704/**
3705 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3706 * @wmi_handle: wmi handle
3707 * @vdevid: vdev id
3708 * @peer_addr: peer mac address
3709 * @auto_triggerparam: auto trigger parameters
3710 * @num_ac: number of access category
3711 *
3712 * This function sets the trigger
3713 * uapsd params such as service interval, delay interval
3714 * and suspend interval which will be used by the firmware
3715 * to send trigger frames periodically when there is no
3716 * traffic on the transmit side.
3717 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303718 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303719 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303720static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303721 struct sta_uapsd_trig_params *param)
3722{
3723 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303724 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303725 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3726 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3727 uint32_t i;
3728 wmi_buf_t buf;
3729 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003730 struct sta_uapsd_params *uapsd_param;
3731 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303732
3733 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3734 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303735 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303736 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303737 }
3738
3739 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3740 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3741 WMITLV_SET_HDR(&cmd->tlv_header,
3742 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3743 WMITLV_GET_STRUCT_TLVLEN
3744 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3745 cmd->vdev_id = param->vdevid;
3746 cmd->num_ac = param->num_ac;
3747 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3748
3749 /* TLV indicating array of structures to follow */
3750 buf_ptr += sizeof(*cmd);
3751 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3752
3753 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303754
3755 /*
3756 * Update tag and length for uapsd auto trigger params (this will take
3757 * care of updating tag and length if it is not pre-filled by caller).
3758 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003759 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3760 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303761 for (i = 0; i < param->num_ac; i++) {
3762 WMITLV_SET_HDR((buf_ptr +
3763 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3764 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3765 WMITLV_GET_STRUCT_TLVLEN
3766 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003767 trig_param->wmm_ac = uapsd_param->wmm_ac;
3768 trig_param->user_priority = uapsd_param->user_priority;
3769 trig_param->service_interval = uapsd_param->service_interval;
3770 trig_param->suspend_interval = uapsd_param->suspend_interval;
3771 trig_param->delay_interval = uapsd_param->delay_interval;
3772 trig_param++;
3773 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303774 }
3775
3776 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3777 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303778 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303779 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303780 wmi_buf_free(buf);
3781 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303782
Govind Singh427ee5a2016-02-26 18:09:36 +05303783 return ret;
3784}
3785
Zhang Qian11c0de32018-01-05 16:50:53 +08003786#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303787/**
3788 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3789 * @wmi_handle: pointer to the wmi handle
3790 * @utc: pointer to the UTC time struct
3791 *
3792 * Return: 0 on succes
3793 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303794static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303795 struct ocb_utc_param *utc)
3796{
Govind Singh67922e82016-04-01 16:48:57 +05303797 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303798 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3799 uint8_t *buf_ptr;
3800 uint32_t len, i;
3801 wmi_buf_t buf;
3802
3803 len = sizeof(*cmd);
3804 buf = wmi_buf_alloc(wmi_handle, len);
3805 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303806 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303807 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303808 }
3809
3810 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3811 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3812 WMITLV_SET_HDR(&cmd->tlv_header,
3813 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3814 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3815 cmd->vdev_id = utc->vdev_id;
3816
3817 for (i = 0; i < SIZE_UTC_TIME; i++)
3818 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3819
3820 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3821 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3822
3823 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3824 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303825 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303826 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303827 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303828 }
3829
Govind Singh67922e82016-04-01 16:48:57 +05303830 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303831}
3832
3833/**
3834 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3835 * frames on a channel
3836 * @wmi_handle: pointer to the wmi handle
3837 * @timing_advert: pointer to the timing advertisement struct
3838 *
3839 * Return: 0 on succes
3840 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303841static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303842 struct ocb_timing_advert_param *timing_advert)
3843{
Govind Singh67922e82016-04-01 16:48:57 +05303844 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303845 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3846 uint8_t *buf_ptr;
3847 uint32_t len, len_template;
3848 wmi_buf_t buf;
3849
3850 len = sizeof(*cmd) +
3851 WMI_TLV_HDR_SIZE;
3852
3853 len_template = timing_advert->template_length;
3854 /* Add padding to the template if needed */
3855 if (len_template % 4 != 0)
3856 len_template += 4 - (len_template % 4);
3857 len += len_template;
3858
3859 buf = wmi_buf_alloc(wmi_handle, len);
3860 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303861 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303862 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303863 }
3864
3865 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3866 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3867 WMITLV_SET_HDR(&cmd->tlv_header,
3868 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3869 WMITLV_GET_STRUCT_TLVLEN(
3870 wmi_ocb_start_timing_advert_cmd_fixed_param));
3871 cmd->vdev_id = timing_advert->vdev_id;
3872 cmd->repeat_rate = timing_advert->repeat_rate;
3873 cmd->channel_freq = timing_advert->chan_freq;
3874 cmd->timestamp_offset = timing_advert->timestamp_offset;
3875 cmd->time_value_offset = timing_advert->time_value_offset;
3876 cmd->timing_advert_template_length = timing_advert->template_length;
3877 buf_ptr += sizeof(*cmd);
3878
3879 /* Add the timing advert template */
3880 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3881 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303882 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303883 (uint8_t *)timing_advert->template_value,
3884 timing_advert->template_length);
3885
3886 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3887 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303888 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303889 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303890 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303891 }
3892
Govind Singh67922e82016-04-01 16:48:57 +05303893 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303894}
3895
3896/**
3897 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3898 * on a channel
3899 * @wmi_handle: pointer to the wmi handle
3900 * @timing_advert: pointer to the timing advertisement struct
3901 *
3902 * Return: 0 on succes
3903 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303904static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303905 struct ocb_timing_advert_param *timing_advert)
3906{
Govind Singh67922e82016-04-01 16:48:57 +05303907 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303908 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3909 uint8_t *buf_ptr;
3910 uint32_t len;
3911 wmi_buf_t buf;
3912
3913 len = sizeof(*cmd);
3914 buf = wmi_buf_alloc(wmi_handle, len);
3915 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303916 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303917 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303918 }
3919
3920 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3921 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3922 WMITLV_SET_HDR(&cmd->tlv_header,
3923 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3924 WMITLV_GET_STRUCT_TLVLEN(
3925 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3926 cmd->vdev_id = timing_advert->vdev_id;
3927 cmd->channel_freq = timing_advert->chan_freq;
3928
3929 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3930 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303931 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303932 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303933 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303934 }
3935
Govind Singh67922e82016-04-01 16:48:57 +05303936 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303937}
3938
3939/**
3940 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3941 * @wmi_handle: pointer to the wmi handle
3942 * @request: pointer to the request
3943 *
3944 * Return: 0 on succes
3945 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303946static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303947 uint8_t vdev_id)
3948{
Govind Singhb53420c2016-03-09 14:32:57 +05303949 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303950 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3951 uint8_t *buf_ptr;
3952 wmi_buf_t buf;
3953 int32_t len;
3954
3955 len = sizeof(*cmd);
3956 buf = wmi_buf_alloc(wmi_handle, len);
3957 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303958 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303959 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303960 }
3961 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3962
3963 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303964 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303965 WMITLV_SET_HDR(&cmd->tlv_header,
3966 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3967 WMITLV_GET_STRUCT_TLVLEN(
3968 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3969 cmd->vdev_id = vdev_id;
3970
3971 /* Send the WMI command */
3972 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3973 WMI_OCB_GET_TSF_TIMER_CMDID);
3974 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303975 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303976 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303977 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303978 }
3979
Govind Singh67922e82016-04-01 16:48:57 +05303980 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303981}
3982
3983/**
3984 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3985 * @wmi_handle: pointer to the wmi handle
3986 * @get_stats_param: pointer to the dcc stats
3987 *
3988 * Return: 0 on succes
3989 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303990static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08003991 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05303992{
Govind Singh67922e82016-04-01 16:48:57 +05303993 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303994 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3995 wmi_dcc_channel_stats_request *channel_stats_array;
3996 wmi_buf_t buf;
3997 uint8_t *buf_ptr;
3998 uint32_t len;
3999 uint32_t i;
4000
4001 /* Validate the input */
4002 if (get_stats_param->request_array_len !=
4003 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304004 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304005 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304006 }
4007
4008 /* Allocate memory for the WMI command */
4009 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4010 get_stats_param->request_array_len;
4011
4012 buf = wmi_buf_alloc(wmi_handle, len);
4013 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304014 WMI_LOGE(FL("wmi_buf_alloc failed"));
4015 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304016 }
4017
4018 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304019 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304020
4021 /* Populate the WMI command */
4022 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4023 buf_ptr += sizeof(*cmd);
4024
4025 WMITLV_SET_HDR(&cmd->tlv_header,
4026 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4027 WMITLV_GET_STRUCT_TLVLEN(
4028 wmi_dcc_get_stats_cmd_fixed_param));
4029 cmd->vdev_id = get_stats_param->vdev_id;
4030 cmd->num_channels = get_stats_param->channel_count;
4031
4032 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4033 get_stats_param->request_array_len);
4034 buf_ptr += WMI_TLV_HDR_SIZE;
4035
4036 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304037 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304038 get_stats_param->request_array_len);
4039 for (i = 0; i < cmd->num_channels; i++)
4040 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4041 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4042 WMITLV_GET_STRUCT_TLVLEN(
4043 wmi_dcc_channel_stats_request));
4044
4045 /* Send the WMI command */
4046 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4047 WMI_DCC_GET_STATS_CMDID);
4048
Govind Singh67922e82016-04-01 16:48:57 +05304049 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304050 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304051 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304052 }
4053
Govind Singh67922e82016-04-01 16:48:57 +05304054 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304055}
4056
4057/**
4058 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4059 * @wmi_handle: pointer to the wmi handle
4060 * @vdev_id: vdev id
4061 * @dcc_stats_bitmap: dcc status bitmap
4062 *
4063 * Return: 0 on succes
4064 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304065static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304066 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4067{
Govind Singh67922e82016-04-01 16:48:57 +05304068 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304069 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4070 wmi_buf_t buf;
4071 uint8_t *buf_ptr;
4072 uint32_t len;
4073
4074 /* Allocate memory for the WMI command */
4075 len = sizeof(*cmd);
4076
4077 buf = wmi_buf_alloc(wmi_handle, len);
4078 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304079 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304080 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304081 }
4082
4083 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304084 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304085
4086 /* Populate the WMI command */
4087 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4088
4089 WMITLV_SET_HDR(&cmd->tlv_header,
4090 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4091 WMITLV_GET_STRUCT_TLVLEN(
4092 wmi_dcc_clear_stats_cmd_fixed_param));
4093 cmd->vdev_id = vdev_id;
4094 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4095
4096 /* Send the WMI command */
4097 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4098 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304099 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304100 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304101 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304102 }
4103
Govind Singh67922e82016-04-01 16:48:57 +05304104 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304105}
4106
4107/**
4108 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4109 * @wmi_handle: pointer to the wmi handle
4110 * @update_ndl_param: pointer to the request parameters
4111 *
4112 * Return: 0 on success
4113 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304114static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004115 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304116{
Govind Singhb53420c2016-03-09 14:32:57 +05304117 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304118 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4119 wmi_dcc_ndl_chan *ndl_chan_array;
4120 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4121 uint32_t active_state_count;
4122 wmi_buf_t buf;
4123 uint8_t *buf_ptr;
4124 uint32_t len;
4125 uint32_t i;
4126
4127 /* validate the input */
4128 if (update_ndl_param->dcc_ndl_chan_list_len !=
4129 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304130 WMI_LOGE(FL("Invalid parameter"));
4131 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304132 }
4133 active_state_count = 0;
4134 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4135 for (i = 0; i < update_ndl_param->channel_count; i++)
4136 active_state_count +=
4137 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4138 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4139 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304140 WMI_LOGE(FL("Invalid parameter"));
4141 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304142 }
4143
4144 /* Allocate memory for the WMI command */
4145 len = sizeof(*cmd) +
4146 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4147 WMI_TLV_HDR_SIZE +
4148 update_ndl_param->dcc_ndl_active_state_list_len;
4149
4150 buf = wmi_buf_alloc(wmi_handle, len);
4151 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304152 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304153 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304154 }
4155
4156 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304157 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304158
4159 /* Populate the WMI command */
4160 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4161 buf_ptr += sizeof(*cmd);
4162
4163 WMITLV_SET_HDR(&cmd->tlv_header,
4164 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4165 WMITLV_GET_STRUCT_TLVLEN(
4166 wmi_dcc_update_ndl_cmd_fixed_param));
4167 cmd->vdev_id = update_ndl_param->vdev_id;
4168 cmd->num_channel = update_ndl_param->channel_count;
4169
4170 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4171 update_ndl_param->dcc_ndl_chan_list_len);
4172 buf_ptr += WMI_TLV_HDR_SIZE;
4173
4174 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304175 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304176 update_ndl_param->dcc_ndl_chan_list_len);
4177 for (i = 0; i < cmd->num_channel; i++)
4178 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4179 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4180 WMITLV_GET_STRUCT_TLVLEN(
4181 wmi_dcc_ndl_chan));
4182 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4183
4184 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4185 update_ndl_param->dcc_ndl_active_state_list_len);
4186 buf_ptr += WMI_TLV_HDR_SIZE;
4187
4188 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304189 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304190 update_ndl_param->dcc_ndl_active_state_list,
4191 update_ndl_param->dcc_ndl_active_state_list_len);
4192 for (i = 0; i < active_state_count; i++) {
4193 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4194 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4195 WMITLV_GET_STRUCT_TLVLEN(
4196 wmi_dcc_ndl_active_state_config));
4197 }
4198 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4199
4200 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304201 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304202 WMI_DCC_UPDATE_NDL_CMDID);
4203 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304204 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304205 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304206 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304207 }
4208
Govind Singh67922e82016-04-01 16:48:57 +05304209 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304210}
4211
4212/**
4213 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4214 * @wmi_handle: pointer to the wmi handle
4215 * @config: the OCB configuration
4216 *
4217 * Return: 0 on success
4218 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304219static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004220 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304221{
Govind Singh67922e82016-04-01 16:48:57 +05304222 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304223 wmi_ocb_set_config_cmd_fixed_param *cmd;
4224 wmi_channel *chan;
4225 wmi_ocb_channel *ocb_chan;
4226 wmi_qos_parameter *qos_param;
4227 wmi_dcc_ndl_chan *ndl_chan;
4228 wmi_dcc_ndl_active_state_config *ndl_active_config;
4229 wmi_ocb_schedule_element *sched_elem;
4230 uint8_t *buf_ptr;
4231 wmi_buf_t buf;
4232 int32_t len;
4233 int32_t i, j, active_state_count;
4234
4235 /*
4236 * Validate the dcc_ndl_chan_list_len and count the number of active
4237 * states. Validate dcc_ndl_active_state_list_len.
4238 */
4239 active_state_count = 0;
4240 if (config->dcc_ndl_chan_list_len) {
4241 if (!config->dcc_ndl_chan_list ||
4242 config->dcc_ndl_chan_list_len !=
4243 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304244 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304245 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304246 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304247 }
4248
4249 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4250 i < config->channel_count; ++i, ++ndl_chan)
4251 active_state_count +=
4252 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4253
4254 if (active_state_count) {
4255 if (!config->dcc_ndl_active_state_list ||
4256 config->dcc_ndl_active_state_list_len !=
4257 active_state_count *
4258 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304259 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304260 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304261 }
4262 }
4263 }
4264
4265 len = sizeof(*cmd) +
4266 WMI_TLV_HDR_SIZE + config->channel_count *
4267 sizeof(wmi_channel) +
4268 WMI_TLV_HDR_SIZE + config->channel_count *
4269 sizeof(wmi_ocb_channel) +
4270 WMI_TLV_HDR_SIZE + config->channel_count *
4271 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4272 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4273 WMI_TLV_HDR_SIZE + active_state_count *
4274 sizeof(wmi_dcc_ndl_active_state_config) +
4275 WMI_TLV_HDR_SIZE + config->schedule_size *
4276 sizeof(wmi_ocb_schedule_element);
4277 buf = wmi_buf_alloc(wmi_handle, len);
4278 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304279 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304280 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304281 }
4282
4283 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4284 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4285 WMITLV_SET_HDR(&cmd->tlv_header,
4286 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4287 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004288 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304289 cmd->channel_count = config->channel_count;
4290 cmd->schedule_size = config->schedule_size;
4291 cmd->flags = config->flags;
4292 buf_ptr += sizeof(*cmd);
4293
4294 /* Add the wmi_channel info */
4295 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4296 config->channel_count*sizeof(wmi_channel));
4297 buf_ptr += WMI_TLV_HDR_SIZE;
4298 for (i = 0; i < config->channel_count; i++) {
4299 chan = (wmi_channel *)buf_ptr;
4300 WMITLV_SET_HDR(&chan->tlv_header,
4301 WMITLV_TAG_STRUC_wmi_channel,
4302 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4303 chan->mhz = config->channels[i].chan_freq;
4304 chan->band_center_freq1 = config->channels[i].chan_freq;
4305 chan->band_center_freq2 = 0;
4306 chan->info = 0;
4307
Zhang Qian11c0de32018-01-05 16:50:53 +08004308 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304309 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4310 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4311 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4312 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4313 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4314 config->channels[i].antenna_max);
4315
4316 if (config->channels[i].bandwidth < 10)
4317 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4318 else if (config->channels[i].bandwidth < 20)
4319 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4320 buf_ptr += sizeof(*chan);
4321 }
4322
4323 /* Add the wmi_ocb_channel info */
4324 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4325 config->channel_count*sizeof(wmi_ocb_channel));
4326 buf_ptr += WMI_TLV_HDR_SIZE;
4327 for (i = 0; i < config->channel_count; i++) {
4328 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4329 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4330 WMITLV_TAG_STRUC_wmi_ocb_channel,
4331 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4332 ocb_chan->bandwidth = config->channels[i].bandwidth;
4333 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4334 config->channels[i].mac_address.bytes,
4335 &ocb_chan->mac_address);
4336 buf_ptr += sizeof(*ocb_chan);
4337 }
4338
4339 /* Add the wmi_qos_parameter info */
4340 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4341 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4342 buf_ptr += WMI_TLV_HDR_SIZE;
4343 /* WMI_MAX_NUM_AC parameters for each channel */
4344 for (i = 0; i < config->channel_count; i++) {
4345 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4346 qos_param = (wmi_qos_parameter *)buf_ptr;
4347 WMITLV_SET_HDR(&qos_param->tlv_header,
4348 WMITLV_TAG_STRUC_wmi_qos_parameter,
4349 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4350 qos_param->aifsn =
4351 config->channels[i].qos_params[j].aifsn;
4352 qos_param->cwmin =
4353 config->channels[i].qos_params[j].cwmin;
4354 qos_param->cwmax =
4355 config->channels[i].qos_params[j].cwmax;
4356 buf_ptr += sizeof(*qos_param);
4357 }
4358 }
4359
4360 /* Add the wmi_dcc_ndl_chan (per channel) */
4361 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4362 config->dcc_ndl_chan_list_len);
4363 buf_ptr += WMI_TLV_HDR_SIZE;
4364 if (config->dcc_ndl_chan_list_len) {
4365 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304366 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304367 config->dcc_ndl_chan_list_len);
4368 for (i = 0; i < config->channel_count; i++)
4369 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4370 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4371 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4372 buf_ptr += config->dcc_ndl_chan_list_len;
4373 }
4374
4375 /* Add the wmi_dcc_ndl_active_state_config */
4376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4377 sizeof(wmi_dcc_ndl_active_state_config));
4378 buf_ptr += WMI_TLV_HDR_SIZE;
4379 if (active_state_count) {
4380 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304381 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304382 config->dcc_ndl_active_state_list,
4383 active_state_count * sizeof(*ndl_active_config));
4384 for (i = 0; i < active_state_count; ++i)
4385 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4386 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4387 WMITLV_GET_STRUCT_TLVLEN(
4388 wmi_dcc_ndl_active_state_config));
4389 buf_ptr += active_state_count *
4390 sizeof(*ndl_active_config);
4391 }
4392
4393 /* Add the wmi_ocb_schedule_element info */
4394 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4395 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4396 buf_ptr += WMI_TLV_HDR_SIZE;
4397 for (i = 0; i < config->schedule_size; i++) {
4398 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4399 WMITLV_SET_HDR(&sched_elem->tlv_header,
4400 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4401 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4402 sched_elem->channel_freq = config->schedule[i].chan_freq;
4403 sched_elem->total_duration = config->schedule[i].total_duration;
4404 sched_elem->guard_interval = config->schedule[i].guard_interval;
4405 buf_ptr += sizeof(*sched_elem);
4406 }
4407
4408
4409 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4410 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304411 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304412 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304413 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304414 }
4415
Govind Singh67922e82016-04-01 16:48:57 +05304416 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304417}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304418
4419/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004420 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4421 * @wmi_handle: wmi handle
4422 * @evt_buf: wmi event buffer
4423 * @status: status buffer
4424 *
4425 * Return: QDF_STATUS_SUCCESS on success
4426 */
4427static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4428 void *evt_buf,
4429 uint32_t *status)
4430{
4431 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4432 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4433
4434 param_tlvs = evt_buf;
4435 fix_param = param_tlvs->fixed_param;
4436
4437 *status = fix_param->status;
4438 return QDF_STATUS_SUCCESS;
4439}
4440
4441/**
4442 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4443 * @wmi_handle: wmi handle
4444 * @evt_buf: wmi event buffer
4445 * @resp: response buffer
4446 *
4447 * Return: QDF_STATUS_SUCCESS on success
4448 */
4449static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4450 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4451{
4452 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4453 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4454
4455 param_tlvs = evt_buf;
4456 fix_param = param_tlvs->fixed_param;
4457 resp->vdev_id = fix_param->vdev_id;
4458 resp->timer_high = fix_param->tsf_timer_high;
4459 resp->timer_low = fix_param->tsf_timer_low;
4460
4461 return QDF_STATUS_SUCCESS;
4462}
4463
4464/**
4465 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4466 * @wmi_handle: wmi handle
4467 * @evt_buf: wmi event buffer
4468 * @resp: response buffer
4469 *
4470 * Return: QDF_STATUS_SUCCESS on success
4471 */
4472static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4473 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4474{
4475 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4476 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4477
4478 param_tlvs = evt_buf;
4479 fix_param = param_tlvs->fixed_param;
4480 resp->vdev_id = fix_param->vdev_id;
4481 resp->status = fix_param->status;
4482 return QDF_STATUS_SUCCESS;
4483}
4484
4485/**
4486 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4487 * @wmi_handle: wmi handle
4488 * @evt_buf: wmi event buffer
4489 * @resp: response buffer
4490 *
4491 * Since length of stats is variable, buffer for DCC stats will be allocated
4492 * in this function. The caller must free the buffer.
4493 *
4494 * Return: QDF_STATUS_SUCCESS on success
4495 */
4496static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4497 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4498{
4499 struct ocb_dcc_get_stats_response *response;
4500 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4501 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4502
4503 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4504 fix_param = param_tlvs->fixed_param;
4505
4506 /* Allocate and populate the response */
4507 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4508 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4509 WMI_LOGE("%s: too many channels:%d", __func__,
4510 fix_param->num_channels);
4511 QDF_ASSERT(0);
4512 *resp = NULL;
4513 return QDF_STATUS_E_INVAL;
4514 }
4515 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4516 sizeof(wmi_dcc_ndl_stats_per_channel));
4517 *resp = response;
4518 if (!response)
4519 return QDF_STATUS_E_NOMEM;
4520
4521 response->vdev_id = fix_param->vdev_id;
4522 response->num_channels = fix_param->num_channels;
4523 response->channel_stats_array_len =
4524 fix_param->num_channels *
4525 sizeof(wmi_dcc_ndl_stats_per_channel);
4526 response->channel_stats_array = ((uint8_t *)response) +
4527 sizeof(*response);
4528 qdf_mem_copy(response->channel_stats_array,
4529 param_tlvs->stats_per_channel_list,
4530 response->channel_stats_array_len);
4531
4532 return QDF_STATUS_SUCCESS;
4533}
4534#endif
4535
4536/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304537 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4538 * @wmi_handle: wmi handle
4539 * @mcc_adaptive_scheduler: enable/disable
4540 *
4541 * This function enable/disable mcc adaptive scheduler in fw.
4542 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -07004543 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304544 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304545static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004546 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4547 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304548{
Govind Singh67922e82016-04-01 16:48:57 +05304549 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304550 wmi_buf_t buf = 0;
4551 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4552 uint16_t len =
4553 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4554
4555 buf = wmi_buf_alloc(wmi_handle, len);
4556 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304557 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4558 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304559 }
4560 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4561 wmi_buf_data(buf);
4562
4563 WMITLV_SET_HDR(&cmd->tlv_header,
4564 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4565 WMITLV_GET_STRUCT_TLVLEN
4566 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4567 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304568 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304569
4570 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4571 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304572 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304573 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304574 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304575 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304576 }
Govind Singh67922e82016-04-01 16:48:57 +05304577
4578 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304579}
4580
4581/**
4582 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4583 * @wmi: wmi handle
4584 * @mcc_channel: mcc channel
4585 * @mcc_channel_time_latency: MCC channel time latency.
4586 *
4587 * Currently used to set time latency for an MCC vdev/adapter using operating
4588 * channel of it and channel number. The info is provided run time using
4589 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4590 *
4591 * Return: CDF status
4592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304593static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304594 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4595{
Govind Singh67922e82016-04-01 16:48:57 +05304596 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304597 wmi_buf_t buf = 0;
4598 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4599 uint16_t len = 0;
4600 uint8_t *buf_ptr = NULL;
4601 wmi_resmgr_chan_latency chan_latency;
4602 /* Note: we only support MCC time latency for a single channel */
4603 uint32_t num_channels = 1;
4604 uint32_t chan1_freq = mcc_channel_freq;
4605 uint32_t latency_chan1 = mcc_channel_time_latency;
4606
4607
4608 /* If 0ms latency is provided, then FW will set to a default.
4609 * Otherwise, latency must be at least 30ms.
4610 */
4611 if ((latency_chan1 > 0) &&
4612 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304613 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304614 "Minimum is 30ms (or 0 to use default value by "
4615 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304616 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304617 }
4618
4619 /* Set WMI CMD for channel time latency here */
4620 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4621 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4622 num_channels * sizeof(wmi_resmgr_chan_latency);
4623 buf = wmi_buf_alloc(wmi_handle, len);
4624 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304625 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4626 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304627 }
4628 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4629 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4630 wmi_buf_data(buf);
4631 WMITLV_SET_HDR(&cmdTL->tlv_header,
4632 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4633 WMITLV_GET_STRUCT_TLVLEN
4634 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4635 cmdTL->num_chans = num_channels;
4636 /* Update channel time latency information for home channel(s) */
4637 buf_ptr += sizeof(*cmdTL);
4638 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4639 num_channels * sizeof(wmi_resmgr_chan_latency));
4640 buf_ptr += WMI_TLV_HDR_SIZE;
4641 chan_latency.chan_mhz = chan1_freq;
4642 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304643 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304644 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4645 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304646 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304647 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304648 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304649 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304650 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304651 }
Govind Singh67922e82016-04-01 16:48:57 +05304652
4653 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304654}
4655
4656/**
4657 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4658 * @wmi: wmi handle
4659 * @adapter_1_chan_number: adapter 1 channel number
4660 * @adapter_1_quota: adapter 1 quota
4661 * @adapter_2_chan_number: adapter 2 channel number
4662 *
4663 * Return: CDF status
4664 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304665static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304666 uint32_t adapter_1_chan_freq,
4667 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4668{
Govind Singh67922e82016-04-01 16:48:57 +05304669 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304670 wmi_buf_t buf = 0;
4671 uint16_t len = 0;
4672 uint8_t *buf_ptr = NULL;
4673 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4674 wmi_resmgr_chan_time_quota chan_quota;
4675 uint32_t quota_chan1 = adapter_1_quota;
4676 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4677 uint32_t quota_chan2 = 100 - quota_chan1;
4678 /* Note: setting time quota for MCC requires info for 2 channels */
4679 uint32_t num_channels = 2;
4680 uint32_t chan1_freq = adapter_1_chan_freq;
4681 uint32_t chan2_freq = adapter_2_chan_freq;
4682
Govind Singhb53420c2016-03-09 14:32:57 +05304683 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304684 "freq2:%dMHz, Quota2:%dms", __func__,
4685 chan1_freq, quota_chan1, chan2_freq,
4686 quota_chan2);
4687
4688 /*
4689 * Perform sanity check on time quota values provided.
4690 */
4691 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4692 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304693 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304694 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304695 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304696 }
4697 /* Set WMI CMD for channel time quota here */
4698 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4699 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4700 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4701 buf = wmi_buf_alloc(wmi_handle, len);
4702 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304703 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4704 QDF_ASSERT(0);
4705 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304706 }
4707 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4708 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4709 wmi_buf_data(buf);
4710 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4711 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4712 WMITLV_GET_STRUCT_TLVLEN
4713 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4714 cmdTQ->num_chans = num_channels;
4715
4716 /* Update channel time quota information for home channel(s) */
4717 buf_ptr += sizeof(*cmdTQ);
4718 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4719 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4720 buf_ptr += WMI_TLV_HDR_SIZE;
4721 chan_quota.chan_mhz = chan1_freq;
4722 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304723 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304724 /* Construct channel and quota record for the 2nd MCC mode. */
4725 buf_ptr += sizeof(chan_quota);
4726 chan_quota.chan_mhz = chan2_freq;
4727 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304728 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304729
4730 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4731 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304732 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304733 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304734 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304735 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304736 }
Govind Singh67922e82016-04-01 16:48:57 +05304737
4738 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304739}
4740
4741/**
4742 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4743 * @wmi_handle: Pointer to wmi handle
4744 * @thermal_info: Thermal command information
4745 *
4746 * This function sends the thermal management command
4747 * to the firmware
4748 *
Govind Singhb53420c2016-03-09 14:32:57 +05304749 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304750 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304751static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304752 struct thermal_cmd_params *thermal_info)
4753{
4754 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4755 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304756 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304757 uint32_t len = 0;
4758
4759 len = sizeof(*cmd);
4760
4761 buf = wmi_buf_alloc(wmi_handle, len);
4762 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304763 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4764 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304765 }
4766
4767 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4768
4769 WMITLV_SET_HDR(&cmd->tlv_header,
4770 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4771 WMITLV_GET_STRUCT_TLVLEN
4772 (wmi_thermal_mgmt_cmd_fixed_param));
4773
4774 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4775 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4776 cmd->enable = thermal_info->thermal_enable;
4777
Govind Singhb53420c2016-03-09 14:32:57 +05304778 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304779 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4780
4781 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4782 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304783 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304784 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304785 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304786 }
4787
Govind Singh67922e82016-04-01 16:48:57 +05304788 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304789}
4790
4791
4792/**
4793 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304794 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304795 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4796 *
4797 * This function sends down the LRO configuration parameters to
4798 * the firmware to enable LRO, sets the TCP flags and sets the
4799 * seed values for the toeplitz hash generation
4800 *
Govind Singhb53420c2016-03-09 14:32:57 +05304801 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304802 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304803static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304804 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4805{
4806 wmi_lro_info_cmd_fixed_param *cmd;
4807 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304808 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304809
4810
4811 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4812 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304813 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4814 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304815 }
4816
4817 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4818
4819 WMITLV_SET_HDR(&cmd->tlv_header,
4820 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4821 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4822
4823 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4824 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4825 wmi_lro_cmd->tcp_flag);
4826 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4827 wmi_lro_cmd->tcp_flag_mask);
4828 cmd->toeplitz_hash_ipv4_0_3 =
4829 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4830 cmd->toeplitz_hash_ipv4_4_7 =
4831 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4832 cmd->toeplitz_hash_ipv4_8_11 =
4833 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4834 cmd->toeplitz_hash_ipv4_12_15 =
4835 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4836 cmd->toeplitz_hash_ipv4_16 =
4837 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4838
4839 cmd->toeplitz_hash_ipv6_0_3 =
4840 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4841 cmd->toeplitz_hash_ipv6_4_7 =
4842 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4843 cmd->toeplitz_hash_ipv6_8_11 =
4844 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4845 cmd->toeplitz_hash_ipv6_12_15 =
4846 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4847 cmd->toeplitz_hash_ipv6_16_19 =
4848 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4849 cmd->toeplitz_hash_ipv6_20_23 =
4850 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4851 cmd->toeplitz_hash_ipv6_24_27 =
4852 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4853 cmd->toeplitz_hash_ipv6_28_31 =
4854 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4855 cmd->toeplitz_hash_ipv6_32_35 =
4856 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4857 cmd->toeplitz_hash_ipv6_36_39 =
4858 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4859 cmd->toeplitz_hash_ipv6_40 =
4860 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4861
Govind Singhb53420c2016-03-09 14:32:57 +05304862 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304863 cmd->lro_enable, cmd->tcp_flag_u32);
4864
4865 status = wmi_unified_cmd_send(wmi_handle, buf,
4866 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304867 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304868 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304869 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304870 }
4871
Govind Singh67922e82016-04-01 16:48:57 +05304872 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304873}
4874
Govind Singh4eacd2b2016-03-07 14:24:22 +05304875/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304876 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4877 * @wmi_handle: Pointer to wmi handle
4878 * @rate_report_params: Pointer to peer rate report parameters
4879 *
4880 *
4881 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4882 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304883static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304884 struct wmi_peer_rate_report_params *rate_report_params)
4885{
4886 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4887 wmi_buf_t buf = NULL;
4888 QDF_STATUS status = 0;
4889 uint32_t len = 0;
4890 uint32_t i, j;
4891
4892 len = sizeof(*cmd);
4893
4894 buf = wmi_buf_alloc(wmi_handle, len);
4895 if (!buf) {
4896 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4897 return QDF_STATUS_E_FAILURE;
4898 }
4899
4900 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4901 wmi_buf_data(buf);
4902
4903 WMITLV_SET_HDR(
4904 &cmd->tlv_header,
4905 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4906 WMITLV_GET_STRUCT_TLVLEN(
4907 wmi_peer_set_rate_report_condition_fixed_param));
4908
4909 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4910 cmd->report_backoff_time = rate_report_params->backoff_time;
4911 cmd->report_timer_period = rate_report_params->timer_period;
4912 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4913 cmd->cond_per_phy[i].val_cond_flags =
4914 rate_report_params->report_per_phy[i].cond_flags;
4915 cmd->cond_per_phy[i].rate_delta.min_delta =
4916 rate_report_params->report_per_phy[i].delta.delta_min;
4917 cmd->cond_per_phy[i].rate_delta.percentage =
4918 rate_report_params->report_per_phy[i].delta.percent;
4919 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4920 cmd->cond_per_phy[i].rate_threshold[j] =
4921 rate_report_params->report_per_phy[i].
4922 report_rate_threshold[j];
4923 }
4924 }
4925
4926 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4927 cmd->enable_rate_report,
4928 cmd->report_backoff_time, cmd->report_timer_period);
4929
4930 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4931 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4932 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304933 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304934 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4935 __func__);
4936 }
4937 return status;
4938}
4939
4940/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304941 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4942 * @wmi_handle: wmi handle
4943 * @param: bcn ll cmd parameter
4944 *
Govind Singhb53420c2016-03-09 14:32:57 +05304945 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304946 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304947static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304948 wmi_bcn_send_from_host_cmd_fixed_param *param)
4949{
4950 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4951 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304952 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304953
4954 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4955 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304956 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4957 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304958 }
4959
4960 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4961 WMITLV_SET_HDR(&cmd->tlv_header,
4962 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4963 WMITLV_GET_STRUCT_TLVLEN
4964 (wmi_bcn_send_from_host_cmd_fixed_param));
4965 cmd->vdev_id = param->vdev_id;
4966 cmd->data_len = param->data_len;
4967 cmd->frame_ctrl = param->frame_ctrl;
4968 cmd->frag_ptr = param->frag_ptr;
4969 cmd->dtim_flag = param->dtim_flag;
4970
4971 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4972 WMI_PDEV_SEND_BCN_CMDID);
4973
Govind Singh67922e82016-04-01 16:48:57 +05304974 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304975 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304976 wmi_buf_free(wmi_buf);
4977 }
4978
4979 return ret;
4980}
4981
4982/**
4983 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4984 * @wmi_handle: wmi handle
4985 * @vdev_id: vdev id
4986 * @max_retries: max retries
4987 * @retry_interval: retry interval
4988 * This function sets sta query related parameters in fw.
4989 *
Govind Singhb53420c2016-03-09 14:32:57 +05304990 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304991 */
4992
Sathish Kumarfd347372017-02-13 12:29:09 +05304993static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304994 uint8_t vdev_id, uint32_t max_retries,
4995 uint32_t retry_interval)
4996{
4997 wmi_buf_t buf;
4998 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4999 int len;
5000
5001 len = sizeof(*cmd);
5002 buf = wmi_buf_alloc(wmi_handle, len);
5003 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305004 WMI_LOGE(FL("wmi_buf_alloc failed"));
5005 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305006 }
5007
5008 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5009 WMITLV_SET_HDR(&cmd->tlv_header,
5010 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5011 WMITLV_GET_STRUCT_TLVLEN
5012 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5013
5014
5015 cmd->vdev_id = vdev_id;
5016 cmd->sa_query_max_retry_count = max_retries;
5017 cmd->sa_query_retry_interval = retry_interval;
5018
Govind Singhb53420c2016-03-09 14:32:57 +05305019 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305020 vdev_id, retry_interval, max_retries);
5021
5022 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5023 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305024 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305025 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305026 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305027 }
5028
Govind Singhb53420c2016-03-09 14:32:57 +05305029 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305030 return 0;
5031}
5032
5033/**
5034 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5035 * @wmi_handle: wmi handle
5036 * @params: sta keep alive parameter
5037 *
5038 * This function sets keep alive related parameters in fw.
5039 *
5040 * Return: CDF status
5041 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305042static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305043 struct sta_params *params)
5044{
5045 wmi_buf_t buf;
5046 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5047 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5048 uint8_t *buf_ptr;
5049 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305050 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305051
Govind Singhb53420c2016-03-09 14:32:57 +05305052 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305053
Govind Singh4eacd2b2016-03-07 14:24:22 +05305054 len = sizeof(*cmd) + sizeof(*arp_rsp);
5055 buf = wmi_buf_alloc(wmi_handle, len);
5056 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305057 WMI_LOGE("wmi_buf_alloc failed");
5058 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305059 }
5060
5061 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5062 buf_ptr = (uint8_t *) cmd;
5063 WMITLV_SET_HDR(&cmd->tlv_header,
5064 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5065 WMITLV_GET_STRUCT_TLVLEN
5066 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5067 cmd->interval = params->timeperiod;
5068 cmd->enable = (params->timeperiod) ? 1 : 0;
5069 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305070 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305071 params->timeperiod, params->method);
5072 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5073 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5074 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5075 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5076
c_manjee2772b9c2017-01-23 15:14:13 +05305077 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5078 (params->method ==
5079 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305080 if ((NULL == params->hostv4addr) ||
5081 (NULL == params->destv4addr) ||
5082 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005083 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5084 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305085 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305086 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305087 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305088 }
c_manjee2772b9c2017-01-23 15:14:13 +05305089 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305090 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305091 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305092 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305093 WMI_IPV4_ADDR_LEN);
5094 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5095 } else {
5096 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5097 }
5098
Govind Singh67922e82016-04-01 16:48:57 +05305099 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5100 WMI_STA_KEEPALIVE_CMDID);
5101 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305102 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305103 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305104 }
5105
Govind Singhb53420c2016-03-09 14:32:57 +05305106 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305107 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305108}
5109
5110/**
5111 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5112 * @wmi_handle: wmi handle
5113 * @if_id: vdev id
5114 * @gtx_info: GTX config params
5115 *
5116 * This function set GTX related params in firmware.
5117 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305118 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305119 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305120static 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 +05305121 struct wmi_gtx_config *gtx_info)
5122{
5123 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5124 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305125 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305126 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305127
Govind Singh4eacd2b2016-03-07 14:24:22 +05305128 buf = wmi_buf_alloc(wmi_handle, len);
5129 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305130 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305131 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305132 }
5133 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5134 WMITLV_SET_HDR(&cmd->tlv_header,
5135 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5136 WMITLV_GET_STRUCT_TLVLEN
5137 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5138 cmd->vdev_id = if_id;
5139
5140 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5141 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5142 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5143 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5144 cmd->gtxPERMargin = gtx_info->gtx_margin;
5145 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5146 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5147 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5148
Govind Singhb53420c2016-03-09 14:32:57 +05305149 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305150 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5151 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5152 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5153 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5154
Abhishek Singh716c46c2016-05-04 16:24:07 +05305155 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305156 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305157 if (QDF_IS_STATUS_ERROR(ret)) {
5158 WMI_LOGE("Failed to set GTX PARAMS");
5159 wmi_buf_free(buf);
5160 }
5161 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305162}
5163
5164/**
5165 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5166 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305167 * @vdev_id: vdev id.
5168 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305169 *
5170 * This function updates EDCA parameters to the target
5171 *
5172 * Return: CDF Status
5173 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305174static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005175 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305176 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305177{
5178 uint8_t *buf_ptr;
5179 wmi_buf_t buf;
5180 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305181 wmi_wmm_vparams *wmm_param;
5182 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305183 int len = sizeof(*cmd);
5184 int ac;
5185
5186 buf = wmi_buf_alloc(wmi_handle, len);
5187
5188 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305189 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5190 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305191 }
5192
5193 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5194 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5195 WMITLV_SET_HDR(&cmd->tlv_header,
5196 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5197 WMITLV_GET_STRUCT_TLVLEN
5198 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5199 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005200 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305201
5202 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5203 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305204 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305205 WMITLV_SET_HDR(&wmm_param->tlv_header,
5206 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5207 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5208 wmm_param->cwmin = twmm_param->cwmin;
5209 wmm_param->cwmax = twmm_param->cwmax;
5210 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005211 if (mu_edca_param)
5212 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5213 else
5214 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305215 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305216 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305217 }
5218
5219 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5220 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5221 goto fail;
5222
Govind Singhb53420c2016-03-09 14:32:57 +05305223 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305224
5225fail:
5226 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305227 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5228 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305229}
5230
5231/**
5232 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5233 * @wmi_handle: wmi handle
5234 * @vdev_id: vdev id
5235 * @probe_rsp_info: probe response info
5236 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305237 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305238 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305239static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305240 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005241 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305242{
5243 wmi_prb_tmpl_cmd_fixed_param *cmd;
5244 wmi_bcn_prb_info *bcn_prb_info;
5245 wmi_buf_t wmi_buf;
5246 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5247 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305248 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305249
Govind Singhb53420c2016-03-09 14:32:57 +05305250 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305251
Krunal Soni89426862017-11-14 15:42:48 -08005252 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305253 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305254
5255 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5256 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5257 tmpl_len_aligned;
5258
5259 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305260 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305261 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305262 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305263 }
5264
5265 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5266 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305267 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305268 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305269 }
5270
5271 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5272
5273 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5274 WMITLV_SET_HDR(&cmd->tlv_header,
5275 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5276 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5277 cmd->vdev_id = vdev_id;
5278 cmd->buf_len = tmpl_len;
5279 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5280
5281 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5282 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5283 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5284 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5285 bcn_prb_info->caps = 0;
5286 bcn_prb_info->erp = 0;
5287 buf_ptr += sizeof(wmi_bcn_prb_info);
5288
5289 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5290 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005291 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305292
5293 ret = wmi_unified_cmd_send(wmi_handle,
5294 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305295 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305296 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305297 wmi_buf_free(wmi_buf);
5298 }
5299
5300 return ret;
5301}
5302
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305303#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305304#define WPI_IV_LEN 16
5305
5306/**
5307 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5308 *
5309 * @dest_tx: destination address of tsc key counter
5310 * @src_tx: source address of tsc key counter
5311 * @dest_rx: destination address of rsc key counter
5312 * @src_rx: source address of rsc key counter
5313 *
5314 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5315 *
5316 * Return: None
5317 *
5318 */
5319static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5320 uint8_t *dest_rx, uint8_t *src_rx)
5321{
5322 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5323 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5324}
5325#else
5326static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5327 uint8_t *dest_rx, uint8_t *src_rx)
5328{
5329 return;
5330}
5331#endif
5332
5333/**
5334 * send_setup_install_key_cmd_tlv() - set key parameters
5335 * @wmi_handle: wmi handle
5336 * @key_params: key parameters
5337 *
5338 * This function fills structure from information
5339 * passed in key_params.
5340 *
5341 * Return: QDF_STATUS_SUCCESS - success
5342 * QDF_STATUS_E_FAILURE - failure
5343 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5344 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305345static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305346 struct set_key_params *key_params)
5347{
5348 wmi_vdev_install_key_cmd_fixed_param *cmd;
5349 wmi_buf_t buf;
5350 uint8_t *buf_ptr;
5351 uint32_t len;
5352 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305353 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305354
5355 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5356 WMI_TLV_HDR_SIZE;
5357
5358 buf = wmi_buf_alloc(wmi_handle, len);
5359 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305360 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305361 return QDF_STATUS_E_NOMEM;
5362 }
5363
5364 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5365 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5366 WMITLV_SET_HDR(&cmd->tlv_header,
5367 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5368 WMITLV_GET_STRUCT_TLVLEN
5369 (wmi_vdev_install_key_cmd_fixed_param));
5370 cmd->vdev_id = key_params->vdev_id;
5371 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305372
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305373
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305374 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5375 cmd->key_flags |= key_params->key_flags;
5376 cmd->key_cipher = key_params->key_cipher;
5377 if ((key_params->key_txmic_len) &&
5378 (key_params->key_rxmic_len)) {
5379 cmd->key_txmic_len = key_params->key_txmic_len;
5380 cmd->key_rxmic_len = key_params->key_rxmic_len;
5381 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305382#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305383 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5384 key_params->tx_iv,
5385 cmd->wpi_key_rsc_counter,
5386 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305387#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305388 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5389 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5390 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305391 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305392 qdf_mem_copy((void *)key_data,
5393 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005394 if (key_params->key_rsc_counter)
5395 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5396 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305397 cmd->key_len = key_params->key_len;
5398
5399 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5400 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305401 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305402 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305403
Govind Singh67922e82016-04-01 16:48:57 +05305404 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305405}
5406
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305407/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005408 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5409 * @wmi_handle: wmi handle
5410 * @params: sar limit params
5411 *
5412 * Return: QDF_STATUS_SUCCESS for success or error code
5413 */
5414static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5415 struct sar_limit_cmd_params *sar_limit_params)
5416{
5417 wmi_buf_t buf;
5418 QDF_STATUS qdf_status;
5419 wmi_sar_limits_cmd_fixed_param *cmd;
5420 int i;
5421 uint8_t *buf_ptr;
5422 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5423 struct sar_limit_cmd_row *sar_rows_list;
5424 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5425
5426 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5427 buf = wmi_buf_alloc(wmi_handle, len);
5428 if (!buf) {
5429 WMI_LOGE("Failed to allocate memory");
5430 qdf_status = QDF_STATUS_E_NOMEM;
5431 goto end;
5432 }
5433
5434 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5435 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5436 WMITLV_SET_HDR(&cmd->tlv_header,
5437 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5438 WMITLV_GET_STRUCT_TLVLEN
5439 (wmi_sar_limits_cmd_fixed_param));
5440 cmd->sar_enable = sar_limit_params->sar_enable;
5441 cmd->commit_limits = sar_limit_params->commit_limits;
5442 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5443
5444 WMI_LOGD("no of sar rows = %d, len = %d",
5445 sar_limit_params->num_limit_rows, len);
5446 buf_ptr += sizeof(*cmd);
5447 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5448 sizeof(wmi_sar_limit_cmd_row) *
5449 sar_limit_params->num_limit_rows);
5450 if (cmd->num_limit_rows == 0)
5451 goto send_sar_limits;
5452
5453 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5454 (buf_ptr + WMI_TLV_HDR_SIZE);
5455 sar_rows_list = sar_limit_params->sar_limit_row_list;
5456
5457 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5458 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5459 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5460 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5461 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5462 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5463 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5464 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5465 wmi_sar_rows_list->validity_bitmap =
5466 sar_rows_list->validity_bitmap;
5467 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5468 i, wmi_sar_rows_list->band_id,
5469 wmi_sar_rows_list->chain_id,
5470 wmi_sar_rows_list->mod_id,
5471 wmi_sar_rows_list->limit_value,
5472 wmi_sar_rows_list->validity_bitmap);
5473 sar_rows_list++;
5474 wmi_sar_rows_list++;
5475 }
5476send_sar_limits:
5477 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5478 WMI_SAR_LIMITS_CMDID);
5479
5480 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5481 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5482 wmi_buf_free(buf);
5483 }
5484
5485end:
5486 return qdf_status;
5487}
5488
Jeff Johnson4783f902017-12-14 15:50:16 -08005489static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5490{
5491 wmi_sar_get_limits_cmd_fixed_param *cmd;
5492 wmi_buf_t wmi_buf;
5493 uint32_t len;
5494 QDF_STATUS status;
5495
5496 WMI_LOGD(FL("Enter"));
5497
5498 len = sizeof(*cmd);
5499 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5500 if (!wmi_buf) {
5501 WMI_LOGP(FL("failed to allocate memory for msg"));
5502 return QDF_STATUS_E_NOMEM;
5503 }
5504
5505 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5506
5507 WMITLV_SET_HDR(&cmd->tlv_header,
5508 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5509 WMITLV_GET_STRUCT_TLVLEN
5510 (wmi_sar_get_limits_cmd_fixed_param));
5511
5512 cmd->reserved = 0;
5513
5514 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5515 WMI_SAR_GET_LIMITS_CMDID);
5516 if (QDF_IS_STATUS_ERROR(status)) {
5517 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5518 wmi_buf_free(wmi_buf);
5519 }
5520
5521 WMI_LOGD(FL("Exit"));
5522
5523 return status;
5524}
5525
5526static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5527 uint8_t *evt_buf,
5528 struct sar_limit_event *event)
5529{
5530 wmi_sar_get_limits_event_fixed_param *fixed_param;
5531 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5532 wmi_sar_get_limit_event_row *row_in;
5533 struct sar_limit_event_row *row_out;
5534 uint32_t row;
5535
5536 if (!evt_buf) {
5537 WMI_LOGE(FL("input event is NULL"));
5538 return QDF_STATUS_E_INVAL;
5539 }
5540 if (!event) {
5541 WMI_LOGE(FL("output event is NULL"));
5542 return QDF_STATUS_E_INVAL;
5543 }
5544
5545 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5546
5547 fixed_param = param_buf->fixed_param;
5548 if (!fixed_param) {
5549 WMI_LOGE(FL("Invalid fixed param"));
5550 return QDF_STATUS_E_INVAL;
5551 }
5552
5553 event->sar_enable = fixed_param->sar_enable;
5554 event->num_limit_rows = fixed_param->num_limit_rows;
5555
5556 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5557 QDF_ASSERT(0);
5558 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5559 event->num_limit_rows,
5560 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5561 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5562 }
5563
5564 row_in = param_buf->sar_get_limits;
5565 row_out = &event->sar_limit_row[0];
5566 for (row = 0; row < event->num_limit_rows; row++) {
5567 row_out->band_id = row_in->band_id;
5568 row_out->chain_id = row_in->chain_id;
5569 row_out->mod_id = row_in->mod_id;
5570 row_out->limit_value = row_in->limit_value;
5571 row_out++;
5572 row_in++;
5573 }
5574
5575 return QDF_STATUS_SUCCESS;
5576}
5577
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305578#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005579/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305580 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5581 * @wmi_handle: wmi handle
5582 * @params: encrypt/decrypt params
5583 *
5584 * Return: QDF_STATUS_SUCCESS for success or error code
5585 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005586static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305587QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305588 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305589{
5590 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5591 wmi_buf_t wmi_buf;
5592 uint8_t *buf_ptr;
5593 QDF_STATUS ret;
5594 uint32_t len;
5595
5596 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5597
5598 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305599 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305600 WMI_TLV_HDR_SIZE;
5601 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5602 if (!wmi_buf) {
5603 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5604 __func__);
5605 return QDF_STATUS_E_NOMEM;
5606 }
5607
5608 buf_ptr = wmi_buf_data(wmi_buf);
5609 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5610
5611 WMITLV_SET_HDR(&cmd->tlv_header,
5612 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5613 WMITLV_GET_STRUCT_TLVLEN(
5614 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5615
5616 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5617 cmd->key_flag = encrypt_decrypt_params->key_flag;
5618 cmd->key_idx = encrypt_decrypt_params->key_idx;
5619 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5620 cmd->key_len = encrypt_decrypt_params->key_len;
5621 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5622 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5623
5624 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5625 encrypt_decrypt_params->key_len);
5626
5627 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5628 MAX_MAC_HEADER_LEN);
5629
5630 cmd->data_len = encrypt_decrypt_params->data_len;
5631
5632 if (cmd->data_len) {
5633 buf_ptr += sizeof(*cmd);
5634 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5635 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305636 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305637 buf_ptr += WMI_TLV_HDR_SIZE;
5638 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5639 encrypt_decrypt_params->data_len);
5640 }
5641
5642 /* This conversion is to facilitate data to FW in little endian */
5643 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5644 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5645 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5646 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5647 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5648 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5649
5650 ret = wmi_unified_cmd_send(wmi_handle,
5651 wmi_buf, len,
5652 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5653 if (QDF_IS_STATUS_ERROR(ret)) {
5654 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5655 wmi_buf_free(wmi_buf);
5656 }
5657
5658 return ret;
5659}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305660
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305661/**
5662 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5663 * params from event
5664 * @wmi_handle: wmi handle
5665 * @evt_buf: pointer to event buffer
5666 * @resp: Pointer to hold resp parameters
5667 *
5668 * Return: QDF_STATUS_SUCCESS for success or error code
5669 */
5670static
5671QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5672 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5673{
5674 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5675 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5676
5677 param_buf = evt_buf;
5678 if (!param_buf) {
5679 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5680 return QDF_STATUS_E_INVAL;
5681 }
5682
5683 data_event = param_buf->fixed_param;
5684
5685 resp->vdev_id = data_event->vdev_id;
5686 resp->status = data_event->status;
5687
5688 if (data_event->data_length > param_buf->num_enc80211_frame) {
5689 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5690 data_event->data_length,
5691 param_buf->num_enc80211_frame);
5692 return QDF_STATUS_E_INVAL;
5693 }
5694
5695 resp->data_len = data_event->data_length;
5696
5697 if (resp->data_len)
5698 resp->data = (uint8_t *)param_buf->enc80211_frame;
5699
5700 return QDF_STATUS_SUCCESS;
5701}
5702#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305703
Govind Singh4eacd2b2016-03-07 14:24:22 +05305704/**
5705 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5706 * @wmi_handle: wmi handle
5707 * @vdev_id: vdev id
5708 * @p2p_ie: p2p IE
5709 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305710 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305711 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305712static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05305713 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305714{
Govind Singh67922e82016-04-01 16:48:57 +05305715 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305716 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5717 wmi_buf_t wmi_buf;
5718 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5719 uint8_t *buf_ptr;
5720
5721 ie_len = (uint32_t) (p2p_ie[1] + 2);
5722
5723 /* More than one P2P IE may be included in a single frame.
5724 If multiple P2P IEs are present, the complete P2P attribute
5725 data consists of the concatenation of the P2P Attribute
5726 fields of the P2P IEs. The P2P Attributes field of each
5727 P2P IE may be any length up to the maximum (251 octets).
5728 In this case host sends one P2P IE to firmware so the length
5729 should not exceed more than 251 bytes
5730 */
5731 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305732 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305733 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305734 }
5735
Vivekc5823092018-03-22 23:27:21 +05305736 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305737
5738 wmi_buf_len =
5739 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5740 WMI_TLV_HDR_SIZE;
5741
5742 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5743 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305744 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305745 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305746 }
5747
5748 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5749
5750 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5751 WMITLV_SET_HDR(&cmd->tlv_header,
5752 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5753 WMITLV_GET_STRUCT_TLVLEN
5754 (wmi_p2p_go_set_beacon_ie_fixed_param));
5755 cmd->vdev_id = vdev_id;
5756 cmd->ie_buf_len = ie_len;
5757
5758 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5759 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5760 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305761 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305762
Govind Singhb53420c2016-03-09 14:32:57 +05305763 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305764
5765 ret = wmi_unified_cmd_send(wmi_handle,
5766 wmi_buf, wmi_buf_len,
5767 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305768 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305769 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305770 wmi_buf_free(wmi_buf);
5771 }
5772
Govind Singhb53420c2016-03-09 14:32:57 +05305773 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305774 return ret;
5775}
5776
5777/**
5778 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5779 * @wmi_handle: wmi handle
5780 * @req: gateway parameter update request structure
5781 *
5782 * This function reads the incoming @req and fill in the destination
5783 * WMI structure and sends down the gateway configs down to the firmware
5784 *
Govind Singhb53420c2016-03-09 14:32:57 +05305785 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305786 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305787static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305788 struct gateway_update_req_param *req)
5789{
5790 wmi_roam_subnet_change_config_fixed_param *cmd;
5791 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305792 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305793 int len = sizeof(*cmd);
5794
5795 buf = wmi_buf_alloc(wmi_handle, len);
5796 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305797 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5798 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305799 }
5800
5801 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5802 WMITLV_SET_HDR(&cmd->tlv_header,
5803 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5804 WMITLV_GET_STRUCT_TLVLEN(
5805 wmi_roam_subnet_change_config_fixed_param));
5806
5807 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305808 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5809 QDF_IPV4_ADDR_SIZE);
5810 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5811 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305812 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5813 &cmd->inet_gw_mac_addr);
5814 cmd->max_retries = req->max_retries;
5815 cmd->timeout = req->timeout;
5816 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5817 cmd->flag = 0;
5818 if (req->ipv4_addr_type)
5819 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5820
5821 if (req->ipv6_addr_type)
5822 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5823
5824 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5825 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305826 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305827 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305828 ret);
5829 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305830 }
5831
Govind Singh67922e82016-04-01 16:48:57 +05305832 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305833}
5834
5835/**
5836 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5837 * @wmi_handle: wmi handle
5838 * @req: rssi monitoring request structure
5839 *
5840 * This function reads the incoming @req and fill in the destination
5841 * WMI structure and send down the rssi monitoring configs down to the firmware
5842 *
5843 * Return: 0 on success; error number otherwise
5844 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305845static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305846 struct rssi_monitor_param *req)
5847{
5848 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5849 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305850 QDF_STATUS ret;
5851 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305852
5853 buf = wmi_buf_alloc(wmi_handle, len);
5854 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305855 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5856 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305857 }
5858
5859 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5860 WMITLV_SET_HDR(&cmd->tlv_header,
5861 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5862 WMITLV_GET_STRUCT_TLVLEN(
5863 wmi_rssi_breach_monitor_config_fixed_param));
5864
5865 cmd->vdev_id = req->session_id;
5866 cmd->request_id = req->request_id;
5867 cmd->lo_rssi_reenable_hysteresis = 0;
5868 cmd->hi_rssi_reenable_histeresis = 0;
5869 cmd->min_report_interval = 0;
5870 cmd->max_num_report = 1;
5871 if (req->control) {
5872 /* enable one threshold for each min/max */
5873 cmd->enabled_bitmap = 0x09;
5874 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5875 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5876 } else {
5877 cmd->enabled_bitmap = 0;
5878 cmd->low_rssi_breach_threshold[0] = 0;
5879 cmd->hi_rssi_breach_threshold[0] = 0;
5880 }
5881
5882 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5883 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305884 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305885 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305886 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305887 }
5888
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005889 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5890
Govind Singh67922e82016-04-01 16:48:57 +05305891 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305892}
5893
5894/**
5895 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5896 * @wmi_handle: wmi handle
5897 * @psetoui: OUI parameters
5898 *
5899 * set scan probe OUI parameters in firmware
5900 *
5901 * Return: CDF status
5902 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305903static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305904 struct scan_mac_oui *psetoui)
5905{
5906 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5907 wmi_buf_t wmi_buf;
5908 uint32_t len;
5909 uint8_t *buf_ptr;
5910 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305911 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305912
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305913 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5914 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5915
Govind Singh4eacd2b2016-03-07 14:24:22 +05305916 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5917 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305918 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5919 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305920 }
5921 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5922 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5923 WMITLV_SET_HDR(&cmd->tlv_header,
5924 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5925 WMITLV_GET_STRUCT_TLVLEN
5926 (wmi_scan_prob_req_oui_cmd_fixed_param));
5927
5928 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305929 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305930 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5931 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305932 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305933 cmd->prob_req_oui);
5934
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305935 cmd->vdev_id = psetoui->vdev_id;
5936 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5937 if (psetoui->enb_probe_req_sno_randomization)
5938 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5939
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305940 if (ie_whitelist->white_list) {
5941 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5942 &cmd->num_vendor_oui,
5943 ie_whitelist);
5944 cmd->flags |=
5945 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5946 }
5947
5948 buf_ptr += sizeof(*cmd);
5949 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5950 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5951 buf_ptr += WMI_TLV_HDR_SIZE;
5952
5953 if (cmd->num_vendor_oui != 0) {
5954 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5955 ie_whitelist->voui);
5956 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5957 }
5958
Govind Singh4eacd2b2016-03-07 14:24:22 +05305959 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5960 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305961 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305962 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305963 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305964 }
Govind Singhb53420c2016-03-09 14:32:57 +05305965 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305966}
5967
5968/**
5969 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5970 * @wmi_handle: wmi handle
5971 * @req: passpoint network request structure
5972 *
5973 * This function sends down WMI command with network id set to wildcard id.
5974 * firmware shall clear all the config entries
5975 *
Govind Singhb53420c2016-03-09 14:32:57 +05305976 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305977 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305978static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305979 struct wifi_passpoint_req_param *req)
5980{
5981 wmi_passpoint_config_cmd_fixed_param *cmd;
5982 wmi_buf_t buf;
5983 uint32_t len;
5984 int ret;
5985
5986 len = sizeof(*cmd);
5987 buf = wmi_buf_alloc(wmi_handle, len);
5988 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305989 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5990 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305991 }
5992
5993 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5994
5995 WMITLV_SET_HDR(&cmd->tlv_header,
5996 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5997 WMITLV_GET_STRUCT_TLVLEN(
5998 wmi_passpoint_config_cmd_fixed_param));
5999 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
6000
6001 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6002 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6003 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306004 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306005 __func__);
6006 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306007 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306008 }
6009
Govind Singhb53420c2016-03-09 14:32:57 +05306010 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306011}
6012
6013/**
6014 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
6015 * @wmi_handle: wmi handle
6016 * @req: passpoint network request structure
6017 *
6018 * This function reads the incoming @req and fill in the destination
6019 * WMI structure and send down the passpoint configs down to the firmware
6020 *
Govind Singhb53420c2016-03-09 14:32:57 +05306021 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05306022 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306023static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306024 struct wifi_passpoint_req_param *req)
6025{
6026 wmi_passpoint_config_cmd_fixed_param *cmd;
6027 u_int8_t i, j, *bytes;
6028 wmi_buf_t buf;
6029 uint32_t len;
6030 int ret;
6031
6032 len = sizeof(*cmd);
6033 for (i = 0; i < req->num_networks; i++) {
6034 buf = wmi_buf_alloc(wmi_handle, len);
6035 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306036 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6037 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306038 }
6039
6040 cmd = (wmi_passpoint_config_cmd_fixed_param *)
6041 wmi_buf_data(buf);
6042
6043 WMITLV_SET_HDR(&cmd->tlv_header,
6044 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
6045 WMITLV_GET_STRUCT_TLVLEN(
6046 wmi_passpoint_config_cmd_fixed_param));
6047 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05306048 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
6049 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306050 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05306051 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306052 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
6053 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05306054 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306055 j, bytes[0], bytes[1], bytes[2], bytes[3],
6056 bytes[4], bytes[5], bytes[6], bytes[7]);
6057
Govind Singhb53420c2016-03-09 14:32:57 +05306058 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05306059 &req->networks[i].roaming_consortium_ids[j],
6060 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
6061 }
Govind Singhb53420c2016-03-09 14:32:57 +05306062 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306063 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05306064 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306065 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
6066
6067 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6068 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6069 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306070 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306071 __func__);
6072 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306073 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306074 }
6075 }
6076
Govind Singhb53420c2016-03-09 14:32:57 +05306077 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306078}
6079
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306080#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306081/**
6082 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6083 * @wmi_handle: wmi handle
6084 * @roam_req: Roam scan offload params
6085 * @buf_ptr: command buffer to send
6086 * @fils_tlv_len: fils tlv length
6087 *
6088 * Return: Updated buffer pointer
6089 */
6090static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6091 struct roam_offload_scan_params *roam_req,
6092 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6093{
6094 wmi_roam_fils_offload_tlv_param *fils_tlv;
6095 wmi_erp_info *erp_info;
6096 struct roam_fils_params *roam_fils_params;
6097
6098 if (!roam_req->add_fils_tlv)
6099 return buf_ptr;
6100
6101 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6102 sizeof(*fils_tlv));
6103 buf_ptr += WMI_TLV_HDR_SIZE;
6104
6105 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6106 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6107 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6108 WMITLV_GET_STRUCT_TLVLEN
6109 (wmi_roam_fils_offload_tlv_param));
6110
6111 roam_fils_params = &roam_req->roam_fils_params;
6112 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6113
6114 erp_info->username_length = roam_fils_params->username_length;
6115 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6116 erp_info->username_length);
6117
6118 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6119
6120 erp_info->rRk_length = roam_fils_params->rrk_length;
6121 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6122 erp_info->rRk_length);
6123
6124 erp_info->rIk_length = roam_fils_params->rik_length;
6125 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6126 erp_info->rIk_length);
6127
6128 erp_info->realm_len = roam_fils_params->realm_len;
6129 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6130 erp_info->realm_len);
6131
6132 buf_ptr += sizeof(*fils_tlv);
6133 return buf_ptr;
6134}
6135#else
6136static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6137 struct roam_offload_scan_params *roam_req,
6138 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6139{
6140 return buf_ptr;
6141}
6142#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306143/**
6144 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6145 * @wmi_handle: wmi handle
6146 * @scan_cmd_fp: start scan command ptr
6147 * @roam_req: roam request param
6148 *
6149 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6150 * of WMI_ROAM_SCAN_MODE.
6151 *
6152 * Return: QDF status
6153 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306154static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306155 wmi_start_scan_cmd_fixed_param *
6156 scan_cmd_fp,
6157 struct roam_offload_scan_params *roam_req)
6158{
6159 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306160 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306161 int len;
6162 uint8_t *buf_ptr;
6163 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306164
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306165#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6166 int auth_mode = roam_req->auth_mode;
6167 wmi_roam_offload_tlv_param *roam_offload_params;
6168 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6169 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6170 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306171 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306172 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306173#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6174 /* Need to create a buf with roam_scan command at
6175 * front and piggyback with scan command */
6176 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6177#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6178 (2 * WMI_TLV_HDR_SIZE) +
6179#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6180 sizeof(wmi_start_scan_cmd_fixed_param);
6181#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006182 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306183 if (roam_req->is_roam_req_valid &&
6184 roam_req->roam_offload_enabled) {
6185 len += sizeof(wmi_roam_offload_tlv_param);
6186 len += WMI_TLV_HDR_SIZE;
6187 if ((auth_mode != WMI_AUTH_NONE) &&
6188 ((auth_mode != WMI_AUTH_OPEN) ||
6189 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306190 roam_req->mdid.mdie_present &&
6191 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306192 roam_req->is_ese_assoc)) {
6193 len += WMI_TLV_HDR_SIZE;
6194 if (roam_req->is_ese_assoc)
6195 len +=
6196 sizeof(wmi_roam_ese_offload_tlv_param);
6197 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6198 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6199 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306200 roam_req->mdid.mdie_present &&
6201 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306202 len +=
6203 sizeof(wmi_roam_11r_offload_tlv_param);
6204 else
6205 len +=
6206 sizeof(wmi_roam_11i_offload_tlv_param);
6207 } else {
6208 len += WMI_TLV_HDR_SIZE;
6209 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306210
6211 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6212 + roundup(roam_req->assoc_ie_length,
6213 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306214
6215 if (roam_req->add_fils_tlv) {
6216 fils_tlv_len = sizeof(
6217 wmi_roam_fils_offload_tlv_param);
6218 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6219 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306220 } else {
6221 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306222 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306223 __func__, roam_req->roam_offload_enabled);
6224 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306225 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306226 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306227 }
6228 if (roam_req->is_roam_req_valid &&
6229 roam_req->roam_offload_enabled) {
6230 roam_req->mode = roam_req->mode |
6231 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6232 }
6233#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6234
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306235 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6236 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6237 len = sizeof(wmi_roam_scan_mode_fixed_param);
6238
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306239 buf = wmi_buf_alloc(wmi_handle, len);
6240 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306241 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306242 return QDF_STATUS_E_NOMEM;
6243 }
6244
6245 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6246 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6247 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6248 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6249 WMITLV_GET_STRUCT_TLVLEN
6250 (wmi_roam_scan_mode_fixed_param));
6251
Abhinav Kumar334355f2018-04-06 17:18:52 +05306252 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6253 roam_req->roam_trigger_reason_bitmask;
6254 roam_scan_mode_fp->min_delay_btw_scans =
6255 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306256 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6257 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306258 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6259 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6260 roam_scan_mode_fp->flags |=
6261 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306262 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306263 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306264
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306265 /* Fill in scan parameters suitable for roaming scan */
6266 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306267
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306268 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6269 sizeof(wmi_start_scan_cmd_fixed_param));
6270 /* Ensure there is no additional IEs */
6271 scan_cmd_fp->ie_len = 0;
6272 WMITLV_SET_HDR(buf_ptr,
6273 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6274 WMITLV_GET_STRUCT_TLVLEN
6275 (wmi_start_scan_cmd_fixed_param));
6276#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6277 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6278 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6279 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6280 sizeof(wmi_roam_offload_tlv_param));
6281 buf_ptr += WMI_TLV_HDR_SIZE;
6282 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6283 WMITLV_SET_HDR(buf_ptr,
6284 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6285 WMITLV_GET_STRUCT_TLVLEN
6286 (wmi_roam_offload_tlv_param));
6287 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6288 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6289 roam_offload_params->select_5g_margin =
6290 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306291 roam_offload_params->handoff_delay_for_rx =
6292 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306293 roam_offload_params->reassoc_failure_timeout =
6294 roam_req->reassoc_failure_timeout;
6295
6296 /* Fill the capabilities */
6297 roam_offload_params->capability =
6298 roam_req->roam_offload_params.capability;
6299 roam_offload_params->ht_caps_info =
6300 roam_req->roam_offload_params.ht_caps_info;
6301 roam_offload_params->ampdu_param =
6302 roam_req->roam_offload_params.ampdu_param;
6303 roam_offload_params->ht_ext_cap =
6304 roam_req->roam_offload_params.ht_ext_cap;
6305 roam_offload_params->ht_txbf =
6306 roam_req->roam_offload_params.ht_txbf;
6307 roam_offload_params->asel_cap =
6308 roam_req->roam_offload_params.asel_cap;
6309 roam_offload_params->qos_caps =
6310 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006311 roam_offload_params->qos_enabled =
6312 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306313 roam_offload_params->wmm_caps =
6314 roam_req->roam_offload_params.wmm_caps;
6315 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6316 (uint8_t *)roam_req->roam_offload_params.mcsset,
6317 ROAM_OFFLOAD_NUM_MCS_SET);
6318
6319 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6320 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6321 * they are filled in the same order.Depending on the
6322 * authentication type, the other mode TLV's are nullified
6323 * and only headers are filled.*/
6324 if ((auth_mode != WMI_AUTH_NONE) &&
6325 ((auth_mode != WMI_AUTH_OPEN) ||
6326 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306327 && roam_req->mdid.mdie_present &&
6328 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306329 roam_req->is_ese_assoc)) {
6330 if (roam_req->is_ese_assoc) {
6331 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6332 WMITLV_GET_STRUCT_TLVLEN(0));
6333 buf_ptr += WMI_TLV_HDR_SIZE;
6334 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6335 WMITLV_GET_STRUCT_TLVLEN(0));
6336 buf_ptr += WMI_TLV_HDR_SIZE;
6337 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6338 sizeof(wmi_roam_ese_offload_tlv_param));
6339 buf_ptr += WMI_TLV_HDR_SIZE;
6340 roam_offload_ese =
6341 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6342 qdf_mem_copy(roam_offload_ese->krk,
6343 roam_req->krk,
6344 sizeof(roam_req->krk));
6345 qdf_mem_copy(roam_offload_ese->btk,
6346 roam_req->btk,
6347 sizeof(roam_req->btk));
6348 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6349 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6350 WMITLV_GET_STRUCT_TLVLEN
6351 (wmi_roam_ese_offload_tlv_param));
6352 buf_ptr +=
6353 sizeof(wmi_roam_ese_offload_tlv_param);
6354 } else if (auth_mode == WMI_AUTH_FT_RSNA
6355 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6356 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306357 && roam_req->mdid.mdie_present &&
6358 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306359 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6360 0);
6361 buf_ptr += WMI_TLV_HDR_SIZE;
6362 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6363 sizeof(wmi_roam_11r_offload_tlv_param));
6364 buf_ptr += WMI_TLV_HDR_SIZE;
6365 roam_offload_11r =
6366 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6367 roam_offload_11r->r0kh_id_len =
6368 roam_req->rokh_id_length;
6369 qdf_mem_copy(roam_offload_11r->r0kh_id,
6370 roam_req->rokh_id,
6371 roam_offload_11r->r0kh_id_len);
6372 qdf_mem_copy(roam_offload_11r->psk_msk,
6373 roam_req->psk_pmk,
6374 sizeof(roam_req->psk_pmk));
6375 roam_offload_11r->psk_msk_len =
6376 roam_req->pmk_len;
6377 roam_offload_11r->mdie_present =
6378 roam_req->mdid.mdie_present;
6379 roam_offload_11r->mdid =
6380 roam_req->mdid.mobility_domain;
6381 if (auth_mode == WMI_AUTH_OPEN) {
6382 /* If FT-Open ensure pmk length
6383 and r0khid len are zero */
6384 roam_offload_11r->r0kh_id_len = 0;
6385 roam_offload_11r->psk_msk_len = 0;
6386 }
6387 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6388 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6389 WMITLV_GET_STRUCT_TLVLEN
6390 (wmi_roam_11r_offload_tlv_param));
6391 buf_ptr +=
6392 sizeof(wmi_roam_11r_offload_tlv_param);
6393 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6394 WMITLV_GET_STRUCT_TLVLEN(0));
6395 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006396 WMI_LOGD("psk_msk_len = %d",
6397 roam_offload_11r->psk_msk_len);
6398 if (roam_offload_11r->psk_msk_len)
6399 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6400 QDF_TRACE_LEVEL_DEBUG,
6401 roam_offload_11r->psk_msk,
6402 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306403 } else {
6404 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6405 sizeof(wmi_roam_11i_offload_tlv_param));
6406 buf_ptr += WMI_TLV_HDR_SIZE;
6407 roam_offload_11i =
6408 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006409
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006410 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006411 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306412 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6413 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006414 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306415 } else {
6416 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6417 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006418 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006419 }
6420 if (roam_req->roam_key_mgmt_offload_enabled &&
6421 roam_req->fw_pmksa_cache) {
6422 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6423 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006424 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006425 } else {
6426 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6427 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006428 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306429 }
6430
6431 qdf_mem_copy(roam_offload_11i->pmk,
6432 roam_req->psk_pmk,
6433 sizeof(roam_req->psk_pmk));
6434 roam_offload_11i->pmk_len = roam_req->pmk_len;
6435 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6436 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6437 WMITLV_GET_STRUCT_TLVLEN
6438 (wmi_roam_11i_offload_tlv_param));
6439 buf_ptr +=
6440 sizeof(wmi_roam_11i_offload_tlv_param);
6441 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6442 0);
6443 buf_ptr += WMI_TLV_HDR_SIZE;
6444 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6445 0);
6446 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006447 WMI_LOGD("pmk_len = %d",
6448 roam_offload_11i->pmk_len);
6449 if (roam_offload_11i->pmk_len)
6450 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6451 QDF_TRACE_LEVEL_DEBUG,
6452 roam_offload_11i->pmk,
6453 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306454 }
6455 } else {
6456 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6457 WMITLV_GET_STRUCT_TLVLEN(0));
6458 buf_ptr += WMI_TLV_HDR_SIZE;
6459 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6460 WMITLV_GET_STRUCT_TLVLEN(0));
6461 buf_ptr += WMI_TLV_HDR_SIZE;
6462 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6463 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306464 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306465 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306466
6467 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6468 sizeof(*assoc_ies));
6469 buf_ptr += WMI_TLV_HDR_SIZE;
6470
6471 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6472 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6473 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6474 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6475 assoc_ies->buf_len = roam_req->assoc_ie_length;
6476
6477 buf_ptr += sizeof(*assoc_ies);
6478
6479 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6480 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6481 buf_ptr += WMI_TLV_HDR_SIZE;
6482
6483 if (assoc_ies->buf_len != 0) {
6484 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6485 assoc_ies->buf_len);
6486 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306487 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6488 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6489 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306490 } else {
6491 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6492 WMITLV_GET_STRUCT_TLVLEN(0));
6493 buf_ptr += WMI_TLV_HDR_SIZE;
6494 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6495 WMITLV_GET_STRUCT_TLVLEN(0));
6496 buf_ptr += WMI_TLV_HDR_SIZE;
6497 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6498 WMITLV_GET_STRUCT_TLVLEN(0));
6499 buf_ptr += WMI_TLV_HDR_SIZE;
6500 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6501 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306502 buf_ptr += WMI_TLV_HDR_SIZE;
6503 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6504 WMITLV_GET_STRUCT_TLVLEN(0));
6505 buf_ptr += WMI_TLV_HDR_SIZE;
6506 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6507 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306508 }
6509#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306510
6511send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306512 status = wmi_unified_cmd_send(wmi_handle, buf,
6513 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306514 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306515 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306516 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6517 status);
6518 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306519 }
6520
Govind Singh67922e82016-04-01 16:48:57 +05306521 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306522}
6523
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006524static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6525 struct wmi_mawc_roam_params *params)
6526{
6527 wmi_buf_t buf = NULL;
6528 QDF_STATUS status;
6529 int len;
6530 uint8_t *buf_ptr;
6531 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6532
6533 len = sizeof(*wmi_roam_mawc_params);
6534 buf = wmi_buf_alloc(wmi_handle, len);
6535 if (!buf) {
6536 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6537 return QDF_STATUS_E_NOMEM;
6538 }
6539
6540 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6541 wmi_roam_mawc_params =
6542 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6543 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6544 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6545 WMITLV_GET_STRUCT_TLVLEN
6546 (wmi_roam_configure_mawc_cmd_fixed_param));
6547 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6548 if (params->enable)
6549 wmi_roam_mawc_params->enable = 1;
6550 else
6551 wmi_roam_mawc_params->enable = 0;
6552 wmi_roam_mawc_params->traffic_load_threshold =
6553 params->traffic_load_threshold;
6554 wmi_roam_mawc_params->best_ap_rssi_threshold =
6555 params->best_ap_rssi_threshold;
6556 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6557 params->rssi_stationary_high_adjust;
6558 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6559 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006560 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6561 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6562 wmi_roam_mawc_params->traffic_load_threshold,
6563 wmi_roam_mawc_params->best_ap_rssi_threshold,
6564 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6565 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006566
6567 status = wmi_unified_cmd_send(wmi_handle, buf,
6568 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6569 if (QDF_IS_STATUS_ERROR(status)) {
6570 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6571 status);
6572 wmi_buf_free(buf);
6573 return status;
6574 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006575
6576 return QDF_STATUS_SUCCESS;
6577}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306578
6579/**
6580 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6581 * rssi threashold
6582 * @wmi_handle: wmi handle
6583 * @roam_req: Roaming request buffer
6584 *
6585 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6586 *
6587 * Return: QDF status
6588 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306589static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306590 struct roam_offload_scan_rssi_params *roam_req)
6591{
6592 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306593 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306594 int len;
6595 uint8_t *buf_ptr;
6596 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6597 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6598 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306599 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006600 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306601
6602 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6603 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6604 len += sizeof(wmi_roam_scan_extended_threshold_param);
6605 len += WMI_TLV_HDR_SIZE;
6606 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306607 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6608 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006609 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6610 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306611 buf = wmi_buf_alloc(wmi_handle, len);
6612 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306613 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306614 return QDF_STATUS_E_NOMEM;
6615 }
6616
6617 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6618 rssi_threshold_fp =
6619 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6620 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6621 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6622 WMITLV_GET_STRUCT_TLVLEN
6623 (wmi_roam_scan_rssi_threshold_fixed_param));
6624 /* fill in threshold values */
6625 rssi_threshold_fp->vdev_id = roam_req->session_id;
6626 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6627 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6628 rssi_threshold_fp->hirssi_scan_max_count =
6629 roam_req->hi_rssi_scan_max_count;
6630 rssi_threshold_fp->hirssi_scan_delta =
6631 roam_req->hi_rssi_scan_rssi_delta;
6632 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006633 rssi_threshold_fp->rssi_thresh_offset_5g =
6634 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306635
6636 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6637 WMITLV_SET_HDR(buf_ptr,
6638 WMITLV_TAG_ARRAY_STRUC,
6639 sizeof(wmi_roam_scan_extended_threshold_param));
6640 buf_ptr += WMI_TLV_HDR_SIZE;
6641 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6642
6643 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6644 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6645 ext_thresholds->boost_threshold_5g =
6646 roam_req->boost_threshold_5g;
6647
6648 ext_thresholds->boost_algorithm_5g =
6649 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6650 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6651 ext_thresholds->penalty_algorithm_5g =
6652 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6653 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6654 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6655 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6656 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6657
6658 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6659 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6660 WMITLV_GET_STRUCT_TLVLEN
6661 (wmi_roam_scan_extended_threshold_param));
6662 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6663 WMITLV_SET_HDR(buf_ptr,
6664 WMITLV_TAG_ARRAY_STRUC,
6665 sizeof(wmi_roam_earlystop_rssi_thres_param));
6666 buf_ptr += WMI_TLV_HDR_SIZE;
6667 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6668 early_stop_thresholds->roam_earlystop_thres_min =
6669 roam_req->roam_earlystop_thres_min;
6670 early_stop_thresholds->roam_earlystop_thres_max =
6671 roam_req->roam_earlystop_thres_max;
6672 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6673 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6674 WMITLV_GET_STRUCT_TLVLEN
6675 (wmi_roam_earlystop_rssi_thres_param));
6676
Gupta, Kapil7e652922016-04-12 15:02:00 +05306677 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6678 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6679 sizeof(wmi_roam_dense_thres_param));
6680 buf_ptr += WMI_TLV_HDR_SIZE;
6681 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6682 dense_thresholds->roam_dense_rssi_thres_offset =
6683 roam_req->dense_rssi_thresh_offset;
6684 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6685 dense_thresholds->roam_dense_traffic_thres =
6686 roam_req->traffic_threshold;
6687 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6688 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6689 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6690 WMITLV_GET_STRUCT_TLVLEN
6691 (wmi_roam_dense_thres_param));
6692
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006693 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6694 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6695 sizeof(wmi_roam_bg_scan_roaming_param));
6696 buf_ptr += WMI_TLV_HDR_SIZE;
6697 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6698 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6699 roam_req->bg_scan_bad_rssi_thresh;
6700 bg_scan_params->roam_bg_scan_client_bitmap =
6701 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306702 bg_scan_params->bad_rssi_thresh_offset_2g =
6703 roam_req->roam_bad_rssi_thresh_offset_2g;
6704 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006705 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6706 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6707 WMITLV_GET_STRUCT_TLVLEN
6708 (wmi_roam_bg_scan_roaming_param));
6709
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306710 status = wmi_unified_cmd_send(wmi_handle, buf,
6711 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306712 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306713 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306714 status);
6715 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306716 }
6717
Govind Singh67922e82016-04-01 16:48:57 +05306718 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306719}
6720
6721/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306722 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6723 * configuration params
6724 * @wma_handle: wma handler
6725 * @dwelltime_params: pointer to dwelltime_params
6726 *
6727 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6728 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006729static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306730QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6731 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6732{
6733 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6734 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6735 wmi_buf_t buf;
6736 uint8_t *buf_ptr;
6737 int32_t err;
6738 int len;
6739
6740 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6741 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6742 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6743 buf = wmi_buf_alloc(wmi_handle, len);
6744 if (!buf) {
6745 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6746 __func__);
6747 return QDF_STATUS_E_NOMEM;
6748 }
6749 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6750 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6751 WMITLV_SET_HDR(&dwell_param->tlv_header,
6752 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6753 WMITLV_GET_STRUCT_TLVLEN
6754 (wmi_scan_adaptive_dwell_config_fixed_param));
6755
6756 dwell_param->enable = dwelltime_params->is_enabled;
6757 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6758 WMITLV_SET_HDR(buf_ptr,
6759 WMITLV_TAG_ARRAY_STRUC,
6760 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6761 buf_ptr += WMI_TLV_HDR_SIZE;
6762
6763 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6764 WMITLV_SET_HDR(&cmd->tlv_header,
6765 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6766 WMITLV_GET_STRUCT_TLVLEN(
6767 wmi_scan_adaptive_dwell_parameters_tlv));
6768
6769 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6770 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6771 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6772 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6773 err = wmi_unified_cmd_send(wmi_handle, buf,
6774 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6775 if (err) {
6776 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6777 wmi_buf_free(buf);
6778 return QDF_STATUS_E_FAILURE;
6779 }
6780
6781 return QDF_STATUS_SUCCESS;
6782}
6783
Nitesh Shah52323d02017-05-22 15:49:00 +05306784/**
6785 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6786 * configuration params
6787 * @wmi_handle: wmi handler
6788 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6789 *
6790 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6791 */
6792static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6793 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6794{
6795 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6796 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6797 wmi_buf_t buf;
6798 uint8_t *buf_ptr;
6799 QDF_STATUS err;
6800 uint32_t i;
6801 int len;
6802
6803 len = sizeof(*dbs_scan_param);
6804 len += WMI_TLV_HDR_SIZE;
6805 len += dbs_scan_params->num_clients * sizeof(*cmd);
6806
6807 buf = wmi_buf_alloc(wmi_handle, len);
6808 if (!buf) {
6809 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6810 return QDF_STATUS_E_NOMEM;
6811 }
6812
6813 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6814 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6815 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6816 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6817 WMITLV_GET_STRUCT_TLVLEN
6818 (wmi_scan_dbs_duty_cycle_fixed_param));
6819
6820 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6821 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6822 buf_ptr += sizeof(*dbs_scan_param);
6823 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6824 (sizeof(*cmd) * dbs_scan_params->num_clients));
6825 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6826
6827 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6828 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6829 WMITLV_SET_HDR(&cmd->tlv_header,
6830 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6831 WMITLV_GET_STRUCT_TLVLEN(
6832 wmi_scan_dbs_duty_cycle_tlv_param));
6833 cmd->module_id = dbs_scan_params->module_id[i];
6834 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6835 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6836 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6837 }
6838
6839 err = wmi_unified_cmd_send(wmi_handle, buf,
6840 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6841 if (QDF_IS_STATUS_ERROR(err)) {
6842 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6843 wmi_buf_free(buf);
6844 return QDF_STATUS_E_FAILURE;
6845 }
6846
6847 return QDF_STATUS_SUCCESS;
6848}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306849
6850/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306851 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6852 * @wmi_handle: wmi handle
6853 * @roam_req: Request which contains the filters
6854 *
6855 * There are filters such as whitelist, blacklist and preferred
6856 * list that need to be applied to the scan results to form the
6857 * probable candidates for roaming.
6858 *
Jeff Johnsonda263992018-05-12 14:22:00 -07006859 * Return: Return success upon successfully passing the
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306860 * parameters to the firmware, otherwise failure.
6861 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306862static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306863 struct roam_scan_filter_params *roam_req)
6864{
6865 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306866 QDF_STATUS status;
6867 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306868 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306869 uint8_t *buf_ptr;
6870 wmi_roam_filter_fixed_param *roam_filter;
6871 uint8_t *bssid_src_ptr = NULL;
6872 wmi_mac_addr *bssid_dst_ptr = NULL;
6873 wmi_ssid *ssid_ptr = NULL;
6874 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306875 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306876 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306877
6878 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306879
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306880 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306881 if (roam_req->num_bssid_black_list)
6882 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6883 len += WMI_TLV_HDR_SIZE;
6884 if (roam_req->num_ssid_white_list)
6885 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6886 len += 2 * WMI_TLV_HDR_SIZE;
6887 if (roam_req->num_bssid_preferred_list) {
6888 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05306889 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306890 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306891 len += WMI_TLV_HDR_SIZE;
6892 if (roam_req->lca_disallow_config_present) {
6893 len += sizeof(*blist_param);
6894 blist_len = sizeof(*blist_param);
6895 }
6896
6897 len += WMI_TLV_HDR_SIZE;
6898 if (roam_req->num_rssi_rejection_ap)
6899 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306900
6901 buf = wmi_buf_alloc(wmi_handle, len);
6902 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306903 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306904 return QDF_STATUS_E_NOMEM;
6905 }
6906
6907 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6908 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6909 WMITLV_SET_HDR(&roam_filter->tlv_header,
6910 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6911 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6912 /* fill in fixed values */
6913 roam_filter->vdev_id = roam_req->session_id;
6914 roam_filter->flags = 0;
6915 roam_filter->op_bitmap = roam_req->op_bitmap;
6916 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6917 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6918 roam_filter->num_bssid_preferred_list =
6919 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306920 roam_filter->num_rssi_rejection_ap =
6921 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306922 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6923
6924 WMITLV_SET_HDR((buf_ptr),
6925 WMITLV_TAG_ARRAY_FIXED_STRUC,
6926 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6927 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6928 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6929 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6930 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6931 bssid_src_ptr += ATH_MAC_LEN;
6932 bssid_dst_ptr++;
6933 }
6934 buf_ptr += WMI_TLV_HDR_SIZE +
6935 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6936 WMITLV_SET_HDR((buf_ptr),
6937 WMITLV_TAG_ARRAY_FIXED_STRUC,
6938 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6939 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6940 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6941 qdf_mem_copy(&ssid_ptr->ssid,
6942 &roam_req->ssid_allowed_list[i].mac_ssid,
6943 roam_req->ssid_allowed_list[i].length);
6944 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6945 ssid_ptr++;
6946 }
6947 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6948 sizeof(wmi_ssid));
6949 WMITLV_SET_HDR((buf_ptr),
6950 WMITLV_TAG_ARRAY_FIXED_STRUC,
6951 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6952 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6953 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6954 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6955 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6956 (wmi_mac_addr *)bssid_dst_ptr);
6957 bssid_src_ptr += ATH_MAC_LEN;
6958 bssid_dst_ptr++;
6959 }
6960 buf_ptr += WMI_TLV_HDR_SIZE +
6961 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6962 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6963 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6964 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6965 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6966 *bssid_preferred_factor_ptr =
6967 roam_req->bssid_favored_factor[i];
6968 bssid_preferred_factor_ptr++;
6969 }
6970 buf_ptr += WMI_TLV_HDR_SIZE +
6971 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6972
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306973 WMITLV_SET_HDR(buf_ptr,
6974 WMITLV_TAG_ARRAY_STRUC, blist_len);
6975 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306976 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306977 blist_param =
6978 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6979 WMITLV_SET_HDR(&blist_param->tlv_header,
6980 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6981 WMITLV_GET_STRUCT_TLVLEN(
6982 wmi_roam_lca_disallow_config_tlv_param));
6983
6984 blist_param->disallow_duration = roam_req->disallow_duration;
6985 blist_param->rssi_channel_penalization =
6986 roam_req->rssi_channel_penalization;
6987 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05306988 blist_param->disallow_lca_enable_source_bitmap =
6989 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
6990 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306991 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6992 }
6993
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306994 WMITLV_SET_HDR(buf_ptr,
6995 WMITLV_TAG_ARRAY_STRUC,
6996 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
6997 buf_ptr += WMI_TLV_HDR_SIZE;
6998 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
6999 rssi_rej =
7000 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7001 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7002 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7003 WMITLV_GET_STRUCT_TLVLEN(
7004 wmi_roam_rssi_rejection_oce_config_param));
7005 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7006 roam_req->rssi_rejection_ap[i].bssid.bytes,
7007 &rssi_rej->bssid);
7008 rssi_rej->remaining_disallow_duration =
7009 roam_req->rssi_rejection_ap[i].remaining_duration;
7010 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05307011 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307012 buf_ptr +=
7013 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7014 }
7015
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307016 status = wmi_unified_cmd_send(wmi_handle, buf,
7017 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307018 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307019 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307020 status);
7021 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307022 }
Govind Singh67922e82016-04-01 16:48:57 +05307023
7024 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307025}
7026
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307027#if defined(WLAN_FEATURE_FILS_SK)
7028static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7029 struct hlp_params *params)
7030{
7031 uint32_t len;
7032 uint8_t *buf_ptr;
7033 wmi_buf_t buf = NULL;
7034 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7035
7036 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7037 len += WMI_TLV_HDR_SIZE;
7038 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7039
7040 buf = wmi_buf_alloc(wmi_handle, len);
7041 if (!buf) {
7042 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7043 return QDF_STATUS_E_NOMEM;
7044 }
7045
7046 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7047 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7048 WMITLV_SET_HDR(&hlp_params->tlv_header,
7049 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7050 WMITLV_GET_STRUCT_TLVLEN(
7051 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7052
7053 hlp_params->vdev_id = params->vdev_id;
7054 hlp_params->size = params->hlp_ie_len;
7055 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7056
7057 buf_ptr += sizeof(*hlp_params);
7058
7059 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7060 round_up(params->hlp_ie_len,
7061 sizeof(uint32_t)));
7062 buf_ptr += WMI_TLV_HDR_SIZE;
7063 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7064
7065 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7066 hlp_params->vdev_id, hlp_params->size);
7067 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7068 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7069 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7070 wmi_buf_free(buf);
7071 return QDF_STATUS_E_FAILURE;
7072 }
7073
7074 return QDF_STATUS_SUCCESS;
7075}
7076#endif
7077
Govind Singh4eacd2b2016-03-07 14:24:22 +05307078/** send_set_epno_network_list_cmd_tlv() - set epno network list
7079 * @wmi_handle: wmi handle
7080 * @req: epno config params request structure
7081 *
7082 * This function reads the incoming epno config request structure
7083 * and constructs the WMI message to the firmware.
7084 *
7085 * Returns: 0 on success, error number otherwise
7086 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307087static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307088 struct wifi_enhanched_pno_params *req)
7089{
7090 wmi_nlo_config_cmd_fixed_param *cmd;
7091 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307092 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307093 u_int8_t i, *buf_ptr;
7094 wmi_buf_t buf;
7095 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307096 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307097
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307098 /* Fixed Params */
7099 len = sizeof(*cmd);
7100 if (req->num_networks) {
7101 /* TLV place holder for array of structures
7102 * then each nlo_configured_parameters(nlo_list) TLV.
7103 */
7104 len += WMI_TLV_HDR_SIZE;
7105 len += (sizeof(nlo_configured_parameters)
7106 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
7107 /* TLV for array of uint32 channel_list */
7108 len += WMI_TLV_HDR_SIZE;
7109 /* TLV for nlo_channel_prediction_cfg */
7110 len += WMI_TLV_HDR_SIZE;
7111 /* TLV for candidate score params */
7112 len += sizeof(enlo_candidate_score_params);
7113 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05307114
7115 buf = wmi_buf_alloc(wmi_handle, len);
7116 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307117 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7118 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307119 }
7120
7121 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7122
7123 buf_ptr = (u_int8_t *) cmd;
7124 WMITLV_SET_HDR(&cmd->tlv_header,
7125 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7126 WMITLV_GET_STRUCT_TLVLEN(
7127 wmi_nlo_config_cmd_fixed_param));
7128 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307129
7130 /* set flag to reset if num of networks are 0 */
7131 cmd->flags = (req->num_networks == 0 ?
7132 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307133
7134 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7135
Govind Singhb53420c2016-03-09 14:32:57 +05307136 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307137 WMI_LOGD("SSID count: %d flags: %d",
7138 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307139
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307140 /* Fill nlo_config only when num_networks are non zero */
7141 if (cmd->no_of_ssids) {
7142 /* Fill networks */
7143 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7144 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7145 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307146
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307147 nlo_list = (nlo_configured_parameters *) buf_ptr;
7148 for (i = 0; i < cmd->no_of_ssids; i++) {
7149 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7150 WMITLV_TAG_ARRAY_BYTE,
7151 WMITLV_GET_STRUCT_TLVLEN(
7152 nlo_configured_parameters));
7153 /* Copy ssid and it's length */
7154 nlo_list[i].ssid.valid = true;
7155 nlo_list[i].ssid.ssid.ssid_len =
7156 req->networks[i].ssid.length;
7157 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
7158 req->networks[i].ssid.mac_ssid,
7159 nlo_list[i].ssid.ssid.ssid_len);
7160 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
7161 nlo_list[i].ssid.ssid.ssid_len,
7162 (char *) nlo_list[i].ssid.ssid.ssid,
7163 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307164
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307165 /* Copy pno flags */
7166 nlo_list[i].bcast_nw_type.valid = true;
7167 nlo_list[i].bcast_nw_type.bcast_nw_type =
7168 req->networks[i].flags;
7169 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307170 nlo_list[i].bcast_nw_type.bcast_nw_type);
7171
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307172 /* Copy auth bit field */
7173 nlo_list[i].auth_type.valid = true;
7174 nlo_list[i].auth_type.auth_type =
7175 req->networks[i].auth_bit_field;
7176 WMI_LOGD("Auth bit field (%u)",
7177 nlo_list[i].auth_type.auth_type);
7178 }
7179
7180 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7181 /* Fill the channel list */
7182 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7183 buf_ptr += WMI_TLV_HDR_SIZE;
7184
7185 /* Fill prediction_param */
7186 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7187 buf_ptr += WMI_TLV_HDR_SIZE;
7188
7189 /* Fill epno candidate score params */
7190 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
7191 WMITLV_SET_HDR(buf_ptr,
7192 WMITLV_TAG_STRUC_enlo_candidate_score_param,
7193 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7194 cand_score_params->min5GHz_rssi =
7195 req->min_5ghz_rssi;
7196 cand_score_params->min24GHz_rssi =
7197 req->min_24ghz_rssi;
7198 cand_score_params->initial_score_max =
7199 req->initial_score_max;
7200 cand_score_params->current_connection_bonus =
7201 req->current_connection_bonus;
7202 cand_score_params->same_network_bonus =
7203 req->same_network_bonus;
7204 cand_score_params->secure_bonus =
7205 req->secure_bonus;
7206 cand_score_params->band5GHz_bonus =
7207 req->band_5ghz_bonus;
7208 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307209 }
7210
Govind Singh4eacd2b2016-03-07 14:24:22 +05307211 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307212 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307213 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307214 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307215 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307216 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307217 }
7218
Govind Singhb53420c2016-03-09 14:32:57 +05307219 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307220 req->session_id);
7221
Govind Singh67922e82016-04-01 16:48:57 +05307222 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307223}
7224
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307225#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307226/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7227 * @wmi_handle: wmi handle
7228 * @ipa_offload: ipa offload control parameter
7229 *
7230 * Returns: 0 on success, error number otherwise
7231 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307232static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307233 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307234{
7235 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7236 wmi_buf_t wmi_buf;
7237 uint32_t len;
7238 u_int8_t *buf_ptr;
7239
7240 len = sizeof(*cmd);
7241 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7242 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307243 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7244 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307245 }
7246
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007247 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307248 ipa_offload->offload_type, ipa_offload->enable);
7249
7250 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7251
7252 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7253 WMITLV_SET_HDR(&cmd->tlv_header,
7254 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7255 WMITLV_GET_STRUCT_TLVLEN(
7256 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7257
7258 cmd->offload_type = ipa_offload->offload_type;
7259 cmd->vdev_id = ipa_offload->vdev_id;
7260 cmd->enable = ipa_offload->enable;
7261
7262 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7263 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307264 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307265 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307266 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307267 }
7268
Govind Singhb53420c2016-03-09 14:32:57 +05307269 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307270}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307271#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307272
7273/**
7274 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
7275 * @wmi_handle: wmi handle
7276 * @pgetcapab: get capabilities params
7277 *
7278 * This function send request to fw to get extscan capabilities.
7279 *
7280 * Return: CDF status
7281 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307282static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307283 struct extscan_capabilities_params *pgetcapab)
7284{
7285 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
7286 wmi_buf_t wmi_buf;
7287 uint32_t len;
7288 uint8_t *buf_ptr;
7289
7290 len = sizeof(*cmd);
7291 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7292 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307293 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7294 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307295 }
7296 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7297
7298 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
7299 WMITLV_SET_HDR(&cmd->tlv_header,
7300 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
7301 WMITLV_GET_STRUCT_TLVLEN
7302 (wmi_extscan_get_capabilities_cmd_fixed_param));
7303
7304 cmd->request_id = pgetcapab->request_id;
7305
7306 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7307 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307308 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307309 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307310 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307311 }
Govind Singhb53420c2016-03-09 14:32:57 +05307312 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307313}
7314
7315/**
7316 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
7317 * @wmi_handle: wmi handle
7318 * @pcached_results: cached results parameters
7319 *
7320 * This function send request to fw to get cached results.
7321 *
7322 * Return: CDF status
7323 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307324static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307325 struct extscan_cached_result_params *pcached_results)
7326{
7327 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
7328 wmi_buf_t wmi_buf;
7329 uint32_t len;
7330 uint8_t *buf_ptr;
7331
7332 len = sizeof(*cmd);
7333 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7334 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307335 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7336 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307337 }
7338 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7339
7340 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
7341 WMITLV_SET_HDR(&cmd->tlv_header,
7342 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
7343 WMITLV_GET_STRUCT_TLVLEN
7344 (wmi_extscan_get_cached_results_cmd_fixed_param));
7345
7346 cmd->request_id = pcached_results->request_id;
7347 cmd->vdev_id = pcached_results->session_id;
7348 cmd->control_flags = pcached_results->flush;
7349
7350 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7351 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307352 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307353 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307354 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307355 }
Govind Singhb53420c2016-03-09 14:32:57 +05307356 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307357}
7358
7359/**
7360 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
7361 * @wmi_handle: wmi handle
7362 * @reset_req: Reset change request params
7363 *
7364 * This function sends stop change monitor request to fw.
7365 *
7366 * Return: CDF status
7367 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307368static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307369 struct extscan_capabilities_reset_params *reset_req)
7370{
7371 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7372 wmi_buf_t wmi_buf;
7373 uint32_t len;
7374 uint8_t *buf_ptr;
7375 int change_list = 0;
7376
7377 len = sizeof(*cmd);
7378
7379 /* reset significant change tlv is set to 0 */
7380 len += WMI_TLV_HDR_SIZE;
7381 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
7382 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7383 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307384 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7385 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307386 }
7387 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7388
7389 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7390 buf_ptr;
7391 WMITLV_SET_HDR(&cmd->tlv_header,
7392 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7393 WMITLV_GET_STRUCT_TLVLEN
7394 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7395
7396 cmd->request_id = reset_req->request_id;
7397 cmd->vdev_id = reset_req->session_id;
7398 cmd->mode = 0;
7399
7400 buf_ptr += sizeof(*cmd);
7401 WMITLV_SET_HDR(buf_ptr,
7402 WMITLV_TAG_ARRAY_STRUC,
7403 change_list *
7404 sizeof(wmi_extscan_wlan_change_bssid_param));
7405 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
7406 sizeof
7407 (wmi_extscan_wlan_change_bssid_param));
7408
7409 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7410 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307411 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307412 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307413 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307414 }
Govind Singhb53420c2016-03-09 14:32:57 +05307415 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307416}
7417
7418/**
7419 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
7420 * @wmi_handle: wmi handle
7421 * @psigchange: change monitor request params
7422 * @buf: wmi buffer
7423 * @buf_len: buffer length
7424 *
7425 * This function fills elements of change monitor request buffer.
7426 *
7427 * Return: CDF status
7428 */
Govind Singhb53420c2016-03-09 14:32:57 +05307429static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307430 struct extscan_set_sig_changereq_params
7431 *psigchange, wmi_buf_t *buf, int *buf_len)
7432{
7433 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7434 wmi_extscan_wlan_change_bssid_param *dest_chglist;
7435 uint8_t *buf_ptr;
7436 int j;
7437 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007438 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307439 struct ap_threshold_params *src_ap = psigchange->ap;
7440
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007441 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307442 WMI_LOGE("%s: Invalid number of bssid's", __func__);
7443 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307444 }
7445 len += WMI_TLV_HDR_SIZE;
7446 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
7447
7448 *buf = wmi_buf_alloc(wmi_handle, len);
7449 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307450 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307451 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307452 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307453 }
7454 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7455 cmd =
7456 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7457 buf_ptr;
7458 WMITLV_SET_HDR(&cmd->tlv_header,
7459 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7460 WMITLV_GET_STRUCT_TLVLEN
7461 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7462
7463 cmd->request_id = psigchange->request_id;
7464 cmd->vdev_id = psigchange->session_id;
7465 cmd->total_entries = numap;
7466 cmd->mode = 1;
7467 cmd->num_entries_in_page = numap;
7468 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
7469 cmd->max_rssi_samples = psigchange->rssi_sample_size;
7470 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
7471 cmd->max_out_of_range_count = psigchange->min_breaching;
7472
7473 buf_ptr += sizeof(*cmd);
7474 WMITLV_SET_HDR(buf_ptr,
7475 WMITLV_TAG_ARRAY_STRUC,
7476 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7477 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
7478 (buf_ptr + WMI_TLV_HDR_SIZE);
7479
7480 for (j = 0; j < numap; j++) {
7481 WMITLV_SET_HDR(dest_chglist,
7482 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7483 WMITLV_GET_STRUCT_TLVLEN
7484 (wmi_extscan_wlan_change_bssid_param));
7485
7486 dest_chglist->lower_rssi_limit = src_ap->low;
7487 dest_chglist->upper_rssi_limit = src_ap->high;
7488 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
7489 &dest_chglist->bssid);
7490
Govind Singhb53420c2016-03-09 14:32:57 +05307491 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307492 dest_chglist->lower_rssi_limit);
7493 dest_chglist++;
7494 src_ap++;
7495 }
7496 buf_ptr += WMI_TLV_HDR_SIZE +
7497 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7498 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307499 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307500}
7501
7502/**
7503 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
7504 * @wmi_handle: wmi handle
7505 * @psigchange: change monitor request params
7506 *
7507 * This function sends start change monitor request to fw.
7508 *
7509 * Return: CDF status
7510 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307511static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307512 struct extscan_set_sig_changereq_params *
7513 psigchange)
7514{
Govind Singhb53420c2016-03-09 14:32:57 +05307515 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307516 wmi_buf_t buf;
7517 int len;
7518
7519
Govind Singhb53420c2016-03-09 14:32:57 +05307520 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307521 psigchange, &buf,
7522 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307523 if (qdf_status != QDF_STATUS_SUCCESS) {
7524 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307525 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307526 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307527 }
7528 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307529 WMI_LOGE("%s: Failed to get buffer", __func__);
7530 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307531 }
7532 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7533 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307534 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307535 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307536 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307537 }
Govind Singhb53420c2016-03-09 14:32:57 +05307538 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307539}
7540
7541/**
7542 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
7543 * @wmi_handle: wmi handle
7544 * @photlist_reset: hotlist reset params
7545 *
7546 * This function configures hotlist monitor to stop in fw.
7547 *
7548 * Return: CDF status
7549 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307550static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307551 struct extscan_bssid_hotlist_reset_params *photlist_reset)
7552{
7553 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
7554 wmi_buf_t wmi_buf;
7555 uint32_t len;
7556 uint8_t *buf_ptr;
7557 int hotlist_entries = 0;
7558
7559 len = sizeof(*cmd);
7560
7561 /* reset bssid hotlist with tlv set to 0 */
7562 len += WMI_TLV_HDR_SIZE;
7563 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
7564
7565 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7566 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307567 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7568 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307569 }
7570
7571 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7572 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
7573 buf_ptr;
7574 WMITLV_SET_HDR(&cmd->tlv_header,
7575 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
7576 WMITLV_GET_STRUCT_TLVLEN
7577 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
7578
7579 cmd->request_id = photlist_reset->request_id;
7580 cmd->vdev_id = photlist_reset->session_id;
7581 cmd->mode = 0;
7582
7583 buf_ptr += sizeof(*cmd);
7584 WMITLV_SET_HDR(buf_ptr,
7585 WMITLV_TAG_ARRAY_STRUC,
7586 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7587 buf_ptr += WMI_TLV_HDR_SIZE +
7588 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7589
7590 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7591 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307592 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307593 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307594 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307595 }
Govind Singhb53420c2016-03-09 14:32:57 +05307596 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307597}
7598
7599/**
7600 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
7601 * @wmi_handle: wmi handle
7602 * @pstopcmd: stop scan command request params
7603 *
7604 * This function sends stop extscan request to fw.
7605 *
7606 * Return: CDF Status.
7607 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307608static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307609 struct extscan_stop_req_params *pstopcmd)
7610{
7611 wmi_extscan_stop_cmd_fixed_param *cmd;
7612 wmi_buf_t wmi_buf;
7613 uint32_t len;
7614 uint8_t *buf_ptr;
7615
7616 len = sizeof(*cmd);
7617 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7618 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307619 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7620 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307621 }
7622 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7623 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
7624 WMITLV_SET_HDR(&cmd->tlv_header,
7625 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
7626 WMITLV_GET_STRUCT_TLVLEN
7627 (wmi_extscan_stop_cmd_fixed_param));
7628
7629 cmd->request_id = pstopcmd->request_id;
7630 cmd->vdev_id = pstopcmd->session_id;
7631
7632 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7633 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307634 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307635 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307636 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307637 }
7638
Govind Singhb53420c2016-03-09 14:32:57 +05307639 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307640}
7641
7642/**
7643 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
7644 * @wmi_handle: wmi handle
7645 * @pstart: scan command request params
7646 * @buf: event buffer
7647 * @buf_len: length of buffer
7648 *
7649 * This function fills individual elements of extscan request and
7650 * TLV for buckets, channel list.
7651 *
7652 * Return: CDF Status.
7653 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007654static
Govind Singhb53420c2016-03-09 14:32:57 +05307655QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307656 struct wifi_scan_cmd_req_params *pstart,
7657 wmi_buf_t *buf, int *buf_len)
7658{
7659 wmi_extscan_start_cmd_fixed_param *cmd;
7660 wmi_extscan_bucket *dest_blist;
7661 wmi_extscan_bucket_channel *dest_clist;
7662 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
7663 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
7664 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
7665
7666 uint8_t *buf_ptr;
7667 int i, k, count = 0;
7668 int len = sizeof(*cmd);
7669 int nbuckets = pstart->numBuckets;
7670 int nchannels = 0;
7671
7672 /* These TLV's are are NULL by default */
7673 uint32_t ie_len_with_pad = 0;
7674 int num_ssid = 0;
7675 int num_bssid = 0;
7676 int ie_len = 0;
7677
7678 uint32_t base_period = pstart->basePeriod;
7679
7680 /* TLV placeholder for ssid_list (NULL) */
7681 len += WMI_TLV_HDR_SIZE;
7682 len += num_ssid * sizeof(wmi_ssid);
7683
7684 /* TLV placeholder for bssid_list (NULL) */
7685 len += WMI_TLV_HDR_SIZE;
7686 len += num_bssid * sizeof(wmi_mac_addr);
7687
7688 /* TLV placeholder for ie_data (NULL) */
7689 len += WMI_TLV_HDR_SIZE;
7690 len += ie_len * sizeof(uint32_t);
7691
7692 /* TLV placeholder for bucket */
7693 len += WMI_TLV_HDR_SIZE;
7694 len += nbuckets * sizeof(wmi_extscan_bucket);
7695
7696 /* TLV channel placeholder */
7697 len += WMI_TLV_HDR_SIZE;
7698 for (i = 0; i < nbuckets; i++) {
7699 nchannels += src_bucket->numChannels;
7700 src_bucket++;
7701 }
7702
Govind Singhb53420c2016-03-09 14:32:57 +05307703 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307704 __func__, nbuckets, nchannels);
7705 len += nchannels * sizeof(wmi_extscan_bucket_channel);
7706 /* Allocate the memory */
7707 *buf = wmi_buf_alloc(wmi_handle, len);
7708 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307709 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307710 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307711 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307712 }
7713 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7714 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
7715 WMITLV_SET_HDR(&cmd->tlv_header,
7716 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
7717 WMITLV_GET_STRUCT_TLVLEN
7718 (wmi_extscan_start_cmd_fixed_param));
7719
7720 cmd->request_id = pstart->requestId;
7721 cmd->vdev_id = pstart->sessionId;
7722 cmd->base_period = pstart->basePeriod;
7723 cmd->num_buckets = nbuckets;
7724 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05307725 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307726 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05307727 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307728 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05307729#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05307730 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
7731 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05307732 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
7733 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
7734#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307735 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7736
7737 /* The max dwell time is retrieved from the first channel
7738 * of the first bucket and kept common for all channels.
7739 */
7740 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
7741 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
7742 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
7743 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
7744 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7745 cmd->max_table_usage = pstart->report_threshold_percent;
7746 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
7747
7748 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05307749 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307750 cmd->probe_delay = 0;
7751 cmd->probe_spacing_time = 0;
7752 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307753 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
7754 WMI_SCAN_ADD_CCK_RATES |
7755 WMI_SCAN_ADD_OFDM_RATES |
7756 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
7757 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05307758 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
7759 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05307760 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307761 cmd->num_ssids = 0;
7762 cmd->num_bssid = 0;
7763 cmd->ie_len = 0;
7764 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
7765 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
7766
7767 buf_ptr += sizeof(*cmd);
7768 WMITLV_SET_HDR(buf_ptr,
7769 WMITLV_TAG_ARRAY_FIXED_STRUC,
7770 num_ssid * sizeof(wmi_ssid));
7771 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
7772
7773 WMITLV_SET_HDR(buf_ptr,
7774 WMITLV_TAG_ARRAY_FIXED_STRUC,
7775 num_bssid * sizeof(wmi_mac_addr));
7776 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7777
7778 ie_len_with_pad = 0;
7779 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7780 ie_len_with_pad);
7781 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7782
7783 WMITLV_SET_HDR(buf_ptr,
7784 WMITLV_TAG_ARRAY_STRUC,
7785 nbuckets * sizeof(wmi_extscan_bucket));
7786 dest_blist = (wmi_extscan_bucket *)
7787 (buf_ptr + WMI_TLV_HDR_SIZE);
7788 src_bucket = pstart->buckets;
7789
7790 /* Retrieve scanning information from each bucket and
7791 * channels and send it to the target
7792 */
7793 for (i = 0; i < nbuckets; i++) {
7794 WMITLV_SET_HDR(dest_blist,
7795 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7796 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7797
7798 dest_blist->bucket_id = src_bucket->bucket;
7799 dest_blist->base_period_multiplier =
7800 src_bucket->period / base_period;
7801 dest_blist->min_period = src_bucket->period;
7802 dest_blist->max_period = src_bucket->max_period;
7803 dest_blist->exp_backoff = src_bucket->exponent;
7804 dest_blist->exp_max_step_count = src_bucket->step_count;
7805 dest_blist->channel_band = src_bucket->band;
7806 dest_blist->num_channels = src_bucket->numChannels;
7807 dest_blist->notify_extscan_events = 0;
7808
7809 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7810 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007811 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7812 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307813
7814 if (src_bucket->reportEvents &
7815 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7816 dest_blist->forwarding_flags =
7817 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7818 dest_blist->notify_extscan_events |=
7819 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7820 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7821 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7822 } else {
7823 dest_blist->forwarding_flags =
7824 WMI_EXTSCAN_NO_FORWARDING;
7825 }
7826
7827 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7828 dest_blist->configuration_flags = 0;
7829 else
7830 dest_blist->configuration_flags =
7831 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7832
Govind Singhb53420c2016-03-09 14:32:57 +05307833 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307834 __func__, dest_blist->notify_extscan_events,
7835 dest_blist->configuration_flags,
7836 dest_blist->forwarding_flags);
7837
7838 dest_blist->min_dwell_time_active =
7839 src_bucket->min_dwell_time_active;
7840 dest_blist->max_dwell_time_active =
7841 src_bucket->max_dwell_time_active;
7842 dest_blist->min_dwell_time_passive =
7843 src_bucket->min_dwell_time_passive;
7844 dest_blist->max_dwell_time_passive =
7845 src_bucket->max_dwell_time_passive;
7846 src_channel = src_bucket->channels;
7847
7848 /* save the channel info to later populate
7849 * the channel TLV
7850 */
7851 for (k = 0; k < src_bucket->numChannels; k++) {
7852 save_channel[count++].channel = src_channel->channel;
7853 src_channel++;
7854 }
7855 dest_blist++;
7856 src_bucket++;
7857 }
7858 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7859 WMITLV_SET_HDR(buf_ptr,
7860 WMITLV_TAG_ARRAY_STRUC,
7861 nchannels * sizeof(wmi_extscan_bucket_channel));
7862 dest_clist = (wmi_extscan_bucket_channel *)
7863 (buf_ptr + WMI_TLV_HDR_SIZE);
7864
7865 /* Active or passive scan is based on the bucket dwell time
7866 * and channel specific active,passive scans are not
7867 * supported yet
7868 */
7869 for (i = 0; i < nchannels; i++) {
7870 WMITLV_SET_HDR(dest_clist,
7871 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7872 WMITLV_GET_STRUCT_TLVLEN
7873 (wmi_extscan_bucket_channel));
7874 dest_clist->channel = save_channel[i].channel;
7875 dest_clist++;
7876 }
7877 buf_ptr += WMI_TLV_HDR_SIZE +
7878 (nchannels * sizeof(wmi_extscan_bucket_channel));
7879 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307880 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307881}
7882
7883/**
7884 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7885 * @wmi_handle: wmi handle
7886 * @pstart: scan command request params
7887 *
7888 * This function sends start extscan request to fw.
7889 *
7890 * Return: CDF Status.
7891 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307892static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307893 struct wifi_scan_cmd_req_params *pstart)
7894{
Govind Singhb53420c2016-03-09 14:32:57 +05307895 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307896 wmi_buf_t buf;
7897 int len;
7898
7899 /* Fill individual elements of extscan request and
7900 * TLV for buckets, channel list.
7901 */
Govind Singhb53420c2016-03-09 14:32:57 +05307902 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307903 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307904 if (qdf_status != QDF_STATUS_SUCCESS) {
7905 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7906 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307907 }
7908 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307909 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307910 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307911 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307912 }
7913 if (wmi_unified_cmd_send(wmi_handle, buf,
7914 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307915 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307916 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307917 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307918 }
7919
Govind Singhb53420c2016-03-09 14:32:57 +05307920 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307921}
7922
7923/**
7924 * send_plm_stop_cmd_tlv() - plm stop request
7925 * @wmi_handle: wmi handle
7926 * @plm: plm request parameters
7927 *
7928 * This function request FW to stop PLM.
7929 *
7930 * Return: CDF status
7931 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307932static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307933 const struct plm_req_params *plm)
7934{
7935 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7936 int32_t len;
7937 wmi_buf_t buf;
7938 uint8_t *buf_ptr;
7939 int ret;
7940
7941 len = sizeof(*cmd);
7942 buf = wmi_buf_alloc(wmi_handle, len);
7943 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307944 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7945 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307946 }
7947
7948 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7949
7950 buf_ptr = (uint8_t *) cmd;
7951
7952 WMITLV_SET_HDR(&cmd->tlv_header,
7953 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7954 WMITLV_GET_STRUCT_TLVLEN
7955 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7956
7957 cmd->vdev_id = plm->session_id;
7958
7959 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307960 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307961
7962 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7963 WMI_VDEV_PLMREQ_STOP_CMDID);
7964 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307965 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307966 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307967 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307968 }
7969
Govind Singhb53420c2016-03-09 14:32:57 +05307970 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307971}
7972
7973/**
7974 * send_plm_start_cmd_tlv() - plm start request
7975 * @wmi_handle: wmi handle
7976 * @plm: plm request parameters
7977 *
7978 * This function request FW to start PLM.
7979 *
7980 * Return: CDF status
7981 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307982static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307983 const struct plm_req_params *plm,
7984 uint32_t *gchannel_list)
7985{
7986 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7987 uint32_t *channel_list;
7988 int32_t len;
7989 wmi_buf_t buf;
7990 uint8_t *buf_ptr;
7991 uint8_t count;
7992 int ret;
7993
7994 /* TLV place holder for channel_list */
7995 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7996 len += sizeof(uint32_t) * plm->plm_num_ch;
7997
7998 buf = wmi_buf_alloc(wmi_handle, len);
7999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308000 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8001 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308002 }
8003 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
8004
8005 buf_ptr = (uint8_t *) cmd;
8006
8007 WMITLV_SET_HDR(&cmd->tlv_header,
8008 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
8009 WMITLV_GET_STRUCT_TLVLEN
8010 (wmi_vdev_plmreq_start_cmd_fixed_param));
8011
8012 cmd->vdev_id = plm->session_id;
8013
8014 cmd->meas_token = plm->meas_token;
8015 cmd->dialog_token = plm->diag_token;
8016 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05308017 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308018 cmd->off_duration = plm->meas_duration;
8019 cmd->burst_cycle = plm->burst_len;
8020 cmd->tx_power = plm->desired_tx_pwr;
8021 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
8022 cmd->num_chans = plm->plm_num_ch;
8023
8024 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
8025
Govind Singhb53420c2016-03-09 14:32:57 +05308026 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
8027 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
8028 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
8029 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
8030 WMI_LOGD("off_duration: %d", cmd->off_duration);
8031 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
8032 WMI_LOGD("tx_power: %d", cmd->tx_power);
8033 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308034
8035 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8036 (cmd->num_chans * sizeof(uint32_t)));
8037
8038 buf_ptr += WMI_TLV_HDR_SIZE;
8039 if (cmd->num_chans) {
8040 channel_list = (uint32_t *) buf_ptr;
8041 for (count = 0; count < cmd->num_chans; count++) {
8042 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308043 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308044 channel_list[count] =
8045 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308046 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308047 }
8048 buf_ptr += cmd->num_chans * sizeof(uint32_t);
8049 }
8050
8051 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8052 WMI_VDEV_PLMREQ_START_CMDID);
8053 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308054 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308055 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308056 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308057 }
8058
Govind Singhb53420c2016-03-09 14:32:57 +05308059 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308060}
8061
8062/**
8063 * send_pno_stop_cmd_tlv() - PNO stop request
8064 * @wmi_handle: wmi handle
8065 * @vdev_id: vdev id
8066 *
8067 * This function request FW to stop ongoing PNO operation.
8068 *
8069 * Return: CDF status
8070 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308071static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308072{
8073 wmi_nlo_config_cmd_fixed_param *cmd;
8074 int32_t len = sizeof(*cmd);
8075 wmi_buf_t buf;
8076 uint8_t *buf_ptr;
8077 int ret;
8078
8079 /*
8080 * TLV place holder for array of structures nlo_configured_parameters
8081 * TLV place holder for array of uint32_t channel_list
8082 * TLV place holder for chnl prediction cfg
8083 */
8084 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
8085 buf = wmi_buf_alloc(wmi_handle, len);
8086 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308087 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8088 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308089 }
8090
8091 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8092 buf_ptr = (uint8_t *) cmd;
8093
8094 WMITLV_SET_HDR(&cmd->tlv_header,
8095 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8096 WMITLV_GET_STRUCT_TLVLEN
8097 (wmi_nlo_config_cmd_fixed_param));
8098
8099 cmd->vdev_id = vdev_id;
8100 cmd->flags = WMI_NLO_CONFIG_STOP;
8101 buf_ptr += sizeof(*cmd);
8102
8103 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8104 buf_ptr += WMI_TLV_HDR_SIZE;
8105
8106 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
8107 buf_ptr += WMI_TLV_HDR_SIZE;
8108
8109 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8110 buf_ptr += WMI_TLV_HDR_SIZE;
8111
8112
8113 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8114 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8115 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308116 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308117 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308118 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308119 }
8120
Govind Singhb53420c2016-03-09 14:32:57 +05308121 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308122}
8123
8124/**
Govind Singhccb0c272016-04-01 16:30:08 +05308125 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
8126 * @buf_ptr: Buffer passed by upper layers
8127 * @pno: Buffer to be sent to the firmware
8128 *
8129 * Copy the PNO Channel prediction configuration parameters
8130 * passed by the upper layers to a WMI format TLV and send it
8131 * down to the firmware.
8132 *
8133 * Return: None
8134 */
8135static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
8136 struct pno_scan_req_params *pno)
8137{
8138 nlo_channel_prediction_cfg *channel_prediction_cfg =
8139 (nlo_channel_prediction_cfg *) buf_ptr;
8140 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
8141 WMITLV_TAG_ARRAY_BYTE,
8142 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05308143#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05308144 channel_prediction_cfg->enable = pno->pno_channel_prediction;
8145 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
8146 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
8147 channel_prediction_cfg->full_scan_period_ms =
8148 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05308149#endif
Govind Singhccb0c272016-04-01 16:30:08 +05308150 buf_ptr += sizeof(nlo_channel_prediction_cfg);
8151 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
8152 channel_prediction_cfg->enable,
8153 channel_prediction_cfg->top_k_num,
8154 channel_prediction_cfg->stationary_threshold,
8155 channel_prediction_cfg->full_scan_period_ms);
8156}
8157
8158/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008159 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
8160 * @wmi_handle: wmi handle
8161 * @params: configuration parameters
8162 *
8163 * Return: QDF_STATUS
8164 */
8165static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
8166 struct nlo_mawc_params *params)
8167{
8168 wmi_buf_t buf = NULL;
8169 QDF_STATUS status;
8170 int len;
8171 uint8_t *buf_ptr;
8172 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
8173
8174 len = sizeof(*wmi_nlo_mawc_params);
8175 buf = wmi_buf_alloc(wmi_handle, len);
8176 if (!buf) {
8177 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8178 return QDF_STATUS_E_NOMEM;
8179 }
8180
8181 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8182 wmi_nlo_mawc_params =
8183 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
8184 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
8185 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
8186 WMITLV_GET_STRUCT_TLVLEN
8187 (wmi_nlo_configure_mawc_cmd_fixed_param));
8188 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
8189 if (params->enable)
8190 wmi_nlo_mawc_params->enable = 1;
8191 else
8192 wmi_nlo_mawc_params->enable = 0;
8193 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
8194 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
8195 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07008196 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
8197 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
8198 wmi_nlo_mawc_params->exp_backoff_ratio,
8199 wmi_nlo_mawc_params->init_scan_interval,
8200 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008201
8202 status = wmi_unified_cmd_send(wmi_handle, buf,
8203 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
8204 if (QDF_IS_STATUS_ERROR(status)) {
8205 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
8206 status);
8207 wmi_buf_free(buf);
8208 return QDF_STATUS_E_FAILURE;
8209 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008210
8211 return QDF_STATUS_SUCCESS;
8212}
8213
8214/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05308215 * send_pno_start_cmd_tlv() - PNO start request
8216 * @wmi_handle: wmi handle
8217 * @pno: PNO request
8218 *
8219 * This function request FW to start PNO request.
8220 * Request: CDF status
8221 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308222static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05308223 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308224{
8225 wmi_nlo_config_cmd_fixed_param *cmd;
8226 nlo_configured_parameters *nlo_list;
8227 uint32_t *channel_list;
8228 int32_t len;
8229 wmi_buf_t buf;
8230 uint8_t *buf_ptr;
8231 uint8_t i;
8232 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308233 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308234 connected_nlo_rssi_params *nlo_relative_rssi;
8235 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308236
8237 /*
8238 * TLV place holder for array nlo_configured_parameters(nlo_list)
8239 * TLV place holder for array of uint32_t channel_list
8240 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308241 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308242 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05308243 */
8244 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308245 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308246 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308247
Abhishek Singh5987b632017-03-03 22:09:07 +05308248 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308249 WMI_NLO_MAX_CHAN);
8250 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05308251 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308252 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308253 len += sizeof(enlo_candidate_score_params);
8254 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308255 len += sizeof(connected_nlo_rssi_params);
8256 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308257
8258 buf = wmi_buf_alloc(wmi_handle, len);
8259 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308260 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8261 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308262 }
8263
8264 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8265
8266 buf_ptr = (uint8_t *) cmd;
8267 WMITLV_SET_HDR(&cmd->tlv_header,
8268 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8269 WMITLV_GET_STRUCT_TLVLEN
8270 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05308271 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308272 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
8273
Govind Singh87542482016-06-08 19:40:11 +05308274#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05308275 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05308276 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05308277#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05308278 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05308279 cmd->active_dwell_time = pno->active_dwell_time;
8280 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308281
Manjeet Singhcd2dc062016-08-11 15:31:34 +05308282 if (pno->do_passive_scan)
8283 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308284 /* Copy scan interval */
8285 cmd->fast_scan_period = pno->fast_scan_period;
8286 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08008287 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308288 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07008289 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05308290 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308291 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05308292 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308293
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05308294 /* mac randomization attributes */
8295 if (pno->scan_random.randomize) {
8296 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
8297 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
8298 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
8299 pno->scan_random.mac_mask,
8300 &cmd->mac_addr,
8301 &cmd->mac_mask);
8302 }
8303
Govind Singh4eacd2b2016-03-07 14:24:22 +05308304 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
8305
Abhishek Singh5987b632017-03-03 22:09:07 +05308306 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05308307 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308308 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8309 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
8310 buf_ptr += WMI_TLV_HDR_SIZE;
8311
8312 nlo_list = (nlo_configured_parameters *) buf_ptr;
8313 for (i = 0; i < cmd->no_of_ssids; i++) {
8314 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
8315 WMITLV_TAG_ARRAY_BYTE,
8316 WMITLV_GET_STRUCT_TLVLEN
8317 (nlo_configured_parameters));
8318 /* Copy ssid and it's length */
8319 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05308320 nlo_list[i].ssid.ssid.ssid_len =
8321 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05308322 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05308323 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308324 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05308325 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308326 nlo_list[i].ssid.ssid.ssid_len,
8327 (char *)nlo_list[i].ssid.ssid.ssid,
8328 nlo_list[i].ssid.ssid.ssid_len);
8329
8330 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05308331 if (pno->networks_list[i].rssi_thresh &&
8332 pno->networks_list[i].rssi_thresh >
8333 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05308334 nlo_list[i].rssi_cond.valid = true;
8335 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05308336 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05308337 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308338 nlo_list[i].rssi_cond.rssi);
8339 }
8340 nlo_list[i].bcast_nw_type.valid = true;
8341 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05308342 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07008343 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308344 nlo_list[i].bcast_nw_type.bcast_nw_type);
8345 }
8346 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
8347
8348 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05308349 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308350 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05308351 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308352 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8353 (cmd->num_of_channels * sizeof(uint32_t)));
8354 buf_ptr += WMI_TLV_HDR_SIZE;
8355
8356 channel_list = (uint32_t *) buf_ptr;
8357 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05308358 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05308359
8360 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05308361 channel_list[i] =
8362 wlan_chan_to_freq(pno->
8363 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308364
Govind Singhb53420c2016-03-09 14:32:57 +05308365 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308366 }
8367 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
8368 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8369 sizeof(nlo_channel_prediction_cfg));
8370 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05308371 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308372 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308373 /** TODO: Discrete firmware doesn't have command/option to configure
8374 * App IE which comes from wpa_supplicant as of part PNO start request.
8375 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
8377 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
8378 buf_ptr += sizeof(enlo_candidate_score_params);
8379
8380 if (ie_whitelist->white_list) {
8381 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
8382 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
8383 &cmd->num_vendor_oui,
8384 ie_whitelist);
8385 }
8386
8387 /* ie white list */
8388 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8389 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
8390 buf_ptr += WMI_TLV_HDR_SIZE;
8391 if (cmd->num_vendor_oui != 0) {
8392 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
8393 ie_whitelist->voui);
8394 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
8395 }
8396
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308397 if (pno->relative_rssi_set)
8398 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
8399
8400 /*
8401 * Firmware calculation using connected PNO params:
8402 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
8403 * deduction of rssi_pref for chosen band_pref and
8404 * addition of rssi_pref for remaining bands (other than chosen band).
8405 */
8406 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
8407 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
8408 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
8409 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
8410 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
8411 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
8412 buf_ptr += sizeof(*nlo_relative_rssi);
8413
8414 /*
8415 * As of now Kernel and Host supports one band and rssi preference.
8416 * Firmware supports array of band and rssi preferences
8417 */
8418 cmd->num_cnlo_band_pref = 1;
8419 WMITLV_SET_HDR(buf_ptr,
8420 WMITLV_TAG_ARRAY_STRUC,
8421 cmd->num_cnlo_band_pref *
8422 sizeof(connected_nlo_bss_band_rssi_pref));
8423 buf_ptr += WMI_TLV_HDR_SIZE;
8424
8425 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
8426 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
8427 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
8428 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
8429 WMITLV_GET_STRUCT_TLVLEN(
8430 connected_nlo_bss_band_rssi_pref));
8431 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
8432 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
8433 WMI_LOGI("band_pref %d, rssi_pref %d",
8434 nlo_band_rssi[i].band,
8435 nlo_band_rssi[i].rssi_pref);
8436 }
8437 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
8438
Govind Singh4eacd2b2016-03-07 14:24:22 +05308439 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8440 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8441 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308442 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308443 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308444 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308445 }
8446
Govind Singhb53420c2016-03-09 14:32:57 +05308447 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308448}
8449
8450/* send_set_ric_req_cmd_tlv() - set ric request element
8451 * @wmi_handle: wmi handle
8452 * @msg: message
8453 * @is_add_ts: is addts required
8454 *
8455 * This function sets ric request element for 11r roaming.
8456 *
8457 * Return: CDF status
8458 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308459static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308460 void *msg, uint8_t is_add_ts)
8461{
8462 wmi_ric_request_fixed_param *cmd;
8463 wmi_ric_tspec *tspec_param;
8464 wmi_buf_t buf;
8465 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05308466 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308467 int32_t len = sizeof(wmi_ric_request_fixed_param) +
8468 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
8469
8470 buf = wmi_buf_alloc(wmi_handle, len);
8471 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308472 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8473 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308474 }
8475
8476 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8477
8478 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
8479 WMITLV_SET_HDR(&cmd->tlv_header,
8480 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
8481 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
8482 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07008483 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308484 else
8485 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
8486 cmd->num_ric_request = 1;
8487 cmd->is_add_ric = is_add_ts;
8488
8489 buf_ptr += sizeof(wmi_ric_request_fixed_param);
8490 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
8491
8492 buf_ptr += WMI_TLV_HDR_SIZE;
8493 tspec_param = (wmi_ric_tspec *) buf_ptr;
8494 WMITLV_SET_HDR(&tspec_param->tlv_header,
8495 WMITLV_TAG_STRUC_wmi_ric_tspec,
8496 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
8497
8498 if (is_add_ts)
8499 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05308500#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05308501 else
8502 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05308503#endif
8504 if (ptspecIE) {
8505 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308506#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05308507 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
8508 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308509#else
Govind Singh87542482016-06-08 19:40:11 +05308510 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
8511 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308512#endif /* ANI_LITTLE_BIT_ENDIAN */
8513
Govind Singh87542482016-06-08 19:40:11 +05308514 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
8515 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
8516 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
8517 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
8518 tspec_param->inactivity_interval = ptspecIE->inactInterval;
8519 tspec_param->suspension_interval = ptspecIE->suspendInterval;
8520 tspec_param->svc_start_time = ptspecIE->svcStartTime;
8521 tspec_param->min_data_rate = ptspecIE->minDataRate;
8522 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
8523 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
8524 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
8525 tspec_param->delay_bound = ptspecIE->delayBound;
8526 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
8527 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
8528 tspec_param->medium_time = 0;
8529 }
Govind Singhb53420c2016-03-09 14:32:57 +05308530 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308531
8532 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8533 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308534 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308535 __func__);
8536 if (is_add_ts)
8537 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05308538 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308539 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308540 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308541 }
8542
Govind Singhb53420c2016-03-09 14:32:57 +05308543 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308544}
8545
8546/**
8547 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
8548 * @wmi_handle: wmi handle
8549 * @clear_req: ll stats clear request command params
8550 *
Govind Singhb53420c2016-03-09 14:32:57 +05308551 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308552 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308553static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308554 const struct ll_stats_clear_params *clear_req,
8555 uint8_t addr[IEEE80211_ADDR_LEN])
8556{
8557 wmi_clear_link_stats_cmd_fixed_param *cmd;
8558 int32_t len;
8559 wmi_buf_t buf;
8560 uint8_t *buf_ptr;
8561 int ret;
8562
8563 len = sizeof(*cmd);
8564 buf = wmi_buf_alloc(wmi_handle, len);
8565
8566 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308567 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8568 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308569 }
8570
8571 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308572 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308573 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
8574
8575 WMITLV_SET_HDR(&cmd->tlv_header,
8576 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
8577 WMITLV_GET_STRUCT_TLVLEN
8578 (wmi_clear_link_stats_cmd_fixed_param));
8579
8580 cmd->stop_stats_collection_req = clear_req->stop_req;
8581 cmd->vdev_id = clear_req->sta_id;
8582 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
8583
8584 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8585 &cmd->peer_macaddr);
8586
Govind Singhb53420c2016-03-09 14:32:57 +05308587 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
8588 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
8589 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
8590 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
8591 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308592 cmd->peer_macaddr); */
8593
8594 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8595 WMI_CLEAR_LINK_STATS_CMDID);
8596 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308597 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308598 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308599 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308600 }
8601
Govind Singhb53420c2016-03-09 14:32:57 +05308602 WMI_LOGD("Clear Link Layer Stats request sent successfully");
8603 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308604}
8605
8606/**
8607 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
8608 * @wmi_handle: wmi handle
8609 * @setReq: ll stats set request command params
8610 *
Govind Singhb53420c2016-03-09 14:32:57 +05308611 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308612 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308613static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308614 const struct ll_stats_set_params *set_req)
8615{
8616 wmi_start_link_stats_cmd_fixed_param *cmd;
8617 int32_t len;
8618 wmi_buf_t buf;
8619 uint8_t *buf_ptr;
8620 int ret;
8621
8622 len = sizeof(*cmd);
8623 buf = wmi_buf_alloc(wmi_handle, len);
8624
8625 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308626 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8627 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308628 }
8629
8630 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308631 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308632 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
8633
8634 WMITLV_SET_HDR(&cmd->tlv_header,
8635 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
8636 WMITLV_GET_STRUCT_TLVLEN
8637 (wmi_start_link_stats_cmd_fixed_param));
8638
8639 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
8640 cmd->aggressive_statistics_gathering =
8641 set_req->aggressive_statistics_gathering;
8642
Govind Singhb53420c2016-03-09 14:32:57 +05308643 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
8644 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
8645 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308646
8647 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8648 WMI_START_LINK_STATS_CMDID);
8649 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308650 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308651 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308652 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308653 }
8654
Govind Singhb53420c2016-03-09 14:32:57 +05308655 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308656}
8657
8658/**
8659 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
8660 * @wmi_handle:wmi handle
8661 * @get_req:ll stats get request command params
8662 * @addr: mac address
8663 *
Govind Singhb53420c2016-03-09 14:32:57 +05308664 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308665 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308666static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308667 const struct ll_stats_get_params *get_req,
8668 uint8_t addr[IEEE80211_ADDR_LEN])
8669{
8670 wmi_request_link_stats_cmd_fixed_param *cmd;
8671 int32_t len;
8672 wmi_buf_t buf;
8673 uint8_t *buf_ptr;
8674 int ret;
8675
8676 len = sizeof(*cmd);
8677 buf = wmi_buf_alloc(wmi_handle, len);
8678
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308679 if (!buf) {
8680 WMI_LOGE("%s: buf allocation failed", __func__);
8681 return QDF_STATUS_E_NOMEM;
8682 }
8683
Govind Singh4eacd2b2016-03-07 14:24:22 +05308684 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308685 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308686 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8687
8688 WMITLV_SET_HDR(&cmd->tlv_header,
8689 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8690 WMITLV_GET_STRUCT_TLVLEN
8691 (wmi_request_link_stats_cmd_fixed_param));
8692
8693 cmd->request_id = get_req->req_id;
8694 cmd->stats_type = get_req->param_id_mask;
8695 cmd->vdev_id = get_req->sta_id;
8696
8697 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8698 &cmd->peer_macaddr);
8699
Govind Singhb53420c2016-03-09 14:32:57 +05308700 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008701 WMI_LOGD("Request ID : %u", cmd->request_id);
8702 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308703 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8704 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308705
8706 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8707 WMI_REQUEST_LINK_STATS_CMDID);
8708 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308709 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308710 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308711 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308712 }
8713
Govind Singhb53420c2016-03-09 14:32:57 +05308714 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308715}
8716
Govind Singh4eacd2b2016-03-07 14:24:22 +05308717
Govind Singh20c5dac2016-03-07 15:33:31 +05308718/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308719 * send_congestion_cmd_tlv() - send request to fw to get CCA
8720 * @wmi_handle: wmi handle
8721 * @vdev_id: vdev id
8722 *
8723 * Return: CDF status
8724 */
8725static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05308726 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308727{
8728 wmi_buf_t buf;
8729 wmi_request_stats_cmd_fixed_param *cmd;
8730 uint8_t len;
8731 uint8_t *buf_ptr;
8732
8733 len = sizeof(*cmd);
8734 buf = wmi_buf_alloc(wmi_handle, len);
8735 if (!buf) {
8736 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8737 return QDF_STATUS_E_FAILURE;
8738 }
8739
8740 buf_ptr = wmi_buf_data(buf);
8741 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8742 WMITLV_SET_HDR(&cmd->tlv_header,
8743 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8744 WMITLV_GET_STRUCT_TLVLEN
8745 (wmi_request_stats_cmd_fixed_param));
8746
8747 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8748 cmd->vdev_id = vdev_id;
8749 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8750 cmd->vdev_id, cmd->stats_id);
8751
8752 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8753 WMI_REQUEST_STATS_CMDID)) {
8754 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8755 __func__);
8756 wmi_buf_free(buf);
8757 return QDF_STATUS_E_FAILURE;
8758 }
8759
8760 return QDF_STATUS_SUCCESS;
8761}
8762
8763/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308764 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8765 * @wmi_handle: wmi handle
8766 * @rssi_req: get RSSI request
8767 *
8768 * Return: CDF status
8769 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308770static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308771{
8772 wmi_buf_t buf;
8773 wmi_request_stats_cmd_fixed_param *cmd;
8774 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8775
8776 buf = wmi_buf_alloc(wmi_handle, len);
8777 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308778 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8779 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308780 }
8781
8782 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8783 WMITLV_SET_HDR(&cmd->tlv_header,
8784 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8785 WMITLV_GET_STRUCT_TLVLEN
8786 (wmi_request_stats_cmd_fixed_param));
8787 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8788 if (wmi_unified_cmd_send
8789 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308790 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308791 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308792 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308793 }
8794
Govind Singhb53420c2016-03-09 14:32:57 +05308795 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308796}
8797
8798/**
8799 * send_snr_cmd_tlv() - get RSSI from fw
8800 * @wmi_handle: wmi handle
8801 * @vdev_id: vdev id
8802 *
8803 * Return: CDF status
8804 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308805static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308806{
8807 wmi_buf_t buf;
8808 wmi_request_stats_cmd_fixed_param *cmd;
8809 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8810
8811 buf = wmi_buf_alloc(wmi_handle, len);
8812 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308813 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8814 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308815 }
8816
8817 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8818 cmd->vdev_id = vdev_id;
8819
8820 WMITLV_SET_HDR(&cmd->tlv_header,
8821 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8822 WMITLV_GET_STRUCT_TLVLEN
8823 (wmi_request_stats_cmd_fixed_param));
8824 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8825 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8826 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308827 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308828 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308829 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308830 }
8831
Govind Singhb53420c2016-03-09 14:32:57 +05308832 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308833}
8834
8835/**
8836 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8837 * @wmi_handle: wmi handle
8838 * @link_status: get link params
8839 *
8840 * Return: CDF status
8841 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308842static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308843 struct link_status_params *link_status)
8844{
8845 wmi_buf_t buf;
8846 wmi_request_stats_cmd_fixed_param *cmd;
8847 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8848
8849 buf = wmi_buf_alloc(wmi_handle, len);
8850 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308851 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8852 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308853 }
8854
8855 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8856 WMITLV_SET_HDR(&cmd->tlv_header,
8857 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8858 WMITLV_GET_STRUCT_TLVLEN
8859 (wmi_request_stats_cmd_fixed_param));
8860 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8861 cmd->vdev_id = link_status->session_id;
8862 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8863 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308864 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308865 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308866 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308867 }
8868
Govind Singhb53420c2016-03-09 14:32:57 +05308869 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308870}
8871
Govind Singh20c5dac2016-03-07 15:33:31 +05308872/**
8873 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8874 * @wmi_handle: wmi handle
8875 * @ta_dhcp_ind: DHCP indication parameter
8876 *
8877 * Return: CDF Status
8878 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308879static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308880 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8881{
Govind Singh67922e82016-04-01 16:48:57 +05308882 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308883 wmi_buf_t buf = NULL;
8884 uint8_t *buf_ptr;
8885 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8886 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8887
8888
8889 buf = wmi_buf_alloc(wmi_handle, len);
8890 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308891 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8892 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308893 }
8894
8895 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8896 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8897 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8898 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8899 WMITLV_GET_STRUCT_TLVLEN
8900 (wmi_peer_set_param_cmd_fixed_param));
8901
8902 /* fill in values */
8903 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8904 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8905 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308906 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308907 &ta_dhcp_ind->peer_macaddr,
8908 sizeof(ta_dhcp_ind->peer_macaddr));
8909
8910 status = wmi_unified_cmd_send(wmi_handle, buf,
8911 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308912 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308913 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308914 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308915 wmi_buf_free(buf);
8916 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308917
Govind Singh67922e82016-04-01 16:48:57 +05308918 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308919}
8920
8921/**
8922 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8923 * @wmi_handle: wmi handle
8924 * @pLinkSpeed: link speed info
8925 *
8926 * Return: CDF status
8927 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308928static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308929 wmi_mac_addr peer_macaddr)
8930{
8931 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8932 wmi_buf_t wmi_buf;
8933 uint32_t len;
8934 uint8_t *buf_ptr;
8935
8936 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8937 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8938 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308939 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8940 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308941 }
8942 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8943
8944 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8945 WMITLV_SET_HDR(&cmd->tlv_header,
8946 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8947 WMITLV_GET_STRUCT_TLVLEN
8948 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8949
8950 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308951 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308952 &peer_macaddr,
8953 sizeof(peer_macaddr));
8954
8955
8956 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8957 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308958 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308959 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308960 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308961 }
Govind Singhb53420c2016-03-09 14:32:57 +05308962 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308963}
8964
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308965#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308966/**
8967 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8968 * @wmi_handle: wmi handler
8969 * @egap_params: pointer to egap_params
8970 *
8971 * Return: 0 for success, otherwise appropriate error code
8972 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308973static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308974 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308975{
8976 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8977 wmi_buf_t buf;
8978 int32_t err;
8979
8980 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8981 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308982 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8983 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308984 }
8985 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8986 WMITLV_SET_HDR(&cmd->tlv_header,
8987 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8988 WMITLV_GET_STRUCT_TLVLEN(
8989 wmi_ap_ps_egap_param_cmd_fixed_param));
8990
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308991 cmd->enable = egap_params->host_enable_egap;
8992 cmd->inactivity_time = egap_params->egap_inactivity_time;
8993 cmd->wait_time = egap_params->egap_wait_time;
8994 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308995 err = wmi_unified_cmd_send(wmi_handle, buf,
8996 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8997 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308998 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308999 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309000 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309001 }
9002
Govind Singhb53420c2016-03-09 14:32:57 +05309003 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309004}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05309005#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05309006
9007/**
9008 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
9009 * @wmi_handl: wmi handle
9010 * @cmd: Profiling command index
9011 * @value1: parameter1 value
9012 * @value2: parameter2 value
9013 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309014 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309015 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309016static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309017 uint32_t cmd, uint32_t value1, uint32_t value2)
9018{
9019 wmi_buf_t buf;
9020 int32_t len = 0;
9021 int ret;
9022 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
9023 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
9024 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
9025 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
9026
9027 switch (cmd) {
9028 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
9029 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
9030 buf = wmi_buf_alloc(wmi_handle, len);
9031 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309032 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309033 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309034 }
9035 prof_trig_cmd =
9036 (wmi_wlan_profile_trigger_cmd_fixed_param *)
9037 wmi_buf_data(buf);
9038 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
9039 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
9040 WMITLV_GET_STRUCT_TLVLEN
9041 (wmi_wlan_profile_trigger_cmd_fixed_param));
9042 prof_trig_cmd->enable = value1;
9043 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9044 WMI_WLAN_PROFILE_TRIGGER_CMDID);
9045 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309046 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309047 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309048 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309049 return ret;
9050 }
9051 break;
9052
9053 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
9054 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
9055 buf = wmi_buf_alloc(wmi_handle, len);
9056 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309057 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309058 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309059 }
9060 profile_getdata_cmd =
9061 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
9062 wmi_buf_data(buf);
9063 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
9064 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
9065 WMITLV_GET_STRUCT_TLVLEN
9066 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
9067 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9068 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
9069 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309070 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309071 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309072 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309073 return ret;
9074 }
9075 break;
9076
9077 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
9078 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
9079 buf = wmi_buf_alloc(wmi_handle, len);
9080 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309081 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309082 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309083 }
9084 hist_intvl_cmd =
9085 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
9086 wmi_buf_data(buf);
9087 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
9088 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
9089 WMITLV_GET_STRUCT_TLVLEN
9090 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
9091 hist_intvl_cmd->profile_id = value1;
9092 hist_intvl_cmd->value = value2;
9093 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9094 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
9095 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309096 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309097 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309098 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309099 return ret;
9100 }
9101 break;
9102
9103 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
9104 len =
9105 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
9106 buf = wmi_buf_alloc(wmi_handle, len);
9107 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309108 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309109 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309110 }
9111 profile_enable_cmd =
9112 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
9113 wmi_buf_data(buf);
9114 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
9115 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
9116 WMITLV_GET_STRUCT_TLVLEN
9117 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
9118 profile_enable_cmd->profile_id = value1;
9119 profile_enable_cmd->enable = value2;
9120 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9121 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
9122 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309123 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309124 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309125 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309126 return ret;
9127 }
9128 break;
9129
9130 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309131 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309132 break;
9133 }
9134
9135 return 0;
9136}
9137
Paul Zhang92ab8d32017-12-08 16:08:00 +08009138static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
9139 struct wlm_latency_level_param *params)
9140{
9141 wmi_wlm_config_cmd_fixed_param *cmd;
9142 wmi_buf_t buf;
9143 uint32_t len = sizeof(*cmd);
9144 static uint32_t ll[4] = {100, 60, 40, 20};
9145
9146 buf = wmi_buf_alloc(wmi_handle, len);
9147 if (!buf) {
9148 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9149 return QDF_STATUS_E_NOMEM;
9150 }
9151 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
9152 WMITLV_SET_HDR(&cmd->tlv_header,
9153 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
9154 WMITLV_GET_STRUCT_TLVLEN
9155 (wmi_wlm_config_cmd_fixed_param));
9156 cmd->vdev_id = params->vdev_id;
9157 cmd->latency_level = params->wlm_latency_level;
9158 cmd->ul_latency = ll[params->wlm_latency_level];
9159 cmd->dl_latency = ll[params->wlm_latency_level];
9160 cmd->flags = params->wlm_latency_flags;
9161 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9162 WMI_WLM_CONFIG_CMDID)) {
9163 WMI_LOGE("%s: Failed to send setting latency config command",
9164 __func__);
9165 wmi_buf_free(buf);
9166 return QDF_STATUS_E_FAILURE;
9167 }
9168
9169 return 0;
9170}
Govind Singh20c5dac2016-03-07 15:33:31 +05309171/**
9172 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
9173 * @wmi_handle: wmi handle
9174 * @vdev_id: vdev id
9175 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309176 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309177 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309178static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309179{
9180 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
9181 wmi_buf_t buf;
9182 int32_t len = sizeof(*cmd);
9183
Govind Singhb53420c2016-03-09 14:32:57 +05309184 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309185 buf = wmi_buf_alloc(wmi_handle, len);
9186 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309187 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309188 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309189 }
9190 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
9191 wmi_buf_data(buf);
9192 WMITLV_SET_HDR(&cmd->tlv_header,
9193 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
9194 WMITLV_GET_STRUCT_TLVLEN
9195 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
9196 cmd->vdev_id = vdev_id;
9197 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
9198 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9199 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309200 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309201 __func__);
9202 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309203 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309204 }
9205
9206 return 0;
9207}
9208
9209/**
9210 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
9211 * @wmi_handle: wmi handle
9212 * @vdev_id: vdev id
9213 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309214 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309215 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309216static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309217 uint8_t vdev_id)
9218{
9219 wmi_csa_offload_enable_cmd_fixed_param *cmd;
9220 wmi_buf_t buf;
9221 int32_t len = sizeof(*cmd);
9222
Govind Singhb53420c2016-03-09 14:32:57 +05309223 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309224 buf = wmi_buf_alloc(wmi_handle, len);
9225 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309226 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309227 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309228 }
9229 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
9230 WMITLV_SET_HDR(&cmd->tlv_header,
9231 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
9232 WMITLV_GET_STRUCT_TLVLEN
9233 (wmi_csa_offload_enable_cmd_fixed_param));
9234 cmd->vdev_id = vdev_id;
9235 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
9236 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9237 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309238 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309239 __func__);
9240 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309241 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309242 }
9243
9244 return 0;
9245}
9246
Naveen Rawat42cd1e62017-05-13 15:56:57 -07009247#ifdef WLAN_FEATURE_CIF_CFR
9248/**
9249 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
9250 * @wmi_handle: wmi handle
9251 * @data_len: len of dma cfg req
9252 * @data: dma cfg req
9253 *
9254 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9255 */
9256static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9257 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
9258{
9259 wmi_buf_t buf;
9260 uint8_t *cmd;
9261 QDF_STATUS ret;
9262
9263 WMITLV_SET_HDR(cfg,
9264 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
9265 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
9266
9267 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
9268 if (!buf) {
9269 WMI_LOGE(FL("wmi_buf_alloc failed"));
9270 return QDF_STATUS_E_FAILURE;
9271 }
9272
9273 cmd = (uint8_t *) wmi_buf_data(buf);
9274 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
9275 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
9276 sizeof(*cfg));
9277 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
9278 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
9279 if (QDF_IS_STATUS_ERROR(ret)) {
9280 WMI_LOGE(FL(":wmi cmd send failed"));
9281 wmi_buf_free(buf);
9282 }
9283
9284 return ret;
9285}
9286#endif
9287
Govind Singh20c5dac2016-03-07 15:33:31 +05309288/**
Sathish Kumarf396c722017-11-17 17:30:41 +05309289 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
9290 * @wmi_handle: wmi handle
9291 * @data_len: len of dma cfg req
9292 * @data: dma cfg req
9293 *
9294 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9295 */
9296static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9297 struct direct_buf_rx_cfg_req *cfg)
9298{
9299 wmi_buf_t buf;
9300 wmi_dma_ring_cfg_req_fixed_param *cmd;
9301 QDF_STATUS ret;
9302 int32_t len = sizeof(*cmd);
9303
9304 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9305 if (!buf) {
9306 WMI_LOGE(FL("wmi_buf_alloc failed"));
9307 return QDF_STATUS_E_FAILURE;
9308 }
9309
9310 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
9311
9312 WMITLV_SET_HDR(&cmd->tlv_header,
9313 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
9314 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
9315
9316 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9317 cfg->pdev_id);
9318 cmd->mod_id = cfg->mod_id;
9319 cmd->base_paddr_lo = cfg->base_paddr_lo;
9320 cmd->base_paddr_hi = cfg->base_paddr_hi;
9321 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
9322 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
9323 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
9324 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
9325 cmd->num_elems = cfg->num_elems;
9326 cmd->buf_size = cfg->buf_size;
9327 cmd->num_resp_per_event = cfg->num_resp_per_event;
9328 cmd->event_timeout_ms = cfg->event_timeout_ms;
9329
9330 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
9331 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
9332 "head idx paddr hi %x tail idx paddr lo %x"
9333 "tail idx addr hi %x num elems %d buf size %d num resp %d"
9334 "event timeout %d\n", __func__, cmd->pdev_id,
9335 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
9336 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
9337 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
9338 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
9339 cmd->event_timeout_ms);
9340 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9341 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
9342 if (QDF_IS_STATUS_ERROR(ret)) {
9343 WMI_LOGE(FL(":wmi cmd send failed"));
9344 wmi_buf_free(buf);
9345 }
9346
9347 return ret;
9348}
9349
9350/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009351 * send_start_11d_scan_cmd_tlv() - start 11d scan request
9352 * @wmi_handle: wmi handle
9353 * @start_11d_scan: 11d scan start request parameters
9354 *
9355 * This function request FW to start 11d scan.
9356 *
9357 * Return: QDF status
9358 */
9359static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9360 struct reg_start_11d_scan_req *start_11d_scan)
9361{
9362 wmi_11d_scan_start_cmd_fixed_param *cmd;
9363 int32_t len;
9364 wmi_buf_t buf;
9365 int ret;
9366
9367 len = sizeof(*cmd);
9368 buf = wmi_buf_alloc(wmi_handle, len);
9369 if (!buf) {
9370 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9371 return QDF_STATUS_E_NOMEM;
9372 }
9373
9374 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
9375
9376 WMITLV_SET_HDR(&cmd->tlv_header,
9377 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
9378 WMITLV_GET_STRUCT_TLVLEN
9379 (wmi_11d_scan_start_cmd_fixed_param));
9380
9381 cmd->vdev_id = start_11d_scan->vdev_id;
9382 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
9383 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
9384
9385 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
9386
9387 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9388 WMI_11D_SCAN_START_CMDID);
9389 if (ret) {
9390 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
9391 wmi_buf_free(buf);
9392 return QDF_STATUS_E_FAILURE;
9393 }
9394
9395 return QDF_STATUS_SUCCESS;
9396}
9397
9398/**
9399 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
9400 * @wmi_handle: wmi handle
9401 * @start_11d_scan: 11d scan stop request parameters
9402 *
9403 * This function request FW to stop 11d scan.
9404 *
9405 * Return: QDF status
9406 */
9407static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9408 struct reg_stop_11d_scan_req *stop_11d_scan)
9409{
9410 wmi_11d_scan_stop_cmd_fixed_param *cmd;
9411 int32_t len;
9412 wmi_buf_t buf;
9413 int ret;
9414
9415 len = sizeof(*cmd);
9416 buf = wmi_buf_alloc(wmi_handle, len);
9417 if (!buf) {
9418 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9419 return QDF_STATUS_E_NOMEM;
9420 }
9421
9422 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
9423
9424 WMITLV_SET_HDR(&cmd->tlv_header,
9425 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
9426 WMITLV_GET_STRUCT_TLVLEN
9427 (wmi_11d_scan_stop_cmd_fixed_param));
9428
9429 cmd->vdev_id = stop_11d_scan->vdev_id;
9430
9431 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
9432
9433 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9434 WMI_11D_SCAN_STOP_CMDID);
9435 if (ret) {
9436 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
9437 wmi_buf_free(buf);
9438 return QDF_STATUS_E_FAILURE;
9439 }
9440
9441 return QDF_STATUS_SUCCESS;
9442}
9443
9444/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309445 * send_start_oem_data_cmd_tlv() - start OEM data request to target
9446 * @wmi_handle: wmi handle
9447 * @startOemDataReq: start request params
9448 *
9449 * Return: CDF status
9450 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309451static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07009452 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05309453 uint8_t *data)
9454{
9455 wmi_buf_t buf;
9456 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309457 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309458
9459 buf = wmi_buf_alloc(wmi_handle,
9460 (data_len + WMI_TLV_HDR_SIZE));
9461 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309462 WMI_LOGE(FL("wmi_buf_alloc failed"));
9463 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309464 }
9465
9466 cmd = (uint8_t *) wmi_buf_data(buf);
9467
9468 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
9469 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309470 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05309471 data_len);
9472
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08009473 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309474 data_len);
9475
9476 ret = wmi_unified_cmd_send(wmi_handle, buf,
9477 (data_len +
9478 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
9479
Govind Singh67922e82016-04-01 16:48:57 +05309480 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309481 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309482 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309483 }
9484
Govind Singh67922e82016-04-01 16:48:57 +05309485 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309486}
9487
9488/**
9489 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
9490 * @wmi_handle: wmi handle
9491 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
9492 *
9493 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
9494 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
9495 * to firmware based on phyerr filtering
9496 * offload status.
9497 *
9498 * Return: 1 success, 0 failure
9499 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309500static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05309501send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
9502 bool dfs_phyerr_filter_offload)
9503{
9504 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
9505 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
9506 wmi_buf_t buf;
9507 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05309508 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309509
9510
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07009511 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05309512 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309513 __func__);
9514 len = sizeof(*disable_phyerr_offload_cmd);
9515 buf = wmi_buf_alloc(wmi_handle, len);
9516 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309517 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309518 return 0;
9519 }
9520 disable_phyerr_offload_cmd =
9521 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
9522 wmi_buf_data(buf);
9523
9524 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
9525 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
9526 WMITLV_GET_STRUCT_TLVLEN
9527 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
9528
9529 /*
9530 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
9531 * to the firmware to disable the phyerror
9532 * filtering offload.
9533 */
9534 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9535 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309536 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309537 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309538 __func__, ret);
9539 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309540 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309541 }
Govind Singhb53420c2016-03-09 14:32:57 +05309542 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309543 __func__);
9544 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05309545 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309546 __func__);
9547
9548 len = sizeof(*enable_phyerr_offload_cmd);
9549 buf = wmi_buf_alloc(wmi_handle, len);
9550 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309551 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9552 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309553 }
9554
9555 enable_phyerr_offload_cmd =
9556 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
9557 wmi_buf_data(buf);
9558
9559 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
9560 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
9561 WMITLV_GET_STRUCT_TLVLEN
9562 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
9563
9564 /*
9565 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
9566 * to the firmware to enable the phyerror
9567 * filtering offload.
9568 */
9569 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9570 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
9571
Govind Singh67922e82016-04-01 16:48:57 +05309572 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309573 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309574 __func__, ret);
9575 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309576 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309577 }
Govind Singhb53420c2016-03-09 14:32:57 +05309578 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309579 __func__);
9580 }
9581
Govind Singhb53420c2016-03-09 14:32:57 +05309582 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309583}
9584
Naveen Rawata5817e72017-10-26 18:50:19 -07009585/**
9586 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
9587 * will wake up host after specified time is elapsed
9588 * @wmi_handle: wmi handle
9589 * @vdev_id: vdev id
9590 * @cookie: value to identify reason why host set up wake call.
9591 * @time: time in ms
9592 *
9593 * Return: QDF status
9594 */
9595static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9596 uint8_t vdev_id, uint32_t cookie, uint32_t time)
9597{
9598 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
9599 wmi_buf_t buf;
9600 uint8_t *buf_ptr;
9601 int32_t len;
9602 int ret;
9603
9604 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
9605 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
9606 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
9607 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
9608 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05309609 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
9610 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07009611
9612 buf = wmi_buf_alloc(wmi_handle, len);
9613 if (!buf) {
9614 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9615 return QDF_STATUS_E_NOMEM;
9616 }
9617
9618 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9619 buf_ptr = (uint8_t *) cmd;
9620
9621 WMITLV_SET_HDR(&cmd->tlv_header,
9622 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
9623 WMITLV_GET_STRUCT_TLVLEN
9624 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
9625 cmd->vdev_id = vdev_id;
9626 cmd->pattern_id = cookie,
9627 cmd->pattern_type = WOW_TIMER_PATTERN;
9628 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
9629
9630 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
9631 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9632 buf_ptr += WMI_TLV_HDR_SIZE;
9633
9634 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
9635 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9636 buf_ptr += WMI_TLV_HDR_SIZE;
9637
9638 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
9639 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9640 buf_ptr += WMI_TLV_HDR_SIZE;
9641
9642 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
9643 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9644 buf_ptr += WMI_TLV_HDR_SIZE;
9645
9646 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05309647 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07009648 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05309649 *((uint32_t *) buf_ptr) = time;
9650 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07009651
9652 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05309653 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07009654 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05309655 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07009656
9657 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
9658 __func__, time, vdev_id);
9659
9660 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9661 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9662 if (ret) {
9663 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9664 __func__);
9665 wmi_buf_free(buf);
9666 return QDF_STATUS_E_FAILURE;
9667 }
9668
9669 return QDF_STATUS_SUCCESS;
9670}
9671
Govind Singh20c5dac2016-03-07 15:33:31 +05309672#if !defined(REMOVE_PKT_LOG)
9673/**
9674 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9675 * @wmi_handle: wmi handle
9676 * @pktlog_event: pktlog event
9677 * @cmd_id: pktlog cmd id
9678 *
9679 * Return: CDF status
9680 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309681static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309682 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309683 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309684{
9685 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9686 WMI_CMD_ID CMD_ID;
9687 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9688 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9689 int len = 0;
9690 wmi_buf_t buf;
9691
9692 PKTLOG_EVENT = pktlog_event;
9693 CMD_ID = cmd_id;
9694
9695 switch (CMD_ID) {
9696 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9697 len = sizeof(*cmd);
9698 buf = wmi_buf_alloc(wmi_handle, len);
9699 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309700 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9701 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309702 }
9703 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9704 wmi_buf_data(buf);
9705 WMITLV_SET_HDR(&cmd->tlv_header,
9706 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9707 WMITLV_GET_STRUCT_TLVLEN
9708 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9709 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309710 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9711 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309712 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9713 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309714 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9715 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309716 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309717 goto wmi_send_failed;
9718 }
9719 break;
9720 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9721 len = sizeof(*disable_cmd);
9722 buf = wmi_buf_alloc(wmi_handle, len);
9723 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309724 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9725 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309726 }
9727 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9728 wmi_buf_data(buf);
9729 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9730 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9731 WMITLV_GET_STRUCT_TLVLEN
9732 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309733 disable_cmd->pdev_id =
9734 wmi_handle->ops->convert_pdev_id_host_to_target(
9735 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309736 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9737 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309738 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309739 goto wmi_send_failed;
9740 }
9741 break;
9742 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309743 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309744 break;
9745 }
9746
Govind Singhb53420c2016-03-09 14:32:57 +05309747 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309748
9749wmi_send_failed:
9750 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309751 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309752}
9753#endif /* REMOVE_PKT_LOG */
9754
9755/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309756 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9757 * @wmi_handle: wmi handle
9758 * @ptrn_id: pattern id
9759 * @vdev_id: vdev id
9760 *
9761 * Return: CDF status
9762 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309763static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9764 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309765{
9766 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9767 wmi_buf_t buf;
9768 int32_t len;
9769 int ret;
9770
9771 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9772
9773
9774 buf = wmi_buf_alloc(wmi_handle, len);
9775 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309776 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9777 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309778 }
9779
9780 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9781
9782 WMITLV_SET_HDR(&cmd->tlv_header,
9783 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9784 WMITLV_GET_STRUCT_TLVLEN(
9785 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9786 cmd->vdev_id = vdev_id;
9787 cmd->pattern_id = ptrn_id;
9788 cmd->pattern_type = WOW_BITMAP_PATTERN;
9789
Govind Singhb53420c2016-03-09 14:32:57 +05309790 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309791 cmd->pattern_id, vdev_id);
9792
9793 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9794 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9795 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309796 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309797 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309798 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309799 }
9800
Govind Singhb53420c2016-03-09 14:32:57 +05309801 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309802}
9803
9804/**
9805 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9806 * @wmi_handle: wmi handle
9807 *
9808 * Sends host wakeup indication to FW. On receiving this indication,
9809 * FW will come out of WOW.
9810 *
9811 * Return: CDF status
9812 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309813static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309814{
9815 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9816 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309817 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309818 int32_t len;
9819 int ret;
9820
9821 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9822
9823 buf = wmi_buf_alloc(wmi_handle, len);
9824 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309825 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9826 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309827 }
9828
9829 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9830 wmi_buf_data(buf);
9831 WMITLV_SET_HDR(&cmd->tlv_header,
9832 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9833 WMITLV_GET_STRUCT_TLVLEN
9834 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9835
9836
9837 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9838 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9839 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309840 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309841 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309842 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309843 }
9844
Govind Singhb53420c2016-03-09 14:32:57 +05309845 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309846}
9847
9848/**
9849 * send_del_ts_cmd_tlv() - send DELTS request to fw
9850 * @wmi_handle: wmi handle
9851 * @msg: delts params
9852 *
9853 * Return: CDF status
9854 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309855static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309856 uint8_t ac)
9857{
9858 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9859 wmi_buf_t buf;
9860 int32_t len = sizeof(*cmd);
9861
9862 buf = wmi_buf_alloc(wmi_handle, len);
9863 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309864 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9865 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309866 }
9867 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9868 WMITLV_SET_HDR(&cmd->tlv_header,
9869 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9870 WMITLV_GET_STRUCT_TLVLEN
9871 (wmi_vdev_wmm_delts_cmd_fixed_param));
9872 cmd->vdev_id = vdev_id;
9873 cmd->ac = ac;
9874
Govind Singhb53420c2016-03-09 14:32:57 +05309875 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309876 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9877 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9878 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309879 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309880 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309881 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309882 }
9883
Govind Singhb53420c2016-03-09 14:32:57 +05309884 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309885}
9886
9887/**
9888 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9889 * @wmi_handle: handle to wmi
9890 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9891 *
Govind Singhb53420c2016-03-09 14:32:57 +05309892 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309893 * ADD_TS requestes to firmware in loop for all the ACs with
9894 * active flow.
9895 *
9896 * Return: CDF status
9897 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309898static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309899 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9900{
9901 int i = 0;
9902 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9903 wmi_buf_t buf;
9904 int32_t len = sizeof(*cmd);
9905
9906 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9907 /* if flow in this AC is active */
9908 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9909 /*
9910 * as per implementation of wma_add_ts_req() we
9911 * are not waiting any response from firmware so
9912 * apart from sending ADDTS to firmware just send
9913 * success to upper layers
9914 */
Govind Singhb53420c2016-03-09 14:32:57 +05309915 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309916
9917 buf = wmi_buf_alloc(wmi_handle, len);
9918 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309919 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9920 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309921 }
9922 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9923 wmi_buf_data(buf);
9924 WMITLV_SET_HDR(&cmd->tlv_header,
9925 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9926 WMITLV_GET_STRUCT_TLVLEN
9927 (wmi_vdev_wmm_addts_cmd_fixed_param));
9928 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9929 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309930 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309931 traffic.userPrio);
9932 cmd->medium_time_us =
9933 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9934 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309935 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309936 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9937 cmd->medium_time_us, cmd->downgrade_type);
9938 if (wmi_unified_cmd_send
9939 (wmi_handle, buf, len,
9940 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309941 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309942 __func__);
9943 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309944 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309945 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309946 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309947 }
9948 }
9949 }
9950
Govind Singhb53420c2016-03-09 14:32:57 +05309951 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309952}
9953
9954/**
9955 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9956 * @wmi_handle: wmi handle
9957 * @msg: ADDTS params
9958 *
9959 * Return: CDF status
9960 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309961static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309962 struct add_ts_param *msg)
9963{
9964 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9965 wmi_buf_t buf;
9966 int32_t len = sizeof(*cmd);
9967
Govind Singhb53420c2016-03-09 14:32:57 +05309968 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309969
9970 buf = wmi_buf_alloc(wmi_handle, len);
9971 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309972 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9973 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309974 }
9975 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9976 WMITLV_SET_HDR(&cmd->tlv_header,
9977 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9978 WMITLV_GET_STRUCT_TLVLEN
9979 (wmi_vdev_wmm_addts_cmd_fixed_param));
9980 cmd->vdev_id = msg->sme_session_id;
9981 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9982 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9983 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309984 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309985 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9986 cmd->downgrade_type, __func__, __LINE__);
9987 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9988 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309989 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9990 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309991 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309992 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309993 }
9994
Govind Singhb53420c2016-03-09 14:32:57 +05309995 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309996}
9997
9998/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309999 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
10000 * @wmi_handle: wmi handle
10001 * @pAddPeriodicTxPtrnParams: tx ptrn params
10002 *
10003 * Retrun: CDF status
10004 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010005static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010006 struct periodic_tx_pattern *
10007 pAddPeriodicTxPtrnParams,
10008 uint8_t vdev_id)
10009{
10010 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10011 wmi_buf_t wmi_buf;
10012 uint32_t len;
10013 uint8_t *buf_ptr;
10014 uint32_t ptrn_len, ptrn_len_aligned;
10015 int j;
10016
10017 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
10018 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
10019 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
10020 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
10021
10022 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10023 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010024 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10025 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010026 }
10027
10028 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10029
10030 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
10031 WMITLV_SET_HDR(&cmd->tlv_header,
10032 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10033 WMITLV_GET_STRUCT_TLVLEN
10034 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10035
10036 /* Pass the pattern id to delete for the corresponding vdev id */
10037 cmd->vdev_id = vdev_id;
10038 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
10039 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
10040 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
10041
10042 /* Pattern info */
10043 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10044 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
10045 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010046 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010047 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +053010048 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +053010049
Govind Singhb53420c2016-03-09 14:32:57 +053010050 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010051 __func__, cmd->pattern_id, cmd->vdev_id);
10052
10053 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10054 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010055 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010056 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010057 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010058 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010059 }
Govind Singhb53420c2016-03-09 14:32:57 +053010060 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010061}
10062
10063/**
10064 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
10065 * @wmi_handle: wmi handle
10066 * @vdev_id: vdev id
10067 * @pattern_id: pattern id
10068 *
10069 * Retrun: CDF status
10070 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010071static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010072 uint8_t vdev_id,
10073 uint8_t pattern_id)
10074{
10075 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10076 wmi_buf_t wmi_buf;
10077 uint32_t len =
10078 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10079
10080 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10081 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010082 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10083 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010084 }
10085
10086 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
10087 wmi_buf_data(wmi_buf);
10088 WMITLV_SET_HDR(&cmd->tlv_header,
10089 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10090 WMITLV_GET_STRUCT_TLVLEN
10091 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10092
10093 /* Pass the pattern id to delete for the corresponding vdev id */
10094 cmd->vdev_id = vdev_id;
10095 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +053010096 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010097 __func__, cmd->pattern_id, cmd->vdev_id);
10098
10099 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10100 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010101 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010102 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010103 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010104 }
Govind Singhb53420c2016-03-09 14:32:57 +053010105 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010106}
10107
10108/**
10109 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
10110 * @wmi_handle: wmi handle
10111 * @preq: stats ext params
10112 *
10113 * Return: CDF status
10114 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010115static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010116 struct stats_ext_params *preq)
10117{
Govind Singh67922e82016-04-01 16:48:57 +053010118 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010119 wmi_req_stats_ext_cmd_fixed_param *cmd;
10120 wmi_buf_t buf;
10121 uint16_t len;
10122 uint8_t *buf_ptr;
10123
10124 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
10125
10126 buf = wmi_buf_alloc(wmi_handle, len);
10127 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010128 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010129 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010130 }
10131
10132 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10133 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
10134
10135 WMITLV_SET_HDR(&cmd->tlv_header,
10136 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
10137 WMITLV_GET_STRUCT_TLVLEN
10138 (wmi_req_stats_ext_cmd_fixed_param));
10139 cmd->vdev_id = preq->vdev_id;
10140 cmd->data_len = preq->request_data_len;
10141
Govind Singhb53420c2016-03-09 14:32:57 +053010142 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +053010143 __func__, preq->request_data_len, preq->vdev_id);
10144
10145 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
10146 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
10147
10148 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010149 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010150
10151 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10152 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010153 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010154 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +053010155 ret);
10156 wmi_buf_free(buf);
10157 }
10158
10159 return ret;
10160}
10161
10162/**
10163 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
10164 * @wmi_handle: wmi handle
10165 * @params: ext wow params
10166 *
10167 * Return:0 for success or error code
10168 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010169static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010170 struct ext_wow_params *params)
10171{
10172 wmi_extwow_enable_cmd_fixed_param *cmd;
10173 wmi_buf_t buf;
10174 int32_t len;
10175 int ret;
10176
10177 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
10178 buf = wmi_buf_alloc(wmi_handle, len);
10179 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010180 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10181 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010182 }
10183
10184 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
10185
10186 WMITLV_SET_HDR(&cmd->tlv_header,
10187 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
10188 WMITLV_GET_STRUCT_TLVLEN
10189 (wmi_extwow_enable_cmd_fixed_param));
10190
10191 cmd->vdev_id = params->vdev_id;
10192 cmd->type = params->type;
10193 cmd->wakeup_pin_num = params->wakeup_pin_num;
10194
Govind Singhb53420c2016-03-09 14:32:57 +053010195 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +053010196 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
10197
10198 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10199 WMI_EXTWOW_ENABLE_CMDID);
10200 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010201 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010202 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010203 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010204 }
10205
Govind Singhb53420c2016-03-09 14:32:57 +053010206 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010207
10208}
10209
10210/**
10211 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
10212 * @wmi_handle: wmi handle
10213 * @app_type1_params: app type1 params
10214 *
10215 * Return: CDF status
10216 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010217static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010218 struct app_type1_params *app_type1_params)
10219{
10220 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
10221 wmi_buf_t buf;
10222 int32_t len;
10223 int ret;
10224
10225 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
10226 buf = wmi_buf_alloc(wmi_handle, len);
10227 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010228 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10229 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010230 }
10231
10232 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
10233 wmi_buf_data(buf);
10234
10235 WMITLV_SET_HDR(&cmd->tlv_header,
10236 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
10237 WMITLV_GET_STRUCT_TLVLEN
10238 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
10239
10240 cmd->vdev_id = app_type1_params->vdev_id;
10241 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
10242 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +053010243 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +053010244 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +053010245 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010246 cmd->passwd_len = app_type1_params->pass_length;
10247
Govind Singhb53420c2016-03-09 14:32:57 +053010248 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010249 "identification_id %.8s id_length %u "
10250 "password %.16s pass_length %u",
10251 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
10252 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
10253
10254 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10255 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
10256 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010257 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010258 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010259 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010260 }
10261
Govind Singhb53420c2016-03-09 14:32:57 +053010262 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010263}
10264
10265/**
10266 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
10267 * @wmi_handle: wmi handle
10268 * @appType2Params: app type2 params
10269 *
10270 * Return: CDF status
10271 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010272static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010273 struct app_type2_params *appType2Params)
10274{
10275 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
10276 wmi_buf_t buf;
10277 int32_t len;
10278 int ret;
10279
10280 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
10281 buf = wmi_buf_alloc(wmi_handle, len);
10282 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010283 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10284 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010285 }
10286
10287 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
10288 wmi_buf_data(buf);
10289
10290 WMITLV_SET_HDR(&cmd->tlv_header,
10291 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
10292 WMITLV_GET_STRUCT_TLVLEN
10293 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
10294
10295 cmd->vdev_id = appType2Params->vdev_id;
10296
Govind Singhb53420c2016-03-09 14:32:57 +053010297 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010298 cmd->rc4_key_len = appType2Params->rc4_key_len;
10299
10300 cmd->ip_id = appType2Params->ip_id;
10301 cmd->ip_device_ip = appType2Params->ip_device_ip;
10302 cmd->ip_server_ip = appType2Params->ip_server_ip;
10303
10304 cmd->tcp_src_port = appType2Params->tcp_src_port;
10305 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
10306 cmd->tcp_seq = appType2Params->tcp_seq;
10307 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
10308
10309 cmd->keepalive_init = appType2Params->keepalive_init;
10310 cmd->keepalive_min = appType2Params->keepalive_min;
10311 cmd->keepalive_max = appType2Params->keepalive_max;
10312 cmd->keepalive_inc = appType2Params->keepalive_inc;
10313
10314 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
10315 &cmd->gateway_mac);
10316 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
10317 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
10318
Govind Singhb53420c2016-03-09 14:32:57 +053010319 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010320 "rc4_key %.16s rc4_key_len %u "
10321 "ip_id %x ip_device_ip %x ip_server_ip %x "
10322 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
10323 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
10324 "keepalive_max %u keepalive_inc %u "
10325 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
10326 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
10327 cmd->rc4_key, cmd->rc4_key_len,
10328 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
10329 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
10330 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
10331 cmd->keepalive_max, cmd->keepalive_inc,
10332 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
10333
10334 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10335 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
10336 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010337 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010338 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010339 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010340 }
10341
Govind Singhb53420c2016-03-09 14:32:57 +053010342 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010343
10344}
10345
10346/**
10347 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
10348 * @wmi_handle: wmi handle
10349 * @timer_val: auto shutdown timer value
10350 *
10351 * Return: CDF status
10352 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010353static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010354 uint32_t timer_val)
10355{
Govind Singh67922e82016-04-01 16:48:57 +053010356 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010357 wmi_buf_t buf = NULL;
10358 uint8_t *buf_ptr;
10359 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
10360 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
10361
Govind Singhb53420c2016-03-09 14:32:57 +053010362 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010363 __func__, timer_val);
10364
10365 buf = wmi_buf_alloc(wmi_handle, len);
10366 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010367 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10368 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010369 }
10370
10371 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10372 wmi_auto_sh_cmd =
10373 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
10374 wmi_auto_sh_cmd->timer_value = timer_val;
10375
10376 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
10377 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
10378 WMITLV_GET_STRUCT_TLVLEN
10379 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
10380
10381 status = wmi_unified_cmd_send(wmi_handle, buf,
10382 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010383 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010384 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010385 __func__, status);
10386 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010387 }
10388
Govind Singh67922e82016-04-01 16:48:57 +053010389 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010390}
10391
10392/**
10393 * send_nan_req_cmd_tlv() - to send nan request to target
10394 * @wmi_handle: wmi handle
10395 * @nan_req: request data which will be non-null
10396 *
10397 * Return: CDF status
10398 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010399static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010400 struct nan_req_params *nan_req)
10401{
Govind Singh67922e82016-04-01 16:48:57 +053010402 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010403 wmi_nan_cmd_param *cmd;
10404 wmi_buf_t buf;
10405 uint16_t len = sizeof(*cmd);
10406 uint16_t nan_data_len, nan_data_len_aligned;
10407 uint8_t *buf_ptr;
10408
10409 /*
10410 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
10411 * +------------+----------+-----------------------+--------------+
10412 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
10413 * +------------+----------+-----------------------+--------------+
10414 */
10415 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +053010416 WMI_LOGE("%s:nan req is not valid", __func__);
10417 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010418 }
10419 nan_data_len = nan_req->request_data_len;
10420 nan_data_len_aligned = roundup(nan_req->request_data_len,
10421 sizeof(uint32_t));
Naveen Rawatd30dad62018-05-08 09:40:10 -070010422 if (nan_data_len_aligned < nan_req->request_data_len) {
10423 WMI_LOGE("%s: integer overflow while rounding up data_len",
10424 __func__);
10425 return QDF_STATUS_E_FAILURE;
10426 }
10427
10428 if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
10429 WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen",
10430 __func__);
10431 return QDF_STATUS_E_FAILURE;
10432 }
10433
Govind Singh20c5dac2016-03-07 15:33:31 +053010434 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
10435 buf = wmi_buf_alloc(wmi_handle, len);
10436 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010437 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
10438 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010439 }
10440 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10441 cmd = (wmi_nan_cmd_param *) buf_ptr;
10442 WMITLV_SET_HDR(&cmd->tlv_header,
10443 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
10444 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
10445 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +053010446 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +053010447 __func__, nan_req->request_data_len);
10448 buf_ptr += sizeof(wmi_nan_cmd_param);
10449 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
10450 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010451 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010452
10453 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10454 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010455 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010456 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010457 __func__, ret);
10458 wmi_buf_free(buf);
10459 }
10460
10461 return ret;
10462}
10463
10464/**
10465 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
10466 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -070010467 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +053010468 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010469 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010470 */
Jeff Johnsona87370f2017-10-04 19:19:20 -070010471static QDF_STATUS
10472send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
10473 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +053010474{
10475 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
10476 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +053010477 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010478
10479 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10480 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010481 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +053010482 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010483 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010484 }
10485
10486 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010487
10488 WMITLV_SET_HDR(&cmd->tlv_header,
10489 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
10490 WMITLV_GET_STRUCT_TLVLEN
10491 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -070010492 cmd->vdev_id = params->vdev_id;
10493 cmd->enable = params->dhcp_offload_enabled;
10494 cmd->num_client = params->dhcp_client_num;
10495 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +053010496 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +053010497 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +053010498 sizeof(*cmd),
10499 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010500 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010501 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +053010502 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010503 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010504 }
Govind Singhb53420c2016-03-09 14:32:57 +053010505 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -070010506 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +053010507
10508 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010509}
10510
10511/**
10512 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
10513 * @wmi_handle: wmi handle
10514 * @flashing: flashing request
10515 *
10516 * Return: CDF status
10517 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010518static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010519 struct flashing_req_params *flashing)
10520{
10521 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +053010522 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010523 wmi_buf_t buf;
10524 uint8_t *buf_ptr;
10525 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
10526
10527 buf = wmi_buf_alloc(wmi_handle, len);
10528 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010529 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +053010530 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010531 }
10532 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10533 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
10534 WMITLV_SET_HDR(&cmd->tlv_header,
10535 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
10536 WMITLV_GET_STRUCT_TLVLEN
10537 (wmi_set_led_flashing_cmd_fixed_param));
10538 cmd->pattern_id = flashing->pattern_id;
10539 cmd->led_x0 = flashing->led_x0;
10540 cmd->led_x1 = flashing->led_x1;
10541
10542 status = wmi_unified_cmd_send(wmi_handle, buf, len,
10543 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010544 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010545 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +053010546 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010547 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010548 }
Govind Singh67922e82016-04-01 16:48:57 +053010549
10550 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010551}
10552
10553/**
10554 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
10555 * @wmi_handle: wmi handle
10556 * @ch_avoid_update_req: channel avoid update params
10557 *
10558 * Return: CDF status
10559 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010560static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +053010561{
Govind Singh67922e82016-04-01 16:48:57 +053010562 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010563 wmi_buf_t buf = NULL;
10564 uint8_t *buf_ptr;
10565 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
10566 int len = sizeof(wmi_chan_avoid_update_cmd_param);
10567
10568
10569 buf = wmi_buf_alloc(wmi_handle, len);
10570 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010571 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10572 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010573 }
10574
10575 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10576 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
10577 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
10578 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
10579 WMITLV_GET_STRUCT_TLVLEN
10580 (wmi_chan_avoid_update_cmd_param));
10581
10582 status = wmi_unified_cmd_send(wmi_handle, buf,
10583 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010584 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010585 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +053010586 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
10587 " returned Error %d", status);
10588 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010589 }
10590
Govind Singh67922e82016-04-01 16:48:57 +053010591 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010592}
10593
10594/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010595 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
10596 * @wmi_handle: wmi handle
10597 * @param: pointer to pdev regdomain params
10598 *
10599 * Return: 0 for success or error code
10600 */
10601static QDF_STATUS
10602send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
10603 struct pdev_set_regdomain_params *param)
10604{
10605 wmi_buf_t buf;
10606 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10607 int32_t len = sizeof(*cmd);
10608
10609
10610 buf = wmi_buf_alloc(wmi_handle, len);
10611 if (!buf) {
10612 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10613 return QDF_STATUS_E_NOMEM;
10614 }
10615 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10616 WMITLV_SET_HDR(&cmd->tlv_header,
10617 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10618 WMITLV_GET_STRUCT_TLVLEN
10619 (wmi_pdev_set_regdomain_cmd_fixed_param));
10620
10621 cmd->reg_domain = param->currentRDinuse;
10622 cmd->reg_domain_2G = param->currentRD2G;
10623 cmd->reg_domain_5G = param->currentRD5G;
10624 cmd->conformance_test_limit_2G = param->ctl_2G;
10625 cmd->conformance_test_limit_5G = param->ctl_5G;
10626 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010627 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10628 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010629
10630 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10631 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
10632 WMI_LOGE("%s: Failed to send pdev set regdomain command",
10633 __func__);
10634 wmi_buf_free(buf);
10635 return QDF_STATUS_E_FAILURE;
10636 }
10637
10638 return QDF_STATUS_SUCCESS;
10639}
10640
10641/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010642 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
10643 * @wmi_handle: wmi handle
10644 * @reg_dmn: reg domain
10645 * @regdmn2G: 2G reg domain
10646 * @regdmn5G: 5G reg domain
10647 * @ctl2G: 2G test limit
10648 * @ctl5G: 5G test limit
10649 *
10650 * Return: none
10651 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010652static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010653 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +053010654 uint16_t regdmn5G, uint8_t ctl2G,
10655 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +053010656{
10657 wmi_buf_t buf;
10658 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10659 int32_t len = sizeof(*cmd);
10660
10661
10662 buf = wmi_buf_alloc(wmi_handle, len);
10663 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010664 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10665 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010666 }
10667 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10668 WMITLV_SET_HDR(&cmd->tlv_header,
10669 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10670 WMITLV_GET_STRUCT_TLVLEN
10671 (wmi_pdev_set_regdomain_cmd_fixed_param));
10672 cmd->reg_domain = reg_dmn;
10673 cmd->reg_domain_2G = regdmn2G;
10674 cmd->reg_domain_5G = regdmn5G;
10675 cmd->conformance_test_limit_2G = ctl2G;
10676 cmd->conformance_test_limit_5G = ctl5G;
10677
10678 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10679 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010680 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010681 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010682 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010683 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010684 }
10685
Govind Singhb53420c2016-03-09 14:32:57 +053010686 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010687}
10688
10689
10690/**
10691 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10692 * @wmi_handle: wmi handle
10693 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10694 *
10695 * This function sets tdls off channel mode
10696 *
10697 * Return: 0 on success; Negative errno otherwise
10698 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010699static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010700 struct tdls_channel_switch_params *chan_switch_params)
10701{
10702 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10703 wmi_buf_t wmi_buf;
10704 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10705
10706 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10707 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010708 WMI_LOGE(FL("wmi_buf_alloc failed"));
10709 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010710 }
10711 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10712 wmi_buf_data(wmi_buf);
10713 WMITLV_SET_HDR(&cmd->tlv_header,
10714 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10715 WMITLV_GET_STRUCT_TLVLEN(
10716 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10717
10718 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10719 &cmd->peer_macaddr);
10720 cmd->vdev_id = chan_switch_params->vdev_id;
10721 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10722 cmd->is_peer_responder = chan_switch_params->is_responder;
10723 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10724 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10725 cmd->offchan_oper_class = chan_switch_params->oper_class;
10726
Govind Singhb53420c2016-03-09 14:32:57 +053010727 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010728 cmd->peer_macaddr.mac_addr31to0,
10729 cmd->peer_macaddr.mac_addr47to32);
10730
Govind Singhb53420c2016-03-09 14:32:57 +053010731 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010732 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10733 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10734 ),
10735 cmd->vdev_id,
10736 cmd->offchan_mode,
10737 cmd->offchan_num,
10738 cmd->offchan_bw_bitmap,
10739 cmd->is_peer_responder,
10740 cmd->offchan_oper_class);
10741
10742 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10743 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010744 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010745 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010746 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010747 }
10748
10749
Govind Singhb53420c2016-03-09 14:32:57 +053010750 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010751}
10752
10753/**
10754 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10755 * @wmi_handle: wmi handle
10756 * @pwmaTdlsparams: TDLS params
10757 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -070010758 * Return: 0 for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010759 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010760static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010761 void *tdls_param, uint8_t tdls_state)
10762{
10763 wmi_tdls_set_state_cmd_fixed_param *cmd;
10764 wmi_buf_t wmi_buf;
10765
10766 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10767 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10768
10769 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10770 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010771 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10772 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010773 }
10774 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10775 WMITLV_SET_HDR(&cmd->tlv_header,
10776 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10777 WMITLV_GET_STRUCT_TLVLEN
10778 (wmi_tdls_set_state_cmd_fixed_param));
10779 cmd->vdev_id = wmi_tdls->vdev_id;
10780 cmd->state = tdls_state;
10781 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10782 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10783 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10784 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10785 cmd->rssi_delta = wmi_tdls->rssi_delta;
10786 cmd->tdls_options = wmi_tdls->tdls_options;
10787 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10788 cmd->tdls_peer_traffic_response_timeout_ms =
10789 wmi_tdls->peer_traffic_response_timeout;
10790 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10791 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10792 cmd->tdls_puapsd_rx_frame_threshold =
10793 wmi_tdls->puapsd_rx_frame_threshold;
10794 cmd->teardown_notification_ms =
10795 wmi_tdls->teardown_notification_ms;
10796 cmd->tdls_peer_kickout_threshold =
10797 wmi_tdls->tdls_peer_kickout_threshold;
10798
Govind Singhb53420c2016-03-09 14:32:57 +053010799 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010800 "notification_interval_ms: %d, "
10801 "tx_discovery_threshold: %d, "
10802 "tx_teardown_threshold: %d, "
10803 "rssi_teardown_threshold: %d, "
10804 "rssi_delta: %d, "
10805 "tdls_options: 0x%x, "
10806 "tdls_peer_traffic_ind_window: %d, "
10807 "tdls_peer_traffic_response_timeout: %d, "
10808 "tdls_puapsd_mask: 0x%x, "
10809 "tdls_puapsd_inactivity_time: %d, "
10810 "tdls_puapsd_rx_frame_threshold: %d, "
10811 "teardown_notification_ms: %d, "
10812 "tdls_peer_kickout_threshold: %d",
10813 __func__, tdls_state, cmd->state,
10814 cmd->notification_interval_ms,
10815 cmd->tx_discovery_threshold,
10816 cmd->tx_teardown_threshold,
10817 cmd->rssi_teardown_threshold,
10818 cmd->rssi_delta,
10819 cmd->tdls_options,
10820 cmd->tdls_peer_traffic_ind_window,
10821 cmd->tdls_peer_traffic_response_timeout_ms,
10822 cmd->tdls_puapsd_mask,
10823 cmd->tdls_puapsd_inactivity_time_ms,
10824 cmd->tdls_puapsd_rx_frame_threshold,
10825 cmd->teardown_notification_ms,
10826 cmd->tdls_peer_kickout_threshold);
10827
10828 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10829 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010830 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010831 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010832 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010833 }
Govind Singhb53420c2016-03-09 14:32:57 +053010834 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010835
Govind Singhb53420c2016-03-09 14:32:57 +053010836 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010837}
10838
10839/**
10840 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10841 * @wmi_handle: wmi handle
10842 * @peerStateParams: TDLS peer state params
10843 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010844 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010845 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010846static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010847 struct tdls_peer_state_params *peerStateParams,
10848 uint32_t *ch_mhz)
10849{
10850 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10851 wmi_tdls_peer_capabilities *peer_cap;
10852 wmi_channel *chan_info;
10853 wmi_buf_t wmi_buf;
10854 uint8_t *buf_ptr;
10855 uint32_t i;
10856 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10857 sizeof(wmi_tdls_peer_capabilities);
10858
10859
10860 len += WMI_TLV_HDR_SIZE +
10861 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10862
10863 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10864 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010865 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10866 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010867 }
10868
10869 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10870 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10871 WMITLV_SET_HDR(&cmd->tlv_header,
10872 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10873 WMITLV_GET_STRUCT_TLVLEN
10874 (wmi_tdls_peer_update_cmd_fixed_param));
10875
10876 cmd->vdev_id = peerStateParams->vdevId;
10877 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10878 &cmd->peer_macaddr);
10879
10880
10881 cmd->peer_state = peerStateParams->peerState;
10882
Govind Singhb53420c2016-03-09 14:32:57 +053010883 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010884 "peer_macaddr.mac_addr31to0: 0x%x, "
10885 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10886 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10887 cmd->peer_macaddr.mac_addr31to0,
10888 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10889
10890 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10891 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10892 WMITLV_SET_HDR(&peer_cap->tlv_header,
10893 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10894 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10895
10896 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10897 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10898 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10899 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10900 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10901 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10902 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10903 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10904
10905 /* Ack and More Data Ack are sent as 0, so no need to set
10906 * but fill SP
10907 */
10908 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10909 peerStateParams->peerCap.peerMaxSp);
10910
10911 peer_cap->buff_sta_support =
10912 peerStateParams->peerCap.peerBuffStaSupport;
10913 peer_cap->off_chan_support =
10914 peerStateParams->peerCap.peerOffChanSupport;
10915 peer_cap->peer_curr_operclass =
10916 peerStateParams->peerCap.peerCurrOperClass;
10917 /* self curr operclass is not being used and so pass op class for
10918 * preferred off chan in it.
10919 */
10920 peer_cap->self_curr_operclass =
10921 peerStateParams->peerCap.opClassForPrefOffChan;
10922 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10923 peer_cap->peer_operclass_len =
10924 peerStateParams->peerCap.peerOperClassLen;
10925
Govind Singhb53420c2016-03-09 14:32:57 +053010926 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010927 __func__, peer_cap->peer_operclass_len);
10928 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10929 peer_cap->peer_operclass[i] =
10930 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010931 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010932 __func__, i, peer_cap->peer_operclass[i]);
10933 }
10934
10935 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10936 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10937 peer_cap->pref_offchan_bw =
10938 peerStateParams->peerCap.prefOffChanBandwidth;
10939
Govind Singhb53420c2016-03-09 14:32:57 +053010940 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010941 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10942 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10943 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10944 " %d, pref_offchan_bw: %d",
10945 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10946 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10947 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10948 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10949 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10950
10951 /* next fill variable size array of peer chan info */
10952 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10953 WMITLV_SET_HDR(buf_ptr,
10954 WMITLV_TAG_ARRAY_STRUC,
10955 sizeof(wmi_channel) *
10956 peerStateParams->peerCap.peerChanLen);
10957 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10958
10959 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10960 WMITLV_SET_HDR(&chan_info->tlv_header,
10961 WMITLV_TAG_STRUC_wmi_channel,
10962 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10963 chan_info->mhz = ch_mhz[i];
10964 chan_info->band_center_freq1 = chan_info->mhz;
10965 chan_info->band_center_freq2 = 0;
10966
Govind Singhb53420c2016-03-09 14:32:57 +053010967 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010968
10969 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10970 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010971 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010972 peerStateParams->peerCap.peerChan[i].chanId,
10973 peerStateParams->peerCap.peerChan[i].dfsSet);
10974 }
10975
10976 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10977 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10978 else
10979 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10980
10981 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10982 peerStateParams->peerCap.
10983 peerChan[i].pwr);
10984
10985 WMI_SET_CHANNEL_REG_POWER(chan_info,
10986 peerStateParams->peerCap.peerChan[i].
10987 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010988 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010989 peerStateParams->peerCap.peerChan[i].pwr);
10990
10991 chan_info++;
10992 }
10993
10994 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10995 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010996 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010997 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010998 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010999 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053011000 }
11001
11002
Govind Singhb53420c2016-03-09 14:32:57 +053011003 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053011004}
11005
11006/*
Govind Singh20c5dac2016-03-07 15:33:31 +053011007 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
11008 * @wmi_handle: Pointer to WMi handle
11009 * @ie_data: Pointer for ie data
11010 *
11011 * This function sends IE information to firmware
11012 *
Govind Singhb53420c2016-03-09 14:32:57 +053011013 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053011014 *
11015 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011016static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053011017 struct vdev_ie_info_param *ie_info)
11018{
11019 wmi_vdev_set_ie_cmd_fixed_param *cmd;
11020 wmi_buf_t buf;
11021 uint8_t *buf_ptr;
11022 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053011023 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053011024
11025
11026 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
11027 /* Allocate memory for the WMI command */
11028 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
11029
11030 buf = wmi_buf_alloc(wmi_handle, len);
11031 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011032 WMI_LOGE(FL("wmi_buf_alloc failed"));
11033 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053011034 }
11035
11036 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011037 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011038
11039 /* Populate the WMI command */
11040 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
11041
11042 WMITLV_SET_HDR(&cmd->tlv_header,
11043 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
11044 WMITLV_GET_STRUCT_TLVLEN(
11045 wmi_vdev_set_ie_cmd_fixed_param));
11046 cmd->vdev_id = ie_info->vdev_id;
11047 cmd->ie_id = ie_info->ie_id;
11048 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070011049 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053011050
Govind Singhb53420c2016-03-09 14:32:57 +053011051 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053011052 ie_info->length, ie_info->vdev_id);
11053
11054 buf_ptr += sizeof(*cmd);
11055 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
11056 buf_ptr += WMI_TLV_HDR_SIZE;
11057
Govind Singhb53420c2016-03-09 14:32:57 +053011058 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011059
11060 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11061 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011062 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011063 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053011064 wmi_buf_free(buf);
11065 }
11066
11067 return ret;
11068}
11069
Sathish Kumar497bef42017-03-01 14:02:36 +053011070/**
11071 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
11072 *
11073 * @param wmi_handle : handle to WMI.
11074 * @param param : pointer to antenna param
11075 *
11076 * This function sends smart antenna enable command to FW
11077 *
11078 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11079 */
11080static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
11081 struct smart_ant_enable_params *param)
11082{
11083 /* Send WMI COMMAND to Enable */
11084 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
11085 wmi_pdev_smart_ant_gpio_handle *gpio_param;
11086 wmi_buf_t buf;
11087 uint8_t *buf_ptr;
11088 int len = 0;
11089 QDF_STATUS ret;
11090 int loop = 0;
11091
11092 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11093 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
11094 buf = wmi_buf_alloc(wmi_handle, len);
11095
11096 if (!buf) {
11097 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11098 return QDF_STATUS_E_NOMEM;
11099 }
11100
11101 buf_ptr = wmi_buf_data(buf);
11102 qdf_mem_zero(buf_ptr, len);
11103 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
11104
11105 WMITLV_SET_HDR(&cmd->tlv_header,
11106 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
11107 WMITLV_GET_STRUCT_TLVLEN(
11108 wmi_pdev_smart_ant_enable_cmd_fixed_param));
11109
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011110 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11111 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011112 cmd->enable = param->enable;
11113 cmd->mode = param->mode;
11114 cmd->rx_antenna = param->rx_antenna;
11115 cmd->tx_default_antenna = param->rx_antenna;
11116
11117 /* TLV indicating array of structures to follow */
11118 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
11119 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11120 WMI_HAL_MAX_SANTENNA *
11121 sizeof(wmi_pdev_smart_ant_gpio_handle));
11122
11123 buf_ptr += WMI_TLV_HDR_SIZE;
11124 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
11125
11126 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
11127 WMITLV_SET_HDR(&gpio_param->tlv_header,
11128 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
11129 WMITLV_GET_STRUCT_TLVLEN(
11130 wmi_pdev_smart_ant_gpio_handle));
11131 if (param->mode == SMART_ANT_MODE_SERIAL) {
11132 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
11133 gpio_param->gpio_pin = param->gpio_pin[loop];
11134 gpio_param->gpio_func = param->gpio_func[loop];
11135 } else {
11136 gpio_param->gpio_pin = 0;
11137 gpio_param->gpio_func = 0;
11138 }
11139 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
11140 gpio_param->gpio_pin = param->gpio_pin[loop];
11141 gpio_param->gpio_func = param->gpio_func[loop];
11142 }
11143 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011144 gpio_param->pdev_id =
11145 wmi_handle->ops->convert_pdev_id_host_to_target(
11146 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011147 gpio_param++;
11148 }
11149
11150 ret = wmi_unified_cmd_send(wmi_handle,
11151 buf,
11152 len,
11153 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
11154
11155 if (ret != 0) {
11156 WMI_LOGE(" %s :WMI Failed\n", __func__);
11157 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
11158 cmd->enable,
11159 cmd->mode,
11160 cmd->rx_antenna,
11161 param->gpio_pin[0], param->gpio_pin[1],
11162 param->gpio_pin[2], param->gpio_pin[3],
11163 param->gpio_func[0], param->gpio_func[1],
11164 param->gpio_func[2], param->gpio_func[3],
11165 ret);
11166 wmi_buf_free(buf);
11167 }
11168
11169 return ret;
11170}
11171
11172/**
11173 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
11174 *
11175 * @param wmi_handle : handle to WMI.
11176 * @param param : pointer to rx antenna param
11177 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11178 */
11179static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11180 struct smart_ant_rx_ant_params *param)
11181{
11182 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
11183 wmi_buf_t buf;
11184 uint8_t *buf_ptr;
11185 uint32_t len;
11186 QDF_STATUS ret;
11187
11188 len = sizeof(*cmd);
11189 buf = wmi_buf_alloc(wmi_handle, len);
11190 WMI_LOGD("%s:\n", __func__);
11191 if (!buf) {
11192 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11193 return QDF_STATUS_E_NOMEM;
11194 }
11195
11196 buf_ptr = wmi_buf_data(buf);
11197 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
11198 WMITLV_SET_HDR(&cmd->tlv_header,
11199 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
11200 WMITLV_GET_STRUCT_TLVLEN(
11201 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
11202 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011203 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11204 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011205
11206 ret = wmi_unified_cmd_send(wmi_handle,
11207 buf,
11208 len,
11209 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
11210
11211 if (ret != 0) {
11212 WMI_LOGE(" %s :WMI Failed\n", __func__);
11213 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
11214 __func__,
11215 cmd->rx_antenna,
11216 ret);
11217 wmi_buf_free(buf);
11218 }
11219
11220 return ret;
11221}
11222
11223/**
11224 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
11225 * @wmi_handle: wmi handle
11226 * @param: pointer to hold ctl table param
11227 *
11228 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11229 */
11230static QDF_STATUS
11231send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
11232 struct ctl_table_params *param)
11233{
11234 uint16_t len, ctl_tlv_len;
11235 uint8_t *buf_ptr;
11236 wmi_buf_t buf;
11237 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
11238 uint32_t *ctl_array;
11239
11240 if (!param->ctl_array)
11241 return QDF_STATUS_E_FAILURE;
11242
Sathish Kumar497bef42017-03-01 14:02:36 +053011243 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053011244 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053011245 len = sizeof(*cmd) + ctl_tlv_len;
11246
11247 buf = wmi_buf_alloc(wmi_handle, len);
11248 if (!buf) {
11249 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11250 return QDF_STATUS_E_FAILURE;
11251 }
11252
11253 buf_ptr = wmi_buf_data(buf);
11254 qdf_mem_zero(buf_ptr, len);
11255
11256 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
11257
11258 WMITLV_SET_HDR(&cmd->tlv_header,
11259 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
11260 WMITLV_GET_STRUCT_TLVLEN(
11261 wmi_pdev_set_ctl_table_cmd_fixed_param));
11262 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011263 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11264 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011265
11266 buf_ptr += sizeof(*cmd);
11267 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11268 (cmd->ctl_len));
11269 buf_ptr += WMI_TLV_HDR_SIZE;
11270 ctl_array = (uint32_t *)buf_ptr;
11271
11272 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
11273 sizeof(param->ctl_band));
11274 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
11275 param->ctl_cmd_len -
11276 sizeof(param->ctl_band));
11277
11278 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11279 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
11280 WMI_LOGE("%s:Failed to send command\n", __func__);
11281 wmi_buf_free(buf);
11282 return QDF_STATUS_E_FAILURE;
11283 }
11284
11285 return QDF_STATUS_SUCCESS;
11286}
11287
11288/**
11289 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
11290 * @wmi_handle: wmi handle
11291 * @param: pointer to hold mimogain table param
11292 *
11293 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11294 */
11295static QDF_STATUS
11296send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
11297 struct mimogain_table_params *param)
11298{
11299 uint16_t len, table_tlv_len;
11300 wmi_buf_t buf;
11301 uint8_t *buf_ptr;
11302 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
11303 uint32_t *gain_table;
11304
11305 if (!param->array_gain)
11306 return QDF_STATUS_E_FAILURE;
11307
11308 /* len must be multiple of a single array gain table */
11309 if (param->tbl_len %
11310 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
11311 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
11312 WMI_LOGE("Array gain table len not correct\n");
11313 return QDF_STATUS_E_FAILURE;
11314 }
11315
11316 table_tlv_len = WMI_TLV_HDR_SIZE +
11317 roundup(param->tbl_len, sizeof(uint32_t));
11318 len = sizeof(*cmd) + table_tlv_len;
11319
11320 buf = wmi_buf_alloc(wmi_handle, len);
11321 if (!buf) {
11322 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11323 return QDF_STATUS_E_FAILURE;
11324 }
11325
11326 buf_ptr = wmi_buf_data(buf);
11327 qdf_mem_zero(buf_ptr, len);
11328
11329 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
11330
11331 WMITLV_SET_HDR(&cmd->tlv_header,
11332 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
11333 WMITLV_GET_STRUCT_TLVLEN(
11334 wmi_pdev_set_mimogain_table_cmd_fixed_param));
11335
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011336 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11337 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011338 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
11339 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
11340 param->multichain_gain_bypass);
11341
11342 buf_ptr += sizeof(*cmd);
11343 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11344 (param->tbl_len));
11345 buf_ptr += WMI_TLV_HDR_SIZE;
11346 gain_table = (uint32_t *)buf_ptr;
11347
11348 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
11349 param->array_gain,
11350 param->tbl_len);
11351
11352 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11353 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
11354 return QDF_STATUS_E_FAILURE;
11355 }
11356
11357 return QDF_STATUS_SUCCESS;
11358}
11359
11360/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011361 * enum packet_power_tlv_flags: target defined
11362 * packet power rate flags for TLV
11363 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
11364 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
11365 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
11366 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
11367 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
11368 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
11369 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
11370 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
11371 * @WMI_TLV_FLAG_STBC: STBC is set
11372 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
11373 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
11374 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
11375 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
11376 * @WMI_TLV_FLAG_RTSENA: RTS enabled
11377 * @WMI_TLV_FLAG_CTSENA: CTS enabled
11378 * @WMI_TLV_FLAG_LDPC: LDPC is set
11379 * @WMI_TLV_FLAG_SGI: Short gaurd interval
11380 * @WMI_TLV_FLAG_SU: SU Data
11381 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
11382 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
11383 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
11384 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
11385 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
11386 *
11387 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
11388 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
11389 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
11390 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
11391 */
11392enum packet_power_tlv_flags {
11393 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
11394 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
11395 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
11396 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
11397 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
11398 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
11399 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
11400 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
11401 WMI_TLV_FLAG_STBC = 0x00000100,
11402 WMI_TLV_FLAG_40MHZ = 0x00000200,
11403 WMI_TLV_FLAG_80MHZ = 0x00000300,
11404 WMI_TLV_FLAG_160MHZ = 0x00000400,
11405 WMI_TLV_FLAG_TXBF = 0x00000800,
11406 WMI_TLV_FLAG_RTSENA = 0x00001000,
11407 WMI_TLV_FLAG_CTSENA = 0x00002000,
11408 WMI_TLV_FLAG_LDPC = 0x00004000,
11409 WMI_TLV_FLAG_SGI = 0x00008000,
11410 WMI_TLV_FLAG_SU = 0x00100000,
11411 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
11412 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
11413 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
11414 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
11415 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
11416
11417 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
11418 WMI_TLV_FLAG_BW_MASK = 0x3,
11419 WMI_TLV_FLAG_BW_SHIFT = 9,
11420 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
11421 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
11422};
11423
11424/**
11425 * convert_to_power_info_rate_flags() - convert packet_power_info_params
11426 * to FW understandable format
11427 * @param: pointer to hold packet power info param
11428 *
11429 * @return FW understandable 32 bit rate flags
11430 */
11431static uint32_t
11432convert_to_power_info_rate_flags(struct packet_power_info_params *param)
11433{
11434 uint32_t rateflags = 0;
11435
11436 if (param->chainmask)
11437 rateflags |=
11438 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
11439 if (param->chan_width)
11440 rateflags |=
11441 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
11442 << WMI_TLV_FLAG_BW_SHIFT);
11443 if (param->su_mu_ofdma)
11444 rateflags |=
11445 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
11446 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
11447 if (param->rate_flags & WMI_HOST_FLAG_STBC)
11448 rateflags |= WMI_TLV_FLAG_STBC;
11449 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
11450 rateflags |= WMI_TLV_FLAG_LDPC;
11451 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
11452 rateflags |= WMI_TLV_FLAG_TXBF;
11453 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
11454 rateflags |= WMI_TLV_FLAG_RTSENA;
11455 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
11456 rateflags |= WMI_TLV_FLAG_CTSENA;
11457 if (param->rate_flags & WMI_HOST_FLAG_SGI)
11458 rateflags |= WMI_TLV_FLAG_SGI;
11459
11460 return rateflags;
11461}
11462
11463/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011464 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
11465 * info to fw
11466 * @wmi_handle: wmi handle
11467 * @param: pointer to hold packet power info param
11468 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011469 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053011470 */
11471static QDF_STATUS
11472send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
11473 struct packet_power_info_params *param)
11474{
11475 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
11476 wmi_buf_t wmibuf;
11477 uint8_t *buf_ptr;
11478 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
11479
11480 wmibuf = wmi_buf_alloc(wmi_handle, len);
11481 if (wmibuf == NULL)
11482 return QDF_STATUS_E_NOMEM;
11483
11484 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
11485
11486 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
11487 WMITLV_SET_HDR(&cmd->tlv_header,
11488 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
11489 WMITLV_GET_STRUCT_TLVLEN(
11490 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011491 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11492 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011493 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053011494 cmd->nss = param->nss;
11495 cmd->preamble = param->preamble;
11496 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011497
11498 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
11499 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
11500 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
11501 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
11502
Sathish Kumar497bef42017-03-01 14:02:36 +053011503 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
11504 WMI_PDEV_GET_TPC_CMDID)) {
11505 WMI_LOGE(FL("Failed to get tpc command\n"));
11506 wmi_buf_free(wmibuf);
11507 return QDF_STATUS_E_FAILURE;
11508 }
11509
11510 return QDF_STATUS_SUCCESS;
11511}
11512
11513/**
11514 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
11515 * @wmi_handle: wmi handle
11516 * @param: pointer to hold config ratemask params
11517 *
11518 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11519 */
11520static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
11521 struct config_ratemask_params *param)
11522{
11523 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
11524 wmi_buf_t buf;
11525 int32_t len = sizeof(*cmd);
11526
11527 buf = wmi_buf_alloc(wmi_handle, len);
11528 if (!buf) {
11529 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11530 return QDF_STATUS_E_FAILURE;
11531 }
11532 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
11533 WMITLV_SET_HDR(&cmd->tlv_header,
11534 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
11535 WMITLV_GET_STRUCT_TLVLEN(
11536 wmi_vdev_config_ratemask_cmd_fixed_param));
11537 cmd->vdev_id = param->vdev_id;
11538 cmd->type = param->type;
11539 cmd->mask_lower32 = param->lower32;
11540 cmd->mask_higher32 = param->higher32;
11541 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
11542 param->vdev_id, param->type, param->lower32, param->higher32);
11543
11544 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11545 WMI_VDEV_RATEMASK_CMDID)) {
11546 WMI_LOGE("Seting vdev ratemask failed\n");
11547 wmi_buf_free(buf);
11548 return QDF_STATUS_E_FAILURE;
11549 }
11550
11551 return QDF_STATUS_SUCCESS;
11552}
11553
11554/**
Sathish Kumar6011c742017-11-08 14:49:58 +053011555 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
11556 * @param: param sent from the host side
11557 * @cmd: param to be sent to the fw side
11558 */
11559static inline void copy_custom_aggr_bitmap(
11560 struct set_custom_aggr_size_params *param,
11561 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
11562{
11563 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
11564 param->ac);
11565 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
11566 param->aggr_type);
11567 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11568 param->tx_aggr_size_disable);
11569 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11570 param->rx_aggr_size_disable);
11571 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
11572 param->tx_ac_enable);
11573}
11574
11575/**
11576 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
11577 * @wmi_handle: wmi handle
11578 * @param: pointer to hold custom aggr size params
11579 *
11580 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11581 */
11582static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
11583 wmi_unified_t wmi_handle,
11584 struct set_custom_aggr_size_params *param)
11585{
11586 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
11587 wmi_buf_t buf;
11588 int32_t len = sizeof(*cmd);
11589
11590 buf = wmi_buf_alloc(wmi_handle, len);
11591 if (!buf) {
11592 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11593 return QDF_STATUS_E_FAILURE;
11594 }
11595 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
11596 wmi_buf_data(buf);
11597 WMITLV_SET_HDR(&cmd->tlv_header,
11598 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
11599 WMITLV_GET_STRUCT_TLVLEN(
11600 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
11601 cmd->vdev_id = param->vdev_id;
11602 cmd->tx_aggr_size = param->tx_aggr_size;
11603 cmd->rx_aggr_size = param->rx_aggr_size;
11604 copy_custom_aggr_bitmap(param, cmd);
11605
11606 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
11607 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
11608 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
11609 "tx_ac_enable=0x%X\n",
11610 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
11611 param->ac, param->aggr_type, param->tx_aggr_size_disable,
11612 param->rx_aggr_size_disable, param->tx_ac_enable);
11613
11614 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11615 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
11616 WMI_LOGE("Seting custom aggregation size failed\n");
11617 wmi_buf_free(buf);
11618 return QDF_STATUS_E_FAILURE;
11619 }
11620
11621 return QDF_STATUS_SUCCESS;
11622}
11623
11624/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011625 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
11626 * @param wmi_handle : handle to WMI.
11627 * @param param : pointer to tx antenna param
11628 *
11629 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11630 */
11631
11632static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
11633 struct set_qdepth_thresh_params *param)
11634{
11635 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
11636 wmi_msduq_qdepth_thresh_update *cmd_update;
11637 wmi_buf_t buf;
11638 int32_t len = 0;
11639 int i;
11640 uint8_t *buf_ptr;
11641 QDF_STATUS ret;
11642
11643 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
11644 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
11645 return QDF_STATUS_E_INVAL;
11646 }
11647
11648 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11649 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
11650 param->num_of_msduq_updates);
11651 buf = wmi_buf_alloc(wmi_handle, len);
11652
11653 if (!buf) {
11654 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11655 return QDF_STATUS_E_NOMEM;
11656 }
11657
11658 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11659 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11660 buf_ptr;
11661
11662 WMITLV_SET_HDR(&cmd->tlv_header,
11663 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11664 , WMITLV_GET_STRUCT_TLVLEN(
11665 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11666
11667 cmd->pdev_id =
11668 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11669 cmd->vdev_id = param->vdev_id;
11670 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11671 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11672
11673 buf_ptr += sizeof(
11674 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11675 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11676 param->num_of_msduq_updates *
11677 sizeof(wmi_msduq_qdepth_thresh_update));
11678 buf_ptr += WMI_TLV_HDR_SIZE;
11679 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11680
11681 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11682 WMITLV_SET_HDR(&cmd_update->tlv_header,
11683 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11684 WMITLV_GET_STRUCT_TLVLEN(
11685 wmi_msduq_qdepth_thresh_update));
11686 cmd_update->tid_num = param->update_params[i].tid_num;
11687 cmd_update->msduq_update_mask =
11688 param->update_params[i].msduq_update_mask;
11689 cmd_update->qdepth_thresh_value =
11690 param->update_params[i].qdepth_thresh_value;
11691 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11692 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11693 " update mask=0x%X thresh val=0x%X\n",
11694 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11695 cmd->peer_mac_address.mac_addr31to0,
11696 cmd->peer_mac_address.mac_addr47to32,
11697 cmd_update->msduq_update_mask,
11698 cmd_update->qdepth_thresh_value);
11699 cmd_update++;
11700 }
11701
11702 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11703 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11704
11705 if (ret != 0) {
11706 WMI_LOGE(" %s :WMI Failed\n", __func__);
11707 wmi_buf_free(buf);
11708 }
11709
11710 return ret;
11711}
11712
11713/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011714 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11715 * @wmi_handle: wmi handle
11716 * @param: pointer to hold vap dscp tid map param
11717 *
11718 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11719 */
11720static QDF_STATUS
11721send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11722 struct vap_dscp_tid_map_params *param)
11723{
11724 wmi_buf_t buf;
11725 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11726 int32_t len = sizeof(*cmd);
11727
11728 buf = wmi_buf_alloc(wmi_handle, len);
11729 if (!buf) {
11730 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11731 return QDF_STATUS_E_FAILURE;
11732 }
11733
11734 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11735 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053011736 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053011737
11738 cmd->vdev_id = param->vdev_id;
11739 cmd->enable_override = 0;
11740
11741 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11742 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11743 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11744 WMI_LOGE("Failed to set dscp cmd\n");
11745 wmi_buf_free(buf);
11746 return QDF_STATUS_E_FAILURE;
11747 }
11748
11749 return QDF_STATUS_SUCCESS;
11750}
11751
11752/**
11753 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11754 * @wmi_handle: wmi handle
11755 * @macaddr: vdev mac address
11756 * @param: pointer to hold neigbour rx param
11757 *
11758 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11759 */
11760static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11761 uint8_t macaddr[IEEE80211_ADDR_LEN],
11762 struct set_neighbour_rx_params *param)
11763{
11764 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11765 wmi_buf_t buf;
11766 int32_t len = sizeof(*cmd);
11767
11768 buf = wmi_buf_alloc(wmi_handle, len);
11769 if (!buf) {
11770 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11771 return QDF_STATUS_E_FAILURE;
11772 }
11773 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11774 WMITLV_SET_HDR(&cmd->tlv_header,
11775 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11776 WMITLV_GET_STRUCT_TLVLEN(
11777 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11778 cmd->vdev_id = param->vdev_id;
11779 cmd->bssid_idx = param->idx;
11780 cmd->action = param->action;
11781 cmd->type = param->type;
11782 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11783 cmd->flag = 0;
11784
11785 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11786 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11787 WMI_LOGE("Failed to set neighbour rx param\n");
11788 wmi_buf_free(buf);
11789 return QDF_STATUS_E_FAILURE;
11790 }
11791
11792 return QDF_STATUS_SUCCESS;
11793}
11794
11795/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011796 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011797 * @param wmi_handle : handle to WMI.
11798 * @param macaddr : vdev mac address
11799 * @param param : pointer to tx antenna param
11800 *
11801 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11802 */
11803static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11804 uint8_t macaddr[IEEE80211_ADDR_LEN],
11805 struct smart_ant_tx_ant_params *param)
11806{
11807 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11808 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11809 wmi_buf_t buf;
11810 int32_t len = 0;
11811 int i;
11812 uint8_t *buf_ptr;
11813 QDF_STATUS ret;
11814
11815 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11816 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11817 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11818 buf = wmi_buf_alloc(wmi_handle, len);
11819
11820 if (!buf) {
11821 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11822 return QDF_STATUS_E_NOMEM;
11823 }
11824
11825 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11826 qdf_mem_zero(buf_ptr, len);
11827 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11828
11829 WMITLV_SET_HDR(&cmd->tlv_header,
11830 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11831 WMITLV_GET_STRUCT_TLVLEN(
11832 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11833
11834 cmd->vdev_id = param->vdev_id;
11835 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11836
11837 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11838 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11839 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11840 buf_ptr += WMI_TLV_HDR_SIZE;
11841 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11842
11843 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11844 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11845 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11846 WMITLV_GET_STRUCT_TLVLEN(
11847 wmi_peer_smart_ant_set_tx_antenna_series));
11848 ant_tx_series->antenna_series = param->antenna_array[i];
11849 ant_tx_series++;
11850 }
11851
11852 ret = wmi_unified_cmd_send(wmi_handle,
11853 buf,
11854 len,
11855 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11856
11857 if (ret != 0) {
11858 WMI_LOGE(" %s :WMI Failed\n", __func__);
11859 wmi_buf_free(buf);
11860 }
11861
11862 return ret;
11863}
11864
Sathish Kumar02c3b542017-02-22 17:24:45 +053011865/**
11866 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11867 * @wmi_handle: wmi handle
11868 * @param: pointer to hold ant switch tbl param
11869 *
11870 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11871 */
11872static QDF_STATUS
11873send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11874 struct ant_switch_tbl_params *param)
11875{
11876 uint8_t len;
11877 wmi_buf_t buf;
11878 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11879 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11880 uint8_t *buf_ptr;
11881
11882 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11883 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11884 buf = wmi_buf_alloc(wmi_handle, len);
11885
11886 if (!buf) {
11887 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11888 return QDF_STATUS_E_NOMEM;
11889 }
11890
11891 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11892 qdf_mem_zero(buf_ptr, len);
11893 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11894
11895 WMITLV_SET_HDR(&cmd->tlv_header,
11896 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11897 WMITLV_GET_STRUCT_TLVLEN(
11898 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11899
11900 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11901 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011902 cmd->mac_id =
11903 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011904
11905 /* TLV indicating array of structures to follow */
11906 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11907 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11908 sizeof(wmi_pdev_set_ant_ctrl_chain));
11909 buf_ptr += WMI_TLV_HDR_SIZE;
11910 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11911
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011912 ctrl_chain->pdev_id =
11913 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011914 ctrl_chain->antCtrlChain = param->antCtrlChain;
11915
11916 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11917 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11918 wmi_buf_free(buf);
11919 return QDF_STATUS_E_FAILURE;
11920 }
11921
11922 return QDF_STATUS_SUCCESS;
11923}
11924
11925/**
11926 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11927 * training information function
11928 * @param wmi_handle : handle to WMI.
11929 * @macaddr : vdev mac address
11930 * @param param : pointer to tx antenna param
11931 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11932 */
11933static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11934 wmi_unified_t wmi_handle,
11935 uint8_t macaddr[IEEE80211_ADDR_LEN],
11936 struct smart_ant_training_info_params *param)
11937{
11938 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11939 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11940 wmi_buf_t buf;
11941 uint8_t *buf_ptr;
11942 int32_t len = 0;
11943 QDF_STATUS ret;
11944 int loop;
11945
11946 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11947 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11948 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11949 buf = wmi_buf_alloc(wmi_handle, len);
11950
11951 if (!buf) {
11952 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11953 return QDF_STATUS_E_NOMEM;
11954 }
11955
11956 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11957 qdf_mem_zero(buf_ptr, len);
11958 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11959
11960 WMITLV_SET_HDR(&cmd->tlv_header,
11961 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11962 WMITLV_GET_STRUCT_TLVLEN(
11963 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11964
11965 cmd->vdev_id = param->vdev_id;
11966 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11967 cmd->num_pkts = param->numpkts;
11968
11969 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11970 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11971 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11972 WMI_SMART_ANT_MAX_RATE_SERIES);
11973
11974 buf_ptr += WMI_TLV_HDR_SIZE;
11975 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11976
11977 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11978 WMITLV_SET_HDR(&train_param->tlv_header,
11979 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11980 WMITLV_GET_STRUCT_TLVLEN(
11981 wmi_peer_smart_ant_set_train_antenna_param));
11982 train_param->train_rate_series = param->rate_array[loop];
11983 train_param->train_antenna_series = param->antenna_array[loop];
11984 train_param->rc_flags = 0;
11985 WMI_LOGI(FL("Series number:%d\n"), loop);
11986 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11987 train_param->train_rate_series,
11988 train_param->train_antenna_series);
11989 train_param++;
11990 }
11991
11992 ret = wmi_unified_cmd_send(wmi_handle,
11993 buf,
11994 len,
11995 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11996
11997 if (ret != 0) {
11998 WMI_LOGE(" %s :WMI Failed\n", __func__);
11999 wmi_buf_free(buf);
12000 return QDF_STATUS_E_FAILURE;
12001 }
12002
12003 return ret;
12004}
12005
12006/**
12007 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
12008 * configuration function
12009 * @param wmi_handle : handle to WMI.
12010 * @macaddr : vdev mad address
12011 * @param param : pointer to tx antenna param
12012 *
12013 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12014 */
12015static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
12016 wmi_unified_t wmi_handle,
12017 uint8_t macaddr[IEEE80211_ADDR_LEN],
12018 struct smart_ant_node_config_params *param)
12019{
12020 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
12021 wmi_buf_t buf;
12022 uint8_t *buf_ptr;
12023 int32_t len = 0, args_tlv_len;
12024 int ret;
12025 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053012026 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053012027
Vivekc5823092018-03-22 23:27:21 +053012028 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053012029 len = sizeof(*cmd) + args_tlv_len;
12030
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070012031 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053012032 WMI_LOGE("%s: Can't send a command with %d arguments\n",
12033 __func__, param->args_count);
12034 return QDF_STATUS_E_FAILURE;
12035 }
12036
12037 buf = wmi_buf_alloc(wmi_handle, len);
12038 if (!buf) {
12039 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12040 return QDF_STATUS_E_NOMEM;
12041 }
12042
12043 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
12044 wmi_buf_data(buf);
12045 buf_ptr = (uint8_t *)cmd;
12046 WMITLV_SET_HDR(&cmd->tlv_header,
12047 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
12048 WMITLV_GET_STRUCT_TLVLEN(
12049 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
12050 cmd->vdev_id = param->vdev_id;
12051 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12052 cmd->cmd_id = param->cmd_id;
12053 cmd->args_count = param->args_count;
12054 buf_ptr += sizeof(
12055 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
12056 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053012057 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053012058 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053012059 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053012060
12061 for (i = 0; i < param->args_count; i++) {
12062 node_config_args[i] = param->args_arr[i];
12063 WMI_LOGI("%d", param->args_arr[i]);
12064 }
12065
12066 ret = wmi_unified_cmd_send(wmi_handle,
12067 buf,
12068 len,
12069 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
12070
12071 if (ret != 0) {
12072 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
12073 __func__, param->cmd_id, macaddr[0],
12074 macaddr[1], macaddr[2], macaddr[3],
12075 macaddr[4], macaddr[5], ret);
12076 wmi_buf_free(buf);
12077 }
12078
12079 return ret;
12080}
12081
12082/**
12083 * send_set_atf_cmd_tlv() - send set atf command to fw
12084 * @wmi_handle: wmi handle
12085 * @param: pointer to set atf param
12086 *
12087 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12088 */
12089static QDF_STATUS
12090send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
12091 struct set_atf_params *param)
12092{
12093 wmi_atf_peer_info *peer_info;
12094 wmi_peer_atf_request_fixed_param *cmd;
12095 wmi_buf_t buf;
12096 uint8_t *buf_ptr;
12097 int i;
12098 int32_t len = 0;
12099 QDF_STATUS retval;
12100
12101 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12102 len += param->num_peers * sizeof(wmi_atf_peer_info);
12103 buf = wmi_buf_alloc(wmi_handle, len);
12104 if (!buf) {
12105 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12106 return QDF_STATUS_E_FAILURE;
12107 }
12108 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12109 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
12110 WMITLV_SET_HDR(&cmd->tlv_header,
12111 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
12112 WMITLV_GET_STRUCT_TLVLEN(
12113 wmi_peer_atf_request_fixed_param));
12114 cmd->num_peers = param->num_peers;
12115
12116 buf_ptr += sizeof(*cmd);
12117 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12118 sizeof(wmi_atf_peer_info) *
12119 cmd->num_peers);
12120 buf_ptr += WMI_TLV_HDR_SIZE;
12121 peer_info = (wmi_atf_peer_info *)buf_ptr;
12122
12123 for (i = 0; i < cmd->num_peers; i++) {
12124 WMITLV_SET_HDR(&peer_info->tlv_header,
12125 WMITLV_TAG_STRUC_wmi_atf_peer_info,
12126 WMITLV_GET_STRUCT_TLVLEN(
12127 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012128 qdf_mem_copy(&(peer_info->peer_macaddr),
12129 &(param->peer_info[i].peer_macaddr),
12130 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053012131 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012132 peer_info->vdev_id = param->peer_info[i].vdev_id;
12133 peer_info->pdev_id =
12134 wmi_handle->ops->convert_pdev_id_host_to_target(
12135 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053012136 /*
12137 * TLV definition for peer atf request fixed param combines
12138 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
12139 * stats and atf extension stats as two different
12140 * implementations.
12141 * Need to discuss with FW on this.
12142 *
12143 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
12144 * peer_info->atf_units_reserved =
12145 * param->peer_ext_info[i].atf_index_reserved;
12146 */
12147 peer_info++;
12148 }
12149
12150 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12151 WMI_PEER_ATF_REQUEST_CMDID);
12152
12153 if (retval != QDF_STATUS_SUCCESS) {
12154 WMI_LOGE("%s : WMI Failed\n", __func__);
12155 wmi_buf_free(buf);
12156 }
12157
12158 return retval;
12159}
12160
12161/**
12162 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
12163 * @wmi_handle: wmi handle
12164 * @param: pointer to hold fwtest param
12165 *
12166 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12167 */
12168static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
12169 struct set_fwtest_params *param)
12170{
12171 wmi_fwtest_set_param_cmd_fixed_param *cmd;
12172 wmi_buf_t buf;
12173 int32_t len = sizeof(*cmd);
12174
12175 buf = wmi_buf_alloc(wmi_handle, len);
12176
12177 if (!buf) {
12178 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12179 return QDF_STATUS_E_FAILURE;
12180 }
12181
12182 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
12183 WMITLV_SET_HDR(&cmd->tlv_header,
12184 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
12185 WMITLV_GET_STRUCT_TLVLEN(
12186 wmi_fwtest_set_param_cmd_fixed_param));
12187 cmd->param_id = param->arg;
12188 cmd->param_value = param->value;
12189
12190 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
12191 WMI_LOGE("Setting FW test param failed\n");
12192 wmi_buf_free(buf);
12193 return QDF_STATUS_E_FAILURE;
12194 }
12195
12196 return QDF_STATUS_SUCCESS;
12197}
12198
12199/**
12200 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
12201 * @wmi_handle: wmi handle
12202 * @param: pointer to qboost params
12203 * @macaddr: vdev mac address
12204 *
12205 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12206 */
12207static QDF_STATUS
12208send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
12209 uint8_t macaddr[IEEE80211_ADDR_LEN],
12210 struct set_qboost_params *param)
12211{
12212 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
12213 wmi_buf_t buf;
12214 int32_t len;
12215 QDF_STATUS ret;
12216
12217 len = sizeof(*cmd);
12218
12219 buf = wmi_buf_alloc(wmi_handle, len);
12220 if (!buf) {
12221 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12222 return QDF_STATUS_E_FAILURE;
12223 }
12224
12225 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
12226 WMITLV_SET_HDR(&cmd->tlv_header,
12227 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
12228 WMITLV_GET_STRUCT_TLVLEN(
12229 WMI_QBOOST_CFG_CMD_fixed_param));
12230 cmd->vdev_id = param->vdev_id;
12231 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12232 cmd->qb_enable = param->value;
12233
12234 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12235 WMI_QBOOST_CFG_CMDID);
12236
12237 if (ret != 0) {
12238 WMI_LOGE("Setting qboost cmd failed\n");
12239 wmi_buf_free(buf);
12240 }
12241
12242 return ret;
12243}
12244
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012245/**
12246 * send_gpio_config_cmd_tlv() - send gpio config to fw
12247 * @wmi_handle: wmi handle
12248 * @param: pointer to hold gpio config param
12249 *
12250 * Return: 0 for success or error code
12251 */
12252static QDF_STATUS
12253send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
12254 struct gpio_config_params *param)
12255{
12256 wmi_gpio_config_cmd_fixed_param *cmd;
12257 wmi_buf_t buf;
12258 int32_t len;
12259 QDF_STATUS ret;
12260
12261 len = sizeof(*cmd);
12262
12263 /* Sanity Checks */
12264 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
12265 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
12266 return QDF_STATUS_E_FAILURE;
12267 }
12268
12269 buf = wmi_buf_alloc(wmi_handle, len);
12270 if (!buf) {
12271 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12272 return QDF_STATUS_E_FAILURE;
12273 }
12274
12275 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
12276 WMITLV_SET_HDR(&cmd->tlv_header,
12277 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
12278 WMITLV_GET_STRUCT_TLVLEN(
12279 wmi_gpio_config_cmd_fixed_param));
12280 cmd->gpio_num = param->gpio_num;
12281 cmd->input = param->input;
12282 cmd->pull_type = param->pull_type;
12283 cmd->intr_mode = param->intr_mode;
12284
12285 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12286 WMI_GPIO_CONFIG_CMDID);
12287
12288 if (ret != 0) {
12289 WMI_LOGE("Sending GPIO config cmd failed\n");
12290 wmi_buf_free(buf);
12291 }
12292
12293 return ret;
12294}
12295
12296/**
12297 * send_gpio_output_cmd_tlv() - send gpio output to fw
12298 * @wmi_handle: wmi handle
12299 * @param: pointer to hold gpio output param
12300 *
12301 * Return: 0 for success or error code
12302 */
12303static QDF_STATUS
12304send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
12305 struct gpio_output_params *param)
12306{
12307 wmi_gpio_output_cmd_fixed_param *cmd;
12308 wmi_buf_t buf;
12309 int32_t len;
12310 QDF_STATUS ret;
12311
12312 len = sizeof(*cmd);
12313
12314 buf = wmi_buf_alloc(wmi_handle, len);
12315 if (!buf) {
12316 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12317 return QDF_STATUS_E_FAILURE;
12318 }
12319
12320 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
12321 WMITLV_SET_HDR(&cmd->tlv_header,
12322 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
12323 WMITLV_GET_STRUCT_TLVLEN(
12324 wmi_gpio_output_cmd_fixed_param));
12325 cmd->gpio_num = param->gpio_num;
12326 cmd->set = param->set;
12327
12328 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12329 WMI_GPIO_OUTPUT_CMDID);
12330
12331 if (ret != 0) {
12332 WMI_LOGE("Sending GPIO output cmd failed\n");
12333 wmi_buf_free(buf);
12334 }
12335
12336 return ret;
12337
12338}
12339
12340/**
12341 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
12342 *
12343 * @param wmi_handle : handle to WMI.
12344 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12345 */
12346static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
12347{
12348 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
12349 wmi_buf_t buf;
12350 QDF_STATUS ret;
12351 int32_t len;
12352
12353 len = sizeof(*cmd);
12354
12355 buf = wmi_buf_alloc(wmi_handle, len);
12356 if (!buf) {
12357 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12358 return QDF_STATUS_E_FAILURE;
12359 }
12360
12361 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
12362 WMITLV_SET_HDR(&cmd->tlv_header,
12363 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
12364 WMITLV_GET_STRUCT_TLVLEN(
12365 wmi_pdev_dfs_disable_cmd_fixed_param));
12366 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012367 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12368 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012369
12370 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12371 WMI_PDEV_DFS_DISABLE_CMDID);
12372
12373 if (ret != 0) {
12374 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
12375 wmi_buf_free(buf);
12376 }
12377
12378 return ret;
12379}
12380
12381/**
12382 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
12383 *
12384 * @param wmi_handle : handle to WMI.
12385 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12386 */
12387static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
12388{
12389 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
12390 wmi_buf_t buf;
12391 QDF_STATUS ret;
12392 int32_t len;
12393
12394 len = sizeof(*cmd);
12395
12396 buf = wmi_buf_alloc(wmi_handle, len);
12397 if (!buf) {
12398 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12399 return QDF_STATUS_E_FAILURE;
12400 }
12401
12402 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
12403 WMITLV_SET_HDR(&cmd->tlv_header,
12404 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
12405 WMITLV_GET_STRUCT_TLVLEN(
12406 wmi_pdev_dfs_enable_cmd_fixed_param));
12407 /* Reserved for future use */
12408 cmd->reserved0 = 0;
12409
12410 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12411 WMI_PDEV_DFS_ENABLE_CMDID);
12412
12413 if (ret != 0) {
12414 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
12415 wmi_buf_free(buf);
12416 }
12417
12418 return ret;
12419}
12420
12421/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053012422 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
12423 * to fw
12424 * @wmi_handle: wmi handle
12425 * @param: pointer to hold periodic chan stats param
12426 *
12427 * Return: 0 for success or error code
12428 */
12429static QDF_STATUS
12430send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
12431 struct periodic_chan_stats_params *param)
12432{
12433 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
12434 wmi_buf_t buf;
12435 QDF_STATUS ret;
12436 int32_t len;
12437
12438 len = sizeof(*cmd);
12439
12440 buf = wmi_buf_alloc(wmi_handle, len);
12441 if (!buf) {
12442 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12443 return QDF_STATUS_E_FAILURE;
12444 }
12445
12446 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
12447 wmi_buf_data(buf);
12448 WMITLV_SET_HDR(&cmd->tlv_header,
12449 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
12450 WMITLV_GET_STRUCT_TLVLEN(
12451 wmi_set_periodic_channel_stats_config_fixed_param));
12452 cmd->enable = param->enable;
12453 cmd->stats_period = param->stats_period;
12454 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12455 param->pdev_id);
12456
12457 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12458 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
12459
12460 if (ret != 0) {
12461 WMI_LOGE("Sending periodic chan stats config failed");
12462 wmi_buf_free(buf);
12463 }
12464
12465 return ret;
12466}
12467
12468/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012469 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
12470 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080012471 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012472 *
12473 * Return: 0 for success or error code
12474 */
12475static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080012476send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012477{
12478 wmi_buf_t buf;
12479 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080012480 wmi_pdev_get_nfcal_power_fixed_param *cmd;
12481 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012482
nobeljf74583b2018-01-25 16:35:36 -080012483 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012484 if (buf == NULL)
12485 return QDF_STATUS_E_NOMEM;
12486
nobeljf74583b2018-01-25 16:35:36 -080012487 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
12488 WMITLV_SET_HDR(&cmd->tlv_header,
12489 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
12490 WMITLV_GET_STRUCT_TLVLEN
12491 (wmi_pdev_get_nfcal_power_fixed_param));
12492 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
12493
12494 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012495 WMI_PDEV_GET_NFCAL_POWER_CMDID);
12496 if (ret != 0) {
12497 WMI_LOGE("Sending get nfcal power cmd failed\n");
12498 wmi_buf_free(buf);
12499 }
12500
12501 return ret;
12502}
12503
12504/**
12505 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
12506 * @wmi_handle: wmi handle
12507 * @param: pointer to ht ie param
12508 *
12509 * Return: 0 for success or error code
12510 */
12511static QDF_STATUS
12512send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12513 struct ht_ie_params *param)
12514{
12515 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
12516 wmi_buf_t buf;
12517 QDF_STATUS ret;
12518 int32_t len;
12519 uint8_t *buf_ptr;
12520
12521 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12522 roundup(param->ie_len, sizeof(uint32_t));
12523
12524 buf = wmi_buf_alloc(wmi_handle, len);
12525 if (!buf) {
12526 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12527 return QDF_STATUS_E_FAILURE;
12528 }
12529
12530 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12531 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
12532 WMITLV_SET_HDR(&cmd->tlv_header,
12533 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
12534 WMITLV_GET_STRUCT_TLVLEN(
12535 wmi_pdev_set_ht_ie_cmd_fixed_param));
12536 cmd->reserved0 = 0;
12537 cmd->ie_len = param->ie_len;
12538 cmd->tx_streams = param->tx_streams;
12539 cmd->rx_streams = param->rx_streams;
12540
12541 buf_ptr += sizeof(*cmd);
12542 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12543 buf_ptr += WMI_TLV_HDR_SIZE;
12544 if (param->ie_len)
12545 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12546 cmd->ie_len);
12547
12548 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12549 WMI_PDEV_SET_HT_CAP_IE_CMDID);
12550
12551 if (ret != 0) {
12552 WMI_LOGE("Sending set ht ie cmd failed\n");
12553 wmi_buf_free(buf);
12554 }
12555
12556 return ret;
12557}
12558
12559/**
12560 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
12561 * @wmi_handle: wmi handle
12562 * @param: pointer to vht ie param
12563 *
12564 * Return: 0 for success or error code
12565 */
12566static QDF_STATUS
12567send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12568 struct vht_ie_params *param)
12569{
12570 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
12571 wmi_buf_t buf;
12572 QDF_STATUS ret;
12573 int32_t len;
12574 uint8_t *buf_ptr;
12575
12576 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12577 roundup(param->ie_len, sizeof(uint32_t));
12578
12579 buf = wmi_buf_alloc(wmi_handle, len);
12580 if (!buf) {
12581 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12582 return QDF_STATUS_E_FAILURE;
12583 }
12584
12585 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12586 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
12587 WMITLV_SET_HDR(&cmd->tlv_header,
12588 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
12589 WMITLV_GET_STRUCT_TLVLEN(
12590 wmi_pdev_set_vht_ie_cmd_fixed_param));
12591 cmd->reserved0 = 0;
12592 cmd->ie_len = param->ie_len;
12593 cmd->tx_streams = param->tx_streams;
12594 cmd->rx_streams = param->rx_streams;
12595
12596 buf_ptr += sizeof(*cmd);
12597 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12598 buf_ptr += WMI_TLV_HDR_SIZE;
12599 if (param->ie_len)
12600 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12601 cmd->ie_len);
12602
12603 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12604 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
12605
12606 if (ret != 0) {
12607 WMI_LOGE("Sending set vht ie cmd failed\n");
12608 wmi_buf_free(buf);
12609 }
12610
12611 return ret;
12612}
12613
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012614/**
12615 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
12616 * @wmi_handle: wmi handle
12617 * @param: pointer to quiet mode params
12618 *
12619 * Return: 0 for success or error code
12620 */
12621static QDF_STATUS
12622send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
12623 struct set_quiet_mode_params *param)
12624{
12625 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
12626 wmi_buf_t buf;
12627 QDF_STATUS ret;
12628 int32_t len;
12629
12630 len = sizeof(*quiet_cmd);
12631 buf = wmi_buf_alloc(wmi_handle, len);
12632 if (!buf) {
12633 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12634 return QDF_STATUS_E_FAILURE;
12635 }
12636
12637 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12638 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
12639 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
12640 WMITLV_GET_STRUCT_TLVLEN(
12641 wmi_pdev_set_quiet_cmd_fixed_param));
12642 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12643 quiet_cmd->enabled = param->enabled;
12644 quiet_cmd->period = (param->period)*(param->intval);
12645 quiet_cmd->duration = param->duration;
12646 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012647 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12648 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012649
12650 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12651 WMI_PDEV_SET_QUIET_MODE_CMDID);
12652
12653 if (ret != 0) {
12654 WMI_LOGE("Sending set quiet cmd failed\n");
12655 wmi_buf_free(buf);
12656 }
12657
12658 return ret;
12659}
12660
12661/**
12662 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12663 * @wmi_handle: wmi handle
12664 * @param: pointer to set bwf param
12665 *
12666 * Return: 0 for success or error code
12667 */
12668static QDF_STATUS
12669send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12670 struct set_bwf_params *param)
12671{
12672 wmi_bwf_peer_info *peer_info;
12673 wmi_peer_bwf_request_fixed_param *cmd;
12674 wmi_buf_t buf;
12675 QDF_STATUS retval;
12676 int32_t len;
12677 uint8_t *buf_ptr;
12678 int i;
12679
12680 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12681 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12682 buf = wmi_buf_alloc(wmi_handle, len);
12683 if (!buf) {
12684 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12685 return QDF_STATUS_E_FAILURE;
12686 }
12687 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12688 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12689 WMITLV_SET_HDR(&cmd->tlv_header,
12690 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12691 WMITLV_GET_STRUCT_TLVLEN(
12692 wmi_peer_bwf_request_fixed_param));
12693 cmd->num_peers = param->num_peers;
12694
12695 buf_ptr += sizeof(*cmd);
12696 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12697 sizeof(wmi_bwf_peer_info) *
12698 cmd->num_peers);
12699 buf_ptr += WMI_TLV_HDR_SIZE;
12700 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12701
12702 for (i = 0; i < cmd->num_peers; i++) {
12703 WMITLV_SET_HDR(&peer_info->tlv_header,
12704 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12705 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12706 peer_info->bwf_guaranteed_bandwidth =
12707 param->peer_info[i].throughput;
12708 peer_info->bwf_max_airtime =
12709 param->peer_info[i].max_airtime;
12710 peer_info->bwf_peer_priority =
12711 param->peer_info[i].priority;
12712 qdf_mem_copy(&peer_info->peer_macaddr,
12713 &param->peer_info[i].peer_macaddr,
12714 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012715 peer_info->vdev_id =
12716 param->peer_info[i].vdev_id;
12717 peer_info->pdev_id =
12718 wmi_handle->ops->convert_pdev_id_host_to_target(
12719 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012720 peer_info++;
12721 }
12722
12723 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12724 WMI_PEER_BWF_REQUEST_CMDID);
12725
12726 if (retval != QDF_STATUS_SUCCESS) {
12727 WMI_LOGE("%s : WMI Failed\n", __func__);
12728 wmi_buf_free(buf);
12729 }
12730
12731 return retval;
12732}
12733
12734/**
12735 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12736 * @wmi_handle: wmi handle
12737 * @param: pointer to hold mcast update param
12738 *
12739 * Return: 0 for success or error code
12740 */
12741static QDF_STATUS
12742send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12743 struct mcast_group_update_params *param)
12744{
12745 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12746 wmi_buf_t buf;
12747 QDF_STATUS ret;
12748 int32_t len;
12749 int offset = 0;
12750 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12751
12752 len = sizeof(*cmd);
12753 buf = wmi_buf_alloc(wmi_handle, len);
12754 if (!buf) {
12755 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12756 return QDF_STATUS_E_FAILURE;
12757 }
12758 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12759 WMITLV_SET_HDR(&cmd->tlv_header,
12760 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12761 WMITLV_GET_STRUCT_TLVLEN(
12762 wmi_peer_mcast_group_cmd_fixed_param));
12763 /* confirm the buffer is 4-byte aligned */
12764 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12765 qdf_mem_zero(cmd, sizeof(*cmd));
12766
12767 cmd->vdev_id = param->vap_id;
12768 /* construct the message assuming our endianness matches the target */
12769 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12770 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12771 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12772 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12773 if (param->is_action_delete)
12774 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12775
12776 if (param->is_mcast_addr_len)
12777 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12778
12779 if (param->is_filter_mode_snoop)
12780 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12781
12782 /* unicast address spec only applies for non-wildcard cases */
12783 if (!param->wildcard && param->ucast_mac_addr) {
12784 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12785 &cmd->ucast_mac_addr);
12786 }
Amar Singhal5593c902017-10-03 13:00:29 -070012787
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012788 if (param->mcast_ip_addr) {
12789 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12790 sizeof(cmd->mcast_ip_addr));
12791 offset = sizeof(cmd->mcast_ip_addr) -
12792 param->mcast_ip_addr_bytes;
12793 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12794 param->mcast_ip_addr,
12795 param->mcast_ip_addr_bytes);
12796 }
12797 if (!param->mask)
12798 param->mask = &dummymask[0];
12799
12800 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12801 param->mask,
12802 param->mcast_ip_addr_bytes);
12803
12804 if (param->srcs && param->nsrcs) {
12805 cmd->num_filter_addr = param->nsrcs;
12806 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12807 sizeof(cmd->filter_addr));
12808
12809 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12810 param->nsrcs * param->mcast_ip_addr_bytes);
12811 }
12812
12813 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12814 WMI_PEER_MCAST_GROUP_CMDID);
12815
12816 if (ret != QDF_STATUS_SUCCESS) {
12817 WMI_LOGE("%s : WMI Failed\n", __func__);
12818 wmi_buf_free(buf);
12819 }
12820
12821 return ret;
12822}
12823
12824/**
12825 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12826 * command to fw
12827 * @wmi_handle: wmi handle
12828 * @param: pointer to hold spectral config parameter
12829 *
12830 * Return: 0 for success or error code
12831 */
12832static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12833 struct vdev_spectral_configure_params *param)
12834{
12835 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12836 wmi_buf_t buf;
12837 QDF_STATUS ret;
12838 int32_t len;
12839
12840 len = sizeof(*cmd);
12841 buf = wmi_buf_alloc(wmi_handle, len);
12842 if (!buf) {
12843 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12844 return QDF_STATUS_E_FAILURE;
12845 }
12846
12847 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12848 WMITLV_SET_HDR(&cmd->tlv_header,
12849 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12850 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012851 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012852
12853 cmd->vdev_id = param->vdev_id;
12854 cmd->spectral_scan_count = param->count;
12855 cmd->spectral_scan_period = param->period;
12856 cmd->spectral_scan_priority = param->spectral_pri;
12857 cmd->spectral_scan_fft_size = param->fft_size;
12858 cmd->spectral_scan_gc_ena = param->gc_enable;
12859 cmd->spectral_scan_restart_ena = param->restart_enable;
12860 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12861 cmd->spectral_scan_init_delay = param->init_delay;
12862 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12863 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12864 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12865 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12866 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12867 cmd->spectral_scan_pwr_format = param->pwr_format;
12868 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12869 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012870 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012871 cmd->spectral_scan_chn_mask = param->chn_mask;
12872
12873 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12874 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12875
12876 if (ret != 0) {
12877 WMI_LOGE("Sending set quiet cmd failed\n");
12878 wmi_buf_free(buf);
12879 }
12880
12881 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12882 __func__);
12883
12884 WMI_LOGI("vdev_id = %u\n"
12885 "spectral_scan_count = %u\n"
12886 "spectral_scan_period = %u\n"
12887 "spectral_scan_priority = %u\n"
12888 "spectral_scan_fft_size = %u\n"
12889 "spectral_scan_gc_ena = %u\n"
12890 "spectral_scan_restart_ena = %u\n"
12891 "spectral_scan_noise_floor_ref = %u\n"
12892 "spectral_scan_init_delay = %u\n"
12893 "spectral_scan_nb_tone_thr = %u\n"
12894 "spectral_scan_str_bin_thr = %u\n"
12895 "spectral_scan_wb_rpt_mode = %u\n"
12896 "spectral_scan_rssi_rpt_mode = %u\n"
12897 "spectral_scan_rssi_thr = %u\n"
12898 "spectral_scan_pwr_format = %u\n"
12899 "spectral_scan_rpt_mode = %u\n"
12900 "spectral_scan_bin_scale = %u\n"
12901 "spectral_scan_dBm_adj = %u\n"
12902 "spectral_scan_chn_mask = %u\n",
12903 param->vdev_id,
12904 param->count,
12905 param->period,
12906 param->spectral_pri,
12907 param->fft_size,
12908 param->gc_enable,
12909 param->restart_enable,
12910 param->noise_floor_ref,
12911 param->init_delay,
12912 param->nb_tone_thr,
12913 param->str_bin_thr,
12914 param->wb_rpt_mode,
12915 param->rssi_rpt_mode,
12916 param->rssi_thr,
12917 param->pwr_format,
12918 param->rpt_mode,
12919 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012920 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012921 param->chn_mask);
12922 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12923
12924 return ret;
12925}
12926
12927/**
12928 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12929 * command to fw
12930 * @wmi_handle: wmi handle
12931 * @param: pointer to hold spectral enable parameter
12932 *
12933 * Return: 0 for success or error code
12934 */
12935static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12936 struct vdev_spectral_enable_params *param)
12937{
12938 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12939 wmi_buf_t buf;
12940 QDF_STATUS ret;
12941 int32_t len;
12942
12943 len = sizeof(*cmd);
12944 buf = wmi_buf_alloc(wmi_handle, len);
12945 if (!buf) {
12946 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12947 return QDF_STATUS_E_FAILURE;
12948 }
12949
12950 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12951 WMITLV_SET_HDR(&cmd->tlv_header,
12952 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12953 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012954 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012955
12956 cmd->vdev_id = param->vdev_id;
12957
12958 if (param->active_valid) {
12959 cmd->trigger_cmd = param->active ? 1 : 2;
12960 /* 1: Trigger, 2: Clear Trigger */
12961 } else {
12962 cmd->trigger_cmd = 0; /* 0: Ignore */
12963 }
12964
12965 if (param->enabled_valid) {
12966 cmd->enable_cmd = param->enabled ? 1 : 2;
12967 /* 1: Enable 2: Disable */
12968 } else {
12969 cmd->enable_cmd = 0; /* 0: Ignore */
12970 }
12971
12972 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12973 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12974
12975 if (ret != 0) {
12976 WMI_LOGE("Sending scan enable CMD failed\n");
12977 wmi_buf_free(buf);
12978 }
12979
12980 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12981
12982 WMI_LOGI("vdev_id = %u\n"
12983 "trigger_cmd = %u\n"
12984 "enable_cmd = %u\n",
12985 cmd->vdev_id,
12986 cmd->trigger_cmd,
12987 cmd->enable_cmd);
12988
12989 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12990
12991 return ret;
12992}
12993
12994/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012995 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12996 * @param wmi_handle : handle to WMI.
12997 * @param param : pointer to hold thermal mitigation param
12998 *
12999 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
13000 */
13001static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
13002 wmi_unified_t wmi_handle,
13003 struct thermal_mitigation_params *param)
13004{
13005 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
13006 wmi_therm_throt_level_config_info *lvl_conf = NULL;
13007 wmi_buf_t buf = NULL;
13008 uint8_t *buf_ptr = NULL;
13009 int error;
13010 int32_t len;
13011 int i;
13012
13013 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
13014 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
13015
13016 buf = wmi_buf_alloc(wmi_handle, len);
13017 if (!buf) {
13018 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13019 return QDF_STATUS_E_NOMEM;
13020 }
13021 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
13022
13023 /* init fixed params */
13024 WMITLV_SET_HDR(tt_conf,
13025 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
13026 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
13027
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013028 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13029 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053013030 tt_conf->enable = param->enable;
13031 tt_conf->dc = param->dc;
13032 tt_conf->dc_per_event = param->dc_per_event;
13033 tt_conf->therm_throt_levels = THERMAL_LEVELS;
13034
13035 buf_ptr = (uint8_t *) ++tt_conf;
13036 /* init TLV params */
13037 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13038 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
13039
13040 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
13041 for (i = 0; i < THERMAL_LEVELS; i++) {
13042 WMITLV_SET_HDR(&lvl_conf->tlv_header,
13043 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
13044 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
13045 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
13046 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
13047 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
13048 lvl_conf->prio = param->levelconf[i].priority;
13049 lvl_conf++;
13050 }
13051
13052 error = wmi_unified_cmd_send(wmi_handle, buf, len,
13053 WMI_THERM_THROT_SET_CONF_CMDID);
13054 if (QDF_IS_STATUS_ERROR(error)) {
13055 wmi_buf_free(buf);
13056 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
13057 }
13058
13059 return error;
13060}
13061
13062/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013063 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
13064 * @wmi_handle: wmi handle
13065 * @param: pointer to pdev_qvit_params
13066 *
13067 * Return: 0 for success or error code
13068 */
13069static QDF_STATUS
13070send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
13071 struct pdev_qvit_params *param)
13072{
13073 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013074 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013075 uint8_t *cmd;
13076 static uint8_t msgref = 1;
13077 uint8_t segnumber = 0, seginfo, numsegments;
13078 uint16_t chunk_len, total_bytes;
13079 uint8_t *bufpos;
13080 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
13081
13082 bufpos = param->utf_payload;
13083 total_bytes = param->len;
13084 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
13085 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
13086 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
13087
13088 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
13089 numsegments++;
13090
13091 while (param->len) {
13092 if (param->len > MAX_WMI_QVIT_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -070013093 chunk_len = MAX_WMI_QVIT_LEN; /* MAX message */
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013094 else
13095 chunk_len = param->len;
13096
13097 buf = wmi_buf_alloc(wmi_handle,
13098 (chunk_len + sizeof(seghdrinfo) +
13099 WMI_TLV_HDR_SIZE));
13100 if (!buf) {
13101 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13102 return QDF_STATUS_E_NOMEM;
13103 }
13104
13105 cmd = (uint8_t *) wmi_buf_data(buf);
13106
13107 seghdrinfo.len = total_bytes;
13108 seghdrinfo.msgref = msgref;
13109 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
13110 seghdrinfo.segmentInfo = seginfo;
13111
13112 segnumber++;
13113
13114 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
13115 (chunk_len + sizeof(seghdrinfo)));
13116 cmd += WMI_TLV_HDR_SIZE;
13117 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
13118 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
13119
13120 ret = wmi_unified_cmd_send(wmi_handle, buf,
13121 (chunk_len + sizeof(seghdrinfo) +
13122 WMI_TLV_HDR_SIZE),
13123 WMI_PDEV_QVIT_CMDID);
13124
13125 if (ret != 0) {
13126 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
13127 wmi_buf_free(buf);
13128 break;
13129 }
13130
13131 param->len -= chunk_len;
13132 bufpos += chunk_len;
13133 }
13134 msgref++;
13135
13136 return ret;
13137}
13138
13139/**
13140 * send_wmm_update_cmd_tlv() - send wmm update command to fw
13141 * @wmi_handle: wmi handle
13142 * @param: pointer to wmm update param
13143 *
13144 * Return: 0 for success or error code
13145 */
13146static QDF_STATUS
13147send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
13148 struct wmm_update_params *param)
13149{
13150 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
13151 wmi_wmm_params *wmm_param;
13152 wmi_buf_t buf;
13153 QDF_STATUS ret;
13154 int32_t len;
13155 int ac = 0;
13156 struct wmi_host_wmeParams *wmep;
13157 uint8_t *buf_ptr;
13158
13159 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
13160 buf = wmi_buf_alloc(wmi_handle, len);
13161 if (!buf) {
13162 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13163 return QDF_STATUS_E_FAILURE;
13164 }
13165
13166 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13167 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
13168 WMITLV_SET_HDR(&cmd->tlv_header,
13169 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
13170 WMITLV_GET_STRUCT_TLVLEN
13171 (wmi_pdev_set_wmm_params_cmd_fixed_param));
13172
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013173 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013174
13175 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
13176
13177 for (ac = 0; ac < WME_NUM_AC; ac++) {
13178 wmep = &param->wmep_array[ac];
13179 wmm_param = (wmi_wmm_params *)buf_ptr;
13180 WMITLV_SET_HDR(&wmm_param->tlv_header,
13181 WMITLV_TAG_STRUC_wmi_wmm_params,
13182 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
13183 wmm_param->aifs = wmep->wmep_aifsn;
13184 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
13185 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
13186 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
13187 wmm_param->acm = wmep->wmep_acm;
13188 wmm_param->no_ack = wmep->wmep_noackPolicy;
13189 buf_ptr += sizeof(wmi_wmm_params);
13190 }
13191 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13192 WMI_PDEV_SET_WMM_PARAMS_CMDID);
13193
13194 if (ret != 0) {
13195 WMI_LOGE("Sending WMM update CMD failed\n");
13196 wmi_buf_free(buf);
13197 }
13198
13199 return ret;
13200}
13201
Sathish Kumar80f4f382017-04-24 11:36:00 +053013202/**
13203 * send_coex_config_cmd_tlv() - send coex config command to fw
13204 * @wmi_handle: wmi handle
13205 * @param: pointer to coex config param
13206 *
13207 * Return: 0 for success or error code
13208 */
13209static QDF_STATUS
13210send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
13211 struct coex_config_params *param)
13212{
13213 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
13214 wmi_buf_t buf;
13215 QDF_STATUS ret;
13216 int32_t len;
13217
13218 len = sizeof(*cmd);
13219 buf = wmi_buf_alloc(wmi_handle, len);
13220 if (!buf) {
13221 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13222 return QDF_STATUS_E_FAILURE;
13223 }
13224
13225 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
13226 WMITLV_SET_HDR(&cmd->tlv_header,
13227 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
13228 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053013229 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053013230
13231 cmd->vdev_id = param->vdev_id;
13232 cmd->config_type = param->config_type;
13233 cmd->config_arg1 = param->config_arg1;
13234 cmd->config_arg2 = param->config_arg2;
13235 cmd->config_arg3 = param->config_arg3;
13236 cmd->config_arg4 = param->config_arg4;
13237 cmd->config_arg5 = param->config_arg5;
13238 cmd->config_arg6 = param->config_arg6;
13239
13240 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13241 WMI_COEX_CONFIG_CMDID);
13242
13243 if (ret != 0) {
13244 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
13245 wmi_buf_free(buf);
13246 }
13247
13248 return ret;
13249}
13250
Kiran Venkatappa3619e662018-04-04 14:31:43 +053013251
13252#ifdef WLAN_SUPPORT_TWT
13253static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
13254 target_resource_config *tgt_res_cfg)
13255{
13256 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
13257 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
13258}
13259#else
13260static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
13261 target_resource_config *tgt_res_cfg)
13262{
13263 resource_cfg->twt_ap_pdev_count = 0;
13264 resource_cfg->twt_ap_sta_count = 0;
13265}
13266#endif
13267
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013268static
Govind Singh9ddd5162016-03-07 16:30:32 +053013269void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053013270 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053013271{
Govind Singhe7f2f342016-05-23 12:12:52 +053013272 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053013273 resource_cfg->num_peers = tgt_res_cfg->num_peers;
13274 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
13275 resource_cfg->num_offload_reorder_buffs =
13276 tgt_res_cfg->num_offload_reorder_buffs;
13277 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
13278 resource_cfg->num_tids = tgt_res_cfg->num_tids;
13279 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
13280 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
13281 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
13282 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
13283 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
13284 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
13285 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
13286 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
13287 resource_cfg->scan_max_pending_req =
13288 tgt_res_cfg->scan_max_pending_req;
13289 resource_cfg->bmiss_offload_max_vdev =
13290 tgt_res_cfg->bmiss_offload_max_vdev;
13291 resource_cfg->roam_offload_max_vdev =
13292 tgt_res_cfg->roam_offload_max_vdev;
13293 resource_cfg->roam_offload_max_ap_profiles =
13294 tgt_res_cfg->roam_offload_max_ap_profiles;
13295 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
13296 resource_cfg->num_mcast_table_elems =
13297 tgt_res_cfg->num_mcast_table_elems;
13298 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
13299 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
13300 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
13301 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
13302 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
13303 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
13304 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
13305 resource_cfg->vow_config = tgt_res_cfg->vow_config;
13306 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
13307 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
13308 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
13309 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
13310 resource_cfg->num_tdls_conn_table_entries =
13311 tgt_res_cfg->num_tdls_conn_table_entries;
13312 resource_cfg->beacon_tx_offload_max_vdev =
13313 tgt_res_cfg->beacon_tx_offload_max_vdev;
13314 resource_cfg->num_multicast_filter_entries =
13315 tgt_res_cfg->num_multicast_filter_entries;
13316 resource_cfg->num_wow_filters =
13317 tgt_res_cfg->num_wow_filters;
13318 resource_cfg->num_keep_alive_pattern =
13319 tgt_res_cfg->num_keep_alive_pattern;
13320 resource_cfg->keep_alive_pattern_size =
13321 tgt_res_cfg->keep_alive_pattern_size;
13322 resource_cfg->max_tdls_concurrent_sleep_sta =
13323 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
13324 resource_cfg->max_tdls_concurrent_buffer_sta =
13325 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
13326 resource_cfg->wmi_send_separate =
13327 tgt_res_cfg->wmi_send_separate;
13328 resource_cfg->num_ocb_vdevs =
13329 tgt_res_cfg->num_ocb_vdevs;
13330 resource_cfg->num_ocb_channels =
13331 tgt_res_cfg->num_ocb_channels;
13332 resource_cfg->num_ocb_schedules =
13333 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013334 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
13335 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
13336 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013337 resource_cfg->max_num_dbs_scan_duty_cycle =
13338 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080013339 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080013340 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
13341 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053013342
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013343 if (tgt_res_cfg->atf_config)
13344 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
13345 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
13346 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
13347 resource_cfg->flag1, 1);
13348 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
13349 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
13350 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053013351 if (tgt_res_cfg->cce_disable)
13352 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Kiran Venkatappa3619e662018-04-04 14:31:43 +053013353
13354 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Govind Singh9ddd5162016-03-07 16:30:32 +053013355}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013356
13357/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13358 * @wmi_handle: pointer to wmi handle
13359 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -070013360 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013361 * @param: point host parameters for init command
13362 *
13363 * Return: Updated pointer of buf_ptr.
13364 */
13365static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
13366 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
13367{
13368 uint16_t idx;
13369
13370 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13371 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13372 wmi_pdev_band_to_mac *band_to_mac;
13373
13374 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13375 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13376 sizeof(wmi_resource_config) +
13377 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13378 sizeof(wlan_host_memory_chunk)));
13379
13380 WMITLV_SET_HDR(&hw_mode->tlv_header,
13381 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13382 (WMITLV_GET_STRUCT_TLVLEN
13383 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13384
13385 hw_mode->hw_mode_index = param->hw_mode_id;
13386 hw_mode->num_band_to_mac = param->num_band_to_mac;
13387
13388 buf_ptr = (uint8_t *) (hw_mode + 1);
13389 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13390 WMI_TLV_HDR_SIZE);
13391 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13392 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13393 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13394 WMITLV_GET_STRUCT_TLVLEN
13395 (wmi_pdev_band_to_mac));
13396 band_to_mac[idx].pdev_id =
13397 wmi_handle->ops->convert_pdev_id_host_to_target(
13398 param->band_to_mac[idx].pdev_id);
13399 band_to_mac[idx].start_freq =
13400 param->band_to_mac[idx].start_freq;
13401 band_to_mac[idx].end_freq =
13402 param->band_to_mac[idx].end_freq;
13403 }
13404 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13405 (param->num_band_to_mac *
13406 sizeof(wmi_pdev_band_to_mac)) +
13407 WMI_TLV_HDR_SIZE;
13408
13409 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13410 (param->num_band_to_mac *
13411 sizeof(wmi_pdev_band_to_mac)));
13412 }
13413
13414 return buf_ptr;
13415}
13416
13417static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
13418 wmi_init_cmd_fixed_param *cmd)
13419{
13420 int num_whitelist;
13421 wmi_abi_version my_vers;
13422
13423 num_whitelist = sizeof(version_whitelist) /
13424 sizeof(wmi_whitelist_version_info);
13425 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
13426 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
13427 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
13428 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13429 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13430 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13431
13432 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13433 &my_vers,
13434 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13435 &cmd->host_abi_vers);
13436
13437 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13438 __func__,
13439 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13440 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13441 cmd->host_abi_vers.abi_version_ns_0,
13442 cmd->host_abi_vers.abi_version_ns_1,
13443 cmd->host_abi_vers.abi_version_ns_2,
13444 cmd->host_abi_vers.abi_version_ns_3);
13445
13446 /* Save version sent from host -
13447 * Will be used to check ready event
13448 */
13449 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13450 sizeof(wmi_abi_version));
13451}
13452
Sathish Kumarfd347372017-02-13 12:29:09 +053013453static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053013454{
13455 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13456 wmi_service_ready_event_fixed_param *ev;
13457
13458
13459 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13460
13461 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13462 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053013463 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013464
13465 /*Save fw version from service ready message */
13466 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053013467 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013468 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013469
Govind Singhb53420c2016-03-09 14:32:57 +053013470 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013471}
13472
13473/**
13474 * wmi_unified_save_fw_version_cmd() - save fw version
13475 * @wmi_handle: pointer to wmi handle
13476 * @res_cfg: resource config
13477 * @num_mem_chunks: no of mem chunck
13478 * @mem_chunk: pointer to mem chunck structure
13479 *
13480 * This function sends IE information to firmware
13481 *
Govind Singhb53420c2016-03-09 14:32:57 +053013482 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053013483 *
13484 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013485static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053013486 void *evt_buf)
13487{
13488 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13489 wmi_ready_event_fixed_param *ev = NULL;
13490
13491 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13492 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013493 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
13494 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013495 &ev->fw_abi_vers)) {
13496 /*
13497 * Error: Our host version and the given firmware version
13498 * are incompatible.
13499 **/
Govind Singhb53420c2016-03-09 14:32:57 +053013500 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053013501 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
13502 __func__,
13503 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
13504 abi_version_0),
13505 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
13506 abi_version_0),
13507 wmi_handle->final_abi_vers.abi_version_ns_0,
13508 wmi_handle->final_abi_vers.abi_version_ns_1,
13509 wmi_handle->final_abi_vers.abi_version_ns_2,
13510 wmi_handle->final_abi_vers.abi_version_ns_3,
13511 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
13512 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
13513 ev->fw_abi_vers.abi_version_ns_0,
13514 ev->fw_abi_vers.abi_version_ns_1,
13515 ev->fw_abi_vers.abi_version_ns_2,
13516 ev->fw_abi_vers.abi_version_ns_3);
13517
Govind Singhb53420c2016-03-09 14:32:57 +053013518 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013519 }
Govind Singhb53420c2016-03-09 14:32:57 +053013520 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013521 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053013522 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013523 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053013524
Govind Singhb53420c2016-03-09 14:32:57 +053013525 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013526}
Govind Singha4836fd2016-03-07 16:45:38 +053013527
13528/**
13529 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
13530 * @wmi_handle: wmi handle
13531 * @custom_addr: base mac address
13532 *
Govind Singhe7f2f342016-05-23 12:12:52 +053013533 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053013534 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013535static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013536 uint8_t *custom_addr)
13537{
13538 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
13539 wmi_buf_t buf;
13540 int err;
13541
13542 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13543 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013544 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053013545 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013546 }
13547
13548 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013549 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053013550
13551 WMITLV_SET_HDR(&cmd->tlv_header,
13552 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
13553 WMITLV_GET_STRUCT_TLVLEN
13554 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
13555 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013556 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13557 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013558 err = wmi_unified_cmd_send(wmi_handle, buf,
13559 sizeof(*cmd),
13560 WMI_PDEV_SET_BASE_MACADDR_CMDID);
13561 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053013562 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053013563 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013564 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013565 }
13566
13567 return 0;
13568}
13569
13570/**
13571 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
13572 * @handle: wmi handle
13573 * @event: Event received from FW
13574 * @len: Length of the event
13575 *
13576 * Enables the low frequency events and disables the high frequency
13577 * events. Bit 17 indicates if the event if low/high frequency.
13578 * 1 - high frequency, 0 - low frequency
13579 *
13580 * Return: 0 on successfully enabling/disabling the events
13581 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013582static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013583 uint8_t *event,
13584 uint32_t len)
13585{
13586 uint32_t num_of_diag_events_logs;
13587 wmi_diag_event_log_config_fixed_param *cmd;
13588 wmi_buf_t buf;
13589 uint8_t *buf_ptr;
13590 uint32_t *cmd_args, *evt_args;
13591 uint32_t buf_len, i;
13592
13593 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
13594 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
13595
Govind Singhb53420c2016-03-09 14:32:57 +053013596 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053013597
13598 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
13599 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013600 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053013601 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013602 }
13603 wmi_event = param_buf->fixed_param;
13604 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070013605
13606 if (num_of_diag_events_logs >
13607 param_buf->num_diag_events_logs_list) {
13608 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
13609 num_of_diag_events_logs,
13610 param_buf->num_diag_events_logs_list);
13611 return QDF_STATUS_E_INVAL;
13612 }
13613
Govind Singha4836fd2016-03-07 16:45:38 +053013614 evt_args = param_buf->diag_events_logs_list;
13615 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053013616 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013617 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053013618 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013619 }
13620
Govind Singhb53420c2016-03-09 14:32:57 +053013621 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013622 __func__, num_of_diag_events_logs);
13623
13624 /* Free any previous allocation */
13625 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053013626 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013627
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070013628 if (num_of_diag_events_logs >
13629 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
13630 WMI_LOGE("%s: excess num of logs:%d", __func__,
13631 num_of_diag_events_logs);
13632 QDF_ASSERT(0);
13633 return QDF_STATUS_E_INVAL;
13634 }
Govind Singha4836fd2016-03-07 16:45:38 +053013635 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053013636 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053013637 sizeof(uint32_t));
13638 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013639 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013640 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013641 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013642 }
13643 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
13644
13645 /* Prepare the send buffer */
13646 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13647 (num_of_diag_events_logs * sizeof(uint32_t));
13648
13649 buf = wmi_buf_alloc(wmi_handle, buf_len);
13650 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013651 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13652 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013653 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013654 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013655 }
13656
13657 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13658 buf_ptr = (uint8_t *) cmd;
13659
13660 WMITLV_SET_HDR(&cmd->tlv_header,
13661 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13662 WMITLV_GET_STRUCT_TLVLEN(
13663 wmi_diag_event_log_config_fixed_param));
13664
13665 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13666
13667 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13668
13669 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13670 (num_of_diag_events_logs * sizeof(uint32_t)));
13671
13672 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13673
13674 /* Populate the events */
13675 for (i = 0; i < num_of_diag_events_logs; i++) {
13676 /* Low freq (0) - Enable (1) the event
13677 * High freq (1) - Disable (0) the event
13678 */
13679 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13680 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13681 /* Set the event ID */
13682 WMI_DIAG_ID_SET(cmd_args[i],
13683 WMI_DIAG_ID_GET(evt_args[i]));
13684 /* Set the type */
13685 WMI_DIAG_TYPE_SET(cmd_args[i],
13686 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013687 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013688 wmi_handle->events_logs_list[i] = evt_args[i];
13689 }
13690
13691 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13692 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013693 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013694 __func__);
13695 wmi_buf_free(buf);
13696 /* Not clearing events_logs_list, though wmi cmd failed.
13697 * Host can still have this list
13698 */
Govind Singh67922e82016-04-01 16:48:57 +053013699 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013700 }
13701
13702 return 0;
13703}
13704
13705/**
13706 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13707 * @wmi_handle: wmi handle
13708 * @start_log: Start logging related parameters
13709 *
13710 * Send the command to the FW based on which specific logging of diag
13711 * event/log id can be started/stopped
13712 *
13713 * Return: None
13714 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013715static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013716 struct wmi_wifi_start_log *start_log)
13717{
13718 wmi_diag_event_log_config_fixed_param *cmd;
13719 wmi_buf_t buf;
13720 uint8_t *buf_ptr;
13721 uint32_t len, count, log_level, i;
13722 uint32_t *cmd_args;
13723 uint32_t total_len;
13724 count = 0;
13725
13726 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013727 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013728 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013729 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013730 }
13731 /* total_len stores the number of events where BITS 17 and 18 are set.
13732 * i.e., events of high frequency (17) and for extended debugging (18)
13733 */
13734 total_len = 0;
13735 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13736 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13737 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13738 total_len++;
13739 }
13740
13741 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13742 (total_len * sizeof(uint32_t));
13743
13744 buf = wmi_buf_alloc(wmi_handle, len);
13745 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013746 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013747 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013748 }
13749 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13750 buf_ptr = (uint8_t *) cmd;
13751
13752 WMITLV_SET_HDR(&cmd->tlv_header,
13753 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13754 WMITLV_GET_STRUCT_TLVLEN(
13755 wmi_diag_event_log_config_fixed_param));
13756
13757 cmd->num_of_diag_events_logs = total_len;
13758
13759 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13760
13761 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13762 (total_len * sizeof(uint32_t)));
13763
13764 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13765
Govind Singh224a7312016-06-21 14:33:26 +053013766 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013767 log_level = 1;
13768 else
13769 log_level = 0;
13770
Govind Singhb53420c2016-03-09 14:32:57 +053013771 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013772 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13773 uint32_t val = wmi_handle->events_logs_list[i];
13774 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13775 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13776
13777 WMI_DIAG_ID_SET(cmd_args[count],
13778 WMI_DIAG_ID_GET(val));
13779 WMI_DIAG_TYPE_SET(cmd_args[count],
13780 WMI_DIAG_TYPE_GET(val));
13781 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13782 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013783 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013784 count++;
13785 }
13786 }
13787
13788 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13789 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013790 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013791 __func__);
13792 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013793 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013794 }
13795
Govind Singhb53420c2016-03-09 14:32:57 +053013796 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013797}
13798
13799/**
13800 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13801 * @wmi_handle: WMI handle
13802 *
13803 * This function is used to send the flush command to the FW,
13804 * that will flush the fw logs that are residue in the FW
13805 *
13806 * Return: None
13807 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013808static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013809{
13810 wmi_debug_mesg_flush_fixed_param *cmd;
13811 wmi_buf_t buf;
13812 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013813 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013814
13815 buf = wmi_buf_alloc(wmi_handle, len);
13816 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013817 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013818 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013819 }
13820
13821 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13822 WMITLV_SET_HDR(&cmd->tlv_header,
13823 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13824 WMITLV_GET_STRUCT_TLVLEN(
13825 wmi_debug_mesg_flush_fixed_param));
13826 cmd->reserved0 = 0;
13827
13828 ret = wmi_unified_cmd_send(wmi_handle,
13829 buf,
13830 len,
13831 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013832 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013833 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013834 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013835 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013836 }
Govind Singhb53420c2016-03-09 14:32:57 +053013837 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013838
Govind Singh67922e82016-04-01 16:48:57 +053013839 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013840}
13841
13842/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013843 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013844 * @wmi_handle: wmi handle
13845 * @msg: PCL structure containing the PCL and the number of channels
13846 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013847 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013848 * firmware. The DBS Manager is the consumer of this information in the WLAN
13849 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13850 * to migrate to a new channel without host driver involvement. An example of
13851 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13852 * manage the channel selection without firmware involvement.
13853 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013854 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13855 * channel list. The weights corresponds to the channels sent in
13856 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13857 * weightage compared to the non PCL channels.
13858 *
Govind Singha4836fd2016-03-07 16:45:38 +053013859 * Return: Success if the cmd is sent successfully to the firmware
13860 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013861static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013862 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013863{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013864 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013865 wmi_buf_t buf;
13866 uint8_t *buf_ptr;
13867 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013868 uint32_t chan_len;
13869
13870 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013871
13872 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013873 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013874
13875 buf = wmi_buf_alloc(wmi_handle, len);
13876 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013877 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13878 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013879 }
13880
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013881 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013882 buf_ptr = (uint8_t *) cmd;
13883 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013884 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13885 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013886
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013887 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13888 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013889 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013890 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013891
13892 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013893 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013894 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013895 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013896 for (i = 0; i < chan_len ; i++) {
13897 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013898 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013899 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013900 }
13901 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013902 WMI_PDEV_SET_PCL_CMDID)) {
13903 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013904 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013905 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013906 }
Govind Singhb53420c2016-03-09 14:32:57 +053013907 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013908}
13909
13910/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013911 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013912 * @wmi_handle: wmi handle
13913 * @msg: Structure containing the following parameters
13914 *
13915 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13916 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13917 *
13918 * Provides notification to the WLAN firmware that host driver is requesting a
13919 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13920 * configurations that include the Dual Band Simultaneous (DBS) feature.
13921 *
13922 * Return: Success if the cmd is sent successfully to the firmware
13923 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013924static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013925 uint32_t hw_mode_index)
13926{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013927 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013928 wmi_buf_t buf;
13929 uint32_t len;
13930
13931 len = sizeof(*cmd);
13932
13933 buf = wmi_buf_alloc(wmi_handle, len);
13934 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013935 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13936 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013937 }
13938
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013939 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013940 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013941 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13942 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13943
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013944 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13945 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013946 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013947 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013948
13949 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013950 WMI_PDEV_SET_HW_MODE_CMDID)) {
13951 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013952 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013953 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013954 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013955 }
13956
Govind Singhb53420c2016-03-09 14:32:57 +053013957 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013958}
13959
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013960#ifdef WLAN_POLICY_MGR_ENABLE
Govind Singha4836fd2016-03-07 16:45:38 +053013961/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013962 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013963 * @wmi_handle: wmi handle
13964 * @msg: Dual MAC config parameters
13965 *
13966 * Configures WLAN firmware with the dual MAC features
13967 *
Govind Singhb53420c2016-03-09 14:32:57 +053013968 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013969 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013970static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013971QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013972 struct policy_mgr_dual_mac_config *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013973{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013974 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013975 wmi_buf_t buf;
13976 uint32_t len;
13977
13978 len = sizeof(*cmd);
13979
13980 buf = wmi_buf_alloc(wmi_handle, len);
13981 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013982 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13983 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013984 }
13985
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013986 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013987 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013988 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013989 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013990 wmi_pdev_set_mac_config_cmd_fixed_param));
13991
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013992 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13993 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013994 cmd->concurrent_scan_config_bits = msg->scan_config;
13995 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013996 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013997 __func__, msg->scan_config, msg->fw_mode_config);
13998
13999 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053014000 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
14001 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053014002 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014003 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014004 }
Govind Singhb53420c2016-03-09 14:32:57 +053014005 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014006}
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080014007#endif
Govind Singha4836fd2016-03-07 16:45:38 +053014008
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014009#ifdef BIG_ENDIAN_HOST
14010/**
14011* fips_conv_data_be() - LE to BE conversion of FIPS ev data
14012* @param data_len - data length
14013* @param data - pointer to data
14014*
14015* Return: QDF_STATUS - success or error status
14016*/
14017static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14018 struct fips_params *param)
14019{
14020 unsigned char *key_unaligned, *data_unaligned;
14021 int c;
14022 u_int8_t *key_aligned = NULL;
14023 u_int8_t *data_aligned = NULL;
14024
14025 /* Assigning unaligned space to copy the key */
14026 key_unaligned = qdf_mem_malloc(
14027 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
14028 data_unaligned = qdf_mem_malloc(
14029 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
14030
Jeff Johnsonda263992018-05-12 14:22:00 -070014031 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014032 if (key_unaligned == NULL)
14033 return QDF_STATUS_SUCCESS;
14034 /* Checking if space is aligned */
14035 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
14036 /* align to 4 */
14037 key_aligned =
14038 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
14039 FIPS_ALIGN);
14040 } else {
14041 key_aligned = (u_int8_t *)key_unaligned;
14042 }
14043
14044 /* memset and copy content from key to key aligned */
14045 OS_MEMSET(key_aligned, 0, param->key_len);
14046 OS_MEMCPY(key_aligned, param->key, param->key_len);
14047
14048 /* print a hexdump for host debug */
14049 print_hex_dump(KERN_DEBUG,
14050 "\t Aligned and Copied Key:@@@@ ",
14051 DUMP_PREFIX_NONE,
14052 16, 1, key_aligned, param->key_len, true);
14053
Jeff Johnsonda263992018-05-12 14:22:00 -070014054 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014055 if (data_unaligned == NULL)
14056 return QDF_STATUS_SUCCESS;
14057 /* Checking of space is aligned */
14058 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
14059 /* align to 4 */
14060 data_aligned =
14061 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
14062 FIPS_ALIGN);
14063 } else {
14064 data_aligned = (u_int8_t *)data_unaligned;
14065 }
14066
14067 /* memset and copy content from data to data aligned */
14068 OS_MEMSET(data_aligned, 0, param->data_len);
14069 OS_MEMCPY(data_aligned, param->data, param->data_len);
14070
14071 /* print a hexdump for host debug */
14072 print_hex_dump(KERN_DEBUG,
14073 "\t Properly Aligned and Copied Data:@@@@ ",
14074 DUMP_PREFIX_NONE,
14075 16, 1, data_aligned, param->data_len, true);
14076
14077 /* converting to little Endian both key_aligned and
14078 * data_aligned*/
14079 for (c = 0; c < param->key_len/4; c++) {
14080 *((u_int32_t *)key_aligned+c) =
14081 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
14082 }
14083 for (c = 0; c < param->data_len/4; c++) {
14084 *((u_int32_t *)data_aligned+c) =
14085 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
14086 }
14087
14088 /* update endian data to key and data vectors */
14089 OS_MEMCPY(param->key, key_aligned, param->key_len);
14090 OS_MEMCPY(param->data, data_aligned, param->data_len);
14091
14092 /* clean up allocated spaces */
14093 qdf_mem_free(key_unaligned);
14094 key_unaligned = NULL;
14095 key_aligned = NULL;
14096
14097 qdf_mem_free(data_unaligned);
14098 data_unaligned = NULL;
14099 data_aligned = NULL;
14100
14101 return QDF_STATUS_SUCCESS;
14102}
14103#else
14104/**
14105* fips_align_data_be() - DUMMY for LE platform
14106*
14107* Return: QDF_STATUS - success
14108*/
14109static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14110 struct fips_params *param)
14111{
14112 return QDF_STATUS_SUCCESS;
14113}
14114#endif
14115
14116
14117/**
14118 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
14119 * @wmi_handle: wmi handle
14120 * @param: pointer to hold pdev fips param
14121 *
14122 * Return: 0 for success or error code
14123 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014124static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014125send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
14126 struct fips_params *param)
14127{
14128 wmi_pdev_fips_cmd_fixed_param *cmd;
14129 wmi_buf_t buf;
14130 uint8_t *buf_ptr;
14131 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
14132 QDF_STATUS retval = QDF_STATUS_SUCCESS;
14133
14134 /* Length TLV placeholder for array of bytes */
14135 len += WMI_TLV_HDR_SIZE;
14136 if (param->data_len)
14137 len += (param->data_len*sizeof(uint8_t));
14138
14139 /*
14140 * Data length must be multiples of 16 bytes - checked against 0xF -
14141 * and must be less than WMI_SVC_MSG_SIZE - static size of
14142 * wmi_pdev_fips_cmd structure
14143 */
14144
14145 /* do sanity on the input */
14146 if (!(((param->data_len & 0xF) == 0) &&
14147 ((param->data_len > 0) &&
14148 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
14149 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
14150 return QDF_STATUS_E_INVAL;
14151 }
14152
14153 buf = wmi_buf_alloc(wmi_handle, len);
14154 if (!buf) {
14155 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
14156 return QDF_STATUS_E_FAILURE;
14157 }
14158
14159 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14160 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
14161 WMITLV_SET_HDR(&cmd->tlv_header,
14162 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
14163 WMITLV_GET_STRUCT_TLVLEN
14164 (wmi_pdev_fips_cmd_fixed_param));
14165
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014166 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14167 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014168 if (param->key != NULL && param->data != NULL) {
14169 cmd->key_len = param->key_len;
14170 cmd->data_len = param->data_len;
14171 cmd->fips_cmd = !!(param->op);
14172
14173 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
14174 return QDF_STATUS_E_FAILURE;
14175
14176 qdf_mem_copy(cmd->key, param->key, param->key_len);
14177
14178 if (param->mode == FIPS_ENGINE_AES_CTR ||
14179 param->mode == FIPS_ENGINE_AES_MIC) {
14180 cmd->mode = param->mode;
14181 } else {
14182 cmd->mode = FIPS_ENGINE_AES_CTR;
14183 }
14184 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
14185 cmd->key_len, cmd->data_len);
14186
14187 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
14188 cmd->key, cmd->key_len, true);
14189 buf_ptr += sizeof(*cmd);
14190
14191 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
14192
14193 buf_ptr += WMI_TLV_HDR_SIZE;
14194 if (param->data_len)
14195 qdf_mem_copy(buf_ptr,
14196 (uint8_t *) param->data, param->data_len);
14197
14198 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
14199 16, 1, buf_ptr, cmd->data_len, true);
14200
14201 buf_ptr += param->data_len;
14202
14203 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
14204 WMI_PDEV_FIPS_CMDID);
14205 qdf_print("%s return value %d\n", __func__, retval);
14206 } else {
14207 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
14208 wmi_buf_free(buf);
14209 retval = -QDF_STATUS_E_BADMSG;
14210 }
14211
14212 return retval;
14213}
14214
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014215#ifdef WLAN_PMO_ENABLE
14216/**
14217 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
14218 * @wmi_handle: wmi handle
14219 * @vdev_id: vdev id
14220 * @bitmap: Event bitmap
14221 * @enable: enable/disable
14222 *
14223 * Return: CDF status
14224 */
14225static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
14226 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014227 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014228 bool enable)
14229{
14230 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
14231 uint16_t len;
14232 wmi_buf_t buf;
14233 int ret;
14234
14235 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
14236 buf = wmi_buf_alloc(wmi_handle, len);
14237 if (!buf) {
14238 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14239 return QDF_STATUS_E_NOMEM;
14240 }
14241 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
14242 WMITLV_SET_HDR(&cmd->tlv_header,
14243 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
14244 WMITLV_GET_STRUCT_TLVLEN
14245 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
14246 cmd->vdev_id = vdev_id;
14247 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014248 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
14249 WMI_WOW_MAX_EVENT_BM_LEN);
14250
14251 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
14252 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
14253 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014254
14255 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14256 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
14257 if (ret) {
14258 WMI_LOGE("Failed to config wow wakeup event");
14259 wmi_buf_free(buf);
14260 return QDF_STATUS_E_FAILURE;
14261 }
14262
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014263 return QDF_STATUS_SUCCESS;
14264}
14265
14266/**
14267 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
14268 * @wmi_handle: wmi handle
14269 * @vdev_id: vdev id
14270 * @ptrn_id: pattern id
14271 * @ptrn: pattern
14272 * @ptrn_len: pattern length
14273 * @ptrn_offset: pattern offset
14274 * @mask: mask
14275 * @mask_len: mask length
14276 * @user: true for user configured pattern and false for default pattern
14277 * @default_patterns: default patterns
14278 *
14279 * Return: CDF status
14280 */
14281static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
14282 uint8_t vdev_id, uint8_t ptrn_id,
14283 const uint8_t *ptrn, uint8_t ptrn_len,
14284 uint8_t ptrn_offset, const uint8_t *mask,
14285 uint8_t mask_len, bool user,
14286 uint8_t default_patterns)
14287{
14288 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14289 WOW_BITMAP_PATTERN_T *bitmap_pattern;
14290 wmi_buf_t buf;
14291 uint8_t *buf_ptr;
14292 int32_t len;
14293 int ret;
14294
14295 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14296 WMI_TLV_HDR_SIZE +
14297 1 * sizeof(WOW_BITMAP_PATTERN_T) +
14298 WMI_TLV_HDR_SIZE +
14299 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14300 WMI_TLV_HDR_SIZE +
14301 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14302 WMI_TLV_HDR_SIZE +
14303 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14304 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014305 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014306
14307 buf = wmi_buf_alloc(wmi_handle, len);
14308 if (!buf) {
14309 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14310 return QDF_STATUS_E_NOMEM;
14311 }
14312
14313 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14314 buf_ptr = (uint8_t *) cmd;
14315
14316 WMITLV_SET_HDR(&cmd->tlv_header,
14317 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14318 WMITLV_GET_STRUCT_TLVLEN
14319 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14320 cmd->vdev_id = vdev_id;
14321 cmd->pattern_id = ptrn_id;
14322
14323 cmd->pattern_type = WOW_BITMAP_PATTERN;
14324 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14325
14326 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14327 sizeof(WOW_BITMAP_PATTERN_T));
14328 buf_ptr += WMI_TLV_HDR_SIZE;
14329 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
14330
14331 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
14332 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
14333 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
14334
14335 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
14336 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
14337
14338 bitmap_pattern->pattern_offset = ptrn_offset;
14339 bitmap_pattern->pattern_len = ptrn_len;
14340
14341 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
14342 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
14343
14344 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
14345 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
14346
14347 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
14348 bitmap_pattern->pattern_id = ptrn_id;
14349
14350 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
14351 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
14352 bitmap_pattern->pattern_offset, user);
14353 WMI_LOGI("Pattern : ");
14354 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14355 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
14356
14357 WMI_LOGI("Mask : ");
14358 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14359 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
14360
14361 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
14362
14363 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14364 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14365 buf_ptr += WMI_TLV_HDR_SIZE;
14366
14367 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14368 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14369 buf_ptr += WMI_TLV_HDR_SIZE;
14370
14371 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14372 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14373 buf_ptr += WMI_TLV_HDR_SIZE;
14374
14375 /* Fill TLV for pattern_info_timeout but no data. */
14376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14377 buf_ptr += WMI_TLV_HDR_SIZE;
14378
14379 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053014380 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014381 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053014382 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014383
14384 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14385 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14386 if (ret) {
14387 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
14388 wmi_buf_free(buf);
14389 return QDF_STATUS_E_FAILURE;
14390 }
14391
14392 return QDF_STATUS_SUCCESS;
14393}
14394
Govind Singha4836fd2016-03-07 16:45:38 +053014395/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014396 * fill_arp_offload_params_tlv() - Fill ARP offload data
14397 * @wmi_handle: wmi handle
14398 * @offload_req: offload request
14399 * @buf_ptr: buffer pointer
14400 *
14401 * To fill ARP offload data to firmware
14402 * when target goes to wow mode.
14403 *
14404 * Return: None
14405 */
14406static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014407 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014408{
14409
14410 int i;
14411 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014412 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014413
14414 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14415 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
14416 *buf_ptr += WMI_TLV_HDR_SIZE;
14417 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
14418 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
14419 WMITLV_SET_HDR(&arp_tuple->tlv_header,
14420 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
14421 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
14422
14423 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014424 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014425 /* Copy the target ip addr and flags */
14426 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
14427 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014428 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014429 WMI_IPV4_ADDR_LEN);
14430 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014431 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014432 }
14433 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
14434 }
14435}
14436
14437#ifdef WLAN_NS_OFFLOAD
14438/**
14439 * fill_ns_offload_params_tlv() - Fill NS offload data
14440 * @wmi|_handle: wmi handle
14441 * @offload_req: offload request
14442 * @buf_ptr: buffer pointer
14443 *
14444 * To fill NS offload data to firmware
14445 * when target goes to wow mode.
14446 *
14447 * Return: None
14448 */
14449static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014450 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014451{
14452
14453 int i;
14454 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014455
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014456 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14457 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14458 *buf_ptr += WMI_TLV_HDR_SIZE;
14459 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
14460 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14461 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14462 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14463 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
14464
14465 /*
14466 * Fill data only for NS offload in the first ARP tuple for LA
14467 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014468 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014469 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14470 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014471 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014472 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014473 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014474 sizeof(WMI_IPV6_ADDR));
14475 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014476 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014477 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014478 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014479 ns_tuple->flags |=
14480 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14481 }
14482 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014483 i, &ns_req->self_ipv6_addr[i],
14484 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014485
14486 /* target MAC is optional, check if it is valid,
14487 * if this is not valid, the target will use the known
14488 * local MAC address rather than the tuple
14489 */
14490 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014491 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014492 &ns_tuple->target_mac);
14493 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14494 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14495 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14496 }
14497 }
14498 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14499 }
14500}
14501
14502
14503/**
14504 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
14505 * @wmi: wmi handle
14506 * @offload_req: offload request
14507 * @buf_ptr: buffer pointer
14508 *
14509 * To fill extended NS offload extended data to firmware
14510 * when target goes to wow mode.
14511 *
14512 * Return: None
14513 */
14514static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014515 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014516{
14517 int i;
14518 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
14519 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014520
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014521 count = ns_req->num_ns_offload_count;
14522 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014523 WMI_MAX_NS_OFFLOADS;
14524
14525 /* Populate extended NS offload tuples */
14526 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14527 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14528 *buf_ptr += WMI_TLV_HDR_SIZE;
14529 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
14530 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14531 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14532 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14533 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
14534
14535 /*
14536 * Fill data only for NS offload in the first ARP tuple for LA
14537 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014538 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014539 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14540 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014541 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014542 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014543 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014544 sizeof(WMI_IPV6_ADDR));
14545 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014546 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014547 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014548 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014549 ns_tuple->flags |=
14550 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14551 }
14552 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014553 i, &ns_req->self_ipv6_addr[i],
14554 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014555
14556 /* target MAC is optional, check if it is valid,
14557 * if this is not valid, the target will use the
14558 * known local MAC address rather than the tuple
14559 */
14560 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014561 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014562 &ns_tuple->target_mac);
14563 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14564 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14565 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14566 }
14567 }
14568 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14569 }
14570}
14571#else
14572static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014573 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014574{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014575}
14576
14577static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014578 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014579{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014580}
14581#endif
14582
14583/**
Govind Singha4836fd2016-03-07 16:45:38 +053014584 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
14585 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014586 * @arp_offload_req: arp offload request
14587 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053014588 * @arp_only: flag
14589 *
14590 * To configure ARP NS off load data to firmware
14591 * when target goes to wow mode.
14592 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014593 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053014594 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014595static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014596 struct pmo_arp_offload_params *arp_offload_req,
14597 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053014598 uint8_t vdev_id)
14599{
Govind Singha4836fd2016-03-07 16:45:38 +053014600 int32_t res;
14601 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053014602 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053014603 wmi_buf_t buf;
14604 int32_t len;
14605 uint32_t count = 0, num_ns_ext_tuples = 0;
14606
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014607 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053014608
Govind Singha4836fd2016-03-07 16:45:38 +053014609 /*
14610 * TLV place holder size for array of NS tuples
14611 * TLV place holder size for array of ARP tuples
14612 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014613 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
14614 WMI_TLV_HDR_SIZE +
14615 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
14616 WMI_TLV_HDR_SIZE +
14617 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014618
14619 /*
14620 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
14621 * extra length for extended NS offload tuples which follows ARP offload
14622 * tuples. Host needs to fill this structure in following format:
14623 * 2 NS ofload tuples
14624 * 2 ARP offload tuples
14625 * N numbers of extended NS offload tuples if HDD has given more than
14626 * 2 NS offload addresses
14627 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014628 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053014629 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014630 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
14631 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014632 }
14633
14634 buf = wmi_buf_alloc(wmi_handle, len);
14635 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014636 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014637 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014638 }
14639
Vivekc5823092018-03-22 23:27:21 +053014640 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014641 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
14642 WMITLV_SET_HDR(&cmd->tlv_header,
14643 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
14644 WMITLV_GET_STRUCT_TLVLEN
14645 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
14646 cmd->flags = 0;
14647 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014648 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053014649
Govind Singhb53420c2016-03-09 14:32:57 +053014650 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053014651
Govind Singha4836fd2016-03-07 16:45:38 +053014652 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014653 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
14654 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14655 if (num_ns_ext_tuples)
14656 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014657
14658 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14659 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14660 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014661 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014662 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014663 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014664 }
14665
Govind Singhb53420c2016-03-09 14:32:57 +053014666 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014667}
14668
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014669/**
14670 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14671 * @wmi_handle: wmi handle
14672 * @vdev_id: vdev id
14673 * @action: true for enable else false
14674 *
14675 * To enable enhance multicast offload to firmware
14676 * when target goes to wow mode.
14677 *
14678 * Return: QDF Status
14679 */
14680
14681static
14682QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14683 wmi_unified_t wmi_handle,
14684 uint8_t vdev_id, bool action)
14685{
14686 QDF_STATUS status;
14687 wmi_buf_t buf;
14688 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14689
14690 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14691 if (!buf) {
14692 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14693 return QDF_STATUS_E_NOMEM;
14694 }
14695
14696 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14697 wmi_buf_data(buf);
14698
14699 WMITLV_SET_HDR(&cmd->tlv_header,
14700 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14701 WMITLV_GET_STRUCT_TLVLEN(
14702 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14703
14704 cmd->vdev_id = vdev_id;
14705 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14706 ENHANCED_MCAST_FILTER_ENABLED);
14707 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14708 __func__, action, vdev_id);
14709 status = wmi_unified_cmd_send(wmi_handle, buf,
14710 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14711 if (status != QDF_STATUS_SUCCESS) {
14712 qdf_nbuf_free(buf);
14713 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14714 __func__);
14715 }
14716
14717 return status;
14718}
14719
14720/**
14721 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14722 * @wmi_handle: wmi handle
14723 * @param evt_buf: pointer to event buffer
14724 * @param hdr: Pointer to hold header
14725 * @param bufp: Pointer to hold pointer to rx param buffer
14726 *
14727 * Return: QDF_STATUS_SUCCESS for success or error code
14728 */
14729static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14730 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14731{
14732 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14733 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14734
14735 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14736 if (!param_buf) {
14737 WMI_LOGE("gtk param_buf is NULL");
14738 return QDF_STATUS_E_INVAL;
14739 }
14740
14741 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14742 WMI_LOGE("Invalid length for GTK status");
14743 return QDF_STATUS_E_INVAL;
14744 }
14745
14746 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14747 param_buf->fixed_param;
14748 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14749 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14750 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14751 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14752 &fixed_param->replay_counter,
14753 GTK_REPLAY_COUNTER_BYTES);
14754
14755 return QDF_STATUS_SUCCESS;
14756
14757}
14758
14759#ifdef FEATURE_WLAN_RA_FILTERING
14760/**
14761 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14762 * @wmi_handle: wmi handle
14763 * @vdev_id: vdev id
14764 *
14765 * Return: CDF status
14766 */
14767static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14768 uint8_t vdev_id, uint8_t default_pattern,
14769 uint16_t rate_limit_interval)
14770{
14771
14772 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14773 wmi_buf_t buf;
14774 uint8_t *buf_ptr;
14775 int32_t len;
14776 int ret;
14777
14778 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14779 WMI_TLV_HDR_SIZE +
14780 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14781 WMI_TLV_HDR_SIZE +
14782 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14783 WMI_TLV_HDR_SIZE +
14784 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14785 WMI_TLV_HDR_SIZE +
14786 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14787 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014788 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014789
14790 buf = wmi_buf_alloc(wmi_handle, len);
14791 if (!buf) {
14792 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14793 return QDF_STATUS_E_NOMEM;
14794 }
14795
14796 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14797 buf_ptr = (uint8_t *) cmd;
14798
14799 WMITLV_SET_HDR(&cmd->tlv_header,
14800 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14801 WMITLV_GET_STRUCT_TLVLEN
14802 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14803 cmd->vdev_id = vdev_id;
14804 cmd->pattern_id = default_pattern,
14805 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14806 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14807
14808 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14809 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14810 buf_ptr += WMI_TLV_HDR_SIZE;
14811
14812 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14813 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14814 buf_ptr += WMI_TLV_HDR_SIZE;
14815
14816 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14817 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14818 buf_ptr += WMI_TLV_HDR_SIZE;
14819
14820 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14821 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14822 buf_ptr += WMI_TLV_HDR_SIZE;
14823
14824 /* Fill TLV for pattern_info_timeout but no data. */
14825 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14826 buf_ptr += WMI_TLV_HDR_SIZE;
14827
14828 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014829 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014830 buf_ptr += WMI_TLV_HDR_SIZE;
14831
Vivekc5823092018-03-22 23:27:21 +053014832 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014833
14834 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14835 rate_limit_interval, vdev_id);
14836
14837 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14838 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14839 if (ret) {
14840 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14841 wmi_buf_free(buf);
14842 return QDF_STATUS_E_FAILURE;
14843 }
14844
14845 return QDF_STATUS_SUCCESS;
14846
14847}
14848#endif /* FEATURE_WLAN_RA_FILTERING */
14849
14850/**
14851 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14852 * @wmi_handle: wmi handle
14853 * @vdev_id: vdev id
14854 * @multicastAddr: mcast address
14855 * @clearList: clear list flag
14856 *
14857 * Return: QDF_STATUS_SUCCESS for success or error code
14858 */
14859static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14860 uint8_t vdev_id,
14861 struct qdf_mac_addr multicast_addr,
14862 bool clearList)
14863{
14864 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14865 wmi_buf_t buf;
14866 int err;
14867
14868 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14869 if (!buf) {
14870 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14871 return QDF_STATUS_E_NOMEM;
14872 }
14873
14874 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14875 qdf_mem_zero(cmd, sizeof(*cmd));
14876
14877 WMITLV_SET_HDR(&cmd->tlv_header,
14878 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14879 WMITLV_GET_STRUCT_TLVLEN
14880 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14881 cmd->action =
14882 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14883 cmd->vdev_id = vdev_id;
14884 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14885
14886 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14887 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14888
14889 err = wmi_unified_cmd_send(wmi_handle, buf,
14890 sizeof(*cmd),
14891 WMI_SET_MCASTBCAST_FILTER_CMDID);
14892 if (err) {
14893 WMI_LOGE("Failed to send set_param cmd");
14894 wmi_buf_free(buf);
14895 return QDF_STATUS_E_FAILURE;
14896 }
14897
14898 return QDF_STATUS_SUCCESS;
14899}
14900
14901/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014902 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14903 * command to fw
14904 * @wmi_handle: wmi handle
14905 * @vdev_id: vdev id
14906 * @mcast_filter_params: mcast filter params
14907 *
14908 * Return: QDF_STATUS_SUCCESS for success or error code
14909 */
14910static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14911 wmi_unified_t wmi_handle,
14912 uint8_t vdev_id,
14913 struct pmo_mcast_filter_params *filter_param)
14914
14915{
14916 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14917 uint8_t *buf_ptr;
14918 wmi_buf_t buf;
14919 int err;
14920 int i;
14921 uint8_t *mac_addr_src_ptr = NULL;
14922 wmi_mac_addr *mac_addr_dst_ptr;
14923 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14924 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14925
14926 buf = wmi_buf_alloc(wmi_handle, len);
14927 if (!buf) {
14928 WMI_LOGE("Failed to allocate memory");
14929 return QDF_STATUS_E_NOMEM;
14930 }
14931
Vivekc5823092018-03-22 23:27:21 +053014932 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014933 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14934 wmi_buf_data(buf);
14935 qdf_mem_zero(cmd, sizeof(*cmd));
14936
14937 WMITLV_SET_HDR(&cmd->tlv_header,
14938 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14939 WMITLV_GET_STRUCT_TLVLEN
14940 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14941 cmd->operation =
14942 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14943 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14944 cmd->vdev_id = vdev_id;
14945 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14946
14947 buf_ptr += sizeof(*cmd);
14948 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14949 sizeof(wmi_mac_addr) *
14950 filter_param->multicast_addr_cnt);
14951
14952 if (filter_param->multicast_addr_cnt == 0)
14953 goto send_cmd;
14954
14955 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14956 mac_addr_dst_ptr = (wmi_mac_addr *)
14957 (buf_ptr + WMI_TLV_HDR_SIZE);
14958
14959 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14960 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14961 mac_addr_src_ptr += ATH_MAC_LEN;
14962 mac_addr_dst_ptr++;
14963 }
14964
14965send_cmd:
14966 err = wmi_unified_cmd_send(wmi_handle, buf,
14967 len,
14968 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14969 if (err) {
14970 WMI_LOGE("Failed to send set_param cmd");
14971 wmi_buf_free(buf);
14972 return QDF_STATUS_E_FAILURE;
14973 }
14974
14975 return QDF_STATUS_SUCCESS;
14976}
14977
14978
14979/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014980 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14981 * @wmi_handle: wmi handle
14982 * @vdev_id: vdev id
14983 * @params: GTK offload parameters
14984 *
14985 * Return: CDF status
14986 */
14987static
14988QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14989 struct pmo_gtk_req *params,
14990 bool enable_offload,
14991 uint32_t gtk_offload_opcode)
14992{
14993 int len;
14994 wmi_buf_t buf;
14995 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014996 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014997 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014998 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014999
15000 WMI_LOGD("%s Enter", __func__);
15001
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015002 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015003
15004 /* alloc wmi buffer */
15005 buf = wmi_buf_alloc(wmi_handle, len);
15006 if (!buf) {
15007 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
15008 status = QDF_STATUS_E_NOMEM;
15009 goto out;
15010 }
15011
15012 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015013 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015014 WMITLV_SET_HDR(&cmd->tlv_header,
15015 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15016 WMITLV_GET_STRUCT_TLVLEN
15017 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15018
15019 cmd->vdev_id = vdev_id;
15020
15021 /* Request target to enable GTK offload */
15022 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
15023 cmd->flags = gtk_offload_opcode;
15024
15025 /* Copy the keys and replay counter */
15026 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015027 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015028 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
15029 GTK_REPLAY_COUNTER_BYTES);
15030 } else {
15031 cmd->flags = gtk_offload_opcode;
15032 }
15033
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015034 buf_ptr += sizeof(*cmd);
15035 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
15036 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015037
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015038 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
15039 WMITLV_SET_HDR(&ext_param->tlv_header,
15040 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
15041 WMITLV_GET_STRUCT_TLVLEN(
15042 wmi_gtk_offload_fils_tlv_param));
15043 ext_param->vdev_id = vdev_id;
15044 ext_param->flags = cmd->flags;
15045 ext_param->kek_len = params->kek_len;
15046 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
15047 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
15048 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
15049 GTK_REPLAY_COUNTER_BYTES);
15050
15051 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 +053015052 /* send the wmi command */
15053 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15054 WMI_GTK_OFFLOAD_CMDID)) {
15055 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
15056 wmi_buf_free(buf);
15057 status = QDF_STATUS_E_FAILURE;
15058 }
15059
15060out:
15061 WMI_LOGD("%s Exit", __func__);
15062 return status;
15063}
15064
15065/**
15066 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
15067 * @wmi_handle: wmi handle
15068 * @params: GTK offload params
15069 *
15070 * Return: CDF status
15071 */
15072static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
15073 wmi_unified_t wmi_handle,
15074 uint8_t vdev_id,
15075 uint64_t offload_req_opcode)
15076{
15077 int len;
15078 wmi_buf_t buf;
15079 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
15080 QDF_STATUS status = QDF_STATUS_SUCCESS;
15081
15082 len = sizeof(*cmd);
15083
15084 /* alloc wmi buffer */
15085 buf = wmi_buf_alloc(wmi_handle, len);
15086 if (!buf) {
15087 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
15088 status = QDF_STATUS_E_NOMEM;
15089 goto out;
15090 }
15091
15092 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
15093 WMITLV_SET_HDR(&cmd->tlv_header,
15094 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15095 WMITLV_GET_STRUCT_TLVLEN
15096 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15097
15098 /* Request for GTK offload status */
15099 cmd->flags = offload_req_opcode;
15100 cmd->vdev_id = vdev_id;
15101
15102 /* send the wmi command */
15103 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15104 WMI_GTK_OFFLOAD_CMDID)) {
15105 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
15106 wmi_buf_free(buf);
15107 status = QDF_STATUS_E_FAILURE;
15108 }
15109
15110out:
15111 return status;
15112}
15113
15114/**
15115 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
15116 * @wmi_handle: wmi handler
15117 * @action_params: pointer to action_params
15118 *
15119 * Return: 0 for success, otherwise appropriate error code
15120 */
15121static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
15122 struct pmo_action_wakeup_set_params *action_params)
15123{
15124 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
15125 wmi_buf_t buf;
15126 int i;
15127 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015128 uint32_t len = 0, *cmd_args;
15129 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015130
Vivekc5823092018-03-22 23:27:21 +053015131 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015132 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
15133 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015134 if (!buf) {
15135 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
15136 return QDF_STATUS_E_NOMEM;
15137 }
15138 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015139 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015140 WMITLV_SET_HDR(&cmd->tlv_header,
15141 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
15142 WMITLV_GET_STRUCT_TLVLEN(
15143 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
15144
15145 cmd->vdev_id = action_params->vdev_id;
15146 cmd->operation = action_params->operation;
15147
15148 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
15149 cmd->action_category_map[i] =
15150 action_params->action_category_map[i];
15151
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015152 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
15153 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015154 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015155 buf_ptr += WMI_TLV_HDR_SIZE;
15156 cmd_args = (uint32_t *) buf_ptr;
15157 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
15158 cmd_args[i] = action_params->action_per_category[i];
15159
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015160 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015161 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015162 if (err) {
15163 WMI_LOGE("Failed to send ap_ps_egap cmd");
15164 wmi_buf_free(buf);
15165 return QDF_STATUS_E_FAILURE;
15166 }
15167
15168 return QDF_STATUS_SUCCESS;
15169}
15170
15171#ifdef FEATURE_WLAN_LPHB
15172
15173/**
15174 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
15175 * @wmi_handle: wmi handle
15176 * @lphb_conf_req: configuration info
15177 *
15178 * Return: CDF status
15179 */
15180static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
15181 wmi_hb_set_enable_cmd_fixed_param *params)
15182{
15183 QDF_STATUS status;
15184 wmi_buf_t buf = NULL;
15185 uint8_t *buf_ptr;
15186 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
15187 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
15188
15189
15190 buf = wmi_buf_alloc(wmi_handle, len);
15191 if (!buf) {
15192 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15193 return QDF_STATUS_E_NOMEM;
15194 }
15195
15196 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15197 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
15198 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
15199 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
15200 WMITLV_GET_STRUCT_TLVLEN
15201 (wmi_hb_set_enable_cmd_fixed_param));
15202
15203 /* fill in values */
15204 hb_enable_fp->vdev_id = params->session;
15205 hb_enable_fp->enable = params->enable;
15206 hb_enable_fp->item = params->item;
15207 hb_enable_fp->session = params->session;
15208
15209 status = wmi_unified_cmd_send(wmi_handle, buf,
15210 len, WMI_HB_SET_ENABLE_CMDID);
15211 if (QDF_IS_STATUS_ERROR(status)) {
15212 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
15213 status);
15214 wmi_buf_free(buf);
15215 }
15216
15217 return status;
15218}
15219
15220/**
15221 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
15222 * @wmi_handle: wmi handle
15223 * @lphb_conf_req: lphb config request
15224 *
15225 * Return: CDF status
15226 */
15227static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
15228 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
15229{
15230 QDF_STATUS status;
15231 wmi_buf_t buf = NULL;
15232 uint8_t *buf_ptr;
15233 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
15234 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
15235
15236 buf = wmi_buf_alloc(wmi_handle, len);
15237 if (!buf) {
15238 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15239 return QDF_STATUS_E_NOMEM;
15240 }
15241
15242 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15243 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
15244 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
15245 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
15246 WMITLV_GET_STRUCT_TLVLEN
15247 (wmi_hb_set_tcp_params_cmd_fixed_param));
15248
15249 /* fill in values */
15250 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15251 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15252 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15253 hb_tcp_params_fp->seq = lphb_conf_req->seq;
15254 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
15255 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
15256 hb_tcp_params_fp->interval = lphb_conf_req->interval;
15257 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
15258 hb_tcp_params_fp->session = lphb_conf_req->session;
15259 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
15260 &lphb_conf_req->gateway_mac,
15261 sizeof(hb_tcp_params_fp->gateway_mac));
15262
15263 status = wmi_unified_cmd_send(wmi_handle, buf,
15264 len, WMI_HB_SET_TCP_PARAMS_CMDID);
15265 if (QDF_IS_STATUS_ERROR(status)) {
15266 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
15267 status);
15268 wmi_buf_free(buf);
15269 }
15270
15271 return status;
15272}
15273
15274/**
15275 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
15276 * @wmi_handle: wmi handle
15277 * @lphb_conf_req: lphb config request
15278 *
15279 * Return: CDF status
15280 */
15281static
15282QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15283 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
15284{
15285 QDF_STATUS status;
15286 wmi_buf_t buf = NULL;
15287 uint8_t *buf_ptr;
15288 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
15289 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
15290
15291 buf = wmi_buf_alloc(wmi_handle, len);
15292 if (!buf) {
15293 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15294 return QDF_STATUS_E_NOMEM;
15295 }
15296
15297 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15298 hb_tcp_filter_fp =
15299 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
15300 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
15301 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
15302 WMITLV_GET_STRUCT_TLVLEN
15303 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
15304
15305 /* fill in values */
15306 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
15307 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
15308 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
15309 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
15310 memcpy((void *)&hb_tcp_filter_fp->filter,
15311 (void *)&g_hb_tcp_filter_fp->filter,
15312 WMI_WLAN_HB_MAX_FILTER_SIZE);
15313
15314 status = wmi_unified_cmd_send(wmi_handle, buf,
15315 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
15316 if (QDF_IS_STATUS_ERROR(status)) {
15317 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
15318 status);
15319 wmi_buf_free(buf);
15320 }
15321
15322 return status;
15323}
15324
15325/**
15326 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
15327 * @wmi_handle: wmi handle
15328 * @lphb_conf_req: lphb config request
15329 *
15330 * Return: CDF status
15331 */
15332static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
15333 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
15334{
15335 QDF_STATUS status;
15336 wmi_buf_t buf = NULL;
15337 uint8_t *buf_ptr;
15338 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
15339 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
15340
15341 buf = wmi_buf_alloc(wmi_handle, len);
15342 if (!buf) {
15343 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15344 return QDF_STATUS_E_NOMEM;
15345 }
15346
15347 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15348 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
15349 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
15350 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
15351 WMITLV_GET_STRUCT_TLVLEN
15352 (wmi_hb_set_udp_params_cmd_fixed_param));
15353
15354 /* fill in values */
15355 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15356 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15357 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15358 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
15359 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
15360 hb_udp_params_fp->interval = lphb_conf_req->interval;
15361 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
15362 hb_udp_params_fp->session = lphb_conf_req->session;
15363 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
15364 &lphb_conf_req->gateway_mac,
15365 sizeof(lphb_conf_req->gateway_mac));
15366
15367 status = wmi_unified_cmd_send(wmi_handle, buf,
15368 len, WMI_HB_SET_UDP_PARAMS_CMDID);
15369 if (QDF_IS_STATUS_ERROR(status)) {
15370 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
15371 status);
15372 wmi_buf_free(buf);
15373 }
15374
15375 return status;
15376}
15377
15378/**
15379 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
15380 * @wmi_handle: wmi handle
15381 * @lphb_conf_req: lphb config request
15382 *
15383 * Return: CDF status
15384 */
15385static
15386QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15387 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
15388{
15389 QDF_STATUS status;
15390 wmi_buf_t buf = NULL;
15391 uint8_t *buf_ptr;
15392 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
15393 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
15394
15395 buf = wmi_buf_alloc(wmi_handle, len);
15396 if (!buf) {
15397 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15398 return QDF_STATUS_E_NOMEM;
15399 }
15400
15401 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15402 hb_udp_filter_fp =
15403 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
15404 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
15405 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
15406 WMITLV_GET_STRUCT_TLVLEN
15407 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
15408
15409 /* fill in values */
15410 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
15411 hb_udp_filter_fp->length = lphb_conf_req->length;
15412 hb_udp_filter_fp->offset = lphb_conf_req->offset;
15413 hb_udp_filter_fp->session = lphb_conf_req->session;
15414 memcpy((void *)&hb_udp_filter_fp->filter,
15415 (void *)&lphb_conf_req->filter,
15416 WMI_WLAN_HB_MAX_FILTER_SIZE);
15417
15418 status = wmi_unified_cmd_send(wmi_handle, buf,
15419 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
15420 if (QDF_IS_STATUS_ERROR(status)) {
15421 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
15422 status);
15423 wmi_buf_free(buf);
15424 }
15425
15426 return status;
15427}
15428#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015429
Dustin Brownf31f88b2017-05-12 14:01:44 -070015430static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
15431 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015432{
Dustin Brownf31f88b2017-05-12 14:01:44 -070015433 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015434 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070015435 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015436
Dustin Brownf31f88b2017-05-12 14:01:44 -070015437 if (!req) {
15438 WMI_LOGE("req is null");
15439 return QDF_STATUS_E_INVAL;
15440 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015441
Dustin Brownf31f88b2017-05-12 14:01:44 -070015442 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
15443 if (!wmi_buf) {
15444 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015445 return QDF_STATUS_E_NOMEM;
15446 }
15447
Dustin Brownf31f88b2017-05-12 14:01:44 -070015448 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015449 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070015450 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
15451 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
15452 cmd->vdev_id = req->vdev_id;
15453 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
15454 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015455
Dustin Brownf31f88b2017-05-12 14:01:44 -070015456 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
15457 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015458
Dustin Brownf31f88b2017-05-12 14:01:44 -070015459 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
15460 WMI_HW_DATA_FILTER_CMDID);
15461 if (QDF_IS_STATUS_ERROR(status)) {
15462 WMI_LOGE("Failed to configure hw filter");
15463 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015464 }
15465
Dustin Brownf31f88b2017-05-12 14:01:44 -070015466 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015467}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015468
15469/**
15470 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
15471 * @wmi_handle: wmi handle
15472 * @vdev_id: vdev id
15473 * @enable: Flag to enable/disable packet filter
15474 *
15475 * Return: QDF_STATUS_SUCCESS for success or error code
15476 */
15477static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
15478 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
15479{
15480 int32_t len;
15481 int ret = 0;
15482 wmi_buf_t buf;
15483 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
15484
15485 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
15486
15487 buf = wmi_buf_alloc(wmi_handle, len);
15488 if (!buf) {
15489 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
15490 return QDF_STATUS_E_NOMEM;
15491 }
15492
15493 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
15494 WMITLV_SET_HDR(&cmd->tlv_header,
15495 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
15496 WMITLV_GET_STRUCT_TLVLEN(
15497 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
15498
15499 cmd->vdev_id = vdev_id;
15500 if (enable)
15501 cmd->enable = PACKET_FILTER_SET_ENABLE;
15502 else
15503 cmd->enable = PACKET_FILTER_SET_DISABLE;
15504
15505 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
15506 __func__, cmd->enable, vdev_id);
15507
15508 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15509 WMI_PACKET_FILTER_ENABLE_CMDID);
15510 if (ret) {
15511 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
15512 wmi_buf_free(buf);
15513 }
15514
15515 return ret;
15516}
15517
15518/**
15519 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
15520 * @wmi_handle: wmi handle
15521 * @vdev_id: vdev id
15522 * @rcv_filter_param: Packet filter parameters
15523 * @filter_id: Filter id
15524 * @enable: Flag to add/delete packet filter configuration
15525 *
15526 * Return: QDF_STATUS_SUCCESS for success or error code
15527 */
15528static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
15529 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
15530 uint8_t filter_id, bool enable)
15531{
15532 int len, i;
15533 int err = 0;
15534 wmi_buf_t buf;
15535 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
15536
15537
15538 /* allocate the memory */
15539 len = sizeof(*cmd);
15540 buf = wmi_buf_alloc(wmi_handle, len);
15541 if (!buf) {
15542 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
15543 return QDF_STATUS_E_NOMEM;
15544 }
15545
15546 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
15547 WMITLV_SET_HDR(&cmd->tlv_header,
15548 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
15549 WMITLV_GET_STRUCT_TLVLEN
15550 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
15551
15552 cmd->vdev_id = vdev_id;
15553 cmd->filter_id = filter_id;
15554 if (enable)
15555 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
15556 else
15557 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
15558
15559 if (enable) {
15560 cmd->num_params = QDF_MIN(
15561 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
15562 rcv_filter_param->num_params);
15563 cmd->filter_type = rcv_filter_param->filter_type;
15564 cmd->coalesce_time = rcv_filter_param->coalesce_time;
15565
15566 for (i = 0; i < cmd->num_params; i++) {
15567 cmd->paramsData[i].proto_type =
15568 rcv_filter_param->params_data[i].protocol_layer;
15569 cmd->paramsData[i].cmp_type =
15570 rcv_filter_param->params_data[i].compare_flag;
15571 cmd->paramsData[i].data_length =
15572 rcv_filter_param->params_data[i].data_length;
15573 cmd->paramsData[i].data_offset =
15574 rcv_filter_param->params_data[i].data_offset;
15575 memcpy(&cmd->paramsData[i].compareData,
15576 rcv_filter_param->params_data[i].compare_data,
15577 sizeof(cmd->paramsData[i].compareData));
15578 memcpy(&cmd->paramsData[i].dataMask,
15579 rcv_filter_param->params_data[i].data_mask,
15580 sizeof(cmd->paramsData[i].dataMask));
15581 }
15582 }
15583
15584 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
15585 cmd->filter_action, cmd->filter_id, cmd->num_params);
15586 /* send the command along with data */
15587 err = wmi_unified_cmd_send(wmi_handle, buf, len,
15588 WMI_PACKET_FILTER_CONFIG_CMDID);
15589 if (err) {
15590 WMI_LOGE("Failed to send pkt_filter cmd");
15591 wmi_buf_free(buf);
15592 return QDF_STATUS_E_FAILURE;
15593 }
15594
15595 return QDF_STATUS_SUCCESS;
15596}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053015597#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015598
Govind Singha4836fd2016-03-07 16:45:38 +053015599/**
15600 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
15601 * @wmi_handle: wmi handle
15602 * @request: SSID hotlist set request
15603 *
Govind Singhb53420c2016-03-09 14:32:57 +053015604 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053015605 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015606static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053015607send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
15608 struct ssid_hotlist_request_params *request)
15609{
15610 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
15611 wmi_buf_t wmi_buf;
15612 uint32_t len;
15613 uint32_t array_size;
15614 uint8_t *buf_ptr;
15615
15616 /* length of fixed portion */
15617 len = sizeof(*cmd);
15618
15619 /* length of variable portion */
15620 array_size =
15621 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
15622 len += WMI_TLV_HDR_SIZE + array_size;
15623
15624 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15625 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015626 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15627 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015628 }
15629
15630 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
15631 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
15632 buf_ptr;
15633 WMITLV_SET_HDR
15634 (&cmd->tlv_header,
15635 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15636 WMITLV_GET_STRUCT_TLVLEN
15637 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15638
15639 cmd->request_id = request->request_id;
15640 cmd->requestor_id = 0;
15641 cmd->vdev_id = request->session_id;
15642 cmd->table_id = 0;
15643 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15644 cmd->total_entries = request->ssid_count;
15645 cmd->num_entries_in_page = request->ssid_count;
15646 cmd->first_entry_index = 0;
15647
15648 buf_ptr += sizeof(*cmd);
15649 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15650
15651 if (request->ssid_count) {
15652 wmi_extscan_hotlist_ssid_entry *entry;
15653 int i;
15654
15655 buf_ptr += WMI_TLV_HDR_SIZE;
15656 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15657 for (i = 0; i < request->ssid_count; i++) {
15658 WMITLV_SET_HDR
15659 (entry,
15660 WMITLV_TAG_ARRAY_STRUC,
15661 WMITLV_GET_STRUCT_TLVLEN
15662 (wmi_extscan_hotlist_ssid_entry));
15663 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015664 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015665 request->ssids[i].ssid.mac_ssid,
15666 request->ssids[i].ssid.length);
15667 entry->band = request->ssids[i].band;
15668 entry->min_rssi = request->ssids[i].rssi_low;
15669 entry->max_rssi = request->ssids[i].rssi_high;
15670 entry++;
15671 }
15672 cmd->mode = WMI_EXTSCAN_MODE_START;
15673 } else {
15674 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15675 }
15676
15677 if (wmi_unified_cmd_send
15678 (wmi_handle, wmi_buf, len,
15679 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015680 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015681 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015682 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015683 }
15684
Govind Singhb53420c2016-03-09 14:32:57 +053015685 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015686}
15687
15688/**
15689 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15690 * @wmi_handle: wmi handle
15691 * @vdev_id: vdev id
15692 *
15693 * This function sends roam synch complete event to fw.
15694 *
15695 * Return: CDF STATUS
15696 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015697static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015698 uint8_t vdev_id)
15699{
15700 wmi_roam_synch_complete_fixed_param *cmd;
15701 wmi_buf_t wmi_buf;
15702 uint8_t *buf_ptr;
15703 uint16_t len;
15704 len = sizeof(wmi_roam_synch_complete_fixed_param);
15705
15706 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15707 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015708 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15709 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015710 }
15711 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15712 buf_ptr = (uint8_t *) cmd;
15713 WMITLV_SET_HDR(&cmd->tlv_header,
15714 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15715 WMITLV_GET_STRUCT_TLVLEN
15716 (wmi_roam_synch_complete_fixed_param));
15717 cmd->vdev_id = vdev_id;
15718 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15719 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015720 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015721 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015722 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015723 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015724 }
15725
Govind Singhb53420c2016-03-09 14:32:57 +053015726 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015727}
15728
15729/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015730 * send_fw_test_cmd_tlv() - send fw test command to fw.
15731 * @wmi_handle: wmi handle
15732 * @wmi_fwtest: fw test command
15733 *
15734 * This function sends fw test command to fw.
15735 *
15736 * Return: CDF STATUS
15737 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015738static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015739QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15740 struct set_fwtest_params *wmi_fwtest)
15741{
15742 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15743 wmi_buf_t wmi_buf;
15744 uint16_t len;
15745
15746 len = sizeof(*cmd);
15747
15748 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15749 if (!wmi_buf) {
15750 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15751 return QDF_STATUS_E_NOMEM;
15752 }
15753
15754 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15755 WMITLV_SET_HDR(&cmd->tlv_header,
15756 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15757 WMITLV_GET_STRUCT_TLVLEN(
15758 wmi_fwtest_set_param_cmd_fixed_param));
15759 cmd->param_id = wmi_fwtest->arg;
15760 cmd->param_value = wmi_fwtest->value;
15761
15762 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15763 WMI_FWTEST_CMDID)) {
15764 WMI_LOGP("%s: failed to send fw test command", __func__);
15765 qdf_nbuf_free(wmi_buf);
15766 return QDF_STATUS_E_FAILURE;
15767 }
15768
15769 return QDF_STATUS_SUCCESS;
15770}
15771
15772/**
Govind Singha4836fd2016-03-07 16:45:38 +053015773 * send_unit_test_cmd_tlv() - send unit test command to fw.
15774 * @wmi_handle: wmi handle
15775 * @wmi_utest: unit test command
15776 *
15777 * This function send unit test command to fw.
15778 *
15779 * Return: CDF STATUS
15780 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015781static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015782 struct wmi_unit_test_cmd *wmi_utest)
15783{
15784 wmi_unit_test_cmd_fixed_param *cmd;
15785 wmi_buf_t wmi_buf;
15786 uint8_t *buf_ptr;
15787 int i;
15788 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015789 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015790
15791 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015792 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015793 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15794
15795 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15796 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015797 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15798 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015799 }
15800
15801 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15802 buf_ptr = (uint8_t *) cmd;
15803 WMITLV_SET_HDR(&cmd->tlv_header,
15804 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15805 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15806 cmd->vdev_id = wmi_utest->vdev_id;
15807 cmd->module_id = wmi_utest->module_id;
15808 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015809 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015810 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15811 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15812 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015813 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015814 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15815 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15816 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015817 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015818 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015819 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015820 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015821 }
15822 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15823 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015824 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015825 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015826 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015827 }
15828
Govind Singhb53420c2016-03-09 14:32:57 +053015829 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015830}
15831
15832/**
15833 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15834 * @wmi_handle: wma handle
15835 * @roaminvoke: roam invoke command
15836 *
15837 * Send roam invoke command to fw for fastreassoc.
15838 *
15839 * Return: CDF STATUS
15840 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015841static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015842 struct wmi_roam_invoke_cmd *roaminvoke,
15843 uint32_t ch_hz)
15844{
15845 wmi_roam_invoke_cmd_fixed_param *cmd;
15846 wmi_buf_t wmi_buf;
15847 u_int8_t *buf_ptr;
15848 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015849 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015850 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015851 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015852
15853 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015854 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015855 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15856 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015857 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15858 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15859 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015860 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15861 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015862 }
15863
15864 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15865 buf_ptr = (u_int8_t *) cmd;
15866 WMITLV_SET_HDR(&cmd->tlv_header,
15867 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15868 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15869 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015870 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015871 if (roaminvoke->is_same_bssid)
15872 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15873 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015874
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015875 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015876 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015877 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15878 cmd->num_buf = 1;
15879 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015880 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015881 cmd->num_buf = 0;
15882 }
Naveen Rawat77797922017-01-20 17:00:07 -080015883
Govind Singha4836fd2016-03-07 16:45:38 +053015884 cmd->roam_ap_sel_mode = 0;
15885 cmd->roam_delay = 0;
15886 cmd->num_chan = 1;
15887 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015888
Govind Singha4836fd2016-03-07 16:45:38 +053015889 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15890 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15891 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015892 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015893 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015894 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015895 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15896 (sizeof(wmi_mac_addr)));
15897 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15898 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015899
15900 /* move to next tlv i.e. bcn_prb_buf_list */
15901 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15902
15903 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15904 sizeof(wmi_tlv_buf_len_param));
15905
15906 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15907 buf_len_tlv->buf_len = roaminvoke->frame_len;
15908
15909 /* move to next tlv i.e. bcn_prb_frm */
15910 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15911 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15912 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15913
15914 /* copy frame after the header */
15915 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15916 roaminvoke->frame_buf,
15917 roaminvoke->frame_len);
15918
15919 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
15920 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
15921 buf_ptr + WMI_TLV_HDR_SIZE,
15922 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015923 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15924 cmd->flags, cmd->roam_scan_mode,
15925 cmd->roam_ap_sel_mode, cmd->roam_delay,
15926 cmd->num_chan, cmd->num_bssid);
15927 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015928
Govind Singha4836fd2016-03-07 16:45:38 +053015929 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15930 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015931 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015932 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015933 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015934 }
15935
Govind Singhb53420c2016-03-09 14:32:57 +053015936 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015937}
15938
15939/**
15940 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15941 * @wmi_handle: wmi handle
15942 * @command: command
15943 * @vdev_id: vdev id
15944 *
15945 * This function set roam offload command to fw.
15946 *
15947 * Return: CDF status
15948 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015949static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015950 uint32_t command, uint32_t vdev_id)
15951{
Govind Singh67922e82016-04-01 16:48:57 +053015952 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015953 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15954 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015955 int len;
15956 uint8_t *buf_ptr;
15957
15958 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15959 buf = wmi_buf_alloc(wmi_handle, len);
15960 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015961 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15962 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015963 }
15964
15965 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15966
15967 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15968 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15969 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15970 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15971 cmd_fp->vdev_id = vdev_id;
15972 cmd_fp->command_arg = command;
15973
15974 status = wmi_unified_cmd_send(wmi_handle, buf,
15975 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015976 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015977 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015978 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015979 goto error;
15980 }
15981
Govind Singhb53420c2016-03-09 14:32:57 +053015982 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15983 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015984
15985error:
15986 wmi_buf_free(buf);
15987
Govind Singh67922e82016-04-01 16:48:57 +053015988 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015989}
15990
15991/**
15992 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15993 * @wmi_handle: wmi handle
15994 * @ap_profile_p: ap profile
15995 * @vdev_id: vdev id
15996 *
15997 * Send WMI_ROAM_AP_PROFILE to firmware
15998 *
15999 * Return: CDF status
16000 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016001static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016002 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053016003{
Govind Singha4836fd2016-03-07 16:45:38 +053016004 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016005 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016006 int len;
16007 uint8_t *buf_ptr;
16008 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016009 wmi_roam_cnd_scoring_param *score_param;
16010 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053016011
16012 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016013 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053016014 buf = wmi_buf_alloc(wmi_handle, len);
16015 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016016 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16017 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016018 }
16019
16020 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16021 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
16022 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
16023 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
16024 WMITLV_GET_STRUCT_TLVLEN
16025 (wmi_roam_ap_profile_fixed_param));
16026 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016027 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053016028 roam_ap_profile_fp->id = 0;
16029 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
16030
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016031 profile = (wmi_ap_profile *)buf_ptr;
16032 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053016033 WMITLV_TAG_STRUC_wmi_ap_profile,
16034 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016035 profile->flags = ap_profile->profile.flags;
16036 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
16037 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
16038 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
16039 profile->ssid.ssid_len);
16040 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
16041 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
16042 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
16043 profile->rsn_mcastmgmtcipherset =
16044 ap_profile->profile.rsn_mcastmgmtcipherset;
16045 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
16046
16047 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",
16048 profile->flags, profile->rssi_threshold,
16049 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
16050 profile->rsn_authmode, profile->rsn_ucastcipherset,
16051 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
16052 profile->rssi_abs_thresh);
16053
16054 buf_ptr += sizeof(wmi_ap_profile);
16055
16056 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
16057 WMITLV_SET_HDR(&score_param->tlv_header,
16058 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
16059 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
16060 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
16061 score_param->rssi_weightage_pcnt =
16062 ap_profile->param.rssi_weightage;
16063 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
16064 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
16065 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
16066 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
16067 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
16068 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
16069 score_param->esp_qbss_weightage_pcnt =
16070 ap_profile->param.esp_qbss_weightage;
16071 score_param->beamforming_weightage_pcnt =
16072 ap_profile->param.beamforming_weightage;
16073 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
16074 score_param->oce_wan_weightage_pcnt =
16075 ap_profile->param.oce_wan_weightage;
16076
16077 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",
16078 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
16079 score_param->ht_weightage_pcnt,
16080 score_param->vht_weightage_pcnt,
16081 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
16082 score_param->band_weightage_pcnt,
16083 score_param->nss_weightage_pcnt,
16084 score_param->esp_qbss_weightage_pcnt,
16085 score_param->beamforming_weightage_pcnt,
16086 score_param->pcl_weightage_pcnt,
16087 score_param->oce_wan_weightage_pcnt);
16088
16089 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
16090 score_param->band_scoring.score_pcnt =
16091 ap_profile->param.band_index_score;
16092 score_param->nss_scoring.score_pcnt =
16093 ap_profile->param.nss_index_score;
16094
16095 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
16096 score_param->bw_scoring.score_pcnt,
16097 score_param->band_scoring.score_pcnt,
16098 score_param->nss_scoring.score_pcnt);
16099
16100 score_param->rssi_scoring.best_rssi_threshold =
16101 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
16102 score_param->rssi_scoring.good_rssi_threshold =
16103 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
16104 score_param->rssi_scoring.bad_rssi_threshold =
16105 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
16106 score_param->rssi_scoring.good_rssi_pcnt =
16107 ap_profile->param.rssi_scoring.good_rssi_pcnt;
16108 score_param->rssi_scoring.bad_rssi_pcnt =
16109 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
16110 score_param->rssi_scoring.good_bucket_size =
16111 ap_profile->param.rssi_scoring.good_bucket_size;
16112 score_param->rssi_scoring.bad_bucket_size =
16113 ap_profile->param.rssi_scoring.bad_bucket_size;
16114 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
16115 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
16116
16117 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
16118 score_param->rssi_scoring.best_rssi_threshold,
16119 score_param->rssi_scoring.good_rssi_threshold,
16120 score_param->rssi_scoring.bad_rssi_threshold,
16121 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
16122 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
16123 score_param->rssi_scoring.good_rssi_pcnt,
16124 score_param->rssi_scoring.bad_rssi_pcnt,
16125 score_param->rssi_scoring.good_bucket_size,
16126 score_param->rssi_scoring.bad_bucket_size);
16127
16128 score_param->esp_qbss_scoring.num_slot =
16129 ap_profile->param.esp_qbss_scoring.num_slot;
16130 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
16131 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
16132 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
16133 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
16134 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
16135 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
16136 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
16137 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
16138
16139 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16140 score_param->esp_qbss_scoring.num_slot,
16141 score_param->esp_qbss_scoring.score_pcnt3_to_0,
16142 score_param->esp_qbss_scoring.score_pcnt7_to_4,
16143 score_param->esp_qbss_scoring.score_pcnt11_to_8,
16144 score_param->esp_qbss_scoring.score_pcnt15_to_12);
16145
16146 score_param->oce_wan_scoring.num_slot =
16147 ap_profile->param.oce_wan_scoring.num_slot;
16148 score_param->oce_wan_scoring.score_pcnt3_to_0 =
16149 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
16150 score_param->oce_wan_scoring.score_pcnt7_to_4 =
16151 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
16152 score_param->oce_wan_scoring.score_pcnt11_to_8 =
16153 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
16154 score_param->oce_wan_scoring.score_pcnt15_to_12 =
16155 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
16156
16157 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16158 score_param->oce_wan_scoring.num_slot,
16159 score_param->oce_wan_scoring.score_pcnt3_to_0,
16160 score_param->oce_wan_scoring.score_pcnt7_to_4,
16161 score_param->oce_wan_scoring.score_pcnt11_to_8,
16162 score_param->oce_wan_scoring.score_pcnt15_to_12);
16163
Govind Singha4836fd2016-03-07 16:45:38 +053016164 status = wmi_unified_cmd_send(wmi_handle, buf,
16165 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053016166 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016167 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016168 status);
Govind Singh67922e82016-04-01 16:48:57 +053016169 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053016170 }
16171
Govind Singhb53420c2016-03-09 14:32:57 +053016172 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053016173
Govind Singh67922e82016-04-01 16:48:57 +053016174 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016175}
16176
16177/**
16178 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
16179 * @wmi_handle: wmi handle
16180 * @scan_period: scan period
16181 * @scan_age: scan age
16182 * @vdev_id: vdev id
16183 *
16184 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
16185 *
16186 * Return: CDF status
16187 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016188static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016189 uint32_t scan_period,
16190 uint32_t scan_age,
16191 uint32_t vdev_id)
16192{
Govind Singh67922e82016-04-01 16:48:57 +053016193 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016194 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053016195 int len;
16196 uint8_t *buf_ptr;
16197 wmi_roam_scan_period_fixed_param *scan_period_fp;
16198
16199 /* Send scan period values */
16200 len = sizeof(wmi_roam_scan_period_fixed_param);
16201 buf = wmi_buf_alloc(wmi_handle, len);
16202 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016203 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16204 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016205 }
16206
16207 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16208 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
16209 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
16210 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
16211 WMITLV_GET_STRUCT_TLVLEN
16212 (wmi_roam_scan_period_fixed_param));
16213 /* fill in scan period values */
16214 scan_period_fp->vdev_id = vdev_id;
16215 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
16216 scan_period_fp->roam_scan_age = scan_age;
16217
16218 status = wmi_unified_cmd_send(wmi_handle, buf,
16219 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053016220 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016221 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016222 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016223 goto error;
16224 }
16225
Govind Singhb53420c2016-03-09 14:32:57 +053016226 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053016227 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053016228 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016229error:
16230 wmi_buf_free(buf);
16231
Govind Singh67922e82016-04-01 16:48:57 +053016232 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016233}
16234
16235/**
16236 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
16237 * @wmi_handle: wmi handle
16238 * @chan_count: channel count
16239 * @chan_list: channel list
16240 * @list_type: list type
16241 * @vdev_id: vdev id
16242 *
16243 * Set roam offload channel list.
16244 *
16245 * Return: CDF status
16246 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016247static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016248 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070016249 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053016250 uint8_t list_type, uint32_t vdev_id)
16251{
Govind Singha4836fd2016-03-07 16:45:38 +053016252 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016253 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016254 int len, list_tlv_len;
16255 int i;
16256 uint8_t *buf_ptr;
16257 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053016258 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053016259
16260 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053016261 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053016262 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053016263 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053016264 }
16265 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053016266 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053016267 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
16268 buf = wmi_buf_alloc(wmi_handle, len);
16269 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016270 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16271 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016272 }
16273
16274 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16275 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
16276 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
16277 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
16278 WMITLV_GET_STRUCT_TLVLEN
16279 (wmi_roam_chan_list_fixed_param));
16280 chan_list_fp->vdev_id = vdev_id;
16281 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053016282 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053016283 /* external app is controlling channel list */
16284 chan_list_fp->chan_list_type =
16285 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
16286 } else {
16287 /* umac supplied occupied channel list in LFR */
16288 chan_list_fp->chan_list_type =
16289 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
16290 }
16291
16292 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
16293 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16294 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053016295 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016296 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053016297 for (i = 0; ((i < chan_list_fp->num_chan) &&
16298 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
16299 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053016300 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053016301 }
16302
16303 status = wmi_unified_cmd_send(wmi_handle, buf,
16304 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053016305 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016306 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016307 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016308 goto error;
16309 }
16310
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016311 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053016312 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016313error:
16314 wmi_buf_free(buf);
16315
Govind Singh67922e82016-04-01 16:48:57 +053016316 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016317}
16318
16319/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016320 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
16321 * @wmi_handle: wmi handle
16322 * @req_buf: per roam config buffer
16323 *
16324 * Return: QDF status
16325 */
16326static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
16327 struct wmi_per_roam_config_req *req_buf)
16328{
16329 wmi_buf_t buf = NULL;
16330 QDF_STATUS status;
16331 int len;
16332 uint8_t *buf_ptr;
16333 wmi_roam_per_config_fixed_param *wmi_per_config;
16334
16335 len = sizeof(wmi_roam_per_config_fixed_param);
16336 buf = wmi_buf_alloc(wmi_handle, len);
16337 if (!buf) {
16338 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16339 return QDF_STATUS_E_NOMEM;
16340 }
16341
16342 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16343 wmi_per_config =
16344 (wmi_roam_per_config_fixed_param *) buf_ptr;
16345 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
16346 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
16347 WMITLV_GET_STRUCT_TLVLEN
16348 (wmi_roam_per_config_fixed_param));
16349
16350 /* fill in per roam config values */
16351 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016352
16353 wmi_per_config->enable = req_buf->per_config.enable;
16354 wmi_per_config->high_rate_thresh =
16355 (req_buf->per_config.tx_high_rate_thresh << 16) |
16356 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
16357 wmi_per_config->low_rate_thresh =
16358 (req_buf->per_config.tx_low_rate_thresh << 16) |
16359 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
16360 wmi_per_config->pkt_err_rate_thresh_pct =
16361 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
16362 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
16363 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053016364 wmi_per_config->pkt_err_rate_mon_time =
16365 (req_buf->per_config.tx_per_mon_time << 16) |
16366 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053016367 wmi_per_config->min_candidate_rssi =
16368 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016369
16370 /* Send per roam config parameters */
16371 status = wmi_unified_cmd_send(wmi_handle, buf,
16372 len, WMI_ROAM_PER_CONFIG_CMDID);
16373 if (QDF_IS_STATUS_ERROR(status)) {
16374 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
16375 status);
16376 wmi_buf_free(buf);
16377 return status;
16378 }
16379
16380 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
16381 req_buf->per_config.enable, req_buf->vdev_id);
16382 return QDF_STATUS_SUCCESS;
16383}
16384
16385/**
Govind Singha4836fd2016-03-07 16:45:38 +053016386 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
16387 * @wmi_handle: wmi handle
16388 * @rssi_change_thresh: RSSI Change threshold
16389 * @bcn_rssi_weight: beacon RSSI weight
16390 * @vdev_id: vdev id
16391 *
16392 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
16393 *
16394 * Return: CDF status
16395 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016396static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016397 uint32_t vdev_id,
16398 int32_t rssi_change_thresh,
16399 uint32_t bcn_rssi_weight,
16400 uint32_t hirssi_delay_btw_scans)
16401{
Govind Singha4836fd2016-03-07 16:45:38 +053016402 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016403 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016404 int len;
16405 uint8_t *buf_ptr;
16406 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
16407
16408 /* Send rssi change parameters */
16409 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
16410 buf = wmi_buf_alloc(wmi_handle, len);
16411 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016412 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16413 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016414 }
16415
16416 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16417 rssi_change_fp =
16418 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
16419 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
16420 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
16421 WMITLV_GET_STRUCT_TLVLEN
16422 (wmi_roam_scan_rssi_change_threshold_fixed_param));
16423 /* fill in rssi change threshold (hysteresis) values */
16424 rssi_change_fp->vdev_id = vdev_id;
16425 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
16426 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
16427 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
16428
16429 status = wmi_unified_cmd_send(wmi_handle, buf,
16430 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053016431 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016432 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016433 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016434 goto error;
16435 }
16436
Govind Singhb53420c2016-03-09 14:32:57 +053016437 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053016438 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053016439 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
16440 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016441error:
16442 wmi_buf_free(buf);
16443
Govind Singh67922e82016-04-01 16:48:57 +053016444 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016445}
16446
16447/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
16448 * @wmi_handle: wmi handle.
16449 * @cmd: size of command structure.
16450 * @per_entry_size: per entry size.
16451 *
16452 * This utility function calculates how many hotlist entries can
16453 * fit in one page.
16454 *
16455 * Return: number of entries
16456 */
16457static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
16458 size_t cmd_size,
16459 size_t per_entry_size)
16460{
16461 uint32_t avail_space = 0;
16462 int num_entries = 0;
16463 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
16464
16465 /* Calculate number of hotlist entries that can
16466 * be passed in wma message request.
16467 */
16468 avail_space = max_msg_len - cmd_size;
16469 num_entries = avail_space / per_entry_size;
16470 return num_entries;
16471}
16472
16473/**
16474 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
16475 * @wmi_handle: wmi handle
16476 * @photlist: hotlist command params
16477 * @buf_len: buffer length
16478 *
16479 * This function fills individual elements for hotlist request and
16480 * TLV for bssid entries
16481 *
16482 * Return: CDF Status.
16483 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016484static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016485 struct ext_scan_setbssi_hotlist_params *
16486 photlist, int *buf_len)
16487{
16488 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
16489 wmi_extscan_hotlist_entry *dest_hotlist;
16490 struct ap_threshold_params *src_ap = photlist->ap;
16491 wmi_buf_t buf;
16492 uint8_t *buf_ptr;
16493
16494 int j, index = 0;
16495 int cmd_len = 0;
16496 int num_entries;
16497 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016498 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053016499 int len = sizeof(*cmd);
16500
16501 len += WMI_TLV_HDR_SIZE;
16502 cmd_len = len;
16503
16504 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
16505 cmd_len,
16506 sizeof(*dest_hotlist));
16507 /* setbssid hotlist expects the bssid list
16508 * to be non zero value
16509 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016510 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080016511 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053016512 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053016513 }
16514
16515 /* Split the hot list entry pages and send multiple command
16516 * requests if the buffer reaches the maximum request size
16517 */
16518 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053016519 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053016520 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
16521 buf = wmi_buf_alloc(wmi_handle, len);
16522 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016523 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
16524 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016525 }
16526 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16527 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
16528 buf_ptr;
16529 WMITLV_SET_HDR(&cmd->tlv_header,
16530 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
16531 WMITLV_GET_STRUCT_TLVLEN
16532 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
16533
16534 /* Multiple requests are sent until the num_entries_in_page
16535 * matches the total_entries
16536 */
16537 cmd->request_id = photlist->requestId;
16538 cmd->vdev_id = photlist->sessionId;
16539 cmd->total_entries = numap;
16540 cmd->mode = 1;
16541 cmd->num_entries_in_page = min_entries;
16542 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
16543 cmd->first_entry_index = index;
16544
Govind Singhb53420c2016-03-09 14:32:57 +053016545 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016546 __func__, cmd->vdev_id, cmd->total_entries,
16547 cmd->num_entries_in_page,
16548 cmd->lost_ap_scan_count);
16549
16550 buf_ptr += sizeof(*cmd);
16551 WMITLV_SET_HDR(buf_ptr,
16552 WMITLV_TAG_ARRAY_STRUC,
16553 min_entries * sizeof(wmi_extscan_hotlist_entry));
16554 dest_hotlist = (wmi_extscan_hotlist_entry *)
16555 (buf_ptr + WMI_TLV_HDR_SIZE);
16556
16557 /* Populate bssid, channel info and rssi
16558 * for the bssid's that are sent as hotlists.
16559 */
16560 for (j = 0; j < min_entries; j++) {
16561 WMITLV_SET_HDR(dest_hotlist,
16562 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
16563 WMITLV_GET_STRUCT_TLVLEN
16564 (wmi_extscan_hotlist_entry));
16565
16566 dest_hotlist->min_rssi = src_ap->low;
16567 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
16568 &dest_hotlist->bssid);
16569
Govind Singhb53420c2016-03-09 14:32:57 +053016570 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016571 __func__, dest_hotlist->channel,
16572 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053016573 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053016574 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16575 __func__, dest_hotlist->bssid.mac_addr31to0,
16576 dest_hotlist->bssid.mac_addr47to32);
16577 dest_hotlist++;
16578 src_ap++;
16579 }
16580 buf_ptr += WMI_TLV_HDR_SIZE +
16581 (min_entries * sizeof(wmi_extscan_hotlist_entry));
16582
16583 if (wmi_unified_cmd_send(wmi_handle, buf, len,
16584 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016585 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053016586 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053016587 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016588 }
16589 index = index + min_entries;
16590 num_entries = numap - min_entries;
16591 len = cmd_len;
16592 }
Govind Singhb53420c2016-03-09 14:32:57 +053016593 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016594}
16595
Govind Singhbca3b1b2016-05-02 17:59:24 +053016596/**
Dustin Brown4423f632017-01-13 15:24:07 -080016597 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
16598 * @wmi_handle: the WMI handle
16599 * @vdev_id: the Id of the vdev to apply the configuration to
16600 * @ucast_mode: the active BPF mode to configure for unicast packets
16601 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
16602 * packets
16603 *
16604 * Return: QDF status
16605 */
16606static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
16607 uint8_t vdev_id,
16608 enum wmi_host_active_bpf_mode ucast_mode,
16609 enum wmi_host_active_bpf_mode mcast_bcast_mode)
16610{
16611 const WMITLV_TAG_ID tag_id =
16612 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
16613 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
16614 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
16615 QDF_STATUS status;
16616 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
16617 wmi_buf_t buf;
16618
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016619 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080016620 vdev_id, ucast_mode, mcast_bcast_mode);
16621
16622 /* allocate command buffer */
16623 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
16624 if (!buf) {
16625 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
16626 return QDF_STATUS_E_NOMEM;
16627 }
16628
16629 /* set TLV header */
16630 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
16631 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
16632
16633 /* populate data */
16634 cmd->vdev_id = vdev_id;
16635 cmd->uc_mode = ucast_mode;
16636 cmd->mcbc_mode = mcast_bcast_mode;
16637
16638 /* send to FW */
16639 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
16640 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
16641 if (QDF_IS_STATUS_ERROR(status)) {
16642 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
16643 status);
16644 wmi_buf_free(buf);
16645 return status;
16646 }
16647
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016648 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080016649
16650 return QDF_STATUS_SUCCESS;
16651}
16652
16653/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053016654 * send_power_dbg_cmd_tlv() - send power debug commands
16655 * @wmi_handle: wmi handle
16656 * @param: wmi power debug parameter
16657 *
16658 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
16659 *
16660 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16661 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016662static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
16663 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053016664{
16665 wmi_buf_t buf = NULL;
16666 QDF_STATUS status;
16667 int len, args_tlv_len;
16668 uint8_t *buf_ptr;
16669 uint8_t i;
16670 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
16671 uint32_t *cmd_args;
16672
16673 /* Prepare and send power debug cmd parameters */
16674 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
16675 len = sizeof(*cmd) + args_tlv_len;
16676 buf = wmi_buf_alloc(wmi_handle, len);
16677 if (!buf) {
16678 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16679 return QDF_STATUS_E_NOMEM;
16680 }
16681
16682 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16683 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
16684 WMITLV_SET_HDR(&cmd->tlv_header,
16685 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
16686 WMITLV_GET_STRUCT_TLVLEN
16687 (wmi_pdev_wal_power_debug_cmd_fixed_param));
16688
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016689 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16690 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016691 cmd->module_id = param->module_id;
16692 cmd->num_args = param->num_args;
16693 buf_ptr += sizeof(*cmd);
16694 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16695 (param->num_args * sizeof(uint32_t)));
16696 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
16697 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080016698 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053016699 cmd_args[i] = param->args[i];
16700 WMI_LOGI("%d,", param->args[i]);
16701 }
16702
16703 status = wmi_unified_cmd_send(wmi_handle, buf,
16704 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
16705 if (QDF_IS_STATUS_ERROR(status)) {
16706 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
16707 status);
16708 goto error;
16709 }
16710
16711 return QDF_STATUS_SUCCESS;
16712error:
16713 wmi_buf_free(buf);
16714
16715 return status;
16716}
16717
Govind Singhe7f2f342016-05-23 12:12:52 +053016718/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016719 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
16720 * @wmi_handle: wmi handle
16721 * @param: wmi multiple vdev restart req param
16722 *
16723 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
16724 *
16725 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16726 */
16727static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
16728 wmi_unified_t wmi_handle,
16729 struct multiple_vdev_restart_params *param)
16730{
16731 wmi_buf_t buf;
16732 QDF_STATUS qdf_status;
16733 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
16734 int i;
16735 uint8_t *buf_ptr;
16736 uint32_t *vdev_ids;
16737 wmi_channel *chan_info;
16738 struct channel_param *tchan_info;
16739 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
16740
16741 len += sizeof(wmi_channel);
16742 if (param->num_vdevs)
16743 len += sizeof(uint32_t) * param->num_vdevs;
16744
16745 buf = wmi_buf_alloc(wmi_handle, len);
16746 if (!buf) {
16747 WMI_LOGE("Failed to allocate memory\n");
16748 qdf_status = QDF_STATUS_E_NOMEM;
16749 goto end;
16750 }
16751
16752 buf_ptr = (uint8_t *)wmi_buf_data(buf);
16753 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
16754 buf_ptr;
16755
16756 WMITLV_SET_HDR(&cmd->tlv_header,
16757 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
16758 WMITLV_GET_STRUCT_TLVLEN
16759 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016760 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16761 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016762 cmd->requestor_id = param->requestor_id;
16763 cmd->disable_hw_ack = param->disable_hw_ack;
16764 cmd->cac_duration_ms = param->cac_duration_ms;
16765 cmd->num_vdevs = param->num_vdevs;
16766
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016767 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
16768 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
16769 " cmd->num_vdevs: %d ",
16770 __func__, cmd->pdev_id, cmd->requestor_id,
16771 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016772 buf_ptr += sizeof(*cmd);
16773
16774 WMITLV_SET_HDR(buf_ptr,
16775 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053016776 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016777 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
16778 for (i = 0; i < param->num_vdevs; i++) {
16779 vdev_ids[i] = param->vdev_ids[i];
16780 }
16781
Vivekc5823092018-03-22 23:27:21 +053016782 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016783
16784 WMITLV_SET_HDR(buf_ptr,
16785 WMITLV_TAG_STRUC_wmi_channel,
16786 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053016787 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016788 tchan_info = &(param->ch_param);
16789 chan_info->mhz = tchan_info->mhz;
16790 chan_info->band_center_freq1 = tchan_info->cfreq1;
16791 chan_info->band_center_freq2 = tchan_info->cfreq2;
16792 if (tchan_info->is_chan_passive)
16793 WMI_SET_CHANNEL_FLAG(chan_info,
16794 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016795 if (tchan_info->dfs_set)
16796 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
16797
Sathish Kumar45e991b2017-02-27 10:35:40 +053016798 if (tchan_info->allow_vht)
16799 WMI_SET_CHANNEL_FLAG(chan_info,
16800 WMI_CHAN_FLAG_ALLOW_VHT);
16801 else if (tchan_info->allow_ht)
16802 WMI_SET_CHANNEL_FLAG(chan_info,
16803 WMI_CHAN_FLAG_ALLOW_HT);
16804 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
16805 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
16806 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
16807 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
16808 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
16809 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080016810 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016811
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016812 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
16813 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
16814 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
16815 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
16816 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
16817 "tchan_info->reg_class_id: %d ,"
16818 "tchan_info->maxregpower : %d ", __func__,
16819 tchan_info->is_chan_passive, tchan_info->dfs_set,
16820 tchan_info->allow_vht, tchan_info->allow_ht,
16821 tchan_info->antennamax, tchan_info->phy_mode,
16822 tchan_info->minpower, tchan_info->maxpower,
16823 tchan_info->maxregpower, tchan_info->reg_class_id,
16824 tchan_info->maxregpower);
16825
Sathish Kumar45e991b2017-02-27 10:35:40 +053016826 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
16827 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
16828
16829 if (QDF_IS_STATUS_ERROR(qdf_status)) {
16830 WMI_LOGE("%s: Failed to send\n", __func__);
16831 wmi_buf_free(buf);
16832 }
16833
16834end:
16835 return qdf_status;
16836}
16837
16838/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080016839 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
16840 * @wmi_handle: wmi handle
16841 * @pdev_id: pdev id
16842 *
16843 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16844 *
16845 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16846 */
16847static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16848 uint32_t pdev_id)
16849{
16850 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16851 wmi_buf_t buf;
16852 uint16_t len;
16853 QDF_STATUS ret;
16854
16855 len = sizeof(*cmd);
16856 buf = wmi_buf_alloc(wmi_handle, len);
16857
16858 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16859
16860 if (!buf) {
16861 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16862 return QDF_STATUS_E_NOMEM;
16863 }
16864
16865 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16866 wmi_buf_data(buf);
16867
16868 WMITLV_SET_HDR(&cmd->tlv_header,
16869 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16870 WMITLV_GET_STRUCT_TLVLEN(
16871 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16872
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016873 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016874 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16875 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16876 if (QDF_IS_STATUS_ERROR(ret)) {
16877 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16878 __func__, ret, pdev_id);
16879 wmi_buf_free(buf);
16880 return QDF_STATUS_E_FAILURE;
16881 }
16882
16883 return QDF_STATUS_SUCCESS;
16884}
16885
16886/**
16887 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16888 * @wmi_handle: wmi handle
16889 * @pdev_id: pdev id
16890 *
16891 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16892 *
16893 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16894 */
16895static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16896 uint32_t pdev_id)
16897{
16898 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16899 wmi_buf_t buf;
16900 uint16_t len;
16901 QDF_STATUS ret;
16902
16903 len = sizeof(*cmd);
16904 buf = wmi_buf_alloc(wmi_handle, len);
16905
16906 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16907
16908 if (!buf) {
16909 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16910 return QDF_STATUS_E_NOMEM;
16911 }
16912
16913 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16914 wmi_buf_data(buf);
16915
16916 WMITLV_SET_HDR(&cmd->tlv_header,
16917 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16918 WMITLV_GET_STRUCT_TLVLEN(
16919 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16920
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016921 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016922 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16923 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16924 if (QDF_IS_STATUS_ERROR(ret)) {
16925 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16926 __func__, ret, pdev_id);
16927 wmi_buf_free(buf);
16928 return QDF_STATUS_E_FAILURE;
16929 }
16930
16931 return QDF_STATUS_SUCCESS;
16932}
16933
16934/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016935 * init_cmd_send_tlv() - send initialization cmd to fw
16936 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016937 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016938 *
16939 * Return: QDF_STATUS_SUCCESS for success or error code
16940 */
16941static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016942 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016943{
16944 wmi_buf_t buf;
16945 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016946 uint8_t *buf_ptr;
16947 wmi_resource_config *resource_cfg;
16948 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016949 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016950 uint16_t idx;
16951 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016952 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016953
Kiran Venkatappa26117052016-12-23 19:58:54 +053016954 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16955 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016956 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016957
16958 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16959 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16960 WMI_TLV_HDR_SIZE +
16961 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16962
16963 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016964 if (!buf) {
16965 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16966 return QDF_STATUS_E_FAILURE;
16967 }
16968
16969 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16970 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16971 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16972
16973 host_mem_chunks = (wlan_host_memory_chunk *)
16974 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16975 + WMI_TLV_HDR_SIZE);
16976
16977 WMITLV_SET_HDR(&cmd->tlv_header,
16978 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16979 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16980
Kiran Venkatappa26117052016-12-23 19:58:54 +053016981 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016982 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16983 WMITLV_TAG_STRUC_wmi_resource_config,
16984 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16985
Kiran Venkatappa26117052016-12-23 19:58:54 +053016986 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016987 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16988 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16989 WMITLV_GET_STRUCT_TLVLEN
16990 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016991 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16992 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16993 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016994 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16995 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016996 idx, host_mem_chunks[idx].size,
16997 host_mem_chunks[idx].ptr);
16998 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016999 cmd->num_host_mem_chunks = param->num_mem_chunks;
17000 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
17001
Govind Singhe7f2f342016-05-23 12:12:52 +053017002 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
17003 WMITLV_TAG_ARRAY_STRUC,
17004 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053017005 param->num_mem_chunks));
17006
17007 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017008 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053017009
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017010 /* Fill fw_abi_vers */
17011 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053017012
Abhishek Singh716c46c2016-05-04 16:24:07 +053017013 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
17014 if (QDF_IS_STATUS_ERROR(ret)) {
17015 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
17016 ret);
17017 wmi_buf_free(buf);
17018 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017019
Abhishek Singh716c46c2016-05-04 16:24:07 +053017020 return ret;
17021
Govind Singhe7f2f342016-05-23 12:12:52 +053017022}
17023
17024/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080017025 * send_addba_send_cmd_tlv() - send addba send command to fw
17026 * @wmi_handle: wmi handle
17027 * @param: pointer to delba send params
17028 * @macaddr: peer mac address
17029 *
17030 * Send WMI_ADDBA_SEND_CMDID command to firmware
17031 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17032 */
17033static QDF_STATUS
17034send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
17035 uint8_t macaddr[IEEE80211_ADDR_LEN],
17036 struct addba_send_params *param)
17037{
17038 wmi_addba_send_cmd_fixed_param *cmd;
17039 wmi_buf_t buf;
17040 uint16_t len;
17041 QDF_STATUS ret;
17042
17043 len = sizeof(*cmd);
17044
17045 buf = wmi_buf_alloc(wmi_handle, len);
17046 if (!buf) {
17047 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17048 return QDF_STATUS_E_NOMEM;
17049 }
17050
17051 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
17052
17053 WMITLV_SET_HDR(&cmd->tlv_header,
17054 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
17055 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
17056
17057 cmd->vdev_id = param->vdev_id;
17058 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17059 cmd->tid = param->tidno;
17060 cmd->buffersize = param->buffersize;
17061
17062 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
17063 if (QDF_IS_STATUS_ERROR(ret)) {
17064 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17065 wmi_buf_free(buf);
17066 return QDF_STATUS_E_FAILURE;
17067 }
17068
17069 return QDF_STATUS_SUCCESS;
17070}
17071
17072/**
17073 * send_delba_send_cmd_tlv() - send delba send command to fw
17074 * @wmi_handle: wmi handle
17075 * @param: pointer to delba send params
17076 * @macaddr: peer mac address
17077 *
17078 * Send WMI_DELBA_SEND_CMDID command to firmware
17079 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17080 */
17081static QDF_STATUS
17082send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
17083 uint8_t macaddr[IEEE80211_ADDR_LEN],
17084 struct delba_send_params *param)
17085{
17086 wmi_delba_send_cmd_fixed_param *cmd;
17087 wmi_buf_t buf;
17088 uint16_t len;
17089 QDF_STATUS ret;
17090
17091 len = sizeof(*cmd);
17092
17093 buf = wmi_buf_alloc(wmi_handle, len);
17094 if (!buf) {
17095 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17096 return QDF_STATUS_E_NOMEM;
17097 }
17098
17099 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
17100
17101 WMITLV_SET_HDR(&cmd->tlv_header,
17102 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
17103 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
17104
17105 cmd->vdev_id = param->vdev_id;
17106 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17107 cmd->tid = param->tidno;
17108 cmd->initiator = param->initiator;
17109 cmd->reasoncode = param->reasoncode;
17110
17111 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
17112 if (QDF_IS_STATUS_ERROR(ret)) {
17113 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17114 wmi_buf_free(buf);
17115 return QDF_STATUS_E_FAILURE;
17116 }
17117
17118 return QDF_STATUS_SUCCESS;
17119}
17120
17121/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080017122 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
17123 * to fw
17124 * @wmi_handle: wmi handle
17125 * @param: pointer to addba clearresp params
17126 * @macaddr: peer mac address
17127 * Return: 0 for success or error code
17128 */
17129static QDF_STATUS
17130send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
17131 uint8_t macaddr[IEEE80211_ADDR_LEN],
17132 struct addba_clearresponse_params *param)
17133{
17134 wmi_addba_clear_resp_cmd_fixed_param *cmd;
17135 wmi_buf_t buf;
17136 uint16_t len;
17137 QDF_STATUS ret;
17138
17139 len = sizeof(*cmd);
17140
17141 buf = wmi_buf_alloc(wmi_handle, len);
17142 if (!buf) {
17143 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
17144 return QDF_STATUS_E_FAILURE;
17145 }
17146 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
17147
17148 WMITLV_SET_HDR(&cmd->tlv_header,
17149 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
17150 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
17151
17152 cmd->vdev_id = param->vdev_id;
17153 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17154
17155 ret = wmi_unified_cmd_send(wmi_handle,
17156 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
17157 if (QDF_IS_STATUS_ERROR(ret)) {
17158 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17159 wmi_buf_free(buf);
17160 return QDF_STATUS_E_FAILURE;
17161 }
17162
17163 return QDF_STATUS_SUCCESS;
17164}
17165
17166/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017167 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
17168 * @wmi_handle: wmi handle
17169 * @bcn_ctrl_param: pointer to bcn_offload_control param
17170 *
17171 * Return: QDF_STATUS_SUCCESS for success or error code
17172 */
17173static
17174QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
17175 struct bcn_offload_control *bcn_ctrl_param)
17176{
17177 wmi_buf_t buf;
17178 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
17179 QDF_STATUS ret;
17180 uint32_t len;
17181
17182 len = sizeof(*cmd);
17183
17184 buf = wmi_buf_alloc(wmi_handle, len);
17185 if (!buf) {
17186 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17187 return QDF_STATUS_E_FAILURE;
17188 }
17189
17190 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
17191 WMITLV_SET_HDR(&cmd->tlv_header,
17192 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
17193 WMITLV_GET_STRUCT_TLVLEN
17194 (wmi_bcn_offload_ctrl_cmd_fixed_param));
17195 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053017196 switch (bcn_ctrl_param->bcn_ctrl_op) {
17197 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017198 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053017199 break;
17200 case BCN_OFFLD_CTRL_TX_ENABLE:
17201 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
17202 break;
17203 case BCN_OFFLD_CTRL_SWBA_DISABLE:
17204 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
17205 break;
17206 case BCN_OFFLD_CTRL_SWBA_ENABLE:
17207 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
17208 break;
17209 default:
17210 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
17211 bcn_ctrl_param->bcn_ctrl_op);
17212 wmi_buf_free(buf);
17213 return QDF_STATUS_E_FAILURE;
17214 break;
17215 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017216 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
17217 WMI_BCN_OFFLOAD_CTRL_CMDID);
17218
17219 if (QDF_IS_STATUS_ERROR(ret)) {
17220 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
17221 ret);
17222 wmi_buf_free(buf);
17223 }
17224
17225 return ret;
17226}
17227
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017228#ifdef WLAN_FEATURE_NAN_CONVERGENCE
17229static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
17230 struct nan_datapath_initiator_req *ndp_req)
17231{
17232 uint16_t len;
17233 wmi_buf_t buf;
17234 uint8_t *tlv_ptr;
17235 QDF_STATUS status;
17236 wmi_channel *ch_tlv;
17237 wmi_ndp_initiator_req_fixed_param *cmd;
17238 uint32_t passphrase_len, service_name_len;
17239 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
17240
17241 /*
17242 * WMI command expects 4 byte alligned len:
17243 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17244 */
17245 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
17246 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
17247 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
17248 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
17249 service_name_len =
17250 qdf_roundup(ndp_req->service_name.service_name_len, 4);
17251 /* allocated memory for fixed params as well as variable size data */
17252 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
17253 + ndp_cfg_len + ndp_app_info_len + pmk_len
17254 + passphrase_len + service_name_len;
17255
17256 buf = wmi_buf_alloc(wmi_handle, len);
17257 if (!buf) {
17258 WMI_LOGE("wmi_buf_alloc failed");
17259 return QDF_STATUS_E_NOMEM;
17260 }
17261
17262 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
17263 WMITLV_SET_HDR(&cmd->tlv_header,
17264 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
17265 WMITLV_GET_STRUCT_TLVLEN(
17266 wmi_ndp_initiator_req_fixed_param));
17267 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
17268 cmd->transaction_id = ndp_req->transaction_id;
17269 cmd->service_instance_id = ndp_req->service_instance_id;
17270 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
17271 &cmd->peer_discovery_mac_addr);
17272
17273 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
17274 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
17275 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
17276 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
17277 cmd->nan_csid = ndp_req->ncs_sk_type;
17278 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
17279 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
17280
17281 ch_tlv = (wmi_channel *)&cmd[1];
17282 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
17283 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
17284 ch_tlv->mhz = ndp_req->channel;
17285 tlv_ptr = (uint8_t *)&ch_tlv[1];
17286
17287 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17288 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17289 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17290 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17291
17292 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17293 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17294 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
17295 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17296
17297 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17298 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
17299 cmd->nan_pmk_len);
17300 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17301
17302 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17303 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
17304 cmd->nan_passphrase_len);
17305 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17306
17307 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17308 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17309 ndp_req->service_name.service_name,
17310 cmd->nan_servicename_len);
17311 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17312
17313 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
17314 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
17315 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
17316 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
17317 cmd->peer_discovery_mac_addr.mac_addr31to0,
17318 cmd->peer_discovery_mac_addr.mac_addr47to32);
17319
17320 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
17321 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17322 ndp_req->ndp_config.ndp_cfg,
17323 ndp_req->ndp_config.ndp_cfg_len);
17324
17325 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
17326 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17327 ndp_req->ndp_info.ndp_app_info,
17328 ndp_req->ndp_info.ndp_app_info_len);
17329
17330 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17331 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17332 ndp_req->pmk.pmk, cmd->nan_pmk_len);
17333
17334 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17335 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17336 ndp_req->passphrase.passphrase,
17337 cmd->nan_passphrase_len);
17338
17339 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17340 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17341 ndp_req->service_name.service_name,
17342 cmd->nan_servicename_len);
17343
17344 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
17345 WMI_NDP_INITIATOR_REQ_CMDID);
17346
17347 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17348 WMI_NDP_INITIATOR_REQ_CMDID);
17349 if (QDF_IS_STATUS_ERROR(status)) {
17350 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
17351 wmi_buf_free(buf);
17352 }
17353
17354 return status;
17355}
17356
17357static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
17358 struct nan_datapath_responder_req *req)
17359{
17360 uint16_t len;
17361 wmi_buf_t buf;
17362 uint8_t *tlv_ptr;
17363 QDF_STATUS status;
17364 wmi_ndp_responder_req_fixed_param *cmd;
17365 uint32_t passphrase_len, service_name_len;
17366 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
17367
17368 vdev_id = wlan_vdev_get_id(req->vdev);
17369 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
17370 vdev_id, req->transaction_id,
17371 req->ndp_rsp,
17372 req->ndp_instance_id,
17373 req->ndp_info.ndp_app_info_len);
17374
17375 /*
17376 * WMI command expects 4 byte alligned len:
17377 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17378 */
17379 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
17380 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
17381 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
17382 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
17383 service_name_len =
17384 qdf_roundup(req->service_name.service_name_len, 4);
17385
17386 /* allocated memory for fixed params as well as variable size data */
17387 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
17388 + pmk_len + passphrase_len + service_name_len;
17389
17390 buf = wmi_buf_alloc(wmi_handle, len);
17391 if (!buf) {
17392 WMI_LOGE("wmi_buf_alloc failed");
17393 return QDF_STATUS_E_NOMEM;
17394 }
17395 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
17396 WMITLV_SET_HDR(&cmd->tlv_header,
17397 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
17398 WMITLV_GET_STRUCT_TLVLEN(
17399 wmi_ndp_responder_req_fixed_param));
17400 cmd->vdev_id = vdev_id;
17401 cmd->transaction_id = req->transaction_id;
17402 cmd->ndp_instance_id = req->ndp_instance_id;
17403 cmd->rsp_code = req->ndp_rsp;
17404 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
17405 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
17406 cmd->nan_pmk_len = req->pmk.pmk_len;
17407 cmd->nan_csid = req->ncs_sk_type;
17408 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
17409 cmd->nan_servicename_len = req->service_name.service_name_len;
17410
17411 tlv_ptr = (uint8_t *)&cmd[1];
17412 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17413 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17414 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17415
17416 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17417 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17418 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17419 req->ndp_info.ndp_app_info,
17420 req->ndp_info.ndp_app_info_len);
17421
17422 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17423 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17424 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
17425 cmd->nan_pmk_len);
17426
17427 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17428 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17429 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17430 req->passphrase.passphrase,
17431 cmd->nan_passphrase_len);
17432 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17433
17434 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17435 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17436 req->service_name.service_name,
17437 cmd->nan_servicename_len);
17438
17439 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17440
17441 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
17442 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
17443
17444 WMI_LOGD("ndp_config len: %d",
17445 req->ndp_config.ndp_cfg_len);
17446 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17447 req->ndp_config.ndp_cfg,
17448 req->ndp_config.ndp_cfg_len);
17449
17450 WMI_LOGD("ndp_app_info len: %d",
17451 req->ndp_info.ndp_app_info_len);
17452 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17453 req->ndp_info.ndp_app_info,
17454 req->ndp_info.ndp_app_info_len);
17455
17456 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17457 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17458 req->pmk.pmk, cmd->nan_pmk_len);
17459
17460 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17461 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17462 req->passphrase.passphrase,
17463 cmd->nan_passphrase_len);
17464
17465 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17466 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17467 req->service_name.service_name,
17468 cmd->nan_servicename_len);
17469
17470 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
17471 WMI_NDP_RESPONDER_REQ_CMDID);
17472 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17473 WMI_NDP_RESPONDER_REQ_CMDID);
17474 if (QDF_IS_STATUS_ERROR(status)) {
17475 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
17476 wmi_buf_free(buf);
17477 }
17478 return status;
17479}
17480
17481static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
17482 struct nan_datapath_end_req *req)
17483{
17484 uint16_t len;
17485 wmi_buf_t buf;
17486 QDF_STATUS status;
17487 uint32_t ndp_end_req_len, i;
17488 wmi_ndp_end_req *ndp_end_req_lst;
17489 wmi_ndp_end_req_fixed_param *cmd;
17490
17491 /* len of tlv following fixed param */
17492 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
17493 /* above comes out to 4 byte alligned already, no need of padding */
17494 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
17495 buf = wmi_buf_alloc(wmi_handle, len);
17496 if (!buf) {
17497 WMI_LOGE("Malloc failed");
17498 return QDF_STATUS_E_NOMEM;
17499 }
17500
17501 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
17502 WMITLV_SET_HDR(&cmd->tlv_header,
17503 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
17504 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
17505
17506 cmd->transaction_id = req->transaction_id;
17507
17508 /* set tlv pointer to end of fixed param */
17509 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
17510 ndp_end_req_len);
17511
17512 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
17513 WMI_TLV_HDR_SIZE);
17514 for (i = 0; i < req->num_ndp_instances; i++) {
17515 WMITLV_SET_HDR(&ndp_end_req_lst[i],
17516 WMITLV_TAG_ARRAY_FIXED_STRUC,
17517 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
17518
17519 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
17520 }
17521
17522 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
17523 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17524 WMI_NDP_END_REQ_CMDID);
17525 if (QDF_IS_STATUS_ERROR(status)) {
17526 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
17527 wmi_buf_free(buf);
17528 }
17529
17530 return status;
17531}
17532
17533static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017534 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017535{
17536 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
17537 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
17538
17539 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
17540 fixed_params = event->fixed_param;
17541
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017542 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017543 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17544 fixed_params->vdev_id,
17545 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017546 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017547 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017548 return QDF_STATUS_E_INVAL;
17549 }
17550
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017551 rsp->transaction_id = fixed_params->transaction_id;
17552 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17553 rsp->status = fixed_params->rsp_status;
17554 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017555
17556 return QDF_STATUS_SUCCESS;
17557}
17558
17559static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017560 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017561{
17562 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
17563 wmi_ndp_indication_event_fixed_param *fixed_params;
17564
17565 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
17566 fixed_params =
17567 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
17568
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017569 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17570 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17571 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17572 return QDF_STATUS_E_INVAL;
17573 }
17574
17575 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17576 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17577 fixed_params->ndp_app_info_len,
17578 event->num_ndp_app_info);
17579 return QDF_STATUS_E_INVAL;
17580 }
17581
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017582 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017583 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17584 fixed_params->vdev_id,
17585 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017586 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017587 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017588 return QDF_STATUS_E_INVAL;
17589 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017590 rsp->service_instance_id = fixed_params->service_instance_id;
17591 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17592 rsp->role = fixed_params->self_ndp_role;
17593 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017594
17595 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017596 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017597 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017598 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017599
17600 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
17601 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
17602 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
17603 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
17604 fixed_params->service_instance_id,
17605 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
17606 fixed_params->accept_policy,
17607 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017608 rsp->peer_mac_addr.bytes,
17609 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017610
17611 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17612 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17613 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17614
17615 WMI_LOGD("ndp_app_info - %d bytes",
17616 fixed_params->ndp_app_info_len);
17617 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17618 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17619
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017620 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
17621 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17622 rsp->ncs_sk_type = fixed_params->nan_csid;
17623 rsp->scid.scid_len = fixed_params->nan_scid_len;
17624 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
17625 rsp->ndp_config.ndp_cfg_len);
17626 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
17627 rsp->ndp_info.ndp_app_info_len);
17628 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017629 WMI_LOGD("scid hex dump:");
17630 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017631 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017632
17633 return QDF_STATUS_SUCCESS;
17634}
17635
17636static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017637 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017638{
17639 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
17640 wmi_ndp_confirm_event_fixed_param *fixed_params;
17641
17642 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
17643 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017644 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 -080017645 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
17646 fixed_params->ndp_instance_id, fixed_params->rsp_code,
17647 fixed_params->reason_code,
17648 fixed_params->num_active_ndps_on_peer);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017649
17650 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17651 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17652 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17653 return QDF_STATUS_E_INVAL;
17654 }
17655
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017656 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17657 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17658 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17659
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017660 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17661 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17662 fixed_params->ndp_app_info_len,
17663 event->num_ndp_app_info);
17664 return QDF_STATUS_E_INVAL;
17665 }
17666
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017667 WMI_LOGD("ndp_app_info - %d bytes",
17668 fixed_params->ndp_app_info_len);
17669 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17670 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17671
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017672 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017673 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17674 fixed_params->vdev_id,
17675 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017676 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017677 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017678 return QDF_STATUS_E_INVAL;
17679 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017680 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17681 rsp->rsp_code = fixed_params->rsp_code;
17682 rsp->reason_code = fixed_params->reason_code;
17683 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017684 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017685 rsp->peer_ndi_mac_addr.bytes);
17686 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17687 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
17688 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017689
17690 return QDF_STATUS_SUCCESS;
17691}
17692
17693static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017694 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017695{
17696 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17697 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17698
17699 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17700 fixed_params = event->fixed_param;
17701
17702 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",
17703 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017704 rsp->peer_mac_addr.bytes, rsp->transaction_id,
17705 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017706
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017707 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017708 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17709 fixed_params->vdev_id,
17710 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017711 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017712 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017713 return QDF_STATUS_E_INVAL;
17714 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017715 rsp->transaction_id = fixed_params->transaction_id;
17716 rsp->reason = fixed_params->reason_code;
17717 rsp->status = fixed_params->rsp_status;
17718 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017719 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017720 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017721
17722 return QDF_STATUS_SUCCESS;
17723}
17724
17725static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017726 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017727{
17728 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17729 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17730
17731 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17732 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017733 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 -080017734 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17735 fixed_params->rsp_status, fixed_params->reason_code);
17736
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017737 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017738 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017739 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017740 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017741 return QDF_STATUS_E_INVAL;
17742 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017743 rsp->transaction_id = fixed_params->transaction_id;
17744 rsp->reason = fixed_params->reason_code;
17745 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017746
17747 return QDF_STATUS_SUCCESS;
17748}
17749
17750static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17751 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17752{
17753 uint32_t i, buf_size;
17754 wmi_ndp_end_indication *ind;
17755 struct qdf_mac_addr peer_addr;
17756 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17757
17758 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17759 ind = event->ndp_end_indication_list;
17760
17761 if (event->num_ndp_end_indication_list == 0) {
17762 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017763 return QDF_STATUS_E_INVAL;
17764 }
17765
17766 WMI_LOGD("number of ndp instances = %d",
17767 event->num_ndp_end_indication_list);
17768
17769 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17770 sizeof((*rsp)->ndp_map[0]))) {
17771 WMI_LOGE("num_ndp_end_ind_list %d too large",
17772 event->num_ndp_end_indication_list);
17773 return QDF_STATUS_E_INVAL;
17774 }
17775
17776 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17777 sizeof((*rsp)->ndp_map[0]);
17778 *rsp = qdf_mem_malloc(buf_size);
17779 if (!(*rsp)) {
17780 WMI_LOGE("Failed to allocate memory");
17781 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017782 }
17783
17784 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17785 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17786 if (!(*rsp)->vdev) {
17787 WMI_LOGE("vdev is null");
17788 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017789 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017790 return QDF_STATUS_E_INVAL;
17791 }
17792
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017793 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17794 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17795 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17796 peer_addr.bytes);
17797 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17798 i, ind[i].type, ind[i].reason_code,
17799 ind[i].ndp_instance_id,
17800 ind[i].num_active_ndps_on_peer);
17801 /* Add each instance entry to the list */
17802 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17803 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17804 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17805 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17806 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17807 ind[i].num_active_ndps_on_peer;
17808 (*rsp)->ndp_map[i].type = ind[i].type;
17809 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17810 }
17811
17812 return QDF_STATUS_SUCCESS;
17813}
Naveen Rawatd42ce382018-01-09 17:54:41 -080017814
17815static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,
17816 uint8_t *data, struct nan_datapath_sch_update_event *ind)
17817{
17818 uint8_t i;
17819 WMI_HOST_WLAN_PHY_MODE ch_mode;
17820 WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *event;
17821 wmi_ndl_schedule_update_fixed_param *fixed_params;
17822
17823 event = (WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *)data;
17824 fixed_params = event->fixed_param;
17825
17826 WMI_LOGD(FL("flags: %d, num_ch: %d, num_ndp_instances: %d"),
17827 fixed_params->flags, fixed_params->num_channels,
17828 fixed_params->num_ndp_instances);
17829
17830 ind->vdev =
17831 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17832 fixed_params->vdev_id,
17833 WLAN_NAN_ID);
17834 if (!ind->vdev) {
17835 WMI_LOGE("vdev is null");
17836 return QDF_STATUS_E_INVAL;
17837 }
17838
17839 ind->flags = fixed_params->flags;
17840 ind->num_channels = fixed_params->num_channels;
17841 ind->num_ndp_instances = fixed_params->num_ndp_instances;
17842 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_macaddr,
17843 ind->peer_addr.bytes);
17844
17845 if (ind->num_ndp_instances > NDP_NUM_INSTANCE_ID) {
17846 WMI_LOGE(FL("uint32 overflow"));
17847 wlan_objmgr_vdev_release_ref(ind->vdev, WLAN_NAN_ID);
17848 return QDF_STATUS_E_INVAL;
17849 }
17850
17851 qdf_mem_copy(ind->ndp_instances, event->ndp_instance_list,
17852 sizeof(uint32_t) * ind->num_ndp_instances);
17853
17854 if (ind->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
17855 WMI_LOGE(FL("too many channels"));
17856 ind->num_channels = NAN_CH_INFO_MAX_CHANNELS;
17857 }
17858 for (i = 0; i < ind->num_channels; i++) {
17859 ind->ch[i].channel = event->ndl_channel_list[i].mhz;
17860 ind->ch[i].nss = event->nss_list[i];
17861 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]);
17862 ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
17863 ch_mode);
17864 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
17865 ind->ch[i].channel,
17866 ind->ch[i].ch_width,
17867 ind->ch[i].nss);
17868 }
17869
17870 for (i = 0; i < fixed_params->num_ndp_instances; i++)
17871 WMI_LOGD(FL("instance_id[%d]: %d"),
17872 i, event->ndp_instance_list[i]);
17873
17874 return QDF_STATUS_SUCCESS;
17875}
17876
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017877#endif
17878
Naveen Rawat963ee942018-04-13 16:38:36 -070017879#ifdef QCA_SUPPORT_CP_STATS
17880/**
17881 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
17882 * @wmi_handle: wma handle
17883 * @evt_buf: event buffer
17884 * @out_buff: buffer to populated after stats extraction
17885 *
17886 * Return: status of operation
17887 */
17888static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
17889 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
17890{
17891 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17892 wmi_congestion_stats *congestion_stats;
17893
17894 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
17895 congestion_stats = param_buf->congestion_stats;
17896 if (!congestion_stats) {
17897 WMI_LOGD("%s: no cca stats in event buffer", __func__);
17898 return QDF_STATUS_E_INVAL;
17899 }
17900
17901 out_buff->vdev_id = congestion_stats->vdev_id;
17902 out_buff->congestion = congestion_stats->congestion;
17903
17904 WMI_LOGD("%s: cca stats event processed", __func__);
17905 return QDF_STATUS_SUCCESS;
17906}
17907#endif /* QCA_SUPPORT_CP_STATS */
17908
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017909/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017910 * save_service_bitmap_tlv() - save service bitmap
17911 * @wmi_handle: wmi handle
17912 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017913 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017914 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017915 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017916 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017917static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017918QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017919 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017920{
17921 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017922 struct wmi_soc *soc = wmi_handle->soc;
17923
Govind Singhe7f2f342016-05-23 12:12:52 +053017924 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17925
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017926 /* If it is already allocated, use that buffer. This can happen
17927 * during target stop/start scenarios where host allocation is skipped.
17928 */
17929 if (!soc->wmi_service_bitmap) {
17930 soc->wmi_service_bitmap =
17931 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17932 if (!soc->wmi_service_bitmap) {
17933 WMI_LOGE("Failed memory allocation for service bitmap");
17934 return QDF_STATUS_E_NOMEM;
17935 }
17936 }
17937
17938 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017939 param_buf->wmi_service_bitmap,
17940 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017941
17942 if (bitmap_buf)
17943 qdf_mem_copy(bitmap_buf,
17944 param_buf->wmi_service_bitmap,
17945 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017946
17947 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017948}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017949
17950/**
17951 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17952 * @wmi_handle: wmi handle
17953 * @param evt_buf: pointer to event buffer
17954 * @param bitmap_buf: bitmap buffer, for converged legacy support
17955 *
17956 * Return: QDF_STATUS
17957 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017958static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017959QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017960 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017961{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017962 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17963 wmi_service_available_event_fixed_param *ev;
17964 struct wmi_soc *soc = wmi_handle->soc;
17965
17966 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17967
17968 ev = param_buf->fixed_param;
17969
17970 /* If it is already allocated, use that buffer. This can happen
17971 * during target stop/start scenarios where host allocation is skipped.
17972 */
17973 if (!soc->wmi_ext_service_bitmap) {
17974 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17975 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17976 if (!soc->wmi_ext_service_bitmap) {
17977 WMI_LOGE("Failed memory allocation for service bitmap");
17978 return QDF_STATUS_E_NOMEM;
17979 }
17980 }
17981
17982 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17983 ev->wmi_service_segment_bitmap,
17984 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017985
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017986 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17987 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17988 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17989
Rajeev Kumar77901472017-02-12 02:12:17 -080017990 if (bitmap_buf)
17991 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017992 soc->wmi_ext_service_bitmap,
17993 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017994
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017995 return QDF_STATUS_SUCCESS;
17996}
Govind Singhe7f2f342016-05-23 12:12:52 +053017997/**
17998 * is_service_enabled_tlv() - Check if service enabled
17999 * @param wmi_handle: wmi handle
18000 * @param service_id: service identifier
18001 *
18002 * Return: 1 enabled, 0 disabled
18003 */
Govind Singhe7f2f342016-05-23 12:12:52 +053018004static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
18005 uint32_t service_id)
18006{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053018007 struct wmi_soc *soc = wmi_handle->soc;
18008
18009 if (!soc->wmi_service_bitmap) {
18010 WMI_LOGE("WMI service bit map is not saved yet\n");
18011 return false;
18012 }
18013
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053018014 /* if wmi_service_enabled was received with extended bitmap,
18015 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053018016 */
18017 if (soc->wmi_ext_service_bitmap)
18018 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
18019 soc->wmi_ext_service_bitmap,
18020 service_id);
18021
18022 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
18023 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018024}
Govind Singhe7f2f342016-05-23 12:12:52 +053018025
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053018026static inline void copy_ht_cap_info(uint32_t ev_target_cap,
18027 struct wlan_psoc_target_capability_info *cap)
18028{
18029 /* except LDPC all flags are common betwen legacy and here
18030 * also IBFEER is not defined for TLV
18031 */
18032 cap->ht_cap_info |= ev_target_cap & (
18033 WMI_HT_CAP_ENABLED
18034 | WMI_HT_CAP_HT20_SGI
18035 | WMI_HT_CAP_DYNAMIC_SMPS
18036 | WMI_HT_CAP_TX_STBC
18037 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
18038 | WMI_HT_CAP_RX_STBC
18039 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
18040 | WMI_HT_CAP_LDPC
18041 | WMI_HT_CAP_L_SIG_TXOP_PROT
18042 | WMI_HT_CAP_MPDU_DENSITY
18043 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
18044 | WMI_HT_CAP_HT40_SGI);
18045 if (ev_target_cap & WMI_HT_CAP_LDPC)
18046 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
18047 WMI_HOST_HT_CAP_TX_LDPC;
18048}
Govind Singhe7f2f342016-05-23 12:12:52 +053018049/**
18050 * extract_service_ready_tlv() - extract service ready event
18051 * @wmi_handle: wmi handle
18052 * @param evt_buf: pointer to received event buffer
18053 * @param cap: pointer to hold target capability information extracted from even
18054 *
18055 * Return: QDF_STATUS_SUCCESS for success or error code
18056 */
18057static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018058 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053018059{
18060 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18061 wmi_service_ready_event_fixed_param *ev;
18062
18063
18064 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18065
18066 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18067 if (!ev) {
18068 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18069 return QDF_STATUS_E_FAILURE;
18070 }
18071
18072 cap->phy_capability = ev->phy_capability;
18073 cap->max_frag_entry = ev->max_frag_entry;
18074 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053018075 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053018076 cap->vht_cap_info = ev->vht_cap_info;
18077 cap->vht_supp_mcs = ev->vht_supp_mcs;
18078 cap->hw_min_tx_power = ev->hw_min_tx_power;
18079 cap->hw_max_tx_power = ev->hw_max_tx_power;
18080 cap->sys_cap_info = ev->sys_cap_info;
18081 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
18082 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
18083 cap->max_num_scan_channels = ev->max_num_scan_channels;
18084 cap->max_supported_macs = ev->max_supported_macs;
18085 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
18086 cap->txrx_chainmask = ev->txrx_chainmask;
18087 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
18088 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053018089 cap->fw_version = ev->fw_build_vers;
18090 /* fw_version_1 is not available in TLV. */
18091 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053018092
18093 return QDF_STATUS_SUCCESS;
18094}
18095
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018096/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
18097 * to host internal WMI_HOST_REGDMN_MODE values.
18098 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
18099 * host currently. Add this in the future if required.
18100 * 11AX (Phase II) : 11ax related values are not currently
18101 * advertised separately by FW. As part of phase II regulatory bring-up,
18102 * finalize the advertisement mechanism.
18103 * @target_wireless_mode: target wireless mode received in message
18104 *
18105 * Return: returns the host internal wireless mode.
18106 */
18107static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
18108{
18109
18110 uint32_t wireless_modes = 0;
18111
18112 if (target_wireless_mode & REGDMN_MODE_11A)
18113 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
18114
18115 if (target_wireless_mode & REGDMN_MODE_TURBO)
18116 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
18117
18118 if (target_wireless_mode & REGDMN_MODE_11B)
18119 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
18120
18121 if (target_wireless_mode & REGDMN_MODE_PUREG)
18122 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
18123
18124 if (target_wireless_mode & REGDMN_MODE_11G)
18125 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
18126
18127 if (target_wireless_mode & REGDMN_MODE_108G)
18128 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
18129
18130 if (target_wireless_mode & REGDMN_MODE_108A)
18131 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
18132
18133 if (target_wireless_mode & REGDMN_MODE_XR)
18134 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
18135
18136 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
18137 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
18138
18139 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
18140 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
18141
18142 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
18143 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
18144
18145 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
18146 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
18147
18148 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
18149 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
18150
18151 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
18152 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
18153
18154 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
18155 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
18156
18157 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
18158 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
18159
18160 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
18161 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
18162
18163 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
18164 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
18165
18166 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
18167 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
18168
18169 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
18170 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
18171
18172 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
18173 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
18174
18175 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
18176 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
18177
18178 return wireless_modes;
18179}
18180
Govind Singhe7f2f342016-05-23 12:12:52 +053018181/**
18182 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
18183 * @wmi_handle: wmi handle
18184 * @param evt_buf: Pointer to event buffer
18185 * @param cap: pointer to hold HAL reg capabilities
18186 *
18187 * Return: QDF_STATUS_SUCCESS for success or error code
18188 */
18189static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018190 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053018191{
18192 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18193
18194 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18195
18196 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
18197 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080018198 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053018199
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018200 cap->wireless_modes = convert_wireless_modes_tlv(
18201 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053018202
Govind Singhe7f2f342016-05-23 12:12:52 +053018203 return QDF_STATUS_SUCCESS;
18204}
18205
18206/**
18207 * extract_host_mem_req_tlv() - Extract host memory request event
18208 * @wmi_handle: wmi handle
18209 * @param evt_buf: pointer to event buffer
18210 * @param num_entries: pointer to hold number of entries requested
18211 *
18212 * Return: Number of entries requested
18213 */
18214static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
18215 void *evt_buf, uint8_t *num_entries)
18216{
18217 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18218 wmi_service_ready_event_fixed_param *ev;
18219
18220 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18221
18222 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18223 if (!ev) {
18224 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18225 return NULL;
18226 }
18227
18228 *num_entries = ev->num_mem_reqs;
18229
18230 return (host_mem_req *)param_buf->mem_reqs;
18231}
18232
18233/**
18234 * save_fw_version_in_service_ready_tlv() - Save fw version in service
18235 * ready function
18236 * @wmi_handle: wmi handle
18237 * @param evt_buf: pointer to event buffer
18238 *
18239 * Return: QDF_STATUS_SUCCESS for success or error code
18240 */
18241static QDF_STATUS
18242save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
18243{
18244 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18245 wmi_service_ready_event_fixed_param *ev;
18246
18247
18248 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18249
18250 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18251 if (!ev) {
18252 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18253 return QDF_STATUS_E_FAILURE;
18254 }
18255
18256 /*Save fw version from service ready message */
18257 /*This will be used while sending INIT message */
18258 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
18259 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053018260
Govind Singhe7f2f342016-05-23 12:12:52 +053018261 return QDF_STATUS_SUCCESS;
18262}
18263
18264/**
18265 * ready_extract_init_status_tlv() - Extract init status from ready event
18266 * @wmi_handle: wmi handle
18267 * @param evt_buf: Pointer to event buffer
18268 *
18269 * Return: ready status
18270 */
18271static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
18272 void *evt_buf)
18273{
18274 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18275 wmi_ready_event_fixed_param *ev = NULL;
18276
Govind Singhe7f2f342016-05-23 12:12:52 +053018277 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18278 ev = param_buf->fixed_param;
18279
18280 qdf_print("%s:%d\n", __func__, ev->status);
18281
18282 return ev->status;
18283}
18284
18285/**
18286 * ready_extract_mac_addr_tlv() - extract mac address from ready event
18287 * @wmi_handle: wmi handle
18288 * @param evt_buf: pointer to event buffer
18289 * @param macaddr: Pointer to hold MAC address
18290 *
18291 * Return: QDF_STATUS_SUCCESS for success or error code
18292 */
18293static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
18294 void *evt_buf, uint8_t *macaddr)
18295{
18296 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18297 wmi_ready_event_fixed_param *ev = NULL;
18298
18299
18300 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18301 ev = param_buf->fixed_param;
18302
18303 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
18304
18305 return QDF_STATUS_SUCCESS;
18306}
18307
18308/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070018309 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
18310 * @wmi_handle: wmi handle
18311 * @param evt_buf: pointer to event buffer
18312 * @param macaddr: Pointer to hold number of MAC addresses
18313 *
18314 * Return: Pointer to addr list
18315 */
18316static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
18317 void *evt_buf, uint8_t *num_mac)
18318{
18319 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18320 wmi_ready_event_fixed_param *ev = NULL;
18321
18322 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18323 ev = param_buf->fixed_param;
18324
18325 *num_mac = ev->num_extra_mac_addr;
18326
18327 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
18328}
18329
18330/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018331 * extract_ready_params_tlv() - Extract data from ready event apart from
18332 * status, macaddr and version.
18333 * @wmi_handle: Pointer to WMI handle.
18334 * @evt_buf: Pointer to Ready event buffer.
18335 * @ev_param: Pointer to host defined struct to copy the data from event.
18336 *
18337 * Return: QDF_STATUS_SUCCESS on success.
18338 */
18339static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
18340 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
18341{
18342 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18343 wmi_ready_event_fixed_param *ev = NULL;
18344
18345 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18346 ev = param_buf->fixed_param;
18347
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018348 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018349 ev_param->num_dscp_table = ev->num_dscp_table;
18350 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
18351 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018352 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018353 /* Agile_cap in ready event is not supported in TLV target */
18354 ev_param->agile_capability = false;
18355
18356 return QDF_STATUS_SUCCESS;
18357}
18358
18359/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018360 * extract_dbglog_data_len_tlv() - extract debuglog data length
18361 * @wmi_handle: wmi handle
18362 * @param evt_buf: pointer to event buffer
18363 *
18364 * Return: length
18365 */
18366static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080018367 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053018368{
18369 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
18370
18371 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
18372
18373 *len = param_buf->num_bufp;
18374
18375 return param_buf->bufp;
18376}
18377
18378/**
18379 * extract_vdev_start_resp_tlv() - extract vdev start response
18380 * @wmi_handle: wmi handle
18381 * @param evt_buf: pointer to event buffer
18382 * @param vdev_rsp: Pointer to hold vdev response
18383 *
18384 * Return: QDF_STATUS_SUCCESS for success or error code
18385 */
18386static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
18387 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
18388{
18389 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
18390 wmi_vdev_start_response_event_fixed_param *ev;
18391
18392 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
18393 if (!param_buf) {
18394 qdf_print("Invalid start response event buffer\n");
18395 return QDF_STATUS_E_INVAL;
18396 }
18397
18398 ev = param_buf->fixed_param;
18399 if (!ev) {
18400 qdf_print("Invalid start response event buffer\n");
18401 return QDF_STATUS_E_INVAL;
18402 }
18403
18404 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
18405
18406 vdev_rsp->vdev_id = ev->vdev_id;
18407 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070018408 switch (ev->resp_type) {
18409 case WMI_VDEV_START_RESP_EVENT:
18410 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
18411 break;
18412 case WMI_VDEV_RESTART_RESP_EVENT:
18413 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
18414 break;
18415 default:
18416 qdf_print("Invalid start response event buffer\n");
18417 break;
18418 };
Govind Singhe7f2f342016-05-23 12:12:52 +053018419 vdev_rsp->status = ev->status;
18420 vdev_rsp->chain_mask = ev->chain_mask;
18421 vdev_rsp->smps_mode = ev->smps_mode;
18422 vdev_rsp->mac_id = ev->mac_id;
18423 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
18424 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
18425
18426 return QDF_STATUS_SUCCESS;
18427}
18428
18429/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053018430 * extract_vdev_delete_resp_tlv() - extract vdev delete response
18431 * @wmi_handle: wmi handle
18432 * @param evt_buf: pointer to event buffer
18433 * @param delete_rsp: Pointer to hold vdev delete response
18434 *
18435 * Return: QDF_STATUS_SUCCESS for success or error code
18436 */
18437static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
18438 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
18439{
18440 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
18441 wmi_vdev_delete_resp_event_fixed_param *ev;
18442
18443 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
18444 if (!param_buf) {
18445 WMI_LOGE("Invalid vdev delete response event buffer\n");
18446 return QDF_STATUS_E_INVAL;
18447 }
18448
18449 ev = param_buf->fixed_param;
18450 if (!ev) {
18451 WMI_LOGE("Invalid vdev delete response event\n");
18452 return QDF_STATUS_E_INVAL;
18453 }
18454
18455 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
18456 delete_rsp->vdev_id = ev->vdev_id;
18457
18458 return QDF_STATUS_SUCCESS;
18459}
18460
18461
18462/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018463 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053018464 * @wmi_handle: wmi handle
18465 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018466 * @param num_vdevs: Pointer to hold num vdev
18467 *
18468 * Return: QDF_STATUS_SUCCESS for success or error code
18469 */
18470static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18471 void *evt_buf, uint32_t *num_vdevs)
18472{
18473 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18474 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
18475 uint32_t vdev_map;
18476
18477 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
18478 if (!param_buf) {
18479 qdf_print("Invalid tbtt update ext event buffer\n");
18480 return QDF_STATUS_E_INVAL;
18481 }
18482 tbtt_offset_event = param_buf->fixed_param;
18483 vdev_map = tbtt_offset_event->vdev_map;
18484 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18485
18486 return QDF_STATUS_SUCCESS;
18487}
18488
18489/**
18490 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
18491 * @wmi_handle: wmi handle
18492 * @param evt_buf: pointer to event buffer
18493 * @param num_vdevs: Pointer to hold num vdev
18494 *
18495 * Return: QDF_STATUS_SUCCESS for success or error code
18496 */
18497static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18498 void *evt_buf, uint32_t *num_vdevs)
18499{
18500 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18501 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
18502
18503 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18504 if (!param_buf) {
18505 qdf_print("Invalid tbtt update ext event buffer\n");
18506 return QDF_STATUS_E_INVAL;
18507 }
18508 tbtt_offset_ext_event = param_buf->fixed_param;
18509
18510 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
18511
18512 return QDF_STATUS_SUCCESS;
18513}
18514
18515/**
18516 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
18517 * @wmi_handle: wmi handle
18518 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070018519 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018520 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053018521 *
18522 * Return: QDF_STATUS_SUCCESS for success or error code
18523 */
18524static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018525 void *evt_buf, uint8_t idx,
18526 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018527{
18528 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18529 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018530 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018531
18532 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
18533 if (!param_buf) {
18534 qdf_print("Invalid tbtt update event buffer\n");
18535 return QDF_STATUS_E_INVAL;
18536 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018537
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018538 tbtt_offset_event = param_buf->fixed_param;
18539 vdev_map = tbtt_offset_event->vdev_map;
18540 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
18541 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
18542 return QDF_STATUS_E_INVAL;
18543 tbtt_param->tbttoffset =
18544 param_buf->tbttoffset_list[tbtt_param->vdev_id];
18545
18546 return QDF_STATUS_SUCCESS;
18547}
18548
18549/**
18550 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
18551 * @wmi_handle: wmi handle
18552 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070018553 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018554 * @param tbtt_param: Pointer to tbttoffset event param
18555 *
18556 * Return: QDF_STATUS_SUCCESS for success or error code
18557 */
18558static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
18559 void *evt_buf, uint8_t idx,
18560 struct tbttoffset_params *tbtt_param)
18561{
18562 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18563 wmi_tbtt_offset_info *tbtt_offset_info;
18564
18565 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18566 if (!param_buf) {
18567 qdf_print("Invalid tbtt update event buffer\n");
18568 return QDF_STATUS_E_INVAL;
18569 }
18570 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
18571
18572 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
18573 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053018574
18575 return QDF_STATUS_SUCCESS;
18576}
18577
18578/**
18579 * extract_mgmt_rx_params_tlv() - extract management rx params from event
18580 * @wmi_handle: wmi handle
18581 * @param evt_buf: pointer to event buffer
18582 * @param hdr: Pointer to hold header
18583 * @param bufp: Pointer to hold pointer to rx param buffer
18584 *
18585 * Return: QDF_STATUS_SUCCESS for success or error code
18586 */
18587static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053018588 void *evt_buf, struct mgmt_rx_event_params *hdr,
18589 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053018590{
18591 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
18592 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018593 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053018594
18595 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
18596 if (!param_tlvs) {
18597 WMI_LOGE("Get NULL point message from FW");
18598 return QDF_STATUS_E_INVAL;
18599 }
18600
18601 ev_hdr = param_tlvs->hdr;
18602 if (!hdr) {
18603 WMI_LOGE("Rx event is NULL");
18604 return QDF_STATUS_E_INVAL;
18605 }
18606
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018607 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18608 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018609
18610 hdr->channel = ev_hdr->channel;
18611 hdr->snr = ev_hdr->snr;
18612 hdr->rate = ev_hdr->rate;
18613 hdr->phy_mode = ev_hdr->phy_mode;
18614 hdr->buf_len = ev_hdr->buf_len;
18615 hdr->status = ev_hdr->status;
18616 hdr->flags = ev_hdr->flags;
18617 hdr->rssi = ev_hdr->rssi;
18618 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018619 for (i = 0; i < ATH_MAX_ANTENNA; i++)
18620 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053018621
18622 *bufp = param_tlvs->bufp;
18623
18624 return QDF_STATUS_SUCCESS;
18625}
18626
18627/**
18628 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
18629 * @wmi_handle: wmi handle
18630 * @param evt_buf: pointer to event buffer
18631 * @param vdev_id: Pointer to hold vdev identifier
18632 *
18633 * Return: QDF_STATUS_SUCCESS for success or error code
18634 */
18635static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
18636 void *evt_buf, uint32_t *vdev_id)
18637{
18638 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
18639 wmi_vdev_stopped_event_fixed_param *resp_event;
18640
18641 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
18642 if (!param_buf) {
18643 WMI_LOGE("Invalid event buffer");
18644 return QDF_STATUS_E_INVAL;
18645 }
18646 resp_event = param_buf->fixed_param;
18647 *vdev_id = resp_event->vdev_id;
18648
18649 return QDF_STATUS_SUCCESS;
18650}
18651
18652/**
18653 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
18654 * @wmi_handle: wmi handle
18655 * @param evt_buf: pointer to event buffer
18656 * @param param: Pointer to hold roam param
18657 *
18658 * Return: QDF_STATUS_SUCCESS for success or error code
18659 */
18660static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
18661 void *evt_buf, wmi_host_roam_event *param)
18662{
18663 WMI_ROAM_EVENTID_param_tlvs *param_buf;
18664 wmi_roam_event_fixed_param *evt;
18665
18666 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18667 if (!param_buf) {
18668 WMI_LOGE("Invalid roam event buffer");
18669 return QDF_STATUS_E_INVAL;
18670 }
18671
18672 evt = param_buf->fixed_param;
18673 qdf_mem_zero(param, sizeof(*param));
18674
18675 param->vdev_id = evt->vdev_id;
18676 param->reason = evt->reason;
18677 param->rssi = evt->rssi;
18678
18679 return QDF_STATUS_SUCCESS;
18680}
18681
18682/**
18683 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18684 * @wmi_handle: wmi handle
18685 * @param evt_buf: pointer to event buffer
18686 * @param param: Pointer to hold vdev scan param
18687 *
18688 * Return: QDF_STATUS_SUCCESS for success or error code
18689 */
18690static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018691 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018692{
18693 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18694 wmi_scan_event_fixed_param *evt = NULL;
18695
18696 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18697 evt = param_buf->fixed_param;
18698
18699 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018700
Govind Singhe7f2f342016-05-23 12:12:52 +053018701 switch (evt->event) {
18702 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018703 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018704 break;
18705 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018706 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018707 break;
18708 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018709 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018710 break;
18711 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018712 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018713 break;
18714 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018715 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018716 break;
18717 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018718 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018719 break;
18720 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018721 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018722 break;
18723 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018724 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018725 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018726 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018727 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018728 break;
18729 case WMI_SCAN_EVENT_MAX:
18730 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018731 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018732 break;
18733 };
18734
18735 switch (evt->reason) {
18736 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018737 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018738 break;
18739 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018740 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018741 break;
18742 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018743 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018744 break;
18745 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018746 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018747 break;
18748 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018749 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018750 break;
18751 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018752 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018753 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018754 case WMI_SCAN_REASON_SUSPENDED:
18755 param->reason = SCAN_REASON_SUSPENDED;
18756 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018757 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018758 param->reason = SCAN_REASON_MAX;
18759 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018760 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018761 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018762 break;
18763 };
18764
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018765 param->chan_freq = evt->channel_freq;
18766 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018767 param->scan_id = evt->scan_id;
18768 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018769 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018770
18771 return QDF_STATUS_SUCCESS;
18772}
18773
Frank Liu3d5e9992017-03-15 17:51:43 +080018774#ifdef CONVERGED_TDLS_ENABLE
18775/**
18776 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18777 * @wmi_handle: wmi handle
18778 * @param evt_buf: pointer to event buffer
18779 * @param param: Pointer to hold vdev tdls param
18780 *
18781 * Return: QDF_STATUS_SUCCESS for success or error code
18782 */
18783static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18784 void *evt_buf, struct tdls_event_info *param)
18785{
18786 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18787 wmi_tdls_peer_event_fixed_param *evt;
18788
18789 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18790 if (!param_buf) {
18791 WMI_LOGE("%s: NULL param_buf", __func__);
18792 return QDF_STATUS_E_NULL_VALUE;
18793 }
18794
18795 evt = param_buf->fixed_param;
18796
18797 qdf_mem_zero(param, sizeof(*param));
18798
18799 param->vdev_id = evt->vdev_id;
18800 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18801 param->peermac.bytes);
18802 switch (evt->peer_status) {
18803 case WMI_TDLS_SHOULD_DISCOVER:
18804 param->message_type = TDLS_SHOULD_DISCOVER;
18805 break;
18806 case WMI_TDLS_SHOULD_TEARDOWN:
18807 param->message_type = TDLS_SHOULD_TEARDOWN;
18808 break;
18809 case WMI_TDLS_PEER_DISCONNECTED:
18810 param->message_type = TDLS_PEER_DISCONNECTED;
18811 break;
18812 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18813 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18814 break;
18815 default:
18816 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18817 __func__, evt->peer_status);
18818 return QDF_STATUS_E_INVAL;
18819 };
18820
18821 switch (evt->peer_reason) {
18822 case WMI_TDLS_TEARDOWN_REASON_TX:
18823 param->peer_reason = TDLS_TEARDOWN_TX;
18824 break;
18825 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18826 param->peer_reason = TDLS_TEARDOWN_RSSI;
18827 break;
18828 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18829 param->peer_reason = TDLS_TEARDOWN_SCAN;
18830 break;
18831 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18832 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18833 break;
18834 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18835 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18836 break;
18837 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18838 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18839 break;
18840 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18841 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18842 break;
18843 case WMI_TDLS_ENTER_BUF_STA:
18844 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18845 break;
18846 case WMI_TDLS_EXIT_BUF_STA:
18847 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18848 break;
18849 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18850 param->peer_reason = TDLS_ENTER_BT_BUSY;
18851 break;
18852 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18853 param->peer_reason = TDLS_EXIT_BT_BUSY;
18854 break;
18855 case WMI_TDLS_SCAN_STARTED_EVENT:
18856 param->peer_reason = TDLS_SCAN_STARTED;
18857 break;
18858 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18859 param->peer_reason = TDLS_SCAN_COMPLETED;
18860 break;
18861
18862 default:
18863 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18864 __func__, evt->peer_reason, evt->peer_status);
18865 return QDF_STATUS_E_INVAL;
18866 };
18867
18868 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18869 __func__, param->peermac.bytes, param->message_type,
18870 param->peer_reason, param->vdev_id);
18871
18872 return QDF_STATUS_SUCCESS;
18873}
18874#endif
18875
Govind Singhe7f2f342016-05-23 12:12:52 +053018876/**
18877 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18878 * @wmi_handle: wmi handle
18879 * @param evt_buf: pointer to event buffer
18880 * @param param: Pointer to hold MGMT TX completion params
18881 *
18882 * Return: QDF_STATUS_SUCCESS for success or error code
18883 */
18884static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18885 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18886{
18887 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18888 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18889
18890 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18891 evt_buf;
18892 if (!param_buf) {
18893 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18894 return QDF_STATUS_E_INVAL;
18895 }
18896 cmpl_params = param_buf->fixed_param;
18897
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018898 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18899 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018900 param->desc_id = cmpl_params->desc_id;
18901 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018902 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018903
18904 return QDF_STATUS_SUCCESS;
18905}
18906
18907/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018908 * extract_offchan_data_tx_compl_param_tlv() -
18909 * extract Offchan data tx completion event params
18910 * @wmi_handle: wmi handle
18911 * @param evt_buf: pointer to event buffer
18912 * @param param: Pointer to hold offchan data TX completion params
18913 *
18914 * Return: QDF_STATUS_SUCCESS for success or error code
18915 */
18916static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18917 wmi_unified_t wmi_handle, void *evt_buf,
18918 struct wmi_host_offchan_data_tx_compl_event *param)
18919{
18920 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18921 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18922
18923 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18924 evt_buf;
18925 if (!param_buf) {
18926 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18927 return QDF_STATUS_E_INVAL;
18928 }
18929 cmpl_params = param_buf->fixed_param;
18930
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018931 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18932 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018933 param->desc_id = cmpl_params->desc_id;
18934 param->status = cmpl_params->status;
18935
18936 return QDF_STATUS_SUCCESS;
18937}
18938
18939/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018940 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18941 * status tlv
18942 * @wmi_handle: wmi handle
18943 * @param evt_buf: pointer to event buffer
18944 * @param param: Pointer to hold csa switch count status event param
18945 *
18946 * Return: QDF_STATUS_SUCCESS for success or error code
18947 */
18948static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18949 wmi_unified_t wmi_handle,
18950 void *evt_buf,
18951 struct pdev_csa_switch_count_status *param)
18952{
18953 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18954 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18955
18956 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18957 evt_buf;
18958 if (!param_buf) {
18959 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18960 return QDF_STATUS_E_INVAL;
18961 }
18962
18963 csa_status = param_buf->fixed_param;
18964
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018965 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18966 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018967 param->current_switch_count = csa_status->current_switch_count;
18968 param->num_vdevs = csa_status->num_vdevs;
18969 param->vdev_ids = param_buf->vdev_ids;
18970
18971 return QDF_STATUS_SUCCESS;
18972}
18973
18974/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018975 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18976 * param from event
18977 * @wmi_handle: wmi handle
18978 * @param evt_buf: pointer to event buffer
18979 * @param param: Pointer to hold tpc configuration
18980 *
18981 * Return: 0 for success or error code
18982 */
18983static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18984 void *evt_buf,
18985 wmi_host_pdev_tpc_config_event *param)
18986{
18987 wmi_pdev_tpc_config_event_fixed_param *event =
18988 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18989
18990 if (!event) {
18991 WMI_LOGE("Invalid event buffer");
18992 return QDF_STATUS_E_INVAL;
18993 }
18994
18995 param->pdev_id = event->pdev_id;
18996 param->regDomain = event->regDomain;
18997 param->chanFreq = event->chanFreq;
18998 param->phyMode = event->phyMode;
18999 param->twiceAntennaReduction = event->twiceAntennaReduction;
19000 param->twiceMaxRDPower = event->twiceMaxRDPower;
19001 param->powerLimit = event->powerLimit;
19002 param->rateMax = event->rateMax;
19003 param->numTxChain = event->numTxChain;
19004 param->ctl = event->ctl;
19005 param->flags = event->flags;
19006
19007 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
19008 sizeof(param->maxRegAllowedPower));
19009 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
19010 event->maxRegAllowedPowerAGCDD,
19011 sizeof(param->maxRegAllowedPowerAGCDD));
19012 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
19013 event->maxRegAllowedPowerAGSTBC,
19014 sizeof(param->maxRegAllowedPowerAGSTBC));
19015 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
19016 event->maxRegAllowedPowerAGTXBF,
19017 sizeof(param->maxRegAllowedPowerAGTXBF));
19018 WMI_LOGD("%s:extract success", __func__);
19019
19020 return QDF_STATUS_SUCCESS;
19021}
19022
19023/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019024 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053019025 * @wmi_handle: wmi handle
19026 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019027 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053019028 *
19029 * Return: QDF_STATUS_SUCCESS for success or error code
19030 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019031static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
19032 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053019033{
19034 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
19035 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019036 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053019037
19038 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
19039 if (!param_buf) {
19040 WMI_LOGE("Invalid swba event buffer");
19041 return QDF_STATUS_E_INVAL;
19042 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019043
Govind Singhe7f2f342016-05-23 12:12:52 +053019044 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019045 *num_vdevs = swba_event->num_vdevs;
19046 if (!(*num_vdevs)) {
19047 vdev_map = swba_event->vdev_map;
19048 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
19049 }
Govind Singhe7f2f342016-05-23 12:12:52 +053019050
19051 return QDF_STATUS_SUCCESS;
19052}
19053
19054/**
19055 * extract_swba_tim_info_tlv() - extract swba tim info from event
19056 * @wmi_handle: wmi handle
19057 * @param evt_buf: pointer to event buffer
19058 * @param idx: Index to bcn info
19059 * @param tim_info: Pointer to hold tim info
19060 *
19061 * Return: QDF_STATUS_SUCCESS for success or error code
19062 */
19063static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
19064 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
19065{
19066 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
19067 wmi_tim_info *tim_info_ev;
19068
19069 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
19070 if (!param_buf) {
19071 WMI_LOGE("Invalid swba event buffer");
19072 return QDF_STATUS_E_INVAL;
19073 }
19074
19075 tim_info_ev = &param_buf->tim_info[idx];
19076
19077 tim_info->tim_len = tim_info_ev->tim_len;
19078 tim_info->tim_mcast = tim_info_ev->tim_mcast;
19079 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
19080 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
19081 tim_info->tim_changed = tim_info_ev->tim_changed;
19082 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019083 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019084
19085 return QDF_STATUS_SUCCESS;
19086}
19087
19088/**
19089 * extract_swba_noa_info_tlv() - extract swba NoA information from event
19090 * @wmi_handle: wmi handle
19091 * @param evt_buf: pointer to event buffer
19092 * @param idx: Index to bcn info
19093 * @param p2p_desc: Pointer to hold p2p NoA info
19094 *
19095 * Return: QDF_STATUS_SUCCESS for success or error code
19096 */
19097static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
19098 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
19099{
19100 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
19101 wmi_p2p_noa_info *p2p_noa_info;
19102 uint8_t i = 0;
19103
19104 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
19105 if (!param_buf) {
19106 WMI_LOGE("Invalid swba event buffer");
19107 return QDF_STATUS_E_INVAL;
19108 }
19109
19110 p2p_noa_info = &param_buf->p2p_noa_info[idx];
19111
19112 p2p_desc->modified = false;
19113 p2p_desc->num_descriptors = 0;
19114 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
19115 p2p_desc->modified = true;
19116 p2p_desc->index =
19117 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
19118 p2p_desc->oppPS =
19119 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
19120 p2p_desc->ctwindow =
19121 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
19122 p2p_desc->num_descriptors =
19123 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
19124 (p2p_noa_info);
19125 for (i = 0; i < p2p_desc->num_descriptors; i++) {
19126 p2p_desc->noa_descriptors[i].type_count =
19127 (uint8_t) p2p_noa_info->noa_descriptors[i].
19128 type_count;
19129 p2p_desc->noa_descriptors[i].duration =
19130 p2p_noa_info->noa_descriptors[i].duration;
19131 p2p_desc->noa_descriptors[i].interval =
19132 p2p_noa_info->noa_descriptors[i].interval;
19133 p2p_desc->noa_descriptors[i].start_time =
19134 p2p_noa_info->noa_descriptors[i].start_time;
19135 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019136 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019137 }
19138
19139 return QDF_STATUS_SUCCESS;
19140}
19141
Wu Gaocd3a8512017-03-13 20:17:34 +080019142#ifdef CONVERGED_P2P_ENABLE
19143/**
19144 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
19145 * @wmi_handle: wmi handle
19146 * @param evt_buf: pointer to event buffer
19147 * @param param: Pointer to hold p2p noa info
19148 *
19149 * Return: QDF_STATUS_SUCCESS for success or error code
19150 */
19151static QDF_STATUS extract_p2p_noa_ev_param_tlv(
19152 wmi_unified_t wmi_handle, void *evt_buf,
19153 struct p2p_noa_info *param)
19154{
19155 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
19156 wmi_p2p_noa_event_fixed_param *fixed_param;
19157 uint8_t i;
19158 wmi_p2p_noa_info *wmi_noa_info;
19159 uint8_t *buf_ptr;
19160 uint32_t descriptors;
19161
19162 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
19163 if (!param_tlvs) {
19164 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
19165 return QDF_STATUS_E_INVAL;
19166 }
19167
19168 if (!param) {
19169 WMI_LOGE("noa information param is null");
19170 return QDF_STATUS_E_INVAL;
19171 }
19172
19173 fixed_param = param_tlvs->fixed_param;
19174 buf_ptr = (uint8_t *) fixed_param;
19175 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
19176 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
19177
19178 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
19179 WMI_LOGE("%s: noa attr is not modified", __func__);
19180 return QDF_STATUS_E_INVAL;
19181 }
19182
19183 param->vdev_id = fixed_param->vdev_id;
19184 param->index =
19185 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
19186 param->opps_ps =
19187 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
19188 param->ct_window =
19189 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
19190 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
19191 param->num_desc = (uint8_t) descriptors;
19192
19193 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
19194 param->index, param->opps_ps, param->ct_window,
19195 param->num_desc);
19196 for (i = 0; i < param->num_desc; i++) {
19197 param->noa_desc[i].type_count =
19198 (uint8_t) wmi_noa_info->noa_descriptors[i].
19199 type_count;
19200 param->noa_desc[i].duration =
19201 wmi_noa_info->noa_descriptors[i].duration;
19202 param->noa_desc[i].interval =
19203 wmi_noa_info->noa_descriptors[i].interval;
19204 param->noa_desc[i].start_time =
19205 wmi_noa_info->noa_descriptors[i].start_time;
19206 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
19207 __func__, i, param->noa_desc[i].type_count,
19208 param->noa_desc[i].duration,
19209 param->noa_desc[i].interval,
19210 param->noa_desc[i].start_time);
19211 }
19212
19213 return QDF_STATUS_SUCCESS;
19214}
19215
19216/**
19217 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
19218 * information from event
19219 * @wmi_handle: wmi handle
19220 * @param evt_buf: pointer to event buffer
19221 * @param param: Pointer to hold p2p lo stop event information
19222 *
19223 * Return: QDF_STATUS_SUCCESS for success or error code
19224 */
19225static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
19226 wmi_unified_t wmi_handle, void *evt_buf,
19227 struct p2p_lo_event *param)
19228{
19229 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
19230 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
19231
19232 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
19233 evt_buf;
19234 if (!param_tlvs) {
19235 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
19236 return QDF_STATUS_E_INVAL;
19237 }
19238
19239 if (!param) {
19240 WMI_LOGE("lo stop event param is null");
19241 return QDF_STATUS_E_INVAL;
19242 }
19243
19244 lo_param = param_tlvs->fixed_param;
19245 param->vdev_id = lo_param->vdev_id;
19246 param->reason_code = lo_param->reason;
19247 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
19248 param->vdev_id, param->reason_code);
19249
19250 return QDF_STATUS_SUCCESS;
19251}
19252#endif /* End of CONVERGED_P2P_ENABLE */
19253
Govind Singhe7f2f342016-05-23 12:12:52 +053019254/**
19255 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
19256 * @wmi_handle: wmi handle
19257 * @param evt_buf: pointer to event buffer
19258 * @param ev: Pointer to hold peer param
19259 *
19260 * Return: QDF_STATUS_SUCCESS for success or error code
19261 */
19262static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
19263 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
19264{
19265 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
19266 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
19267
19268 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
19269 kickout_event = param_buf->fixed_param;
19270
19271 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
19272 ev->peer_macaddr);
19273
19274 ev->reason = kickout_event->reason;
19275 ev->rssi = kickout_event->rssi;
19276
19277 return QDF_STATUS_SUCCESS;
19278}
19279
19280/**
19281 * extract_all_stats_counts_tlv() - extract all stats count from event
19282 * @wmi_handle: wmi handle
19283 * @param evt_buf: pointer to event buffer
19284 * @param stats_param: Pointer to hold stats count
19285 *
19286 * Return: QDF_STATUS_SUCCESS for success or error code
19287 */
19288static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
19289 void *evt_buf, wmi_host_stats_event *stats_param)
19290{
Govind Singhe7f2f342016-05-23 12:12:52 +053019291 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019292 wmi_per_chain_rssi_stats *rssi_event;
19293 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053019294
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019295 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053019296 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053019297 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019298 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053019299 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019300 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053019301 return QDF_STATUS_E_FAILURE;
19302 }
19303
19304 switch (ev->stats_id) {
19305 case WMI_REQUEST_PEER_STAT:
19306 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
19307 break;
19308
19309 case WMI_REQUEST_AP_STAT:
19310 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
19311 break;
19312
19313 case WMI_REQUEST_PDEV_STAT:
19314 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
19315 break;
19316
19317 case WMI_REQUEST_VDEV_STAT:
19318 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
19319 break;
19320
19321 case WMI_REQUEST_BCNFLT_STAT:
19322 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
19323 break;
19324
19325 case WMI_REQUEST_VDEV_RATE_STAT:
19326 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
19327 break;
19328
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019329 case WMI_REQUEST_BCN_STAT:
19330 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
19331 break;
19332
Govind Singhe7f2f342016-05-23 12:12:52 +053019333 default:
19334 stats_param->stats_id = 0;
19335 break;
19336
19337 }
19338
19339 stats_param->num_pdev_stats = ev->num_pdev_stats;
19340 stats_param->num_pdev_ext_stats = 0;
19341 stats_param->num_vdev_stats = ev->num_vdev_stats;
19342 stats_param->num_peer_stats = ev->num_peer_stats;
19343 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
19344 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019345 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053019346 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19347 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053019348
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019349 /* if chain_stats is not populated */
19350 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
19351 return QDF_STATUS_SUCCESS;
19352
19353 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
19354 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
19355 return QDF_STATUS_SUCCESS;
19356
19357 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
19358 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
19359 return QDF_STATUS_SUCCESS;
19360
19361 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
19362
Govind Singhe7f2f342016-05-23 12:12:52 +053019363 return QDF_STATUS_SUCCESS;
19364}
19365
19366/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019367 * extract_pdev_tx_stats() - extract pdev tx stats from event
19368 */
19369static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
19370{
19371 /* Tx Stats */
19372 tx->comp_queued = tx_stats->comp_queued;
19373 tx->comp_delivered = tx_stats->comp_delivered;
19374 tx->msdu_enqued = tx_stats->msdu_enqued;
19375 tx->mpdu_enqued = tx_stats->mpdu_enqued;
19376 tx->wmm_drop = tx_stats->wmm_drop;
19377 tx->local_enqued = tx_stats->local_enqued;
19378 tx->local_freed = tx_stats->local_freed;
19379 tx->hw_queued = tx_stats->hw_queued;
19380 tx->hw_reaped = tx_stats->hw_reaped;
19381 tx->underrun = tx_stats->underrun;
19382 tx->tx_abort = tx_stats->tx_abort;
19383 tx->mpdus_requed = tx_stats->mpdus_requed;
19384 tx->data_rc = tx_stats->data_rc;
19385 tx->self_triggers = tx_stats->self_triggers;
19386 tx->sw_retry_failure = tx_stats->sw_retry_failure;
19387 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
19388 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
19389 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
19390 tx->pdev_resets = tx_stats->pdev_resets;
19391 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
19392 tx->phy_underrun = tx_stats->phy_underrun;
19393 tx->txop_ovf = tx_stats->txop_ovf;
19394
19395 return;
19396}
19397
19398
19399/**
19400 * extract_pdev_rx_stats() - extract pdev rx stats from event
19401 */
19402static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
19403{
19404 /* Rx Stats */
19405 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
19406 rx->status_rcvd = rx_stats->status_rcvd;
19407 rx->r0_frags = rx_stats->r0_frags;
19408 rx->r1_frags = rx_stats->r1_frags;
19409 rx->r2_frags = rx_stats->r2_frags;
19410 /* Only TLV */
19411 rx->r3_frags = 0;
19412 rx->htt_msdus = rx_stats->htt_msdus;
19413 rx->htt_mpdus = rx_stats->htt_mpdus;
19414 rx->loc_msdus = rx_stats->loc_msdus;
19415 rx->loc_mpdus = rx_stats->loc_mpdus;
19416 rx->oversize_amsdu = rx_stats->oversize_amsdu;
19417 rx->phy_errs = rx_stats->phy_errs;
19418 rx->phy_err_drop = rx_stats->phy_err_drop;
19419 rx->mpdu_errs = rx_stats->mpdu_errs;
19420
19421 return;
19422}
19423
19424/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019425 * extract_pdev_stats_tlv() - extract pdev stats from event
19426 * @wmi_handle: wmi handle
19427 * @param evt_buf: pointer to event buffer
19428 * @param index: Index into pdev stats
19429 * @param pdev_stats: Pointer to hold pdev stats
19430 *
19431 * Return: QDF_STATUS_SUCCESS for success or error code
19432 */
19433static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
19434 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
19435{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019436 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19437 wmi_stats_event_fixed_param *ev_param;
19438 uint8_t *data;
19439
19440 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19441 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19442
19443 data = param_buf->data;
19444
19445 if (index < ev_param->num_pdev_stats) {
19446 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
19447 (index * sizeof(wmi_pdev_stats)));
19448
19449 pdev_stats->chan_nf = ev->chan_nf;
19450 pdev_stats->tx_frame_count = ev->tx_frame_count;
19451 pdev_stats->rx_frame_count = ev->rx_frame_count;
19452 pdev_stats->rx_clear_count = ev->rx_clear_count;
19453 pdev_stats->cycle_count = ev->cycle_count;
19454 pdev_stats->phy_err_count = ev->phy_err_count;
19455 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
19456
19457 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
19458 &(ev->pdev_stats.tx));
19459 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
19460 &(ev->pdev_stats.rx));
19461 }
19462
Govind Singhe7f2f342016-05-23 12:12:52 +053019463 return QDF_STATUS_SUCCESS;
19464}
19465
19466/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070019467 * extract_unit_test_tlv() - extract unit test data
19468 * @wmi_handle: wmi handle
19469 * @param evt_buf: pointer to event buffer
19470 * @param unit_test: pointer to hold unit test data
19471 * @param maxspace: Amount of space in evt_buf
19472 *
19473 * Return: QDF_STATUS_SUCCESS for success or error code
19474 */
19475static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
19476 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
19477{
19478 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
19479 wmi_unit_test_event_fixed_param *ev_param;
19480 uint32_t num_bufp;
19481 uint32_t copy_size;
19482 uint8_t *bufp;
19483
19484 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
19485 ev_param = param_buf->fixed_param;
19486 bufp = param_buf->bufp;
19487 num_bufp = param_buf->num_bufp;
19488 unit_test->vdev_id = ev_param->vdev_id;
19489 unit_test->module_id = ev_param->module_id;
19490 unit_test->diag_token = ev_param->diag_token;
19491 unit_test->flag = ev_param->flag;
19492 unit_test->payload_len = ev_param->payload_len;
19493 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
19494 ev_param->vdev_id,
19495 ev_param->module_id,
19496 ev_param->diag_token,
19497 ev_param->flag);
19498 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
19499 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
19500 bufp, num_bufp);
19501 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
19502 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
19503 unit_test->buffer_len = copy_size;
19504
19505 return QDF_STATUS_SUCCESS;
19506}
19507
19508/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019509 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
19510 * @wmi_handle: wmi handle
19511 * @param evt_buf: pointer to event buffer
19512 * @param index: Index into extended pdev stats
19513 * @param pdev_ext_stats: Pointer to hold extended pdev stats
19514 *
19515 * Return: QDF_STATUS_SUCCESS for success or error code
19516 */
19517static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
19518 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
19519{
19520 return QDF_STATUS_SUCCESS;
19521}
19522
19523/**
19524 * extract_vdev_stats_tlv() - extract vdev stats from event
19525 * @wmi_handle: wmi handle
19526 * @param evt_buf: pointer to event buffer
19527 * @param index: Index into vdev stats
19528 * @param vdev_stats: Pointer to hold vdev stats
19529 *
19530 * Return: QDF_STATUS_SUCCESS for success or error code
19531 */
19532static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
19533 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
19534{
19535 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19536 wmi_stats_event_fixed_param *ev_param;
19537 uint8_t *data;
19538
19539 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19540 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19541 data = (uint8_t *) param_buf->data;
19542
19543 if (index < ev_param->num_vdev_stats) {
19544 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
19545 ((ev_param->num_pdev_stats) *
19546 sizeof(wmi_pdev_stats)) +
19547 (index * sizeof(wmi_vdev_stats)));
19548
19549 vdev_stats->vdev_id = ev->vdev_id;
19550 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
19551 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
19552
19553 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
19554 sizeof(ev->tx_frm_cnt));
19555 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
19556 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
19557 ev->multiple_retry_cnt,
19558 sizeof(ev->multiple_retry_cnt));
19559 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
19560 sizeof(ev->fail_cnt));
19561 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
19562 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
19563 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
19564 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
19565 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
19566 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
19567 sizeof(ev->tx_rate_history));
19568 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
19569 sizeof(ev->bcn_rssi_history));
19570
19571 }
19572
19573 return QDF_STATUS_SUCCESS;
19574}
19575
19576/**
Naveen Rawatd2115722018-04-12 08:17:55 -070019577 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
19578 * buffer
19579 * @wmi_handle: wmi handle
19580 * @evt_buf: pointer to event buffer
19581 * @index: Index into vdev stats
19582 * @rssi_stats: Pointer to hold rssi stats
19583 *
19584 * Return: QDF_STATUS_SUCCESS for success or error code
19585 */
19586static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
19587 void *evt_buf, uint32_t index,
19588 struct wmi_host_per_chain_rssi_stats *rssi_stats)
19589{
19590 uint8_t *data;
19591 wmi_rssi_stats *fw_rssi_stats;
19592 wmi_per_chain_rssi_stats *rssi_event;
19593 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19594
19595 if (!evt_buf) {
19596 WMI_LOGE("evt_buf is null");
19597 return QDF_STATUS_E_NULL_VALUE;
19598 }
19599
19600 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19601 rssi_event = param_buf->chain_stats;
19602
19603 if (index >= rssi_event->num_per_chain_rssi_stats) {
19604 WMI_LOGE("invalid index");
19605 return QDF_STATUS_E_INVAL;
19606 }
19607
19608 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
19609 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
19610
19611 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
19612 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
19613 fw_rssi_stats->rssi_avg_beacon,
19614 sizeof(fw_rssi_stats->rssi_avg_beacon));
19615 qdf_mem_copy(rssi_stats->rssi_avg_data,
19616 fw_rssi_stats->rssi_avg_data,
19617 sizeof(fw_rssi_stats->rssi_avg_data));
19618 qdf_mem_copy(&rssi_stats->peer_macaddr,
19619 &fw_rssi_stats->peer_macaddr,
19620 sizeof(fw_rssi_stats->peer_macaddr));
19621
19622 return QDF_STATUS_SUCCESS;
19623}
19624
19625
19626
19627/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019628 * extract_bcn_stats_tlv() - extract bcn stats from event
19629 * @wmi_handle: wmi handle
19630 * @param evt_buf: pointer to event buffer
19631 * @param index: Index into vdev stats
19632 * @param bcn_stats: Pointer to hold bcn stats
19633 *
19634 * Return: QDF_STATUS_SUCCESS for success or error code
19635 */
19636static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
19637 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
19638{
19639 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19640 wmi_stats_event_fixed_param *ev_param;
19641 uint8_t *data;
19642
19643 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19644 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19645 data = (uint8_t *) param_buf->data;
19646
19647 if (index < ev_param->num_bcn_stats) {
19648 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
19649 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19650 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19651 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19652 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
19653 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
19654 (index * sizeof(wmi_bcn_stats)));
19655
19656 bcn_stats->vdev_id = ev->vdev_id;
19657 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
19658 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
19659 }
19660
19661 return QDF_STATUS_SUCCESS;
19662}
19663
19664/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019665 * extract_peer_stats_tlv() - extract peer stats from event
19666 * @wmi_handle: wmi handle
19667 * @param evt_buf: pointer to event buffer
19668 * @param index: Index into peer stats
19669 * @param peer_stats: Pointer to hold peer stats
19670 *
19671 * Return: QDF_STATUS_SUCCESS for success or error code
19672 */
19673static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19674 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19675{
19676 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19677 wmi_stats_event_fixed_param *ev_param;
19678 uint8_t *data;
19679
19680 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19681 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19682 data = (uint8_t *) param_buf->data;
19683
19684 if (index < ev_param->num_peer_stats) {
19685 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19686 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19687 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19688 (index * sizeof(wmi_peer_stats)));
19689
19690 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19691
19692 OS_MEMCPY(&(peer_stats->peer_macaddr),
19693 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19694
19695 peer_stats->peer_rssi = ev->peer_rssi;
19696 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19697 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19698 }
19699
19700 return QDF_STATUS_SUCCESS;
19701}
19702
19703/**
19704 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19705 * @wmi_handle: wmi handle
19706 * @param evt_buf: pointer to event buffer
19707 * @param index: Index into bcn fault stats
19708 * @param bcnflt_stats: Pointer to hold bcn fault stats
19709 *
19710 * Return: QDF_STATUS_SUCCESS for success or error code
19711 */
19712static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19713 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19714{
19715 return QDF_STATUS_SUCCESS;
19716}
19717
19718/**
19719 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19720 * @wmi_handle: wmi handle
19721 * @param evt_buf: pointer to event buffer
19722 * @param index: Index into extended peer stats
19723 * @param peer_extd_stats: Pointer to hold extended peer stats
19724 *
19725 * Return: QDF_STATUS_SUCCESS for success or error code
19726 */
19727static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19728 void *evt_buf, uint32_t index,
19729 wmi_host_peer_extd_stats *peer_extd_stats)
19730{
19731 return QDF_STATUS_SUCCESS;
19732}
19733
19734/**
19735 * extract_chan_stats_tlv() - extract chan stats from event
19736 * @wmi_handle: wmi handle
19737 * @param evt_buf: pointer to event buffer
19738 * @param index: Index into chan stats
19739 * @param vdev_extd_stats: Pointer to hold chan stats
19740 *
19741 * Return: QDF_STATUS_SUCCESS for success or error code
19742 */
19743static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19744 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19745{
19746 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19747 wmi_stats_event_fixed_param *ev_param;
19748 uint8_t *data;
19749
19750 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19751 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19752 data = (uint8_t *) param_buf->data;
19753
19754 if (index < ev_param->num_chan_stats) {
19755 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19756 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19757 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19758 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19759 (index * sizeof(wmi_chan_stats)));
19760
19761
Jeff Johnson79eaacb2018-05-06 17:53:18 -070019762 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +053019763 chan_stats->chan_mhz = ev->chan_mhz;
19764 chan_stats->sampling_period_us = ev->sampling_period_us;
19765 chan_stats->rx_clear_count = ev->rx_clear_count;
19766 chan_stats->tx_duration_us = ev->tx_duration_us;
19767 chan_stats->rx_duration_us = ev->rx_duration_us;
19768 }
19769
19770 return QDF_STATUS_SUCCESS;
19771}
19772
19773/**
19774 * extract_profile_ctx_tlv() - extract profile context from event
19775 * @wmi_handle: wmi handle
19776 * @param evt_buf: pointer to event buffer
19777 * @idx: profile stats index to extract
19778 * @param profile_ctx: Pointer to hold profile context
19779 *
19780 * Return: QDF_STATUS_SUCCESS for success or error code
19781 */
19782static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19783 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19784{
19785 return QDF_STATUS_SUCCESS;
19786}
19787
19788/**
19789 * extract_profile_data_tlv() - extract profile data from event
19790 * @wmi_handle: wmi handle
19791 * @param evt_buf: pointer to event buffer
19792 * @param profile_data: Pointer to hold profile data
19793 *
19794 * Return: QDF_STATUS_SUCCESS for success or error code
19795 */
19796static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19797 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19798{
19799
19800 return QDF_STATUS_SUCCESS;
19801}
19802
19803/**
19804 * extract_chan_info_event_tlv() - extract chan information from event
19805 * @wmi_handle: wmi handle
19806 * @param evt_buf: pointer to event buffer
19807 * @param chan_info: Pointer to hold chan information
19808 *
19809 * Return: QDF_STATUS_SUCCESS for success or error code
19810 */
19811static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19812 void *evt_buf, wmi_host_chan_info_event *chan_info)
19813{
19814 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19815 wmi_chan_info_event_fixed_param *ev;
19816
19817 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19818
19819 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19820 if (!ev) {
19821 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19822 return QDF_STATUS_E_FAILURE;
19823 }
19824
19825 chan_info->err_code = ev->err_code;
19826 chan_info->freq = ev->freq;
19827 chan_info->cmd_flags = ev->cmd_flags;
19828 chan_info->noise_floor = ev->noise_floor;
19829 chan_info->rx_clear_count = ev->rx_clear_count;
19830 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019831 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19832 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019833 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19834 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19835 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019836 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19837 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19838 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19839 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19840 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19841 chan_info->rx_frame_count = ev->rx_frame_count;
19842 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19843 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019844
19845 return QDF_STATUS_SUCCESS;
19846}
19847
19848/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019849 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19850 * @wmi_handle: WMI handle
19851 * @param evt_buf: Pointer to event buffer
19852 * @param param: Pointer to hold data
19853 *
19854 * Return : QDF_STATUS_SUCCESS for success or error code
19855 */
19856static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19857 uint8_t *evt_buf,
19858 struct wmi_host_pdev_utf_event *event)
19859{
19860 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019861 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019862
19863 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19864 event->data = param_buf->data;
19865 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019866 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019867 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019868 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019869 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019870
19871 return QDF_STATUS_SUCCESS;
19872}
Govind Singhe7f2f342016-05-23 12:12:52 +053019873
Kiran Venkatappa06520822016-08-10 23:55:40 +053019874/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019875 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19876 * @wmi_handle: wmi handle
19877 * @param evt_buf: pointer to event buffer
19878 * @param param: Pointer to hold evt buf
19879 *
19880 * Return: QDF_STATUS_SUCCESS for success or error code
19881 */
19882static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19883 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19884{
19885 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19886 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19887 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19888 uint8_t i = 0, j = 0;
19889
19890 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19891 if (!param_buf)
19892 return QDF_STATUS_E_INVAL;
19893
19894 hw_caps = param_buf->soc_hw_mode_caps;
19895 if (!hw_caps)
19896 return QDF_STATUS_E_INVAL;
19897
19898 if (!hw_caps->num_chainmask_tables)
19899 return QDF_STATUS_E_INVAL;
19900
19901 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19902
19903 if (chainmask_caps == NULL)
19904 return QDF_STATUS_E_INVAL;
19905
19906 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19907
19908 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19909 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19910
19911 chainmask_table[i].cap_list[j].chainmask =
19912 chainmask_caps->chainmask;
19913
19914 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19915 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19916
19917 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19918 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19919
19920 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19921 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19922
19923 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19924 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19925
19926 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19927 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19928
19929 chainmask_table[i].cap_list[j].chain_mask_2G =
19930 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19931
19932 chainmask_table[i].cap_list[j].chain_mask_5G =
19933 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19934
19935 chainmask_table[i].cap_list[j].chain_mask_tx =
19936 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19937
19938 chainmask_table[i].cap_list[j].chain_mask_rx =
19939 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19940
19941 chainmask_table[i].cap_list[j].supports_aDFS =
19942 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19943
19944 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19945 chainmask_caps->supported_flags,
19946 chainmask_caps->chainmask
19947 );
19948 chainmask_caps++;
19949 }
19950 }
19951
19952 return QDF_STATUS_SUCCESS;
19953}
19954
19955/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019956 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19957 * from event
19958 * @wmi_handle: wmi handle
19959 * @param evt_buf: pointer to event buffer
19960 * @param param: Pointer to hold evt buf
19961 *
19962 * Return: QDF_STATUS_SUCCESS for success or error code
19963 */
19964static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019965 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019966{
19967 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19968 wmi_service_ready_ext_event_fixed_param *ev;
19969 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19970 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019971 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19972 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019973
19974 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19975 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019976 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019977
19978 ev = param_buf->fixed_param;
19979 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019980 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019981
19982 /* Move this to host based bitmap */
19983 param->default_conc_scan_config_bits =
19984 ev->default_conc_scan_config_bits;
19985 param->default_fw_config_bits = ev->default_fw_config_bits;
19986 param->he_cap_info = ev->he_cap_info;
19987 param->mpdu_density = ev->mpdu_density;
19988 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019989 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019990 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019991 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19992
19993 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019994 if (hw_caps)
19995 param->num_hw_modes = hw_caps->num_hw_modes;
19996 else
19997 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019998
19999 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020000 if (reg_caps)
20001 param->num_phy = reg_caps->num_phy;
20002 else
20003 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020004
Kapil Gupta0692a1a2017-05-15 15:57:36 +053020005 if (hw_caps) {
20006 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
20007 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
20008 } else
20009 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053020010
20011 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
20012
20013 if (chain_mask_combo == NULL)
20014 return QDF_STATUS_SUCCESS;
20015
20016 qdf_print("Dumping chain mask combo data\n");
20017
Kapil Gupta0692a1a2017-05-15 15:57:36 +053020018 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053020019
20020 qdf_print("table_id : %d Num valid chainmasks: %d\n",
20021 chain_mask_combo->chainmask_table_id,
20022 chain_mask_combo->num_valid_chainmask
20023 );
20024
20025 param->chainmask_table[i].table_id =
20026 chain_mask_combo->chainmask_table_id;
20027 param->chainmask_table[i].num_valid_chainmasks =
20028 chain_mask_combo->num_valid_chainmask;
20029 chain_mask_combo++;
20030 }
20031 qdf_print("chain mask combo end\n");
20032
Kiran Venkatappa06520822016-08-10 23:55:40 +053020033 return QDF_STATUS_SUCCESS;
20034}
20035
20036/**
20037 * extract_hw_mode_cap_service_ready_ext_tlv() -
20038 * extract HW mode cap from service ready event
20039 * @wmi_handle: wmi handle
20040 * @param evt_buf: pointer to event buffer
20041 * @param param: Pointer to hold evt buf
20042 * @param hw_mode_idx: hw mode idx should be less than num_mode
20043 *
20044 * Return: QDF_STATUS_SUCCESS for success or error code
20045 */
20046static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
20047 wmi_unified_t wmi_handle,
20048 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080020049 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053020050{
20051 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20052 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
20053
20054 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
20055 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020056 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020057
20058 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020059 if (!hw_caps)
20060 return QDF_STATUS_E_INVAL;
20061
Kiran Venkatappa06520822016-08-10 23:55:40 +053020062 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020063 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020064
20065 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
20066 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
20067
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020068 param->hw_mode_config_type =
20069 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
20070
Kiran Venkatappa06520822016-08-10 23:55:40 +053020071 return QDF_STATUS_SUCCESS;
20072}
20073
20074/**
20075 * extract_mac_phy_cap_service_ready_ext_tlv() -
20076 * extract MAC phy cap from service ready event
20077 * @wmi_handle: wmi handle
20078 * @param evt_buf: pointer to event buffer
20079 * @param param: Pointer to hold evt buf
20080 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020081 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053020082 *
20083 * Return: QDF_STATUS_SUCCESS for success or error code
20084 */
20085static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
20086 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020087 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080020088 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053020089{
20090 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020091 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020092 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
20093 uint32_t phy_map;
20094 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020095
20096 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
20097 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020098 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020099
20100 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020101 if (!hw_caps)
20102 return QDF_STATUS_E_INVAL;
20103
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020104 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
20105 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
20106 break;
20107
20108 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
20109 while (phy_map) {
20110 phy_map >>= 1;
20111 phy_idx++;
20112 }
20113 }
20114
20115 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020116 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020117
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020118 phy_idx += phy_id;
20119 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020120 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020121
20122 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053020123
20124 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020125 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20126 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053020127 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053020128 param->supports_11b =
20129 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
20130 param->supports_11g =
20131 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
20132 param->supports_11a =
20133 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
20134 param->supports_11n =
20135 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
20136 param->supports_11ac =
20137 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
20138 param->supports_11ax =
20139 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053020140
20141 param->supported_bands = mac_phy_caps->supported_bands;
20142 param->ampdu_density = mac_phy_caps->ampdu_density;
20143 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
20144 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
20145 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
20146 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
20147 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
20148 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
20149 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
20150 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
20151 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
20152 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
20153 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
20154 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
20155 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
20156 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
20157 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
20158 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080020159 qdf_mem_copy(&param->he_cap_phy_info_2G,
20160 &mac_phy_caps->he_cap_phy_info_2G,
20161 sizeof(param->he_cap_phy_info_2G));
20162 qdf_mem_copy(&param->he_cap_phy_info_5G,
20163 &mac_phy_caps->he_cap_phy_info_5G,
20164 sizeof(param->he_cap_phy_info_5G));
20165 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
20166 sizeof(param->he_ppet2G));
20167 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
20168 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053020169 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020170
20171 return QDF_STATUS_SUCCESS;
20172}
20173
20174/**
20175 * extract_reg_cap_service_ready_ext_tlv() -
20176 * extract REG cap from service ready event
20177 * @wmi_handle: wmi handle
20178 * @param evt_buf: pointer to event buffer
20179 * @param param: Pointer to hold evt buf
20180 * @param phy_idx: phy idx should be less than num_mode
20181 *
20182 * Return: QDF_STATUS_SUCCESS for success or error code
20183 */
20184static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
20185 wmi_unified_t wmi_handle,
20186 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080020187 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053020188{
20189 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20190 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
20191 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
20192
20193 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
20194 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020195 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020196
20197 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020198 if (!reg_caps)
20199 return QDF_STATUS_E_INVAL;
20200
Kiran Venkatappa06520822016-08-10 23:55:40 +053020201 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020202 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020203
20204 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
20205
20206 param->phy_id = ext_reg_cap->phy_id;
20207 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
20208 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
20209 param->regcap1 = ext_reg_cap->regcap1;
20210 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053020211 param->wireless_modes = convert_wireless_modes_tlv(
20212 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053020213 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
20214 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
20215 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
20216 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
20217
20218 return QDF_STATUS_SUCCESS;
20219}
20220
Sathish Kumarf396c722017-11-17 17:30:41 +053020221static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
20222 wmi_unified_t wmi_handle,
20223 uint8_t *event, uint8_t idx,
20224 struct wlan_psoc_host_dbr_ring_caps *param)
20225{
20226 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20227 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
20228
20229 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
20230 if (!param_buf)
20231 return QDF_STATUS_E_INVAL;
20232
20233 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
20234
20235 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20236 dbr_ring_caps->pdev_id);
20237 param->mod_id = dbr_ring_caps->mod_id;
20238 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
20239 param->min_buf_size = dbr_ring_caps->min_buf_size;
20240 param->min_buf_align = dbr_ring_caps->min_buf_align;
20241
20242 return QDF_STATUS_SUCCESS;
20243}
20244
20245static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
20246 uint8_t *event, struct direct_buf_rx_rsp *param)
20247{
20248 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20249 wmi_dma_buf_release_fixed_param *ev;
20250
20251 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20252 if (!param_buf)
20253 return QDF_STATUS_E_INVAL;
20254
20255 ev = param_buf->fixed_param;
20256 if (!ev)
20257 return QDF_STATUS_E_INVAL;
20258
20259 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20260 ev->pdev_id);
20261 param->mod_id = ev->mod_id;
20262 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053020263 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053020264 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
20265 param->pdev_id, param->mod_id, param->num_buf_release_entry);
20266
20267 return QDF_STATUS_SUCCESS;
20268}
20269
20270static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
20271 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
20272{
20273 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20274 wmi_dma_buf_release_entry *entry;
20275
20276 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20277 if (!param_buf)
20278 return QDF_STATUS_E_INVAL;
20279
20280 entry = &param_buf->entries[idx];
20281
20282 if (!entry) {
20283 WMI_LOGE("%s: Entry is NULL\n", __func__);
20284 return QDF_STATUS_E_FAILURE;
20285 }
20286
20287 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
20288
20289 param->paddr_lo = entry->paddr_lo;
20290 param->paddr_hi = entry->paddr_hi;
20291
20292 return QDF_STATUS_SUCCESS;
20293}
20294
Edayilliam Jayadev92651222018-04-06 16:37:17 +053020295static QDF_STATUS extract_dbr_buf_metadata_tlv(
20296 wmi_unified_t wmi_handle, uint8_t *event,
20297 uint8_t idx, struct direct_buf_rx_metadata *param)
20298{
20299 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20300 wmi_dma_buf_release_spectral_meta_data *entry;
20301
20302 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20303 if (!param_buf)
20304 return QDF_STATUS_E_INVAL;
20305
20306 entry = &param_buf->meta_data[idx];
20307
20308 if (!entry) {
20309 WMI_LOGE("%s: Entry is NULL\n", __func__);
20310 return QDF_STATUS_E_FAILURE;
20311 }
20312
20313 qdf_mem_copy(param->noisefloor, entry->noise_floor,
20314 sizeof(entry->noise_floor));
20315 return QDF_STATUS_SUCCESS;
20316}
20317
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020318/**
20319 * extract_dcs_interference_type_tlv() - extract dcs interference type
20320 * from event
20321 * @wmi_handle: wmi handle
20322 * @param evt_buf: pointer to event buffer
20323 * @param param: Pointer to hold dcs interference param
20324 *
20325 * Return: 0 for success or error code
20326 */
20327static QDF_STATUS extract_dcs_interference_type_tlv(
20328 wmi_unified_t wmi_handle,
20329 void *evt_buf, struct wmi_host_dcs_interference_param *param)
20330{
20331 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20332
20333 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20334 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020335 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020336
20337 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020338 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20339 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020340
20341 return QDF_STATUS_SUCCESS;
20342}
20343
20344/*
20345 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
20346 * @wmi_handle: wmi handle
20347 * @param evt_buf: pointer to event buffer
20348 * @param cw_int: Pointer to hold cw interference
20349 *
20350 * Return: 0 for success or error code
20351 */
20352static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
20353 void *evt_buf,
20354 wmi_host_ath_dcs_cw_int *cw_int)
20355{
20356 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20357 wlan_dcs_cw_int *ev;
20358
20359 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20360 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020361 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020362
20363 ev = param_buf->cw_int;
20364
20365 cw_int->channel = ev->channel;
20366
20367 return QDF_STATUS_SUCCESS;
20368}
20369
20370/**
20371 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
20372 * @wmi_handle: wmi handle
20373 * @param evt_buf: pointer to event buffer
20374 * @param wlan_stat: Pointer to hold wlan stats
20375 *
20376 * Return: 0 for success or error code
20377 */
20378static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
20379 void *evt_buf,
20380 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
20381{
20382 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20383 wlan_dcs_im_tgt_stats_t *ev;
20384
20385 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20386 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020387 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020388
20389 ev = param_buf->wlan_stat;
20390 wlan_stat->reg_tsf32 = ev->reg_tsf32;
20391 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
20392 wlan_stat->tx_waste_time = ev->tx_waste_time;
20393 wlan_stat->rx_time = ev->rx_time;
20394 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
20395 wlan_stat->mib_stats.listen_time = ev->listen_time;
20396 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
20397 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
20398 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
20399 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
20400 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
20401 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
20402 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
20403 wlan_stat->chan_nf = ev->chan_nf;
20404 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
20405
20406 return QDF_STATUS_SUCCESS;
20407}
20408
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020409/**
20410 * extract_thermal_stats_tlv() - extract thermal stats from event
20411 * @wmi_handle: wmi handle
20412 * @param evt_buf: Pointer to event buffer
20413 * @param temp: Pointer to hold extracted temperature
20414 * @param level: Pointer to hold extracted level
20415 *
20416 * Return: 0 for success or error code
20417 */
20418static QDF_STATUS
20419extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
20420 void *evt_buf, uint32_t *temp,
20421 uint32_t *level, uint32_t *pdev_id)
20422{
20423 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20424 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
20425
20426 param_buf =
20427 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20428 if (!param_buf)
20429 return QDF_STATUS_E_INVAL;
20430
20431 tt_stats_event = param_buf->fixed_param;
20432
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020433 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20434 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020435 *temp = tt_stats_event->temp;
20436 *level = tt_stats_event->level;
20437
20438 return QDF_STATUS_SUCCESS;
20439}
20440
20441/**
20442 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
20443 * @wmi_handle: wmi handle
20444 * @param evt_buf: pointer to event buffer
20445 * @param idx: Index to level stats
20446 * @param levelcount: Pointer to hold levelcount
20447 * @param dccount: Pointer to hold dccount
20448 *
20449 * Return: 0 for success or error code
20450 */
20451static QDF_STATUS
20452extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
20453 void *evt_buf, uint8_t idx, uint32_t *levelcount,
20454 uint32_t *dccount)
20455{
20456 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20457 wmi_therm_throt_level_stats_info *tt_level_info;
20458
20459 param_buf =
20460 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20461 if (!param_buf)
20462 return QDF_STATUS_E_INVAL;
20463
20464 tt_level_info = param_buf->therm_throt_level_stats_info;
20465
20466 if (idx < THERMAL_LEVELS) {
20467 *levelcount = tt_level_info[idx].level_count;
20468 *dccount = tt_level_info[idx].dc_count;
20469 return QDF_STATUS_SUCCESS;
20470 }
20471
20472 return QDF_STATUS_E_FAILURE;
20473}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020474#ifdef BIG_ENDIAN_HOST
20475/**
20476 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
20477 * @param data_len - data length
20478 * @param data - pointer to data
20479 *
20480 * Return: QDF_STATUS - success or error status
20481 */
20482static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20483{
20484 uint8_t *data_aligned = NULL;
20485 int c;
20486 unsigned char *data_unaligned;
20487
20488 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
20489 FIPS_ALIGN));
20490 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -070020491 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020492 if (data_unaligned == NULL)
20493 return QDF_STATUS_E_FAILURE;
20494
20495 /* Checking if space is alligned */
20496 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
20497 /* align the data space */
20498 data_aligned =
20499 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
20500 } else {
20501 data_aligned = (u_int8_t *)data_unaligned;
20502 }
20503
20504 /* memset and copy content from data to data aligned */
20505 OS_MEMSET(data_aligned, 0, data_len);
20506 OS_MEMCPY(data_aligned, data, data_len);
20507 /* Endianness to LE */
20508 for (c = 0; c < data_len/4; c++) {
20509 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020510 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020511 }
20512
20513 /* Copy content to event->data */
20514 OS_MEMCPY(data, data_aligned, data_len);
20515
20516 /* clean up allocated space */
20517 qdf_mem_free(data_unaligned);
20518 data_aligned = NULL;
20519 data_unaligned = NULL;
20520
20521 /*************************************************************/
20522
20523 return QDF_STATUS_SUCCESS;
20524}
20525#else
20526/**
20527 * fips_conv_data_be() - DUMMY for LE platform
20528 *
20529 * Return: QDF_STATUS - success
20530 */
20531static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20532{
20533 return QDF_STATUS_SUCCESS;
20534}
20535#endif
20536
20537/**
20538 * extract_fips_event_data_tlv() - extract fips event data
20539 * @wmi_handle: wmi handle
20540 * @param evt_buf: pointer to event buffer
20541 * @param param: pointer FIPS event params
20542 *
20543 * Return: 0 for success or error code
20544 */
20545static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
20546 void *evt_buf, struct wmi_host_fips_event_param *param)
20547{
20548 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
20549 wmi_pdev_fips_event_fixed_param *event;
20550
20551 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
20552 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
20553
20554 if (fips_conv_data_be(event->data_len, param_buf->data) !=
20555 QDF_STATUS_SUCCESS)
20556 return QDF_STATUS_E_FAILURE;
20557
20558 param->data = (uint32_t *)param_buf->data;
20559 param->data_len = event->data_len;
20560 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020561 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20562 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020563
20564 return QDF_STATUS_SUCCESS;
20565}
20566
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020567/*
20568 * extract_peer_delete_response_event_tlv() - extract peer delete response event
20569 * @wmi_handle: wmi handle
20570 * @param evt_buf: pointer to event buffer
20571 * @param vdev_id: Pointer to hold vdev_id
20572 * @param mac_addr: Pointer to hold peer mac address
20573 *
20574 * Return: QDF_STATUS_SUCCESS for success or error code
20575 */
20576static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
20577 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
20578{
20579 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
20580 wmi_peer_delete_resp_event_fixed_param *ev;
20581
20582 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
20583
20584 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
20585 if (!ev) {
20586 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
20587 return QDF_STATUS_E_FAILURE;
20588 }
20589
20590 param->vdev_id = ev->vdev_id;
20591 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
20592 &param->mac_address.bytes[0]);
20593
20594 return QDF_STATUS_SUCCESS;
20595}
20596
Govind Singhecf03cd2016-05-12 12:45:51 +053020597static bool is_management_record_tlv(uint32_t cmd_id)
20598{
jiad36c94d22018-01-22 15:37:03 +080020599 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
20600 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
20601 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053020602 return true;
jiad36c94d22018-01-22 15:37:03 +080020603 }
Govind Singhe7f2f342016-05-23 12:12:52 +053020604
Govind Singhecf03cd2016-05-12 12:45:51 +053020605 return false;
20606}
20607
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053020608static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20609{
20610 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
20611
20612 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
20613
20614 switch (set_cmd->param_id) {
20615 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
20616 case WMI_VDEV_PARAM_DTIM_POLICY:
20617 return HTC_TX_PACKET_TAG_AUTO_PM;
20618 default:
20619 break;
20620 }
20621
20622 return 0;
20623}
20624
20625static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20626{
20627 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
20628
20629 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20630
20631 switch (ps_cmd->param) {
20632 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20633 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20634 case WMI_STA_PS_ENABLE_QPOWER:
20635 return HTC_TX_PACKET_TAG_AUTO_PM;
20636 default:
20637 break;
20638 }
20639
20640 return 0;
20641}
20642
20643static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20644 uint32_t cmd_id)
20645{
20646 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20647 return 0;
20648
20649 switch (cmd_id) {
20650 case WMI_VDEV_SET_PARAM_CMDID:
20651 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20652 case WMI_STA_POWERSAVE_PARAM_CMDID:
20653 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20654 default:
20655 break;
20656 }
20657
20658 return 0;
20659}
20660
20661static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20662{
20663 uint16_t tag = 0;
20664
20665 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20666 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20667 __func__);
20668 return tag;
20669 }
20670
20671 if (wmi_handle->tag_crash_inject)
20672 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20673
20674 wmi_handle->tag_crash_inject = false;
20675 return tag;
20676}
20677
20678/**
20679 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20680 * @wmi_handle: WMI handle
20681 * @buf: WMI buffer
20682 * @cmd_id: WMI command Id
20683 *
20684 * Return htc_tx_tag
20685 */
20686static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20687 wmi_buf_t buf,
20688 uint32_t cmd_id)
20689{
20690 uint16_t htc_tx_tag = 0;
20691
20692 switch (cmd_id) {
20693 case WMI_WOW_ENABLE_CMDID:
20694 case WMI_PDEV_SUSPEND_CMDID:
20695 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20696 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20697 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20698 case WMI_PDEV_RESUME_CMDID:
20699 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20700 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20701#ifdef FEATURE_WLAN_D0WOW
20702 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20703#endif
20704 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20705 break;
20706 case WMI_FORCE_FW_HANG_CMDID:
20707 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20708 break;
20709 case WMI_VDEV_SET_PARAM_CMDID:
20710 case WMI_STA_POWERSAVE_PARAM_CMDID:
20711 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20712 default:
20713 break;
20714 }
20715
20716 return htc_tx_tag;
20717}
20718
Sathish Kumard3ab1002017-02-07 17:10:59 +053020719/**
20720 * extract_channel_hopping_event_tlv() - extract channel hopping param
20721 * from event
20722 * @wmi_handle: wmi handle
20723 * @param evt_buf: pointer to event buffer
20724 * @param ch_hopping: Pointer to hold channel hopping param
20725 *
20726 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20727 */
20728static QDF_STATUS extract_channel_hopping_event_tlv(
20729 wmi_unified_t wmi_handle, void *evt_buf,
20730 wmi_host_pdev_channel_hopping_event *ch_hopping)
20731{
20732 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20733 wmi_pdev_channel_hopping_event_fixed_param *event;
20734
20735 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20736 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20737 param_buf->fixed_param;
20738
20739 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20740 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020741 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20742 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020743
20744 return QDF_STATUS_SUCCESS;
20745}
20746
20747/**
20748 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20749 * @wmi_handle: wmi handle
20750 * @param evt_buf: pointer to event buffer
20751 * @param param: Pointer to hold tpc param
20752 *
20753 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20754 */
20755static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20756 void *evt_buf,
20757 wmi_host_pdev_tpc_event *param)
20758{
20759 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20760 wmi_pdev_tpc_event_fixed_param *event;
20761
20762 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20763 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20764
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020765 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20766 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020767 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20768
20769 return QDF_STATUS_SUCCESS;
20770}
20771
nobeljf74583b2018-01-25 16:35:36 -080020772/**
20773 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20774 * power param from event
20775 * @wmi_handle: wmi handle
20776 * @param evt_buf: pointer to event buffer
20777 * @param param: Pointer to hold nf cal power param
20778 *
20779 * Return: 0 for success or error code
20780 */
20781static QDF_STATUS
20782extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20783 void *evt_buf,
20784 wmi_host_pdev_nfcal_power_all_channels_event *param)
20785{
20786 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20787 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20788 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20789 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20790 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20791 uint32_t i;
20792
20793 param_buf =
20794 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20795 event = param_buf->fixed_param;
20796 ch_nfdbr = param_buf->nfdbr;
20797 ch_nfdbm = param_buf->nfdbm;
20798 ch_freqnum = param_buf->freqnum;
20799
20800 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20801 event->pdev_id, param_buf->num_nfdbr,
20802 param_buf->num_nfdbm, param_buf->num_freqnum);
20803
20804 if (param_buf->num_nfdbr >
20805 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20806 WMI_LOGE("invalid number of nfdBr");
20807 return QDF_STATUS_E_FAILURE;
20808 }
20809
20810 if (param_buf->num_nfdbm >
20811 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20812 WMI_LOGE("invalid number of nfdBm");
20813 return QDF_STATUS_E_FAILURE;
20814 }
20815
20816 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20817 WMI_LOGE("invalid number of freqNum");
20818 return QDF_STATUS_E_FAILURE;
20819 }
20820
20821 for (i = 0; i < param_buf->num_nfdbr; i++) {
20822 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20823 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20824 ch_nfdbr++;
20825 ch_nfdbm++;
20826 }
20827
20828 for (i = 0; i < param_buf->num_freqnum; i++) {
20829 param->freqnum[i] = ch_freqnum->freqNum;
20830 ch_freqnum++;
20831 }
20832
Keyur Parekh2c0bab62018-05-16 13:15:38 -070020833 param->pdev_id = wmi_handle->ops->
20834 convert_pdev_id_target_to_host(event->pdev_id);
nobeljf74583b2018-01-25 16:35:36 -080020835
20836 return QDF_STATUS_SUCCESS;
20837}
20838
Sathish Kumard3ab1002017-02-07 17:10:59 +053020839
20840#ifdef BIG_ENDIAN_HOST
20841/**
20842 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20843 * @param data_len - data length
20844 * @param data - pointer to data
20845 *
20846 * Return: QDF_STATUS - success or error status
20847 */
20848static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20849{
20850 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020851 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020852 /* Skip swapping the first word */
20853 datap += sizeof(uint32_t);
20854 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20855 i++, datap += sizeof(uint32_t)) {
20856 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20857 }
20858
20859 return QDF_STATUS_SUCCESS;
20860}
20861#else
20862/**
20863 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20864 * @param data_len - data length
20865 * @param data - pointer to data
20866 *
20867 * Return: QDF_STATUS - success or error status
20868 */
20869static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20870{
20871 return QDF_STATUS_SUCCESS;
20872}
20873#endif
20874
20875/**
20876 * extract_wds_addr_event_tlv() - extract wds address from event
20877 * @wmi_handle: wmi handle
20878 * @param evt_buf: pointer to event buffer
20879 * @param wds_ev: Pointer to hold wds address
20880 *
20881 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20882 */
20883static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20884 void *evt_buf,
20885 uint16_t len, wds_addr_event_t *wds_ev)
20886{
20887 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20888 wmi_wds_addr_event_fixed_param *ev;
20889 int i;
20890
20891 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20892 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20893
20894 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20895 return QDF_STATUS_E_FAILURE;
20896
20897 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20898 sizeof(wds_ev->event_type));
20899 for (i = 0; i < 4; i++) {
20900 wds_ev->peer_mac[i] =
20901 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20902 wds_ev->dest_mac[i] =
20903 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20904 }
20905 for (i = 0; i < 2; i++) {
20906 wds_ev->peer_mac[4+i] =
20907 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20908 wds_ev->dest_mac[4+i] =
20909 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20910 }
20911 return QDF_STATUS_SUCCESS;
20912}
20913
20914/**
20915 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20916 * from event
20917 * @wmi_handle: wmi handle
20918 * @param evt_buf: pointer to event buffer
20919 * @param ev: Pointer to hold peer param and ps state
20920 *
20921 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20922 */
20923static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20924 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20925{
20926 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20927 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20928
20929 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20930 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20931 param_buf->fixed_param;
20932
20933 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20934 ev->peer_ps_state = event->peer_ps_state;
20935
20936 return QDF_STATUS_SUCCESS;
20937}
20938
20939/**
20940 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20941 * @wmi_handle: wmi handle
20942 * @param evt_buf: pointer to event buffer
20943 * @param inst_rssi_resp: Pointer to hold inst rssi response
20944 *
20945 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20946 */
20947static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20948 wmi_unified_t wmi_handle, void *evt_buf,
20949 wmi_host_inst_stats_resp *inst_rssi_resp)
20950{
20951 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20952 wmi_inst_rssi_stats_resp_fixed_param *event;
20953
20954 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20955 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20956
20957 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20958 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20959 inst_rssi_resp->iRSSI = event->iRSSI;
20960
20961 return QDF_STATUS_SUCCESS;
20962}
20963
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020964static struct cur_reg_rule
20965*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20966 wmi_regulatory_rule_struct *wmi_reg_rule)
20967{
20968 struct cur_reg_rule *reg_rule_ptr;
20969 uint32_t count;
20970
20971 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20972
20973 if (NULL == reg_rule_ptr) {
20974 WMI_LOGE("memory allocation failure");
20975 return NULL;
20976 }
20977
20978 for (count = 0; count < num_reg_rules; count++) {
20979 reg_rule_ptr[count].start_freq =
20980 WMI_REG_RULE_START_FREQ_GET(
20981 wmi_reg_rule[count].freq_info);
20982 reg_rule_ptr[count].end_freq =
20983 WMI_REG_RULE_END_FREQ_GET(
20984 wmi_reg_rule[count].freq_info);
20985 reg_rule_ptr[count].max_bw =
20986 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020987 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020988 reg_rule_ptr[count].reg_power =
20989 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020990 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020991 reg_rule_ptr[count].ant_gain =
20992 WMI_REG_RULE_ANTENNA_GAIN_GET(
20993 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020994 reg_rule_ptr[count].flags =
20995 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020996 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020997 }
20998
20999 return reg_rule_ptr;
21000}
21001
21002static QDF_STATUS extract_reg_chan_list_update_event_tlv(
21003 wmi_unified_t wmi_handle, uint8_t *evt_buf,
21004 struct cur_regulatory_info *reg_info, uint32_t len)
21005{
21006 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
21007 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
21008 wmi_regulatory_rule_struct *wmi_reg_rule;
21009 uint32_t num_2g_reg_rules, num_5g_reg_rules;
21010
21011 WMI_LOGD("processing regulatory channel list");
21012
21013 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
21014 if (!param_buf) {
21015 WMI_LOGE("invalid channel list event buf");
21016 return QDF_STATUS_E_FAILURE;
21017 }
21018
21019 chan_list_event_hdr = param_buf->fixed_param;
21020
21021 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
21022 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
21023 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053021024 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053021025 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
21026 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070021027 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070021028 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053021029 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070021030 reg_info->ctry_code = chan_list_event_hdr->country_id;
21031 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
21032 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
21033 reg_info->status_code = REG_SET_CC_STATUS_PASS;
21034 else if (chan_list_event_hdr->status_code ==
21035 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
21036 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
21037 else if (chan_list_event_hdr->status_code ==
21038 WMI_REG_INIT_ALPHA2_NOT_FOUND)
21039 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
21040 else if (chan_list_event_hdr->status_code ==
21041 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
21042 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
21043 else if (chan_list_event_hdr->status_code ==
21044 WMI_REG_SET_CC_STATUS_NO_MEMORY)
21045 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
21046 else if (chan_list_event_hdr->status_code ==
21047 WMI_REG_SET_CC_STATUS_FAIL)
21048 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
21049
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053021050 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
21051 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
21052 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
21053 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
21054
21055 num_2g_reg_rules = reg_info->num_2g_reg_rules;
21056 num_5g_reg_rules = reg_info->num_5g_reg_rules;
21057
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021058 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
21059 __func__, reg_info->alpha2, reg_info->dfs_region,
21060 reg_info->min_bw_2g, reg_info->max_bw_2g,
21061 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053021062
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021063 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
21064 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070021065 wmi_reg_rule =
21066 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
21067 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
21068 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053021069 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
21070 wmi_reg_rule);
21071 wmi_reg_rule += num_2g_reg_rules;
21072
21073 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
21074 wmi_reg_rule);
21075
21076 WMI_LOGD("processed regulatory channel list");
21077
21078 return QDF_STATUS_SUCCESS;
21079}
21080
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070021081static QDF_STATUS extract_reg_11d_new_country_event_tlv(
21082 wmi_unified_t wmi_handle, uint8_t *evt_buf,
21083 struct reg_11d_new_country *reg_11d_country, uint32_t len)
21084{
21085 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
21086 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
21087
21088 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
21089 if (!param_buf) {
21090 WMI_LOGE("invalid 11d country event buf");
21091 return QDF_STATUS_E_FAILURE;
21092 }
21093
21094 reg_11d_country_event = param_buf->fixed_param;
21095
21096 qdf_mem_copy(reg_11d_country->alpha2,
21097 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
21098
21099 WMI_LOGD("processed 11d country event, new cc %s",
21100 reg_11d_country->alpha2);
21101
21102 return QDF_STATUS_SUCCESS;
21103}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070021104
21105static QDF_STATUS extract_reg_ch_avoid_event_tlv(
21106 wmi_unified_t wmi_handle, uint8_t *evt_buf,
21107 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
21108{
21109 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
21110 wmi_avoid_freq_range_desc *afr_desc;
21111 uint32_t num_freq_ranges, freq_range_idx;
21112 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
21113 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
21114
21115 if (!param_buf) {
21116 WMI_LOGE("Invalid channel avoid event buffer");
21117 return QDF_STATUS_E_INVAL;
21118 }
21119
21120 afr_fixed_param = param_buf->fixed_param;
21121 if (!afr_fixed_param) {
21122 WMI_LOGE("Invalid channel avoid event fixed param buffer");
21123 return QDF_STATUS_E_INVAL;
21124 }
21125
21126 if (!ch_avoid_ind) {
21127 WMI_LOGE("Invalid channel avoid indication buffer");
21128 return QDF_STATUS_E_INVAL;
21129 }
21130 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
21131 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
21132 afr_fixed_param->num_freq_ranges;
21133
21134 WMI_LOGD("Channel avoid event received with %d ranges",
21135 num_freq_ranges);
21136
21137 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
21138 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
21139 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
21140 freq_range_idx++) {
21141 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
21142 afr_desc->start_freq;
21143 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
21144 afr_desc->end_freq;
21145 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
21146 freq_range_idx, afr_desc->tlv_header,
21147 afr_desc->start_freq, afr_desc->end_freq);
21148 afr_desc++;
21149 }
21150
21151 return QDF_STATUS_SUCCESS;
21152}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021153#ifdef DFS_COMPONENT_ENABLE
21154/**
21155 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
21156 * @wmi_handle: wma handle
21157 * @evt_buf: event buffer
21158 * @vdev_id: vdev id
21159 * @len: length of buffer
21160 *
21161 * Return: 0 for success or error code
21162 */
21163static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
21164 uint8_t *evt_buf,
21165 uint32_t *vdev_id,
21166 uint32_t len)
21167{
21168 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
21169 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
21170
21171 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
21172 if (!param_tlvs) {
21173 WMI_LOGE("invalid cac complete event buf");
21174 return QDF_STATUS_E_FAILURE;
21175 }
21176
21177 cac_event = param_tlvs->fixed_param;
21178 *vdev_id = cac_event->vdev_id;
21179 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
21180
21181 return QDF_STATUS_SUCCESS;
21182}
21183
21184/**
21185 * extract_dfs_radar_detection_event_tlv() - extract radar found event
21186 * @wmi_handle: wma handle
21187 * @evt_buf: event buffer
21188 * @radar_found: radar found event info
21189 * @len: length of buffer
21190 *
21191 * Return: 0 for success or error code
21192 */
21193static QDF_STATUS extract_dfs_radar_detection_event_tlv(
21194 wmi_unified_t wmi_handle,
21195 uint8_t *evt_buf,
21196 struct radar_found_info *radar_found,
21197 uint32_t len)
21198{
21199 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
21200 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
21201
21202 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
21203 if (!param_tlv) {
21204 WMI_LOGE("invalid radar detection event buf");
21205 return QDF_STATUS_E_FAILURE;
21206 }
21207
21208 radar_event = param_tlv->fixed_param;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021209 radar_found->pdev_id = wmi_handle->ops->
21210 convert_pdev_id_target_to_host(radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021211 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021212 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021213 radar_found->chan_width = radar_event->chan_width;
21214 radar_found->detector_id = radar_event->detector_id;
21215 radar_found->segment_id = radar_event->segment_id;
21216 radar_found->timestamp = radar_event->timestamp;
21217 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021218 radar_found->freq_offset = radar_event->freq_offset;
21219 radar_found->sidx = radar_event->sidx;
21220
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080021221 WMI_LOGI("processed radar found event pdev %d,"
21222 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
21223 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
21224 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
21225 "is_chirp %d,detection mode %d\n",
21226 radar_event->pdev_id, radar_event->pdev_id,
21227 radar_event->timestamp, radar_event->chan_freq,
21228 radar_event->chan_width, radar_event->detector_id,
21229 radar_event->freq_offset, radar_event->segment_id,
21230 radar_event->sidx, radar_event->is_chirp,
21231 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021232
21233 return QDF_STATUS_SUCCESS;
21234}
bings1ea12532017-12-18 16:56:53 +080021235
21236#ifdef QCA_MCL_DFS_SUPPORT
21237/**
21238 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
21239 * @wmi_handle: wma handle
21240 * @evt_buf: event buffer
21241 * @wlan_radar_event: Pointer to struct radar_event_info
21242 * @len: length of buffer
21243 *
21244 * Return: QDF_STATUS
21245 */
21246static QDF_STATUS extract_wlan_radar_event_info_tlv(
21247 wmi_unified_t wmi_handle,
21248 uint8_t *evt_buf,
21249 struct radar_event_info *wlan_radar_event,
21250 uint32_t len)
21251{
21252 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
21253 wmi_dfs_radar_event_fixed_param *radar_event;
21254
21255 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
21256 if (!param_tlv) {
21257 WMI_LOGE("invalid wlan radar event buf");
21258 return QDF_STATUS_E_FAILURE;
21259 }
21260
21261 radar_event = param_tlv->fixed_param;
21262 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
21263 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
21264 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
21265 wlan_radar_event->rssi = radar_event->rssi;
21266 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
21267 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
21268 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
21269 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080021270 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
21271 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +080021272 if (radar_event->pulse_flags &
21273 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
21274 wlan_radar_event->is_psidx_diff_valid = true;
21275 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
21276 } else {
21277 wlan_radar_event->is_psidx_diff_valid = false;
21278 }
21279
bings1ea12532017-12-18 16:56:53 +080021280 wlan_radar_event->pdev_id = radar_event->pdev_id;
21281
21282 return QDF_STATUS_SUCCESS;
21283}
21284#else
21285static QDF_STATUS extract_wlan_radar_event_info_tlv(
21286 wmi_unified_t wmi_handle,
21287 uint8_t *evt_buf,
21288 struct radar_event_info *wlan_radar_event,
21289 uint32_t len)
21290{
21291 return QDF_STATUS_SUCCESS;
21292}
21293#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021294#endif
21295
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021296/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021297 * send_get_rcpi_cmd_tlv() - send request for rcpi value
21298 * @wmi_handle: wmi handle
21299 * @get_rcpi_param: rcpi params
21300 *
21301 * Return: QDF status
21302 */
21303static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
21304 struct rcpi_req *get_rcpi_param)
21305{
21306 wmi_buf_t buf;
21307 wmi_request_rcpi_cmd_fixed_param *cmd;
21308 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
21309
21310 buf = wmi_buf_alloc(wmi_handle, len);
21311 if (!buf) {
21312 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21313 return QDF_STATUS_E_NOMEM;
21314 }
21315
21316 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
21317 WMITLV_SET_HDR(&cmd->tlv_header,
21318 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
21319 WMITLV_GET_STRUCT_TLVLEN
21320 (wmi_request_rcpi_cmd_fixed_param));
21321
21322 cmd->vdev_id = get_rcpi_param->vdev_id;
21323 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
21324 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070021325
21326 switch (get_rcpi_param->measurement_type) {
21327
21328 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21329 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21330 break;
21331
21332 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
21333 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
21334 break;
21335
21336 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21337 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21338 break;
21339
21340 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
21341 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
21342 break;
21343
21344 default:
21345 /*
21346 * invalid rcpi measurement type, fall back to
21347 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
21348 */
21349 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21350 break;
21351 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021352 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
21353 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21354 WMI_REQUEST_RCPI_CMDID)) {
21355
21356 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
21357 __func__);
21358 wmi_buf_free(buf);
21359 return QDF_STATUS_E_FAILURE;
21360 }
21361
21362 return QDF_STATUS_SUCCESS;
21363}
21364
21365/**
21366 * extract_rcpi_response_event_tlv() - Extract RCPI event params
21367 * @wmi_handle: wmi handle
21368 * @evt_buf: pointer to event buffer
21369 * @res: pointer to hold rcpi response from firmware
21370 *
21371 * Return: QDF_STATUS_SUCCESS for successful event parse
21372 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
21373 */
21374static QDF_STATUS
21375extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
21376 void *evt_buf, struct rcpi_res *res)
21377{
21378 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
21379 wmi_update_rcpi_event_fixed_param *event;
21380
21381 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
21382 if (!param_buf) {
21383 WMI_LOGE(FL("Invalid rcpi event"));
21384 return QDF_STATUS_E_INVAL;
21385 }
21386
21387 event = param_buf->fixed_param;
21388 res->vdev_id = event->vdev_id;
21389 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
21390
21391 switch (event->measurement_type) {
21392
21393 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21394 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21395 break;
21396
21397 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
21398 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
21399 break;
21400
21401 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21402 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21403 break;
21404
21405 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
21406 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
21407 break;
21408
21409 default:
21410 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
21411 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
21412 return QDF_STATUS_E_FAILURE;
21413 }
21414
21415 if (event->status)
21416 return QDF_STATUS_E_FAILURE;
21417 else
21418 return QDF_STATUS_SUCCESS;
21419}
21420
21421/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053021422 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
21423 * host to target defines. For legacy there is not conversion
21424 * required. Just return pdev_id as it is.
21425 * @param pdev_id: host pdev_id to be converted.
21426 * Return: target pdev_id after conversion.
21427 */
21428static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
21429 uint32_t pdev_id)
21430{
21431 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
21432 return WMI_PDEV_ID_SOC;
21433
21434 /*No conversion required*/
21435 return pdev_id;
21436}
21437
21438/**
21439 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
21440 * target to host defines. For legacy there is not conversion
21441 * required. Just return pdev_id as it is.
21442 * @param pdev_id: target pdev_id to be converted.
21443 * Return: host pdev_id after conversion.
21444 */
21445static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
21446 uint32_t pdev_id)
21447{
21448 /*No conversion required*/
21449 return pdev_id;
21450}
21451
21452/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021453 * send_set_country_cmd_tlv() - WMI scan channel list function
21454 * @param wmi_handle : handle to WMI.
21455 * @param param : pointer to hold scan channel list parameter
21456 *
21457 * Return: 0 on success and -ve on failure.
21458 */
21459static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
21460 struct set_country *params)
21461{
21462 wmi_buf_t buf;
21463 QDF_STATUS qdf_status;
21464 wmi_set_current_country_cmd_fixed_param *cmd;
21465 uint16_t len = sizeof(*cmd);
21466
21467 buf = wmi_buf_alloc(wmi_handle, len);
21468 if (!buf) {
21469 WMI_LOGE("Failed to allocate memory");
21470 qdf_status = QDF_STATUS_E_NOMEM;
21471 goto end;
21472 }
21473
21474 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
21475 WMITLV_SET_HDR(&cmd->tlv_header,
21476 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
21477 WMITLV_GET_STRUCT_TLVLEN
21478 (wmi_set_current_country_cmd_fixed_param));
21479
21480 WMI_LOGD("setting cuurnet country to %s", params->country);
21481
21482 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
21483
21484 cmd->pdev_id = params->pdev_id;
21485
21486 qdf_status = wmi_unified_cmd_send(wmi_handle,
21487 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
21488
21489 if (QDF_IS_STATUS_ERROR(qdf_status)) {
21490 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
21491 wmi_buf_free(buf);
21492 }
21493
21494end:
21495 return qdf_status;
21496}
21497
Abhijit Pradhand38a2692017-06-29 12:32:20 +053021498#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
21499 WMI_SET_BITS(alpha, 0, 8, val0); \
21500 WMI_SET_BITS(alpha, 8, 8, val1); \
21501 WMI_SET_BITS(alpha, 16, 8, val2); \
21502 } while (0)
21503
21504static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
21505 uint8_t pdev_id, struct cc_regdmn_s *rd)
21506{
21507 wmi_set_init_country_cmd_fixed_param *cmd;
21508 uint16_t len;
21509 wmi_buf_t buf;
21510 int ret;
21511
21512 len = sizeof(wmi_set_init_country_cmd_fixed_param);
21513 buf = wmi_buf_alloc(wmi_handle, len);
21514 if (!buf) {
21515 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
21516 return QDF_STATUS_E_NOMEM;
21517 }
21518 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
21519 WMITLV_SET_HDR(&cmd->tlv_header,
21520 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
21521 WMITLV_GET_STRUCT_TLVLEN
21522 (wmi_set_init_country_cmd_fixed_param));
21523
21524 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
21525
21526 if (rd->flags == CC_IS_SET) {
21527 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
21528 cmd->country_code.country_id = rd->cc.country_code;
21529 } else if (rd->flags == ALPHA_IS_SET) {
21530 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
21531 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
21532 rd->cc.alpha[0],
21533 rd->cc.alpha[1],
21534 rd->cc.alpha[2]);
21535 } else if (rd->flags == REGDMN_IS_SET) {
21536 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
21537 cmd->country_code.domain_code = rd->cc.regdmn_id;
21538 }
21539
21540 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
21541 WMI_SET_INIT_COUNTRY_CMDID);
21542 if (ret) {
21543 WMI_LOGE("Failed to config wow wakeup event");
21544 wmi_buf_free(buf);
21545 return QDF_STATUS_E_FAILURE;
21546 }
21547
21548 return QDF_STATUS_SUCCESS;
21549}
21550
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053021551/**
21552 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
21553 * configuration params
21554 * @wmi_handle: wmi handler
21555 * @limit_off_chan_param: pointer to wmi_off_chan_param
21556 *
21557 * Return: 0 for success and non zero for failure
21558 */
21559static
21560QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
21561 struct wmi_limit_off_chan_param *limit_off_chan_param)
21562{
21563 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
21564 wmi_buf_t buf;
21565 uint32_t len = sizeof(*cmd);
21566 int err;
21567
21568 buf = wmi_buf_alloc(wmi_handle, len);
21569 if (!buf) {
21570 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
21571 __func__);
21572 return QDF_STATUS_E_NOMEM;
21573 }
21574
21575 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
21576
21577 WMITLV_SET_HDR(&cmd->tlv_header,
21578 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
21579 WMITLV_GET_STRUCT_TLVLEN(
21580 wmi_vdev_limit_offchan_cmd_fixed_param));
21581
21582 cmd->vdev_id = limit_off_chan_param->vdev_id;
21583
21584 cmd->flags &= 0;
21585 if (limit_off_chan_param->status)
21586 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
21587 if (limit_off_chan_param->skip_dfs_chans)
21588 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
21589
21590 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
21591 cmd->rest_time = limit_off_chan_param->rest_time;
21592
21593 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
21594 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
21595 cmd->rest_time);
21596
21597 err = wmi_unified_cmd_send(wmi_handle, buf,
21598 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
21599 if (QDF_IS_STATUS_ERROR(err)) {
21600 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
21601 wmi_buf_free(buf);
21602 return QDF_STATUS_E_FAILURE;
21603 }
21604
21605 return QDF_STATUS_SUCCESS;
21606}
21607
Anurag Chouhan97f00422017-09-11 14:56:30 +053021608/**
21609 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
21610 * @wmi_handle: wmi handler
21611 * @req_buf: set arp stats request buffer
21612 *
21613 * Return: 0 for success and non zero for failure
21614 */
21615static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21616 struct set_arp_stats *req_buf)
21617{
21618 wmi_buf_t buf = NULL;
21619 QDF_STATUS status;
21620 int len;
21621 uint8_t *buf_ptr;
21622 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
21623
21624 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021625 if (req_buf->pkt_type_bitmap) {
21626 len += WMI_TLV_HDR_SIZE;
21627 len += sizeof(wmi_vdev_set_connectivity_check_stats);
21628 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053021629 buf = wmi_buf_alloc(wmi_handle, len);
21630 if (!buf) {
21631 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21632 return QDF_STATUS_E_NOMEM;
21633 }
21634
21635 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21636 wmi_set_arp =
21637 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
21638 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
21639 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
21640 WMITLV_GET_STRUCT_TLVLEN
21641 (wmi_vdev_set_arp_stats_cmd_fixed_param));
21642
21643 /* fill in per roam config values */
21644 wmi_set_arp->vdev_id = req_buf->vdev_id;
21645
21646 wmi_set_arp->set_clr = req_buf->flag;
21647 wmi_set_arp->pkt_type = req_buf->pkt_type;
21648 wmi_set_arp->ipv4 = req_buf->ip_addr;
21649
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021650 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
21651 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
21652 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
21653
21654 /*
21655 * pkt_type_bitmap should be non-zero to ensure
21656 * presence of additional stats.
21657 */
21658 if (req_buf->pkt_type_bitmap) {
21659 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
21660
21661 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21662 WMITLV_SET_HDR(buf_ptr,
21663 WMITLV_TAG_ARRAY_STRUC,
21664 sizeof(wmi_vdev_set_connectivity_check_stats));
21665 buf_ptr += WMI_TLV_HDR_SIZE;
21666 wmi_set_connect_stats =
21667 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
21668 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
21669 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
21670 WMITLV_GET_STRUCT_TLVLEN(
21671 wmi_vdev_set_connectivity_check_stats));
21672 wmi_set_connect_stats->pkt_type_bitmap =
21673 req_buf->pkt_type_bitmap;
21674 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
21675 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
21676 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
21677
21678 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
21679 wmi_set_connect_stats->pkt_type_bitmap,
21680 wmi_set_connect_stats->tcp_src_port,
21681 wmi_set_connect_stats->tcp_dst_port,
21682 wmi_set_connect_stats->icmp_ipv4);
21683 }
21684
Anurag Chouhan97f00422017-09-11 14:56:30 +053021685 /* Send per roam config parameters */
21686 status = wmi_unified_cmd_send(wmi_handle, buf,
21687 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21688 if (QDF_IS_STATUS_ERROR(status)) {
21689 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21690 status);
21691 goto error;
21692 }
21693
21694 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
21695 req_buf->flag, req_buf->vdev_id);
21696 return QDF_STATUS_SUCCESS;
21697error:
21698 wmi_buf_free(buf);
21699
21700 return status;
21701}
21702
21703/**
21704 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21705 * @wmi_handle: wmi handler
21706 * @req_buf: get arp stats request buffer
21707 *
21708 * Return: 0 for success and non zero for failure
21709 */
21710static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21711 struct get_arp_stats *req_buf)
21712{
21713 wmi_buf_t buf = NULL;
21714 QDF_STATUS status;
21715 int len;
21716 uint8_t *buf_ptr;
21717 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21718
21719 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21720 buf = wmi_buf_alloc(wmi_handle, len);
21721 if (!buf) {
21722 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21723 return QDF_STATUS_E_NOMEM;
21724 }
21725
21726 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21727 get_arp_stats =
21728 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21729 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21730 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21731 WMITLV_GET_STRUCT_TLVLEN
21732 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21733
21734 /* fill in arp stats req cmd values */
21735 get_arp_stats->vdev_id = req_buf->vdev_id;
21736
21737 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21738 /* Send per roam config parameters */
21739 status = wmi_unified_cmd_send(wmi_handle, buf,
21740 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21741 if (QDF_IS_STATUS_ERROR(status)) {
21742 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21743 status);
21744 goto error;
21745 }
21746
21747 return QDF_STATUS_SUCCESS;
21748error:
21749 wmi_buf_free(buf);
21750
21751 return status;
21752}
21753
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021754/**
21755 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21756 * @wmi_handle: wmi handler
21757 * @pmk_info: pointer to PMK cache entry
21758 * @vdev_id: vdev id
21759 *
21760 * Return: 0 for success and non zero for failure
21761 */
21762static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21763 struct wmi_unified_pmk_cache *pmk_info)
21764{
21765 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21766 wmi_buf_t buf;
21767 QDF_STATUS status;
21768 uint8_t *buf_ptr;
21769 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021770 uint32_t len = sizeof(*cmd);
21771
21772 if (pmk_info->pmk_len)
21773 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021774
21775 buf = wmi_buf_alloc(wmi_handle, len);
21776 if (!buf) {
21777 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21778 __func__);
21779 return QDF_STATUS_E_NOMEM;
21780 }
21781
21782 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21783 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21784
21785 WMITLV_SET_HDR(&cmd->tlv_header,
21786 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21787 WMITLV_GET_STRUCT_TLVLEN(
21788 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21789
21790 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021791
21792 /* If pmk_info->pmk_len is 0, this is a flush request */
21793 if (!pmk_info->pmk_len) {
21794 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21795 cmd->num_cache = 0;
21796 goto send_cmd;
21797 }
21798
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021799 cmd->num_cache = 1;
21800 buf_ptr += sizeof(*cmd);
21801
21802 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21803 sizeof(*pmksa));
21804 buf_ptr += WMI_TLV_HDR_SIZE;
21805
21806 pmksa = (wmi_pmk_cache *)buf_ptr;
21807 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21808 WMITLV_GET_STRUCT_TLVLEN
21809 (wmi_pmk_cache));
21810 pmksa->pmk_len = pmk_info->pmk_len;
21811 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21812 pmksa->pmkid_len = pmk_info->pmkid_len;
21813 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21814 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21815 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21816 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21817 pmksa->ssid.ssid_len);
21818 pmksa->cache_id = pmk_info->cache_id;
21819 pmksa->cat_flag = pmk_info->cat_flag;
21820 pmksa->action_flag = pmk_info->action_flag;
21821
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021822send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021823 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21824 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21825 if (status != QDF_STATUS_SUCCESS) {
21826 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21827 __func__, status);
21828 wmi_buf_free(buf);
21829 }
21830
21831 return status;
21832}
21833
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021834/**
21835 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21836 * @wmi_handle: wmi handle
21837 * @param: reserved param
21838 *
21839 * Return: 0 for success or error code
21840 */
21841static QDF_STATUS
21842send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21843 uint32_t param)
21844{
21845 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21846 wmi_buf_t buf;
21847 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21848
21849 buf = wmi_buf_alloc(wmi_handle, len);
21850 if (!buf) {
21851 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21852 return QDF_STATUS_E_FAILURE;
21853 }
21854 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21855 WMITLV_SET_HDR(&cmd->tlv_header,
21856 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21857 WMITLV_GET_STRUCT_TLVLEN
21858 (wmi_pdev_check_cal_version_cmd_fixed_param));
21859 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21860 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21861 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21862 wmi_buf_free(buf);
21863 return QDF_STATUS_E_FAILURE;
21864 }
21865
21866 return QDF_STATUS_SUCCESS;
21867}
21868
21869/**
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053021870 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
21871 * host to target defines.
21872 * @param pdev_id: host pdev_id to be converted.
21873 * Return: target pdev_id after conversion.
21874 */
21875static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
21876{
21877 switch (pdev_id) {
21878 case WMI_HOST_PDEV_ID_SOC:
21879 return WMI_PDEV_ID_SOC;
21880 case WMI_HOST_PDEV_ID_0:
21881 return WMI_PDEV_ID_1ST;
21882 case WMI_HOST_PDEV_ID_1:
21883 return WMI_PDEV_ID_2ND;
21884 case WMI_HOST_PDEV_ID_2:
21885 return WMI_PDEV_ID_3RD;
21886 }
21887
21888 QDF_ASSERT(0);
21889
21890 return WMI_PDEV_ID_SOC;
21891}
21892
21893/**
21894 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
21895 * target to host defines.
21896 * @param pdev_id: target pdev_id to be converted.
21897 * Return: host pdev_id after conversion.
21898 */
21899static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
21900{
21901 switch (pdev_id) {
21902 case WMI_PDEV_ID_SOC:
21903 return WMI_HOST_PDEV_ID_SOC;
21904 case WMI_PDEV_ID_1ST:
21905 return WMI_HOST_PDEV_ID_0;
21906 case WMI_PDEV_ID_2ND:
21907 return WMI_HOST_PDEV_ID_1;
21908 case WMI_PDEV_ID_3RD:
21909 return WMI_HOST_PDEV_ID_2;
21910 }
21911
21912 QDF_ASSERT(0);
21913
21914 return WMI_HOST_PDEV_ID_SOC;
21915}
21916
21917/**
21918 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
21919 *
21920 * Return None.
21921 */
21922static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
21923{
21924 wmi_handle->ops->convert_pdev_id_host_to_target =
21925 convert_host_pdev_id_to_target_pdev_id;
21926 wmi_handle->ops->convert_pdev_id_target_to_host =
21927 convert_target_pdev_id_to_host_pdev_id;
21928}
21929
21930/**
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021931 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21932 * @wmi_handle: wmi handle
21933 * @param evt_buf: pointer to event buffer
21934 * @param param: Pointer to hold peer caldata version data
21935 *
21936 * Return: 0 for success or error code
21937 */
21938static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21939 wmi_unified_t wmi_handle,
21940 void *evt_buf,
21941 wmi_host_pdev_check_cal_version_event *param)
21942{
21943 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21944 wmi_pdev_check_cal_version_event_fixed_param *event;
21945
21946 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21947 if (!param_tlvs) {
21948 WMI_LOGE("invalid cal version event buf");
21949 return QDF_STATUS_E_FAILURE;
21950 }
21951 event = param_tlvs->fixed_param;
21952 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21953 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21954 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21955 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21956
21957 param->software_cal_version = event->software_cal_version;
21958 param->board_cal_version = event->board_cal_version;
21959 param->cal_ok = event->cal_status;
21960
21961 return QDF_STATUS_SUCCESS;
21962}
21963
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021964/*
21965 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21966 * @wmi_handle: wmi handle
21967 * @params: pointer to wmi_btm_config
21968 *
21969 * Return: QDF_STATUS
21970 */
21971static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21972 struct wmi_btm_config *params)
21973{
21974
21975 wmi_btm_config_fixed_param *cmd;
21976 wmi_buf_t buf;
21977 uint32_t len;
21978
21979 len = sizeof(*cmd);
21980 buf = wmi_buf_alloc(wmi_handle, len);
21981 if (!buf) {
21982 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21983 return QDF_STATUS_E_NOMEM;
21984 }
21985
21986 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21987 WMITLV_SET_HDR(&cmd->tlv_header,
21988 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21989 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21990 cmd->vdev_id = params->vdev_id;
21991 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021992 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21993 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21994 cmd->stick_time_seconds = params->btm_sticky_time;
21995
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021996 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21997 WMI_ROAM_BTM_CONFIG_CMDID)) {
21998 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21999 __func__);
22000 wmi_buf_free(buf);
22001 return QDF_STATUS_E_FAILURE;
22002 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080022003
22004 return QDF_STATUS_SUCCESS;
22005}
22006
22007/**
22008 * send_obss_detection_cfg_cmd_tlv() - send obss detection
22009 * configurations to firmware.
22010 * @wmi_handle: wmi handle
22011 * @obss_cfg_param: obss detection configurations
22012 *
22013 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
22014 *
22015 * Return: QDF_STATUS
22016 */
22017static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
22018 struct wmi_obss_detection_cfg_param *obss_cfg_param)
22019{
22020 wmi_buf_t buf;
22021 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
22022 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
22023
22024 buf = wmi_buf_alloc(wmi_handle, len);
22025 if (!buf) {
22026 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22027 return QDF_STATUS_E_NOMEM;
22028 }
22029
22030 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
22031 WMITLV_SET_HDR(&cmd->tlv_header,
22032 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
22033 WMITLV_GET_STRUCT_TLVLEN
22034 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
22035
22036 cmd->vdev_id = obss_cfg_param->vdev_id;
22037 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
22038 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
22039 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
22040 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
22041 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
22042 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
22043 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
22044 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022045
22046 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22047 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
22048 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
22049 wmi_buf_free(buf);
22050 return QDF_STATUS_E_FAILURE;
22051 }
22052
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022053 return QDF_STATUS_SUCCESS;
22054}
22055
Arif Hussain33d98502018-01-12 13:15:04 -080022056/**
22057 * extract_obss_detection_info_tlv() - Extract obss detection info
22058 * received from firmware.
22059 * @evt_buf: pointer to event buffer
22060 * @obss_detection: Pointer to hold obss detection info
22061 *
22062 * Return: QDF_STATUS
22063 */
22064static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
22065 struct wmi_obss_detect_info
22066 *obss_detection)
22067{
22068 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
22069 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
22070
22071 if (!obss_detection) {
22072 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
22073 return QDF_STATUS_E_INVAL;
22074 }
22075
22076 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
22077 if (!param_buf) {
22078 WMI_LOGE("%s: Invalid evt_buf", __func__);
22079 return QDF_STATUS_E_INVAL;
22080 }
22081
22082 fix_param = param_buf->fixed_param;
22083 obss_detection->vdev_id = fix_param->vdev_id;
22084 obss_detection->matched_detection_masks =
22085 fix_param->matched_detection_masks;
22086 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
22087 &obss_detection->matched_bssid_addr[0]);
22088 switch (fix_param->reason) {
22089 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
22090 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
22091 break;
22092 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
22093 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
22094 break;
22095 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
22096 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
22097 break;
22098 default:
22099 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
22100 return QDF_STATUS_E_INVAL;
22101 }
22102
22103 return QDF_STATUS_SUCCESS;
22104}
22105
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022106/**
22107 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
22108 * @wmi_handle: wmi handler
22109 * @params: pointer to 11k offload params
22110 *
22111 * Return: 0 for success and non zero for failure
22112 */
22113static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
22114 struct wmi_11k_offload_params *params)
22115{
22116 wmi_11k_offload_report_fixed_param *cmd;
22117 wmi_buf_t buf;
22118 QDF_STATUS status;
22119 uint8_t *buf_ptr;
22120 wmi_neighbor_report_11k_offload_tlv_param
22121 *neighbor_report_offload_params;
22122 wmi_neighbor_report_offload *neighbor_report_offload;
22123
22124 uint32_t len = sizeof(*cmd);
22125
22126 if (params->offload_11k_bitmask &
22127 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
22128 len += WMI_TLV_HDR_SIZE +
22129 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
22130
22131 buf = wmi_buf_alloc(wmi_handle, len);
22132 if (!buf) {
22133 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
22134 __func__);
22135 return QDF_STATUS_E_NOMEM;
22136 }
22137
22138 buf_ptr = (uint8_t *) wmi_buf_data(buf);
22139 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
22140
22141 WMITLV_SET_HDR(&cmd->tlv_header,
22142 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
22143 WMITLV_GET_STRUCT_TLVLEN(
22144 wmi_11k_offload_report_fixed_param));
22145
22146 cmd->vdev_id = params->vdev_id;
22147 cmd->offload_11k = params->offload_11k_bitmask;
22148
22149 if (params->offload_11k_bitmask &
22150 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
22151 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
22152
22153 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
22154 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
22155 buf_ptr += WMI_TLV_HDR_SIZE;
22156
22157 neighbor_report_offload_params =
22158 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
22159 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
22160 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
22161 WMITLV_GET_STRUCT_TLVLEN(
22162 wmi_neighbor_report_11k_offload_tlv_param));
22163
22164 neighbor_report_offload = &neighbor_report_offload_params->
22165 neighbor_rep_ofld_params;
22166
22167 neighbor_report_offload->time_offset =
22168 params->neighbor_report_params.time_offset;
22169 neighbor_report_offload->low_rssi_offset =
22170 params->neighbor_report_params.low_rssi_offset;
22171 neighbor_report_offload->bmiss_count_trigger =
22172 params->neighbor_report_params.bmiss_count_trigger;
22173 neighbor_report_offload->per_threshold_offset =
22174 params->neighbor_report_params.per_threshold_offset;
22175 neighbor_report_offload->neighbor_report_cache_timeout =
22176 params->neighbor_report_params.
22177 neighbor_report_cache_timeout;
22178 neighbor_report_offload->max_neighbor_report_req_cap =
22179 params->neighbor_report_params.
22180 max_neighbor_report_req_cap;
22181 neighbor_report_offload->ssid.ssid_len =
22182 params->neighbor_report_params.ssid.length;
22183 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
22184 &params->neighbor_report_params.ssid.mac_ssid,
22185 neighbor_report_offload->ssid.ssid_len);
22186 }
22187
22188 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22189 WMI_11K_OFFLOAD_REPORT_CMDID);
22190 if (status != QDF_STATUS_SUCCESS) {
22191 WMI_LOGE("%s: failed to send 11k offload command %d",
22192 __func__, status);
22193 wmi_buf_free(buf);
22194 }
22195
22196 return status;
22197}
22198
22199/**
22200 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
22201 * command
22202 * @wmi_handle: wmi handler
22203 * @params: pointer to neighbor report invoke params
22204 *
22205 * Return: 0 for success and non zero for failure
22206 */
22207static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
22208 struct wmi_invoke_neighbor_report_params *params)
22209{
22210 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
22211 wmi_buf_t buf;
22212 QDF_STATUS status;
22213 uint8_t *buf_ptr;
22214 uint32_t len = sizeof(*cmd);
22215
22216 buf = wmi_buf_alloc(wmi_handle, len);
22217 if (!buf) {
22218 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
22219 __func__);
22220 return QDF_STATUS_E_NOMEM;
22221 }
22222
22223 buf_ptr = (uint8_t *) wmi_buf_data(buf);
22224 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
22225
22226 WMITLV_SET_HDR(&cmd->tlv_header,
22227 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
22228 WMITLV_GET_STRUCT_TLVLEN(
22229 wmi_11k_offload_invoke_neighbor_report_fixed_param));
22230
22231 cmd->vdev_id = params->vdev_id;
22232 cmd->flags = params->send_resp_to_host;
22233
22234 cmd->ssid.ssid_len = params->ssid.length;
22235 qdf_mem_copy(cmd->ssid.ssid,
22236 &params->ssid.mac_ssid,
22237 cmd->ssid.ssid_len);
22238
22239 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22240 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
22241 if (status != QDF_STATUS_SUCCESS) {
22242 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
22243 __func__, status);
22244 wmi_buf_free(buf);
22245 }
22246
22247 return status;
22248}
22249
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022250#ifdef WLAN_SUPPORT_GREEN_AP
22251static QDF_STATUS extract_green_ap_egap_status_info_tlv(
22252 uint8_t *evt_buf,
22253 struct wlan_green_ap_egap_status_info *egap_status_info_params)
22254{
22255 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
22256 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
22257 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
22258
22259 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
22260 if (!param_buf) {
22261 WMI_LOGE("Invalid EGAP Info status event buffer");
22262 return QDF_STATUS_E_INVAL;
22263 }
22264
22265 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
22266 param_buf->fixed_param;
22267 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
22268 param_buf->chainmask_list;
22269
22270 egap_status_info_params->status = egap_info_event->status;
22271 egap_status_info_params->mac_id = chainmask_event->mac_id;
22272 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
22273 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
22274
22275 return QDF_STATUS_SUCCESS;
22276}
22277#endif
22278
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022279/*
22280 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
22281 * updating bss color change within firmware when AP announces bss color change.
22282 * @wmi_handle: wmi handle
22283 * @vdev_id: vdev ID
22284 * @enable: enable bss color change within firmware
22285 *
22286 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
22287 *
22288 * Return: QDF_STATUS
22289 */
22290static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
22291 uint32_t vdev_id,
22292 bool enable)
22293{
22294 wmi_buf_t buf;
22295 wmi_bss_color_change_enable_fixed_param *cmd;
22296 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
22297
22298 buf = wmi_buf_alloc(wmi_handle, len);
22299 if (!buf) {
22300 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22301 return QDF_STATUS_E_NOMEM;
22302 }
22303
22304 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
22305 WMITLV_SET_HDR(&cmd->tlv_header,
22306 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
22307 WMITLV_GET_STRUCT_TLVLEN
22308 (wmi_bss_color_change_enable_fixed_param));
22309 cmd->vdev_id = vdev_id;
22310 cmd->enable = enable;
22311 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22312 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
22313 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
22314 wmi_buf_free(buf);
22315 return QDF_STATUS_E_FAILURE;
22316 }
22317
22318 return QDF_STATUS_SUCCESS;
22319}
22320
22321/**
22322 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
22323 * configurations to firmware.
22324 * @wmi_handle: wmi handle
22325 * @cfg_param: obss detection configurations
22326 *
22327 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
22328 *
22329 * Return: QDF_STATUS
22330 */
22331static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
22332 wmi_unified_t wmi_handle,
22333 struct wmi_obss_color_collision_cfg_param *cfg_param)
22334{
22335 wmi_buf_t buf;
22336 wmi_obss_color_collision_det_config_fixed_param *cmd;
22337 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
22338
22339 buf = wmi_buf_alloc(wmi_handle, len);
22340 if (!buf) {
22341 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22342 return QDF_STATUS_E_NOMEM;
22343 }
22344
22345 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
22346 buf);
22347 WMITLV_SET_HDR(&cmd->tlv_header,
22348 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
22349 WMITLV_GET_STRUCT_TLVLEN
22350 (wmi_obss_color_collision_det_config_fixed_param));
22351 cmd->vdev_id = cfg_param->vdev_id;
22352 cmd->flags = cfg_param->flags;
22353 cmd->current_bss_color = cfg_param->current_bss_color;
22354 cmd->detection_period_ms = cfg_param->detection_period_ms;
22355 cmd->scan_period_ms = cfg_param->scan_period_ms;
22356 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
22357
22358 switch (cfg_param->evt_type) {
22359 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
22360 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
22361 break;
22362 case OBSS_COLOR_COLLISION_DETECTION:
22363 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
22364 break;
22365 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22366 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22367 break;
22368 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
22369 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
22370 break;
22371 default:
22372 WMI_LOGE("%s: invalid event type: %d",
22373 __func__, cfg_param->evt_type);
22374 wmi_buf_free(buf);
22375 return QDF_STATUS_E_FAILURE;
22376 }
22377
22378 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22379 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
22380 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
22381 __func__, cfg_param->vdev_id);
22382 wmi_buf_free(buf);
22383 return QDF_STATUS_E_FAILURE;
22384 }
22385
22386 return QDF_STATUS_SUCCESS;
22387}
22388
22389/**
22390 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
22391 * received from firmware.
22392 * @evt_buf: pointer to event buffer
22393 * @info: Pointer to hold bss collision info
22394 *
22395 * Return: QDF_STATUS
22396 */
22397static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
22398 struct wmi_obss_color_collision_info *info)
22399{
22400 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
22401 wmi_obss_color_collision_evt_fixed_param *fix_param;
22402
22403 if (!info) {
22404 WMI_LOGE("%s: Invalid obss color buffer", __func__);
22405 return QDF_STATUS_E_INVAL;
22406 }
22407
22408 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
22409 evt_buf;
22410 if (!param_buf) {
22411 WMI_LOGE("%s: Invalid evt_buf", __func__);
22412 return QDF_STATUS_E_INVAL;
22413 }
22414
22415 fix_param = param_buf->fixed_param;
22416 info->vdev_id = fix_param->vdev_id;
22417 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
22418 info->obss_color_bitmap_bit32to63 =
22419 fix_param->bss_color_bitmap_bit32to63;
22420
22421 switch (fix_param->evt_type) {
22422 case WMI_BSS_COLOR_COLLISION_DISABLE:
22423 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
22424 break;
22425 case WMI_BSS_COLOR_COLLISION_DETECTION:
22426 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
22427 break;
22428 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22429 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22430 break;
22431 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
22432 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
22433 break;
22434 default:
22435 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
22436 __func__, fix_param->evt_type, fix_param->vdev_id);
22437 return QDF_STATUS_E_FAILURE;
22438 }
22439
22440 return QDF_STATUS_SUCCESS;
22441}
22442
Arif Hussaine0eb7302018-03-01 14:40:59 -080022443/*
22444 * extract_comb_phyerr_tlv() - extract comb phy error from event
22445 * @wmi_handle: wmi handle
22446 * @evt_buf: pointer to event buffer
22447 * @datalen: data length of event buffer
22448 * @buf_offset: Pointer to hold value of current event buffer offset
22449 * post extraction
22450 * @phyerr: Pointer to hold phyerr
22451 *
22452 * Return: QDF_STATUS
22453 */
22454static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
22455 void *evt_buf,
22456 uint16_t datalen,
22457 uint16_t *buf_offset,
22458 wmi_host_phyerr_t *phyerr)
22459{
22460 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
22461 wmi_comb_phyerr_rx_hdr *pe_hdr;
22462
22463 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
22464 if (!param_tlvs) {
22465 WMI_LOGD("%s: Received null data from FW", __func__);
22466 return QDF_STATUS_E_FAILURE;
22467 }
22468
22469 pe_hdr = param_tlvs->hdr;
22470 if (!pe_hdr) {
22471 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
22472 return QDF_STATUS_E_FAILURE;
22473 }
22474
22475 /* Ensure it's at least the size of the header */
22476 if (datalen < sizeof(*pe_hdr)) {
22477 WMI_LOGD("%s: Expected minimum size %zu, received %d",
22478 __func__, sizeof(*pe_hdr), datalen);
22479 return QDF_STATUS_E_FAILURE;
22480 }
22481
22482 phyerr->pdev_id = wmi_handle->ops->
22483 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
22484 phyerr->tsf64 = pe_hdr->tsf_l32;
22485 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
22486 phyerr->bufp = param_tlvs->bufp;
22487 phyerr->buf_len = pe_hdr->buf_len;
22488 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
22489 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
22490 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
22491
22492 return QDF_STATUS_SUCCESS;
22493}
22494
22495/**
22496 * extract_single_phyerr_tlv() - extract single phy error from event
22497 * @wmi_handle: wmi handle
22498 * @evt_buf: pointer to event buffer
22499 * @datalen: data length of event buffer
22500 * @buf_offset: Pointer to hold value of current event buffer offset
22501 * post extraction
22502 * @phyerr: Pointer to hold phyerr
22503 *
22504 * Return: QDF_STATUS
22505 */
22506static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
22507 void *evt_buf,
22508 uint16_t datalen,
22509 uint16_t *buf_offset,
22510 wmi_host_phyerr_t *phyerr)
22511{
22512 wmi_single_phyerr_rx_event *ev;
22513 uint16_t n = *buf_offset;
22514 uint8_t *data = (uint8_t *)evt_buf;
22515
22516 if (n < datalen) {
22517 if ((datalen - n) < sizeof(ev->hdr)) {
22518 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
22519 __func__, datalen, n, sizeof(ev->hdr));
22520 return QDF_STATUS_E_FAILURE;
22521 }
22522
22523 /*
22524 * Obtain a pointer to the beginning of the current event.
22525 * data[0] is the beginning of the WMI payload.
22526 */
22527 ev = (wmi_single_phyerr_rx_event *)&data[n];
22528
22529 /*
22530 * Sanity check the buffer length of the event against
22531 * what we currently have.
22532 *
22533 * Since buf_len is 32 bits, we check if it overflows
22534 * a large 32 bit value. It's not 0x7fffffff because
22535 * we increase n by (buf_len + sizeof(hdr)), which would
22536 * in itself cause n to overflow.
22537 *
22538 * If "int" is 64 bits then this becomes a moot point.
22539 */
22540 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
22541 WMI_LOGD("%s: buf_len is garbage 0x%x",
22542 __func__, ev->hdr.buf_len);
22543 return QDF_STATUS_E_FAILURE;
22544 }
22545
22546 if ((n + ev->hdr.buf_len) > datalen) {
22547 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
22548 __func__, n, ev->hdr.buf_len, datalen);
22549 return QDF_STATUS_E_FAILURE;
22550 }
22551
22552 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
22553 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
22554 phyerr->bufp = &ev->bufp[0];
22555 phyerr->buf_len = ev->hdr.buf_len;
22556 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
22557
22558 /*
22559 * Advance the buffer pointer to the next PHY error.
22560 * buflen is the length of this payload, so we need to
22561 * advance past the current header _AND_ the payload.
22562 */
22563 n += sizeof(*ev) + ev->hdr.buf_len;
22564 }
22565 *buf_offset = n;
22566
22567 return QDF_STATUS_SUCCESS;
22568}
22569
Govind Singh5eb51532016-03-09 11:34:12 +053022570struct wmi_ops tlv_ops = {
22571 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
22572 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
22573 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053022574 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
22575 .send_hidden_ssid_vdev_restart_cmd =
22576 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022577 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
22578 .send_peer_param_cmd = send_peer_param_cmd_tlv,
22579 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022580 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022581 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022582 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070022583 .send_peer_rx_reorder_queue_setup_cmd =
22584 send_peer_rx_reorder_queue_setup_cmd_tlv,
22585 .send_peer_rx_reorder_queue_remove_cmd =
22586 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053022587 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
22588 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
22589 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022590 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
22591 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022592 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022593 .send_suspend_cmd = send_suspend_cmd_tlv,
22594 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080022595#ifdef FEATURE_WLAN_D0WOW
22596 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
22597 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
22598#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022599 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
22600 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
22601 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
22602 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080022603#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053022604 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080022605#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022606 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
22607 .send_stats_request_cmd = send_stats_request_cmd_tlv,
22608 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053022609 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070022610 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022611 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022612 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022613 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
22614 .send_scan_start_cmd = send_scan_start_cmd_tlv,
22615 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
22616 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022617 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022618 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022619 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
22620 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022621 .send_set_sta_uapsd_auto_trig_cmd =
22622 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022623 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
22624 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
22625 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022626#ifdef CONVERGED_P2P_ENABLE
22627 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
22628 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
22629#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053022630 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
22631 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022632#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053022633 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
22634 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
22635 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
22636 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
22637 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
22638 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
22639 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022640 .send_ocb_start_timing_advert_cmd =
22641 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022642 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
22643 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
22644 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
22645 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
22646#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053022647 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
22648 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
22649 .send_set_mcc_channel_time_latency_cmd =
22650 send_set_mcc_channel_time_latency_cmd_tlv,
22651 .send_set_mcc_channel_time_quota_cmd =
22652 send_set_mcc_channel_time_quota_cmd_tlv,
22653 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
22654 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053022655 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022656 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
22657 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
22658 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022659 .send_probe_rsp_tmpl_send_cmd =
22660 send_probe_rsp_tmpl_send_cmd_tlv,
22661 .send_p2p_go_set_beacon_ie_cmd =
22662 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053022663 .send_setup_install_key_cmd =
22664 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022665 .send_set_gateway_params_cmd =
22666 send_set_gateway_params_cmd_tlv,
22667 .send_set_rssi_monitoring_cmd =
22668 send_set_rssi_monitoring_cmd_tlv,
22669 .send_scan_probe_setoui_cmd =
22670 send_scan_probe_setoui_cmd_tlv,
22671 .send_reset_passpoint_network_list_cmd =
22672 send_reset_passpoint_network_list_cmd_tlv,
22673 .send_set_passpoint_network_list_cmd =
22674 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022675 .send_roam_scan_offload_rssi_thresh_cmd =
22676 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070022677 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022678 .send_roam_scan_filter_cmd =
22679 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022680 .send_set_epno_network_list_cmd =
22681 send_set_epno_network_list_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022682#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053022683 .send_ipa_offload_control_cmd =
22684 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022685#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053022686 .send_extscan_get_capabilities_cmd =
22687 send_extscan_get_capabilities_cmd_tlv,
22688 .send_extscan_get_cached_results_cmd =
22689 send_extscan_get_cached_results_cmd_tlv,
22690 .send_extscan_stop_change_monitor_cmd =
22691 send_extscan_stop_change_monitor_cmd_tlv,
22692 .send_extscan_start_change_monitor_cmd =
22693 send_extscan_start_change_monitor_cmd_tlv,
22694 .send_extscan_stop_hotlist_monitor_cmd =
22695 send_extscan_stop_hotlist_monitor_cmd_tlv,
22696 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
22697 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
22698 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
22699 .send_plm_start_cmd = send_plm_start_cmd_tlv,
22700 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
22701 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070022702 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022703 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
22704 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
22705 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
22706 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053022707 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022708 .send_snr_request_cmd = send_snr_request_cmd_tlv,
22709 .send_snr_cmd = send_snr_cmd_tlv,
22710 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022711#ifdef WLAN_PMO_ENABLE
22712 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
22713 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
22714 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
22715 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053022716 .send_multiple_add_clear_mcbc_filter_cmd =
22717 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070022718 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022719 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
22720 .send_process_gtk_offload_getinfo_cmd =
22721 send_process_gtk_offload_getinfo_cmd_tlv,
22722 .send_enable_enhance_multicast_offload_cmd =
22723 send_enable_enhance_multicast_offload_tlv,
22724 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
22725#ifdef FEATURE_WLAN_RA_FILTERING
22726 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
22727#endif
22728 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022729 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
22730 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022731 .send_lphb_config_tcp_pkt_filter_cmd =
22732 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022733 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22734 .send_lphb_config_udp_pkt_filter_cmd =
22735 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022736 .send_enable_disable_packet_filter_cmd =
22737 send_enable_disable_packet_filter_cmd_tlv,
22738 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022739#endif /* End of WLAN_PMO_ENABLE */
22740#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022741 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22742 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022743 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022744 .send_roam_scan_offload_mode_cmd =
22745 send_roam_scan_offload_mode_cmd_tlv,
22746 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
22747 .send_roam_scan_offload_ap_profile_cmd =
22748 send_roam_scan_offload_ap_profile_cmd_tlv,
22749#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022750#ifdef WLAN_SUPPORT_GREEN_AP
22751 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22752 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022753 .extract_green_ap_egap_status_info =
22754 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022755#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022756 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22757 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022758 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022759 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022760 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022761#ifdef WLAN_FEATURE_CIF_CFR
22762 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22763#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022764 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022765 .send_dfs_phyerr_filter_offload_en_cmd =
22766 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022767 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22768 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22769 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22770 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22771 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022772 .send_process_add_periodic_tx_ptrn_cmd =
22773 send_process_add_periodic_tx_ptrn_cmd_tlv,
22774 .send_process_del_periodic_tx_ptrn_cmd =
22775 send_process_del_periodic_tx_ptrn_cmd_tlv,
22776 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22777 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22778 .send_set_app_type2_params_in_fw_cmd =
22779 send_set_app_type2_params_in_fw_cmd_tlv,
22780 .send_set_auto_shutdown_timer_cmd =
22781 send_set_auto_shutdown_timer_cmd_tlv,
22782 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22783 .send_process_dhcpserver_offload_cmd =
22784 send_process_dhcpserver_offload_cmd_tlv,
22785 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22786 .send_process_ch_avoid_update_cmd =
22787 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022788 .send_pdev_set_regdomain_cmd =
22789 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022790 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22791 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22792 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22793 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022794 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022795 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022796 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022797 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022798 .send_set_base_macaddr_indicate_cmd =
22799 send_set_base_macaddr_indicate_cmd_tlv,
22800 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22801 .send_enable_specific_fw_logs_cmd =
22802 send_enable_specific_fw_logs_cmd_tlv,
22803 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022804 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022805 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022806#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022807 .send_pdev_set_dual_mac_config_cmd =
22808 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022809#endif
Govind Singha4836fd2016-03-07 16:45:38 +053022810 .send_app_type1_params_in_fw_cmd =
22811 send_app_type1_params_in_fw_cmd_tlv,
22812 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22813 .send_process_roam_synch_complete_cmd =
22814 send_process_roam_synch_complete_cmd_tlv,
22815 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22816 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22817 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022818 .send_roam_scan_offload_scan_period_cmd =
22819 send_roam_scan_offload_scan_period_cmd_tlv,
22820 .send_roam_scan_offload_chan_list_cmd =
22821 send_roam_scan_offload_chan_list_cmd_tlv,
22822 .send_roam_scan_offload_rssi_change_cmd =
22823 send_roam_scan_offload_rssi_change_cmd_tlv,
22824 .send_get_buf_extscan_hotlist_cmd =
22825 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080022826 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053022827 .send_adapt_dwelltime_params_cmd =
22828 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022829 .send_dbs_scan_sel_params_cmd =
22830 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022831 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022832 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22833 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22834 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22835 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22836 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22837 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022838 .send_vdev_set_custom_aggr_size_cmd =
22839 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022840 .send_vdev_set_qdepth_thresh_cmd =
22841 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022842 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22843 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22844 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022845 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22846 .send_smart_ant_set_training_info_cmd =
22847 send_smart_ant_set_training_info_cmd_tlv,
22848 .send_smart_ant_set_node_config_cmd =
22849 send_smart_ant_set_node_config_cmd_tlv,
22850 .send_set_atf_cmd = send_set_atf_cmd_tlv,
22851 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22852 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022853 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22854 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22855 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22856 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022857 .send_periodic_chan_stats_config_cmd =
22858 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022859 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22860 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22861 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022862 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22863 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22864 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22865 .send_vdev_spectral_configure_cmd =
22866 send_vdev_spectral_configure_cmd_tlv,
22867 .send_vdev_spectral_enable_cmd =
22868 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022869 .send_thermal_mitigation_param_cmd =
22870 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022871 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22872 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022873 .send_process_update_edca_param_cmd =
22874 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022875 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022876 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022877 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022878 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22879 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022880 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022881 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22882 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22883 .extract_host_mem_req = extract_host_mem_req_tlv,
22884 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022885 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022886 .is_service_enabled = is_service_enabled_tlv,
22887 .save_fw_version = save_fw_version_in_service_ready_tlv,
22888 .ready_extract_init_status = ready_extract_init_status_tlv,
22889 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022890 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022891 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022892 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22893 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022894 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022895 .extract_tbttoffset_update_params =
22896 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022897 .extract_ext_tbttoffset_update_params =
22898 extract_ext_tbttoffset_update_params_tlv,
22899 .extract_tbttoffset_num_vdevs =
22900 extract_tbttoffset_num_vdevs_tlv,
22901 .extract_ext_tbttoffset_num_vdevs =
22902 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022903 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22904 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22905 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22906 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022907#ifdef CONVERGED_TDLS_ENABLE
22908 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22909#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022910 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022911 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022912 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22913 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022914#ifdef CONVERGED_P2P_ENABLE
22915 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22916 .extract_p2p_lo_stop_ev_param =
22917 extract_p2p_lo_stop_ev_param_tlv,
22918#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022919 .extract_offchan_data_tx_compl_param =
22920 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022921 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22922 .extract_all_stats_count = extract_all_stats_counts_tlv,
22923 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022924 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022925 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22926 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070022927 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022928 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022929 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022930 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22931 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22932 .extract_chan_stats = extract_chan_stats_tlv,
22933 .extract_profile_ctx = extract_profile_ctx_tlv,
22934 .extract_profile_data = extract_profile_data_tlv,
22935 .extract_chan_info_event = extract_chan_info_event_tlv,
22936 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022937 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022938#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022939 .send_encrypt_decrypt_send_cmd =
22940 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022941 .extract_encrypt_decrypt_resp_event =
22942 extract_encrypt_decrypt_resp_event_tlv,
22943#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022944 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022945 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22946 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022947 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022948 .send_multiple_vdev_restart_req_cmd =
22949 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022950 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22951 .extract_hw_mode_cap_service_ready_ext =
22952 extract_hw_mode_cap_service_ready_ext_tlv,
22953 .extract_mac_phy_cap_service_ready_ext =
22954 extract_mac_phy_cap_service_ready_ext_tlv,
22955 .extract_reg_cap_service_ready_ext =
22956 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022957 .extract_dbr_ring_cap_service_ready_ext =
22958 extract_dbr_ring_cap_service_ready_ext_tlv,
22959 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22960 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022961 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022962 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022963 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022964 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22965 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22966 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022967 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022968 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022969 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022970 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022971 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022972 .extract_pdev_csa_switch_count_status =
22973 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022974 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022975 .extract_pdev_tpc_config_ev_param =
22976 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022977 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022978 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22979 .extract_peer_sta_ps_statechange_ev =
22980 extract_peer_sta_ps_statechange_ev_tlv,
22981 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022982 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080022983 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22984 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022985 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022986 extract_reg_chan_list_update_event_tlv,
22987 .extract_chainmask_tables =
22988 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022989 .extract_thermal_stats = extract_thermal_stats_tlv,
22990 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022991 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22992 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022993#ifdef DFS_COMPONENT_ENABLE
22994 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22995 .extract_dfs_radar_detection_event =
22996 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022997 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022998#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022999 .convert_pdev_id_host_to_target =
23000 convert_host_pdev_id_to_target_pdev_id_legacy,
23001 .convert_pdev_id_target_to_host =
23002 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070023003
23004 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
23005 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
23006 .extract_reg_11d_new_country_event =
23007 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053023008 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053023009 .send_limit_off_chan_cmd =
23010 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070023011 .extract_reg_ch_avoid_event =
23012 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053023013 .send_pdev_caldata_version_check_cmd =
23014 send_pdev_caldata_version_check_cmd_tlv,
23015 .extract_pdev_caldata_version_check_ev_param =
23016 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053023017 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
23018 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053023019 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
23020#if defined(WLAN_FEATURE_FILS_SK)
23021 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
23022#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070023023 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080023024#ifdef WLAN_FEATURE_NAN_CONVERGENCE
23025 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
23026 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
23027 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
23028 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
23029 .extract_ndp_ind = extract_ndp_ind_tlv,
23030 .extract_ndp_confirm = extract_ndp_confirm_tlv,
23031 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
23032 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
23033 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
Naveen Rawatd42ce382018-01-09 17:54:41 -080023034 .extract_ndp_sch_update = extract_ndp_sch_update_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080023035#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053023036 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080023037 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080023038 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053023039#ifdef WLAN_SUPPORT_FILS
23040 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
23041 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
23042 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
23043#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053023044 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
23045 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023046 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
23047 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
23048 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
23049 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080023050 .send_bss_color_change_enable_cmd =
23051 send_bss_color_change_enable_cmd_tlv,
23052 .send_obss_color_collision_cfg_cmd =
23053 send_obss_color_collision_cfg_cmd_tlv,
23054 .extract_obss_color_collision_info =
23055 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080023056 .extract_comb_phyerr = extract_comb_phyerr_tlv,
23057 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070023058#ifdef QCA_SUPPORT_CP_STATS
23059 .extract_cca_stats = extract_cca_stats_tlv,
23060#endif
Govind Singh5eb51532016-03-09 11:34:12 +053023061};
23062
Govind Singhe7f2f342016-05-23 12:12:52 +053023063/**
23064 * populate_tlv_event_id() - populates wmi event ids
23065 *
23066 * @param event_ids: Pointer to hold event ids
23067 * Return: None
23068 */
23069static void populate_tlv_events_id(uint32_t *event_ids)
23070{
23071 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
23072 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
23073 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
23074 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
23075 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
23076 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
23077 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
23078 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
23079 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
23080 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
23081 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
23082 event_ids[wmi_service_ready_ext_event_id] =
23083 WMI_SERVICE_READY_EXT_EVENTID;
23084 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
23085 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
23086 event_ids[wmi_vdev_install_key_complete_event_id] =
23087 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
23088 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
23089 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
23090
23091 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
23092 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
23093 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
23094 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
23095 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
23096 event_ids[wmi_peer_estimated_linkspeed_event_id] =
23097 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
23098 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053023099 event_ids[wmi_peer_delete_response_event_id] =
23100 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023101 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
23102 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
23103 event_ids[wmi_tbttoffset_update_event_id] =
23104 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053023105 event_ids[wmi_ext_tbttoffset_update_event_id] =
23106 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023107 event_ids[wmi_offload_bcn_tx_status_event_id] =
23108 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
23109 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
23110 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
23111 event_ids[wmi_mgmt_tx_completion_event_id] =
23112 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080023113 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
23114 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023115 event_ids[wmi_tx_delba_complete_event_id] =
23116 WMI_TX_DELBA_COMPLETE_EVENTID;
23117 event_ids[wmi_tx_addba_complete_event_id] =
23118 WMI_TX_ADDBA_COMPLETE_EVENTID;
23119 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
23120
23121 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
23122
23123 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
23124 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
23125
23126 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053023127 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023128
23129 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
23130
23131 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080023132 event_ids[wmi_p2p_lo_stop_event_id] =
23133 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023134 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
23135 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080023136 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053023137 WMI_D0_WOW_DISABLE_ACK_EVENTID;
23138 event_ids[wmi_wow_initial_wakeup_event_id] =
23139 WMI_WOW_INITIAL_WAKEUP_EVENTID;
23140
23141 event_ids[wmi_rtt_meas_report_event_id] =
23142 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
23143 event_ids[wmi_tsf_meas_report_event_id] =
23144 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
23145 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
23146 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
23147 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
23148 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
23149 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023150 event_ids[wmi_diag_event_id_log_supported_event_id] =
23151 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
23152 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
23153 event_ids[wmi_nlo_scan_complete_event_id] =
23154 WMI_NLO_SCAN_COMPLETE_EVENTID;
23155 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
23156 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
23157
23158 event_ids[wmi_gtk_offload_status_event_id] =
23159 WMI_GTK_OFFLOAD_STATUS_EVENTID;
23160 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
23161 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
23162 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
23163
23164 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
23165
23166 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
23167
23168 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
23169 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
23170 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
23171 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
23172 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
23173 event_ids[wmi_wlan_profile_data_event_id] =
23174 WMI_WLAN_PROFILE_DATA_EVENTID;
23175 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
23176 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
23177 event_ids[wmi_vdev_get_keepalive_event_id] =
23178 WMI_VDEV_GET_KEEPALIVE_EVENTID;
23179 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
23180
23181 event_ids[wmi_diag_container_event_id] =
23182 WMI_DIAG_DATA_CONTAINER_EVENTID;
23183
23184 event_ids[wmi_host_auto_shutdown_event_id] =
23185 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
23186
23187 event_ids[wmi_update_whal_mib_stats_event_id] =
23188 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
23189
23190 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
23191 event_ids[wmi_update_vdev_rate_stats_event_id] =
23192 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
23193
23194 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070023195 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023196
23197 /** Set OCB Sched Response, deprecated */
23198 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
23199
23200 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
23201 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
23202 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
23203
23204 /* GPIO Event */
23205 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
23206 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
23207
23208 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
23209 event_ids[wmi_rfkill_state_change_event_id] =
23210 WMI_RFKILL_STATE_CHANGE_EVENTID;
23211
23212 /* TDLS Event */
23213 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
23214
23215 event_ids[wmi_batch_scan_enabled_event_id] =
23216 WMI_BATCH_SCAN_ENABLED_EVENTID;
23217 event_ids[wmi_batch_scan_result_event_id] =
23218 WMI_BATCH_SCAN_RESULT_EVENTID;
23219 /* OEM Event */
23220 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
23221 event_ids[wmi_oem_meas_report_event_id] =
23222 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
23223 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
23224
23225 /* NAN Event */
23226 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
23227
23228 /* LPI Event */
23229 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
23230 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
23231 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
23232
23233 /* ExtScan events */
23234 event_ids[wmi_extscan_start_stop_event_id] =
23235 WMI_EXTSCAN_START_STOP_EVENTID;
23236 event_ids[wmi_extscan_operation_event_id] =
23237 WMI_EXTSCAN_OPERATION_EVENTID;
23238 event_ids[wmi_extscan_table_usage_event_id] =
23239 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
23240 event_ids[wmi_extscan_cached_results_event_id] =
23241 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
23242 event_ids[wmi_extscan_wlan_change_results_event_id] =
23243 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
23244 event_ids[wmi_extscan_hotlist_match_event_id] =
23245 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
23246 event_ids[wmi_extscan_capabilities_event_id] =
23247 WMI_EXTSCAN_CAPABILITIES_EVENTID;
23248 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
23249 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
23250
23251 /* mDNS offload events */
23252 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
23253
23254 /* SAP Authentication offload events */
23255 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
23256 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
23257
23258 /** Out-of-context-of-bss (OCB) events */
23259 event_ids[wmi_ocb_set_config_resp_event_id] =
23260 WMI_OCB_SET_CONFIG_RESP_EVENTID;
23261 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
23262 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
23263 event_ids[wmi_dcc_get_stats_resp_event_id] =
23264 WMI_DCC_GET_STATS_RESP_EVENTID;
23265 event_ids[wmi_dcc_update_ndl_resp_event_id] =
23266 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
23267 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
23268 /* System-On-Chip events */
23269 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
23270 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
23271 event_ids[wmi_soc_hw_mode_transition_event_id] =
23272 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
23273 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
23274 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053023275 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053023276 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
23277 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053023278 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053023279 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
23280 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
23281 event_ids[wmi_peer_sta_ps_statechg_event_id] =
23282 WMI_PEER_STA_PS_STATECHG_EVENTID;
23283 event_ids[wmi_pdev_channel_hopping_event_id] =
23284 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053023285 event_ids[wmi_offchan_data_tx_completion_event] =
23286 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070023287 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
23288 event_ids[wmi_dfs_radar_detection_event_id] =
23289 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053023290 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070023291 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053023292 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053023293 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053023294 event_ids[wmi_service_available_event_id] =
23295 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053023296 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053023297 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053023298 /* NDP events */
23299 event_ids[wmi_ndp_initiator_rsp_event_id] =
23300 WMI_NDP_INITIATOR_RSP_EVENTID;
23301 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
23302 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
23303 event_ids[wmi_ndp_responder_rsp_event_id] =
23304 WMI_NDP_RESPONDER_RSP_EVENTID;
23305 event_ids[wmi_ndp_end_indication_event_id] =
23306 WMI_NDP_END_INDICATION_EVENTID;
23307 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080023308 event_ids[wmi_ndl_schedule_update_event_id] =
23309 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053023310
23311 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
23312 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
23313 event_ids[wmi_pdev_chip_power_stats_event_id] =
23314 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
23315 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
23316 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
23317 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
23318 event_ids[wmi_bpf_capability_info_event_id] =
23319 WMI_BPF_CAPABILIY_INFO_EVENTID;
23320 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
23321 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
23322 event_ids[wmi_report_rx_aggr_failure_event_id] =
23323 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
23324 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
23325 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
23326 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
23327 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
23328 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
23329 event_ids[wmi_pdev_hw_mode_transition_event_id] =
23330 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
23331 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
23332 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
23333 event_ids[wmi_coex_bt_activity_event_id] =
23334 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
23335 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
23336 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
23337 event_ids[wmi_radio_tx_power_level_stats_event_id] =
23338 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
23339 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053023340 event_ids[wmi_dma_buf_release_event_id] =
23341 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080023342 event_ids[wmi_sap_obss_detection_report_event_id] =
23343 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053023344 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080023345 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080023346 event_ids[wmi_obss_color_collision_report_event_id] =
23347 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080023348 event_ids[wmi_pdev_div_rssi_antid_event_id] =
23349 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070023350 event_ids[wmi_twt_enable_complete_event_id] =
23351 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023352}
23353
Soumya Bhat488092d2017-03-22 14:41:01 +053023354/**
23355 * populate_tlv_service() - populates wmi services
23356 *
23357 * @param wmi_service: Pointer to hold wmi_service
23358 * Return: None
23359 */
23360static void populate_tlv_service(uint32_t *wmi_service)
23361{
23362 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023363 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023364 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
23365 wmi_service[wmi_service_roam_scan_offload] =
23366 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
23367 wmi_service[wmi_service_bcn_miss_offload] =
23368 WMI_SERVICE_BCN_MISS_OFFLOAD;
23369 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
23370 wmi_service[wmi_service_sta_advanced_pwrsave] =
23371 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
23372 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
23373 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
23374 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
23375 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
23376 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
23377 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
23378 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
23379 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
23380 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
23381 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
23382 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
23383 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
23384 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
23385 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
23386 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
23387 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
23388 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
23389 wmi_service[wmi_service_packet_power_save] =
23390 WMI_SERVICE_PACKET_POWER_SAVE;
23391 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
23392 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
23393 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
23394 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
23395 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
23396 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
23397 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
23398 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
23399 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
23400 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
23401 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
23402 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
23403 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
23404 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
23405 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
23406 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
23407 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
23408 wmi_service[wmi_service_mcc_bcn_interval_change] =
23409 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
23410 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
23411 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
23412 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
23413 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
23414 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
23415 wmi_service[wmi_service_lte_ant_share_support] =
23416 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
23417 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
23418 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
23419 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
23420 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
23421 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
23422 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
23423 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
23424 wmi_service[wmi_service_bcn_txrate_override] =
23425 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
23426 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
23427 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
23428 wmi_service[wmi_service_estimate_linkspeed] =
23429 WMI_SERVICE_ESTIMATE_LINKSPEED;
23430 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
23431 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
23432 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
23433 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
23434 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
23435 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
23436 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
23437 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
23438 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
23439 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
23440 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
23441 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
23442 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
23443 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
23444 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
23445 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
23446 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
23447 wmi_service[wmi_service_sap_auth_offload] =
23448 WMI_SERVICE_SAP_AUTH_OFFLOAD;
23449 wmi_service[wmi_service_dual_band_simultaneous_support] =
23450 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
23451 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
23452 wmi_service[wmi_service_ap_arpns_offload] =
23453 WMI_SERVICE_AP_ARPNS_OFFLOAD;
23454 wmi_service[wmi_service_per_band_chainmask_support] =
23455 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
23456 wmi_service[wmi_service_packet_filter_offload] =
23457 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
23458 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
23459 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
23460 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
23461 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
23462 wmi_service[wmi_service_multiple_vdev_restart] =
23463 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
23464
23465 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
23466 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
23467 wmi_service[wmi_service_smart_antenna_sw_support] =
23468 WMI_SERVICE_UNAVAILABLE;
23469 wmi_service[wmi_service_smart_antenna_hw_support] =
23470 WMI_SERVICE_UNAVAILABLE;
23471 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053023472 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023473 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053023474 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
23475 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
23476 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
23477 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
23478 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
23479 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
23480 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
23481 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053023482 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
23483 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
23484 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053023485 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023486 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
23487 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
23488 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
23489 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
23490 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
23491 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053023492 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
23493 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
23494 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
23495 wmi_service[wmi_service_unified_wow_capability] =
23496 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
23497 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
23498 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
23499 wmi_service[wmi_service_sync_delete_cmds] =
23500 WMI_SERVICE_SYNC_DELETE_CMDS;
23501 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
23502 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
23503 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
23504 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
23505 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
23506 wmi_service[wmi_service_deprecated_replace] =
23507 WMI_SERVICE_DEPRECATED_REPLACE;
23508 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
23509 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
23510 wmi_service[wmi_service_enhanced_mcast_filter] =
23511 WMI_SERVICE_ENHANCED_MCAST_FILTER;
23512 wmi_service[wmi_service_half_rate_quarter_rate_support] =
23513 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
23514 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
23515 wmi_service[wmi_service_p2p_listen_offload_support] =
23516 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
23517 wmi_service[wmi_service_mark_first_wakeup_packet] =
23518 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
23519 wmi_service[wmi_service_multiple_mcast_filter_set] =
23520 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
23521 wmi_service[wmi_service_host_managed_rx_reorder] =
23522 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
23523 wmi_service[wmi_service_flash_rdwr_support] =
23524 WMI_SERVICE_FLASH_RDWR_SUPPORT;
23525 wmi_service[wmi_service_wlan_stats_report] =
23526 WMI_SERVICE_WLAN_STATS_REPORT;
23527 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
23528 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
23529 wmi_service[wmi_service_dfs_phyerr_offload] =
23530 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
23531 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
23532 wmi_service[wmi_service_fw_mem_dump_support] =
23533 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
23534 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
23535 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
23536 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
23537 wmi_service[wmi_service_hw_data_filtering] =
23538 WMI_SERVICE_HW_DATA_FILTERING;
23539 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
23540 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053023541 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053023542 wmi_service[wmi_service_extended_nss_support] =
23543 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053023544 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053023545 wmi_service[wmi_service_bcn_offload_start_stop_support] =
23546 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053023547 wmi_service[wmi_service_offchan_data_tid_support] =
23548 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053023549 wmi_service[wmi_service_support_dma] =
23550 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023551 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
23552 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
23553 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053023554 wmi_service[wmi_service_11k_neighbour_report_support] =
23555 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080023556 wmi_service[wmi_service_ap_obss_detection_offload] =
23557 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
23558 wmi_service[wmi_service_bss_color_offload] =
23559 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053023560 wmi_service[wmi_service_gmac_offload_support] =
23561 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023562
Soumya Bhat488092d2017-03-22 14:41:01 +053023563}
23564
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023565#ifndef CONFIG_MCL
23566
Govind Singhe7f2f342016-05-23 12:12:52 +053023567/**
23568 * populate_pdev_param_tlv() - populates pdev params
23569 *
23570 * @param pdev_param: Pointer to hold pdev params
23571 * Return: None
23572 */
23573static void populate_pdev_param_tlv(uint32_t *pdev_param)
23574{
23575 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
23576 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
23577 pdev_param[wmi_pdev_param_txpower_limit2g] =
23578 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
23579 pdev_param[wmi_pdev_param_txpower_limit5g] =
23580 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
23581 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
23582 pdev_param[wmi_pdev_param_beacon_gen_mode] =
23583 WMI_PDEV_PARAM_BEACON_GEN_MODE;
23584 pdev_param[wmi_pdev_param_beacon_tx_mode] =
23585 WMI_PDEV_PARAM_BEACON_TX_MODE;
23586 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
23587 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
23588 pdev_param[wmi_pdev_param_protection_mode] =
23589 WMI_PDEV_PARAM_PROTECTION_MODE;
23590 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
23591 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
23592 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
23593 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
23594 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
23595 pdev_param[wmi_pdev_param_sta_kickout_th] =
23596 WMI_PDEV_PARAM_STA_KICKOUT_TH;
23597 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
23598 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
23599 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
23600 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
23601 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
23602 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
23603 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
23604 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
23605 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
23606 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
23607 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
23608 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
23609 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
23610 pdev_param[wmi_pdev_param_ltr_sleep_override] =
23611 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
23612 pdev_param[wmi_pdev_param_ltr_rx_override] =
23613 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
23614 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
23615 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
23616 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
23617 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
23618 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
23619 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
23620 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
23621 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
23622 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
23623 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
23624 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
23625 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
23626 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
23627 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
23628 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
23629 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
23630 pdev_param[wmi_pdev_param_peer_stats_update_period] =
23631 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
23632 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
23633 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
23634 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
23635 pdev_param[wmi_pdev_param_arp_ac_override] =
23636 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
23637 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
23638 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
23639 pdev_param[wmi_pdev_param_ani_poll_period] =
23640 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
23641 pdev_param[wmi_pdev_param_ani_listen_period] =
23642 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
23643 pdev_param[wmi_pdev_param_ani_ofdm_level] =
23644 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
23645 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
23646 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
23647 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
23648 pdev_param[wmi_pdev_param_idle_ps_config] =
23649 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
23650 pdev_param[wmi_pdev_param_power_gating_sleep] =
23651 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
23652 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
23653 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
23654 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
23655 pdev_param[wmi_pdev_param_hw_rfkill_config] =
23656 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
23657 pdev_param[wmi_pdev_param_low_power_rf_enable] =
23658 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
23659 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
23660 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
23661 pdev_param[wmi_pdev_param_power_collapse_enable] =
23662 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
23663 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
23664 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
23665 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
23666 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
23667 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
23668 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
23669 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
23670 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
23671 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
23672 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
23673 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
23674 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
23675 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
23676 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
23677 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
23678 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
23679 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
23680 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
23681 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
23682 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
23683 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
23684 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
23685 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
23686 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
23687 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
23688 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
23689 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
23690 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
23691 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
23692 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
23693 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
23694 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
23695 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
23696 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
23697 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
23698 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
23699 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
23700 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
23701 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23702 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23703 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23704 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23705 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23706 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023707 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23708 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23709 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023710 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23711 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023712 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023713 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023714 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23715 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23716 WMI_PDEV_PARAM_PROXY_STA_MODE;
23717 pdev_param[wmi_pdev_param_mu_group_policy] =
23718 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23719 pdev_param[wmi_pdev_param_noise_detection] =
23720 WMI_PDEV_PARAM_NOISE_DETECTION;
23721 pdev_param[wmi_pdev_param_noise_threshold] =
23722 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23723 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23724 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23725 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023726 pdev_param[wmi_pdev_param_atf_strict_sch] =
23727 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23728 pdev_param[wmi_pdev_param_atf_sched_duration] =
23729 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023730 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23731 pdev_param[wmi_pdev_param_sensitivity_level] =
23732 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23733 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23734 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23735 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23736 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023737 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23738 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23739 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23740 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023741 pdev_param[wmi_pdev_param_cca_threshold] =
23742 WMI_PDEV_PARAM_CCA_THRESHOLD;
23743 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23744 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023745 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023746 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23747 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23748 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23749 pdev_param[wmi_pdev_param_arp_srcaddr] =
23750 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23751 pdev_param[wmi_pdev_param_arp_dstaddr] =
23752 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23753 pdev_param[wmi_pdev_param_txpower_decr_db] =
23754 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023755 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23756 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023757 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23758 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023759 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023760 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023761 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23762 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023763 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23764 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023765 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23766 WMI_UNAVAILABLE_PARAM;
23767 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
23768 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023769 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23770 pdev_param[wmi_pdev_param_block_interbss] =
23771 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023772 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023773 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23774 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23775 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023776 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023777 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023778 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23779 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023780 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023781 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23782 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023783 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23784 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23785 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23786 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
23787 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
23788 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23789 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23790 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23791 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23792 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23793 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23794 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23795 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23796 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23797 pdev_param[wmi_pdev_param_fast_channel_reset] =
23798 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23799 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023800 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023801 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023802}
23803
23804/**
23805 * populate_vdev_param_tlv() - populates vdev params
23806 *
23807 * @param vdev_param: Pointer to hold vdev params
23808 * Return: None
23809 */
23810static void populate_vdev_param_tlv(uint32_t *vdev_param)
23811{
23812 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23813 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23814 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23815 vdev_param[wmi_vdev_param_beacon_interval] =
23816 WMI_VDEV_PARAM_BEACON_INTERVAL;
23817 vdev_param[wmi_vdev_param_listen_interval] =
23818 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23819 vdev_param[wmi_vdev_param_multicast_rate] =
23820 WMI_VDEV_PARAM_MULTICAST_RATE;
23821 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23822 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23823 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23824 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23825 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23826 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23827 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23828 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23829 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23830 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23831 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23832 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23833 vdev_param[wmi_vdev_param_bmiss_count_max] =
23834 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23835 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23836 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23837 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23838 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23839 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23840 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23841 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23842 vdev_param[wmi_vdev_param_disable_htprotection] =
23843 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23844 vdev_param[wmi_vdev_param_sta_quickkickout] =
23845 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23846 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23847 vdev_param[wmi_vdev_param_protection_mode] =
23848 WMI_VDEV_PARAM_PROTECTION_MODE;
23849 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23850 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23851 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23852 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23853 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23854 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23855 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23856 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23857 vdev_param[wmi_vdev_param_bcast_data_rate] =
23858 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23859 vdev_param[wmi_vdev_param_mcast_data_rate] =
23860 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23861 vdev_param[wmi_vdev_param_mcast_indicate] =
23862 WMI_VDEV_PARAM_MCAST_INDICATE;
23863 vdev_param[wmi_vdev_param_dhcp_indicate] =
23864 WMI_VDEV_PARAM_DHCP_INDICATE;
23865 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23866 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23867 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23868 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23869 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23870 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23871 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23872 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23873 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23874 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23875 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23876 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23877 vdev_param[wmi_vdev_param_packet_powersave] =
23878 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23879 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23880 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23881 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23882 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23883 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23884 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23885 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23886 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23887 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23888 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23889 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23890 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23891 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23892 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23893 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23894 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23895 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23896 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23897 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23898 vdev_param[wmi_vdev_param_roam_fw_offload] =
23899 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23900 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23901 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23902 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23903 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23904 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23905 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23906 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23907 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23908 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23909 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23910 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23911 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23912 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23913 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23914 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23915 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23916 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23917 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23918 vdev_param[wmi_vdev_param_inactivity_cnt] =
23919 WMI_VDEV_PARAM_INACTIVITY_CNT;
23920 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23921 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23922 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23923 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23924 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23925 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23926 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23927 vdev_param[wmi_vdev_param_rx_leak_window] =
23928 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23929 vdev_param[wmi_vdev_param_stats_avg_factor] =
23930 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23931 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23932 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23933 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23934 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23935 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23936 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023937 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23938 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023939 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023940 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23941 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23942 WMI_VDEV_PARAM_HE_RANGE_EXT;
23943 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23944 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023945 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023946 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23947 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23948 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23949 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23950 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23951 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23952 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023953 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23954 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23955 vdev_param[wmi_vdev_param_rc_num_retries] =
23956 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23957 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23958 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23959 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23960 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23961 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23962 vdev_param[wmi_vdev_param_vht80_ratemask] =
23963 WMI_VDEV_PARAM_VHT80_RATEMASK;
23964 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23965 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23966 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023967 vdev_param[wmi_vdev_param_set_he_ltf] =
23968 WMI_VDEV_PARAM_HE_LTF;
Sathish Kumar6011c742017-11-08 14:49:58 +053023969 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23970 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023971 vdev_param[wmi_vdev_param_set_ba_mode] =
23972 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023973 vdev_param[wmi_vdev_param_capabilities] =
23974 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023975 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23976 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023977}
23978#endif
23979
Govind Singh5eb51532016-03-09 11:34:12 +053023980/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023981 * populate_target_defines_tlv() - Populate target defines and params
23982 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023983 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023984 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023985 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023986#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023987static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023988{
Govind Singhe7f2f342016-05-23 12:12:52 +053023989 populate_pdev_param_tlv(wmi_handle->pdev_param);
23990 populate_vdev_param_tlv(wmi_handle->vdev_param);
23991}
23992#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023993static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23994{ }
23995#endif
23996
23997/**
Zhang Qian537fca62018-01-03 16:33:24 +080023998 * wmi_ocb_ut_attach() - Attach OCB test framework
23999 * @wmi_handle: wmi handle
24000 *
24001 * Return: None
24002 */
24003#ifdef WLAN_OCB_UT
24004void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
24005#else
24006static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
24007{
24008 return;
24009}
24010#endif
24011
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053024012/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053024013 * wmi_tlv_attach() - Attach TLV APIs
24014 *
24015 * Return: None
24016 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053024017void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053024018{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053024019 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080024020 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053024021 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053024022#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053024023 /* Skip saving WMI_CMD_HDR and TLV HDR */
24024 wmi_handle->log_info.buf_offset_command = 8;
24025 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053024026 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053024027#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053024028 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053024029 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053024030 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053024031 wmi_twt_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053024032}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080024033qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053024034
24035/**
24036 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
24037 *
24038 * Return: None
24039 */
24040void wmi_tlv_init(void)
24041{
24042 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
24043}