blob: 4327481a63254a1c45c7f95ce8fd551d2f550b65 [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>
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053027#ifdef FEATURE_WLAN_APF
Nachiket Kukade7d4f04b2018-05-21 17:28:32 +053028#include "wmi_unified_apf_tlv.h"
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053029#endif
Wu Gaocd3a8512017-03-13 20:17:34 +080030#ifdef CONVERGED_P2P_ENABLE
31#include "wlan_p2p_public_struct.h"
32#endif
Wu Gao52c0b772018-05-17 16:14:00 +080033#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Dustin Brownf31f88b2017-05-12 14:01:44 -070034#include "wlan_pmo_hw_filter_public_struct.h"
35#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053036#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053037#ifdef WLAN_SUPPORT_GREEN_AP
38#include "wlan_green_ap_api.h"
39#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053040
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080041#ifdef WLAN_FEATURE_NAN_CONVERGENCE
42#include "nan_public_structs.h"
43#endif
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070044#include "wmi_unified_twt_api.h"
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080045
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080046#ifdef WLAN_POLICY_MGR_ENABLE
47#include "wlan_policy_mgr_public_struct.h"
48#endif
49
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053050/* HTC service ids for WMI for multi-radio */
51static const uint32_t multi_svc_ids[] = {WMI_CONTROL_SVC,
52 WMI_CONTROL_SVC_WMAC1,
53 WMI_CONTROL_SVC_WMAC2};
54
Arif Hussainb522ac92018-06-27 10:51:06 -070055/**
56 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
57 * host to target defines.
58 * @param pdev_id: host pdev_id to be converted.
59 * Return: target pdev_id after conversion.
60 */
61static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
62{
63 switch (pdev_id) {
64 case WMI_HOST_PDEV_ID_SOC:
65 return WMI_PDEV_ID_SOC;
66 case WMI_HOST_PDEV_ID_0:
67 return WMI_PDEV_ID_1ST;
68 case WMI_HOST_PDEV_ID_1:
69 return WMI_PDEV_ID_2ND;
70 case WMI_HOST_PDEV_ID_2:
71 return WMI_PDEV_ID_3RD;
72 }
73
74 QDF_ASSERT(0);
75
76 return WMI_PDEV_ID_SOC;
77}
78
79/**
80 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
81 * target to host defines.
82 * @param pdev_id: target pdev_id to be converted.
83 * Return: host pdev_id after conversion.
84 */
85static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
86{
87 switch (pdev_id) {
88 case WMI_PDEV_ID_SOC:
89 return WMI_HOST_PDEV_ID_SOC;
90 case WMI_PDEV_ID_1ST:
91 return WMI_HOST_PDEV_ID_0;
92 case WMI_PDEV_ID_2ND:
93 return WMI_HOST_PDEV_ID_1;
94 case WMI_PDEV_ID_3RD:
95 return WMI_HOST_PDEV_ID_2;
96 }
97
98 QDF_ASSERT(0);
99
100 return WMI_HOST_PDEV_ID_SOC;
101}
102
103/**
104 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
105 *
106 * Return None.
107 */
108static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
109{
110 wmi_handle->ops->convert_pdev_id_host_to_target =
111 convert_host_pdev_id_to_target_pdev_id;
112 wmi_handle->ops->convert_pdev_id_target_to_host =
113 convert_target_pdev_id_to_host_pdev_id;
114}
115
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530116/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
117 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530118 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530119 * @cmd: pointer target vdev create command buffer
120 * @param: pointer host params for vdev create
121 *
122 * Return: None
123 */
124#ifdef CONFIG_MCL
125static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530126 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530127 wmi_vdev_create_cmd_fixed_param * cmd,
128 struct vdev_create_params *param)
129{
130 cmd->pdev_id = WMI_PDEV_ID_SOC;
131}
132#else
133static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530134 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530135 wmi_vdev_create_cmd_fixed_param * cmd,
136 struct vdev_create_params *param)
137{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530138 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
139 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530140}
141#endif
142
Govind Singh5eb51532016-03-09 11:34:12 +0530143/**
144 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
145 * @wmi_handle: wmi handle
146 * @param: pointer to hold vdev create parameter
147 * @macaddr: vdev mac address
148 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530149 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530150 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530151static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530152 uint8_t macaddr[IEEE80211_ADDR_LEN],
153 struct vdev_create_params *param)
154{
155 wmi_vdev_create_cmd_fixed_param *cmd;
156 wmi_buf_t buf;
157 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +0530158 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700159 int num_bands = 2;
160 uint8_t *buf_ptr;
161 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +0530162
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700163 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530164 buf = wmi_buf_alloc(wmi_handle, len);
165 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530166 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530167 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530168 }
169 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
170 WMITLV_SET_HDR(&cmd->tlv_header,
171 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
172 WMITLV_GET_STRUCT_TLVLEN
173 (wmi_vdev_create_cmd_fixed_param));
174 cmd->vdev_id = param->if_id;
175 cmd->vdev_type = param->type;
176 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700177 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530178 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530179 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700180 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
181 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530182 macaddr[0], macaddr[1], macaddr[2],
183 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700184 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
185 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
186 (num_bands * sizeof(wmi_vdev_txrx_streams)));
187 buf_ptr += WMI_TLV_HDR_SIZE;
188
Govind Singh224a7312016-06-21 14:33:26 +0530189 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700190 param->type, param->subtype,
191 param->nss_2g, param->nss_5g);
192 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
193 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
194 txrx_streams->supported_tx_streams = param->nss_2g;
195 txrx_streams->supported_rx_streams = param->nss_2g;
196 WMITLV_SET_HDR(&txrx_streams->tlv_header,
197 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
198 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
199
200 txrx_streams++;
201 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
202 txrx_streams->supported_tx_streams = param->nss_5g;
203 txrx_streams->supported_rx_streams = param->nss_5g;
204 WMITLV_SET_HDR(&txrx_streams->tlv_header,
205 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
206 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530207 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530208 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530209 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530210 wmi_buf_free(buf);
211 }
212
213 return ret;
214}
215
216/**
217 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
218 * @wmi_handle: wmi handle
219 * @if_id: vdev id
220 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530221 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530222 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530223static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530224 uint8_t if_id)
225{
226 wmi_vdev_delete_cmd_fixed_param *cmd;
227 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530228 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530229
230 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
231 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530232 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530233 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530234 }
235
236 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
237 WMITLV_SET_HDR(&cmd->tlv_header,
238 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
239 WMITLV_GET_STRUCT_TLVLEN
240 (wmi_vdev_delete_cmd_fixed_param));
241 cmd->vdev_id = if_id;
242 ret = wmi_unified_cmd_send(wmi_handle, buf,
243 sizeof(wmi_vdev_delete_cmd_fixed_param),
244 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530245 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530246 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530247 wmi_buf_free(buf);
248 }
Govind Singhb53420c2016-03-09 14:32:57 +0530249 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530250
251 return ret;
252}
253
254/**
255 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
256 * @wmi: wmi handle
257 * @vdev_id: vdev id
258 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530259 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530260 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530261static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530262 uint8_t vdev_id)
263{
264 wmi_vdev_stop_cmd_fixed_param *cmd;
265 wmi_buf_t buf;
266 int32_t len = sizeof(*cmd);
267
268 buf = wmi_buf_alloc(wmi, len);
269 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530270 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530271 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530272 }
273 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
274 WMITLV_SET_HDR(&cmd->tlv_header,
275 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
276 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
277 cmd->vdev_id = vdev_id;
278 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530279 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530280 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530281 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530282 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530283 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530284
285 return 0;
286}
287
288/**
289 * send_vdev_down_cmd_tlv() - send vdev down command to fw
290 * @wmi: wmi handle
291 * @vdev_id: vdev id
292 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530293 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530294 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530295static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530296{
297 wmi_vdev_down_cmd_fixed_param *cmd;
298 wmi_buf_t buf;
299 int32_t len = sizeof(*cmd);
300
301 buf = wmi_buf_alloc(wmi, len);
302 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530303 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530304 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530305 }
306 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
307 WMITLV_SET_HDR(&cmd->tlv_header,
308 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
309 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
310 cmd->vdev_id = vdev_id;
311 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530312 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530313 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530314 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530315 }
Govind Singhb53420c2016-03-09 14:32:57 +0530316 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530317
318 return 0;
319}
320
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530321#ifdef CONFIG_MCL
322static inline void copy_channel_info(
323 wmi_vdev_start_request_cmd_fixed_param * cmd,
324 wmi_channel *chan,
325 struct vdev_start_params *req)
326{
327 chan->mhz = req->chan_freq;
328
329 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
330
331 chan->band_center_freq1 = req->band_center_freq1;
332 chan->band_center_freq2 = req->band_center_freq2;
333
334 if (req->is_half_rate)
335 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
336 else if (req->is_quarter_rate)
337 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
338
Naveen Rawat44f2f432016-12-01 12:58:57 -0800339 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530340 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
341 cmd->disable_hw_ack = req->dis_hw_ack;
342 }
343
344 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
345 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
346
347}
348#else
349static inline void copy_channel_info(
350 wmi_vdev_start_request_cmd_fixed_param * cmd,
351 wmi_channel *chan,
352 struct vdev_start_params *req)
353{
354 chan->mhz = req->channel.mhz;
355
356 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
357
358 chan->band_center_freq1 = req->channel.cfreq1;
359 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800360 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530361
362 if (req->channel.half_rate)
363 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
364 else if (req->channel.quarter_rate)
365 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
366
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800367 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
368
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530369 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530370 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530371 cmd->disable_hw_ack = req->disable_hw_ack;
372 }
373
Krishna Rao0b952ea2017-03-20 13:30:10 +0530374 if (req->channel.dfs_set_cfreq2)
375 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
376
Kai Chen4710d462017-12-15 14:06:06 -0800377 /* According to firmware both reg power and max tx power
378 * on set channel power is used and set it to max reg
379 * power from regulatory.
380 */
381 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
382 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530383 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800384 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
385 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
386 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530387
388}
389#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530390/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530391 * send_vdev_start_cmd_tlv() - send vdev start request to fw
392 * @wmi_handle: wmi handle
393 * @req: vdev start params
394 *
395 * Return: QDF status
396 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530397static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530398 struct vdev_start_params *req)
399{
400 wmi_vdev_start_request_cmd_fixed_param *cmd;
401 wmi_buf_t buf;
402 wmi_channel *chan;
403 int32_t len, ret;
404 uint8_t *buf_ptr;
405
406 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
407 buf = wmi_buf_alloc(wmi_handle, len);
408 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530409 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530410 return QDF_STATUS_E_NOMEM;
411 }
412 buf_ptr = (uint8_t *) wmi_buf_data(buf);
413 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
414 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
415 WMITLV_SET_HDR(&cmd->tlv_header,
416 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
417 WMITLV_GET_STRUCT_TLVLEN
418 (wmi_vdev_start_request_cmd_fixed_param));
419 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
420 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
421 cmd->vdev_id = req->vdev_id;
422
423 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530424 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530425
426 cmd->beacon_interval = req->beacon_intval;
427 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530428
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800429 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
430 if (req->bcn_tx_rate_code)
431 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
432
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530433 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530434 cmd->beacon_interval = req->beacon_intval;
435 cmd->dtim_period = req->dtim_period;
436
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530437 /* Copy the SSID */
438 if (req->ssid.length) {
439 if (req->ssid.length < sizeof(cmd->ssid.ssid))
440 cmd->ssid.ssid_len = req->ssid.length;
441 else
442 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
443 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
444 cmd->ssid.ssid_len);
445 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530446
447 if (req->hidden_ssid)
448 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
449
450 if (req->pmf_enabled)
451 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530452 }
453
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700454 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530455 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530456 cmd->preferred_rx_streams = req->preferred_rx_streams;
457 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700458 cmd->cac_duration_ms = req->cac_duration_ms;
459 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700460 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530461
462 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
463 sizeof(wmi_channel));
464 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
465 cmd->num_noa_descriptors *
466 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800467 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530468 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
469 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800470 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
471 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
472 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530473 req->is_dfs, req->beacon_intval, cmd->dtim_period,
474 chan->band_center_freq1, chan->band_center_freq2,
475 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700476 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700477 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800478 req->regdomain, req->he_ops,
479 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530480
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530481 if (req->is_restart)
482 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
483 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530484 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530485 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
486 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530487 if (ret) {
488 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530489 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530490 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530491 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530492
493 return QDF_STATUS_SUCCESS;
494}
495
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530496/**
497 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
498 * @wmi_handle: wmi handle
499 * @restart_params: vdev restart params
500 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530501 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530502 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530503static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530504 struct hidden_ssid_vdev_restart_params *restart_params)
505{
506 wmi_vdev_start_request_cmd_fixed_param *cmd;
507 wmi_buf_t buf;
508 wmi_channel *chan;
509 int32_t len;
510 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530511 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530512
513 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
514 buf = wmi_buf_alloc(wmi_handle, len);
515 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530516 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530517 return QDF_STATUS_E_NOMEM;
518 }
519 buf_ptr = (uint8_t *) wmi_buf_data(buf);
520 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
521 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
522
523 WMITLV_SET_HDR(&cmd->tlv_header,
524 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
525 WMITLV_GET_STRUCT_TLVLEN
526 (wmi_vdev_start_request_cmd_fixed_param));
527
528 WMITLV_SET_HDR(&chan->tlv_header,
529 WMITLV_TAG_STRUC_wmi_channel,
530 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
531
532 cmd->vdev_id = restart_params->session_id;
533 cmd->ssid.ssid_len = restart_params->ssid_len;
534 qdf_mem_copy(cmd->ssid.ssid,
535 restart_params->ssid,
536 cmd->ssid.ssid_len);
537 cmd->flags = restart_params->flags;
538 cmd->requestor_id = restart_params->requestor_id;
539 cmd->disable_hw_ack = restart_params->disable_hw_ack;
540
541 chan->mhz = restart_params->mhz;
542 chan->band_center_freq1 =
543 restart_params->band_center_freq1;
544 chan->band_center_freq2 =
545 restart_params->band_center_freq2;
546 chan->info = restart_params->info;
547 chan->reg_info_1 = restart_params->reg_info_1;
548 chan->reg_info_2 = restart_params->reg_info_2;
549
550 cmd->num_noa_descriptors = 0;
551 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
552 sizeof(wmi_channel));
553 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
554 cmd->num_noa_descriptors *
555 sizeof(wmi_p2p_noa_descriptor));
556
557 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
558 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530559 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530560 wmi_buf_free(buf);
561 return QDF_STATUS_E_FAILURE;
562 }
563 return QDF_STATUS_SUCCESS;
564}
565
566
567/**
Govind Singh5eb51532016-03-09 11:34:12 +0530568 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
569 * @wmi: wmi handle
570 * @peer_addr: peer mac address
571 * @param: pointer to hold peer flush tid parameter
572 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -0700573 * Return: 0 for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530574 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530575static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530576 uint8_t peer_addr[IEEE80211_ADDR_LEN],
577 struct peer_flush_params *param)
578{
579 wmi_peer_flush_tids_cmd_fixed_param *cmd;
580 wmi_buf_t buf;
581 int32_t len = sizeof(*cmd);
582
583 buf = wmi_buf_alloc(wmi, len);
584 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530585 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530586 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530587 }
588 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
589 WMITLV_SET_HDR(&cmd->tlv_header,
590 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
591 WMITLV_GET_STRUCT_TLVLEN
592 (wmi_peer_flush_tids_cmd_fixed_param));
593 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
594 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
595 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530596 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530597 peer_addr, param->vdev_id,
598 param->peer_tid_bitmap);
599 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530600 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530601 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530602 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530603 }
604
605 return 0;
606}
607
608/**
609 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
610 * @wmi: wmi handle
611 * @peer_addr: peer mac addr
612 * @vdev_id: vdev id
613 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530614 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530615 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530616static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530617 uint8_t peer_addr[IEEE80211_ADDR_LEN],
618 uint8_t vdev_id)
619{
620 wmi_peer_delete_cmd_fixed_param *cmd;
621 wmi_buf_t buf;
622 int32_t len = sizeof(*cmd);
623 buf = wmi_buf_alloc(wmi, len);
624 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530625 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530626 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530627 }
628 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
629 WMITLV_SET_HDR(&cmd->tlv_header,
630 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
631 WMITLV_GET_STRUCT_TLVLEN
632 (wmi_peer_delete_cmd_fixed_param));
633 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
634 cmd->vdev_id = vdev_id;
635
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800636 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530637 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530638 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530639 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530640 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530641 }
Govind Singh5eb51532016-03-09 11:34:12 +0530642
643 return 0;
644}
645
646/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530647 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
648 * to target id.
649 * @targ_paramid: Target parameter id to hold the result.
650 * @peer_param_id: host param id.
651 *
652 * Return: QDF_STATUS_SUCCESS for success
653 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
654 */
655#ifdef CONFIG_MCL
656static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
657 uint32_t *targ_paramid,
658 uint32_t peer_param_id)
659{
660 *targ_paramid = peer_param_id;
661 return QDF_STATUS_SUCCESS;
662}
663#else
664static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
665 uint32_t *targ_paramid,
666 uint32_t peer_param_id)
667{
668 switch (peer_param_id) {
669 case WMI_HOST_PEER_MIMO_PS_STATE:
670 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
671 break;
672 case WMI_HOST_PEER_AMPDU:
673 *targ_paramid = WMI_PEER_AMPDU;
674 break;
675 case WMI_HOST_PEER_AUTHORIZE:
676 *targ_paramid = WMI_PEER_AUTHORIZE;
677 break;
678 case WMI_HOST_PEER_CHWIDTH:
679 *targ_paramid = WMI_PEER_CHWIDTH;
680 break;
681 case WMI_HOST_PEER_NSS:
682 *targ_paramid = WMI_PEER_NSS;
683 break;
684 case WMI_HOST_PEER_USE_4ADDR:
685 *targ_paramid = WMI_PEER_USE_4ADDR;
686 break;
687 case WMI_HOST_PEER_MEMBERSHIP:
688 *targ_paramid = WMI_PEER_MEMBERSHIP;
689 break;
690 case WMI_HOST_PEER_USERPOS:
691 *targ_paramid = WMI_PEER_USERPOS;
692 break;
693 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
694 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
695 break;
696 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
697 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
698 break;
699 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
700 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
701 break;
702 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
703 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
704 break;
705 case WMI_HOST_PEER_PHYMODE:
706 *targ_paramid = WMI_PEER_PHYMODE;
707 break;
708 case WMI_HOST_PEER_USE_FIXED_PWR:
709 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
710 break;
711 case WMI_HOST_PEER_PARAM_FIXED_RATE:
712 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
713 break;
714 case WMI_HOST_PEER_SET_MU_WHITELIST:
715 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
716 break;
717 case WMI_HOST_PEER_SET_MAC_TX_RATE:
718 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
719 break;
720 case WMI_HOST_PEER_SET_MIN_TX_RATE:
721 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
722 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530723 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
724 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
725 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530726 case WMI_HOST_PEER_NSS_VHT160:
727 *targ_paramid = WMI_PEER_NSS_VHT160;
728 break;
729 case WMI_HOST_PEER_NSS_VHT80_80:
730 *targ_paramid = WMI_PEER_NSS_VHT80_80;
731 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530732 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
733 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
734 break;
735 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
736 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
737 break;
738 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
739 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
740 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530741 case WMI_HOST_PEER_PARAM_MU_ENABLE:
742 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
743 break;
744 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
745 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
746 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530747 default:
748 return QDF_STATUS_E_NOSUPPORT;
749 }
750
751 return QDF_STATUS_SUCCESS;
752}
753#endif
754/**
Govind Singh5eb51532016-03-09 11:34:12 +0530755 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530756 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530757 * @peer_addr: peer mac address
758 * @param : pointer to hold peer set parameter
759 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530760 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530761 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530762static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530763 uint8_t peer_addr[IEEE80211_ADDR_LEN],
764 struct peer_set_params *param)
765{
766 wmi_peer_set_param_cmd_fixed_param *cmd;
767 wmi_buf_t buf;
768 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530769 uint32_t param_id;
770
771 if (convert_host_peer_id_to_target_id_tlv(&param_id,
772 param->param_id) != QDF_STATUS_SUCCESS)
773 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530774
775 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
776 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530777 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530778 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530779 }
780 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
781 WMITLV_SET_HDR(&cmd->tlv_header,
782 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
783 WMITLV_GET_STRUCT_TLVLEN
784 (wmi_peer_set_param_cmd_fixed_param));
785 cmd->vdev_id = param->vdev_id;
786 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530787 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530788 cmd->param_value = param->param_value;
789 err = wmi_unified_cmd_send(wmi, buf,
790 sizeof(wmi_peer_set_param_cmd_fixed_param),
791 WMI_PEER_SET_PARAM_CMDID);
792 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530793 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530794 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530795 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530796 }
797
798 return 0;
799}
800
801/**
802 * send_vdev_up_cmd_tlv() - send vdev up command in fw
803 * @wmi: wmi handle
804 * @bssid: bssid
805 * @vdev_up_params: pointer to hold vdev up parameter
806 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530807 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530808 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530809static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530810 uint8_t bssid[IEEE80211_ADDR_LEN],
811 struct vdev_up_params *params)
812{
813 wmi_vdev_up_cmd_fixed_param *cmd;
814 wmi_buf_t buf;
815 int32_t len = sizeof(*cmd);
816
Govind Singhb53420c2016-03-09 14:32:57 +0530817 WMI_LOGD("%s: VDEV_UP", __func__);
818 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530819 params->vdev_id, params->assoc_id, bssid);
820 buf = wmi_buf_alloc(wmi, len);
821 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530822 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530823 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530824 }
825 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
826 WMITLV_SET_HDR(&cmd->tlv_header,
827 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
828 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
829 cmd->vdev_id = params->vdev_id;
830 cmd->vdev_assoc_id = params->assoc_id;
831 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
832 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530833 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530834 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530835 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530836 }
837
838 return 0;
839}
840
841/**
842 * send_peer_create_cmd_tlv() - send peer create command to fw
843 * @wmi: wmi handle
844 * @peer_addr: peer mac address
845 * @peer_type: peer type
846 * @vdev_id: vdev id
847 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530848 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530849 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530850static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530851 struct peer_create_params *param)
852{
853 wmi_peer_create_cmd_fixed_param *cmd;
854 wmi_buf_t buf;
855 int32_t len = sizeof(*cmd);
856
857 buf = wmi_buf_alloc(wmi, len);
858 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530859 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530860 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530861 }
862 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
863 WMITLV_SET_HDR(&cmd->tlv_header,
864 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
865 WMITLV_GET_STRUCT_TLVLEN
866 (wmi_peer_create_cmd_fixed_param));
867 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
868 cmd->peer_type = param->peer_type;
869 cmd->vdev_id = param->vdev_id;
870
871 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530872 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530873 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530874 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530875 }
Govind Singhb53420c2016-03-09 14:32:57 +0530876 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530877 param->vdev_id);
878
879 return 0;
880}
881
882/**
Leo Changeee40872016-09-28 13:43:36 -0700883 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
884 * command to fw
885 * @wmi: wmi handle
886 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
887 *
888 * Return: 0 for success or error code
889 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700890static
Leo Changeee40872016-09-28 13:43:36 -0700891QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
892 struct rx_reorder_queue_setup_params *param)
893{
894 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
895 wmi_buf_t buf;
896 int32_t len = sizeof(*cmd);
897
898 buf = wmi_buf_alloc(wmi, len);
899 if (!buf) {
900 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
901 return QDF_STATUS_E_NOMEM;
902 }
903 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
904 WMITLV_SET_HDR(&cmd->tlv_header,
905 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
906 WMITLV_GET_STRUCT_TLVLEN
907 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
908 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
909 cmd->vdev_id = param->vdev_id;
910 cmd->tid = param->tid;
911 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
912 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
913 cmd->queue_no = param->queue_no;
914
915 if (wmi_unified_cmd_send(wmi, buf, len,
916 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
917 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
918 __func__);
919 qdf_nbuf_free(buf);
920 return QDF_STATUS_E_FAILURE;
921 }
922 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
923 param->peer_macaddr, param->vdev_id, param->tid);
924
925 return QDF_STATUS_SUCCESS;
926}
927
928/**
929 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
930 * command to fw
931 * @wmi: wmi handle
932 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
933 *
934 * Return: 0 for success or error code
935 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700936static
Leo Changeee40872016-09-28 13:43:36 -0700937QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
938 struct rx_reorder_queue_remove_params *param)
939{
940 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
941 wmi_buf_t buf;
942 int32_t len = sizeof(*cmd);
943
944 buf = wmi_buf_alloc(wmi, len);
945 if (!buf) {
946 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
947 return QDF_STATUS_E_NOMEM;
948 }
949 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
950 wmi_buf_data(buf);
951 WMITLV_SET_HDR(&cmd->tlv_header,
952 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
953 WMITLV_GET_STRUCT_TLVLEN
954 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
955 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
956 cmd->vdev_id = param->vdev_id;
957 cmd->tid_mask = param->peer_tid_bitmap;
958
959 if (wmi_unified_cmd_send(wmi, buf, len,
960 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
961 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
962 __func__);
963 qdf_nbuf_free(buf);
964 return QDF_STATUS_E_FAILURE;
965 }
966 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
967 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
968
969 return QDF_STATUS_SUCCESS;
970}
971
972/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530973 * send_peer_add_wds_entry_cmd_tlv() - send peer add 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_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
980 struct peer_add_wds_entry_params *param)
981{
982 wmi_peer_add_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_FAILURE;
990 }
991 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
992 WMITLV_SET_HDR(&cmd->tlv_header,
993 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
994 WMITLV_GET_STRUCT_TLVLEN
995 (wmi_peer_add_wds_entry_cmd_fixed_param));
996 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
997 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
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
1001 return wmi_unified_cmd_send(wmi_handle, buf, len,
1002 WMI_PEER_ADD_WDS_ENTRY_CMDID);
1003}
1004
1005/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +05301006 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301007 * @wmi_handle: wmi handle
1008 * @param: pointer holding peer details
1009 *
1010 * Return: 0 for success or error code
1011 */
1012static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1013 struct peer_del_wds_entry_params *param)
1014{
1015 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
1016 wmi_buf_t buf;
1017 int len = sizeof(*cmd);
1018
1019 buf = wmi_buf_alloc(wmi_handle, len);
1020 if (!buf) {
1021 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
1022 return QDF_STATUS_E_NOMEM;
1023 }
1024 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1025 WMITLV_SET_HDR(&cmd->tlv_header,
1026 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
1027 WMITLV_GET_STRUCT_TLVLEN
1028 (wmi_peer_remove_wds_entry_cmd_fixed_param));
1029 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001030 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301031 return wmi_unified_cmd_send(wmi_handle, buf, len,
1032 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
1033}
1034
1035/**
1036 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
1037 * @wmi_handle: wmi handle
1038 * @param: pointer holding peer details
1039 *
1040 * Return: 0 for success or error code
1041 */
1042static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1043 struct peer_update_wds_entry_params *param)
1044{
1045 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
1046 wmi_buf_t buf;
1047 int len = sizeof(*cmd);
1048
1049 buf = wmi_buf_alloc(wmi_handle, len);
1050 if (!buf) {
1051 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
1052 return QDF_STATUS_E_NOMEM;
1053 }
1054
1055 /* wmi_buf_alloc returns zeroed command buffer */
1056 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1057 WMITLV_SET_HDR(&cmd->tlv_header,
1058 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
1059 WMITLV_GET_STRUCT_TLVLEN
1060 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001061 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1062 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301063 if (param->wds_macaddr)
1064 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
1065 &cmd->wds_macaddr);
1066 if (param->peer_macaddr)
1067 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1068 &cmd->peer_macaddr);
1069 return wmi_unified_cmd_send(wmi_handle, buf, len,
1070 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1071}
1072
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001073/**
1074 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1075 * @wmi_handle: wmi handle
1076 * @param: pointer to get tpc config params
1077 *
1078 * Return: 0 for success or error code
1079 */
1080static QDF_STATUS
1081send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1082 uint32_t param)
1083{
1084 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1085 wmi_buf_t buf;
1086 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1087
1088 buf = wmi_buf_alloc(wmi_handle, len);
1089 if (!buf) {
1090 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1091 return QDF_STATUS_E_NOMEM;
1092 }
1093 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1094 WMITLV_SET_HDR(&cmd->tlv_header,
1095 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1096 WMITLV_GET_STRUCT_TLVLEN
1097 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1098
1099 cmd->param = param;
1100 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1101 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1102 WMI_LOGE("Send pdev get tpc config cmd failed");
1103 wmi_buf_free(buf);
1104 return QDF_STATUS_E_FAILURE;
1105
1106 }
1107 WMI_LOGD("%s:send success", __func__);
1108
1109 return QDF_STATUS_SUCCESS;
1110}
1111
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301112#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301113/**
Govind Singh5eb51532016-03-09 11:34:12 +05301114 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1115 * @wmi_handle: wmi handle
1116 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301117 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301118 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301119 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301120 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301121static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301122 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301123{
1124 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1125 wmi_buf_t buf;
1126 int32_t len = sizeof(*cmd);
1127
Govind Singhb53420c2016-03-09 14:32:57 +05301128 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301129
1130 buf = wmi_buf_alloc(wmi_handle, len);
1131 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301132 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301133 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301134 }
1135
1136 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1137 WMITLV_SET_HDR(&cmd->tlv_header,
1138 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1139 WMITLV_GET_STRUCT_TLVLEN
1140 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301141 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301142 cmd->enable = value;
1143
1144 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1145 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301146 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301147 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301148 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301149 }
1150
1151 return 0;
1152}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301153#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301154
1155/**
1156 * send_pdev_utf_cmd_tlv() - send utf command to fw
1157 * @wmi_handle: wmi handle
1158 * @param: pointer to pdev_utf_params
1159 * @mac_id: mac id to have radio context
1160 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301161 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301162 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301163static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301164send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1165 struct pdev_utf_params *param,
1166 uint8_t mac_id)
1167{
1168 wmi_buf_t buf;
1169 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001170 /* if param->len is 0 no data is sent, return error */
1171 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301172 static uint8_t msgref = 1;
1173 uint8_t segNumber = 0, segInfo, numSegments;
1174 uint16_t chunk_len, total_bytes;
1175 uint8_t *bufpos;
1176 struct seg_hdr_info segHdrInfo;
1177
1178 bufpos = param->utf_payload;
1179 total_bytes = param->len;
1180 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1181 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1182 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1183
1184 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1185 numSegments++;
1186
1187 while (param->len) {
1188 if (param->len > MAX_WMI_UTF_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -07001189 chunk_len = MAX_WMI_UTF_LEN; /* MAX message */
Govind Singh5eb51532016-03-09 11:34:12 +05301190 else
1191 chunk_len = param->len;
1192
1193 buf = wmi_buf_alloc(wmi_handle,
1194 (chunk_len + sizeof(segHdrInfo) +
1195 WMI_TLV_HDR_SIZE));
1196 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301197 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301198 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301199 }
1200
1201 cmd = (uint8_t *) wmi_buf_data(buf);
1202
1203 segHdrInfo.len = total_bytes;
1204 segHdrInfo.msgref = msgref;
1205 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1206 segHdrInfo.segmentInfo = segInfo;
1207 segHdrInfo.pad = 0;
1208
Govind Singhb53420c2016-03-09 14:32:57 +05301209 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301210 " segHdrInfo.segmentInfo = %d",
1211 __func__, segHdrInfo.len, segHdrInfo.msgref,
1212 segHdrInfo.segmentInfo);
1213
Govind Singhb53420c2016-03-09 14:32:57 +05301214 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301215 "chunk len %d", __func__, total_bytes, segNumber,
1216 numSegments, chunk_len);
1217
1218 segNumber++;
1219
1220 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1221 (chunk_len + sizeof(segHdrInfo)));
1222 cmd += WMI_TLV_HDR_SIZE;
1223 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1224 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1225
1226 ret = wmi_unified_cmd_send(wmi_handle, buf,
1227 (chunk_len + sizeof(segHdrInfo) +
1228 WMI_TLV_HDR_SIZE),
1229 WMI_PDEV_UTF_CMDID);
1230
Govind Singh67922e82016-04-01 16:48:57 +05301231 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301232 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301233 wmi_buf_free(buf);
1234 break;
1235 }
1236
1237 param->len -= chunk_len;
1238 bufpos += chunk_len;
1239 }
1240
1241 msgref++;
1242
1243 return ret;
1244}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301245#ifdef CONFIG_MCL
1246static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1247 uint32_t host_param)
1248{
1249 return host_param;
1250}
1251#else
1252static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1253 uint32_t host_param)
1254{
1255 if (host_param < wmi_pdev_param_max)
1256 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301257
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301258 return WMI_UNAVAILABLE_PARAM;
1259}
1260#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301261/**
1262 * send_pdev_param_cmd_tlv() - set pdev parameters
1263 * @wmi_handle: wmi handle
1264 * @param: pointer to pdev parameter
1265 * @mac_id: radio context
1266 *
1267 * Return: 0 on success, errno on failure
1268 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301269static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301270send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1271 struct pdev_params *param,
1272 uint8_t mac_id)
1273{
Govind Singh67922e82016-04-01 16:48:57 +05301274 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301275 wmi_pdev_set_param_cmd_fixed_param *cmd;
1276 wmi_buf_t buf;
1277 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301278 uint32_t pdev_param;
1279
1280 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1281 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1282 WMI_LOGW("%s: Unavailable param %d\n",
1283 __func__, param->param_id);
1284 return QDF_STATUS_E_INVAL;
1285 }
Govind Singh5eb51532016-03-09 11:34:12 +05301286
1287 buf = wmi_buf_alloc(wmi_handle, len);
1288 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301289 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301290 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301291 }
1292 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1293 WMITLV_SET_HDR(&cmd->tlv_header,
1294 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1295 WMITLV_GET_STRUCT_TLVLEN
1296 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301297 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301298 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301299 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301300 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301301 param->param_value);
1302 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1303 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301304 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301305 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301306 wmi_buf_free(buf);
1307 }
1308 return ret;
1309}
1310
1311/**
1312 * send_suspend_cmd_tlv() - WMI suspend function
1313 * @param wmi_handle : handle to WMI.
1314 * @param param : pointer to hold suspend parameter
1315 * @mac_id: radio context
1316 *
1317 * Return 0 on success and -ve on failure.
1318 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301319static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301320 struct suspend_params *param,
1321 uint8_t mac_id)
1322{
1323 wmi_pdev_suspend_cmd_fixed_param *cmd;
1324 wmi_buf_t wmibuf;
1325 uint32_t len = sizeof(*cmd);
1326 int32_t ret;
1327
1328 /*
Jeff Johnson19a59fe2018-05-06 16:10:43 -07001329 * send the command to Target to ignore the
Govind Singh5eb51532016-03-09 11:34:12 +05301330 * PCIE reset so as to ensure that Host and target
1331 * states are in sync
1332 */
1333 wmibuf = wmi_buf_alloc(wmi_handle, len);
1334 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301335 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301336
1337 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1338 WMITLV_SET_HDR(&cmd->tlv_header,
1339 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1340 WMITLV_GET_STRUCT_TLVLEN
1341 (wmi_pdev_suspend_cmd_fixed_param));
1342 if (param->disable_target_intr)
1343 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1344 else
1345 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301346
1347 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1348
Govind Singh5eb51532016-03-09 11:34:12 +05301349 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1350 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301351 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301352 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301353 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301354 }
1355
1356 return ret;
1357}
1358
1359/**
1360 * send_resume_cmd_tlv() - WMI resume function
1361 * @param wmi_handle : handle to WMI.
1362 * @mac_id: radio context
1363 *
1364 * Return: 0 on success and -ve on failure.
1365 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301366static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301367 uint8_t mac_id)
1368{
1369 wmi_buf_t wmibuf;
1370 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301371 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301372
1373 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1374 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301375 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301376 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1377 WMITLV_SET_HDR(&cmd->tlv_header,
1378 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1379 WMITLV_GET_STRUCT_TLVLEN
1380 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301381 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301382 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1383 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301384 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301385 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301386 wmi_buf_free(wmibuf);
1387 }
1388
1389 return ret;
1390}
1391
Will Huang422ac9a2017-11-17 13:19:16 +08001392#ifdef FEATURE_WLAN_D0WOW
1393/**
1394 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1395 * @param wmi_handle: handle to WMI.
1396 * @mac_id: radio context
1397 *
1398 * Return: 0 on success and error code on failure.
1399 */
1400static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1401 uint8_t mac_id)
1402{
1403 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1404 wmi_buf_t buf;
1405 int32_t len;
1406 QDF_STATUS status;
1407
1408 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1409
1410 buf = wmi_buf_alloc(wmi_handle, len);
1411 if (!buf) {
1412 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1413 return QDF_STATUS_E_NOMEM;
1414 }
1415 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1416 WMITLV_SET_HDR(&cmd->tlv_header,
1417 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1418 WMITLV_GET_STRUCT_TLVLEN
1419 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1420
1421 cmd->enable = true;
1422
1423 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1424 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1425 if (QDF_IS_STATUS_ERROR(status))
1426 wmi_buf_free(buf);
1427
1428 return status;
1429}
1430
1431/**
1432 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1433 * @param wmi_handle: handle to WMI.
1434 * @mac_id: radio context
1435 *
1436 * Return: 0 on success and error code on failure.
1437 */
1438static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1439 uint8_t mac_id)
1440{
1441 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1442 wmi_buf_t buf;
1443 int32_t len;
1444 QDF_STATUS status;
1445
1446 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1447
1448 buf = wmi_buf_alloc(wmi_handle, len);
1449 if (!buf) {
1450 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1451 return QDF_STATUS_E_NOMEM;
1452 }
1453 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1454 WMITLV_SET_HDR(&cmd->tlv_header,
1455 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1456 WMITLV_GET_STRUCT_TLVLEN
1457 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1458
1459 cmd->enable = false;
1460
1461 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1462 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1463 if (QDF_IS_STATUS_ERROR(status))
1464 wmi_buf_free(buf);
1465
1466 return status;
1467}
1468#endif
1469
Govind Singh5eb51532016-03-09 11:34:12 +05301470/**
1471 * send_wow_enable_cmd_tlv() - WMI wow enable function
1472 * @param wmi_handle : handle to WMI.
1473 * @param param : pointer to hold wow enable parameter
1474 * @mac_id: radio context
1475 *
1476 * Return: 0 on success and -ve on failure.
1477 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301478static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301479 struct wow_cmd_params *param,
1480 uint8_t mac_id)
1481{
1482 wmi_wow_enable_cmd_fixed_param *cmd;
1483 wmi_buf_t buf;
1484 int32_t len;
1485 int32_t ret;
1486
1487 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1488
1489 buf = wmi_buf_alloc(wmi_handle, len);
1490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301491 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1492 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301493 }
1494 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1495 WMITLV_SET_HDR(&cmd->tlv_header,
1496 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1497 WMITLV_GET_STRUCT_TLVLEN
1498 (wmi_wow_enable_cmd_fixed_param));
1499 cmd->enable = param->enable;
1500 if (param->can_suspend_link)
1501 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1502 else
1503 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001504 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301505
Govind Singhb53420c2016-03-09 14:32:57 +05301506 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301507 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1508 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1509
1510 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1511 WMI_WOW_ENABLE_CMDID);
1512 if (ret)
1513 wmi_buf_free(buf);
1514
1515 return ret;
1516}
1517
1518/**
1519 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301520 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301521 * @peer_addr: peer mac address
1522 * @param: pointer to ap_ps parameter structure
1523 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301524 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301525 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301526static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301527 uint8_t *peer_addr,
1528 struct ap_ps_params *param)
1529{
1530 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1531 wmi_buf_t buf;
1532 int32_t err;
1533
1534 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1535 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301536 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301537 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301538 }
1539 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1540 WMITLV_SET_HDR(&cmd->tlv_header,
1541 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1542 WMITLV_GET_STRUCT_TLVLEN
1543 (wmi_ap_ps_peer_cmd_fixed_param));
1544 cmd->vdev_id = param->vdev_id;
1545 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1546 cmd->param = param->param;
1547 cmd->value = param->value;
1548 err = wmi_unified_cmd_send(wmi_handle, buf,
1549 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1550 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301551 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301552 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301553 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301554 }
1555
1556 return 0;
1557}
1558
1559/**
1560 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301561 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301562 * @peer_addr: peer mac address
1563 * @param: pointer to sta_ps parameter structure
1564 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301565 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301566 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301567static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301568 struct sta_ps_params *param)
1569{
1570 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1571 wmi_buf_t buf;
1572 int32_t len = sizeof(*cmd);
1573
1574 buf = wmi_buf_alloc(wmi_handle, len);
1575 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301576 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301577 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301578 }
1579
1580 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1581 WMITLV_SET_HDR(&cmd->tlv_header,
1582 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1583 WMITLV_GET_STRUCT_TLVLEN
1584 (wmi_sta_powersave_param_cmd_fixed_param));
1585 cmd->vdev_id = param->vdev_id;
1586 cmd->param = param->param;
1587 cmd->value = param->value;
1588
1589 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1590 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301591 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301592 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301593 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301594 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301595 }
1596
1597 return 0;
1598}
1599
1600/**
1601 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301602 * @wmi_handle: wmi handle
Jeff Johnsonbbd428c2018-05-06 17:02:16 -07001603 * @param: ponirt to crash inject parameter structure
Govind Singh5eb51532016-03-09 11:34:12 +05301604 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301605 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301606 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301607static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301608 struct crash_inject *param)
1609{
1610 int32_t ret = 0;
1611 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1612 uint16_t len = sizeof(*cmd);
1613 wmi_buf_t buf;
1614
1615 buf = wmi_buf_alloc(wmi_handle, len);
1616 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301617 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301618 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301619 }
1620
1621 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1622 WMITLV_SET_HDR(&cmd->tlv_header,
1623 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1624 WMITLV_GET_STRUCT_TLVLEN
1625 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1626 cmd->type = param->type;
1627 cmd->delay_time_ms = param->delay_time_ms;
1628
1629 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1630 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301631 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301632 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301633 __func__, ret);
1634 wmi_buf_free(buf);
1635 }
1636
1637 return ret;
1638}
1639
Wen Gongca174012018-04-20 16:56:28 +08001640#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +05301641/**
1642 * send_dbglog_cmd_tlv() - set debug log level
1643 * @param wmi_handle : handle to WMI.
1644 * @param param : pointer to hold dbglog level parameter
1645 *
1646 * Return: 0 on success and -ve on failure.
1647 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301648 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301649send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1650 struct dbglog_params *dbglog_param)
1651{
1652 wmi_buf_t buf;
1653 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001654 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301655 int32_t i;
1656 int32_t len;
1657 int8_t *buf_ptr;
1658 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1659
Alok Kumar240afea2017-08-30 14:45:34 +05301660 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301661
1662 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1663 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1664 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1665 buf = wmi_buf_alloc(wmi_handle, len);
1666 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001667 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301668
1669 configmsg =
1670 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1671 buf_ptr = (int8_t *) configmsg;
1672 WMITLV_SET_HDR(&configmsg->tlv_header,
1673 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1674 WMITLV_GET_STRUCT_TLVLEN
1675 (wmi_debug_log_config_cmd_fixed_param));
1676 configmsg->dbg_log_param = dbglog_param->param;
1677 configmsg->value = dbglog_param->val;
1678 /* Filling in the data part of second tlv -- should
1679 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301680 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301681 sizeof
1682 (wmi_debug_log_config_cmd_fixed_param)
1683 + WMI_TLV_HDR_SIZE);
1684 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1685 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301686 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301687 if (dbglog_param->module_id_bitmap) {
1688 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1689 module_id_bitmap_array[i] =
1690 dbglog_param->module_id_bitmap[i];
1691 }
1692 }
1693
1694 status = wmi_unified_cmd_send(wmi_handle, buf,
1695 len, WMI_DBGLOG_CFG_CMDID);
1696
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001697 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301698 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301699
1700 return status;
1701}
Wen Gongca174012018-04-20 16:56:28 +08001702#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301703
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301704#ifdef CONFIG_MCL
1705static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1706 uint32_t host_param)
1707{
1708 return host_param;
1709}
1710#else
1711static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1712 uint32_t host_param)
1713{
1714 if (host_param < wmi_vdev_param_max)
1715 return wmi_handle->vdev_param[host_param];
1716
1717 return WMI_UNAVAILABLE_PARAM;
1718}
1719#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301720/**
1721 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1722 * @param wmi_handle : handle to WMI.
1723 * @param macaddr : MAC address
1724 * @param param : pointer to hold vdev set parameter
1725 *
1726 * Return: 0 on success and -ve on failure.
1727 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301728static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301729 struct vdev_set_params *param)
1730{
Govind Singh67922e82016-04-01 16:48:57 +05301731 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301732 wmi_vdev_set_param_cmd_fixed_param *cmd;
1733 wmi_buf_t buf;
1734 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301735 uint32_t vdev_param;
1736
1737 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1738 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1739 WMI_LOGW("%s:Vdev param %d not available", __func__,
1740 param->param_id);
1741 return QDF_STATUS_E_INVAL;
1742
1743 }
Govind Singh5eb51532016-03-09 11:34:12 +05301744
1745 buf = wmi_buf_alloc(wmi_handle, len);
1746 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301747 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301748 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301749 }
1750 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1751 WMITLV_SET_HDR(&cmd->tlv_header,
1752 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1753 WMITLV_GET_STRUCT_TLVLEN
1754 (wmi_vdev_set_param_cmd_fixed_param));
1755 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301756 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301757 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301758 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001759 cmd->vdev_id, cmd->param_id, cmd->param_value);
Govind Singh5eb51532016-03-09 11:34:12 +05301760 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1761 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301762 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301763 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301764 wmi_buf_free(buf);
1765 }
1766
1767 return ret;
1768}
1769
1770/**
1771 * send_stats_request_cmd_tlv() - WMI request stats function
1772 * @param wmi_handle : handle to WMI.
1773 * @param macaddr : MAC address
1774 * @param param : pointer to hold stats request parameter
1775 *
1776 * Return: 0 on success and -ve on failure.
1777 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301778static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301779 uint8_t macaddr[IEEE80211_ADDR_LEN],
1780 struct stats_request_params *param)
1781{
Govind Singhd3156eb2016-02-26 17:50:39 +05301782 int32_t ret;
1783 wmi_request_stats_cmd_fixed_param *cmd;
1784 wmi_buf_t buf;
1785 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1786
1787 buf = wmi_buf_alloc(wmi_handle, len);
1788 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301789 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1790 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301791 }
1792
1793 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1794 WMITLV_SET_HDR(&cmd->tlv_header,
1795 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1796 WMITLV_GET_STRUCT_TLVLEN
1797 (wmi_request_stats_cmd_fixed_param));
1798 cmd->stats_id = param->stats_id;
1799 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301800 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1801 param->pdev_id);
1802 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001803
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301804 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1805 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001806
1807 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1808 WMI_REQUEST_STATS_CMDID);
1809
Govind Singhd3156eb2016-02-26 17:50:39 +05301810 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301811 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301812 wmi_buf_free(buf);
1813 }
1814
1815 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301816}
1817
Govind Singh87542482016-06-08 19:40:11 +05301818#ifdef CONFIG_WIN
1819/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001820 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301821 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001822 * @param PKTLOG_EVENT : packet log event
1823 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301824 *
1825 * Return: 0 on success and -ve on failure.
1826 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301827static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001828 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301829{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001830 int32_t ret;
1831 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1832 wmi_buf_t buf;
1833 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1834
1835 buf = wmi_buf_alloc(wmi_handle, len);
1836 if (!buf) {
1837 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1838 return -QDF_STATUS_E_NOMEM;
1839 }
1840
1841 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1842 WMITLV_SET_HDR(&cmd->tlv_header,
1843 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1844 WMITLV_GET_STRUCT_TLVLEN
1845 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1846 cmd->evlist = PKTLOG_EVENT;
1847 cmd->pdev_id = mac_id;
1848 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1849 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1850 if (ret) {
1851 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1852 wmi_buf_free(buf);
1853 }
1854
1855 return ret;
1856}
1857
1858/**
1859 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1860 * @param wmi_handle : handle to WMI.
1861 * @mac_id: mac id to have radio context
1862 *
1863 * Return: 0 on success and -ve on failure.
1864 */
1865static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001866 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001867{
1868 int32_t ret;
1869 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1870 wmi_buf_t buf;
1871 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1872
1873 buf = wmi_buf_alloc(wmi_handle, len);
1874 if (!buf) {
1875 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1876 return -QDF_STATUS_E_NOMEM;
1877 }
1878
1879 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1880 WMITLV_SET_HDR(&cmd->tlv_header,
1881 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1882 WMITLV_GET_STRUCT_TLVLEN
1883 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1884 cmd->pdev_id = mac_id;
1885 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1886 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1887 if (ret) {
1888 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1889 wmi_buf_free(buf);
1890 }
1891
1892 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301893}
1894#else
Govind Singh5eb51532016-03-09 11:34:12 +05301895/**
Keyur Parekhde522342017-08-18 14:01:05 -07001896 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1897 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301898 * @param wmi_handle : handle to WMI.
1899 * @param macaddr : MAC address
1900 * @param param : pointer to hold stats request parameter
1901 *
1902 * Return: 0 on success and -ve on failure.
1903 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301904static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301905 uint8_t macaddr[IEEE80211_ADDR_LEN],
1906 struct packet_enable_params *param)
1907{
1908 return 0;
1909}
Keyur Parekhde522342017-08-18 14:01:05 -07001910/**
1911 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1912 * packet-log
1913 * @param wmi_handle : handle to WMI.
1914 * @mac_id: mac id to have radio context
1915 *
1916 * Return: 0 on success and -ve on failure.
1917 */
1918static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1919 uint8_t mac_id)
1920{
1921 return 0;
1922}
Govind Singh87542482016-06-08 19:40:11 +05301923#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301924
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301925#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1926/**
1927 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1928 * sync time between bwtween host and firmware
1929 * @param wmi_handle : handle to WMI.
1930 *
1931 * Return: None
1932 */
1933static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1934{
1935 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07001936 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301937 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1938 int32_t len;
1939 qdf_time_t time_ms;
1940
1941 len = sizeof(*time_stamp);
1942 buf = wmi_buf_alloc(wmi_handle, len);
1943
1944 if (!buf) {
1945 WMI_LOGP(FL("wmi_buf_alloc failed"));
1946 return;
1947 }
1948 time_stamp =
1949 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1950 (wmi_buf_data(buf));
1951 WMITLV_SET_HDR(&time_stamp->tlv_header,
1952 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1953 WMITLV_GET_STRUCT_TLVLEN(
1954 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1955
1956 time_ms = qdf_get_time_of_the_day_ms();
1957 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1958 time_stamp->time_stamp_low = time_ms &
1959 WMI_FW_TIME_STAMP_LOW_MASK;
1960 /*
1961 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1962 * wont exceed 27 bit
1963 */
1964 time_stamp->time_stamp_high = 0;
1965 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1966 time_stamp->mode, time_stamp->time_stamp_low,
1967 time_stamp->time_stamp_high);
1968
1969 status = wmi_unified_cmd_send(wmi_handle, buf,
1970 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
1971 if (status) {
1972 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
1973 wmi_buf_free(buf);
1974 }
1975
1976}
1977
Subrat Mishrad7c7a562017-09-27 14:41:20 +05301978#ifdef WLAN_SUPPORT_FILS
1979/**
1980 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
1981 * @wmi_handle: wmi handle
1982 * @evt_buf: pointer to event buffer
1983 * @vdev_id: pointer to hold vdev id
1984 *
1985 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
1986 */
1987static QDF_STATUS
1988extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
1989 void *evt_buf, uint32_t *vdev_id)
1990{
1991 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
1992 wmi_host_swfda_event_fixed_param *swfda_event;
1993
1994 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
1995 if (!param_buf) {
1996 WMI_LOGE("Invalid swfda event buffer");
1997 return QDF_STATUS_E_INVAL;
1998 }
1999 swfda_event = param_buf->fixed_param;
2000 *vdev_id = swfda_event->vdev_id;
2001
2002 return QDF_STATUS_SUCCESS;
2003}
2004
2005/**
2006 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
2007 * @wmi_handle: wmi handle
2008 * @param: pointer to hold FILS discovery enable param
2009 *
2010 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
2011 */
2012static QDF_STATUS
2013send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
2014 struct config_fils_params *param)
2015{
2016 wmi_enable_fils_cmd_fixed_param *cmd;
2017 wmi_buf_t buf;
2018 QDF_STATUS status;
2019 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
2020
2021 buf = wmi_buf_alloc(wmi_handle, len);
2022 if (!buf) {
2023 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2024 return QDF_STATUS_E_NOMEM;
2025 }
2026 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
2027 WMITLV_SET_HDR(&cmd->tlv_header,
2028 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
2029 WMITLV_GET_STRUCT_TLVLEN(
2030 wmi_enable_fils_cmd_fixed_param));
2031 cmd->vdev_id = param->vdev_id;
2032 cmd->fd_period = param->fd_period;
2033 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
2034 param->fd_period, param->vdev_id);
2035
2036 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2037 WMI_ENABLE_FILS_CMDID);
2038 if (status != QDF_STATUS_SUCCESS) {
2039 wmi_buf_free(buf);
2040 return QDF_STATUS_E_FAILURE;
2041 }
2042
2043 return QDF_STATUS_SUCCESS;
2044}
2045
2046/**
2047 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
2048 * @wmi_handle: wmi handle
2049 * @param: pointer to hold FD send cmd parameter
2050 *
2051 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
2052 */
2053static QDF_STATUS
2054send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
2055 struct fd_params *param)
2056{
2057 QDF_STATUS ret;
2058 wmi_fd_send_from_host_cmd_fixed_param *cmd;
2059 wmi_buf_t wmi_buf;
2060 qdf_dma_addr_t dma_addr;
2061
2062 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2063 if (!wmi_buf) {
2064 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2065 return QDF_STATUS_E_NOMEM;
2066 }
2067 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2068 WMITLV_SET_HDR(&cmd->tlv_header,
2069 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2070 WMITLV_GET_STRUCT_TLVLEN(
2071 wmi_fd_send_from_host_cmd_fixed_param));
2072 cmd->vdev_id = param->vdev_id;
2073 cmd->data_len = qdf_nbuf_len(param->wbuf);
2074 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2075 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2076 cmd->frame_ctrl = param->frame_ctrl;
2077
2078 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2079 WMI_PDEV_SEND_FD_CMDID);
2080 if (ret != QDF_STATUS_SUCCESS) {
2081 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2082 __func__, ret);
2083 wmi_buf_free(wmi_buf);
2084 }
2085
2086 return ret;
2087}
2088#endif /* WLAN_SUPPORT_FILS */
2089
Sathish Kumarfd347372017-02-13 12:29:09 +05302090static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302091 struct beacon_params *param)
2092{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302093 QDF_STATUS ret;
2094 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2095 wmi_buf_t wmi_buf;
2096 qdf_dma_addr_t dma_addr;
2097 uint32_t dtim_flag = 0;
2098
2099 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2100 if (!wmi_buf) {
2101 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2102 return QDF_STATUS_E_NOMEM;
2103 }
2104 if (param->is_dtim_count_zero) {
2105 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2106 if (param->is_bitctl_reqd) {
2107 /* deliver CAB traffic in next DTIM beacon */
2108 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2109 }
2110 }
2111 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2112 WMITLV_SET_HDR(&cmd->tlv_header,
2113 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2114 WMITLV_GET_STRUCT_TLVLEN
2115 (wmi_bcn_send_from_host_cmd_fixed_param));
2116 cmd->vdev_id = param->vdev_id;
2117 cmd->data_len = qdf_nbuf_len(param->wbuf);
2118 cmd->frame_ctrl = param->frame_ctrl;
2119 cmd->dtim_flag = dtim_flag;
2120 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2121 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2122#if defined(HTT_PADDR64)
2123 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2124#endif
2125 cmd->bcn_antenna = param->bcn_txant;
2126
2127 ret = wmi_unified_cmd_send(wmi_handle,
2128 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2129 if (ret != QDF_STATUS_SUCCESS) {
2130 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2131 wmi_buf_free(wmi_buf);
2132 }
2133
2134 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302135}
2136
2137/**
2138 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2139 * @param wmi_handle : handle to WMI.
2140 * @param param : pointer to hold beacon send cmd parameter
2141 *
2142 * Return: 0 on success and -ve on failure.
2143 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302144static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302145 struct beacon_tmpl_params *param)
2146{
2147 int32_t ret;
2148 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2149 wmi_bcn_prb_info *bcn_prb_info;
2150 wmi_buf_t wmi_buf;
2151 uint8_t *buf_ptr;
2152 uint32_t wmi_buf_len;
2153
2154 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2155 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2156 param->tmpl_len_aligned;
2157 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2158 if (!wmi_buf) {
2159 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2160 return QDF_STATUS_E_NOMEM;
2161 }
2162 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2163 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2164 WMITLV_SET_HDR(&cmd->tlv_header,
2165 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2166 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2167 cmd->vdev_id = param->vdev_id;
2168 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302169 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2170 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05302171 cmd->buf_len = param->tmpl_len;
2172 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2173
2174 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2175 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2176 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2177 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2178 bcn_prb_info->caps = 0;
2179 bcn_prb_info->erp = 0;
2180 buf_ptr += sizeof(wmi_bcn_prb_info);
2181
2182 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2183 buf_ptr += WMI_TLV_HDR_SIZE;
2184 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2185
2186 ret = wmi_unified_cmd_send(wmi_handle,
2187 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2188 if (ret) {
2189 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2190 wmi_buf_free(wmi_buf);
2191 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302192
Govind Singh87542482016-06-08 19:40:11 +05302193 return 0;
2194}
Govind Singh5eb51532016-03-09 11:34:12 +05302195
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302196#ifdef CONFIG_MCL
2197static inline void copy_peer_flags_tlv(
2198 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2199 struct peer_assoc_params *param)
2200{
2201 cmd->peer_flags = param->peer_flags;
2202}
2203#else
2204static inline void copy_peer_flags_tlv(
2205 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2206 struct peer_assoc_params *param)
2207{
2208 /*
2209 * The target only needs a subset of the flags maintained in the host.
2210 * Just populate those flags and send it down
2211 */
2212 cmd->peer_flags = 0;
2213
2214 /*
2215 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2216 */
2217 if (param->is_wme_set) {
2218
2219 if (param->qos_flag)
2220 cmd->peer_flags |= WMI_PEER_QOS;
2221 if (param->apsd_flag)
2222 cmd->peer_flags |= WMI_PEER_APSD;
2223 if (param->ht_flag)
2224 cmd->peer_flags |= WMI_PEER_HT;
2225 if (param->bw_40)
2226 cmd->peer_flags |= WMI_PEER_40MHZ;
2227 if (param->bw_80)
2228 cmd->peer_flags |= WMI_PEER_80MHZ;
2229 if (param->bw_160)
2230 cmd->peer_flags |= WMI_PEER_160MHZ;
2231
2232 /* Typically if STBC is enabled for VHT it should be enabled
2233 * for HT as well
2234 **/
2235 if (param->stbc_flag)
2236 cmd->peer_flags |= WMI_PEER_STBC;
2237
2238 /* Typically if LDPC is enabled for VHT it should be enabled
2239 * for HT as well
2240 **/
2241 if (param->ldpc_flag)
2242 cmd->peer_flags |= WMI_PEER_LDPC;
2243
2244 if (param->static_mimops_flag)
2245 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2246 if (param->dynamic_mimops_flag)
2247 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2248 if (param->spatial_mux_flag)
2249 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2250 if (param->vht_flag)
2251 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002252 if (param->he_flag)
2253 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302254 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002255
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302256 if (param->is_pmf_enabled)
2257 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302258 /*
2259 * Suppress authorization for all AUTH modes that need 4-way handshake
2260 * (during re-association).
2261 * Authorization will be done for these modes on key installation.
2262 */
2263 if (param->auth_flag)
2264 cmd->peer_flags |= WMI_PEER_AUTH;
2265 if (param->need_ptk_4_way)
2266 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2267 else
2268 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2269 if (param->need_gtk_2_way)
2270 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2271 /* safe mode bypass the 4-way handshake */
2272 if (param->safe_mode_enabled)
2273 cmd->peer_flags &=
2274 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2275 /* Disable AMSDU for station transmit, if user configures it */
2276 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2277 * it
2278 * if (param->amsdu_disable) Add after FW support
2279 **/
2280
2281 /* Target asserts if node is marked HT and all MCS is set to 0.
2282 * Mark the node as non-HT if all the mcs rates are disabled through
2283 * iwpriv
2284 **/
2285 if (param->peer_ht_rates.num_rates == 0)
2286 cmd->peer_flags &= ~WMI_PEER_HT;
2287}
2288#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302289
2290#ifdef CONFIG_MCL
2291static inline void copy_peer_mac_addr_tlv(
2292 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2293 struct peer_assoc_params *param)
2294{
2295 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2296 sizeof(param->peer_macaddr));
2297}
2298#else
2299static inline void copy_peer_mac_addr_tlv(
2300 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2301 struct peer_assoc_params *param)
2302{
2303 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2304}
2305#endif
2306
Govind Singh5eb51532016-03-09 11:34:12 +05302307/**
2308 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2309 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302310 * @param param : pointer to peer assoc parameter
2311 *
2312 * Return: 0 on success and -ve on failure.
2313 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302314static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302315 struct peer_assoc_params *param)
2316{
Govind Singhd3156eb2016-02-26 17:50:39 +05302317 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2318 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002319 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302320 wmi_buf_t buf;
2321 int32_t len;
2322 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302323 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302324 uint32_t peer_legacy_rates_align;
2325 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002326 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302327
2328
2329 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2330 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302331
2332 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002333 (peer_legacy_rates_align * sizeof(uint8_t)) +
2334 WMI_TLV_HDR_SIZE +
2335 (peer_ht_rates_align * sizeof(uint8_t)) +
2336 sizeof(wmi_vht_rate_set) +
2337 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2338 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302339
2340 buf = wmi_buf_alloc(wmi_handle, len);
2341 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302342 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302343 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302344 }
2345
2346 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2347 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2348 WMITLV_SET_HDR(&cmd->tlv_header,
2349 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2350 WMITLV_GET_STRUCT_TLVLEN
2351 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302352
Govind Singhd3156eb2016-02-26 17:50:39 +05302353 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302354
Govind Singhd3156eb2016-02-26 17:50:39 +05302355 cmd->peer_new_assoc = param->peer_new_assoc;
2356 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302357
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302358 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302359 copy_peer_mac_addr_tlv(cmd, param);
2360
Govind Singhd3156eb2016-02-26 17:50:39 +05302361 cmd->peer_rate_caps = param->peer_rate_caps;
2362 cmd->peer_caps = param->peer_caps;
2363 cmd->peer_listen_intval = param->peer_listen_intval;
2364 cmd->peer_ht_caps = param->peer_ht_caps;
2365 cmd->peer_max_mpdu = param->peer_max_mpdu;
2366 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302367 cmd->peer_vht_caps = param->peer_vht_caps;
2368 cmd->peer_phymode = param->peer_phymode;
2369
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002370 /* Update 11ax capabilities */
2371 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2372 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002373 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2374 sizeof(param->peer_he_cap_phyinfo));
2375 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2376 sizeof(param->peer_ppet));
2377
Govind Singhd3156eb2016-02-26 17:50:39 +05302378 /* Update peer legacy rate information */
2379 buf_ptr += sizeof(*cmd);
2380 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302381 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302382 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302383 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302384 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302385 param->peer_legacy_rates.num_rates);
2386
2387 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002388 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302389 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302390 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302391 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302392 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302393 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302394 param->peer_ht_rates.num_rates);
2395
2396 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002397 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302398 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2399 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2400
2401 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302402
2403 /* Update bandwidth-NSS mapping */
2404 cmd->peer_bw_rxnss_override = 0;
2405 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2406
Govind Singhd3156eb2016-02-26 17:50:39 +05302407 mcs = (wmi_vht_rate_set *) buf_ptr;
2408 if (param->vht_capable) {
2409 mcs->rx_max_rate = param->rx_max_rate;
2410 mcs->rx_mcs_set = param->rx_mcs_set;
2411 mcs->tx_max_rate = param->tx_max_rate;
2412 mcs->tx_mcs_set = param->tx_mcs_set;
2413 }
2414
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002415 /* HE Rates */
2416 cmd->peer_he_mcs = param->peer_he_mcs_count;
2417 buf_ptr += sizeof(wmi_vht_rate_set);
2418 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2419 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2420 buf_ptr += WMI_TLV_HDR_SIZE;
2421
2422 /* Loop through the HE rate set */
2423 for (i = 0; i < param->peer_he_mcs_count; i++) {
2424 he_mcs = (wmi_he_rate_set *) buf_ptr;
2425 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2426 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2427
2428 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2429 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2430 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2431 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2432 buf_ptr += sizeof(wmi_he_rate_set);
2433 }
2434
2435
Govind Singhb53420c2016-03-09 14:32:57 +05302436 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302437 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2438 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002439 "cmd->peer_vht_caps %x "
2440 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302441 "HE phy %x %x %x "
2442 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302443 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2444 cmd->peer_rate_caps, cmd->peer_caps,
2445 cmd->peer_listen_intval, cmd->peer_ht_caps,
2446 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2447 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002448 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2449 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302450 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2451 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302452
2453 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2454 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302455 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302456 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302457 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302458 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302459 }
2460
2461 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302462}
2463
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302464/* copy_scan_notify_events() - Helper routine to copy scan notify events
2465 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302466static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302467 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302468 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302469{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302470
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302471 /* Scan events subscription */
2472 if (param->scan_ev_started)
2473 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2474 if (param->scan_ev_completed)
2475 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2476 if (param->scan_ev_bss_chan)
2477 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2478 if (param->scan_ev_foreign_chan)
2479 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2480 if (param->scan_ev_dequeued)
2481 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2482 if (param->scan_ev_preempted)
2483 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2484 if (param->scan_ev_start_failed)
2485 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2486 if (param->scan_ev_restarted)
2487 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2488 if (param->scan_ev_foreign_chn_exit)
2489 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2490 if (param->scan_ev_suspended)
2491 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2492 if (param->scan_ev_resumed)
2493 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302494
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302495 /** Set scan control flags */
2496 cmd->scan_ctrl_flags = 0;
2497 if (param->scan_f_passive)
2498 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2499 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302500 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302501 if (param->scan_f_promisc_mode)
2502 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2503 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302504 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302505 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302506 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302507 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302508 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302509 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302510 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302511 if (param->scan_f_ofdm_rates)
2512 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2513 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302514 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302515 if (param->scan_f_filter_prb_req)
2516 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2517 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302518 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302519 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302520 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302521 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302522 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302523 if (param->scan_f_force_active_dfs_chn)
2524 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2525 if (param->scan_f_add_tpc_ie_in_probe)
2526 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2527 if (param->scan_f_add_ds_ie_in_probe)
2528 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2529 if (param->scan_f_add_spoofed_mac_in_probe)
2530 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2531 if (param->scan_f_add_rand_seq_in_probe)
2532 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2533 if (param->scan_f_en_ie_whitelist_in_probe)
2534 cmd->scan_ctrl_flags |=
2535 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302536
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302537 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2538 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2539 param->adaptive_dwell_time_mode);
2540}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302541
2542/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302543static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302544 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302545{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302546 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302547}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302548
Govind Singh5eb51532016-03-09 11:34:12 +05302549/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302550 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2551 * @mac: random mac addr
2552 * @mask: random mac mask
2553 * @mac_addr: wmi random mac
2554 * @mac_mask: wmi random mac mask
2555 *
2556 * Return None.
2557 */
2558static inline
2559void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2560 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2561{
2562 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2563 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2564}
2565
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302566/*
2567 * wmi_fill_vendor_oui() - fill vendor OUIs
2568 * @buf_ptr: pointer to wmi tlv buffer
2569 * @num_vendor_oui: number of vendor OUIs to be filled
2570 * @param_voui: pointer to OUI buffer
2571 *
2572 * This function populates the wmi tlv buffer when vendor specific OUIs are
2573 * present.
2574 *
2575 * Return: None
2576 */
2577static inline
2578void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2579 uint32_t *pvoui)
2580{
2581 wmi_vendor_oui *voui = NULL;
2582 uint32_t i;
2583
2584 voui = (wmi_vendor_oui *)buf_ptr;
2585
2586 for (i = 0; i < num_vendor_oui; i++) {
2587 WMITLV_SET_HDR(&voui[i].tlv_header,
2588 WMITLV_TAG_STRUC_wmi_vendor_oui,
2589 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2590 voui[i].oui_type_subtype = pvoui[i];
2591 }
2592}
2593
2594/*
2595 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2596 * @ie_bitmap: output pointer to ie bit map in cmd
2597 * @num_vendor_oui: output pointer to num vendor OUIs
2598 * @ie_whitelist: input parameter
2599 *
2600 * This function populates the IE whitelist attrs of scan, pno and
2601 * scan oui commands for ie_whitelist parameter.
2602 *
2603 * Return: None
2604 */
2605static inline
2606void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2607 uint32_t *num_vendor_oui,
2608 struct probe_req_whitelist_attr *ie_whitelist)
2609{
2610 uint32_t i = 0;
2611
2612 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2613 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2614
2615 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2616}
2617
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302618/**
Govind Singh5eb51532016-03-09 11:34:12 +05302619 * send_scan_start_cmd_tlv() - WMI scan start function
2620 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302621 * @param param : pointer to hold scan start cmd parameter
2622 *
2623 * Return: 0 on success and -ve on failure.
2624 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302625static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302626 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302627{
Govind Singhd3156eb2016-02-26 17:50:39 +05302628 int32_t ret = 0;
2629 int32_t i;
2630 wmi_buf_t wmi_buf;
2631 wmi_start_scan_cmd_fixed_param *cmd;
2632 uint8_t *buf_ptr;
2633 uint32_t *tmp_ptr;
2634 wmi_ssid *ssid = NULL;
2635 wmi_mac_addr *bssid;
2636 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302637 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302638 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302639 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302640
2641 /* Length TLV placeholder for array of uint32_t */
2642 len += WMI_TLV_HDR_SIZE;
2643 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302644 if (params->chan_list.num_chan)
2645 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302646
2647 /* Length TLV placeholder for array of wmi_ssid structures */
2648 len += WMI_TLV_HDR_SIZE;
2649 if (params->num_ssids)
2650 len += params->num_ssids * sizeof(wmi_ssid);
2651
2652 /* Length TLV placeholder for array of wmi_mac_addr structures */
2653 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302654 if (params->num_bssid)
2655 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302656
2657 /* Length TLV placeholder for array of bytes */
2658 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302659 if (params->extraie.len)
2660 extraie_len_with_pad =
2661 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002662 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302663
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302664 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2665 if (ie_whitelist->num_vendor_oui)
2666 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2667
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302668 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2669 if (params->scan_f_wide_band)
2670 phymode_roundup =
2671 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2672 sizeof(uint32_t));
2673 len += phymode_roundup;
2674
Govind Singhd3156eb2016-02-26 17:50:39 +05302675 /* Allocate the memory */
2676 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2677 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302678 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302679 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302680 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302681 }
2682 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2683 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2684 WMITLV_SET_HDR(&cmd->tlv_header,
2685 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2686 WMITLV_GET_STRUCT_TLVLEN
2687 (wmi_start_scan_cmd_fixed_param));
2688
2689 cmd->scan_id = params->scan_id;
2690 cmd->scan_req_id = params->scan_req_id;
2691 cmd->vdev_id = params->vdev_id;
2692 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302693
2694 copy_scan_event_cntrl_flags(cmd, params);
2695
Govind Singhd3156eb2016-02-26 17:50:39 +05302696 cmd->dwell_time_active = params->dwell_time_active;
2697 cmd->dwell_time_passive = params->dwell_time_passive;
2698 cmd->min_rest_time = params->min_rest_time;
2699 cmd->max_rest_time = params->max_rest_time;
2700 cmd->repeat_probe_time = params->repeat_probe_time;
2701 cmd->probe_spacing_time = params->probe_spacing_time;
2702 cmd->idle_time = params->idle_time;
2703 cmd->max_scan_time = params->max_scan_time;
2704 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302705 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302706 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302707 cmd->num_bssid = params->num_bssid;
2708 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302709 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302710 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302711 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2712
2713 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2714
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302715 if (params->scan_random.randomize)
2716 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2717 params->scan_random.mac_mask,
2718 &cmd->mac_addr,
2719 &cmd->mac_mask);
2720
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302721 if (ie_whitelist->white_list)
2722 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2723 &cmd->num_vendor_oui,
2724 ie_whitelist);
2725
Govind Singhd3156eb2016-02-26 17:50:39 +05302726 buf_ptr += sizeof(*cmd);
2727 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302728 for (i = 0; i < params->chan_list.num_chan; ++i)
2729 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302730
2731 WMITLV_SET_HDR(buf_ptr,
2732 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302733 (params->chan_list.num_chan * sizeof(uint32_t)));
2734 buf_ptr += WMI_TLV_HDR_SIZE +
2735 (params->chan_list.num_chan * sizeof(uint32_t));
2736
Govind Singh4eacd2b2016-03-07 14:24:22 +05302737 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302738 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302739 goto error;
2740 }
2741
2742 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2743 (params->num_ssids * sizeof(wmi_ssid)));
2744
2745 if (params->num_ssids) {
2746 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2747 for (i = 0; i < params->num_ssids; ++i) {
2748 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302749 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302750 params->ssid[i].length);
2751 ssid++;
2752 }
2753 }
2754 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2755
2756 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2757 (params->num_bssid * sizeof(wmi_mac_addr)));
2758 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302759
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302760 if (params->num_bssid) {
2761 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302762 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2763 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302764 bssid++;
2765 }
2766 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302767
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302768 buf_ptr += WMI_TLV_HDR_SIZE +
2769 (params->num_bssid * sizeof(wmi_mac_addr));
2770
2771 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2772 if (params->extraie.len)
2773 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2774 params);
2775
2776 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302777
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302778 /* probe req ie whitelisting */
2779 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2780 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2781
2782 buf_ptr += WMI_TLV_HDR_SIZE;
2783
2784 if (cmd->num_vendor_oui) {
2785 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2786 ie_whitelist->voui);
2787 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2788 }
2789
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302790 /* Add phy mode TLV if it's a wide band scan */
2791 if (params->scan_f_wide_band) {
2792 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2793 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2794 for (i = 0; i < params->chan_list.num_chan; ++i)
2795 buf_ptr[i] =
2796 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2797 buf_ptr += phymode_roundup;
2798 } else {
2799 /* Add ZERO legth phy mode TLV */
2800 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2801 }
2802
Santosh Anbu1e11b472018-03-07 15:33:27 +05302803 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002804 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302805 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302806 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302807 wmi_buf_free(wmi_buf);
2808 }
2809 return ret;
2810error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302811 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302812 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302813}
2814
2815/**
2816 * send_scan_stop_cmd_tlv() - WMI scan start function
2817 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302818 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302819 *
2820 * Return: 0 on success and -ve on failure.
2821 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302822static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302823 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302824{
Govind Singhd3156eb2016-02-26 17:50:39 +05302825 wmi_stop_scan_cmd_fixed_param *cmd;
2826 int ret;
2827 int len = sizeof(*cmd);
2828 wmi_buf_t wmi_buf;
2829
2830 /* Allocate the memory */
2831 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2832 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302833 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302834 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302835 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302836 goto error;
2837 }
2838
2839 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2840 WMITLV_SET_HDR(&cmd->tlv_header,
2841 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2842 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2843 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302844 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302845 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302846 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2847 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302848 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302849 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2850 /* Cancelling all scans */
2851 cmd->req_type = WMI_SCAN_STOP_ALL;
2852 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2853 /* Cancelling VAP scans */
2854 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2855 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2856 /* Cancelling specific scan */
2857 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302858 } else {
2859 WMI_LOGE("%s: Invalid Command : ", __func__);
2860 wmi_buf_free(wmi_buf);
2861 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302862 }
2863
Santosh Anbu1e11b472018-03-07 15:33:27 +05302864 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002865 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302866 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302867 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302868 wmi_buf_free(wmi_buf);
2869 }
2870
2871error:
2872 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302873}
2874
Govind Singh87542482016-06-08 19:40:11 +05302875#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302876/**
2877 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2878 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302879 * @param param : pointer to hold scan channel list parameter
2880 *
2881 * Return: 0 on success and -ve on failure.
2882 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302883static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302884 struct scan_chan_list_params *chan_list)
2885{
2886 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302887 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302888 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302889 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302890 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302891 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302892 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2893
2894 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2895 buf = wmi_buf_alloc(wmi_handle, len);
2896 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302897 WMI_LOGE("Failed to allocate memory");
2898 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302899 goto end;
2900 }
2901
2902 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2903 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2904 WMITLV_SET_HDR(&cmd->tlv_header,
2905 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2906 WMITLV_GET_STRUCT_TLVLEN
2907 (wmi_scan_chan_list_cmd_fixed_param));
2908
Govind Singhb53420c2016-03-09 14:32:57 +05302909 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302910
2911 cmd->num_scan_chans = chan_list->num_scan_chans;
2912 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2913 WMITLV_TAG_ARRAY_STRUC,
2914 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302915 chan_info = (wmi_channel_param *)
2916 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302917 tchan_info = chan_list->chan_info;
2918
2919 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2920 WMITLV_SET_HDR(&chan_info->tlv_header,
2921 WMITLV_TAG_STRUC_wmi_channel,
2922 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2923 chan_info->mhz = tchan_info->mhz;
2924 chan_info->band_center_freq1 =
2925 tchan_info->band_center_freq1;
2926 chan_info->band_center_freq2 =
2927 tchan_info->band_center_freq2;
2928 chan_info->info = tchan_info->info;
2929 chan_info->reg_info_1 = tchan_info->reg_info_1;
2930 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302931 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302932
2933 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2934 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2935 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2936 tchan_info++;
2937 chan_info++;
2938 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302939 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2940 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302941
Anish Natarajdd855152017-03-20 12:49:08 +05302942 qdf_status = wmi_unified_cmd_send(wmi_handle,
2943 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302944
Govind Singh67922e82016-04-01 16:48:57 +05302945 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302946 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302947 wmi_buf_free(buf);
2948 }
Govind Singh67922e82016-04-01 16:48:57 +05302949
Govind Singhd3156eb2016-02-26 17:50:39 +05302950end:
Govind Singhb53420c2016-03-09 14:32:57 +05302951 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302952}
Govind Singh87542482016-06-08 19:40:11 +05302953#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302954static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302955 struct scan_chan_list_params *chan_list)
2956{
2957 wmi_buf_t buf;
2958 QDF_STATUS qdf_status;
2959 wmi_scan_chan_list_cmd_fixed_param *cmd;
2960 int i;
2961 uint8_t *buf_ptr;
2962 wmi_channel *chan_info;
2963 struct channel_param *tchan_info;
2964 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302965
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302966 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302967 buf = wmi_buf_alloc(wmi_handle, len);
2968 if (!buf) {
2969 WMI_LOGE("Failed to allocate memory");
2970 qdf_status = QDF_STATUS_E_NOMEM;
2971 goto end;
2972 }
2973
2974 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2975 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2976 WMITLV_SET_HDR(&cmd->tlv_header,
2977 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2978 WMITLV_GET_STRUCT_TLVLEN
2979 (wmi_scan_chan_list_cmd_fixed_param));
2980
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302981 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302982
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302983 if (chan_list->append)
2984 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2985
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302986 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2987 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302988 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302989 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2990 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302991 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302992 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2993 tchan_info = &(chan_list->ch_param[0]);
2994
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302995 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302996 WMITLV_SET_HDR(&chan_info->tlv_header,
2997 WMITLV_TAG_STRUC_wmi_channel,
2998 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2999 chan_info->mhz = tchan_info->mhz;
3000 chan_info->band_center_freq1 =
3001 tchan_info->cfreq1;
3002 chan_info->band_center_freq2 =
3003 tchan_info->cfreq2;
3004
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303005 if (tchan_info->is_chan_passive)
3006 WMI_SET_CHANNEL_FLAG(chan_info,
3007 WMI_CHAN_FLAG_PASSIVE);
3008
3009 if (tchan_info->allow_vht)
3010 WMI_SET_CHANNEL_FLAG(chan_info,
3011 WMI_CHAN_FLAG_ALLOW_VHT);
3012 else if (tchan_info->allow_ht)
3013 WMI_SET_CHANNEL_FLAG(chan_info,
3014 WMI_CHAN_FLAG_ALLOW_HT);
3015 WMI_SET_CHANNEL_MODE(chan_info,
3016 tchan_info->phy_mode);
3017
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05303018 if (tchan_info->half_rate)
3019 WMI_SET_CHANNEL_FLAG(chan_info,
3020 WMI_CHAN_FLAG_HALF_RATE);
3021
3022 if (tchan_info->quarter_rate)
3023 WMI_SET_CHANNEL_FLAG(chan_info,
3024 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303025
3026 /* also fill in power information */
3027 WMI_SET_CHANNEL_MIN_POWER(chan_info,
3028 tchan_info->minpower);
3029 WMI_SET_CHANNEL_MAX_POWER(chan_info,
3030 tchan_info->maxpower);
3031 WMI_SET_CHANNEL_REG_POWER(chan_info,
3032 tchan_info->maxregpower);
3033 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
3034 tchan_info->antennamax);
3035 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
3036 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08003037 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
3038 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303039
Govind Singh87542482016-06-08 19:40:11 +05303040 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
3041
Govind Singh87542482016-06-08 19:40:11 +05303042 tchan_info++;
3043 chan_info++;
3044 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303045 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3046 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05303047
Anish Natarajdd855152017-03-20 12:49:08 +05303048 qdf_status = wmi_unified_cmd_send(
3049 wmi_handle,
3050 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05303051
3052 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3053 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
3054 wmi_buf_free(buf);
3055 }
3056
3057end:
3058 return qdf_status;
3059}
3060#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05303061
3062/**
3063 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3064 *
3065 * @bufp: Pointer to buffer
3066 * @param: Pointer to tx param
3067 *
3068 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3069 */
3070static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3071 struct tx_send_params param)
3072{
3073 wmi_tx_send_params *tx_param;
3074 QDF_STATUS status = QDF_STATUS_SUCCESS;
3075
3076 if (!bufp) {
3077 status = QDF_STATUS_E_FAILURE;
3078 return status;
3079 }
3080 tx_param = (wmi_tx_send_params *)bufp;
3081 WMITLV_SET_HDR(&tx_param->tlv_header,
3082 WMITLV_TAG_STRUC_wmi_tx_send_params,
3083 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3084 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3085 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3086 param.mcs_mask);
3087 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3088 param.nss_mask);
3089 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3090 param.retry_limit);
3091 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3092 param.chain_mask);
3093 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3094 param.bw_mask);
3095 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3096 param.preamble_type);
3097 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3098 param.frame_type);
3099
3100 return status;
3101}
3102
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303103#ifdef CONFIG_HL_SUPPORT
3104/**
3105 * send_mgmt_cmd_tlv() - WMI scan start function
3106 * @wmi_handle : handle to WMI.
3107 * @param : pointer to hold mgmt cmd parameter
3108 *
3109 * Return: 0 on success and -ve on failure.
3110 */
3111static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
3112 struct wmi_mgmt_params *param)
3113{
3114 wmi_buf_t buf;
3115 uint8_t *bufp;
3116 int32_t cmd_len;
3117 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3118 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3119 mgmt_tx_dl_frm_len;
3120
3121 if (param->frm_len > mgmt_tx_dl_frm_len) {
3122 WMI_LOGE("%s:mgmt frame len %u exceeds %u",
3123 __func__, param->frm_len, mgmt_tx_dl_frm_len);
3124 return QDF_STATUS_E_INVAL;
3125 }
3126
3127 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
3128 WMI_TLV_HDR_SIZE +
3129 roundup(bufp_len, sizeof(uint32_t));
3130
3131 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
3132 if (!buf) {
3133 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3134 return QDF_STATUS_E_NOMEM;
3135 }
3136
3137 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3138 bufp = (uint8_t *) cmd;
3139 WMITLV_SET_HDR(&cmd->tlv_header,
3140 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3141 WMITLV_GET_STRUCT_TLVLEN
3142 (wmi_mgmt_tx_send_cmd_fixed_param));
3143
3144 cmd->vdev_id = param->vdev_id;
3145
3146 cmd->desc_id = param->desc_id;
3147 cmd->chanfreq = param->chanfreq;
3148 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3149 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3150 sizeof(uint32_t)));
3151 bufp += WMI_TLV_HDR_SIZE;
3152 qdf_mem_copy(bufp, param->pdata, bufp_len);
3153
3154 cmd->frame_len = param->frm_len;
3155 cmd->buf_len = bufp_len;
3156 cmd->tx_params_valid = param->tx_params_valid;
3157
3158 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
3159 bufp, cmd->vdev_id, cmd->chanfreq);
3160
3161 bufp += roundup(bufp_len, sizeof(uint32_t));
3162 if (param->tx_params_valid) {
3163 if (populate_tx_send_params(bufp, param->tx_param) !=
3164 QDF_STATUS_SUCCESS) {
3165 WMI_LOGE("%s: Populate TX send params failed",
3166 __func__);
3167 goto free_buf;
3168 }
3169 cmd_len += sizeof(wmi_tx_send_params);
3170 }
3171
3172 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3173 WMI_MGMT_TX_SEND_CMDID)) {
3174 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
3175 goto free_buf;
3176 }
3177 return QDF_STATUS_SUCCESS;
3178
3179free_buf:
3180 wmi_buf_free(buf);
3181 return QDF_STATUS_E_FAILURE;
3182}
3183#else
Govind Singhd3156eb2016-02-26 17:50:39 +05303184/**
3185 * send_mgmt_cmd_tlv() - WMI scan start function
3186 * @wmi_handle : handle to WMI.
3187 * @param : pointer to hold mgmt cmd parameter
3188 *
3189 * Return: 0 on success and -ve on failure.
3190 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303191static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303192 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303193{
Govind Singh427ee5a2016-02-26 18:09:36 +05303194 wmi_buf_t buf;
3195 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3196 int32_t cmd_len;
3197 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303198 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303199 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303200 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303201 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3202 mgmt_tx_dl_frm_len;
3203
3204 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303205 WMI_TLV_HDR_SIZE +
3206 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303207
Sathish Kumar5b636932017-06-28 14:40:32 +05303208 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303209 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303210 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3211 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303212 }
3213
3214 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3215 bufp = (uint8_t *) cmd;
3216 WMITLV_SET_HDR(&cmd->tlv_header,
3217 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3218 WMITLV_GET_STRUCT_TLVLEN
3219 (wmi_mgmt_tx_send_cmd_fixed_param));
3220
3221 cmd->vdev_id = param->vdev_id;
3222
Govind Singh224a7312016-06-21 14:33:26 +05303223 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303224 cmd->chanfreq = param->chanfreq;
3225 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3226 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3227 sizeof(uint32_t)));
3228 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303229 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303230
3231 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3232 QDF_DMA_TO_DEVICE);
3233 if (status != QDF_STATUS_SUCCESS) {
3234 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303235 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303236 }
3237
Govind Singhb53420c2016-03-09 14:32:57 +05303238 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303239 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003240#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303241 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3242#endif
3243 cmd->frame_len = param->frm_len;
3244 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303245 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303246
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003247 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003248 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003249
Sathish Kumar5b636932017-06-28 14:40:32 +05303250 bufp += roundup(bufp_len, sizeof(uint32_t));
3251 if (param->tx_params_valid) {
3252 status = populate_tx_send_params(bufp, param->tx_param);
3253 if (status != QDF_STATUS_SUCCESS) {
3254 WMI_LOGE("%s: Populate TX send params failed",
3255 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303256 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303257 }
3258 cmd_len += sizeof(wmi_tx_send_params);
3259 }
3260
Govind Singh427ee5a2016-02-26 18:09:36 +05303261 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3262 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303263 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303264 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303265 }
Govind Singhb53420c2016-03-09 14:32:57 +05303266 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303267
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303268unmap_tx_frame:
3269 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3270 QDF_DMA_TO_DEVICE);
3271free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303272 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303273 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303274}
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303275#endif /* CONFIG_HL_SUPPORT */
Govind Singh427ee5a2016-02-26 18:09:36 +05303276
3277/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303278 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3279 * @wmi_handle : handle to WMI.
3280 * @param : pointer to offchan data tx cmd parameter
3281 *
3282 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3283 */
3284static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3285 struct wmi_offchan_data_tx_params *param)
3286{
3287 wmi_buf_t buf;
3288 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3289 int32_t cmd_len;
3290 uint64_t dma_addr;
3291 void *qdf_ctx = param->qdf_ctx;
3292 uint8_t *bufp;
3293 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3294 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303295 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303296
3297 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303298 WMI_TLV_HDR_SIZE +
3299 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303300
Sathish Kumar5b636932017-06-28 14:40:32 +05303301 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303302 if (!buf) {
3303 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3304 return QDF_STATUS_E_NOMEM;
3305 }
3306
3307 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3308 bufp = (uint8_t *) cmd;
3309 WMITLV_SET_HDR(&cmd->tlv_header,
3310 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3311 WMITLV_GET_STRUCT_TLVLEN
3312 (wmi_offchan_data_tx_send_cmd_fixed_param));
3313
3314 cmd->vdev_id = param->vdev_id;
3315
3316 cmd->desc_id = param->desc_id;
3317 cmd->chanfreq = param->chanfreq;
3318 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3319 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3320 sizeof(uint32_t)));
3321 bufp += WMI_TLV_HDR_SIZE;
3322 qdf_mem_copy(bufp, param->pdata, bufp_len);
3323 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3324 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3325 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3326#if defined(HTT_PADDR64)
3327 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3328#endif
3329 cmd->frame_len = param->frm_len;
3330 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303331 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303332
3333 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3334 bufp, cmd->vdev_id, cmd->chanfreq);
3335
Sathish Kumar5b636932017-06-28 14:40:32 +05303336 bufp += roundup(bufp_len, sizeof(uint32_t));
3337 if (param->tx_params_valid) {
3338 status = populate_tx_send_params(bufp, param->tx_param);
3339 if (status != QDF_STATUS_SUCCESS) {
3340 WMI_LOGE("%s: Populate TX send params failed",
3341 __func__);
3342 goto err1;
3343 }
3344 cmd_len += sizeof(wmi_tx_send_params);
3345 }
3346
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303347 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3348 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3349 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303350 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303351 }
3352
3353 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303354
3355err1:
3356 wmi_buf_free(buf);
3357 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303358}
3359
3360/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303361 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3362 * @wmi_handle: wmi handle
3363 * @param_value: parameter value
3364 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303365 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303366 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303367static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303368 uint32_t param_value)
3369{
Govind Singh67922e82016-04-01 16:48:57 +05303370 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303371 wmi_modem_power_state_cmd_param *cmd;
3372 wmi_buf_t buf;
3373 uint16_t len = sizeof(*cmd);
3374
3375 buf = wmi_buf_alloc(wmi_handle, len);
3376 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303377 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303378 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303379 }
3380 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3381 WMITLV_SET_HDR(&cmd->tlv_header,
3382 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3383 WMITLV_GET_STRUCT_TLVLEN
3384 (wmi_modem_power_state_cmd_param));
3385 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303386 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303387 param_value);
3388 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3389 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303390 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303391 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303392 wmi_buf_free(buf);
3393 }
Govind Singh67922e82016-04-01 16:48:57 +05303394
Govind Singh427ee5a2016-02-26 18:09:36 +05303395 return ret;
3396}
3397
3398/**
3399 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3400 * @wmi_handle: wmi handle
3401 * @vdev_id: vdev id
3402 * @val: value
3403 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303404 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303405 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303406static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303407 uint32_t vdev_id, uint8_t val)
3408{
3409 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3410 wmi_buf_t buf;
3411 int32_t len = sizeof(*cmd);
3412
Govind Singhb53420c2016-03-09 14:32:57 +05303413 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303414
3415 buf = wmi_buf_alloc(wmi_handle, len);
3416 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303417 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303418 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303419 }
3420 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3421 WMITLV_SET_HDR(&cmd->tlv_header,
3422 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3423 WMITLV_GET_STRUCT_TLVLEN
3424 (wmi_sta_powersave_mode_cmd_fixed_param));
3425 cmd->vdev_id = vdev_id;
3426 if (val)
3427 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3428 else
3429 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3430
3431 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3432 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303433 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303434 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303435 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303436 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303437 }
Govind Singh5eb51532016-03-09 11:34:12 +05303438 return 0;
3439}
3440
Govind Singh427ee5a2016-02-26 18:09:36 +05303441/**
3442 * send_set_mimops_cmd_tlv() - set MIMO powersave
3443 * @wmi_handle: wmi handle
3444 * @vdev_id: vdev id
3445 * @value: value
3446 *
Govind Singhb53420c2016-03-09 14:32:57 +05303447 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303448 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303449static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303450 uint8_t vdev_id, int value)
3451{
Govind Singh67922e82016-04-01 16:48:57 +05303452 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303453 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3454 wmi_buf_t buf;
3455 uint16_t len = sizeof(*cmd);
3456
3457 buf = wmi_buf_alloc(wmi_handle, len);
3458 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303459 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303460 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303461 }
3462 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3463 WMITLV_SET_HDR(&cmd->tlv_header,
3464 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3465 WMITLV_GET_STRUCT_TLVLEN
3466 (wmi_sta_smps_force_mode_cmd_fixed_param));
3467
3468 cmd->vdev_id = vdev_id;
3469
Houston Hoffmanb5168052016-04-14 02:18:01 -07003470 /* WMI_SMPS_FORCED_MODE values do not directly map
3471 * to SM power save values defined in the specification.
3472 * Make sure to send the right mapping.
3473 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303474 switch (value) {
3475 case 0:
3476 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3477 break;
3478 case 1:
3479 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3480 break;
3481 case 2:
3482 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3483 break;
3484 case 3:
3485 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3486 break;
3487 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303488 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303489 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303490 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303491 }
3492
Govind Singhb53420c2016-03-09 14:32:57 +05303493 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303494
3495 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3496 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303497 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303498 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303499 wmi_buf_free(buf);
3500 }
3501
3502 return ret;
3503}
3504
3505/**
3506 * send_set_smps_params_cmd_tlv() - set smps params
3507 * @wmi_handle: wmi handle
3508 * @vdev_id: vdev id
3509 * @value: value
3510 *
Govind Singhb53420c2016-03-09 14:32:57 +05303511 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303512 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303513static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303514 int value)
3515{
Govind Singh67922e82016-04-01 16:48:57 +05303516 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303517 wmi_sta_smps_param_cmd_fixed_param *cmd;
3518 wmi_buf_t buf;
3519 uint16_t len = sizeof(*cmd);
3520
3521 buf = wmi_buf_alloc(wmi_handle, len);
3522 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303523 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303524 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303525 }
3526 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3527 WMITLV_SET_HDR(&cmd->tlv_header,
3528 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3529 WMITLV_GET_STRUCT_TLVLEN
3530 (wmi_sta_smps_param_cmd_fixed_param));
3531
3532 cmd->vdev_id = vdev_id;
3533 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3534 cmd->param =
3535 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3536
Govind Singhb53420c2016-03-09 14:32:57 +05303537 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303538 cmd->param);
3539
3540 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3541 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303542 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303543 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303544 wmi_buf_free(buf);
3545 }
3546
3547 return ret;
3548}
3549
3550/**
3551 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3552 * @wmi_handle: wmi handle
3553 * @noa: p2p power save parameters
3554 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303555 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303556 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303557static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303558 struct p2p_ps_params *noa)
3559{
3560 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3561 wmi_p2p_noa_descriptor *noa_discriptor;
3562 wmi_buf_t buf;
3563 uint8_t *buf_ptr;
3564 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303565 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303566 uint32_t duration;
3567
Govind Singhb53420c2016-03-09 14:32:57 +05303568 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303569 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3570 buf = wmi_buf_alloc(wmi_handle, len);
3571 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303572 WMI_LOGE("Failed to allocate memory");
3573 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303574 goto end;
3575 }
3576
3577 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3578 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3579 WMITLV_SET_HDR(&cmd->tlv_header,
3580 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3581 WMITLV_GET_STRUCT_TLVLEN
3582 (wmi_p2p_set_noa_cmd_fixed_param));
3583 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3584 cmd->vdev_id = noa->session_id;
3585 cmd->enable = (duration) ? true : false;
3586 cmd->num_noa = 1;
3587
3588 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3589 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3590 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3591 sizeof
3592 (wmi_p2p_set_noa_cmd_fixed_param)
3593 + WMI_TLV_HDR_SIZE);
3594 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3595 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3596 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3597 noa_discriptor->type_count = noa->count;
3598 noa_discriptor->duration = duration;
3599 noa_discriptor->interval = noa->interval;
3600 noa_discriptor->start_time = 0;
3601
Govind Singhb53420c2016-03-09 14:32:57 +05303602 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303603 cmd->vdev_id, noa->count, noa_discriptor->duration,
3604 noa->interval);
3605 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3606 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303607 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303608 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303609 wmi_buf_free(buf);
3610 }
3611
3612end:
Govind Singhb53420c2016-03-09 14:32:57 +05303613 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303614 return status;
3615}
3616
3617
3618/**
3619 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3620 * @wmi_handle: wmi handle
3621 * @noa: p2p opp power save parameters
3622 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303623 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303624 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303625static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303626 struct p2p_ps_params *oppps)
3627{
3628 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3629 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303630 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303631
Govind Singhb53420c2016-03-09 14:32:57 +05303632 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303633 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3634 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303635 WMI_LOGE("Failed to allocate memory");
3636 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303637 goto end;
3638 }
3639
3640 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3641 WMITLV_SET_HDR(&cmd->tlv_header,
3642 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3643 WMITLV_GET_STRUCT_TLVLEN
3644 (wmi_p2p_set_oppps_cmd_fixed_param));
3645 cmd->vdev_id = oppps->session_id;
3646 if (oppps->ctwindow)
3647 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3648
3649 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303650 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303651 cmd->vdev_id, oppps->ctwindow);
3652 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3653 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303654 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303655 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303656 wmi_buf_free(buf);
3657 }
3658
3659end:
Govind Singhb53420c2016-03-09 14:32:57 +05303660 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303661 return status;
3662}
3663
Wu Gaocd3a8512017-03-13 20:17:34 +08003664#ifdef CONVERGED_P2P_ENABLE
3665/**
3666 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3667 * @wmi_handle: wmi handle
3668 * @param: p2p listen offload start parameters
3669 *
3670 * Return: QDF status
3671 */
3672static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3673 struct p2p_lo_start *param)
3674{
3675 wmi_buf_t buf;
3676 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3677 int32_t len = sizeof(*cmd);
3678 uint8_t *buf_ptr;
3679 QDF_STATUS status;
3680 int device_types_len_aligned;
3681 int probe_resp_len_aligned;
3682
3683 if (!param) {
3684 WMI_LOGE("lo start param is null");
3685 return QDF_STATUS_E_INVAL;
3686 }
3687
3688 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3689
3690 device_types_len_aligned =
3691 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303692 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003693 probe_resp_len_aligned =
3694 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303695 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003696
3697 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3698 probe_resp_len_aligned;
3699
3700 buf = wmi_buf_alloc(wmi_handle, len);
3701 if (!buf) {
3702 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3703 __func__);
3704 return QDF_STATUS_E_NOMEM;
3705 }
3706
3707 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3708 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3709
3710 WMITLV_SET_HDR(&cmd->tlv_header,
3711 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3712 WMITLV_GET_STRUCT_TLVLEN(
3713 wmi_p2p_lo_start_cmd_fixed_param));
3714
3715 cmd->vdev_id = param->vdev_id;
3716 cmd->ctl_flags = param->ctl_flags;
3717 cmd->channel = param->freq;
3718 cmd->period = param->period;
3719 cmd->interval = param->interval;
3720 cmd->count = param->count;
3721 cmd->device_types_len = param->dev_types_len;
3722 cmd->prob_resp_len = param->probe_resp_len;
3723
3724 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3725 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3726 device_types_len_aligned);
3727 buf_ptr += WMI_TLV_HDR_SIZE;
3728 qdf_mem_copy(buf_ptr, param->device_types,
3729 param->dev_types_len);
3730
3731 buf_ptr += device_types_len_aligned;
3732 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3733 probe_resp_len_aligned);
3734 buf_ptr += WMI_TLV_HDR_SIZE;
3735 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3736 param->probe_resp_len);
3737
3738 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3739 cmd->channel, cmd->period, cmd->interval, cmd->count);
3740
3741 status = wmi_unified_cmd_send(wmi_handle,
3742 buf, len,
3743 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3744 if (status != QDF_STATUS_SUCCESS) {
3745 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3746 __func__, status);
3747 wmi_buf_free(buf);
3748 return status;
3749 }
3750
3751 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3752
3753 return QDF_STATUS_SUCCESS;
3754}
3755
3756/**
3757 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3758 * @wmi_handle: wmi handle
3759 * @param: p2p listen offload stop parameters
3760 *
3761 * Return: QDF status
3762 */
3763static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3764 uint8_t vdev_id)
3765{
3766 wmi_buf_t buf;
3767 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3768 int32_t len;
3769 QDF_STATUS status;
3770
3771 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3772
3773 len = sizeof(*cmd);
3774 buf = wmi_buf_alloc(wmi_handle, len);
3775 if (!buf) {
3776 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3777 __func__);
3778 return QDF_STATUS_E_NOMEM;
3779 }
3780 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3781
3782 WMITLV_SET_HDR(&cmd->tlv_header,
3783 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3784 WMITLV_GET_STRUCT_TLVLEN(
3785 wmi_p2p_lo_stop_cmd_fixed_param));
3786
3787 cmd->vdev_id = vdev_id;
3788
3789 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3790
3791 status = wmi_unified_cmd_send(wmi_handle,
3792 buf, len,
3793 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3794 if (status != QDF_STATUS_SUCCESS) {
3795 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3796 __func__, status);
3797 wmi_buf_free(buf);
3798 return status;
3799 }
3800
3801 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3802
3803 return QDF_STATUS_SUCCESS;
3804}
3805#endif /* End of CONVERGED_P2P_ENABLE */
3806
Govind Singh427ee5a2016-02-26 18:09:36 +05303807/**
3808 * send_get_temperature_cmd_tlv() - get pdev temperature req
3809 * @wmi_handle: wmi handle
3810 *
Govind Singhb53420c2016-03-09 14:32:57 +05303811 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303812 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303813static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303814{
3815 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3816 wmi_buf_t wmi_buf;
3817 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3818 uint8_t *buf_ptr;
3819
3820 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303821 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3822 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303823 }
3824
3825 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3826 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303827 WMI_LOGE(FL("wmi_buf_alloc failed"));
3828 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303829 }
3830
3831 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3832
3833 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3834 WMITLV_SET_HDR(&cmd->tlv_header,
3835 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3836 WMITLV_GET_STRUCT_TLVLEN
3837 (wmi_pdev_get_temperature_cmd_fixed_param));
3838
3839 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3840 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303841 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303842 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303843 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303844 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303845
Govind Singhb53420c2016-03-09 14:32:57 +05303846 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303847}
3848
3849/**
3850 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3851 * @wmi_handle: wmi handle
3852 * @vdevid: vdev id
3853 * @peer_addr: peer mac address
3854 * @auto_triggerparam: auto trigger parameters
3855 * @num_ac: number of access category
3856 *
3857 * This function sets the trigger
3858 * uapsd params such as service interval, delay interval
3859 * and suspend interval which will be used by the firmware
3860 * to send trigger frames periodically when there is no
3861 * traffic on the transmit side.
3862 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303863 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303864 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303865static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303866 struct sta_uapsd_trig_params *param)
3867{
3868 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303869 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303870 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3871 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3872 uint32_t i;
3873 wmi_buf_t buf;
3874 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003875 struct sta_uapsd_params *uapsd_param;
3876 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303877
3878 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3879 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303880 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303881 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303882 }
3883
3884 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3885 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3886 WMITLV_SET_HDR(&cmd->tlv_header,
3887 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3888 WMITLV_GET_STRUCT_TLVLEN
3889 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3890 cmd->vdev_id = param->vdevid;
3891 cmd->num_ac = param->num_ac;
3892 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3893
3894 /* TLV indicating array of structures to follow */
3895 buf_ptr += sizeof(*cmd);
3896 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3897
3898 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303899
3900 /*
3901 * Update tag and length for uapsd auto trigger params (this will take
3902 * care of updating tag and length if it is not pre-filled by caller).
3903 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003904 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3905 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303906 for (i = 0; i < param->num_ac; i++) {
3907 WMITLV_SET_HDR((buf_ptr +
3908 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3909 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3910 WMITLV_GET_STRUCT_TLVLEN
3911 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003912 trig_param->wmm_ac = uapsd_param->wmm_ac;
3913 trig_param->user_priority = uapsd_param->user_priority;
3914 trig_param->service_interval = uapsd_param->service_interval;
3915 trig_param->suspend_interval = uapsd_param->suspend_interval;
3916 trig_param->delay_interval = uapsd_param->delay_interval;
3917 trig_param++;
3918 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303919 }
3920
3921 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3922 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303923 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303924 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303925 wmi_buf_free(buf);
3926 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303927
Govind Singh427ee5a2016-02-26 18:09:36 +05303928 return ret;
3929}
3930
Zhang Qian11c0de32018-01-05 16:50:53 +08003931#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303932/**
3933 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3934 * @wmi_handle: pointer to the wmi handle
3935 * @utc: pointer to the UTC time struct
3936 *
3937 * Return: 0 on succes
3938 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303939static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303940 struct ocb_utc_param *utc)
3941{
Govind Singh67922e82016-04-01 16:48:57 +05303942 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303943 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3944 uint8_t *buf_ptr;
3945 uint32_t len, i;
3946 wmi_buf_t buf;
3947
3948 len = sizeof(*cmd);
3949 buf = wmi_buf_alloc(wmi_handle, len);
3950 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303951 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303952 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303953 }
3954
3955 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3956 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3957 WMITLV_SET_HDR(&cmd->tlv_header,
3958 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3959 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3960 cmd->vdev_id = utc->vdev_id;
3961
3962 for (i = 0; i < SIZE_UTC_TIME; i++)
3963 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3964
3965 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3966 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3967
3968 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3969 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303970 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303971 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303972 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303973 }
3974
Govind Singh67922e82016-04-01 16:48:57 +05303975 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303976}
3977
3978/**
3979 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3980 * frames on a channel
3981 * @wmi_handle: pointer to the wmi handle
3982 * @timing_advert: pointer to the timing advertisement struct
3983 *
3984 * Return: 0 on succes
3985 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303986static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303987 struct ocb_timing_advert_param *timing_advert)
3988{
Govind Singh67922e82016-04-01 16:48:57 +05303989 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303990 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3991 uint8_t *buf_ptr;
3992 uint32_t len, len_template;
3993 wmi_buf_t buf;
3994
3995 len = sizeof(*cmd) +
3996 WMI_TLV_HDR_SIZE;
3997
3998 len_template = timing_advert->template_length;
3999 /* Add padding to the template if needed */
4000 if (len_template % 4 != 0)
4001 len_template += 4 - (len_template % 4);
4002 len += len_template;
4003
4004 buf = wmi_buf_alloc(wmi_handle, len);
4005 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304006 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304007 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304008 }
4009
4010 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4011 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
4012 WMITLV_SET_HDR(&cmd->tlv_header,
4013 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
4014 WMITLV_GET_STRUCT_TLVLEN(
4015 wmi_ocb_start_timing_advert_cmd_fixed_param));
4016 cmd->vdev_id = timing_advert->vdev_id;
4017 cmd->repeat_rate = timing_advert->repeat_rate;
4018 cmd->channel_freq = timing_advert->chan_freq;
4019 cmd->timestamp_offset = timing_advert->timestamp_offset;
4020 cmd->time_value_offset = timing_advert->time_value_offset;
4021 cmd->timing_advert_template_length = timing_advert->template_length;
4022 buf_ptr += sizeof(*cmd);
4023
4024 /* Add the timing advert template */
4025 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4026 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05304027 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05304028 (uint8_t *)timing_advert->template_value,
4029 timing_advert->template_length);
4030
4031 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4032 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304033 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304034 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304035 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304036 }
4037
Govind Singh67922e82016-04-01 16:48:57 +05304038 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304039}
4040
4041/**
4042 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
4043 * on a channel
4044 * @wmi_handle: pointer to the wmi handle
4045 * @timing_advert: pointer to the timing advertisement struct
4046 *
4047 * Return: 0 on succes
4048 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304049static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304050 struct ocb_timing_advert_param *timing_advert)
4051{
Govind Singh67922e82016-04-01 16:48:57 +05304052 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304053 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
4054 uint8_t *buf_ptr;
4055 uint32_t len;
4056 wmi_buf_t buf;
4057
4058 len = sizeof(*cmd);
4059 buf = wmi_buf_alloc(wmi_handle, len);
4060 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304061 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304062 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304063 }
4064
4065 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4066 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
4067 WMITLV_SET_HDR(&cmd->tlv_header,
4068 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
4069 WMITLV_GET_STRUCT_TLVLEN(
4070 wmi_ocb_stop_timing_advert_cmd_fixed_param));
4071 cmd->vdev_id = timing_advert->vdev_id;
4072 cmd->channel_freq = timing_advert->chan_freq;
4073
4074 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4075 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304076 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304077 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304078 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304079 }
4080
Govind Singh67922e82016-04-01 16:48:57 +05304081 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304082}
4083
4084/**
4085 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
4086 * @wmi_handle: pointer to the wmi handle
4087 * @request: pointer to the request
4088 *
4089 * Return: 0 on succes
4090 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304091static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304092 uint8_t vdev_id)
4093{
Govind Singhb53420c2016-03-09 14:32:57 +05304094 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304095 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
4096 uint8_t *buf_ptr;
4097 wmi_buf_t buf;
4098 int32_t len;
4099
4100 len = sizeof(*cmd);
4101 buf = wmi_buf_alloc(wmi_handle, len);
4102 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304103 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304104 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304105 }
4106 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4107
4108 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304109 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304110 WMITLV_SET_HDR(&cmd->tlv_header,
4111 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
4112 WMITLV_GET_STRUCT_TLVLEN(
4113 wmi_ocb_get_tsf_timer_cmd_fixed_param));
4114 cmd->vdev_id = vdev_id;
4115
4116 /* Send the WMI command */
4117 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4118 WMI_OCB_GET_TSF_TIMER_CMDID);
4119 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304120 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304121 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304122 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304123 }
4124
Govind Singh67922e82016-04-01 16:48:57 +05304125 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304126}
4127
4128/**
4129 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
4130 * @wmi_handle: pointer to the wmi handle
4131 * @get_stats_param: pointer to the dcc stats
4132 *
4133 * Return: 0 on succes
4134 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304135static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004136 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304137{
Govind Singh67922e82016-04-01 16:48:57 +05304138 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304139 wmi_dcc_get_stats_cmd_fixed_param *cmd;
4140 wmi_dcc_channel_stats_request *channel_stats_array;
4141 wmi_buf_t buf;
4142 uint8_t *buf_ptr;
4143 uint32_t len;
4144 uint32_t i;
4145
4146 /* Validate the input */
4147 if (get_stats_param->request_array_len !=
4148 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304149 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304150 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304151 }
4152
4153 /* Allocate memory for the WMI command */
4154 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4155 get_stats_param->request_array_len;
4156
4157 buf = wmi_buf_alloc(wmi_handle, len);
4158 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304159 WMI_LOGE(FL("wmi_buf_alloc failed"));
4160 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304161 }
4162
4163 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304164 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304165
4166 /* Populate the WMI command */
4167 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4168 buf_ptr += sizeof(*cmd);
4169
4170 WMITLV_SET_HDR(&cmd->tlv_header,
4171 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4172 WMITLV_GET_STRUCT_TLVLEN(
4173 wmi_dcc_get_stats_cmd_fixed_param));
4174 cmd->vdev_id = get_stats_param->vdev_id;
4175 cmd->num_channels = get_stats_param->channel_count;
4176
4177 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4178 get_stats_param->request_array_len);
4179 buf_ptr += WMI_TLV_HDR_SIZE;
4180
4181 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304182 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304183 get_stats_param->request_array_len);
4184 for (i = 0; i < cmd->num_channels; i++)
4185 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4186 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4187 WMITLV_GET_STRUCT_TLVLEN(
4188 wmi_dcc_channel_stats_request));
4189
4190 /* Send the WMI command */
4191 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4192 WMI_DCC_GET_STATS_CMDID);
4193
Govind Singh67922e82016-04-01 16:48:57 +05304194 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304195 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304196 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304197 }
4198
Govind Singh67922e82016-04-01 16:48:57 +05304199 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304200}
4201
4202/**
4203 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4204 * @wmi_handle: pointer to the wmi handle
4205 * @vdev_id: vdev id
4206 * @dcc_stats_bitmap: dcc status bitmap
4207 *
4208 * Return: 0 on succes
4209 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304210static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304211 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4212{
Govind Singh67922e82016-04-01 16:48:57 +05304213 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304214 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4215 wmi_buf_t buf;
4216 uint8_t *buf_ptr;
4217 uint32_t len;
4218
4219 /* Allocate memory for the WMI command */
4220 len = sizeof(*cmd);
4221
4222 buf = wmi_buf_alloc(wmi_handle, len);
4223 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304224 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304225 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304226 }
4227
4228 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304229 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304230
4231 /* Populate the WMI command */
4232 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4233
4234 WMITLV_SET_HDR(&cmd->tlv_header,
4235 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4236 WMITLV_GET_STRUCT_TLVLEN(
4237 wmi_dcc_clear_stats_cmd_fixed_param));
4238 cmd->vdev_id = vdev_id;
4239 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4240
4241 /* Send the WMI command */
4242 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4243 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304244 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304245 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304246 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304247 }
4248
Govind Singh67922e82016-04-01 16:48:57 +05304249 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304250}
4251
4252/**
4253 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4254 * @wmi_handle: pointer to the wmi handle
4255 * @update_ndl_param: pointer to the request parameters
4256 *
4257 * Return: 0 on success
4258 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304259static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004260 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304261{
Govind Singhb53420c2016-03-09 14:32:57 +05304262 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304263 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4264 wmi_dcc_ndl_chan *ndl_chan_array;
4265 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4266 uint32_t active_state_count;
4267 wmi_buf_t buf;
4268 uint8_t *buf_ptr;
4269 uint32_t len;
4270 uint32_t i;
4271
4272 /* validate the input */
4273 if (update_ndl_param->dcc_ndl_chan_list_len !=
4274 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304275 WMI_LOGE(FL("Invalid parameter"));
4276 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304277 }
4278 active_state_count = 0;
4279 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4280 for (i = 0; i < update_ndl_param->channel_count; i++)
4281 active_state_count +=
4282 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4283 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4284 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304285 WMI_LOGE(FL("Invalid parameter"));
4286 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304287 }
4288
4289 /* Allocate memory for the WMI command */
4290 len = sizeof(*cmd) +
4291 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4292 WMI_TLV_HDR_SIZE +
4293 update_ndl_param->dcc_ndl_active_state_list_len;
4294
4295 buf = wmi_buf_alloc(wmi_handle, len);
4296 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304297 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304298 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304299 }
4300
4301 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304302 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304303
4304 /* Populate the WMI command */
4305 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4306 buf_ptr += sizeof(*cmd);
4307
4308 WMITLV_SET_HDR(&cmd->tlv_header,
4309 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4310 WMITLV_GET_STRUCT_TLVLEN(
4311 wmi_dcc_update_ndl_cmd_fixed_param));
4312 cmd->vdev_id = update_ndl_param->vdev_id;
4313 cmd->num_channel = update_ndl_param->channel_count;
4314
4315 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4316 update_ndl_param->dcc_ndl_chan_list_len);
4317 buf_ptr += WMI_TLV_HDR_SIZE;
4318
4319 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304320 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304321 update_ndl_param->dcc_ndl_chan_list_len);
4322 for (i = 0; i < cmd->num_channel; i++)
4323 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4324 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4325 WMITLV_GET_STRUCT_TLVLEN(
4326 wmi_dcc_ndl_chan));
4327 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4328
4329 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4330 update_ndl_param->dcc_ndl_active_state_list_len);
4331 buf_ptr += WMI_TLV_HDR_SIZE;
4332
4333 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304334 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304335 update_ndl_param->dcc_ndl_active_state_list,
4336 update_ndl_param->dcc_ndl_active_state_list_len);
4337 for (i = 0; i < active_state_count; i++) {
4338 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4339 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4340 WMITLV_GET_STRUCT_TLVLEN(
4341 wmi_dcc_ndl_active_state_config));
4342 }
4343 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4344
4345 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304346 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304347 WMI_DCC_UPDATE_NDL_CMDID);
4348 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304349 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304350 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304351 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304352 }
4353
Govind Singh67922e82016-04-01 16:48:57 +05304354 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304355}
4356
4357/**
4358 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4359 * @wmi_handle: pointer to the wmi handle
4360 * @config: the OCB configuration
4361 *
4362 * Return: 0 on success
4363 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304364static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004365 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304366{
Govind Singh67922e82016-04-01 16:48:57 +05304367 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304368 wmi_ocb_set_config_cmd_fixed_param *cmd;
4369 wmi_channel *chan;
4370 wmi_ocb_channel *ocb_chan;
4371 wmi_qos_parameter *qos_param;
4372 wmi_dcc_ndl_chan *ndl_chan;
4373 wmi_dcc_ndl_active_state_config *ndl_active_config;
4374 wmi_ocb_schedule_element *sched_elem;
4375 uint8_t *buf_ptr;
4376 wmi_buf_t buf;
4377 int32_t len;
4378 int32_t i, j, active_state_count;
4379
4380 /*
4381 * Validate the dcc_ndl_chan_list_len and count the number of active
4382 * states. Validate dcc_ndl_active_state_list_len.
4383 */
4384 active_state_count = 0;
4385 if (config->dcc_ndl_chan_list_len) {
4386 if (!config->dcc_ndl_chan_list ||
4387 config->dcc_ndl_chan_list_len !=
4388 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304389 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304390 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304391 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304392 }
4393
4394 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4395 i < config->channel_count; ++i, ++ndl_chan)
4396 active_state_count +=
4397 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4398
4399 if (active_state_count) {
4400 if (!config->dcc_ndl_active_state_list ||
4401 config->dcc_ndl_active_state_list_len !=
4402 active_state_count *
4403 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304404 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304405 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304406 }
4407 }
4408 }
4409
4410 len = sizeof(*cmd) +
4411 WMI_TLV_HDR_SIZE + config->channel_count *
4412 sizeof(wmi_channel) +
4413 WMI_TLV_HDR_SIZE + config->channel_count *
4414 sizeof(wmi_ocb_channel) +
4415 WMI_TLV_HDR_SIZE + config->channel_count *
4416 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4417 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4418 WMI_TLV_HDR_SIZE + active_state_count *
4419 sizeof(wmi_dcc_ndl_active_state_config) +
4420 WMI_TLV_HDR_SIZE + config->schedule_size *
4421 sizeof(wmi_ocb_schedule_element);
4422 buf = wmi_buf_alloc(wmi_handle, len);
4423 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304424 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304425 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304426 }
4427
4428 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4429 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4430 WMITLV_SET_HDR(&cmd->tlv_header,
4431 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4432 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004433 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304434 cmd->channel_count = config->channel_count;
4435 cmd->schedule_size = config->schedule_size;
4436 cmd->flags = config->flags;
4437 buf_ptr += sizeof(*cmd);
4438
4439 /* Add the wmi_channel info */
4440 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4441 config->channel_count*sizeof(wmi_channel));
4442 buf_ptr += WMI_TLV_HDR_SIZE;
4443 for (i = 0; i < config->channel_count; i++) {
4444 chan = (wmi_channel *)buf_ptr;
4445 WMITLV_SET_HDR(&chan->tlv_header,
4446 WMITLV_TAG_STRUC_wmi_channel,
4447 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4448 chan->mhz = config->channels[i].chan_freq;
4449 chan->band_center_freq1 = config->channels[i].chan_freq;
4450 chan->band_center_freq2 = 0;
4451 chan->info = 0;
4452
Zhang Qian11c0de32018-01-05 16:50:53 +08004453 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304454 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4455 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4456 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4457 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4458 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4459 config->channels[i].antenna_max);
4460
4461 if (config->channels[i].bandwidth < 10)
4462 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4463 else if (config->channels[i].bandwidth < 20)
4464 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4465 buf_ptr += sizeof(*chan);
4466 }
4467
4468 /* Add the wmi_ocb_channel info */
4469 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4470 config->channel_count*sizeof(wmi_ocb_channel));
4471 buf_ptr += WMI_TLV_HDR_SIZE;
4472 for (i = 0; i < config->channel_count; i++) {
4473 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4474 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4475 WMITLV_TAG_STRUC_wmi_ocb_channel,
4476 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4477 ocb_chan->bandwidth = config->channels[i].bandwidth;
4478 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4479 config->channels[i].mac_address.bytes,
4480 &ocb_chan->mac_address);
4481 buf_ptr += sizeof(*ocb_chan);
4482 }
4483
4484 /* Add the wmi_qos_parameter info */
4485 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4486 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4487 buf_ptr += WMI_TLV_HDR_SIZE;
4488 /* WMI_MAX_NUM_AC parameters for each channel */
4489 for (i = 0; i < config->channel_count; i++) {
4490 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4491 qos_param = (wmi_qos_parameter *)buf_ptr;
4492 WMITLV_SET_HDR(&qos_param->tlv_header,
4493 WMITLV_TAG_STRUC_wmi_qos_parameter,
4494 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4495 qos_param->aifsn =
4496 config->channels[i].qos_params[j].aifsn;
4497 qos_param->cwmin =
4498 config->channels[i].qos_params[j].cwmin;
4499 qos_param->cwmax =
4500 config->channels[i].qos_params[j].cwmax;
4501 buf_ptr += sizeof(*qos_param);
4502 }
4503 }
4504
4505 /* Add the wmi_dcc_ndl_chan (per channel) */
4506 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4507 config->dcc_ndl_chan_list_len);
4508 buf_ptr += WMI_TLV_HDR_SIZE;
4509 if (config->dcc_ndl_chan_list_len) {
4510 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304511 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304512 config->dcc_ndl_chan_list_len);
4513 for (i = 0; i < config->channel_count; i++)
4514 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4515 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4516 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4517 buf_ptr += config->dcc_ndl_chan_list_len;
4518 }
4519
4520 /* Add the wmi_dcc_ndl_active_state_config */
4521 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4522 sizeof(wmi_dcc_ndl_active_state_config));
4523 buf_ptr += WMI_TLV_HDR_SIZE;
4524 if (active_state_count) {
4525 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304526 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304527 config->dcc_ndl_active_state_list,
4528 active_state_count * sizeof(*ndl_active_config));
4529 for (i = 0; i < active_state_count; ++i)
4530 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4531 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4532 WMITLV_GET_STRUCT_TLVLEN(
4533 wmi_dcc_ndl_active_state_config));
4534 buf_ptr += active_state_count *
4535 sizeof(*ndl_active_config);
4536 }
4537
4538 /* Add the wmi_ocb_schedule_element info */
4539 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4540 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4541 buf_ptr += WMI_TLV_HDR_SIZE;
4542 for (i = 0; i < config->schedule_size; i++) {
4543 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4544 WMITLV_SET_HDR(&sched_elem->tlv_header,
4545 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4546 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4547 sched_elem->channel_freq = config->schedule[i].chan_freq;
4548 sched_elem->total_duration = config->schedule[i].total_duration;
4549 sched_elem->guard_interval = config->schedule[i].guard_interval;
4550 buf_ptr += sizeof(*sched_elem);
4551 }
4552
4553
4554 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4555 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304556 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304557 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304558 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304559 }
4560
Govind Singh67922e82016-04-01 16:48:57 +05304561 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304562}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304563
4564/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004565 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4566 * @wmi_handle: wmi handle
4567 * @evt_buf: wmi event buffer
4568 * @status: status buffer
4569 *
4570 * Return: QDF_STATUS_SUCCESS on success
4571 */
4572static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4573 void *evt_buf,
4574 uint32_t *status)
4575{
4576 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4577 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4578
4579 param_tlvs = evt_buf;
4580 fix_param = param_tlvs->fixed_param;
4581
4582 *status = fix_param->status;
4583 return QDF_STATUS_SUCCESS;
4584}
4585
4586/**
4587 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4588 * @wmi_handle: wmi handle
4589 * @evt_buf: wmi event buffer
4590 * @resp: response buffer
4591 *
4592 * Return: QDF_STATUS_SUCCESS on success
4593 */
4594static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4595 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4596{
4597 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4598 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4599
4600 param_tlvs = evt_buf;
4601 fix_param = param_tlvs->fixed_param;
4602 resp->vdev_id = fix_param->vdev_id;
4603 resp->timer_high = fix_param->tsf_timer_high;
4604 resp->timer_low = fix_param->tsf_timer_low;
4605
4606 return QDF_STATUS_SUCCESS;
4607}
4608
4609/**
4610 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4611 * @wmi_handle: wmi handle
4612 * @evt_buf: wmi event buffer
4613 * @resp: response buffer
4614 *
4615 * Return: QDF_STATUS_SUCCESS on success
4616 */
4617static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4618 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4619{
4620 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4621 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4622
4623 param_tlvs = evt_buf;
4624 fix_param = param_tlvs->fixed_param;
4625 resp->vdev_id = fix_param->vdev_id;
4626 resp->status = fix_param->status;
4627 return QDF_STATUS_SUCCESS;
4628}
4629
4630/**
4631 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4632 * @wmi_handle: wmi handle
4633 * @evt_buf: wmi event buffer
4634 * @resp: response buffer
4635 *
4636 * Since length of stats is variable, buffer for DCC stats will be allocated
4637 * in this function. The caller must free the buffer.
4638 *
4639 * Return: QDF_STATUS_SUCCESS on success
4640 */
4641static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4642 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4643{
4644 struct ocb_dcc_get_stats_response *response;
4645 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4646 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4647
4648 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4649 fix_param = param_tlvs->fixed_param;
4650
4651 /* Allocate and populate the response */
4652 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4653 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4654 WMI_LOGE("%s: too many channels:%d", __func__,
4655 fix_param->num_channels);
4656 QDF_ASSERT(0);
4657 *resp = NULL;
4658 return QDF_STATUS_E_INVAL;
4659 }
4660 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4661 sizeof(wmi_dcc_ndl_stats_per_channel));
4662 *resp = response;
4663 if (!response)
4664 return QDF_STATUS_E_NOMEM;
4665
4666 response->vdev_id = fix_param->vdev_id;
4667 response->num_channels = fix_param->num_channels;
4668 response->channel_stats_array_len =
4669 fix_param->num_channels *
4670 sizeof(wmi_dcc_ndl_stats_per_channel);
4671 response->channel_stats_array = ((uint8_t *)response) +
4672 sizeof(*response);
4673 qdf_mem_copy(response->channel_stats_array,
4674 param_tlvs->stats_per_channel_list,
4675 response->channel_stats_array_len);
4676
4677 return QDF_STATUS_SUCCESS;
4678}
4679#endif
4680
4681/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304682 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4683 * @wmi_handle: wmi handle
4684 * @mcc_adaptive_scheduler: enable/disable
4685 *
4686 * This function enable/disable mcc adaptive scheduler in fw.
4687 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -07004688 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304689 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304690static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004691 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4692 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304693{
Govind Singh67922e82016-04-01 16:48:57 +05304694 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304695 wmi_buf_t buf = 0;
4696 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4697 uint16_t len =
4698 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4699
4700 buf = wmi_buf_alloc(wmi_handle, len);
4701 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304702 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4703 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304704 }
4705 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4706 wmi_buf_data(buf);
4707
4708 WMITLV_SET_HDR(&cmd->tlv_header,
4709 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4710 WMITLV_GET_STRUCT_TLVLEN
4711 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4712 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304713 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304714
4715 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4716 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304717 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304718 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304719 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304720 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304721 }
Govind Singh67922e82016-04-01 16:48:57 +05304722
4723 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304724}
4725
4726/**
4727 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4728 * @wmi: wmi handle
4729 * @mcc_channel: mcc channel
4730 * @mcc_channel_time_latency: MCC channel time latency.
4731 *
4732 * Currently used to set time latency for an MCC vdev/adapter using operating
4733 * channel of it and channel number. The info is provided run time using
4734 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4735 *
4736 * Return: CDF status
4737 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304738static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304739 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4740{
Govind Singh67922e82016-04-01 16:48:57 +05304741 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304742 wmi_buf_t buf = 0;
4743 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4744 uint16_t len = 0;
4745 uint8_t *buf_ptr = NULL;
4746 wmi_resmgr_chan_latency chan_latency;
4747 /* Note: we only support MCC time latency for a single channel */
4748 uint32_t num_channels = 1;
4749 uint32_t chan1_freq = mcc_channel_freq;
4750 uint32_t latency_chan1 = mcc_channel_time_latency;
4751
4752
4753 /* If 0ms latency is provided, then FW will set to a default.
4754 * Otherwise, latency must be at least 30ms.
4755 */
4756 if ((latency_chan1 > 0) &&
4757 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304758 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304759 "Minimum is 30ms (or 0 to use default value by "
4760 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304761 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304762 }
4763
4764 /* Set WMI CMD for channel time latency here */
4765 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4766 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4767 num_channels * sizeof(wmi_resmgr_chan_latency);
4768 buf = wmi_buf_alloc(wmi_handle, len);
4769 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304770 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4771 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304772 }
4773 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4774 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4775 wmi_buf_data(buf);
4776 WMITLV_SET_HDR(&cmdTL->tlv_header,
4777 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4778 WMITLV_GET_STRUCT_TLVLEN
4779 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4780 cmdTL->num_chans = num_channels;
4781 /* Update channel time latency information for home channel(s) */
4782 buf_ptr += sizeof(*cmdTL);
4783 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4784 num_channels * sizeof(wmi_resmgr_chan_latency));
4785 buf_ptr += WMI_TLV_HDR_SIZE;
4786 chan_latency.chan_mhz = chan1_freq;
4787 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304788 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304789 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4790 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304791 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304792 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304793 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304794 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304795 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304796 }
Govind Singh67922e82016-04-01 16:48:57 +05304797
4798 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304799}
4800
4801/**
4802 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4803 * @wmi: wmi handle
4804 * @adapter_1_chan_number: adapter 1 channel number
4805 * @adapter_1_quota: adapter 1 quota
4806 * @adapter_2_chan_number: adapter 2 channel number
4807 *
4808 * Return: CDF status
4809 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304810static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304811 uint32_t adapter_1_chan_freq,
4812 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4813{
Govind Singh67922e82016-04-01 16:48:57 +05304814 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304815 wmi_buf_t buf = 0;
4816 uint16_t len = 0;
4817 uint8_t *buf_ptr = NULL;
4818 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4819 wmi_resmgr_chan_time_quota chan_quota;
4820 uint32_t quota_chan1 = adapter_1_quota;
4821 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4822 uint32_t quota_chan2 = 100 - quota_chan1;
4823 /* Note: setting time quota for MCC requires info for 2 channels */
4824 uint32_t num_channels = 2;
4825 uint32_t chan1_freq = adapter_1_chan_freq;
4826 uint32_t chan2_freq = adapter_2_chan_freq;
4827
Govind Singhb53420c2016-03-09 14:32:57 +05304828 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304829 "freq2:%dMHz, Quota2:%dms", __func__,
4830 chan1_freq, quota_chan1, chan2_freq,
4831 quota_chan2);
4832
4833 /*
4834 * Perform sanity check on time quota values provided.
4835 */
4836 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4837 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304838 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304839 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304840 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304841 }
4842 /* Set WMI CMD for channel time quota here */
4843 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4844 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4845 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4846 buf = wmi_buf_alloc(wmi_handle, len);
4847 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304848 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4849 QDF_ASSERT(0);
4850 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304851 }
4852 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4853 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4854 wmi_buf_data(buf);
4855 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4856 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4857 WMITLV_GET_STRUCT_TLVLEN
4858 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4859 cmdTQ->num_chans = num_channels;
4860
4861 /* Update channel time quota information for home channel(s) */
4862 buf_ptr += sizeof(*cmdTQ);
4863 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4864 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4865 buf_ptr += WMI_TLV_HDR_SIZE;
4866 chan_quota.chan_mhz = chan1_freq;
4867 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304868 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304869 /* Construct channel and quota record for the 2nd MCC mode. */
4870 buf_ptr += sizeof(chan_quota);
4871 chan_quota.chan_mhz = chan2_freq;
4872 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304873 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304874
4875 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4876 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304877 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304878 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304879 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304880 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304881 }
Govind Singh67922e82016-04-01 16:48:57 +05304882
4883 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304884}
4885
4886/**
4887 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4888 * @wmi_handle: Pointer to wmi handle
4889 * @thermal_info: Thermal command information
4890 *
4891 * This function sends the thermal management command
4892 * to the firmware
4893 *
Govind Singhb53420c2016-03-09 14:32:57 +05304894 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304895 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304896static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304897 struct thermal_cmd_params *thermal_info)
4898{
4899 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4900 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304901 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304902 uint32_t len = 0;
4903
4904 len = sizeof(*cmd);
4905
4906 buf = wmi_buf_alloc(wmi_handle, len);
4907 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304908 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4909 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304910 }
4911
4912 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4913
4914 WMITLV_SET_HDR(&cmd->tlv_header,
4915 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4916 WMITLV_GET_STRUCT_TLVLEN
4917 (wmi_thermal_mgmt_cmd_fixed_param));
4918
4919 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4920 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4921 cmd->enable = thermal_info->thermal_enable;
4922
Govind Singhb53420c2016-03-09 14:32:57 +05304923 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304924 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4925
4926 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4927 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304928 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304929 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304930 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304931 }
4932
Govind Singh67922e82016-04-01 16:48:57 +05304933 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304934}
4935
4936
4937/**
4938 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304939 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304940 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4941 *
4942 * This function sends down the LRO configuration parameters to
4943 * the firmware to enable LRO, sets the TCP flags and sets the
4944 * seed values for the toeplitz hash generation
4945 *
Govind Singhb53420c2016-03-09 14:32:57 +05304946 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304947 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304948static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304949 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4950{
4951 wmi_lro_info_cmd_fixed_param *cmd;
4952 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304953 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304954
4955
4956 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4957 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304958 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4959 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304960 }
4961
4962 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4963
4964 WMITLV_SET_HDR(&cmd->tlv_header,
4965 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4966 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4967
4968 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4969 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4970 wmi_lro_cmd->tcp_flag);
4971 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4972 wmi_lro_cmd->tcp_flag_mask);
4973 cmd->toeplitz_hash_ipv4_0_3 =
4974 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4975 cmd->toeplitz_hash_ipv4_4_7 =
4976 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4977 cmd->toeplitz_hash_ipv4_8_11 =
4978 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4979 cmd->toeplitz_hash_ipv4_12_15 =
4980 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4981 cmd->toeplitz_hash_ipv4_16 =
4982 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4983
4984 cmd->toeplitz_hash_ipv6_0_3 =
4985 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4986 cmd->toeplitz_hash_ipv6_4_7 =
4987 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4988 cmd->toeplitz_hash_ipv6_8_11 =
4989 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4990 cmd->toeplitz_hash_ipv6_12_15 =
4991 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4992 cmd->toeplitz_hash_ipv6_16_19 =
4993 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4994 cmd->toeplitz_hash_ipv6_20_23 =
4995 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4996 cmd->toeplitz_hash_ipv6_24_27 =
4997 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4998 cmd->toeplitz_hash_ipv6_28_31 =
4999 wmi_lro_cmd->toeplitz_hash_ipv6[7];
5000 cmd->toeplitz_hash_ipv6_32_35 =
5001 wmi_lro_cmd->toeplitz_hash_ipv6[8];
5002 cmd->toeplitz_hash_ipv6_36_39 =
5003 wmi_lro_cmd->toeplitz_hash_ipv6[9];
5004 cmd->toeplitz_hash_ipv6_40 =
5005 wmi_lro_cmd->toeplitz_hash_ipv6[10];
5006
Govind Singhb53420c2016-03-09 14:32:57 +05305007 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05305008 cmd->lro_enable, cmd->tcp_flag_u32);
5009
5010 status = wmi_unified_cmd_send(wmi_handle, buf,
5011 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305012 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305013 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305014 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305015 }
5016
Govind Singh67922e82016-04-01 16:48:57 +05305017 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305018}
5019
Govind Singh4eacd2b2016-03-07 14:24:22 +05305020/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305021 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
5022 * @wmi_handle: Pointer to wmi handle
5023 * @rate_report_params: Pointer to peer rate report parameters
5024 *
5025 *
5026 * Return: QDF_STATUS_SUCCESS for success otherwise failure
5027 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305028static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305029 struct wmi_peer_rate_report_params *rate_report_params)
5030{
5031 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
5032 wmi_buf_t buf = NULL;
5033 QDF_STATUS status = 0;
5034 uint32_t len = 0;
5035 uint32_t i, j;
5036
5037 len = sizeof(*cmd);
5038
5039 buf = wmi_buf_alloc(wmi_handle, len);
5040 if (!buf) {
5041 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
5042 return QDF_STATUS_E_FAILURE;
5043 }
5044
5045 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
5046 wmi_buf_data(buf);
5047
5048 WMITLV_SET_HDR(
5049 &cmd->tlv_header,
5050 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
5051 WMITLV_GET_STRUCT_TLVLEN(
5052 wmi_peer_set_rate_report_condition_fixed_param));
5053
5054 cmd->enable_rate_report = rate_report_params->rate_report_enable;
5055 cmd->report_backoff_time = rate_report_params->backoff_time;
5056 cmd->report_timer_period = rate_report_params->timer_period;
5057 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
5058 cmd->cond_per_phy[i].val_cond_flags =
5059 rate_report_params->report_per_phy[i].cond_flags;
5060 cmd->cond_per_phy[i].rate_delta.min_delta =
5061 rate_report_params->report_per_phy[i].delta.delta_min;
5062 cmd->cond_per_phy[i].rate_delta.percentage =
5063 rate_report_params->report_per_phy[i].delta.percent;
5064 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
5065 cmd->cond_per_phy[i].rate_threshold[j] =
5066 rate_report_params->report_per_phy[i].
5067 report_rate_threshold[j];
5068 }
5069 }
5070
5071 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
5072 cmd->enable_rate_report,
5073 cmd->report_backoff_time, cmd->report_timer_period);
5074
5075 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5076 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
5077 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305078 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305079 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
5080 __func__);
5081 }
5082 return status;
5083}
5084
5085/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05305086 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
5087 * @wmi_handle: wmi handle
5088 * @param: bcn ll cmd parameter
5089 *
Govind Singhb53420c2016-03-09 14:32:57 +05305090 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305091 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305092static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305093 wmi_bcn_send_from_host_cmd_fixed_param *param)
5094{
5095 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
5096 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05305097 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305098
5099 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5100 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305101 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5102 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305103 }
5104
5105 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
5106 WMITLV_SET_HDR(&cmd->tlv_header,
5107 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
5108 WMITLV_GET_STRUCT_TLVLEN
5109 (wmi_bcn_send_from_host_cmd_fixed_param));
5110 cmd->vdev_id = param->vdev_id;
5111 cmd->data_len = param->data_len;
5112 cmd->frame_ctrl = param->frame_ctrl;
5113 cmd->frag_ptr = param->frag_ptr;
5114 cmd->dtim_flag = param->dtim_flag;
5115
5116 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
5117 WMI_PDEV_SEND_BCN_CMDID);
5118
Govind Singh67922e82016-04-01 16:48:57 +05305119 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305120 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305121 wmi_buf_free(wmi_buf);
5122 }
5123
5124 return ret;
5125}
5126
5127/**
5128 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
5129 * @wmi_handle: wmi handle
5130 * @vdev_id: vdev id
5131 * @max_retries: max retries
5132 * @retry_interval: retry interval
5133 * This function sets sta query related parameters in fw.
5134 *
Govind Singhb53420c2016-03-09 14:32:57 +05305135 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305136 */
5137
Sathish Kumarfd347372017-02-13 12:29:09 +05305138static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305139 uint8_t vdev_id, uint32_t max_retries,
5140 uint32_t retry_interval)
5141{
5142 wmi_buf_t buf;
5143 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5144 int len;
5145
5146 len = sizeof(*cmd);
5147 buf = wmi_buf_alloc(wmi_handle, len);
5148 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305149 WMI_LOGE(FL("wmi_buf_alloc failed"));
5150 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305151 }
5152
5153 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5154 WMITLV_SET_HDR(&cmd->tlv_header,
5155 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5156 WMITLV_GET_STRUCT_TLVLEN
5157 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5158
5159
5160 cmd->vdev_id = vdev_id;
5161 cmd->sa_query_max_retry_count = max_retries;
5162 cmd->sa_query_retry_interval = retry_interval;
5163
Govind Singhb53420c2016-03-09 14:32:57 +05305164 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305165 vdev_id, retry_interval, max_retries);
5166
5167 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5168 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305169 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305170 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305171 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305172 }
5173
Govind Singhb53420c2016-03-09 14:32:57 +05305174 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305175 return 0;
5176}
5177
5178/**
5179 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5180 * @wmi_handle: wmi handle
5181 * @params: sta keep alive parameter
5182 *
5183 * This function sets keep alive related parameters in fw.
5184 *
5185 * Return: CDF status
5186 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305187static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305188 struct sta_params *params)
5189{
5190 wmi_buf_t buf;
5191 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5192 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5193 uint8_t *buf_ptr;
5194 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305195 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305196
Govind Singhb53420c2016-03-09 14:32:57 +05305197 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305198
Govind Singh4eacd2b2016-03-07 14:24:22 +05305199 len = sizeof(*cmd) + sizeof(*arp_rsp);
5200 buf = wmi_buf_alloc(wmi_handle, len);
5201 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305202 WMI_LOGE("wmi_buf_alloc failed");
5203 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305204 }
5205
5206 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5207 buf_ptr = (uint8_t *) cmd;
5208 WMITLV_SET_HDR(&cmd->tlv_header,
5209 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5210 WMITLV_GET_STRUCT_TLVLEN
5211 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5212 cmd->interval = params->timeperiod;
5213 cmd->enable = (params->timeperiod) ? 1 : 0;
5214 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305215 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305216 params->timeperiod, params->method);
5217 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5218 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5219 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5220 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5221
c_manjee2772b9c2017-01-23 15:14:13 +05305222 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5223 (params->method ==
5224 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305225 if ((NULL == params->hostv4addr) ||
5226 (NULL == params->destv4addr) ||
5227 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005228 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5229 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305230 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305231 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305232 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305233 }
c_manjee2772b9c2017-01-23 15:14:13 +05305234 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305235 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305236 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305237 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305238 WMI_IPV4_ADDR_LEN);
5239 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5240 } else {
5241 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5242 }
5243
Govind Singh67922e82016-04-01 16:48:57 +05305244 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5245 WMI_STA_KEEPALIVE_CMDID);
5246 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305247 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305248 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305249 }
5250
Govind Singhb53420c2016-03-09 14:32:57 +05305251 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305252 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305253}
5254
5255/**
5256 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5257 * @wmi_handle: wmi handle
5258 * @if_id: vdev id
5259 * @gtx_info: GTX config params
5260 *
5261 * This function set GTX related params in firmware.
5262 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305263 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305264 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305265static 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 +05305266 struct wmi_gtx_config *gtx_info)
5267{
5268 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5269 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305270 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305271 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305272
Govind Singh4eacd2b2016-03-07 14:24:22 +05305273 buf = wmi_buf_alloc(wmi_handle, len);
5274 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305275 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305276 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305277 }
5278 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5279 WMITLV_SET_HDR(&cmd->tlv_header,
5280 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5281 WMITLV_GET_STRUCT_TLVLEN
5282 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5283 cmd->vdev_id = if_id;
5284
5285 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5286 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5287 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5288 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5289 cmd->gtxPERMargin = gtx_info->gtx_margin;
5290 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5291 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5292 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5293
Govind Singhb53420c2016-03-09 14:32:57 +05305294 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305295 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5296 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5297 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5298 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5299
Abhishek Singh716c46c2016-05-04 16:24:07 +05305300 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305301 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305302 if (QDF_IS_STATUS_ERROR(ret)) {
5303 WMI_LOGE("Failed to set GTX PARAMS");
5304 wmi_buf_free(buf);
5305 }
5306 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305307}
5308
5309/**
5310 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5311 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305312 * @vdev_id: vdev id.
5313 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305314 *
5315 * This function updates EDCA parameters to the target
5316 *
5317 * Return: CDF Status
5318 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305319static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005320 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305321 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305322{
5323 uint8_t *buf_ptr;
5324 wmi_buf_t buf;
5325 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305326 wmi_wmm_vparams *wmm_param;
5327 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305328 int len = sizeof(*cmd);
5329 int ac;
5330
5331 buf = wmi_buf_alloc(wmi_handle, len);
5332
5333 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305334 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5335 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305336 }
5337
5338 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5339 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5340 WMITLV_SET_HDR(&cmd->tlv_header,
5341 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5342 WMITLV_GET_STRUCT_TLVLEN
5343 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5344 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005345 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305346
5347 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5348 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305349 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305350 WMITLV_SET_HDR(&wmm_param->tlv_header,
5351 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5352 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5353 wmm_param->cwmin = twmm_param->cwmin;
5354 wmm_param->cwmax = twmm_param->cwmax;
5355 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005356 if (mu_edca_param)
5357 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5358 else
5359 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305360 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305361 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305362 }
5363
5364 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5365 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5366 goto fail;
5367
Govind Singhb53420c2016-03-09 14:32:57 +05305368 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305369
5370fail:
5371 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305372 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5373 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305374}
5375
5376/**
5377 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5378 * @wmi_handle: wmi handle
5379 * @vdev_id: vdev id
5380 * @probe_rsp_info: probe response info
5381 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305382 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305383 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305384static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305385 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005386 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305387{
5388 wmi_prb_tmpl_cmd_fixed_param *cmd;
5389 wmi_bcn_prb_info *bcn_prb_info;
5390 wmi_buf_t wmi_buf;
5391 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5392 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305393 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305394
Govind Singhb53420c2016-03-09 14:32:57 +05305395 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305396
Krunal Soni89426862017-11-14 15:42:48 -08005397 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305398 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305399
5400 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5401 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5402 tmpl_len_aligned;
5403
5404 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305405 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305406 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305407 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305408 }
5409
5410 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5411 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305412 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305413 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305414 }
5415
5416 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5417
5418 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5419 WMITLV_SET_HDR(&cmd->tlv_header,
5420 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5421 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5422 cmd->vdev_id = vdev_id;
5423 cmd->buf_len = tmpl_len;
5424 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5425
5426 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5427 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5428 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5429 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5430 bcn_prb_info->caps = 0;
5431 bcn_prb_info->erp = 0;
5432 buf_ptr += sizeof(wmi_bcn_prb_info);
5433
5434 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5435 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005436 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305437
5438 ret = wmi_unified_cmd_send(wmi_handle,
5439 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305440 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305441 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305442 wmi_buf_free(wmi_buf);
5443 }
5444
5445 return ret;
5446}
5447
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305448#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305449#define WPI_IV_LEN 16
5450
5451/**
5452 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5453 *
5454 * @dest_tx: destination address of tsc key counter
5455 * @src_tx: source address of tsc key counter
5456 * @dest_rx: destination address of rsc key counter
5457 * @src_rx: source address of rsc key counter
5458 *
5459 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5460 *
5461 * Return: None
5462 *
5463 */
5464static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5465 uint8_t *dest_rx, uint8_t *src_rx)
5466{
5467 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5468 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5469}
5470#else
5471static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5472 uint8_t *dest_rx, uint8_t *src_rx)
5473{
5474 return;
5475}
5476#endif
5477
5478/**
5479 * send_setup_install_key_cmd_tlv() - set key parameters
5480 * @wmi_handle: wmi handle
5481 * @key_params: key parameters
5482 *
5483 * This function fills structure from information
5484 * passed in key_params.
5485 *
5486 * Return: QDF_STATUS_SUCCESS - success
5487 * QDF_STATUS_E_FAILURE - failure
5488 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5489 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305490static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305491 struct set_key_params *key_params)
5492{
5493 wmi_vdev_install_key_cmd_fixed_param *cmd;
5494 wmi_buf_t buf;
5495 uint8_t *buf_ptr;
5496 uint32_t len;
5497 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305498 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305499
5500 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5501 WMI_TLV_HDR_SIZE;
5502
5503 buf = wmi_buf_alloc(wmi_handle, len);
5504 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305505 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305506 return QDF_STATUS_E_NOMEM;
5507 }
5508
5509 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5510 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5511 WMITLV_SET_HDR(&cmd->tlv_header,
5512 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5513 WMITLV_GET_STRUCT_TLVLEN
5514 (wmi_vdev_install_key_cmd_fixed_param));
5515 cmd->vdev_id = key_params->vdev_id;
5516 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305517
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305518
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305519 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5520 cmd->key_flags |= key_params->key_flags;
5521 cmd->key_cipher = key_params->key_cipher;
5522 if ((key_params->key_txmic_len) &&
5523 (key_params->key_rxmic_len)) {
5524 cmd->key_txmic_len = key_params->key_txmic_len;
5525 cmd->key_rxmic_len = key_params->key_rxmic_len;
5526 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305527#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305528 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5529 key_params->tx_iv,
5530 cmd->wpi_key_rsc_counter,
5531 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305532#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305533 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5534 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5535 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305536 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305537 qdf_mem_copy((void *)key_data,
5538 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005539 if (key_params->key_rsc_counter)
5540 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5541 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305542 cmd->key_len = key_params->key_len;
5543
5544 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5545 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305546 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305547 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305548
Govind Singh67922e82016-04-01 16:48:57 +05305549 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305550}
5551
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305552/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005553 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5554 * @wmi_handle: wmi handle
5555 * @params: sar limit params
5556 *
5557 * Return: QDF_STATUS_SUCCESS for success or error code
5558 */
5559static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5560 struct sar_limit_cmd_params *sar_limit_params)
5561{
5562 wmi_buf_t buf;
5563 QDF_STATUS qdf_status;
5564 wmi_sar_limits_cmd_fixed_param *cmd;
5565 int i;
5566 uint8_t *buf_ptr;
5567 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5568 struct sar_limit_cmd_row *sar_rows_list;
5569 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5570
5571 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5572 buf = wmi_buf_alloc(wmi_handle, len);
5573 if (!buf) {
5574 WMI_LOGE("Failed to allocate memory");
5575 qdf_status = QDF_STATUS_E_NOMEM;
5576 goto end;
5577 }
5578
5579 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5580 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5581 WMITLV_SET_HDR(&cmd->tlv_header,
5582 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5583 WMITLV_GET_STRUCT_TLVLEN
5584 (wmi_sar_limits_cmd_fixed_param));
5585 cmd->sar_enable = sar_limit_params->sar_enable;
5586 cmd->commit_limits = sar_limit_params->commit_limits;
5587 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5588
5589 WMI_LOGD("no of sar rows = %d, len = %d",
5590 sar_limit_params->num_limit_rows, len);
5591 buf_ptr += sizeof(*cmd);
5592 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5593 sizeof(wmi_sar_limit_cmd_row) *
5594 sar_limit_params->num_limit_rows);
5595 if (cmd->num_limit_rows == 0)
5596 goto send_sar_limits;
5597
5598 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5599 (buf_ptr + WMI_TLV_HDR_SIZE);
5600 sar_rows_list = sar_limit_params->sar_limit_row_list;
5601
5602 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5603 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5604 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5605 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5606 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5607 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5608 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5609 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5610 wmi_sar_rows_list->validity_bitmap =
5611 sar_rows_list->validity_bitmap;
5612 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5613 i, wmi_sar_rows_list->band_id,
5614 wmi_sar_rows_list->chain_id,
5615 wmi_sar_rows_list->mod_id,
5616 wmi_sar_rows_list->limit_value,
5617 wmi_sar_rows_list->validity_bitmap);
5618 sar_rows_list++;
5619 wmi_sar_rows_list++;
5620 }
5621send_sar_limits:
5622 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5623 WMI_SAR_LIMITS_CMDID);
5624
5625 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5626 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5627 wmi_buf_free(buf);
5628 }
5629
5630end:
5631 return qdf_status;
5632}
5633
Jeff Johnson4783f902017-12-14 15:50:16 -08005634static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5635{
5636 wmi_sar_get_limits_cmd_fixed_param *cmd;
5637 wmi_buf_t wmi_buf;
5638 uint32_t len;
5639 QDF_STATUS status;
5640
5641 WMI_LOGD(FL("Enter"));
5642
5643 len = sizeof(*cmd);
5644 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5645 if (!wmi_buf) {
5646 WMI_LOGP(FL("failed to allocate memory for msg"));
5647 return QDF_STATUS_E_NOMEM;
5648 }
5649
5650 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5651
5652 WMITLV_SET_HDR(&cmd->tlv_header,
5653 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5654 WMITLV_GET_STRUCT_TLVLEN
5655 (wmi_sar_get_limits_cmd_fixed_param));
5656
5657 cmd->reserved = 0;
5658
5659 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5660 WMI_SAR_GET_LIMITS_CMDID);
5661 if (QDF_IS_STATUS_ERROR(status)) {
5662 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5663 wmi_buf_free(wmi_buf);
5664 }
5665
5666 WMI_LOGD(FL("Exit"));
5667
5668 return status;
5669}
5670
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07005671/**
5672 * wmi_sar2_result_string() - return string conversion of sar2 result
5673 * @result: sar2 result value
5674 *
5675 * This utility function helps log string conversion of sar2 result.
5676 *
5677 * Return: string conversion of sar 2 result, if match found;
5678 * "Unknown response" otherwise.
5679 */
5680static const char *wmi_sar2_result_string(uint32_t result)
5681{
5682 switch (result) {
5683 CASE_RETURN_STRING(WMI_SAR2_SUCCESS);
5684 CASE_RETURN_STRING(WMI_SAR2_INVALID_ANTENNA_INDEX);
5685 CASE_RETURN_STRING(WMI_SAR2_INVALID_TABLE_INDEX);
5686 CASE_RETURN_STRING(WMI_SAR2_STATE_ERROR);
5687 CASE_RETURN_STRING(WMI_SAR2_BDF_NO_TABLE);
5688 default:
5689 return "Unknown response";
5690 }
5691}
5692
5693/**
5694 * extract_sar2_result_event_tlv() - process sar response event from FW.
5695 * @handle: wma handle
5696 * @event: event buffer
5697 * @len: buffer length
5698 *
5699 * Return: 0 for success or error code
5700 */
5701static QDF_STATUS extract_sar2_result_event_tlv(void *handle,
5702 uint8_t *event,
5703 uint32_t len)
5704{
5705 wmi_sar2_result_event_fixed_param *sar2_fixed_param;
5706
5707 WMI_SAR2_RESULT_EVENTID_param_tlvs *param_buf =
5708 (WMI_SAR2_RESULT_EVENTID_param_tlvs *)event;
5709
5710 if (!param_buf) {
5711 WMI_LOGI("Invalid sar2 result event buffer");
5712 return QDF_STATUS_E_INVAL;
5713 }
5714
5715 sar2_fixed_param = param_buf->fixed_param;
5716 if (!sar2_fixed_param) {
5717 WMI_LOGI("Invalid sar2 result event fixed param buffer");
5718 return QDF_STATUS_E_INVAL;
5719 }
5720
5721 WMI_LOGI("SAR2 result: %s",
5722 wmi_sar2_result_string(sar2_fixed_param->result));
5723
5724 return QDF_STATUS_SUCCESS;
5725}
5726
Jeff Johnson4783f902017-12-14 15:50:16 -08005727static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5728 uint8_t *evt_buf,
5729 struct sar_limit_event *event)
5730{
5731 wmi_sar_get_limits_event_fixed_param *fixed_param;
5732 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5733 wmi_sar_get_limit_event_row *row_in;
5734 struct sar_limit_event_row *row_out;
5735 uint32_t row;
5736
5737 if (!evt_buf) {
5738 WMI_LOGE(FL("input event is NULL"));
5739 return QDF_STATUS_E_INVAL;
5740 }
5741 if (!event) {
5742 WMI_LOGE(FL("output event is NULL"));
5743 return QDF_STATUS_E_INVAL;
5744 }
5745
5746 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5747
5748 fixed_param = param_buf->fixed_param;
5749 if (!fixed_param) {
5750 WMI_LOGE(FL("Invalid fixed param"));
5751 return QDF_STATUS_E_INVAL;
5752 }
5753
5754 event->sar_enable = fixed_param->sar_enable;
5755 event->num_limit_rows = fixed_param->num_limit_rows;
5756
5757 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5758 QDF_ASSERT(0);
5759 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5760 event->num_limit_rows,
5761 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5762 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5763 }
5764
5765 row_in = param_buf->sar_get_limits;
5766 row_out = &event->sar_limit_row[0];
5767 for (row = 0; row < event->num_limit_rows; row++) {
5768 row_out->band_id = row_in->band_id;
5769 row_out->chain_id = row_in->chain_id;
5770 row_out->mod_id = row_in->mod_id;
5771 row_out->limit_value = row_in->limit_value;
5772 row_out++;
5773 row_in++;
5774 }
5775
5776 return QDF_STATUS_SUCCESS;
5777}
5778
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305779#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005780/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305781 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5782 * @wmi_handle: wmi handle
5783 * @params: encrypt/decrypt params
5784 *
5785 * Return: QDF_STATUS_SUCCESS for success or error code
5786 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005787static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305788QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305789 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305790{
5791 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5792 wmi_buf_t wmi_buf;
5793 uint8_t *buf_ptr;
5794 QDF_STATUS ret;
5795 uint32_t len;
5796
5797 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5798
5799 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305800 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305801 WMI_TLV_HDR_SIZE;
5802 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5803 if (!wmi_buf) {
5804 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5805 __func__);
5806 return QDF_STATUS_E_NOMEM;
5807 }
5808
5809 buf_ptr = wmi_buf_data(wmi_buf);
5810 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5811
5812 WMITLV_SET_HDR(&cmd->tlv_header,
5813 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5814 WMITLV_GET_STRUCT_TLVLEN(
5815 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5816
5817 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5818 cmd->key_flag = encrypt_decrypt_params->key_flag;
5819 cmd->key_idx = encrypt_decrypt_params->key_idx;
5820 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5821 cmd->key_len = encrypt_decrypt_params->key_len;
5822 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5823 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5824
5825 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5826 encrypt_decrypt_params->key_len);
5827
5828 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5829 MAX_MAC_HEADER_LEN);
5830
5831 cmd->data_len = encrypt_decrypt_params->data_len;
5832
5833 if (cmd->data_len) {
5834 buf_ptr += sizeof(*cmd);
5835 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5836 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305837 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305838 buf_ptr += WMI_TLV_HDR_SIZE;
5839 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5840 encrypt_decrypt_params->data_len);
5841 }
5842
5843 /* This conversion is to facilitate data to FW in little endian */
5844 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5845 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5846 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5847 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5848 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5849 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5850
5851 ret = wmi_unified_cmd_send(wmi_handle,
5852 wmi_buf, len,
5853 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5854 if (QDF_IS_STATUS_ERROR(ret)) {
5855 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5856 wmi_buf_free(wmi_buf);
5857 }
5858
5859 return ret;
5860}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305861
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305862/**
5863 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5864 * params from event
5865 * @wmi_handle: wmi handle
5866 * @evt_buf: pointer to event buffer
5867 * @resp: Pointer to hold resp parameters
5868 *
5869 * Return: QDF_STATUS_SUCCESS for success or error code
5870 */
5871static
5872QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5873 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5874{
5875 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5876 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5877
5878 param_buf = evt_buf;
5879 if (!param_buf) {
5880 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5881 return QDF_STATUS_E_INVAL;
5882 }
5883
5884 data_event = param_buf->fixed_param;
5885
5886 resp->vdev_id = data_event->vdev_id;
5887 resp->status = data_event->status;
5888
5889 if (data_event->data_length > param_buf->num_enc80211_frame) {
5890 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5891 data_event->data_length,
5892 param_buf->num_enc80211_frame);
5893 return QDF_STATUS_E_INVAL;
5894 }
5895
5896 resp->data_len = data_event->data_length;
5897
5898 if (resp->data_len)
5899 resp->data = (uint8_t *)param_buf->enc80211_frame;
5900
5901 return QDF_STATUS_SUCCESS;
5902}
5903#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305904
Govind Singh4eacd2b2016-03-07 14:24:22 +05305905/**
5906 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5907 * @wmi_handle: wmi handle
5908 * @vdev_id: vdev id
5909 * @p2p_ie: p2p IE
5910 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305911 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305912 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305913static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05305914 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305915{
Govind Singh67922e82016-04-01 16:48:57 +05305916 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305917 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5918 wmi_buf_t wmi_buf;
5919 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5920 uint8_t *buf_ptr;
5921
5922 ie_len = (uint32_t) (p2p_ie[1] + 2);
5923
5924 /* More than one P2P IE may be included in a single frame.
5925 If multiple P2P IEs are present, the complete P2P attribute
5926 data consists of the concatenation of the P2P Attribute
5927 fields of the P2P IEs. The P2P Attributes field of each
5928 P2P IE may be any length up to the maximum (251 octets).
5929 In this case host sends one P2P IE to firmware so the length
5930 should not exceed more than 251 bytes
5931 */
5932 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305933 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305934 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305935 }
5936
Vivekc5823092018-03-22 23:27:21 +05305937 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305938
5939 wmi_buf_len =
5940 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5941 WMI_TLV_HDR_SIZE;
5942
5943 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5944 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305945 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305946 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305947 }
5948
5949 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5950
5951 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5952 WMITLV_SET_HDR(&cmd->tlv_header,
5953 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5954 WMITLV_GET_STRUCT_TLVLEN
5955 (wmi_p2p_go_set_beacon_ie_fixed_param));
5956 cmd->vdev_id = vdev_id;
5957 cmd->ie_buf_len = ie_len;
5958
5959 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5960 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5961 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305962 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305963
Govind Singhb53420c2016-03-09 14:32:57 +05305964 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305965
5966 ret = wmi_unified_cmd_send(wmi_handle,
5967 wmi_buf, wmi_buf_len,
5968 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305969 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305970 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305971 wmi_buf_free(wmi_buf);
5972 }
5973
Govind Singhb53420c2016-03-09 14:32:57 +05305974 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305975 return ret;
5976}
5977
5978/**
5979 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5980 * @wmi_handle: wmi handle
5981 * @req: gateway parameter update request structure
5982 *
5983 * This function reads the incoming @req and fill in the destination
5984 * WMI structure and sends down the gateway configs down to the firmware
5985 *
Govind Singhb53420c2016-03-09 14:32:57 +05305986 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305987 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305988static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305989 struct gateway_update_req_param *req)
5990{
5991 wmi_roam_subnet_change_config_fixed_param *cmd;
5992 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305993 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305994 int len = sizeof(*cmd);
5995
5996 buf = wmi_buf_alloc(wmi_handle, len);
5997 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305998 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5999 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306000 }
6001
6002 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
6003 WMITLV_SET_HDR(&cmd->tlv_header,
6004 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
6005 WMITLV_GET_STRUCT_TLVLEN(
6006 wmi_roam_subnet_change_config_fixed_param));
6007
6008 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05306009 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
6010 QDF_IPV4_ADDR_SIZE);
6011 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
6012 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306013 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
6014 &cmd->inet_gw_mac_addr);
6015 cmd->max_retries = req->max_retries;
6016 cmd->timeout = req->timeout;
6017 cmd->num_skip_subnet_change_detection_bssid_list = 0;
6018 cmd->flag = 0;
6019 if (req->ipv4_addr_type)
6020 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
6021
6022 if (req->ipv6_addr_type)
6023 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
6024
6025 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6026 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306027 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306028 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306029 ret);
6030 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306031 }
6032
Govind Singh67922e82016-04-01 16:48:57 +05306033 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306034}
6035
6036/**
6037 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
6038 * @wmi_handle: wmi handle
6039 * @req: rssi monitoring request structure
6040 *
6041 * This function reads the incoming @req and fill in the destination
6042 * WMI structure and send down the rssi monitoring configs down to the firmware
6043 *
6044 * Return: 0 on success; error number otherwise
6045 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306046static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306047 struct rssi_monitor_param *req)
6048{
6049 wmi_rssi_breach_monitor_config_fixed_param *cmd;
6050 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05306051 QDF_STATUS ret;
6052 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306053
6054 buf = wmi_buf_alloc(wmi_handle, len);
6055 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306056 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6057 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306058 }
6059
6060 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
6061 WMITLV_SET_HDR(&cmd->tlv_header,
6062 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
6063 WMITLV_GET_STRUCT_TLVLEN(
6064 wmi_rssi_breach_monitor_config_fixed_param));
6065
6066 cmd->vdev_id = req->session_id;
6067 cmd->request_id = req->request_id;
6068 cmd->lo_rssi_reenable_hysteresis = 0;
6069 cmd->hi_rssi_reenable_histeresis = 0;
6070 cmd->min_report_interval = 0;
6071 cmd->max_num_report = 1;
6072 if (req->control) {
6073 /* enable one threshold for each min/max */
6074 cmd->enabled_bitmap = 0x09;
6075 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
6076 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
6077 } else {
6078 cmd->enabled_bitmap = 0;
6079 cmd->low_rssi_breach_threshold[0] = 0;
6080 cmd->hi_rssi_breach_threshold[0] = 0;
6081 }
6082
6083 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6084 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306085 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306086 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05306087 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306088 }
6089
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07006090 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
6091
Govind Singh67922e82016-04-01 16:48:57 +05306092 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306093}
6094
6095/**
6096 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
6097 * @wmi_handle: wmi handle
6098 * @psetoui: OUI parameters
6099 *
6100 * set scan probe OUI parameters in firmware
6101 *
6102 * Return: CDF status
6103 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306104static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306105 struct scan_mac_oui *psetoui)
6106{
6107 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
6108 wmi_buf_t wmi_buf;
6109 uint32_t len;
6110 uint8_t *buf_ptr;
6111 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306112 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306113
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306114 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
6115 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
6116
Govind Singh4eacd2b2016-03-07 14:24:22 +05306117 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6118 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306119 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6120 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306121 }
6122 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6123 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
6124 WMITLV_SET_HDR(&cmd->tlv_header,
6125 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
6126 WMITLV_GET_STRUCT_TLVLEN
6127 (wmi_scan_prob_req_oui_cmd_fixed_param));
6128
6129 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05306130 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05306131 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
6132 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05306133 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306134 cmd->prob_req_oui);
6135
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05306136 cmd->vdev_id = psetoui->vdev_id;
6137 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
6138 if (psetoui->enb_probe_req_sno_randomization)
6139 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
6140
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306141 if (ie_whitelist->white_list) {
6142 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
6143 &cmd->num_vendor_oui,
6144 ie_whitelist);
6145 cmd->flags |=
6146 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
6147 }
6148
6149 buf_ptr += sizeof(*cmd);
6150 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6151 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
6152 buf_ptr += WMI_TLV_HDR_SIZE;
6153
6154 if (cmd->num_vendor_oui != 0) {
6155 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
6156 ie_whitelist->voui);
6157 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
6158 }
6159
Govind Singh4eacd2b2016-03-07 14:24:22 +05306160 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6161 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306162 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306163 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306164 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306165 }
Govind Singhb53420c2016-03-09 14:32:57 +05306166 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306167}
6168
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306169#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306170/**
6171 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6172 * @wmi_handle: wmi handle
6173 * @roam_req: Roam scan offload params
6174 * @buf_ptr: command buffer to send
6175 * @fils_tlv_len: fils tlv length
6176 *
6177 * Return: Updated buffer pointer
6178 */
6179static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6180 struct roam_offload_scan_params *roam_req,
6181 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6182{
6183 wmi_roam_fils_offload_tlv_param *fils_tlv;
6184 wmi_erp_info *erp_info;
6185 struct roam_fils_params *roam_fils_params;
6186
6187 if (!roam_req->add_fils_tlv)
6188 return buf_ptr;
6189
6190 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6191 sizeof(*fils_tlv));
6192 buf_ptr += WMI_TLV_HDR_SIZE;
6193
6194 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6195 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6196 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6197 WMITLV_GET_STRUCT_TLVLEN
6198 (wmi_roam_fils_offload_tlv_param));
6199
6200 roam_fils_params = &roam_req->roam_fils_params;
6201 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6202
6203 erp_info->username_length = roam_fils_params->username_length;
6204 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6205 erp_info->username_length);
6206
6207 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6208
6209 erp_info->rRk_length = roam_fils_params->rrk_length;
6210 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6211 erp_info->rRk_length);
6212
6213 erp_info->rIk_length = roam_fils_params->rik_length;
6214 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6215 erp_info->rIk_length);
6216
6217 erp_info->realm_len = roam_fils_params->realm_len;
6218 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6219 erp_info->realm_len);
6220
6221 buf_ptr += sizeof(*fils_tlv);
6222 return buf_ptr;
6223}
6224#else
6225static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6226 struct roam_offload_scan_params *roam_req,
6227 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6228{
6229 return buf_ptr;
6230}
6231#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306232/**
6233 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6234 * @wmi_handle: wmi handle
6235 * @scan_cmd_fp: start scan command ptr
6236 * @roam_req: roam request param
6237 *
6238 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6239 * of WMI_ROAM_SCAN_MODE.
6240 *
6241 * Return: QDF status
6242 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306243static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306244 wmi_start_scan_cmd_fixed_param *
6245 scan_cmd_fp,
6246 struct roam_offload_scan_params *roam_req)
6247{
6248 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306249 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306250 int len;
6251 uint8_t *buf_ptr;
6252 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306253
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306254#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6255 int auth_mode = roam_req->auth_mode;
6256 wmi_roam_offload_tlv_param *roam_offload_params;
6257 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6258 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6259 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306260 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306261 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306262#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6263 /* Need to create a buf with roam_scan command at
6264 * front and piggyback with scan command */
6265 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6266#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6267 (2 * WMI_TLV_HDR_SIZE) +
6268#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6269 sizeof(wmi_start_scan_cmd_fixed_param);
6270#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006271 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306272 if (roam_req->is_roam_req_valid &&
6273 roam_req->roam_offload_enabled) {
6274 len += sizeof(wmi_roam_offload_tlv_param);
6275 len += WMI_TLV_HDR_SIZE;
6276 if ((auth_mode != WMI_AUTH_NONE) &&
6277 ((auth_mode != WMI_AUTH_OPEN) ||
6278 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306279 roam_req->mdid.mdie_present &&
6280 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306281 roam_req->is_ese_assoc)) {
6282 len += WMI_TLV_HDR_SIZE;
6283 if (roam_req->is_ese_assoc)
6284 len +=
6285 sizeof(wmi_roam_ese_offload_tlv_param);
6286 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6287 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6288 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306289 roam_req->mdid.mdie_present &&
6290 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306291 len +=
6292 sizeof(wmi_roam_11r_offload_tlv_param);
6293 else
6294 len +=
6295 sizeof(wmi_roam_11i_offload_tlv_param);
6296 } else {
6297 len += WMI_TLV_HDR_SIZE;
6298 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306299
6300 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6301 + roundup(roam_req->assoc_ie_length,
6302 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306303
6304 if (roam_req->add_fils_tlv) {
6305 fils_tlv_len = sizeof(
6306 wmi_roam_fils_offload_tlv_param);
6307 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6308 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306309 } else {
6310 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306311 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306312 __func__, roam_req->roam_offload_enabled);
6313 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306314 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306315 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306316 }
6317 if (roam_req->is_roam_req_valid &&
6318 roam_req->roam_offload_enabled) {
6319 roam_req->mode = roam_req->mode |
6320 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6321 }
6322#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6323
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306324 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6325 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6326 len = sizeof(wmi_roam_scan_mode_fixed_param);
6327
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306328 buf = wmi_buf_alloc(wmi_handle, len);
6329 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306330 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306331 return QDF_STATUS_E_NOMEM;
6332 }
6333
6334 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6335 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6336 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6337 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6338 WMITLV_GET_STRUCT_TLVLEN
6339 (wmi_roam_scan_mode_fixed_param));
6340
Abhinav Kumar334355f2018-04-06 17:18:52 +05306341 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6342 roam_req->roam_trigger_reason_bitmask;
6343 roam_scan_mode_fp->min_delay_btw_scans =
6344 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306345 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6346 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306347 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6348 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6349 roam_scan_mode_fp->flags |=
6350 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306351 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306352 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306353
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306354 /* Fill in scan parameters suitable for roaming scan */
6355 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306356
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306357 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6358 sizeof(wmi_start_scan_cmd_fixed_param));
6359 /* Ensure there is no additional IEs */
6360 scan_cmd_fp->ie_len = 0;
6361 WMITLV_SET_HDR(buf_ptr,
6362 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6363 WMITLV_GET_STRUCT_TLVLEN
6364 (wmi_start_scan_cmd_fixed_param));
6365#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6366 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6367 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6368 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6369 sizeof(wmi_roam_offload_tlv_param));
6370 buf_ptr += WMI_TLV_HDR_SIZE;
6371 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6372 WMITLV_SET_HDR(buf_ptr,
6373 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6374 WMITLV_GET_STRUCT_TLVLEN
6375 (wmi_roam_offload_tlv_param));
6376 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6377 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6378 roam_offload_params->select_5g_margin =
6379 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306380 roam_offload_params->handoff_delay_for_rx =
6381 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306382 roam_offload_params->reassoc_failure_timeout =
6383 roam_req->reassoc_failure_timeout;
6384
6385 /* Fill the capabilities */
6386 roam_offload_params->capability =
6387 roam_req->roam_offload_params.capability;
6388 roam_offload_params->ht_caps_info =
6389 roam_req->roam_offload_params.ht_caps_info;
6390 roam_offload_params->ampdu_param =
6391 roam_req->roam_offload_params.ampdu_param;
6392 roam_offload_params->ht_ext_cap =
6393 roam_req->roam_offload_params.ht_ext_cap;
6394 roam_offload_params->ht_txbf =
6395 roam_req->roam_offload_params.ht_txbf;
6396 roam_offload_params->asel_cap =
6397 roam_req->roam_offload_params.asel_cap;
6398 roam_offload_params->qos_caps =
6399 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006400 roam_offload_params->qos_enabled =
6401 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306402 roam_offload_params->wmm_caps =
6403 roam_req->roam_offload_params.wmm_caps;
6404 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6405 (uint8_t *)roam_req->roam_offload_params.mcsset,
6406 ROAM_OFFLOAD_NUM_MCS_SET);
6407
6408 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6409 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6410 * they are filled in the same order.Depending on the
6411 * authentication type, the other mode TLV's are nullified
6412 * and only headers are filled.*/
6413 if ((auth_mode != WMI_AUTH_NONE) &&
6414 ((auth_mode != WMI_AUTH_OPEN) ||
6415 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306416 && roam_req->mdid.mdie_present &&
6417 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306418 roam_req->is_ese_assoc)) {
6419 if (roam_req->is_ese_assoc) {
6420 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6421 WMITLV_GET_STRUCT_TLVLEN(0));
6422 buf_ptr += WMI_TLV_HDR_SIZE;
6423 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6424 WMITLV_GET_STRUCT_TLVLEN(0));
6425 buf_ptr += WMI_TLV_HDR_SIZE;
6426 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6427 sizeof(wmi_roam_ese_offload_tlv_param));
6428 buf_ptr += WMI_TLV_HDR_SIZE;
6429 roam_offload_ese =
6430 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6431 qdf_mem_copy(roam_offload_ese->krk,
6432 roam_req->krk,
6433 sizeof(roam_req->krk));
6434 qdf_mem_copy(roam_offload_ese->btk,
6435 roam_req->btk,
6436 sizeof(roam_req->btk));
6437 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6438 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6439 WMITLV_GET_STRUCT_TLVLEN
6440 (wmi_roam_ese_offload_tlv_param));
6441 buf_ptr +=
6442 sizeof(wmi_roam_ese_offload_tlv_param);
6443 } else if (auth_mode == WMI_AUTH_FT_RSNA
6444 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6445 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306446 && roam_req->mdid.mdie_present &&
6447 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306448 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6449 0);
6450 buf_ptr += WMI_TLV_HDR_SIZE;
6451 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6452 sizeof(wmi_roam_11r_offload_tlv_param));
6453 buf_ptr += WMI_TLV_HDR_SIZE;
6454 roam_offload_11r =
6455 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6456 roam_offload_11r->r0kh_id_len =
6457 roam_req->rokh_id_length;
6458 qdf_mem_copy(roam_offload_11r->r0kh_id,
6459 roam_req->rokh_id,
6460 roam_offload_11r->r0kh_id_len);
6461 qdf_mem_copy(roam_offload_11r->psk_msk,
6462 roam_req->psk_pmk,
6463 sizeof(roam_req->psk_pmk));
6464 roam_offload_11r->psk_msk_len =
6465 roam_req->pmk_len;
6466 roam_offload_11r->mdie_present =
6467 roam_req->mdid.mdie_present;
6468 roam_offload_11r->mdid =
6469 roam_req->mdid.mobility_domain;
6470 if (auth_mode == WMI_AUTH_OPEN) {
6471 /* If FT-Open ensure pmk length
6472 and r0khid len are zero */
6473 roam_offload_11r->r0kh_id_len = 0;
6474 roam_offload_11r->psk_msk_len = 0;
6475 }
6476 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6477 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6478 WMITLV_GET_STRUCT_TLVLEN
6479 (wmi_roam_11r_offload_tlv_param));
6480 buf_ptr +=
6481 sizeof(wmi_roam_11r_offload_tlv_param);
6482 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6483 WMITLV_GET_STRUCT_TLVLEN(0));
6484 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006485 WMI_LOGD("psk_msk_len = %d",
6486 roam_offload_11r->psk_msk_len);
6487 if (roam_offload_11r->psk_msk_len)
6488 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6489 QDF_TRACE_LEVEL_DEBUG,
6490 roam_offload_11r->psk_msk,
6491 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306492 } else {
6493 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6494 sizeof(wmi_roam_11i_offload_tlv_param));
6495 buf_ptr += WMI_TLV_HDR_SIZE;
6496 roam_offload_11i =
6497 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006498
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006499 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006500 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306501 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6502 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006503 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306504 } else {
6505 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6506 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006507 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006508 }
6509 if (roam_req->roam_key_mgmt_offload_enabled &&
6510 roam_req->fw_pmksa_cache) {
6511 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6512 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006513 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006514 } else {
6515 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6516 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006517 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306518 }
6519
6520 qdf_mem_copy(roam_offload_11i->pmk,
6521 roam_req->psk_pmk,
6522 sizeof(roam_req->psk_pmk));
6523 roam_offload_11i->pmk_len = roam_req->pmk_len;
6524 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6525 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6526 WMITLV_GET_STRUCT_TLVLEN
6527 (wmi_roam_11i_offload_tlv_param));
6528 buf_ptr +=
6529 sizeof(wmi_roam_11i_offload_tlv_param);
6530 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6531 0);
6532 buf_ptr += WMI_TLV_HDR_SIZE;
6533 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6534 0);
6535 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006536 WMI_LOGD("pmk_len = %d",
6537 roam_offload_11i->pmk_len);
6538 if (roam_offload_11i->pmk_len)
6539 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6540 QDF_TRACE_LEVEL_DEBUG,
6541 roam_offload_11i->pmk,
6542 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306543 }
6544 } else {
6545 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6546 WMITLV_GET_STRUCT_TLVLEN(0));
6547 buf_ptr += WMI_TLV_HDR_SIZE;
6548 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6549 WMITLV_GET_STRUCT_TLVLEN(0));
6550 buf_ptr += WMI_TLV_HDR_SIZE;
6551 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6552 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306553 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306554 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306555
6556 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6557 sizeof(*assoc_ies));
6558 buf_ptr += WMI_TLV_HDR_SIZE;
6559
6560 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6561 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6562 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6563 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6564 assoc_ies->buf_len = roam_req->assoc_ie_length;
6565
6566 buf_ptr += sizeof(*assoc_ies);
6567
6568 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6569 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6570 buf_ptr += WMI_TLV_HDR_SIZE;
6571
6572 if (assoc_ies->buf_len != 0) {
6573 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6574 assoc_ies->buf_len);
6575 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306576 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6577 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6578 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306579 } else {
6580 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6581 WMITLV_GET_STRUCT_TLVLEN(0));
6582 buf_ptr += WMI_TLV_HDR_SIZE;
6583 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6584 WMITLV_GET_STRUCT_TLVLEN(0));
6585 buf_ptr += WMI_TLV_HDR_SIZE;
6586 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6587 WMITLV_GET_STRUCT_TLVLEN(0));
6588 buf_ptr += WMI_TLV_HDR_SIZE;
6589 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6590 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306591 buf_ptr += WMI_TLV_HDR_SIZE;
6592 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6593 WMITLV_GET_STRUCT_TLVLEN(0));
6594 buf_ptr += WMI_TLV_HDR_SIZE;
6595 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6596 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306597 }
6598#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306599
6600send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306601 status = wmi_unified_cmd_send(wmi_handle, buf,
6602 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306603 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306604 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306605 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6606 status);
6607 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306608 }
6609
Govind Singh67922e82016-04-01 16:48:57 +05306610 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306611}
6612
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006613static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6614 struct wmi_mawc_roam_params *params)
6615{
6616 wmi_buf_t buf = NULL;
6617 QDF_STATUS status;
6618 int len;
6619 uint8_t *buf_ptr;
6620 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6621
6622 len = sizeof(*wmi_roam_mawc_params);
6623 buf = wmi_buf_alloc(wmi_handle, len);
6624 if (!buf) {
6625 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6626 return QDF_STATUS_E_NOMEM;
6627 }
6628
6629 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6630 wmi_roam_mawc_params =
6631 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6632 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6633 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6634 WMITLV_GET_STRUCT_TLVLEN
6635 (wmi_roam_configure_mawc_cmd_fixed_param));
6636 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6637 if (params->enable)
6638 wmi_roam_mawc_params->enable = 1;
6639 else
6640 wmi_roam_mawc_params->enable = 0;
6641 wmi_roam_mawc_params->traffic_load_threshold =
6642 params->traffic_load_threshold;
6643 wmi_roam_mawc_params->best_ap_rssi_threshold =
6644 params->best_ap_rssi_threshold;
6645 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6646 params->rssi_stationary_high_adjust;
6647 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6648 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006649 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6650 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6651 wmi_roam_mawc_params->traffic_load_threshold,
6652 wmi_roam_mawc_params->best_ap_rssi_threshold,
6653 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6654 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006655
6656 status = wmi_unified_cmd_send(wmi_handle, buf,
6657 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6658 if (QDF_IS_STATUS_ERROR(status)) {
6659 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6660 status);
6661 wmi_buf_free(buf);
6662 return status;
6663 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006664
6665 return QDF_STATUS_SUCCESS;
6666}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306667
6668/**
6669 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6670 * rssi threashold
6671 * @wmi_handle: wmi handle
6672 * @roam_req: Roaming request buffer
6673 *
6674 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6675 *
6676 * Return: QDF status
6677 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306678static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306679 struct roam_offload_scan_rssi_params *roam_req)
6680{
6681 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306682 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306683 int len;
6684 uint8_t *buf_ptr;
6685 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6686 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6687 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306688 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006689 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306690
6691 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6692 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6693 len += sizeof(wmi_roam_scan_extended_threshold_param);
6694 len += WMI_TLV_HDR_SIZE;
6695 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306696 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6697 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006698 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6699 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306700 buf = wmi_buf_alloc(wmi_handle, len);
6701 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306702 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306703 return QDF_STATUS_E_NOMEM;
6704 }
6705
6706 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6707 rssi_threshold_fp =
6708 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6709 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6710 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6711 WMITLV_GET_STRUCT_TLVLEN
6712 (wmi_roam_scan_rssi_threshold_fixed_param));
6713 /* fill in threshold values */
6714 rssi_threshold_fp->vdev_id = roam_req->session_id;
6715 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6716 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6717 rssi_threshold_fp->hirssi_scan_max_count =
6718 roam_req->hi_rssi_scan_max_count;
6719 rssi_threshold_fp->hirssi_scan_delta =
6720 roam_req->hi_rssi_scan_rssi_delta;
6721 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006722 rssi_threshold_fp->rssi_thresh_offset_5g =
6723 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306724
6725 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6726 WMITLV_SET_HDR(buf_ptr,
6727 WMITLV_TAG_ARRAY_STRUC,
6728 sizeof(wmi_roam_scan_extended_threshold_param));
6729 buf_ptr += WMI_TLV_HDR_SIZE;
6730 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6731
6732 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6733 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6734 ext_thresholds->boost_threshold_5g =
6735 roam_req->boost_threshold_5g;
6736
6737 ext_thresholds->boost_algorithm_5g =
6738 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6739 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6740 ext_thresholds->penalty_algorithm_5g =
6741 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6742 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6743 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6744 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6745 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6746
6747 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6748 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6749 WMITLV_GET_STRUCT_TLVLEN
6750 (wmi_roam_scan_extended_threshold_param));
6751 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6752 WMITLV_SET_HDR(buf_ptr,
6753 WMITLV_TAG_ARRAY_STRUC,
6754 sizeof(wmi_roam_earlystop_rssi_thres_param));
6755 buf_ptr += WMI_TLV_HDR_SIZE;
6756 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6757 early_stop_thresholds->roam_earlystop_thres_min =
6758 roam_req->roam_earlystop_thres_min;
6759 early_stop_thresholds->roam_earlystop_thres_max =
6760 roam_req->roam_earlystop_thres_max;
6761 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6762 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6763 WMITLV_GET_STRUCT_TLVLEN
6764 (wmi_roam_earlystop_rssi_thres_param));
6765
Gupta, Kapil7e652922016-04-12 15:02:00 +05306766 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6767 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6768 sizeof(wmi_roam_dense_thres_param));
6769 buf_ptr += WMI_TLV_HDR_SIZE;
6770 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6771 dense_thresholds->roam_dense_rssi_thres_offset =
6772 roam_req->dense_rssi_thresh_offset;
6773 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6774 dense_thresholds->roam_dense_traffic_thres =
6775 roam_req->traffic_threshold;
6776 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6777 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6778 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6779 WMITLV_GET_STRUCT_TLVLEN
6780 (wmi_roam_dense_thres_param));
6781
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006782 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6783 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6784 sizeof(wmi_roam_bg_scan_roaming_param));
6785 buf_ptr += WMI_TLV_HDR_SIZE;
6786 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6787 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6788 roam_req->bg_scan_bad_rssi_thresh;
6789 bg_scan_params->roam_bg_scan_client_bitmap =
6790 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306791 bg_scan_params->bad_rssi_thresh_offset_2g =
6792 roam_req->roam_bad_rssi_thresh_offset_2g;
6793 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006794 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6795 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6796 WMITLV_GET_STRUCT_TLVLEN
6797 (wmi_roam_bg_scan_roaming_param));
6798
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306799 status = wmi_unified_cmd_send(wmi_handle, buf,
6800 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306801 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306802 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306803 status);
6804 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306805 }
6806
Govind Singh67922e82016-04-01 16:48:57 +05306807 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306808}
6809
6810/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306811 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6812 * configuration params
6813 * @wma_handle: wma handler
6814 * @dwelltime_params: pointer to dwelltime_params
6815 *
6816 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6817 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006818static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306819QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6820 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6821{
6822 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6823 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6824 wmi_buf_t buf;
6825 uint8_t *buf_ptr;
6826 int32_t err;
6827 int len;
6828
6829 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6830 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6831 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6832 buf = wmi_buf_alloc(wmi_handle, len);
6833 if (!buf) {
6834 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6835 __func__);
6836 return QDF_STATUS_E_NOMEM;
6837 }
6838 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6839 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6840 WMITLV_SET_HDR(&dwell_param->tlv_header,
6841 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6842 WMITLV_GET_STRUCT_TLVLEN
6843 (wmi_scan_adaptive_dwell_config_fixed_param));
6844
6845 dwell_param->enable = dwelltime_params->is_enabled;
6846 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6847 WMITLV_SET_HDR(buf_ptr,
6848 WMITLV_TAG_ARRAY_STRUC,
6849 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6850 buf_ptr += WMI_TLV_HDR_SIZE;
6851
6852 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6853 WMITLV_SET_HDR(&cmd->tlv_header,
6854 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6855 WMITLV_GET_STRUCT_TLVLEN(
6856 wmi_scan_adaptive_dwell_parameters_tlv));
6857
6858 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6859 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6860 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6861 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6862 err = wmi_unified_cmd_send(wmi_handle, buf,
6863 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6864 if (err) {
6865 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6866 wmi_buf_free(buf);
6867 return QDF_STATUS_E_FAILURE;
6868 }
6869
6870 return QDF_STATUS_SUCCESS;
6871}
6872
Nitesh Shah52323d02017-05-22 15:49:00 +05306873/**
6874 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6875 * configuration params
6876 * @wmi_handle: wmi handler
6877 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6878 *
6879 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6880 */
6881static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6882 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6883{
6884 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6885 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6886 wmi_buf_t buf;
6887 uint8_t *buf_ptr;
6888 QDF_STATUS err;
6889 uint32_t i;
6890 int len;
6891
6892 len = sizeof(*dbs_scan_param);
6893 len += WMI_TLV_HDR_SIZE;
6894 len += dbs_scan_params->num_clients * sizeof(*cmd);
6895
6896 buf = wmi_buf_alloc(wmi_handle, len);
6897 if (!buf) {
6898 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6899 return QDF_STATUS_E_NOMEM;
6900 }
6901
6902 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6903 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6904 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6905 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6906 WMITLV_GET_STRUCT_TLVLEN
6907 (wmi_scan_dbs_duty_cycle_fixed_param));
6908
6909 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6910 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6911 buf_ptr += sizeof(*dbs_scan_param);
6912 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6913 (sizeof(*cmd) * dbs_scan_params->num_clients));
6914 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6915
6916 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6917 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6918 WMITLV_SET_HDR(&cmd->tlv_header,
6919 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6920 WMITLV_GET_STRUCT_TLVLEN(
6921 wmi_scan_dbs_duty_cycle_tlv_param));
6922 cmd->module_id = dbs_scan_params->module_id[i];
6923 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6924 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6925 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6926 }
6927
6928 err = wmi_unified_cmd_send(wmi_handle, buf,
6929 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6930 if (QDF_IS_STATUS_ERROR(err)) {
6931 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6932 wmi_buf_free(buf);
6933 return QDF_STATUS_E_FAILURE;
6934 }
6935
6936 return QDF_STATUS_SUCCESS;
6937}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306938
6939/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306940 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6941 * @wmi_handle: wmi handle
6942 * @roam_req: Request which contains the filters
6943 *
6944 * There are filters such as whitelist, blacklist and preferred
6945 * list that need to be applied to the scan results to form the
6946 * probable candidates for roaming.
6947 *
Jeff Johnsonda263992018-05-12 14:22:00 -07006948 * Return: Return success upon successfully passing the
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306949 * parameters to the firmware, otherwise failure.
6950 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306951static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306952 struct roam_scan_filter_params *roam_req)
6953{
6954 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306955 QDF_STATUS status;
6956 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306957 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306958 uint8_t *buf_ptr;
6959 wmi_roam_filter_fixed_param *roam_filter;
6960 uint8_t *bssid_src_ptr = NULL;
6961 wmi_mac_addr *bssid_dst_ptr = NULL;
6962 wmi_ssid *ssid_ptr = NULL;
6963 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306964 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306965 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306966
6967 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306968
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306969 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306970 if (roam_req->num_bssid_black_list)
6971 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6972 len += WMI_TLV_HDR_SIZE;
6973 if (roam_req->num_ssid_white_list)
6974 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6975 len += 2 * WMI_TLV_HDR_SIZE;
6976 if (roam_req->num_bssid_preferred_list) {
6977 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05306978 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306979 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306980 len += WMI_TLV_HDR_SIZE;
6981 if (roam_req->lca_disallow_config_present) {
6982 len += sizeof(*blist_param);
6983 blist_len = sizeof(*blist_param);
6984 }
6985
6986 len += WMI_TLV_HDR_SIZE;
6987 if (roam_req->num_rssi_rejection_ap)
6988 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306989
6990 buf = wmi_buf_alloc(wmi_handle, len);
6991 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306992 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306993 return QDF_STATUS_E_NOMEM;
6994 }
6995
6996 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6997 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6998 WMITLV_SET_HDR(&roam_filter->tlv_header,
6999 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
7000 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
7001 /* fill in fixed values */
7002 roam_filter->vdev_id = roam_req->session_id;
7003 roam_filter->flags = 0;
7004 roam_filter->op_bitmap = roam_req->op_bitmap;
7005 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
7006 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
7007 roam_filter->num_bssid_preferred_list =
7008 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307009 roam_filter->num_rssi_rejection_ap =
7010 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307011 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
7012
7013 WMITLV_SET_HDR((buf_ptr),
7014 WMITLV_TAG_ARRAY_FIXED_STRUC,
7015 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
7016 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
7017 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7018 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
7019 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
7020 bssid_src_ptr += ATH_MAC_LEN;
7021 bssid_dst_ptr++;
7022 }
7023 buf_ptr += WMI_TLV_HDR_SIZE +
7024 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
7025 WMITLV_SET_HDR((buf_ptr),
7026 WMITLV_TAG_ARRAY_FIXED_STRUC,
7027 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
7028 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
7029 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
7030 qdf_mem_copy(&ssid_ptr->ssid,
7031 &roam_req->ssid_allowed_list[i].mac_ssid,
7032 roam_req->ssid_allowed_list[i].length);
7033 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
7034 ssid_ptr++;
7035 }
7036 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
7037 sizeof(wmi_ssid));
7038 WMITLV_SET_HDR((buf_ptr),
7039 WMITLV_TAG_ARRAY_FIXED_STRUC,
7040 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
7041 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
7042 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7043 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7044 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
7045 (wmi_mac_addr *)bssid_dst_ptr);
7046 bssid_src_ptr += ATH_MAC_LEN;
7047 bssid_dst_ptr++;
7048 }
7049 buf_ptr += WMI_TLV_HDR_SIZE +
7050 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
7051 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7052 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
7053 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
7054 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7055 *bssid_preferred_factor_ptr =
7056 roam_req->bssid_favored_factor[i];
7057 bssid_preferred_factor_ptr++;
7058 }
7059 buf_ptr += WMI_TLV_HDR_SIZE +
7060 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
7061
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307062 WMITLV_SET_HDR(buf_ptr,
7063 WMITLV_TAG_ARRAY_STRUC, blist_len);
7064 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307065 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307066 blist_param =
7067 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
7068 WMITLV_SET_HDR(&blist_param->tlv_header,
7069 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
7070 WMITLV_GET_STRUCT_TLVLEN(
7071 wmi_roam_lca_disallow_config_tlv_param));
7072
7073 blist_param->disallow_duration = roam_req->disallow_duration;
7074 blist_param->rssi_channel_penalization =
7075 roam_req->rssi_channel_penalization;
7076 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05307077 blist_param->disallow_lca_enable_source_bitmap =
7078 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
7079 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307080 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
7081 }
7082
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307083 WMITLV_SET_HDR(buf_ptr,
7084 WMITLV_TAG_ARRAY_STRUC,
7085 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
7086 buf_ptr += WMI_TLV_HDR_SIZE;
7087 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
7088 rssi_rej =
7089 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7090 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7091 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7092 WMITLV_GET_STRUCT_TLVLEN(
7093 wmi_roam_rssi_rejection_oce_config_param));
7094 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7095 roam_req->rssi_rejection_ap[i].bssid.bytes,
7096 &rssi_rej->bssid);
7097 rssi_rej->remaining_disallow_duration =
7098 roam_req->rssi_rejection_ap[i].remaining_duration;
7099 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05307100 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307101 buf_ptr +=
7102 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7103 }
7104
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307105 status = wmi_unified_cmd_send(wmi_handle, buf,
7106 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307107 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307108 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307109 status);
7110 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307111 }
Govind Singh67922e82016-04-01 16:48:57 +05307112
7113 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307114}
7115
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307116#if defined(WLAN_FEATURE_FILS_SK)
7117static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7118 struct hlp_params *params)
7119{
7120 uint32_t len;
7121 uint8_t *buf_ptr;
7122 wmi_buf_t buf = NULL;
7123 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7124
7125 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7126 len += WMI_TLV_HDR_SIZE;
7127 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7128
7129 buf = wmi_buf_alloc(wmi_handle, len);
7130 if (!buf) {
7131 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7132 return QDF_STATUS_E_NOMEM;
7133 }
7134
7135 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7136 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7137 WMITLV_SET_HDR(&hlp_params->tlv_header,
7138 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7139 WMITLV_GET_STRUCT_TLVLEN(
7140 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7141
7142 hlp_params->vdev_id = params->vdev_id;
7143 hlp_params->size = params->hlp_ie_len;
7144 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7145
7146 buf_ptr += sizeof(*hlp_params);
7147
7148 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7149 round_up(params->hlp_ie_len,
7150 sizeof(uint32_t)));
7151 buf_ptr += WMI_TLV_HDR_SIZE;
7152 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7153
7154 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7155 hlp_params->vdev_id, hlp_params->size);
7156 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7157 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7158 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7159 wmi_buf_free(buf);
7160 return QDF_STATUS_E_FAILURE;
7161 }
7162
7163 return QDF_STATUS_SUCCESS;
7164}
7165#endif
7166
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307167#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307168/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7169 * @wmi_handle: wmi handle
7170 * @ipa_offload: ipa offload control parameter
7171 *
7172 * Returns: 0 on success, error number otherwise
7173 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307174static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307175 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307176{
7177 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7178 wmi_buf_t wmi_buf;
7179 uint32_t len;
7180 u_int8_t *buf_ptr;
7181
7182 len = sizeof(*cmd);
7183 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7184 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307185 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7186 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307187 }
7188
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007189 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307190 ipa_offload->offload_type, ipa_offload->enable);
7191
7192 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7193
7194 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7195 WMITLV_SET_HDR(&cmd->tlv_header,
7196 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7197 WMITLV_GET_STRUCT_TLVLEN(
7198 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7199
7200 cmd->offload_type = ipa_offload->offload_type;
7201 cmd->vdev_id = ipa_offload->vdev_id;
7202 cmd->enable = ipa_offload->enable;
7203
7204 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7205 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307206 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307207 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307208 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307209 }
7210
Govind Singhb53420c2016-03-09 14:32:57 +05307211 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307212}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307213#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307214
7215/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307216 * send_plm_stop_cmd_tlv() - plm stop request
7217 * @wmi_handle: wmi handle
7218 * @plm: plm request parameters
7219 *
7220 * This function request FW to stop PLM.
7221 *
7222 * Return: CDF status
7223 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307224static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307225 const struct plm_req_params *plm)
7226{
7227 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7228 int32_t len;
7229 wmi_buf_t buf;
7230 uint8_t *buf_ptr;
7231 int ret;
7232
7233 len = sizeof(*cmd);
7234 buf = wmi_buf_alloc(wmi_handle, len);
7235 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307236 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7237 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307238 }
7239
7240 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7241
7242 buf_ptr = (uint8_t *) cmd;
7243
7244 WMITLV_SET_HDR(&cmd->tlv_header,
7245 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7246 WMITLV_GET_STRUCT_TLVLEN
7247 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7248
7249 cmd->vdev_id = plm->session_id;
7250
7251 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307252 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307253
7254 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7255 WMI_VDEV_PLMREQ_STOP_CMDID);
7256 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307257 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307258 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307259 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307260 }
7261
Govind Singhb53420c2016-03-09 14:32:57 +05307262 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307263}
7264
7265/**
7266 * send_plm_start_cmd_tlv() - plm start request
7267 * @wmi_handle: wmi handle
7268 * @plm: plm request parameters
7269 *
7270 * This function request FW to start PLM.
7271 *
7272 * Return: CDF status
7273 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307274static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307275 const struct plm_req_params *plm,
7276 uint32_t *gchannel_list)
7277{
7278 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7279 uint32_t *channel_list;
7280 int32_t len;
7281 wmi_buf_t buf;
7282 uint8_t *buf_ptr;
7283 uint8_t count;
7284 int ret;
7285
7286 /* TLV place holder for channel_list */
7287 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7288 len += sizeof(uint32_t) * plm->plm_num_ch;
7289
7290 buf = wmi_buf_alloc(wmi_handle, len);
7291 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307292 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7293 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307294 }
7295 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7296
7297 buf_ptr = (uint8_t *) cmd;
7298
7299 WMITLV_SET_HDR(&cmd->tlv_header,
7300 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7301 WMITLV_GET_STRUCT_TLVLEN
7302 (wmi_vdev_plmreq_start_cmd_fixed_param));
7303
7304 cmd->vdev_id = plm->session_id;
7305
7306 cmd->meas_token = plm->meas_token;
7307 cmd->dialog_token = plm->diag_token;
7308 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307309 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307310 cmd->off_duration = plm->meas_duration;
7311 cmd->burst_cycle = plm->burst_len;
7312 cmd->tx_power = plm->desired_tx_pwr;
7313 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7314 cmd->num_chans = plm->plm_num_ch;
7315
7316 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7317
Govind Singhb53420c2016-03-09 14:32:57 +05307318 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7319 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7320 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7321 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7322 WMI_LOGD("off_duration: %d", cmd->off_duration);
7323 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7324 WMI_LOGD("tx_power: %d", cmd->tx_power);
7325 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307326
7327 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7328 (cmd->num_chans * sizeof(uint32_t)));
7329
7330 buf_ptr += WMI_TLV_HDR_SIZE;
7331 if (cmd->num_chans) {
7332 channel_list = (uint32_t *) buf_ptr;
7333 for (count = 0; count < cmd->num_chans; count++) {
7334 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307335 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307336 channel_list[count] =
7337 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307338 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307339 }
7340 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7341 }
7342
7343 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7344 WMI_VDEV_PLMREQ_START_CMDID);
7345 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307346 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307347 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307348 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307349 }
7350
Govind Singhb53420c2016-03-09 14:32:57 +05307351 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307352}
7353
7354/**
7355 * send_pno_stop_cmd_tlv() - PNO stop request
7356 * @wmi_handle: wmi handle
7357 * @vdev_id: vdev id
7358 *
7359 * This function request FW to stop ongoing PNO operation.
7360 *
7361 * Return: CDF status
7362 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307363static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307364{
7365 wmi_nlo_config_cmd_fixed_param *cmd;
7366 int32_t len = sizeof(*cmd);
7367 wmi_buf_t buf;
7368 uint8_t *buf_ptr;
7369 int ret;
7370
7371 /*
7372 * TLV place holder for array of structures nlo_configured_parameters
7373 * TLV place holder for array of uint32_t channel_list
7374 * TLV place holder for chnl prediction cfg
7375 */
7376 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7377 buf = wmi_buf_alloc(wmi_handle, len);
7378 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307379 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7380 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307381 }
7382
7383 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7384 buf_ptr = (uint8_t *) cmd;
7385
7386 WMITLV_SET_HDR(&cmd->tlv_header,
7387 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7388 WMITLV_GET_STRUCT_TLVLEN
7389 (wmi_nlo_config_cmd_fixed_param));
7390
7391 cmd->vdev_id = vdev_id;
7392 cmd->flags = WMI_NLO_CONFIG_STOP;
7393 buf_ptr += sizeof(*cmd);
7394
7395 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7396 buf_ptr += WMI_TLV_HDR_SIZE;
7397
7398 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7399 buf_ptr += WMI_TLV_HDR_SIZE;
7400
7401 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7402 buf_ptr += WMI_TLV_HDR_SIZE;
7403
7404
7405 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7406 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7407 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307408 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307409 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307410 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307411 }
7412
Govind Singhb53420c2016-03-09 14:32:57 +05307413 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307414}
7415
7416/**
Govind Singhccb0c272016-04-01 16:30:08 +05307417 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7418 * @buf_ptr: Buffer passed by upper layers
7419 * @pno: Buffer to be sent to the firmware
7420 *
7421 * Copy the PNO Channel prediction configuration parameters
7422 * passed by the upper layers to a WMI format TLV and send it
7423 * down to the firmware.
7424 *
7425 * Return: None
7426 */
7427static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7428 struct pno_scan_req_params *pno)
7429{
7430 nlo_channel_prediction_cfg *channel_prediction_cfg =
7431 (nlo_channel_prediction_cfg *) buf_ptr;
7432 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7433 WMITLV_TAG_ARRAY_BYTE,
7434 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307435#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307436 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7437 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7438 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7439 channel_prediction_cfg->full_scan_period_ms =
7440 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307441#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307442 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7443 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7444 channel_prediction_cfg->enable,
7445 channel_prediction_cfg->top_k_num,
7446 channel_prediction_cfg->stationary_threshold,
7447 channel_prediction_cfg->full_scan_period_ms);
7448}
7449
7450/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007451 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7452 * @wmi_handle: wmi handle
7453 * @params: configuration parameters
7454 *
7455 * Return: QDF_STATUS
7456 */
7457static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7458 struct nlo_mawc_params *params)
7459{
7460 wmi_buf_t buf = NULL;
7461 QDF_STATUS status;
7462 int len;
7463 uint8_t *buf_ptr;
7464 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7465
7466 len = sizeof(*wmi_nlo_mawc_params);
7467 buf = wmi_buf_alloc(wmi_handle, len);
7468 if (!buf) {
7469 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7470 return QDF_STATUS_E_NOMEM;
7471 }
7472
7473 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7474 wmi_nlo_mawc_params =
7475 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7476 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7477 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7478 WMITLV_GET_STRUCT_TLVLEN
7479 (wmi_nlo_configure_mawc_cmd_fixed_param));
7480 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7481 if (params->enable)
7482 wmi_nlo_mawc_params->enable = 1;
7483 else
7484 wmi_nlo_mawc_params->enable = 0;
7485 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7486 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7487 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07007488 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7489 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7490 wmi_nlo_mawc_params->exp_backoff_ratio,
7491 wmi_nlo_mawc_params->init_scan_interval,
7492 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007493
7494 status = wmi_unified_cmd_send(wmi_handle, buf,
7495 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7496 if (QDF_IS_STATUS_ERROR(status)) {
7497 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7498 status);
7499 wmi_buf_free(buf);
7500 return QDF_STATUS_E_FAILURE;
7501 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007502
7503 return QDF_STATUS_SUCCESS;
7504}
7505
7506/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307507 * send_pno_start_cmd_tlv() - PNO start request
7508 * @wmi_handle: wmi handle
7509 * @pno: PNO request
7510 *
7511 * This function request FW to start PNO request.
7512 * Request: CDF status
7513 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307514static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307515 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307516{
7517 wmi_nlo_config_cmd_fixed_param *cmd;
7518 nlo_configured_parameters *nlo_list;
7519 uint32_t *channel_list;
7520 int32_t len;
7521 wmi_buf_t buf;
7522 uint8_t *buf_ptr;
7523 uint8_t i;
7524 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307525 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307526 connected_nlo_rssi_params *nlo_relative_rssi;
7527 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307528
7529 /*
7530 * TLV place holder for array nlo_configured_parameters(nlo_list)
7531 * TLV place holder for array of uint32_t channel_list
7532 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307533 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307534 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05307535 */
7536 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307537 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307538 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307539
Abhishek Singh5987b632017-03-03 22:09:07 +05307540 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307541 WMI_NLO_MAX_CHAN);
7542 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307543 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307544 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307545 len += sizeof(enlo_candidate_score_params);
7546 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307547 len += sizeof(connected_nlo_rssi_params);
7548 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307549
7550 buf = wmi_buf_alloc(wmi_handle, len);
7551 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307552 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7553 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307554 }
7555
7556 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7557
7558 buf_ptr = (uint8_t *) cmd;
7559 WMITLV_SET_HDR(&cmd->tlv_header,
7560 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7561 WMITLV_GET_STRUCT_TLVLEN
7562 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307563 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307564 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7565
Govind Singh87542482016-06-08 19:40:11 +05307566#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307567 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307568 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307569#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307570 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307571 cmd->active_dwell_time = pno->active_dwell_time;
7572 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307573
Manjeet Singhcd2dc062016-08-11 15:31:34 +05307574 if (pno->do_passive_scan)
7575 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307576 /* Copy scan interval */
7577 cmd->fast_scan_period = pno->fast_scan_period;
7578 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007579 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307580 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007581 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307582 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307583 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307584 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307585
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307586 /* mac randomization attributes */
7587 if (pno->scan_random.randomize) {
7588 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7589 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7590 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7591 pno->scan_random.mac_mask,
7592 &cmd->mac_addr,
7593 &cmd->mac_mask);
7594 }
7595
Govind Singh4eacd2b2016-03-07 14:24:22 +05307596 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7597
Abhishek Singh5987b632017-03-03 22:09:07 +05307598 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307599 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307600 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7601 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7602 buf_ptr += WMI_TLV_HDR_SIZE;
7603
7604 nlo_list = (nlo_configured_parameters *) buf_ptr;
7605 for (i = 0; i < cmd->no_of_ssids; i++) {
7606 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7607 WMITLV_TAG_ARRAY_BYTE,
7608 WMITLV_GET_STRUCT_TLVLEN
7609 (nlo_configured_parameters));
7610 /* Copy ssid and it's length */
7611 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307612 nlo_list[i].ssid.ssid.ssid_len =
7613 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307614 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307615 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307616 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307617 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307618 nlo_list[i].ssid.ssid.ssid_len,
7619 (char *)nlo_list[i].ssid.ssid.ssid,
7620 nlo_list[i].ssid.ssid.ssid_len);
7621
7622 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307623 if (pno->networks_list[i].rssi_thresh &&
7624 pno->networks_list[i].rssi_thresh >
7625 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307626 nlo_list[i].rssi_cond.valid = true;
7627 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307628 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307629 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307630 nlo_list[i].rssi_cond.rssi);
7631 }
7632 nlo_list[i].bcast_nw_type.valid = true;
7633 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307634 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007635 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307636 nlo_list[i].bcast_nw_type.bcast_nw_type);
7637 }
7638 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7639
7640 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307641 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307642 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307643 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307644 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7645 (cmd->num_of_channels * sizeof(uint32_t)));
7646 buf_ptr += WMI_TLV_HDR_SIZE;
7647
7648 channel_list = (uint32_t *) buf_ptr;
7649 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307650 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307651
7652 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307653 channel_list[i] =
7654 wlan_chan_to_freq(pno->
7655 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307656
Govind Singhb53420c2016-03-09 14:32:57 +05307657 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307658 }
7659 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7660 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7661 sizeof(nlo_channel_prediction_cfg));
7662 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307663 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307664 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307665 /** TODO: Discrete firmware doesn't have command/option to configure
7666 * App IE which comes from wpa_supplicant as of part PNO start request.
7667 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307668 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
7669 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7670 buf_ptr += sizeof(enlo_candidate_score_params);
7671
7672 if (ie_whitelist->white_list) {
7673 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
7674 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
7675 &cmd->num_vendor_oui,
7676 ie_whitelist);
7677 }
7678
7679 /* ie white list */
7680 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7681 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
7682 buf_ptr += WMI_TLV_HDR_SIZE;
7683 if (cmd->num_vendor_oui != 0) {
7684 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
7685 ie_whitelist->voui);
7686 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
7687 }
7688
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307689 if (pno->relative_rssi_set)
7690 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
7691
7692 /*
7693 * Firmware calculation using connected PNO params:
7694 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
7695 * deduction of rssi_pref for chosen band_pref and
7696 * addition of rssi_pref for remaining bands (other than chosen band).
7697 */
7698 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
7699 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
7700 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
7701 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
7702 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
7703 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
7704 buf_ptr += sizeof(*nlo_relative_rssi);
7705
7706 /*
7707 * As of now Kernel and Host supports one band and rssi preference.
7708 * Firmware supports array of band and rssi preferences
7709 */
7710 cmd->num_cnlo_band_pref = 1;
7711 WMITLV_SET_HDR(buf_ptr,
7712 WMITLV_TAG_ARRAY_STRUC,
7713 cmd->num_cnlo_band_pref *
7714 sizeof(connected_nlo_bss_band_rssi_pref));
7715 buf_ptr += WMI_TLV_HDR_SIZE;
7716
7717 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
7718 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
7719 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
7720 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
7721 WMITLV_GET_STRUCT_TLVLEN(
7722 connected_nlo_bss_band_rssi_pref));
7723 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
7724 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
7725 WMI_LOGI("band_pref %d, rssi_pref %d",
7726 nlo_band_rssi[i].band,
7727 nlo_band_rssi[i].rssi_pref);
7728 }
7729 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
7730
Govind Singh4eacd2b2016-03-07 14:24:22 +05307731 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7732 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7733 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307734 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307735 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307736 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307737 }
7738
Govind Singhb53420c2016-03-09 14:32:57 +05307739 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307740}
7741
7742/* send_set_ric_req_cmd_tlv() - set ric request element
7743 * @wmi_handle: wmi handle
7744 * @msg: message
7745 * @is_add_ts: is addts required
7746 *
7747 * This function sets ric request element for 11r roaming.
7748 *
7749 * Return: CDF status
7750 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307751static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307752 void *msg, uint8_t is_add_ts)
7753{
7754 wmi_ric_request_fixed_param *cmd;
7755 wmi_ric_tspec *tspec_param;
7756 wmi_buf_t buf;
7757 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307758 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307759 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7760 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7761
7762 buf = wmi_buf_alloc(wmi_handle, len);
7763 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307764 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7765 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307766 }
7767
7768 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7769
7770 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7771 WMITLV_SET_HDR(&cmd->tlv_header,
7772 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7773 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7774 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007775 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307776 else
7777 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7778 cmd->num_ric_request = 1;
7779 cmd->is_add_ric = is_add_ts;
7780
7781 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7782 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7783
7784 buf_ptr += WMI_TLV_HDR_SIZE;
7785 tspec_param = (wmi_ric_tspec *) buf_ptr;
7786 WMITLV_SET_HDR(&tspec_param->tlv_header,
7787 WMITLV_TAG_STRUC_wmi_ric_tspec,
7788 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7789
7790 if (is_add_ts)
7791 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307792#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307793 else
7794 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307795#endif
7796 if (ptspecIE) {
7797 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307798#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307799 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7800 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307801#else
Govind Singh87542482016-06-08 19:40:11 +05307802 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7803 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307804#endif /* ANI_LITTLE_BIT_ENDIAN */
7805
Govind Singh87542482016-06-08 19:40:11 +05307806 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7807 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7808 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7809 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7810 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7811 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7812 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7813 tspec_param->min_data_rate = ptspecIE->minDataRate;
7814 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7815 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7816 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7817 tspec_param->delay_bound = ptspecIE->delayBound;
7818 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7819 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7820 tspec_param->medium_time = 0;
7821 }
Govind Singhb53420c2016-03-09 14:32:57 +05307822 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307823
7824 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7825 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307826 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307827 __func__);
7828 if (is_add_ts)
7829 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307830 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307831 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307832 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307833 }
7834
Govind Singhb53420c2016-03-09 14:32:57 +05307835 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307836}
7837
Qiwei Cai1ccba222018-05-21 16:49:39 +08007838#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +05307839/**
7840 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7841 * @wmi_handle: wmi handle
7842 * @clear_req: ll stats clear request command params
7843 *
Govind Singhb53420c2016-03-09 14:32:57 +05307844 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307845 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307846static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307847 const struct ll_stats_clear_params *clear_req,
7848 uint8_t addr[IEEE80211_ADDR_LEN])
7849{
7850 wmi_clear_link_stats_cmd_fixed_param *cmd;
7851 int32_t len;
7852 wmi_buf_t buf;
7853 uint8_t *buf_ptr;
7854 int ret;
7855
7856 len = sizeof(*cmd);
7857 buf = wmi_buf_alloc(wmi_handle, len);
7858
7859 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307860 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7861 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307862 }
7863
7864 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307865 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307866 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7867
7868 WMITLV_SET_HDR(&cmd->tlv_header,
7869 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7870 WMITLV_GET_STRUCT_TLVLEN
7871 (wmi_clear_link_stats_cmd_fixed_param));
7872
7873 cmd->stop_stats_collection_req = clear_req->stop_req;
7874 cmd->vdev_id = clear_req->sta_id;
7875 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7876
7877 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7878 &cmd->peer_macaddr);
7879
Govind Singhb53420c2016-03-09 14:32:57 +05307880 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7881 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7882 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7883 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7884 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307885 cmd->peer_macaddr); */
7886
7887 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7888 WMI_CLEAR_LINK_STATS_CMDID);
7889 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307890 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307891 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307892 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307893 }
7894
Govind Singhb53420c2016-03-09 14:32:57 +05307895 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7896 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307897}
7898
7899/**
7900 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7901 * @wmi_handle: wmi handle
7902 * @setReq: ll stats set request command params
7903 *
Govind Singhb53420c2016-03-09 14:32:57 +05307904 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307905 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307906static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307907 const struct ll_stats_set_params *set_req)
7908{
7909 wmi_start_link_stats_cmd_fixed_param *cmd;
7910 int32_t len;
7911 wmi_buf_t buf;
7912 uint8_t *buf_ptr;
7913 int ret;
7914
7915 len = sizeof(*cmd);
7916 buf = wmi_buf_alloc(wmi_handle, len);
7917
7918 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307919 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7920 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307921 }
7922
7923 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307924 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307925 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7926
7927 WMITLV_SET_HDR(&cmd->tlv_header,
7928 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7929 WMITLV_GET_STRUCT_TLVLEN
7930 (wmi_start_link_stats_cmd_fixed_param));
7931
7932 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7933 cmd->aggressive_statistics_gathering =
7934 set_req->aggressive_statistics_gathering;
7935
Govind Singhb53420c2016-03-09 14:32:57 +05307936 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7937 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7938 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307939
7940 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7941 WMI_START_LINK_STATS_CMDID);
7942 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307943 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307944 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307945 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307946 }
7947
Govind Singhb53420c2016-03-09 14:32:57 +05307948 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307949}
7950
7951/**
7952 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7953 * @wmi_handle:wmi handle
7954 * @get_req:ll stats get request command params
7955 * @addr: mac address
7956 *
Govind Singhb53420c2016-03-09 14:32:57 +05307957 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307958 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307959static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307960 const struct ll_stats_get_params *get_req,
7961 uint8_t addr[IEEE80211_ADDR_LEN])
7962{
7963 wmi_request_link_stats_cmd_fixed_param *cmd;
7964 int32_t len;
7965 wmi_buf_t buf;
7966 uint8_t *buf_ptr;
7967 int ret;
7968
7969 len = sizeof(*cmd);
7970 buf = wmi_buf_alloc(wmi_handle, len);
7971
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307972 if (!buf) {
7973 WMI_LOGE("%s: buf allocation failed", __func__);
7974 return QDF_STATUS_E_NOMEM;
7975 }
7976
Govind Singh4eacd2b2016-03-07 14:24:22 +05307977 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307978 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307979 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7980
7981 WMITLV_SET_HDR(&cmd->tlv_header,
7982 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7983 WMITLV_GET_STRUCT_TLVLEN
7984 (wmi_request_link_stats_cmd_fixed_param));
7985
7986 cmd->request_id = get_req->req_id;
7987 cmd->stats_type = get_req->param_id_mask;
7988 cmd->vdev_id = get_req->sta_id;
7989
7990 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7991 &cmd->peer_macaddr);
7992
Govind Singhb53420c2016-03-09 14:32:57 +05307993 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08007994 WMI_LOGD("Request ID : %u", cmd->request_id);
7995 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05307996 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7997 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307998
7999 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8000 WMI_REQUEST_LINK_STATS_CMDID);
8001 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308002 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308003 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308004 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308005 }
8006
Govind Singhb53420c2016-03-09 14:32:57 +05308007 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308008}
Qiwei Cai1ccba222018-05-21 16:49:39 +08008009#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308010
Govind Singh20c5dac2016-03-07 15:33:31 +05308011/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308012 * send_congestion_cmd_tlv() - send request to fw to get CCA
8013 * @wmi_handle: wmi handle
8014 * @vdev_id: vdev id
8015 *
8016 * Return: CDF status
8017 */
8018static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05308019 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308020{
8021 wmi_buf_t buf;
8022 wmi_request_stats_cmd_fixed_param *cmd;
8023 uint8_t len;
8024 uint8_t *buf_ptr;
8025
8026 len = sizeof(*cmd);
8027 buf = wmi_buf_alloc(wmi_handle, len);
8028 if (!buf) {
8029 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8030 return QDF_STATUS_E_FAILURE;
8031 }
8032
8033 buf_ptr = wmi_buf_data(buf);
8034 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8035 WMITLV_SET_HDR(&cmd->tlv_header,
8036 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8037 WMITLV_GET_STRUCT_TLVLEN
8038 (wmi_request_stats_cmd_fixed_param));
8039
8040 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8041 cmd->vdev_id = vdev_id;
8042 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8043 cmd->vdev_id, cmd->stats_id);
8044
8045 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8046 WMI_REQUEST_STATS_CMDID)) {
8047 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8048 __func__);
8049 wmi_buf_free(buf);
8050 return QDF_STATUS_E_FAILURE;
8051 }
8052
8053 return QDF_STATUS_SUCCESS;
8054}
8055
8056/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308057 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8058 * @wmi_handle: wmi handle
8059 * @rssi_req: get RSSI request
8060 *
8061 * Return: CDF status
8062 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308063static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308064{
8065 wmi_buf_t buf;
8066 wmi_request_stats_cmd_fixed_param *cmd;
8067 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8068
8069 buf = wmi_buf_alloc(wmi_handle, len);
8070 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308071 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8072 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308073 }
8074
8075 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8076 WMITLV_SET_HDR(&cmd->tlv_header,
8077 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8078 WMITLV_GET_STRUCT_TLVLEN
8079 (wmi_request_stats_cmd_fixed_param));
8080 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8081 if (wmi_unified_cmd_send
8082 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308083 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308084 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308085 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308086 }
8087
Govind Singhb53420c2016-03-09 14:32:57 +05308088 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308089}
8090
8091/**
8092 * send_snr_cmd_tlv() - get RSSI from fw
8093 * @wmi_handle: wmi handle
8094 * @vdev_id: vdev id
8095 *
8096 * Return: CDF status
8097 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308098static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308099{
8100 wmi_buf_t buf;
8101 wmi_request_stats_cmd_fixed_param *cmd;
8102 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8103
8104 buf = wmi_buf_alloc(wmi_handle, len);
8105 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308106 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8107 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308108 }
8109
8110 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8111 cmd->vdev_id = vdev_id;
8112
8113 WMITLV_SET_HDR(&cmd->tlv_header,
8114 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8115 WMITLV_GET_STRUCT_TLVLEN
8116 (wmi_request_stats_cmd_fixed_param));
8117 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8118 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8119 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308120 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308121 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308122 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308123 }
8124
Govind Singhb53420c2016-03-09 14:32:57 +05308125 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308126}
8127
8128/**
8129 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8130 * @wmi_handle: wmi handle
8131 * @link_status: get link params
8132 *
8133 * Return: CDF status
8134 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308135static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308136 struct link_status_params *link_status)
8137{
8138 wmi_buf_t buf;
8139 wmi_request_stats_cmd_fixed_param *cmd;
8140 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8141
8142 buf = wmi_buf_alloc(wmi_handle, len);
8143 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308144 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8145 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308146 }
8147
8148 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8149 WMITLV_SET_HDR(&cmd->tlv_header,
8150 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8151 WMITLV_GET_STRUCT_TLVLEN
8152 (wmi_request_stats_cmd_fixed_param));
8153 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8154 cmd->vdev_id = link_status->session_id;
8155 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8156 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308157 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308158 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308159 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308160 }
8161
Govind Singhb53420c2016-03-09 14:32:57 +05308162 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308163}
8164
Govind Singh20c5dac2016-03-07 15:33:31 +05308165/**
8166 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8167 * @wmi_handle: wmi handle
8168 * @ta_dhcp_ind: DHCP indication parameter
8169 *
8170 * Return: CDF Status
8171 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308172static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308173 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8174{
Govind Singh67922e82016-04-01 16:48:57 +05308175 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308176 wmi_buf_t buf = NULL;
8177 uint8_t *buf_ptr;
8178 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8179 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8180
8181
8182 buf = wmi_buf_alloc(wmi_handle, len);
8183 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308184 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8185 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308186 }
8187
8188 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8189 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8190 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8191 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8192 WMITLV_GET_STRUCT_TLVLEN
8193 (wmi_peer_set_param_cmd_fixed_param));
8194
8195 /* fill in values */
8196 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8197 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8198 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308199 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308200 &ta_dhcp_ind->peer_macaddr,
8201 sizeof(ta_dhcp_ind->peer_macaddr));
8202
8203 status = wmi_unified_cmd_send(wmi_handle, buf,
8204 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308205 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308206 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308207 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308208 wmi_buf_free(buf);
8209 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308210
Govind Singh67922e82016-04-01 16:48:57 +05308211 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308212}
8213
8214/**
8215 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8216 * @wmi_handle: wmi handle
8217 * @pLinkSpeed: link speed info
8218 *
8219 * Return: CDF status
8220 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308221static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308222 wmi_mac_addr peer_macaddr)
8223{
8224 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8225 wmi_buf_t wmi_buf;
8226 uint32_t len;
8227 uint8_t *buf_ptr;
8228
8229 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8230 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8231 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308232 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8233 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308234 }
8235 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8236
8237 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8238 WMITLV_SET_HDR(&cmd->tlv_header,
8239 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8240 WMITLV_GET_STRUCT_TLVLEN
8241 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8242
8243 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308244 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308245 &peer_macaddr,
8246 sizeof(peer_macaddr));
8247
8248
8249 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8250 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308251 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308252 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308253 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308254 }
Govind Singhb53420c2016-03-09 14:32:57 +05308255 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308256}
8257
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308258#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308259/**
8260 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8261 * @wmi_handle: wmi handler
8262 * @egap_params: pointer to egap_params
8263 *
8264 * Return: 0 for success, otherwise appropriate error code
8265 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308266static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308267 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308268{
8269 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8270 wmi_buf_t buf;
8271 int32_t err;
8272
8273 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8274 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308275 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8276 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308277 }
8278 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8279 WMITLV_SET_HDR(&cmd->tlv_header,
8280 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8281 WMITLV_GET_STRUCT_TLVLEN(
8282 wmi_ap_ps_egap_param_cmd_fixed_param));
8283
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308284 cmd->enable = egap_params->host_enable_egap;
8285 cmd->inactivity_time = egap_params->egap_inactivity_time;
8286 cmd->wait_time = egap_params->egap_wait_time;
8287 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308288 err = wmi_unified_cmd_send(wmi_handle, buf,
8289 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8290 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308291 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308292 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308293 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308294 }
8295
Govind Singhb53420c2016-03-09 14:32:57 +05308296 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308297}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308298#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308299
8300/**
8301 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8302 * @wmi_handl: wmi handle
8303 * @cmd: Profiling command index
8304 * @value1: parameter1 value
8305 * @value2: parameter2 value
8306 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308307 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308308 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308309static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308310 uint32_t cmd, uint32_t value1, uint32_t value2)
8311{
8312 wmi_buf_t buf;
8313 int32_t len = 0;
8314 int ret;
8315 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8316 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8317 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8318 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8319
8320 switch (cmd) {
8321 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8322 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8323 buf = wmi_buf_alloc(wmi_handle, len);
8324 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308325 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308326 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308327 }
8328 prof_trig_cmd =
8329 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8330 wmi_buf_data(buf);
8331 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8332 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8333 WMITLV_GET_STRUCT_TLVLEN
8334 (wmi_wlan_profile_trigger_cmd_fixed_param));
8335 prof_trig_cmd->enable = value1;
8336 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8337 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8338 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308339 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308340 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308341 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308342 return ret;
8343 }
8344 break;
8345
8346 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8347 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8348 buf = wmi_buf_alloc(wmi_handle, len);
8349 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308350 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308351 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308352 }
8353 profile_getdata_cmd =
8354 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8355 wmi_buf_data(buf);
8356 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8357 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8358 WMITLV_GET_STRUCT_TLVLEN
8359 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8360 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8361 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8362 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308363 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308364 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308365 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308366 return ret;
8367 }
8368 break;
8369
8370 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8371 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8372 buf = wmi_buf_alloc(wmi_handle, len);
8373 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308374 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308375 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308376 }
8377 hist_intvl_cmd =
8378 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8379 wmi_buf_data(buf);
8380 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8381 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8382 WMITLV_GET_STRUCT_TLVLEN
8383 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8384 hist_intvl_cmd->profile_id = value1;
8385 hist_intvl_cmd->value = value2;
8386 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8387 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8388 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308389 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308390 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308391 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308392 return ret;
8393 }
8394 break;
8395
8396 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8397 len =
8398 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8399 buf = wmi_buf_alloc(wmi_handle, len);
8400 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308401 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308402 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308403 }
8404 profile_enable_cmd =
8405 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8406 wmi_buf_data(buf);
8407 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8408 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8409 WMITLV_GET_STRUCT_TLVLEN
8410 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8411 profile_enable_cmd->profile_id = value1;
8412 profile_enable_cmd->enable = value2;
8413 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8414 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8415 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308416 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308417 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308418 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308419 return ret;
8420 }
8421 break;
8422
8423 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308424 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308425 break;
8426 }
8427
8428 return 0;
8429}
8430
Paul Zhang92ab8d32017-12-08 16:08:00 +08008431static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
8432 struct wlm_latency_level_param *params)
8433{
8434 wmi_wlm_config_cmd_fixed_param *cmd;
8435 wmi_buf_t buf;
8436 uint32_t len = sizeof(*cmd);
8437 static uint32_t ll[4] = {100, 60, 40, 20};
8438
8439 buf = wmi_buf_alloc(wmi_handle, len);
8440 if (!buf) {
8441 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8442 return QDF_STATUS_E_NOMEM;
8443 }
8444 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
8445 WMITLV_SET_HDR(&cmd->tlv_header,
8446 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
8447 WMITLV_GET_STRUCT_TLVLEN
8448 (wmi_wlm_config_cmd_fixed_param));
8449 cmd->vdev_id = params->vdev_id;
8450 cmd->latency_level = params->wlm_latency_level;
8451 cmd->ul_latency = ll[params->wlm_latency_level];
8452 cmd->dl_latency = ll[params->wlm_latency_level];
8453 cmd->flags = params->wlm_latency_flags;
8454 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8455 WMI_WLM_CONFIG_CMDID)) {
8456 WMI_LOGE("%s: Failed to send setting latency config command",
8457 __func__);
8458 wmi_buf_free(buf);
8459 return QDF_STATUS_E_FAILURE;
8460 }
8461
8462 return 0;
8463}
Govind Singh20c5dac2016-03-07 15:33:31 +05308464/**
8465 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8466 * @wmi_handle: wmi handle
8467 * @vdev_id: vdev id
8468 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308469 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308470 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308471static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308472{
8473 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8474 wmi_buf_t buf;
8475 int32_t len = sizeof(*cmd);
8476
Govind Singhb53420c2016-03-09 14:32:57 +05308477 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308478 buf = wmi_buf_alloc(wmi_handle, len);
8479 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308480 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308481 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308482 }
8483 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8484 wmi_buf_data(buf);
8485 WMITLV_SET_HDR(&cmd->tlv_header,
8486 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8487 WMITLV_GET_STRUCT_TLVLEN
8488 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8489 cmd->vdev_id = vdev_id;
8490 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8491 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8492 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308493 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308494 __func__);
8495 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308496 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308497 }
8498
8499 return 0;
8500}
8501
8502/**
8503 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8504 * @wmi_handle: wmi handle
8505 * @vdev_id: vdev id
8506 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308507 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308508 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308509static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308510 uint8_t vdev_id)
8511{
8512 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8513 wmi_buf_t buf;
8514 int32_t len = sizeof(*cmd);
8515
Govind Singhb53420c2016-03-09 14:32:57 +05308516 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308517 buf = wmi_buf_alloc(wmi_handle, len);
8518 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308519 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308520 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308521 }
8522 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8523 WMITLV_SET_HDR(&cmd->tlv_header,
8524 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8525 WMITLV_GET_STRUCT_TLVLEN
8526 (wmi_csa_offload_enable_cmd_fixed_param));
8527 cmd->vdev_id = vdev_id;
8528 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8529 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8530 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308531 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308532 __func__);
8533 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308534 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308535 }
8536
8537 return 0;
8538}
8539
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008540#ifdef WLAN_FEATURE_CIF_CFR
8541/**
8542 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8543 * @wmi_handle: wmi handle
8544 * @data_len: len of dma cfg req
8545 * @data: dma cfg req
8546 *
8547 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8548 */
8549static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8550 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8551{
8552 wmi_buf_t buf;
8553 uint8_t *cmd;
8554 QDF_STATUS ret;
8555
8556 WMITLV_SET_HDR(cfg,
8557 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8558 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8559
8560 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8561 if (!buf) {
8562 WMI_LOGE(FL("wmi_buf_alloc failed"));
8563 return QDF_STATUS_E_FAILURE;
8564 }
8565
8566 cmd = (uint8_t *) wmi_buf_data(buf);
8567 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8568 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8569 sizeof(*cfg));
8570 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8571 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8572 if (QDF_IS_STATUS_ERROR(ret)) {
8573 WMI_LOGE(FL(":wmi cmd send failed"));
8574 wmi_buf_free(buf);
8575 }
8576
8577 return ret;
8578}
8579#endif
8580
Govind Singh20c5dac2016-03-07 15:33:31 +05308581/**
Sathish Kumarf396c722017-11-17 17:30:41 +05308582 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
8583 * @wmi_handle: wmi handle
8584 * @data_len: len of dma cfg req
8585 * @data: dma cfg req
8586 *
8587 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8588 */
8589static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8590 struct direct_buf_rx_cfg_req *cfg)
8591{
8592 wmi_buf_t buf;
8593 wmi_dma_ring_cfg_req_fixed_param *cmd;
8594 QDF_STATUS ret;
8595 int32_t len = sizeof(*cmd);
8596
8597 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8598 if (!buf) {
8599 WMI_LOGE(FL("wmi_buf_alloc failed"));
8600 return QDF_STATUS_E_FAILURE;
8601 }
8602
8603 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
8604
8605 WMITLV_SET_HDR(&cmd->tlv_header,
8606 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
8607 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
8608
8609 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8610 cfg->pdev_id);
8611 cmd->mod_id = cfg->mod_id;
8612 cmd->base_paddr_lo = cfg->base_paddr_lo;
8613 cmd->base_paddr_hi = cfg->base_paddr_hi;
8614 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
8615 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
8616 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
8617 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
8618 cmd->num_elems = cfg->num_elems;
8619 cmd->buf_size = cfg->buf_size;
8620 cmd->num_resp_per_event = cfg->num_resp_per_event;
8621 cmd->event_timeout_ms = cfg->event_timeout_ms;
8622
8623 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
8624 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
8625 "head idx paddr hi %x tail idx paddr lo %x"
8626 "tail idx addr hi %x num elems %d buf size %d num resp %d"
8627 "event timeout %d\n", __func__, cmd->pdev_id,
8628 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
8629 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
8630 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
8631 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
8632 cmd->event_timeout_ms);
8633 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8634 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
8635 if (QDF_IS_STATUS_ERROR(ret)) {
8636 WMI_LOGE(FL(":wmi cmd send failed"));
8637 wmi_buf_free(buf);
8638 }
8639
8640 return ret;
8641}
8642
8643/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008644 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8645 * @wmi_handle: wmi handle
8646 * @start_11d_scan: 11d scan start request parameters
8647 *
8648 * This function request FW to start 11d scan.
8649 *
8650 * Return: QDF status
8651 */
8652static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8653 struct reg_start_11d_scan_req *start_11d_scan)
8654{
8655 wmi_11d_scan_start_cmd_fixed_param *cmd;
8656 int32_t len;
8657 wmi_buf_t buf;
8658 int ret;
8659
8660 len = sizeof(*cmd);
8661 buf = wmi_buf_alloc(wmi_handle, len);
8662 if (!buf) {
8663 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8664 return QDF_STATUS_E_NOMEM;
8665 }
8666
8667 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8668
8669 WMITLV_SET_HDR(&cmd->tlv_header,
8670 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8671 WMITLV_GET_STRUCT_TLVLEN
8672 (wmi_11d_scan_start_cmd_fixed_param));
8673
8674 cmd->vdev_id = start_11d_scan->vdev_id;
8675 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8676 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8677
8678 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8679
8680 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8681 WMI_11D_SCAN_START_CMDID);
8682 if (ret) {
8683 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8684 wmi_buf_free(buf);
8685 return QDF_STATUS_E_FAILURE;
8686 }
8687
8688 return QDF_STATUS_SUCCESS;
8689}
8690
8691/**
8692 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8693 * @wmi_handle: wmi handle
8694 * @start_11d_scan: 11d scan stop request parameters
8695 *
8696 * This function request FW to stop 11d scan.
8697 *
8698 * Return: QDF status
8699 */
8700static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8701 struct reg_stop_11d_scan_req *stop_11d_scan)
8702{
8703 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8704 int32_t len;
8705 wmi_buf_t buf;
8706 int ret;
8707
8708 len = sizeof(*cmd);
8709 buf = wmi_buf_alloc(wmi_handle, len);
8710 if (!buf) {
8711 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8712 return QDF_STATUS_E_NOMEM;
8713 }
8714
8715 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8716
8717 WMITLV_SET_HDR(&cmd->tlv_header,
8718 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8719 WMITLV_GET_STRUCT_TLVLEN
8720 (wmi_11d_scan_stop_cmd_fixed_param));
8721
8722 cmd->vdev_id = stop_11d_scan->vdev_id;
8723
8724 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8725
8726 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8727 WMI_11D_SCAN_STOP_CMDID);
8728 if (ret) {
8729 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8730 wmi_buf_free(buf);
8731 return QDF_STATUS_E_FAILURE;
8732 }
8733
8734 return QDF_STATUS_SUCCESS;
8735}
8736
8737/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308738 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8739 * @wmi_handle: wmi handle
8740 * @startOemDataReq: start request params
8741 *
8742 * Return: CDF status
8743 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308744static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008745 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308746 uint8_t *data)
8747{
8748 wmi_buf_t buf;
8749 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308750 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308751
8752 buf = wmi_buf_alloc(wmi_handle,
8753 (data_len + WMI_TLV_HDR_SIZE));
8754 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308755 WMI_LOGE(FL("wmi_buf_alloc failed"));
8756 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308757 }
8758
8759 cmd = (uint8_t *) wmi_buf_data(buf);
8760
8761 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8762 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308763 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308764 data_len);
8765
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008766 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308767 data_len);
8768
8769 ret = wmi_unified_cmd_send(wmi_handle, buf,
8770 (data_len +
8771 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8772
Govind Singh67922e82016-04-01 16:48:57 +05308773 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308774 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308775 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308776 }
8777
Govind Singh67922e82016-04-01 16:48:57 +05308778 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308779}
8780
8781/**
8782 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8783 * @wmi_handle: wmi handle
8784 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8785 *
8786 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8787 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8788 * to firmware based on phyerr filtering
8789 * offload status.
8790 *
8791 * Return: 1 success, 0 failure
8792 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308793static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308794send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8795 bool dfs_phyerr_filter_offload)
8796{
8797 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8798 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8799 wmi_buf_t buf;
8800 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308801 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308802
8803
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008804 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308805 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308806 __func__);
8807 len = sizeof(*disable_phyerr_offload_cmd);
8808 buf = wmi_buf_alloc(wmi_handle, len);
8809 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308810 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308811 return 0;
8812 }
8813 disable_phyerr_offload_cmd =
8814 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8815 wmi_buf_data(buf);
8816
8817 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8818 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8819 WMITLV_GET_STRUCT_TLVLEN
8820 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8821
8822 /*
8823 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8824 * to the firmware to disable the phyerror
8825 * filtering offload.
8826 */
8827 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8828 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308829 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308830 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308831 __func__, ret);
8832 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308833 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308834 }
Govind Singhb53420c2016-03-09 14:32:57 +05308835 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308836 __func__);
8837 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308838 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308839 __func__);
8840
8841 len = sizeof(*enable_phyerr_offload_cmd);
8842 buf = wmi_buf_alloc(wmi_handle, len);
8843 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308844 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8845 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308846 }
8847
8848 enable_phyerr_offload_cmd =
8849 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8850 wmi_buf_data(buf);
8851
8852 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8853 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8854 WMITLV_GET_STRUCT_TLVLEN
8855 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8856
8857 /*
8858 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8859 * to the firmware to enable the phyerror
8860 * filtering offload.
8861 */
8862 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8863 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8864
Govind Singh67922e82016-04-01 16:48:57 +05308865 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308866 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308867 __func__, ret);
8868 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308869 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308870 }
Govind Singhb53420c2016-03-09 14:32:57 +05308871 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308872 __func__);
8873 }
8874
Govind Singhb53420c2016-03-09 14:32:57 +05308875 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308876}
8877
Naveen Rawata5817e72017-10-26 18:50:19 -07008878/**
8879 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
8880 * will wake up host after specified time is elapsed
8881 * @wmi_handle: wmi handle
8882 * @vdev_id: vdev id
8883 * @cookie: value to identify reason why host set up wake call.
8884 * @time: time in ms
8885 *
8886 * Return: QDF status
8887 */
8888static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8889 uint8_t vdev_id, uint32_t cookie, uint32_t time)
8890{
8891 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
8892 wmi_buf_t buf;
8893 uint8_t *buf_ptr;
8894 int32_t len;
8895 int ret;
8896
8897 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
8898 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
8899 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
8900 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
8901 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05308902 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
8903 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008904
8905 buf = wmi_buf_alloc(wmi_handle, len);
8906 if (!buf) {
8907 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8908 return QDF_STATUS_E_NOMEM;
8909 }
8910
8911 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8912 buf_ptr = (uint8_t *) cmd;
8913
8914 WMITLV_SET_HDR(&cmd->tlv_header,
8915 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
8916 WMITLV_GET_STRUCT_TLVLEN
8917 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
8918 cmd->vdev_id = vdev_id;
8919 cmd->pattern_id = cookie,
8920 cmd->pattern_type = WOW_TIMER_PATTERN;
8921 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
8922
8923 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
8924 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8925 buf_ptr += WMI_TLV_HDR_SIZE;
8926
8927 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
8928 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8929 buf_ptr += WMI_TLV_HDR_SIZE;
8930
8931 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
8932 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8933 buf_ptr += WMI_TLV_HDR_SIZE;
8934
8935 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
8936 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8937 buf_ptr += WMI_TLV_HDR_SIZE;
8938
8939 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05308940 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008941 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308942 *((uint32_t *) buf_ptr) = time;
8943 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008944
8945 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05308946 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008947 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308948 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07008949
8950 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
8951 __func__, time, vdev_id);
8952
8953 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8954 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
8955 if (ret) {
8956 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
8957 __func__);
8958 wmi_buf_free(buf);
8959 return QDF_STATUS_E_FAILURE;
8960 }
8961
8962 return QDF_STATUS_SUCCESS;
8963}
8964
Govind Singh20c5dac2016-03-07 15:33:31 +05308965#if !defined(REMOVE_PKT_LOG)
8966/**
8967 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
8968 * @wmi_handle: wmi handle
8969 * @pktlog_event: pktlog event
8970 * @cmd_id: pktlog cmd id
8971 *
8972 * Return: CDF status
8973 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308974static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308975 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05308976 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05308977{
8978 WMI_PKTLOG_EVENT PKTLOG_EVENT;
8979 WMI_CMD_ID CMD_ID;
8980 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
8981 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
8982 int len = 0;
8983 wmi_buf_t buf;
8984
8985 PKTLOG_EVENT = pktlog_event;
8986 CMD_ID = cmd_id;
8987
8988 switch (CMD_ID) {
8989 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
8990 len = sizeof(*cmd);
8991 buf = wmi_buf_alloc(wmi_handle, len);
8992 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308993 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8994 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308995 }
8996 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
8997 wmi_buf_data(buf);
8998 WMITLV_SET_HDR(&cmd->tlv_header,
8999 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9000 WMITLV_GET_STRUCT_TLVLEN
9001 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9002 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309003 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9004 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309005 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9006 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309007 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9008 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309009 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309010 goto wmi_send_failed;
9011 }
9012 break;
9013 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9014 len = sizeof(*disable_cmd);
9015 buf = wmi_buf_alloc(wmi_handle, len);
9016 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309017 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9018 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309019 }
9020 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9021 wmi_buf_data(buf);
9022 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9023 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9024 WMITLV_GET_STRUCT_TLVLEN
9025 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309026 disable_cmd->pdev_id =
9027 wmi_handle->ops->convert_pdev_id_host_to_target(
9028 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309029 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9030 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309031 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309032 goto wmi_send_failed;
9033 }
9034 break;
9035 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309036 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309037 break;
9038 }
9039
Govind Singhb53420c2016-03-09 14:32:57 +05309040 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309041
9042wmi_send_failed:
9043 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309044 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309045}
9046#endif /* REMOVE_PKT_LOG */
9047
9048/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309049 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9050 * @wmi_handle: wmi handle
9051 * @ptrn_id: pattern id
9052 * @vdev_id: vdev id
9053 *
9054 * Return: CDF status
9055 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309056static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9057 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309058{
9059 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9060 wmi_buf_t buf;
9061 int32_t len;
9062 int ret;
9063
9064 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9065
9066
9067 buf = wmi_buf_alloc(wmi_handle, len);
9068 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309069 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9070 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309071 }
9072
9073 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9074
9075 WMITLV_SET_HDR(&cmd->tlv_header,
9076 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9077 WMITLV_GET_STRUCT_TLVLEN(
9078 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9079 cmd->vdev_id = vdev_id;
9080 cmd->pattern_id = ptrn_id;
9081 cmd->pattern_type = WOW_BITMAP_PATTERN;
9082
Govind Singhb53420c2016-03-09 14:32:57 +05309083 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309084 cmd->pattern_id, vdev_id);
9085
9086 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9087 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9088 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309089 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309090 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309091 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309092 }
9093
Govind Singhb53420c2016-03-09 14:32:57 +05309094 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309095}
9096
9097/**
9098 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9099 * @wmi_handle: wmi handle
9100 *
9101 * Sends host wakeup indication to FW. On receiving this indication,
9102 * FW will come out of WOW.
9103 *
9104 * Return: CDF status
9105 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309106static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309107{
9108 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9109 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309110 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309111 int32_t len;
9112 int ret;
9113
9114 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9115
9116 buf = wmi_buf_alloc(wmi_handle, len);
9117 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309118 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9119 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309120 }
9121
9122 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9123 wmi_buf_data(buf);
9124 WMITLV_SET_HDR(&cmd->tlv_header,
9125 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9126 WMITLV_GET_STRUCT_TLVLEN
9127 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9128
9129
9130 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9131 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9132 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309133 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309134 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309135 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309136 }
9137
Govind Singhb53420c2016-03-09 14:32:57 +05309138 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309139}
9140
9141/**
9142 * send_del_ts_cmd_tlv() - send DELTS request to fw
9143 * @wmi_handle: wmi handle
9144 * @msg: delts params
9145 *
9146 * Return: CDF status
9147 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309148static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309149 uint8_t ac)
9150{
9151 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9152 wmi_buf_t buf;
9153 int32_t len = sizeof(*cmd);
9154
9155 buf = wmi_buf_alloc(wmi_handle, len);
9156 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309157 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9158 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309159 }
9160 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9161 WMITLV_SET_HDR(&cmd->tlv_header,
9162 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9163 WMITLV_GET_STRUCT_TLVLEN
9164 (wmi_vdev_wmm_delts_cmd_fixed_param));
9165 cmd->vdev_id = vdev_id;
9166 cmd->ac = ac;
9167
Govind Singhb53420c2016-03-09 14:32:57 +05309168 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309169 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9170 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9171 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309172 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309173 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309174 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309175 }
9176
Govind Singhb53420c2016-03-09 14:32:57 +05309177 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309178}
9179
9180/**
9181 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9182 * @wmi_handle: handle to wmi
9183 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9184 *
Govind Singhb53420c2016-03-09 14:32:57 +05309185 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309186 * ADD_TS requestes to firmware in loop for all the ACs with
9187 * active flow.
9188 *
9189 * Return: CDF status
9190 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309191static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309192 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9193{
9194 int i = 0;
9195 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9196 wmi_buf_t buf;
9197 int32_t len = sizeof(*cmd);
9198
9199 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9200 /* if flow in this AC is active */
9201 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9202 /*
9203 * as per implementation of wma_add_ts_req() we
9204 * are not waiting any response from firmware so
9205 * apart from sending ADDTS to firmware just send
9206 * success to upper layers
9207 */
Govind Singhb53420c2016-03-09 14:32:57 +05309208 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309209
9210 buf = wmi_buf_alloc(wmi_handle, len);
9211 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309212 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9213 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309214 }
9215 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9216 wmi_buf_data(buf);
9217 WMITLV_SET_HDR(&cmd->tlv_header,
9218 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9219 WMITLV_GET_STRUCT_TLVLEN
9220 (wmi_vdev_wmm_addts_cmd_fixed_param));
9221 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9222 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309223 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309224 traffic.userPrio);
9225 cmd->medium_time_us =
9226 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9227 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309228 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309229 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9230 cmd->medium_time_us, cmd->downgrade_type);
9231 if (wmi_unified_cmd_send
9232 (wmi_handle, buf, len,
9233 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309234 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309235 __func__);
9236 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309237 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309238 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309239 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309240 }
9241 }
9242 }
9243
Govind Singhb53420c2016-03-09 14:32:57 +05309244 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309245}
9246
9247/**
9248 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9249 * @wmi_handle: wmi handle
9250 * @msg: ADDTS params
9251 *
9252 * Return: CDF status
9253 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309254static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309255 struct add_ts_param *msg)
9256{
9257 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9258 wmi_buf_t buf;
9259 int32_t len = sizeof(*cmd);
9260
Govind Singhb53420c2016-03-09 14:32:57 +05309261 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309262
9263 buf = wmi_buf_alloc(wmi_handle, len);
9264 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309265 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9266 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309267 }
9268 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9269 WMITLV_SET_HDR(&cmd->tlv_header,
9270 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9271 WMITLV_GET_STRUCT_TLVLEN
9272 (wmi_vdev_wmm_addts_cmd_fixed_param));
9273 cmd->vdev_id = msg->sme_session_id;
9274 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9275 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9276 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309277 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309278 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9279 cmd->downgrade_type, __func__, __LINE__);
9280 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9281 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309282 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9283 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309284 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309285 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309286 }
9287
Govind Singhb53420c2016-03-09 14:32:57 +05309288 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309289}
9290
9291/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309292 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9293 * @wmi_handle: wmi handle
9294 * @pAddPeriodicTxPtrnParams: tx ptrn params
9295 *
9296 * Retrun: CDF status
9297 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309298static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309299 struct periodic_tx_pattern *
9300 pAddPeriodicTxPtrnParams,
9301 uint8_t vdev_id)
9302{
9303 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9304 wmi_buf_t wmi_buf;
9305 uint32_t len;
9306 uint8_t *buf_ptr;
9307 uint32_t ptrn_len, ptrn_len_aligned;
9308 int j;
9309
9310 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9311 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9312 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9313 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9314
9315 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9316 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309317 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9318 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309319 }
9320
9321 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9322
9323 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9324 WMITLV_SET_HDR(&cmd->tlv_header,
9325 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9326 WMITLV_GET_STRUCT_TLVLEN
9327 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9328
9329 /* Pass the pattern id to delete for the corresponding vdev id */
9330 cmd->vdev_id = vdev_id;
9331 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9332 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9333 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9334
9335 /* Pattern info */
9336 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9337 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9338 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309339 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309340 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309341 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309342
Govind Singhb53420c2016-03-09 14:32:57 +05309343 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309344 __func__, cmd->pattern_id, cmd->vdev_id);
9345
9346 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9347 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309348 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309349 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309350 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309351 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309352 }
Govind Singhb53420c2016-03-09 14:32:57 +05309353 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309354}
9355
9356/**
9357 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9358 * @wmi_handle: wmi handle
9359 * @vdev_id: vdev id
9360 * @pattern_id: pattern id
9361 *
9362 * Retrun: CDF status
9363 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309364static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309365 uint8_t vdev_id,
9366 uint8_t pattern_id)
9367{
9368 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9369 wmi_buf_t wmi_buf;
9370 uint32_t len =
9371 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9372
9373 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9374 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309375 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9376 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309377 }
9378
9379 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9380 wmi_buf_data(wmi_buf);
9381 WMITLV_SET_HDR(&cmd->tlv_header,
9382 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9383 WMITLV_GET_STRUCT_TLVLEN
9384 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9385
9386 /* Pass the pattern id to delete for the corresponding vdev id */
9387 cmd->vdev_id = vdev_id;
9388 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309389 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309390 __func__, cmd->pattern_id, cmd->vdev_id);
9391
9392 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9393 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309394 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309395 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309396 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309397 }
Govind Singhb53420c2016-03-09 14:32:57 +05309398 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309399}
9400
9401/**
9402 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9403 * @wmi_handle: wmi handle
9404 * @preq: stats ext params
9405 *
9406 * Return: CDF status
9407 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309408static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309409 struct stats_ext_params *preq)
9410{
Govind Singh67922e82016-04-01 16:48:57 +05309411 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309412 wmi_req_stats_ext_cmd_fixed_param *cmd;
9413 wmi_buf_t buf;
Pragaspathi Thilagaraj5920a4b2018-05-16 18:51:32 +05309414 size_t len;
Govind Singh20c5dac2016-03-07 15:33:31 +05309415 uint8_t *buf_ptr;
9416
9417 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9418
9419 buf = wmi_buf_alloc(wmi_handle, len);
9420 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309421 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309422 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309423 }
9424
9425 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9426 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9427
9428 WMITLV_SET_HDR(&cmd->tlv_header,
9429 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9430 WMITLV_GET_STRUCT_TLVLEN
9431 (wmi_req_stats_ext_cmd_fixed_param));
9432 cmd->vdev_id = preq->vdev_id;
9433 cmd->data_len = preq->request_data_len;
9434
Govind Singhb53420c2016-03-09 14:32:57 +05309435 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309436 __func__, preq->request_data_len, preq->vdev_id);
9437
9438 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9439 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9440
9441 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309442 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309443
9444 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9445 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309446 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309447 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309448 ret);
9449 wmi_buf_free(buf);
9450 }
9451
9452 return ret;
9453}
9454
9455/**
9456 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9457 * @wmi_handle: wmi handle
9458 * @params: ext wow params
9459 *
9460 * Return:0 for success or error code
9461 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309462static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309463 struct ext_wow_params *params)
9464{
9465 wmi_extwow_enable_cmd_fixed_param *cmd;
9466 wmi_buf_t buf;
9467 int32_t len;
9468 int ret;
9469
9470 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9471 buf = wmi_buf_alloc(wmi_handle, len);
9472 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309473 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9474 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309475 }
9476
9477 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9478
9479 WMITLV_SET_HDR(&cmd->tlv_header,
9480 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9481 WMITLV_GET_STRUCT_TLVLEN
9482 (wmi_extwow_enable_cmd_fixed_param));
9483
9484 cmd->vdev_id = params->vdev_id;
9485 cmd->type = params->type;
9486 cmd->wakeup_pin_num = params->wakeup_pin_num;
9487
Govind Singhb53420c2016-03-09 14:32:57 +05309488 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309489 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9490
9491 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9492 WMI_EXTWOW_ENABLE_CMDID);
9493 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309494 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309495 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309496 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309497 }
9498
Govind Singhb53420c2016-03-09 14:32:57 +05309499 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309500
9501}
9502
9503/**
9504 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9505 * @wmi_handle: wmi handle
9506 * @app_type1_params: app type1 params
9507 *
9508 * Return: CDF status
9509 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309510static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309511 struct app_type1_params *app_type1_params)
9512{
9513 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9514 wmi_buf_t buf;
9515 int32_t len;
9516 int ret;
9517
9518 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9519 buf = wmi_buf_alloc(wmi_handle, len);
9520 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309521 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9522 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309523 }
9524
9525 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9526 wmi_buf_data(buf);
9527
9528 WMITLV_SET_HDR(&cmd->tlv_header,
9529 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9530 WMITLV_GET_STRUCT_TLVLEN
9531 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9532
9533 cmd->vdev_id = app_type1_params->vdev_id;
9534 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9535 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309536 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309537 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309538 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309539 cmd->passwd_len = app_type1_params->pass_length;
9540
Govind Singhb53420c2016-03-09 14:32:57 +05309541 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309542 "identification_id %.8s id_length %u "
9543 "password %.16s pass_length %u",
9544 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9545 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9546
9547 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9548 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9549 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309550 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309551 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309552 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309553 }
9554
Govind Singhb53420c2016-03-09 14:32:57 +05309555 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309556}
9557
9558/**
9559 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9560 * @wmi_handle: wmi handle
9561 * @appType2Params: app type2 params
9562 *
9563 * Return: CDF status
9564 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309565static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309566 struct app_type2_params *appType2Params)
9567{
9568 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9569 wmi_buf_t buf;
9570 int32_t len;
9571 int ret;
9572
9573 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9574 buf = wmi_buf_alloc(wmi_handle, len);
9575 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309576 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9577 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309578 }
9579
9580 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9581 wmi_buf_data(buf);
9582
9583 WMITLV_SET_HDR(&cmd->tlv_header,
9584 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9585 WMITLV_GET_STRUCT_TLVLEN
9586 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9587
9588 cmd->vdev_id = appType2Params->vdev_id;
9589
Govind Singhb53420c2016-03-09 14:32:57 +05309590 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309591 cmd->rc4_key_len = appType2Params->rc4_key_len;
9592
9593 cmd->ip_id = appType2Params->ip_id;
9594 cmd->ip_device_ip = appType2Params->ip_device_ip;
9595 cmd->ip_server_ip = appType2Params->ip_server_ip;
9596
9597 cmd->tcp_src_port = appType2Params->tcp_src_port;
9598 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9599 cmd->tcp_seq = appType2Params->tcp_seq;
9600 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9601
9602 cmd->keepalive_init = appType2Params->keepalive_init;
9603 cmd->keepalive_min = appType2Params->keepalive_min;
9604 cmd->keepalive_max = appType2Params->keepalive_max;
9605 cmd->keepalive_inc = appType2Params->keepalive_inc;
9606
9607 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9608 &cmd->gateway_mac);
9609 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9610 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9611
Govind Singhb53420c2016-03-09 14:32:57 +05309612 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309613 "rc4_key %.16s rc4_key_len %u "
9614 "ip_id %x ip_device_ip %x ip_server_ip %x "
9615 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9616 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9617 "keepalive_max %u keepalive_inc %u "
9618 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9619 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9620 cmd->rc4_key, cmd->rc4_key_len,
9621 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9622 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9623 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9624 cmd->keepalive_max, cmd->keepalive_inc,
9625 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9626
9627 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9628 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9629 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309630 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309631 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309632 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309633 }
9634
Govind Singhb53420c2016-03-09 14:32:57 +05309635 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309636
9637}
9638
9639/**
9640 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9641 * @wmi_handle: wmi handle
9642 * @timer_val: auto shutdown timer value
9643 *
9644 * Return: CDF status
9645 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309646static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309647 uint32_t timer_val)
9648{
Govind Singh67922e82016-04-01 16:48:57 +05309649 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309650 wmi_buf_t buf = NULL;
9651 uint8_t *buf_ptr;
9652 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9653 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9654
Govind Singhb53420c2016-03-09 14:32:57 +05309655 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309656 __func__, timer_val);
9657
9658 buf = wmi_buf_alloc(wmi_handle, len);
9659 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309660 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9661 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309662 }
9663
9664 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9665 wmi_auto_sh_cmd =
9666 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9667 wmi_auto_sh_cmd->timer_value = timer_val;
9668
9669 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9670 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9671 WMITLV_GET_STRUCT_TLVLEN
9672 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9673
9674 status = wmi_unified_cmd_send(wmi_handle, buf,
9675 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309676 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309677 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309678 __func__, status);
9679 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309680 }
9681
Govind Singh67922e82016-04-01 16:48:57 +05309682 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309683}
9684
9685/**
9686 * send_nan_req_cmd_tlv() - to send nan request to target
9687 * @wmi_handle: wmi handle
9688 * @nan_req: request data which will be non-null
9689 *
9690 * Return: CDF status
9691 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309692static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309693 struct nan_req_params *nan_req)
9694{
Govind Singh67922e82016-04-01 16:48:57 +05309695 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309696 wmi_nan_cmd_param *cmd;
9697 wmi_buf_t buf;
9698 uint16_t len = sizeof(*cmd);
9699 uint16_t nan_data_len, nan_data_len_aligned;
9700 uint8_t *buf_ptr;
9701
9702 /*
9703 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9704 * +------------+----------+-----------------------+--------------+
9705 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9706 * +------------+----------+-----------------------+--------------+
9707 */
9708 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309709 WMI_LOGE("%s:nan req is not valid", __func__);
9710 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309711 }
9712 nan_data_len = nan_req->request_data_len;
9713 nan_data_len_aligned = roundup(nan_req->request_data_len,
9714 sizeof(uint32_t));
Naveen Rawatd30dad62018-05-08 09:40:10 -07009715 if (nan_data_len_aligned < nan_req->request_data_len) {
9716 WMI_LOGE("%s: integer overflow while rounding up data_len",
9717 __func__);
9718 return QDF_STATUS_E_FAILURE;
9719 }
9720
9721 if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
9722 WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen",
9723 __func__);
9724 return QDF_STATUS_E_FAILURE;
9725 }
9726
Govind Singh20c5dac2016-03-07 15:33:31 +05309727 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9728 buf = wmi_buf_alloc(wmi_handle, len);
9729 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309730 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9731 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309732 }
9733 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9734 cmd = (wmi_nan_cmd_param *) buf_ptr;
9735 WMITLV_SET_HDR(&cmd->tlv_header,
9736 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9737 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9738 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309739 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309740 __func__, nan_req->request_data_len);
9741 buf_ptr += sizeof(wmi_nan_cmd_param);
9742 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9743 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309744 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309745
9746 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9747 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309748 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309749 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309750 __func__, ret);
9751 wmi_buf_free(buf);
9752 }
9753
9754 return ret;
9755}
9756
9757/**
9758 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9759 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -07009760 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +05309761 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309762 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309763 */
Jeff Johnsona87370f2017-10-04 19:19:20 -07009764static QDF_STATUS
9765send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
9766 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +05309767{
9768 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9769 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309770 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309771
9772 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9773 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309774 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309775 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309776 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309777 }
9778
9779 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309780
9781 WMITLV_SET_HDR(&cmd->tlv_header,
9782 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9783 WMITLV_GET_STRUCT_TLVLEN
9784 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -07009785 cmd->vdev_id = params->vdev_id;
9786 cmd->enable = params->dhcp_offload_enabled;
9787 cmd->num_client = params->dhcp_client_num;
9788 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +05309789 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309790 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309791 sizeof(*cmd),
9792 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309793 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309794 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309795 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309796 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309797 }
Govind Singhb53420c2016-03-09 14:32:57 +05309798 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -07009799 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309800
9801 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309802}
9803
9804/**
9805 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9806 * @wmi_handle: wmi handle
9807 * @flashing: flashing request
9808 *
9809 * Return: CDF status
9810 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309811static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309812 struct flashing_req_params *flashing)
9813{
9814 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309815 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309816 wmi_buf_t buf;
9817 uint8_t *buf_ptr;
9818 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9819
9820 buf = wmi_buf_alloc(wmi_handle, len);
9821 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309822 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309823 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309824 }
9825 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9826 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9827 WMITLV_SET_HDR(&cmd->tlv_header,
9828 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9829 WMITLV_GET_STRUCT_TLVLEN
9830 (wmi_set_led_flashing_cmd_fixed_param));
9831 cmd->pattern_id = flashing->pattern_id;
9832 cmd->led_x0 = flashing->led_x0;
9833 cmd->led_x1 = flashing->led_x1;
9834
9835 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9836 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309837 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309838 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309839 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309840 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309841 }
Govind Singh67922e82016-04-01 16:48:57 +05309842
9843 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309844}
9845
9846/**
9847 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9848 * @wmi_handle: wmi handle
9849 * @ch_avoid_update_req: channel avoid update params
9850 *
9851 * Return: CDF status
9852 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309853static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309854{
Govind Singh67922e82016-04-01 16:48:57 +05309855 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309856 wmi_buf_t buf = NULL;
9857 uint8_t *buf_ptr;
9858 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9859 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9860
9861
9862 buf = wmi_buf_alloc(wmi_handle, len);
9863 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309864 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9865 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309866 }
9867
9868 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9869 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9870 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9871 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9872 WMITLV_GET_STRUCT_TLVLEN
9873 (wmi_chan_avoid_update_cmd_param));
9874
9875 status = wmi_unified_cmd_send(wmi_handle, buf,
9876 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309877 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309878 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309879 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9880 " returned Error %d", status);
9881 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309882 }
9883
Govind Singh67922e82016-04-01 16:48:57 +05309884 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309885}
9886
9887/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309888 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9889 * @wmi_handle: wmi handle
9890 * @param: pointer to pdev regdomain params
9891 *
9892 * Return: 0 for success or error code
9893 */
9894static QDF_STATUS
9895send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9896 struct pdev_set_regdomain_params *param)
9897{
9898 wmi_buf_t buf;
9899 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9900 int32_t len = sizeof(*cmd);
9901
9902
9903 buf = wmi_buf_alloc(wmi_handle, len);
9904 if (!buf) {
9905 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9906 return QDF_STATUS_E_NOMEM;
9907 }
9908 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9909 WMITLV_SET_HDR(&cmd->tlv_header,
9910 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9911 WMITLV_GET_STRUCT_TLVLEN
9912 (wmi_pdev_set_regdomain_cmd_fixed_param));
9913
9914 cmd->reg_domain = param->currentRDinuse;
9915 cmd->reg_domain_2G = param->currentRD2G;
9916 cmd->reg_domain_5G = param->currentRD5G;
9917 cmd->conformance_test_limit_2G = param->ctl_2G;
9918 cmd->conformance_test_limit_5G = param->ctl_5G;
9919 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309920 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9921 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309922
9923 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9924 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9925 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9926 __func__);
9927 wmi_buf_free(buf);
9928 return QDF_STATUS_E_FAILURE;
9929 }
9930
9931 return QDF_STATUS_SUCCESS;
9932}
9933
9934/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309935 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9936 * @wmi_handle: wmi handle
9937 * @reg_dmn: reg domain
9938 * @regdmn2G: 2G reg domain
9939 * @regdmn5G: 5G reg domain
9940 * @ctl2G: 2G test limit
9941 * @ctl5G: 5G test limit
9942 *
9943 * Return: none
9944 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309945static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309946 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309947 uint16_t regdmn5G, uint8_t ctl2G,
9948 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309949{
9950 wmi_buf_t buf;
9951 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9952 int32_t len = sizeof(*cmd);
9953
9954
9955 buf = wmi_buf_alloc(wmi_handle, len);
9956 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309957 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9958 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309959 }
9960 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9961 WMITLV_SET_HDR(&cmd->tlv_header,
9962 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9963 WMITLV_GET_STRUCT_TLVLEN
9964 (wmi_pdev_set_regdomain_cmd_fixed_param));
9965 cmd->reg_domain = reg_dmn;
9966 cmd->reg_domain_2G = regdmn2G;
9967 cmd->reg_domain_5G = regdmn5G;
9968 cmd->conformance_test_limit_2G = ctl2G;
9969 cmd->conformance_test_limit_5G = ctl5G;
9970
9971 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9972 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309973 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309974 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309975 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309976 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309977 }
9978
Govind Singhb53420c2016-03-09 14:32:57 +05309979 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309980}
9981
9982
9983/**
9984 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9985 * @wmi_handle: wmi handle
9986 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9987 *
9988 * This function sets tdls off channel mode
9989 *
9990 * Return: 0 on success; Negative errno otherwise
9991 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309992static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309993 struct tdls_channel_switch_params *chan_switch_params)
9994{
9995 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9996 wmi_buf_t wmi_buf;
9997 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9998
9999 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10000 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010001 WMI_LOGE(FL("wmi_buf_alloc failed"));
10002 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010003 }
10004 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10005 wmi_buf_data(wmi_buf);
10006 WMITLV_SET_HDR(&cmd->tlv_header,
10007 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10008 WMITLV_GET_STRUCT_TLVLEN(
10009 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10010
10011 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10012 &cmd->peer_macaddr);
10013 cmd->vdev_id = chan_switch_params->vdev_id;
10014 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10015 cmd->is_peer_responder = chan_switch_params->is_responder;
10016 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10017 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10018 cmd->offchan_oper_class = chan_switch_params->oper_class;
10019
Govind Singhb53420c2016-03-09 14:32:57 +053010020 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010021 cmd->peer_macaddr.mac_addr31to0,
10022 cmd->peer_macaddr.mac_addr47to32);
10023
Govind Singhb53420c2016-03-09 14:32:57 +053010024 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010025 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10026 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10027 ),
10028 cmd->vdev_id,
10029 cmd->offchan_mode,
10030 cmd->offchan_num,
10031 cmd->offchan_bw_bitmap,
10032 cmd->is_peer_responder,
10033 cmd->offchan_oper_class);
10034
10035 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10036 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010037 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010038 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010039 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010040 }
10041
10042
Govind Singhb53420c2016-03-09 14:32:57 +053010043 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010044}
10045
10046/**
10047 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10048 * @wmi_handle: wmi handle
10049 * @pwmaTdlsparams: TDLS params
10050 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -070010051 * Return: 0 for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010052 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010053static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010054 void *tdls_param, uint8_t tdls_state)
10055{
10056 wmi_tdls_set_state_cmd_fixed_param *cmd;
10057 wmi_buf_t wmi_buf;
10058
10059 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10060 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10061
10062 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10063 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010064 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10065 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010066 }
10067 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10068 WMITLV_SET_HDR(&cmd->tlv_header,
10069 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10070 WMITLV_GET_STRUCT_TLVLEN
10071 (wmi_tdls_set_state_cmd_fixed_param));
10072 cmd->vdev_id = wmi_tdls->vdev_id;
10073 cmd->state = tdls_state;
10074 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10075 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10076 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10077 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10078 cmd->rssi_delta = wmi_tdls->rssi_delta;
10079 cmd->tdls_options = wmi_tdls->tdls_options;
10080 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10081 cmd->tdls_peer_traffic_response_timeout_ms =
10082 wmi_tdls->peer_traffic_response_timeout;
10083 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10084 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10085 cmd->tdls_puapsd_rx_frame_threshold =
10086 wmi_tdls->puapsd_rx_frame_threshold;
10087 cmd->teardown_notification_ms =
10088 wmi_tdls->teardown_notification_ms;
10089 cmd->tdls_peer_kickout_threshold =
10090 wmi_tdls->tdls_peer_kickout_threshold;
10091
Govind Singhb53420c2016-03-09 14:32:57 +053010092 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010093 "notification_interval_ms: %d, "
10094 "tx_discovery_threshold: %d, "
10095 "tx_teardown_threshold: %d, "
10096 "rssi_teardown_threshold: %d, "
10097 "rssi_delta: %d, "
10098 "tdls_options: 0x%x, "
10099 "tdls_peer_traffic_ind_window: %d, "
10100 "tdls_peer_traffic_response_timeout: %d, "
10101 "tdls_puapsd_mask: 0x%x, "
10102 "tdls_puapsd_inactivity_time: %d, "
10103 "tdls_puapsd_rx_frame_threshold: %d, "
10104 "teardown_notification_ms: %d, "
10105 "tdls_peer_kickout_threshold: %d",
10106 __func__, tdls_state, cmd->state,
10107 cmd->notification_interval_ms,
10108 cmd->tx_discovery_threshold,
10109 cmd->tx_teardown_threshold,
10110 cmd->rssi_teardown_threshold,
10111 cmd->rssi_delta,
10112 cmd->tdls_options,
10113 cmd->tdls_peer_traffic_ind_window,
10114 cmd->tdls_peer_traffic_response_timeout_ms,
10115 cmd->tdls_puapsd_mask,
10116 cmd->tdls_puapsd_inactivity_time_ms,
10117 cmd->tdls_puapsd_rx_frame_threshold,
10118 cmd->teardown_notification_ms,
10119 cmd->tdls_peer_kickout_threshold);
10120
10121 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10122 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010123 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010124 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010125 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010126 }
Govind Singhb53420c2016-03-09 14:32:57 +053010127 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010128
Govind Singhb53420c2016-03-09 14:32:57 +053010129 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010130}
10131
10132/**
10133 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10134 * @wmi_handle: wmi handle
10135 * @peerStateParams: TDLS peer state params
10136 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010137 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010138 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010139static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010140 struct tdls_peer_state_params *peerStateParams,
10141 uint32_t *ch_mhz)
10142{
10143 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10144 wmi_tdls_peer_capabilities *peer_cap;
10145 wmi_channel *chan_info;
10146 wmi_buf_t wmi_buf;
10147 uint8_t *buf_ptr;
10148 uint32_t i;
10149 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10150 sizeof(wmi_tdls_peer_capabilities);
10151
10152
10153 len += WMI_TLV_HDR_SIZE +
10154 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10155
10156 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10157 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010158 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10159 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010160 }
10161
10162 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10163 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10164 WMITLV_SET_HDR(&cmd->tlv_header,
10165 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10166 WMITLV_GET_STRUCT_TLVLEN
10167 (wmi_tdls_peer_update_cmd_fixed_param));
10168
10169 cmd->vdev_id = peerStateParams->vdevId;
10170 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10171 &cmd->peer_macaddr);
10172
10173
10174 cmd->peer_state = peerStateParams->peerState;
10175
Govind Singhb53420c2016-03-09 14:32:57 +053010176 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010177 "peer_macaddr.mac_addr31to0: 0x%x, "
10178 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10179 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10180 cmd->peer_macaddr.mac_addr31to0,
10181 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10182
10183 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10184 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10185 WMITLV_SET_HDR(&peer_cap->tlv_header,
10186 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10187 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10188
10189 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10190 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10191 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10192 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10193 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10194 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10195 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10196 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10197
10198 /* Ack and More Data Ack are sent as 0, so no need to set
10199 * but fill SP
10200 */
10201 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10202 peerStateParams->peerCap.peerMaxSp);
10203
10204 peer_cap->buff_sta_support =
10205 peerStateParams->peerCap.peerBuffStaSupport;
10206 peer_cap->off_chan_support =
10207 peerStateParams->peerCap.peerOffChanSupport;
10208 peer_cap->peer_curr_operclass =
10209 peerStateParams->peerCap.peerCurrOperClass;
10210 /* self curr operclass is not being used and so pass op class for
10211 * preferred off chan in it.
10212 */
10213 peer_cap->self_curr_operclass =
10214 peerStateParams->peerCap.opClassForPrefOffChan;
10215 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10216 peer_cap->peer_operclass_len =
10217 peerStateParams->peerCap.peerOperClassLen;
10218
Govind Singhb53420c2016-03-09 14:32:57 +053010219 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010220 __func__, peer_cap->peer_operclass_len);
10221 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10222 peer_cap->peer_operclass[i] =
10223 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010224 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010225 __func__, i, peer_cap->peer_operclass[i]);
10226 }
10227
10228 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10229 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10230 peer_cap->pref_offchan_bw =
10231 peerStateParams->peerCap.prefOffChanBandwidth;
10232
Govind Singhb53420c2016-03-09 14:32:57 +053010233 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010234 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10235 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10236 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10237 " %d, pref_offchan_bw: %d",
10238 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10239 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10240 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10241 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10242 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10243
10244 /* next fill variable size array of peer chan info */
10245 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10246 WMITLV_SET_HDR(buf_ptr,
10247 WMITLV_TAG_ARRAY_STRUC,
10248 sizeof(wmi_channel) *
10249 peerStateParams->peerCap.peerChanLen);
10250 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10251
10252 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10253 WMITLV_SET_HDR(&chan_info->tlv_header,
10254 WMITLV_TAG_STRUC_wmi_channel,
10255 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10256 chan_info->mhz = ch_mhz[i];
10257 chan_info->band_center_freq1 = chan_info->mhz;
10258 chan_info->band_center_freq2 = 0;
10259
Govind Singhb53420c2016-03-09 14:32:57 +053010260 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010261
10262 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10263 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010264 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010265 peerStateParams->peerCap.peerChan[i].chanId,
10266 peerStateParams->peerCap.peerChan[i].dfsSet);
10267 }
10268
10269 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10270 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10271 else
10272 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10273
10274 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10275 peerStateParams->peerCap.
10276 peerChan[i].pwr);
10277
10278 WMI_SET_CHANNEL_REG_POWER(chan_info,
10279 peerStateParams->peerCap.peerChan[i].
10280 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010281 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010282 peerStateParams->peerCap.peerChan[i].pwr);
10283
10284 chan_info++;
10285 }
10286
10287 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10288 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010289 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010290 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010291 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010292 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010293 }
10294
10295
Govind Singhb53420c2016-03-09 14:32:57 +053010296 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010297}
10298
10299/*
Govind Singh20c5dac2016-03-07 15:33:31 +053010300 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10301 * @wmi_handle: Pointer to WMi handle
10302 * @ie_data: Pointer for ie data
10303 *
10304 * This function sends IE information to firmware
10305 *
Govind Singhb53420c2016-03-09 14:32:57 +053010306 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010307 *
10308 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010309static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010310 struct vdev_ie_info_param *ie_info)
10311{
10312 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10313 wmi_buf_t buf;
10314 uint8_t *buf_ptr;
10315 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010316 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010317
10318
10319 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10320 /* Allocate memory for the WMI command */
10321 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10322
10323 buf = wmi_buf_alloc(wmi_handle, len);
10324 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010325 WMI_LOGE(FL("wmi_buf_alloc failed"));
10326 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010327 }
10328
10329 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010330 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010331
10332 /* Populate the WMI command */
10333 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10334
10335 WMITLV_SET_HDR(&cmd->tlv_header,
10336 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10337 WMITLV_GET_STRUCT_TLVLEN(
10338 wmi_vdev_set_ie_cmd_fixed_param));
10339 cmd->vdev_id = ie_info->vdev_id;
10340 cmd->ie_id = ie_info->ie_id;
10341 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010342 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010343
Govind Singhb53420c2016-03-09 14:32:57 +053010344 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010345 ie_info->length, ie_info->vdev_id);
10346
10347 buf_ptr += sizeof(*cmd);
10348 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10349 buf_ptr += WMI_TLV_HDR_SIZE;
10350
Govind Singhb53420c2016-03-09 14:32:57 +053010351 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010352
10353 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10354 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010355 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010356 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010357 wmi_buf_free(buf);
10358 }
10359
10360 return ret;
10361}
10362
Sathish Kumar497bef42017-03-01 14:02:36 +053010363/**
10364 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10365 *
10366 * @param wmi_handle : handle to WMI.
10367 * @param param : pointer to antenna param
10368 *
10369 * This function sends smart antenna enable command to FW
10370 *
10371 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10372 */
10373static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10374 struct smart_ant_enable_params *param)
10375{
10376 /* Send WMI COMMAND to Enable */
10377 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10378 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10379 wmi_buf_t buf;
10380 uint8_t *buf_ptr;
10381 int len = 0;
10382 QDF_STATUS ret;
10383 int loop = 0;
10384
10385 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10386 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10387 buf = wmi_buf_alloc(wmi_handle, len);
10388
10389 if (!buf) {
10390 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10391 return QDF_STATUS_E_NOMEM;
10392 }
10393
10394 buf_ptr = wmi_buf_data(buf);
10395 qdf_mem_zero(buf_ptr, len);
10396 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10397
10398 WMITLV_SET_HDR(&cmd->tlv_header,
10399 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10400 WMITLV_GET_STRUCT_TLVLEN(
10401 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10402
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010403 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10404 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010405 cmd->enable = param->enable;
10406 cmd->mode = param->mode;
10407 cmd->rx_antenna = param->rx_antenna;
10408 cmd->tx_default_antenna = param->rx_antenna;
10409
10410 /* TLV indicating array of structures to follow */
10411 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10412 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10413 WMI_HAL_MAX_SANTENNA *
10414 sizeof(wmi_pdev_smart_ant_gpio_handle));
10415
10416 buf_ptr += WMI_TLV_HDR_SIZE;
10417 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10418
10419 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10420 WMITLV_SET_HDR(&gpio_param->tlv_header,
10421 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10422 WMITLV_GET_STRUCT_TLVLEN(
10423 wmi_pdev_smart_ant_gpio_handle));
10424 if (param->mode == SMART_ANT_MODE_SERIAL) {
10425 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10426 gpio_param->gpio_pin = param->gpio_pin[loop];
10427 gpio_param->gpio_func = param->gpio_func[loop];
10428 } else {
10429 gpio_param->gpio_pin = 0;
10430 gpio_param->gpio_func = 0;
10431 }
10432 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10433 gpio_param->gpio_pin = param->gpio_pin[loop];
10434 gpio_param->gpio_func = param->gpio_func[loop];
10435 }
10436 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010437 gpio_param->pdev_id =
10438 wmi_handle->ops->convert_pdev_id_host_to_target(
10439 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010440 gpio_param++;
10441 }
10442
10443 ret = wmi_unified_cmd_send(wmi_handle,
10444 buf,
10445 len,
10446 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10447
10448 if (ret != 0) {
10449 WMI_LOGE(" %s :WMI Failed\n", __func__);
10450 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10451 cmd->enable,
10452 cmd->mode,
10453 cmd->rx_antenna,
10454 param->gpio_pin[0], param->gpio_pin[1],
10455 param->gpio_pin[2], param->gpio_pin[3],
10456 param->gpio_func[0], param->gpio_func[1],
10457 param->gpio_func[2], param->gpio_func[3],
10458 ret);
10459 wmi_buf_free(buf);
10460 }
10461
10462 return ret;
10463}
10464
10465/**
10466 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10467 *
10468 * @param wmi_handle : handle to WMI.
10469 * @param param : pointer to rx antenna param
10470 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10471 */
10472static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10473 struct smart_ant_rx_ant_params *param)
10474{
10475 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10476 wmi_buf_t buf;
10477 uint8_t *buf_ptr;
10478 uint32_t len;
10479 QDF_STATUS ret;
10480
10481 len = sizeof(*cmd);
10482 buf = wmi_buf_alloc(wmi_handle, len);
10483 WMI_LOGD("%s:\n", __func__);
10484 if (!buf) {
10485 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10486 return QDF_STATUS_E_NOMEM;
10487 }
10488
10489 buf_ptr = wmi_buf_data(buf);
10490 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10491 WMITLV_SET_HDR(&cmd->tlv_header,
10492 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10493 WMITLV_GET_STRUCT_TLVLEN(
10494 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10495 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010496 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10497 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010498
10499 ret = wmi_unified_cmd_send(wmi_handle,
10500 buf,
10501 len,
10502 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10503
10504 if (ret != 0) {
10505 WMI_LOGE(" %s :WMI Failed\n", __func__);
10506 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10507 __func__,
10508 cmd->rx_antenna,
10509 ret);
10510 wmi_buf_free(buf);
10511 }
10512
10513 return ret;
10514}
10515
10516/**
10517 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10518 * @wmi_handle: wmi handle
10519 * @param: pointer to hold ctl table param
10520 *
10521 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10522 */
10523static QDF_STATUS
10524send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10525 struct ctl_table_params *param)
10526{
10527 uint16_t len, ctl_tlv_len;
10528 uint8_t *buf_ptr;
10529 wmi_buf_t buf;
10530 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10531 uint32_t *ctl_array;
10532
10533 if (!param->ctl_array)
10534 return QDF_STATUS_E_FAILURE;
10535
Sathish Kumar497bef42017-03-01 14:02:36 +053010536 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053010537 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053010538 len = sizeof(*cmd) + ctl_tlv_len;
10539
10540 buf = wmi_buf_alloc(wmi_handle, len);
10541 if (!buf) {
10542 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10543 return QDF_STATUS_E_FAILURE;
10544 }
10545
10546 buf_ptr = wmi_buf_data(buf);
10547 qdf_mem_zero(buf_ptr, len);
10548
10549 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10550
10551 WMITLV_SET_HDR(&cmd->tlv_header,
10552 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10553 WMITLV_GET_STRUCT_TLVLEN(
10554 wmi_pdev_set_ctl_table_cmd_fixed_param));
10555 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010556 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10557 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010558
10559 buf_ptr += sizeof(*cmd);
10560 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10561 (cmd->ctl_len));
10562 buf_ptr += WMI_TLV_HDR_SIZE;
10563 ctl_array = (uint32_t *)buf_ptr;
10564
10565 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10566 sizeof(param->ctl_band));
10567 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10568 param->ctl_cmd_len -
10569 sizeof(param->ctl_band));
10570
10571 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10572 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10573 WMI_LOGE("%s:Failed to send command\n", __func__);
10574 wmi_buf_free(buf);
10575 return QDF_STATUS_E_FAILURE;
10576 }
10577
10578 return QDF_STATUS_SUCCESS;
10579}
10580
10581/**
10582 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10583 * @wmi_handle: wmi handle
10584 * @param: pointer to hold mimogain table param
10585 *
10586 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10587 */
10588static QDF_STATUS
10589send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10590 struct mimogain_table_params *param)
10591{
10592 uint16_t len, table_tlv_len;
10593 wmi_buf_t buf;
10594 uint8_t *buf_ptr;
10595 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10596 uint32_t *gain_table;
10597
10598 if (!param->array_gain)
10599 return QDF_STATUS_E_FAILURE;
10600
10601 /* len must be multiple of a single array gain table */
10602 if (param->tbl_len %
10603 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10604 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10605 WMI_LOGE("Array gain table len not correct\n");
10606 return QDF_STATUS_E_FAILURE;
10607 }
10608
10609 table_tlv_len = WMI_TLV_HDR_SIZE +
10610 roundup(param->tbl_len, sizeof(uint32_t));
10611 len = sizeof(*cmd) + table_tlv_len;
10612
10613 buf = wmi_buf_alloc(wmi_handle, len);
10614 if (!buf) {
10615 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10616 return QDF_STATUS_E_FAILURE;
10617 }
10618
10619 buf_ptr = wmi_buf_data(buf);
10620 qdf_mem_zero(buf_ptr, len);
10621
10622 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10623
10624 WMITLV_SET_HDR(&cmd->tlv_header,
10625 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10626 WMITLV_GET_STRUCT_TLVLEN(
10627 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10628
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010629 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10630 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010631 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10632 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10633 param->multichain_gain_bypass);
10634
10635 buf_ptr += sizeof(*cmd);
10636 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10637 (param->tbl_len));
10638 buf_ptr += WMI_TLV_HDR_SIZE;
10639 gain_table = (uint32_t *)buf_ptr;
10640
10641 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10642 param->array_gain,
10643 param->tbl_len);
10644
10645 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10646 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10647 return QDF_STATUS_E_FAILURE;
10648 }
10649
10650 return QDF_STATUS_SUCCESS;
10651}
10652
10653/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010654 * enum packet_power_tlv_flags: target defined
10655 * packet power rate flags for TLV
10656 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
10657 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
10658 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
10659 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
10660 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
10661 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
10662 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
10663 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
10664 * @WMI_TLV_FLAG_STBC: STBC is set
10665 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
10666 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
10667 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
10668 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
10669 * @WMI_TLV_FLAG_RTSENA: RTS enabled
10670 * @WMI_TLV_FLAG_CTSENA: CTS enabled
10671 * @WMI_TLV_FLAG_LDPC: LDPC is set
10672 * @WMI_TLV_FLAG_SGI: Short gaurd interval
10673 * @WMI_TLV_FLAG_SU: SU Data
10674 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
10675 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
10676 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
10677 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
10678 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
10679 *
10680 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
10681 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
10682 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
10683 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
10684 */
10685enum packet_power_tlv_flags {
10686 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
10687 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
10688 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
10689 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
10690 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
10691 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
10692 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
10693 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
10694 WMI_TLV_FLAG_STBC = 0x00000100,
10695 WMI_TLV_FLAG_40MHZ = 0x00000200,
10696 WMI_TLV_FLAG_80MHZ = 0x00000300,
10697 WMI_TLV_FLAG_160MHZ = 0x00000400,
10698 WMI_TLV_FLAG_TXBF = 0x00000800,
10699 WMI_TLV_FLAG_RTSENA = 0x00001000,
10700 WMI_TLV_FLAG_CTSENA = 0x00002000,
10701 WMI_TLV_FLAG_LDPC = 0x00004000,
10702 WMI_TLV_FLAG_SGI = 0x00008000,
10703 WMI_TLV_FLAG_SU = 0x00100000,
10704 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
10705 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
10706 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
10707 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
10708 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
10709
10710 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
10711 WMI_TLV_FLAG_BW_MASK = 0x3,
10712 WMI_TLV_FLAG_BW_SHIFT = 9,
10713 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
10714 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
10715};
10716
10717/**
10718 * convert_to_power_info_rate_flags() - convert packet_power_info_params
10719 * to FW understandable format
10720 * @param: pointer to hold packet power info param
10721 *
10722 * @return FW understandable 32 bit rate flags
10723 */
10724static uint32_t
10725convert_to_power_info_rate_flags(struct packet_power_info_params *param)
10726{
10727 uint32_t rateflags = 0;
10728
10729 if (param->chainmask)
10730 rateflags |=
10731 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
10732 if (param->chan_width)
10733 rateflags |=
10734 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
10735 << WMI_TLV_FLAG_BW_SHIFT);
10736 if (param->su_mu_ofdma)
10737 rateflags |=
10738 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
10739 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
10740 if (param->rate_flags & WMI_HOST_FLAG_STBC)
10741 rateflags |= WMI_TLV_FLAG_STBC;
10742 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
10743 rateflags |= WMI_TLV_FLAG_LDPC;
10744 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
10745 rateflags |= WMI_TLV_FLAG_TXBF;
10746 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
10747 rateflags |= WMI_TLV_FLAG_RTSENA;
10748 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
10749 rateflags |= WMI_TLV_FLAG_CTSENA;
10750 if (param->rate_flags & WMI_HOST_FLAG_SGI)
10751 rateflags |= WMI_TLV_FLAG_SGI;
10752
10753 return rateflags;
10754}
10755
10756/**
Sathish Kumar497bef42017-03-01 14:02:36 +053010757 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10758 * info to fw
10759 * @wmi_handle: wmi handle
10760 * @param: pointer to hold packet power info param
10761 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010762 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053010763 */
10764static QDF_STATUS
10765send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10766 struct packet_power_info_params *param)
10767{
10768 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10769 wmi_buf_t wmibuf;
10770 uint8_t *buf_ptr;
10771 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10772
10773 wmibuf = wmi_buf_alloc(wmi_handle, len);
10774 if (wmibuf == NULL)
10775 return QDF_STATUS_E_NOMEM;
10776
10777 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10778
10779 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10780 WMITLV_SET_HDR(&cmd->tlv_header,
10781 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10782 WMITLV_GET_STRUCT_TLVLEN(
10783 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010784 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10785 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010786 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053010787 cmd->nss = param->nss;
10788 cmd->preamble = param->preamble;
10789 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010790
10791 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
10792 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
10793 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
10794 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
10795
Sathish Kumar497bef42017-03-01 14:02:36 +053010796 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10797 WMI_PDEV_GET_TPC_CMDID)) {
10798 WMI_LOGE(FL("Failed to get tpc command\n"));
10799 wmi_buf_free(wmibuf);
10800 return QDF_STATUS_E_FAILURE;
10801 }
10802
10803 return QDF_STATUS_SUCCESS;
10804}
10805
10806/**
10807 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10808 * @wmi_handle: wmi handle
10809 * @param: pointer to hold config ratemask params
10810 *
10811 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10812 */
10813static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10814 struct config_ratemask_params *param)
10815{
10816 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10817 wmi_buf_t buf;
10818 int32_t len = sizeof(*cmd);
10819
10820 buf = wmi_buf_alloc(wmi_handle, len);
10821 if (!buf) {
10822 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10823 return QDF_STATUS_E_FAILURE;
10824 }
10825 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10826 WMITLV_SET_HDR(&cmd->tlv_header,
10827 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10828 WMITLV_GET_STRUCT_TLVLEN(
10829 wmi_vdev_config_ratemask_cmd_fixed_param));
10830 cmd->vdev_id = param->vdev_id;
10831 cmd->type = param->type;
10832 cmd->mask_lower32 = param->lower32;
10833 cmd->mask_higher32 = param->higher32;
10834 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
10835 param->vdev_id, param->type, param->lower32, param->higher32);
10836
10837 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10838 WMI_VDEV_RATEMASK_CMDID)) {
10839 WMI_LOGE("Seting vdev ratemask failed\n");
10840 wmi_buf_free(buf);
10841 return QDF_STATUS_E_FAILURE;
10842 }
10843
10844 return QDF_STATUS_SUCCESS;
10845}
10846
10847/**
Sathish Kumar6011c742017-11-08 14:49:58 +053010848 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
10849 * @param: param sent from the host side
10850 * @cmd: param to be sent to the fw side
10851 */
10852static inline void copy_custom_aggr_bitmap(
10853 struct set_custom_aggr_size_params *param,
10854 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
10855{
10856 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
10857 param->ac);
10858 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
10859 param->aggr_type);
10860 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10861 param->tx_aggr_size_disable);
10862 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10863 param->rx_aggr_size_disable);
10864 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
10865 param->tx_ac_enable);
10866}
10867
10868/**
10869 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
10870 * @wmi_handle: wmi handle
10871 * @param: pointer to hold custom aggr size params
10872 *
10873 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10874 */
10875static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
10876 wmi_unified_t wmi_handle,
10877 struct set_custom_aggr_size_params *param)
10878{
10879 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
10880 wmi_buf_t buf;
10881 int32_t len = sizeof(*cmd);
10882
10883 buf = wmi_buf_alloc(wmi_handle, len);
10884 if (!buf) {
10885 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10886 return QDF_STATUS_E_FAILURE;
10887 }
10888 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
10889 wmi_buf_data(buf);
10890 WMITLV_SET_HDR(&cmd->tlv_header,
10891 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
10892 WMITLV_GET_STRUCT_TLVLEN(
10893 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
10894 cmd->vdev_id = param->vdev_id;
10895 cmd->tx_aggr_size = param->tx_aggr_size;
10896 cmd->rx_aggr_size = param->rx_aggr_size;
10897 copy_custom_aggr_bitmap(param, cmd);
10898
10899 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
10900 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
10901 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
10902 "tx_ac_enable=0x%X\n",
10903 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
10904 param->ac, param->aggr_type, param->tx_aggr_size_disable,
10905 param->rx_aggr_size_disable, param->tx_ac_enable);
10906
10907 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10908 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
10909 WMI_LOGE("Seting custom aggregation size failed\n");
10910 wmi_buf_free(buf);
10911 return QDF_STATUS_E_FAILURE;
10912 }
10913
10914 return QDF_STATUS_SUCCESS;
10915}
10916
10917/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053010918 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
10919 * @param wmi_handle : handle to WMI.
10920 * @param param : pointer to tx antenna param
10921 *
10922 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10923 */
10924
10925static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
10926 struct set_qdepth_thresh_params *param)
10927{
10928 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
10929 wmi_msduq_qdepth_thresh_update *cmd_update;
10930 wmi_buf_t buf;
10931 int32_t len = 0;
10932 int i;
10933 uint8_t *buf_ptr;
10934 QDF_STATUS ret;
10935
10936 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
10937 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
10938 return QDF_STATUS_E_INVAL;
10939 }
10940
10941 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10942 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
10943 param->num_of_msduq_updates);
10944 buf = wmi_buf_alloc(wmi_handle, len);
10945
10946 if (!buf) {
10947 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10948 return QDF_STATUS_E_NOMEM;
10949 }
10950
10951 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10952 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
10953 buf_ptr;
10954
10955 WMITLV_SET_HDR(&cmd->tlv_header,
10956 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
10957 , WMITLV_GET_STRUCT_TLVLEN(
10958 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
10959
10960 cmd->pdev_id =
10961 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
10962 cmd->vdev_id = param->vdev_id;
10963 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
10964 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
10965
10966 buf_ptr += sizeof(
10967 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
10968 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10969 param->num_of_msduq_updates *
10970 sizeof(wmi_msduq_qdepth_thresh_update));
10971 buf_ptr += WMI_TLV_HDR_SIZE;
10972 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
10973
10974 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
10975 WMITLV_SET_HDR(&cmd_update->tlv_header,
10976 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
10977 WMITLV_GET_STRUCT_TLVLEN(
10978 wmi_msduq_qdepth_thresh_update));
10979 cmd_update->tid_num = param->update_params[i].tid_num;
10980 cmd_update->msduq_update_mask =
10981 param->update_params[i].msduq_update_mask;
10982 cmd_update->qdepth_thresh_value =
10983 param->update_params[i].qdepth_thresh_value;
10984 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
10985 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
10986 " update mask=0x%X thresh val=0x%X\n",
10987 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
10988 cmd->peer_mac_address.mac_addr31to0,
10989 cmd->peer_mac_address.mac_addr47to32,
10990 cmd_update->msduq_update_mask,
10991 cmd_update->qdepth_thresh_value);
10992 cmd_update++;
10993 }
10994
10995 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10996 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
10997
10998 if (ret != 0) {
10999 WMI_LOGE(" %s :WMI Failed\n", __func__);
11000 wmi_buf_free(buf);
11001 }
11002
11003 return ret;
11004}
11005
11006/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011007 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11008 * @wmi_handle: wmi handle
11009 * @param: pointer to hold vap dscp tid map param
11010 *
11011 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11012 */
11013static QDF_STATUS
11014send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11015 struct vap_dscp_tid_map_params *param)
11016{
11017 wmi_buf_t buf;
11018 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11019 int32_t len = sizeof(*cmd);
11020
11021 buf = wmi_buf_alloc(wmi_handle, len);
11022 if (!buf) {
11023 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11024 return QDF_STATUS_E_FAILURE;
11025 }
11026
11027 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11028 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053011029 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053011030
11031 cmd->vdev_id = param->vdev_id;
11032 cmd->enable_override = 0;
11033
11034 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11035 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11036 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11037 WMI_LOGE("Failed to set dscp cmd\n");
11038 wmi_buf_free(buf);
11039 return QDF_STATUS_E_FAILURE;
11040 }
11041
11042 return QDF_STATUS_SUCCESS;
11043}
11044
11045/**
11046 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11047 * @wmi_handle: wmi handle
11048 * @macaddr: vdev mac address
11049 * @param: pointer to hold neigbour rx param
11050 *
11051 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11052 */
11053static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11054 uint8_t macaddr[IEEE80211_ADDR_LEN],
11055 struct set_neighbour_rx_params *param)
11056{
11057 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11058 wmi_buf_t buf;
11059 int32_t len = sizeof(*cmd);
11060
11061 buf = wmi_buf_alloc(wmi_handle, len);
11062 if (!buf) {
11063 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11064 return QDF_STATUS_E_FAILURE;
11065 }
11066 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11067 WMITLV_SET_HDR(&cmd->tlv_header,
11068 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11069 WMITLV_GET_STRUCT_TLVLEN(
11070 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11071 cmd->vdev_id = param->vdev_id;
11072 cmd->bssid_idx = param->idx;
11073 cmd->action = param->action;
11074 cmd->type = param->type;
11075 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11076 cmd->flag = 0;
11077
11078 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11079 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11080 WMI_LOGE("Failed to set neighbour rx param\n");
11081 wmi_buf_free(buf);
11082 return QDF_STATUS_E_FAILURE;
11083 }
11084
11085 return QDF_STATUS_SUCCESS;
11086}
11087
11088/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011089 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011090 * @param wmi_handle : handle to WMI.
11091 * @param macaddr : vdev mac address
11092 * @param param : pointer to tx antenna param
11093 *
11094 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11095 */
11096static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11097 uint8_t macaddr[IEEE80211_ADDR_LEN],
11098 struct smart_ant_tx_ant_params *param)
11099{
11100 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11101 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11102 wmi_buf_t buf;
11103 int32_t len = 0;
11104 int i;
11105 uint8_t *buf_ptr;
11106 QDF_STATUS ret;
11107
11108 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11109 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11110 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11111 buf = wmi_buf_alloc(wmi_handle, len);
11112
11113 if (!buf) {
11114 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11115 return QDF_STATUS_E_NOMEM;
11116 }
11117
11118 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11119 qdf_mem_zero(buf_ptr, len);
11120 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11121
11122 WMITLV_SET_HDR(&cmd->tlv_header,
11123 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11124 WMITLV_GET_STRUCT_TLVLEN(
11125 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11126
11127 cmd->vdev_id = param->vdev_id;
11128 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11129
11130 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11131 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11132 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11133 buf_ptr += WMI_TLV_HDR_SIZE;
11134 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11135
11136 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11137 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11138 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11139 WMITLV_GET_STRUCT_TLVLEN(
11140 wmi_peer_smart_ant_set_tx_antenna_series));
11141 ant_tx_series->antenna_series = param->antenna_array[i];
11142 ant_tx_series++;
11143 }
11144
11145 ret = wmi_unified_cmd_send(wmi_handle,
11146 buf,
11147 len,
11148 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11149
11150 if (ret != 0) {
11151 WMI_LOGE(" %s :WMI Failed\n", __func__);
11152 wmi_buf_free(buf);
11153 }
11154
11155 return ret;
11156}
11157
Sathish Kumar02c3b542017-02-22 17:24:45 +053011158/**
11159 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11160 * @wmi_handle: wmi handle
11161 * @param: pointer to hold ant switch tbl param
11162 *
11163 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11164 */
11165static QDF_STATUS
11166send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11167 struct ant_switch_tbl_params *param)
11168{
11169 uint8_t len;
11170 wmi_buf_t buf;
11171 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11172 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11173 uint8_t *buf_ptr;
11174
11175 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11176 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11177 buf = wmi_buf_alloc(wmi_handle, len);
11178
11179 if (!buf) {
11180 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11181 return QDF_STATUS_E_NOMEM;
11182 }
11183
11184 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11185 qdf_mem_zero(buf_ptr, len);
11186 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11187
11188 WMITLV_SET_HDR(&cmd->tlv_header,
11189 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11190 WMITLV_GET_STRUCT_TLVLEN(
11191 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11192
11193 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11194 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011195 cmd->mac_id =
11196 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011197
11198 /* TLV indicating array of structures to follow */
11199 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11200 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11201 sizeof(wmi_pdev_set_ant_ctrl_chain));
11202 buf_ptr += WMI_TLV_HDR_SIZE;
11203 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11204
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011205 ctrl_chain->pdev_id =
11206 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011207 ctrl_chain->antCtrlChain = param->antCtrlChain;
11208
11209 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11210 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11211 wmi_buf_free(buf);
11212 return QDF_STATUS_E_FAILURE;
11213 }
11214
11215 return QDF_STATUS_SUCCESS;
11216}
11217
11218/**
11219 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11220 * training information function
11221 * @param wmi_handle : handle to WMI.
11222 * @macaddr : vdev mac address
11223 * @param param : pointer to tx antenna param
11224 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11225 */
11226static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11227 wmi_unified_t wmi_handle,
11228 uint8_t macaddr[IEEE80211_ADDR_LEN],
11229 struct smart_ant_training_info_params *param)
11230{
11231 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11232 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11233 wmi_buf_t buf;
11234 uint8_t *buf_ptr;
11235 int32_t len = 0;
11236 QDF_STATUS ret;
11237 int loop;
11238
11239 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11240 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11241 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11242 buf = wmi_buf_alloc(wmi_handle, len);
11243
11244 if (!buf) {
11245 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11246 return QDF_STATUS_E_NOMEM;
11247 }
11248
11249 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11250 qdf_mem_zero(buf_ptr, len);
11251 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11252
11253 WMITLV_SET_HDR(&cmd->tlv_header,
11254 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11255 WMITLV_GET_STRUCT_TLVLEN(
11256 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11257
11258 cmd->vdev_id = param->vdev_id;
11259 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11260 cmd->num_pkts = param->numpkts;
11261
11262 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11263 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11264 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11265 WMI_SMART_ANT_MAX_RATE_SERIES);
11266
11267 buf_ptr += WMI_TLV_HDR_SIZE;
11268 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11269
11270 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11271 WMITLV_SET_HDR(&train_param->tlv_header,
11272 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11273 WMITLV_GET_STRUCT_TLVLEN(
11274 wmi_peer_smart_ant_set_train_antenna_param));
11275 train_param->train_rate_series = param->rate_array[loop];
11276 train_param->train_antenna_series = param->antenna_array[loop];
11277 train_param->rc_flags = 0;
11278 WMI_LOGI(FL("Series number:%d\n"), loop);
11279 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11280 train_param->train_rate_series,
11281 train_param->train_antenna_series);
11282 train_param++;
11283 }
11284
11285 ret = wmi_unified_cmd_send(wmi_handle,
11286 buf,
11287 len,
11288 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11289
11290 if (ret != 0) {
11291 WMI_LOGE(" %s :WMI Failed\n", __func__);
11292 wmi_buf_free(buf);
11293 return QDF_STATUS_E_FAILURE;
11294 }
11295
11296 return ret;
11297}
11298
11299/**
11300 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11301 * configuration function
11302 * @param wmi_handle : handle to WMI.
11303 * @macaddr : vdev mad address
11304 * @param param : pointer to tx antenna param
11305 *
11306 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11307 */
11308static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
11309 wmi_unified_t wmi_handle,
11310 uint8_t macaddr[IEEE80211_ADDR_LEN],
11311 struct smart_ant_node_config_params *param)
11312{
11313 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
11314 wmi_buf_t buf;
11315 uint8_t *buf_ptr;
11316 int32_t len = 0, args_tlv_len;
11317 int ret;
11318 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053011319 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011320
Vivekc5823092018-03-22 23:27:21 +053011321 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011322 len = sizeof(*cmd) + args_tlv_len;
11323
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070011324 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053011325 WMI_LOGE("%s: Can't send a command with %d arguments\n",
11326 __func__, param->args_count);
11327 return QDF_STATUS_E_FAILURE;
11328 }
11329
11330 buf = wmi_buf_alloc(wmi_handle, len);
11331 if (!buf) {
11332 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11333 return QDF_STATUS_E_NOMEM;
11334 }
11335
11336 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
11337 wmi_buf_data(buf);
11338 buf_ptr = (uint8_t *)cmd;
11339 WMITLV_SET_HDR(&cmd->tlv_header,
11340 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
11341 WMITLV_GET_STRUCT_TLVLEN(
11342 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
11343 cmd->vdev_id = param->vdev_id;
11344 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11345 cmd->cmd_id = param->cmd_id;
11346 cmd->args_count = param->args_count;
11347 buf_ptr += sizeof(
11348 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
11349 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053011350 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011351 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053011352 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011353
11354 for (i = 0; i < param->args_count; i++) {
11355 node_config_args[i] = param->args_arr[i];
11356 WMI_LOGI("%d", param->args_arr[i]);
11357 }
11358
11359 ret = wmi_unified_cmd_send(wmi_handle,
11360 buf,
11361 len,
11362 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
11363
11364 if (ret != 0) {
11365 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
11366 __func__, param->cmd_id, macaddr[0],
11367 macaddr[1], macaddr[2], macaddr[3],
11368 macaddr[4], macaddr[5], ret);
11369 wmi_buf_free(buf);
11370 }
11371
11372 return ret;
11373}
11374
11375/**
11376 * send_set_atf_cmd_tlv() - send set atf command to fw
11377 * @wmi_handle: wmi handle
11378 * @param: pointer to set atf param
11379 *
11380 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11381 */
11382static QDF_STATUS
11383send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
11384 struct set_atf_params *param)
11385{
11386 wmi_atf_peer_info *peer_info;
11387 wmi_peer_atf_request_fixed_param *cmd;
11388 wmi_buf_t buf;
11389 uint8_t *buf_ptr;
11390 int i;
11391 int32_t len = 0;
11392 QDF_STATUS retval;
11393
11394 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11395 len += param->num_peers * sizeof(wmi_atf_peer_info);
11396 buf = wmi_buf_alloc(wmi_handle, len);
11397 if (!buf) {
11398 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11399 return QDF_STATUS_E_FAILURE;
11400 }
11401 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11402 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
11403 WMITLV_SET_HDR(&cmd->tlv_header,
11404 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
11405 WMITLV_GET_STRUCT_TLVLEN(
11406 wmi_peer_atf_request_fixed_param));
11407 cmd->num_peers = param->num_peers;
11408
11409 buf_ptr += sizeof(*cmd);
11410 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11411 sizeof(wmi_atf_peer_info) *
11412 cmd->num_peers);
11413 buf_ptr += WMI_TLV_HDR_SIZE;
11414 peer_info = (wmi_atf_peer_info *)buf_ptr;
11415
11416 for (i = 0; i < cmd->num_peers; i++) {
11417 WMITLV_SET_HDR(&peer_info->tlv_header,
11418 WMITLV_TAG_STRUC_wmi_atf_peer_info,
11419 WMITLV_GET_STRUCT_TLVLEN(
11420 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011421 qdf_mem_copy(&(peer_info->peer_macaddr),
11422 &(param->peer_info[i].peer_macaddr),
11423 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011424 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011425 peer_info->vdev_id = param->peer_info[i].vdev_id;
11426 peer_info->pdev_id =
11427 wmi_handle->ops->convert_pdev_id_host_to_target(
11428 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011429 /*
11430 * TLV definition for peer atf request fixed param combines
11431 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11432 * stats and atf extension stats as two different
11433 * implementations.
11434 * Need to discuss with FW on this.
11435 *
11436 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11437 * peer_info->atf_units_reserved =
11438 * param->peer_ext_info[i].atf_index_reserved;
11439 */
11440 peer_info++;
11441 }
11442
11443 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11444 WMI_PEER_ATF_REQUEST_CMDID);
11445
11446 if (retval != QDF_STATUS_SUCCESS) {
11447 WMI_LOGE("%s : WMI Failed\n", __func__);
11448 wmi_buf_free(buf);
11449 }
11450
11451 return retval;
11452}
11453
11454/**
11455 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11456 * @wmi_handle: wmi handle
11457 * @param: pointer to hold fwtest param
11458 *
11459 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11460 */
11461static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11462 struct set_fwtest_params *param)
11463{
11464 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11465 wmi_buf_t buf;
11466 int32_t len = sizeof(*cmd);
11467
11468 buf = wmi_buf_alloc(wmi_handle, len);
11469
11470 if (!buf) {
11471 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11472 return QDF_STATUS_E_FAILURE;
11473 }
11474
11475 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11476 WMITLV_SET_HDR(&cmd->tlv_header,
11477 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11478 WMITLV_GET_STRUCT_TLVLEN(
11479 wmi_fwtest_set_param_cmd_fixed_param));
11480 cmd->param_id = param->arg;
11481 cmd->param_value = param->value;
11482
11483 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11484 WMI_LOGE("Setting FW test param failed\n");
11485 wmi_buf_free(buf);
11486 return QDF_STATUS_E_FAILURE;
11487 }
11488
11489 return QDF_STATUS_SUCCESS;
11490}
11491
11492/**
11493 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11494 * @wmi_handle: wmi handle
11495 * @param: pointer to qboost params
11496 * @macaddr: vdev mac address
11497 *
11498 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11499 */
11500static QDF_STATUS
11501send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11502 uint8_t macaddr[IEEE80211_ADDR_LEN],
11503 struct set_qboost_params *param)
11504{
11505 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11506 wmi_buf_t buf;
11507 int32_t len;
11508 QDF_STATUS ret;
11509
11510 len = sizeof(*cmd);
11511
11512 buf = wmi_buf_alloc(wmi_handle, len);
11513 if (!buf) {
11514 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11515 return QDF_STATUS_E_FAILURE;
11516 }
11517
11518 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11519 WMITLV_SET_HDR(&cmd->tlv_header,
11520 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11521 WMITLV_GET_STRUCT_TLVLEN(
11522 WMI_QBOOST_CFG_CMD_fixed_param));
11523 cmd->vdev_id = param->vdev_id;
11524 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11525 cmd->qb_enable = param->value;
11526
11527 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11528 WMI_QBOOST_CFG_CMDID);
11529
11530 if (ret != 0) {
11531 WMI_LOGE("Setting qboost cmd failed\n");
11532 wmi_buf_free(buf);
11533 }
11534
11535 return ret;
11536}
11537
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011538/**
11539 * send_gpio_config_cmd_tlv() - send gpio config to fw
11540 * @wmi_handle: wmi handle
11541 * @param: pointer to hold gpio config param
11542 *
11543 * Return: 0 for success or error code
11544 */
11545static QDF_STATUS
11546send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
11547 struct gpio_config_params *param)
11548{
11549 wmi_gpio_config_cmd_fixed_param *cmd;
11550 wmi_buf_t buf;
11551 int32_t len;
11552 QDF_STATUS ret;
11553
11554 len = sizeof(*cmd);
11555
11556 /* Sanity Checks */
11557 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
11558 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
11559 return QDF_STATUS_E_FAILURE;
11560 }
11561
11562 buf = wmi_buf_alloc(wmi_handle, len);
11563 if (!buf) {
11564 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11565 return QDF_STATUS_E_FAILURE;
11566 }
11567
11568 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
11569 WMITLV_SET_HDR(&cmd->tlv_header,
11570 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
11571 WMITLV_GET_STRUCT_TLVLEN(
11572 wmi_gpio_config_cmd_fixed_param));
11573 cmd->gpio_num = param->gpio_num;
11574 cmd->input = param->input;
11575 cmd->pull_type = param->pull_type;
11576 cmd->intr_mode = param->intr_mode;
11577
11578 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11579 WMI_GPIO_CONFIG_CMDID);
11580
11581 if (ret != 0) {
11582 WMI_LOGE("Sending GPIO config cmd failed\n");
11583 wmi_buf_free(buf);
11584 }
11585
11586 return ret;
11587}
11588
11589/**
11590 * send_gpio_output_cmd_tlv() - send gpio output to fw
11591 * @wmi_handle: wmi handle
11592 * @param: pointer to hold gpio output param
11593 *
11594 * Return: 0 for success or error code
11595 */
11596static QDF_STATUS
11597send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
11598 struct gpio_output_params *param)
11599{
11600 wmi_gpio_output_cmd_fixed_param *cmd;
11601 wmi_buf_t buf;
11602 int32_t len;
11603 QDF_STATUS ret;
11604
11605 len = sizeof(*cmd);
11606
11607 buf = wmi_buf_alloc(wmi_handle, len);
11608 if (!buf) {
11609 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11610 return QDF_STATUS_E_FAILURE;
11611 }
11612
11613 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
11614 WMITLV_SET_HDR(&cmd->tlv_header,
11615 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
11616 WMITLV_GET_STRUCT_TLVLEN(
11617 wmi_gpio_output_cmd_fixed_param));
11618 cmd->gpio_num = param->gpio_num;
11619 cmd->set = param->set;
11620
11621 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11622 WMI_GPIO_OUTPUT_CMDID);
11623
11624 if (ret != 0) {
11625 WMI_LOGE("Sending GPIO output cmd failed\n");
11626 wmi_buf_free(buf);
11627 }
11628
11629 return ret;
11630
11631}
11632
11633/**
11634 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
11635 *
11636 * @param wmi_handle : handle to WMI.
11637 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11638 */
11639static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
11640{
11641 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
11642 wmi_buf_t buf;
11643 QDF_STATUS ret;
11644 int32_t len;
11645
11646 len = sizeof(*cmd);
11647
11648 buf = wmi_buf_alloc(wmi_handle, len);
11649 if (!buf) {
11650 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11651 return QDF_STATUS_E_FAILURE;
11652 }
11653
11654 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
11655 WMITLV_SET_HDR(&cmd->tlv_header,
11656 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
11657 WMITLV_GET_STRUCT_TLVLEN(
11658 wmi_pdev_dfs_disable_cmd_fixed_param));
11659 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011660 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11661 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011662
11663 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11664 WMI_PDEV_DFS_DISABLE_CMDID);
11665
11666 if (ret != 0) {
11667 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
11668 wmi_buf_free(buf);
11669 }
11670
11671 return ret;
11672}
11673
11674/**
11675 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
11676 *
11677 * @param wmi_handle : handle to WMI.
11678 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11679 */
11680static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11681{
11682 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11683 wmi_buf_t buf;
11684 QDF_STATUS ret;
11685 int32_t len;
11686
11687 len = sizeof(*cmd);
11688
11689 buf = wmi_buf_alloc(wmi_handle, len);
11690 if (!buf) {
11691 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11692 return QDF_STATUS_E_FAILURE;
11693 }
11694
11695 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11696 WMITLV_SET_HDR(&cmd->tlv_header,
11697 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
11698 WMITLV_GET_STRUCT_TLVLEN(
11699 wmi_pdev_dfs_enable_cmd_fixed_param));
11700 /* Reserved for future use */
11701 cmd->reserved0 = 0;
11702
11703 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11704 WMI_PDEV_DFS_ENABLE_CMDID);
11705
11706 if (ret != 0) {
11707 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
11708 wmi_buf_free(buf);
11709 }
11710
11711 return ret;
11712}
11713
11714/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011715 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
11716 * to fw
11717 * @wmi_handle: wmi handle
11718 * @param: pointer to hold periodic chan stats param
11719 *
11720 * Return: 0 for success or error code
11721 */
11722static QDF_STATUS
11723send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
11724 struct periodic_chan_stats_params *param)
11725{
11726 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
11727 wmi_buf_t buf;
11728 QDF_STATUS ret;
11729 int32_t len;
11730
11731 len = sizeof(*cmd);
11732
11733 buf = wmi_buf_alloc(wmi_handle, len);
11734 if (!buf) {
11735 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11736 return QDF_STATUS_E_FAILURE;
11737 }
11738
11739 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
11740 wmi_buf_data(buf);
11741 WMITLV_SET_HDR(&cmd->tlv_header,
11742 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
11743 WMITLV_GET_STRUCT_TLVLEN(
11744 wmi_set_periodic_channel_stats_config_fixed_param));
11745 cmd->enable = param->enable;
11746 cmd->stats_period = param->stats_period;
11747 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11748 param->pdev_id);
11749
11750 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11751 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
11752
11753 if (ret != 0) {
11754 WMI_LOGE("Sending periodic chan stats config failed");
11755 wmi_buf_free(buf);
11756 }
11757
11758 return ret;
11759}
11760
11761/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011762 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
11763 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080011764 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011765 *
11766 * Return: 0 for success or error code
11767 */
11768static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080011769send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011770{
11771 wmi_buf_t buf;
11772 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080011773 wmi_pdev_get_nfcal_power_fixed_param *cmd;
11774 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011775
nobeljf74583b2018-01-25 16:35:36 -080011776 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011777 if (buf == NULL)
11778 return QDF_STATUS_E_NOMEM;
11779
nobeljf74583b2018-01-25 16:35:36 -080011780 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
11781 WMITLV_SET_HDR(&cmd->tlv_header,
11782 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
11783 WMITLV_GET_STRUCT_TLVLEN
11784 (wmi_pdev_get_nfcal_power_fixed_param));
11785 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
11786
11787 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011788 WMI_PDEV_GET_NFCAL_POWER_CMDID);
11789 if (ret != 0) {
11790 WMI_LOGE("Sending get nfcal power cmd failed\n");
11791 wmi_buf_free(buf);
11792 }
11793
11794 return ret;
11795}
11796
11797/**
11798 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
11799 * @wmi_handle: wmi handle
11800 * @param: pointer to ht ie param
11801 *
11802 * Return: 0 for success or error code
11803 */
11804static QDF_STATUS
11805send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11806 struct ht_ie_params *param)
11807{
11808 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
11809 wmi_buf_t buf;
11810 QDF_STATUS ret;
11811 int32_t len;
11812 uint8_t *buf_ptr;
11813
11814 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11815 roundup(param->ie_len, sizeof(uint32_t));
11816
11817 buf = wmi_buf_alloc(wmi_handle, len);
11818 if (!buf) {
11819 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11820 return QDF_STATUS_E_FAILURE;
11821 }
11822
11823 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11824 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
11825 WMITLV_SET_HDR(&cmd->tlv_header,
11826 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
11827 WMITLV_GET_STRUCT_TLVLEN(
11828 wmi_pdev_set_ht_ie_cmd_fixed_param));
11829 cmd->reserved0 = 0;
11830 cmd->ie_len = param->ie_len;
11831 cmd->tx_streams = param->tx_streams;
11832 cmd->rx_streams = param->rx_streams;
11833
11834 buf_ptr += sizeof(*cmd);
11835 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11836 buf_ptr += WMI_TLV_HDR_SIZE;
11837 if (param->ie_len)
11838 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11839 cmd->ie_len);
11840
11841 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11842 WMI_PDEV_SET_HT_CAP_IE_CMDID);
11843
11844 if (ret != 0) {
11845 WMI_LOGE("Sending set ht ie cmd failed\n");
11846 wmi_buf_free(buf);
11847 }
11848
11849 return ret;
11850}
11851
11852/**
11853 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
11854 * @wmi_handle: wmi handle
11855 * @param: pointer to vht ie param
11856 *
11857 * Return: 0 for success or error code
11858 */
11859static QDF_STATUS
11860send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11861 struct vht_ie_params *param)
11862{
11863 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
11864 wmi_buf_t buf;
11865 QDF_STATUS ret;
11866 int32_t len;
11867 uint8_t *buf_ptr;
11868
11869 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11870 roundup(param->ie_len, sizeof(uint32_t));
11871
11872 buf = wmi_buf_alloc(wmi_handle, len);
11873 if (!buf) {
11874 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11875 return QDF_STATUS_E_FAILURE;
11876 }
11877
11878 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11879 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
11880 WMITLV_SET_HDR(&cmd->tlv_header,
11881 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
11882 WMITLV_GET_STRUCT_TLVLEN(
11883 wmi_pdev_set_vht_ie_cmd_fixed_param));
11884 cmd->reserved0 = 0;
11885 cmd->ie_len = param->ie_len;
11886 cmd->tx_streams = param->tx_streams;
11887 cmd->rx_streams = param->rx_streams;
11888
11889 buf_ptr += sizeof(*cmd);
11890 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11891 buf_ptr += WMI_TLV_HDR_SIZE;
11892 if (param->ie_len)
11893 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11894 cmd->ie_len);
11895
11896 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11897 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11898
11899 if (ret != 0) {
11900 WMI_LOGE("Sending set vht ie cmd failed\n");
11901 wmi_buf_free(buf);
11902 }
11903
11904 return ret;
11905}
11906
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011907/**
11908 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11909 * @wmi_handle: wmi handle
11910 * @param: pointer to quiet mode params
11911 *
11912 * Return: 0 for success or error code
11913 */
11914static QDF_STATUS
11915send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11916 struct set_quiet_mode_params *param)
11917{
11918 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11919 wmi_buf_t buf;
11920 QDF_STATUS ret;
11921 int32_t len;
11922
11923 len = sizeof(*quiet_cmd);
11924 buf = wmi_buf_alloc(wmi_handle, len);
11925 if (!buf) {
11926 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11927 return QDF_STATUS_E_FAILURE;
11928 }
11929
11930 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11931 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11932 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11933 WMITLV_GET_STRUCT_TLVLEN(
11934 wmi_pdev_set_quiet_cmd_fixed_param));
11935 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11936 quiet_cmd->enabled = param->enabled;
11937 quiet_cmd->period = (param->period)*(param->intval);
11938 quiet_cmd->duration = param->duration;
11939 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011940 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11941 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011942
11943 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11944 WMI_PDEV_SET_QUIET_MODE_CMDID);
11945
11946 if (ret != 0) {
11947 WMI_LOGE("Sending set quiet cmd failed\n");
11948 wmi_buf_free(buf);
11949 }
11950
11951 return ret;
11952}
11953
11954/**
11955 * send_set_bwf_cmd_tlv() - send set bwf command to fw
11956 * @wmi_handle: wmi handle
11957 * @param: pointer to set bwf param
11958 *
11959 * Return: 0 for success or error code
11960 */
11961static QDF_STATUS
11962send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
11963 struct set_bwf_params *param)
11964{
11965 wmi_bwf_peer_info *peer_info;
11966 wmi_peer_bwf_request_fixed_param *cmd;
11967 wmi_buf_t buf;
11968 QDF_STATUS retval;
11969 int32_t len;
11970 uint8_t *buf_ptr;
11971 int i;
11972
11973 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11974 len += param->num_peers * sizeof(wmi_bwf_peer_info);
11975 buf = wmi_buf_alloc(wmi_handle, len);
11976 if (!buf) {
11977 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11978 return QDF_STATUS_E_FAILURE;
11979 }
11980 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11981 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
11982 WMITLV_SET_HDR(&cmd->tlv_header,
11983 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
11984 WMITLV_GET_STRUCT_TLVLEN(
11985 wmi_peer_bwf_request_fixed_param));
11986 cmd->num_peers = param->num_peers;
11987
11988 buf_ptr += sizeof(*cmd);
11989 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11990 sizeof(wmi_bwf_peer_info) *
11991 cmd->num_peers);
11992 buf_ptr += WMI_TLV_HDR_SIZE;
11993 peer_info = (wmi_bwf_peer_info *)buf_ptr;
11994
11995 for (i = 0; i < cmd->num_peers; i++) {
11996 WMITLV_SET_HDR(&peer_info->tlv_header,
11997 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
11998 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
11999 peer_info->bwf_guaranteed_bandwidth =
12000 param->peer_info[i].throughput;
12001 peer_info->bwf_max_airtime =
12002 param->peer_info[i].max_airtime;
12003 peer_info->bwf_peer_priority =
12004 param->peer_info[i].priority;
12005 qdf_mem_copy(&peer_info->peer_macaddr,
12006 &param->peer_info[i].peer_macaddr,
12007 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012008 peer_info->vdev_id =
12009 param->peer_info[i].vdev_id;
12010 peer_info->pdev_id =
12011 wmi_handle->ops->convert_pdev_id_host_to_target(
12012 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012013 peer_info++;
12014 }
12015
12016 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12017 WMI_PEER_BWF_REQUEST_CMDID);
12018
12019 if (retval != QDF_STATUS_SUCCESS) {
12020 WMI_LOGE("%s : WMI Failed\n", __func__);
12021 wmi_buf_free(buf);
12022 }
12023
12024 return retval;
12025}
12026
12027/**
12028 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12029 * @wmi_handle: wmi handle
12030 * @param: pointer to hold mcast update param
12031 *
12032 * Return: 0 for success or error code
12033 */
12034static QDF_STATUS
12035send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12036 struct mcast_group_update_params *param)
12037{
12038 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12039 wmi_buf_t buf;
12040 QDF_STATUS ret;
12041 int32_t len;
12042 int offset = 0;
12043 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12044
12045 len = sizeof(*cmd);
12046 buf = wmi_buf_alloc(wmi_handle, len);
12047 if (!buf) {
12048 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12049 return QDF_STATUS_E_FAILURE;
12050 }
12051 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12052 WMITLV_SET_HDR(&cmd->tlv_header,
12053 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12054 WMITLV_GET_STRUCT_TLVLEN(
12055 wmi_peer_mcast_group_cmd_fixed_param));
12056 /* confirm the buffer is 4-byte aligned */
12057 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12058 qdf_mem_zero(cmd, sizeof(*cmd));
12059
12060 cmd->vdev_id = param->vap_id;
12061 /* construct the message assuming our endianness matches the target */
12062 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12063 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12064 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12065 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12066 if (param->is_action_delete)
12067 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12068
12069 if (param->is_mcast_addr_len)
12070 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12071
12072 if (param->is_filter_mode_snoop)
12073 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12074
12075 /* unicast address spec only applies for non-wildcard cases */
12076 if (!param->wildcard && param->ucast_mac_addr) {
12077 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12078 &cmd->ucast_mac_addr);
12079 }
Amar Singhal5593c902017-10-03 13:00:29 -070012080
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012081 if (param->mcast_ip_addr) {
12082 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12083 sizeof(cmd->mcast_ip_addr));
12084 offset = sizeof(cmd->mcast_ip_addr) -
12085 param->mcast_ip_addr_bytes;
12086 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12087 param->mcast_ip_addr,
12088 param->mcast_ip_addr_bytes);
12089 }
12090 if (!param->mask)
12091 param->mask = &dummymask[0];
12092
12093 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12094 param->mask,
12095 param->mcast_ip_addr_bytes);
12096
12097 if (param->srcs && param->nsrcs) {
12098 cmd->num_filter_addr = param->nsrcs;
12099 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12100 sizeof(cmd->filter_addr));
12101
12102 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12103 param->nsrcs * param->mcast_ip_addr_bytes);
12104 }
12105
12106 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12107 WMI_PEER_MCAST_GROUP_CMDID);
12108
12109 if (ret != QDF_STATUS_SUCCESS) {
12110 WMI_LOGE("%s : WMI Failed\n", __func__);
12111 wmi_buf_free(buf);
12112 }
12113
12114 return ret;
12115}
12116
12117/**
12118 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12119 * command to fw
12120 * @wmi_handle: wmi handle
12121 * @param: pointer to hold spectral config parameter
12122 *
12123 * Return: 0 for success or error code
12124 */
12125static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12126 struct vdev_spectral_configure_params *param)
12127{
12128 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12129 wmi_buf_t buf;
12130 QDF_STATUS ret;
12131 int32_t len;
12132
12133 len = sizeof(*cmd);
12134 buf = wmi_buf_alloc(wmi_handle, len);
12135 if (!buf) {
12136 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12137 return QDF_STATUS_E_FAILURE;
12138 }
12139
12140 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12141 WMITLV_SET_HDR(&cmd->tlv_header,
12142 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12143 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012144 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012145
12146 cmd->vdev_id = param->vdev_id;
12147 cmd->spectral_scan_count = param->count;
12148 cmd->spectral_scan_period = param->period;
12149 cmd->spectral_scan_priority = param->spectral_pri;
12150 cmd->spectral_scan_fft_size = param->fft_size;
12151 cmd->spectral_scan_gc_ena = param->gc_enable;
12152 cmd->spectral_scan_restart_ena = param->restart_enable;
12153 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12154 cmd->spectral_scan_init_delay = param->init_delay;
12155 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12156 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12157 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12158 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12159 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12160 cmd->spectral_scan_pwr_format = param->pwr_format;
12161 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12162 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012163 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012164 cmd->spectral_scan_chn_mask = param->chn_mask;
12165
12166 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12167 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12168
12169 if (ret != 0) {
12170 WMI_LOGE("Sending set quiet cmd failed\n");
12171 wmi_buf_free(buf);
12172 }
12173
12174 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12175 __func__);
12176
12177 WMI_LOGI("vdev_id = %u\n"
12178 "spectral_scan_count = %u\n"
12179 "spectral_scan_period = %u\n"
12180 "spectral_scan_priority = %u\n"
12181 "spectral_scan_fft_size = %u\n"
12182 "spectral_scan_gc_ena = %u\n"
12183 "spectral_scan_restart_ena = %u\n"
12184 "spectral_scan_noise_floor_ref = %u\n"
12185 "spectral_scan_init_delay = %u\n"
12186 "spectral_scan_nb_tone_thr = %u\n"
12187 "spectral_scan_str_bin_thr = %u\n"
12188 "spectral_scan_wb_rpt_mode = %u\n"
12189 "spectral_scan_rssi_rpt_mode = %u\n"
12190 "spectral_scan_rssi_thr = %u\n"
12191 "spectral_scan_pwr_format = %u\n"
12192 "spectral_scan_rpt_mode = %u\n"
12193 "spectral_scan_bin_scale = %u\n"
12194 "spectral_scan_dBm_adj = %u\n"
12195 "spectral_scan_chn_mask = %u\n",
12196 param->vdev_id,
12197 param->count,
12198 param->period,
12199 param->spectral_pri,
12200 param->fft_size,
12201 param->gc_enable,
12202 param->restart_enable,
12203 param->noise_floor_ref,
12204 param->init_delay,
12205 param->nb_tone_thr,
12206 param->str_bin_thr,
12207 param->wb_rpt_mode,
12208 param->rssi_rpt_mode,
12209 param->rssi_thr,
12210 param->pwr_format,
12211 param->rpt_mode,
12212 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012213 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012214 param->chn_mask);
12215 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12216
12217 return ret;
12218}
12219
12220/**
12221 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12222 * command to fw
12223 * @wmi_handle: wmi handle
12224 * @param: pointer to hold spectral enable parameter
12225 *
12226 * Return: 0 for success or error code
12227 */
12228static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12229 struct vdev_spectral_enable_params *param)
12230{
12231 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12232 wmi_buf_t buf;
12233 QDF_STATUS ret;
12234 int32_t len;
12235
12236 len = sizeof(*cmd);
12237 buf = wmi_buf_alloc(wmi_handle, len);
12238 if (!buf) {
12239 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12240 return QDF_STATUS_E_FAILURE;
12241 }
12242
12243 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12244 WMITLV_SET_HDR(&cmd->tlv_header,
12245 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12246 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012247 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012248
12249 cmd->vdev_id = param->vdev_id;
12250
12251 if (param->active_valid) {
12252 cmd->trigger_cmd = param->active ? 1 : 2;
12253 /* 1: Trigger, 2: Clear Trigger */
12254 } else {
12255 cmd->trigger_cmd = 0; /* 0: Ignore */
12256 }
12257
12258 if (param->enabled_valid) {
12259 cmd->enable_cmd = param->enabled ? 1 : 2;
12260 /* 1: Enable 2: Disable */
12261 } else {
12262 cmd->enable_cmd = 0; /* 0: Ignore */
12263 }
12264
12265 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12266 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12267
12268 if (ret != 0) {
12269 WMI_LOGE("Sending scan enable CMD failed\n");
12270 wmi_buf_free(buf);
12271 }
12272
12273 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12274
12275 WMI_LOGI("vdev_id = %u\n"
12276 "trigger_cmd = %u\n"
12277 "enable_cmd = %u\n",
12278 cmd->vdev_id,
12279 cmd->trigger_cmd,
12280 cmd->enable_cmd);
12281
12282 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12283
12284 return ret;
12285}
12286
12287/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012288 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12289 * @param wmi_handle : handle to WMI.
12290 * @param param : pointer to hold thermal mitigation param
12291 *
12292 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12293 */
12294static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12295 wmi_unified_t wmi_handle,
12296 struct thermal_mitigation_params *param)
12297{
12298 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12299 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12300 wmi_buf_t buf = NULL;
12301 uint8_t *buf_ptr = NULL;
12302 int error;
12303 int32_t len;
12304 int i;
12305
12306 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
12307 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
12308
12309 buf = wmi_buf_alloc(wmi_handle, len);
12310 if (!buf) {
12311 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12312 return QDF_STATUS_E_NOMEM;
12313 }
12314 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
12315
12316 /* init fixed params */
12317 WMITLV_SET_HDR(tt_conf,
12318 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
12319 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
12320
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012321 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12322 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012323 tt_conf->enable = param->enable;
12324 tt_conf->dc = param->dc;
12325 tt_conf->dc_per_event = param->dc_per_event;
12326 tt_conf->therm_throt_levels = THERMAL_LEVELS;
12327
12328 buf_ptr = (uint8_t *) ++tt_conf;
12329 /* init TLV params */
12330 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12331 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
12332
12333 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
12334 for (i = 0; i < THERMAL_LEVELS; i++) {
12335 WMITLV_SET_HDR(&lvl_conf->tlv_header,
12336 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
12337 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
12338 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
12339 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
12340 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
12341 lvl_conf->prio = param->levelconf[i].priority;
12342 lvl_conf++;
12343 }
12344
12345 error = wmi_unified_cmd_send(wmi_handle, buf, len,
12346 WMI_THERM_THROT_SET_CONF_CMDID);
12347 if (QDF_IS_STATUS_ERROR(error)) {
12348 wmi_buf_free(buf);
12349 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
12350 }
12351
12352 return error;
12353}
12354
12355/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012356 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
12357 * @wmi_handle: wmi handle
12358 * @param: pointer to pdev_qvit_params
12359 *
12360 * Return: 0 for success or error code
12361 */
12362static QDF_STATUS
12363send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
12364 struct pdev_qvit_params *param)
12365{
12366 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012367 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012368 uint8_t *cmd;
12369 static uint8_t msgref = 1;
12370 uint8_t segnumber = 0, seginfo, numsegments;
12371 uint16_t chunk_len, total_bytes;
12372 uint8_t *bufpos;
12373 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
12374
12375 bufpos = param->utf_payload;
12376 total_bytes = param->len;
12377 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
12378 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
12379 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
12380
12381 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
12382 numsegments++;
12383
12384 while (param->len) {
12385 if (param->len > MAX_WMI_QVIT_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -070012386 chunk_len = MAX_WMI_QVIT_LEN; /* MAX message */
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012387 else
12388 chunk_len = param->len;
12389
12390 buf = wmi_buf_alloc(wmi_handle,
12391 (chunk_len + sizeof(seghdrinfo) +
12392 WMI_TLV_HDR_SIZE));
12393 if (!buf) {
12394 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12395 return QDF_STATUS_E_NOMEM;
12396 }
12397
12398 cmd = (uint8_t *) wmi_buf_data(buf);
12399
12400 seghdrinfo.len = total_bytes;
12401 seghdrinfo.msgref = msgref;
12402 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
12403 seghdrinfo.segmentInfo = seginfo;
12404
12405 segnumber++;
12406
12407 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
12408 (chunk_len + sizeof(seghdrinfo)));
12409 cmd += WMI_TLV_HDR_SIZE;
12410 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
12411 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
12412
12413 ret = wmi_unified_cmd_send(wmi_handle, buf,
12414 (chunk_len + sizeof(seghdrinfo) +
12415 WMI_TLV_HDR_SIZE),
12416 WMI_PDEV_QVIT_CMDID);
12417
12418 if (ret != 0) {
12419 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
12420 wmi_buf_free(buf);
12421 break;
12422 }
12423
12424 param->len -= chunk_len;
12425 bufpos += chunk_len;
12426 }
12427 msgref++;
12428
12429 return ret;
12430}
12431
12432/**
12433 * send_wmm_update_cmd_tlv() - send wmm update command to fw
12434 * @wmi_handle: wmi handle
12435 * @param: pointer to wmm update param
12436 *
12437 * Return: 0 for success or error code
12438 */
12439static QDF_STATUS
12440send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
12441 struct wmm_update_params *param)
12442{
12443 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
12444 wmi_wmm_params *wmm_param;
12445 wmi_buf_t buf;
12446 QDF_STATUS ret;
12447 int32_t len;
12448 int ac = 0;
12449 struct wmi_host_wmeParams *wmep;
12450 uint8_t *buf_ptr;
12451
12452 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
12453 buf = wmi_buf_alloc(wmi_handle, len);
12454 if (!buf) {
12455 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12456 return QDF_STATUS_E_FAILURE;
12457 }
12458
12459 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12460 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
12461 WMITLV_SET_HDR(&cmd->tlv_header,
12462 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
12463 WMITLV_GET_STRUCT_TLVLEN
12464 (wmi_pdev_set_wmm_params_cmd_fixed_param));
12465
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012466 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012467
12468 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
12469
12470 for (ac = 0; ac < WME_NUM_AC; ac++) {
12471 wmep = &param->wmep_array[ac];
12472 wmm_param = (wmi_wmm_params *)buf_ptr;
12473 WMITLV_SET_HDR(&wmm_param->tlv_header,
12474 WMITLV_TAG_STRUC_wmi_wmm_params,
12475 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
12476 wmm_param->aifs = wmep->wmep_aifsn;
12477 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
12478 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
12479 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
12480 wmm_param->acm = wmep->wmep_acm;
12481 wmm_param->no_ack = wmep->wmep_noackPolicy;
12482 buf_ptr += sizeof(wmi_wmm_params);
12483 }
12484 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12485 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12486
12487 if (ret != 0) {
12488 WMI_LOGE("Sending WMM update CMD failed\n");
12489 wmi_buf_free(buf);
12490 }
12491
12492 return ret;
12493}
12494
Sathish Kumar80f4f382017-04-24 11:36:00 +053012495/**
12496 * send_coex_config_cmd_tlv() - send coex config command to fw
12497 * @wmi_handle: wmi handle
12498 * @param: pointer to coex config param
12499 *
12500 * Return: 0 for success or error code
12501 */
12502static QDF_STATUS
12503send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12504 struct coex_config_params *param)
12505{
12506 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12507 wmi_buf_t buf;
12508 QDF_STATUS ret;
12509 int32_t len;
12510
12511 len = sizeof(*cmd);
12512 buf = wmi_buf_alloc(wmi_handle, len);
12513 if (!buf) {
12514 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12515 return QDF_STATUS_E_FAILURE;
12516 }
12517
12518 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12519 WMITLV_SET_HDR(&cmd->tlv_header,
12520 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12521 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012522 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012523
12524 cmd->vdev_id = param->vdev_id;
12525 cmd->config_type = param->config_type;
12526 cmd->config_arg1 = param->config_arg1;
12527 cmd->config_arg2 = param->config_arg2;
12528 cmd->config_arg3 = param->config_arg3;
12529 cmd->config_arg4 = param->config_arg4;
12530 cmd->config_arg5 = param->config_arg5;
12531 cmd->config_arg6 = param->config_arg6;
12532
12533 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12534 WMI_COEX_CONFIG_CMDID);
12535
12536 if (ret != 0) {
12537 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12538 wmi_buf_free(buf);
12539 }
12540
12541 return ret;
12542}
12543
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012544
12545#ifdef WLAN_SUPPORT_TWT
12546static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12547 target_resource_config *tgt_res_cfg)
12548{
12549 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
12550 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
12551}
12552#else
12553static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12554 target_resource_config *tgt_res_cfg)
12555{
12556 resource_cfg->twt_ap_pdev_count = 0;
12557 resource_cfg->twt_ap_sta_count = 0;
12558}
12559#endif
12560
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012561static
Govind Singh9ddd5162016-03-07 16:30:32 +053012562void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053012563 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053012564{
Govind Singhe7f2f342016-05-23 12:12:52 +053012565 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053012566 resource_cfg->num_peers = tgt_res_cfg->num_peers;
12567 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
12568 resource_cfg->num_offload_reorder_buffs =
12569 tgt_res_cfg->num_offload_reorder_buffs;
12570 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
12571 resource_cfg->num_tids = tgt_res_cfg->num_tids;
12572 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
12573 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
12574 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
12575 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
12576 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
12577 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
12578 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
12579 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
12580 resource_cfg->scan_max_pending_req =
12581 tgt_res_cfg->scan_max_pending_req;
12582 resource_cfg->bmiss_offload_max_vdev =
12583 tgt_res_cfg->bmiss_offload_max_vdev;
12584 resource_cfg->roam_offload_max_vdev =
12585 tgt_res_cfg->roam_offload_max_vdev;
12586 resource_cfg->roam_offload_max_ap_profiles =
12587 tgt_res_cfg->roam_offload_max_ap_profiles;
12588 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
12589 resource_cfg->num_mcast_table_elems =
12590 tgt_res_cfg->num_mcast_table_elems;
12591 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
12592 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
12593 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
12594 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
12595 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
12596 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
12597 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
12598 resource_cfg->vow_config = tgt_res_cfg->vow_config;
12599 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
12600 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
12601 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
12602 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
12603 resource_cfg->num_tdls_conn_table_entries =
12604 tgt_res_cfg->num_tdls_conn_table_entries;
12605 resource_cfg->beacon_tx_offload_max_vdev =
12606 tgt_res_cfg->beacon_tx_offload_max_vdev;
12607 resource_cfg->num_multicast_filter_entries =
12608 tgt_res_cfg->num_multicast_filter_entries;
12609 resource_cfg->num_wow_filters =
12610 tgt_res_cfg->num_wow_filters;
12611 resource_cfg->num_keep_alive_pattern =
12612 tgt_res_cfg->num_keep_alive_pattern;
12613 resource_cfg->keep_alive_pattern_size =
12614 tgt_res_cfg->keep_alive_pattern_size;
12615 resource_cfg->max_tdls_concurrent_sleep_sta =
12616 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
12617 resource_cfg->max_tdls_concurrent_buffer_sta =
12618 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
12619 resource_cfg->wmi_send_separate =
12620 tgt_res_cfg->wmi_send_separate;
12621 resource_cfg->num_ocb_vdevs =
12622 tgt_res_cfg->num_ocb_vdevs;
12623 resource_cfg->num_ocb_channels =
12624 tgt_res_cfg->num_ocb_channels;
12625 resource_cfg->num_ocb_schedules =
12626 tgt_res_cfg->num_ocb_schedules;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053012627 resource_cfg->bpf_instruction_size = tgt_res_cfg->apf_instruction_size;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053012628 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
12629 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012630 resource_cfg->max_num_dbs_scan_duty_cycle =
12631 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080012632 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080012633 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
12634 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012635
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012636 if (tgt_res_cfg->atf_config)
12637 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
12638 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
12639 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
12640 resource_cfg->flag1, 1);
12641 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
12642 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
12643 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053012644 if (tgt_res_cfg->cce_disable)
12645 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012646
12647 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Govind Singh9ddd5162016-03-07 16:30:32 +053012648}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012649
12650/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
12651 * @wmi_handle: pointer to wmi handle
12652 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -070012653 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012654 * @param: point host parameters for init command
12655 *
12656 * Return: Updated pointer of buf_ptr.
12657 */
12658static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
12659 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
12660{
12661 uint16_t idx;
12662
12663 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
12664 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
12665 wmi_pdev_band_to_mac *band_to_mac;
12666
12667 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
12668 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
12669 sizeof(wmi_resource_config) +
12670 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
12671 sizeof(wlan_host_memory_chunk)));
12672
12673 WMITLV_SET_HDR(&hw_mode->tlv_header,
12674 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12675 (WMITLV_GET_STRUCT_TLVLEN
12676 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
12677
12678 hw_mode->hw_mode_index = param->hw_mode_id;
12679 hw_mode->num_band_to_mac = param->num_band_to_mac;
12680
12681 buf_ptr = (uint8_t *) (hw_mode + 1);
12682 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
12683 WMI_TLV_HDR_SIZE);
12684 for (idx = 0; idx < param->num_band_to_mac; idx++) {
12685 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
12686 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
12687 WMITLV_GET_STRUCT_TLVLEN
12688 (wmi_pdev_band_to_mac));
12689 band_to_mac[idx].pdev_id =
12690 wmi_handle->ops->convert_pdev_id_host_to_target(
12691 param->band_to_mac[idx].pdev_id);
12692 band_to_mac[idx].start_freq =
12693 param->band_to_mac[idx].start_freq;
12694 band_to_mac[idx].end_freq =
12695 param->band_to_mac[idx].end_freq;
12696 }
12697 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
12698 (param->num_band_to_mac *
12699 sizeof(wmi_pdev_band_to_mac)) +
12700 WMI_TLV_HDR_SIZE;
12701
12702 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12703 (param->num_band_to_mac *
12704 sizeof(wmi_pdev_band_to_mac)));
12705 }
12706
12707 return buf_ptr;
12708}
12709
12710static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
12711 wmi_init_cmd_fixed_param *cmd)
12712{
12713 int num_whitelist;
12714 wmi_abi_version my_vers;
12715
12716 num_whitelist = sizeof(version_whitelist) /
12717 sizeof(wmi_whitelist_version_info);
12718 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12719 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12720 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12721 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
12722 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
12723 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
12724
12725 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
12726 &my_vers,
12727 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
12728 &cmd->host_abi_vers);
12729
12730 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
12731 __func__,
12732 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
12733 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
12734 cmd->host_abi_vers.abi_version_ns_0,
12735 cmd->host_abi_vers.abi_version_ns_1,
12736 cmd->host_abi_vers.abi_version_ns_2,
12737 cmd->host_abi_vers.abi_version_ns_3);
12738
12739 /* Save version sent from host -
12740 * Will be used to check ready event
12741 */
12742 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
12743 sizeof(wmi_abi_version));
12744}
12745
Sathish Kumarfd347372017-02-13 12:29:09 +053012746static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053012747{
12748 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12749 wmi_service_ready_event_fixed_param *ev;
12750
12751
12752 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12753
12754 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12755 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053012756 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012757
12758 /*Save fw version from service ready message */
12759 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053012760 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012761 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012762
Govind Singhb53420c2016-03-09 14:32:57 +053012763 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012764}
12765
12766/**
12767 * wmi_unified_save_fw_version_cmd() - save fw version
12768 * @wmi_handle: pointer to wmi handle
12769 * @res_cfg: resource config
12770 * @num_mem_chunks: no of mem chunck
12771 * @mem_chunk: pointer to mem chunck structure
12772 *
12773 * This function sends IE information to firmware
12774 *
Govind Singhb53420c2016-03-09 14:32:57 +053012775 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012776 *
12777 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012778static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012779 void *evt_buf)
12780{
12781 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12782 wmi_ready_event_fixed_param *ev = NULL;
12783
12784 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12785 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012786 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
12787 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012788 &ev->fw_abi_vers)) {
12789 /*
12790 * Error: Our host version and the given firmware version
12791 * are incompatible.
12792 **/
Govind Singhb53420c2016-03-09 14:32:57 +053012793 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053012794 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
12795 __func__,
12796 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
12797 abi_version_0),
12798 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
12799 abi_version_0),
12800 wmi_handle->final_abi_vers.abi_version_ns_0,
12801 wmi_handle->final_abi_vers.abi_version_ns_1,
12802 wmi_handle->final_abi_vers.abi_version_ns_2,
12803 wmi_handle->final_abi_vers.abi_version_ns_3,
12804 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
12805 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
12806 ev->fw_abi_vers.abi_version_ns_0,
12807 ev->fw_abi_vers.abi_version_ns_1,
12808 ev->fw_abi_vers.abi_version_ns_2,
12809 ev->fw_abi_vers.abi_version_ns_3);
12810
Govind Singhb53420c2016-03-09 14:32:57 +053012811 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012812 }
Govind Singhb53420c2016-03-09 14:32:57 +053012813 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012814 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053012815 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012816 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053012817
Govind Singhb53420c2016-03-09 14:32:57 +053012818 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012819}
Govind Singha4836fd2016-03-07 16:45:38 +053012820
12821/**
12822 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
12823 * @wmi_handle: wmi handle
12824 * @custom_addr: base mac address
12825 *
Govind Singhe7f2f342016-05-23 12:12:52 +053012826 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053012827 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012828static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012829 uint8_t *custom_addr)
12830{
12831 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
12832 wmi_buf_t buf;
12833 int err;
12834
12835 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12836 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012837 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053012838 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012839 }
12840
12841 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012842 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053012843
12844 WMITLV_SET_HDR(&cmd->tlv_header,
12845 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
12846 WMITLV_GET_STRUCT_TLVLEN
12847 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
12848 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012849 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12850 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012851 err = wmi_unified_cmd_send(wmi_handle, buf,
12852 sizeof(*cmd),
12853 WMI_PDEV_SET_BASE_MACADDR_CMDID);
12854 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053012855 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053012856 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012857 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012858 }
12859
12860 return 0;
12861}
12862
12863/**
12864 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
12865 * @handle: wmi handle
12866 * @event: Event received from FW
12867 * @len: Length of the event
12868 *
12869 * Enables the low frequency events and disables the high frequency
12870 * events. Bit 17 indicates if the event if low/high frequency.
12871 * 1 - high frequency, 0 - low frequency
12872 *
12873 * Return: 0 on successfully enabling/disabling the events
12874 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012875static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012876 uint8_t *event,
12877 uint32_t len)
12878{
12879 uint32_t num_of_diag_events_logs;
12880 wmi_diag_event_log_config_fixed_param *cmd;
12881 wmi_buf_t buf;
12882 uint8_t *buf_ptr;
12883 uint32_t *cmd_args, *evt_args;
12884 uint32_t buf_len, i;
12885
12886 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12887 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12888
Govind Singhb53420c2016-03-09 14:32:57 +053012889 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012890
12891 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12892 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012893 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012894 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012895 }
12896 wmi_event = param_buf->fixed_param;
12897 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070012898
12899 if (num_of_diag_events_logs >
12900 param_buf->num_diag_events_logs_list) {
12901 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
12902 num_of_diag_events_logs,
12903 param_buf->num_diag_events_logs_list);
12904 return QDF_STATUS_E_INVAL;
12905 }
12906
Govind Singha4836fd2016-03-07 16:45:38 +053012907 evt_args = param_buf->diag_events_logs_list;
12908 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012909 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012910 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012911 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012912 }
12913
Govind Singhb53420c2016-03-09 14:32:57 +053012914 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012915 __func__, num_of_diag_events_logs);
12916
12917 /* Free any previous allocation */
12918 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012919 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012920
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070012921 if (num_of_diag_events_logs >
12922 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
12923 WMI_LOGE("%s: excess num of logs:%d", __func__,
12924 num_of_diag_events_logs);
12925 QDF_ASSERT(0);
12926 return QDF_STATUS_E_INVAL;
12927 }
Govind Singha4836fd2016-03-07 16:45:38 +053012928 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012929 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012930 sizeof(uint32_t));
12931 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012932 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012933 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012934 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012935 }
12936 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12937
12938 /* Prepare the send buffer */
12939 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12940 (num_of_diag_events_logs * sizeof(uint32_t));
12941
12942 buf = wmi_buf_alloc(wmi_handle, buf_len);
12943 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012944 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12945 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012946 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012947 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012948 }
12949
12950 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12951 buf_ptr = (uint8_t *) cmd;
12952
12953 WMITLV_SET_HDR(&cmd->tlv_header,
12954 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12955 WMITLV_GET_STRUCT_TLVLEN(
12956 wmi_diag_event_log_config_fixed_param));
12957
12958 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
12959
12960 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12961
12962 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12963 (num_of_diag_events_logs * sizeof(uint32_t)));
12964
12965 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12966
12967 /* Populate the events */
12968 for (i = 0; i < num_of_diag_events_logs; i++) {
12969 /* Low freq (0) - Enable (1) the event
12970 * High freq (1) - Disable (0) the event
12971 */
12972 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
12973 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
12974 /* Set the event ID */
12975 WMI_DIAG_ID_SET(cmd_args[i],
12976 WMI_DIAG_ID_GET(evt_args[i]));
12977 /* Set the type */
12978 WMI_DIAG_TYPE_SET(cmd_args[i],
12979 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053012980 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053012981 wmi_handle->events_logs_list[i] = evt_args[i];
12982 }
12983
12984 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
12985 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012986 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012987 __func__);
12988 wmi_buf_free(buf);
12989 /* Not clearing events_logs_list, though wmi cmd failed.
12990 * Host can still have this list
12991 */
Govind Singh67922e82016-04-01 16:48:57 +053012992 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012993 }
12994
12995 return 0;
12996}
12997
12998/**
12999 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13000 * @wmi_handle: wmi handle
13001 * @start_log: Start logging related parameters
13002 *
13003 * Send the command to the FW based on which specific logging of diag
13004 * event/log id can be started/stopped
13005 *
13006 * Return: None
13007 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013008static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013009 struct wmi_wifi_start_log *start_log)
13010{
13011 wmi_diag_event_log_config_fixed_param *cmd;
13012 wmi_buf_t buf;
13013 uint8_t *buf_ptr;
13014 uint32_t len, count, log_level, i;
13015 uint32_t *cmd_args;
13016 uint32_t total_len;
13017 count = 0;
13018
13019 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013020 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013021 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013022 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013023 }
13024 /* total_len stores the number of events where BITS 17 and 18 are set.
13025 * i.e., events of high frequency (17) and for extended debugging (18)
13026 */
13027 total_len = 0;
13028 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13029 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13030 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13031 total_len++;
13032 }
13033
13034 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13035 (total_len * sizeof(uint32_t));
13036
13037 buf = wmi_buf_alloc(wmi_handle, len);
13038 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013039 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013040 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013041 }
13042 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13043 buf_ptr = (uint8_t *) cmd;
13044
13045 WMITLV_SET_HDR(&cmd->tlv_header,
13046 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13047 WMITLV_GET_STRUCT_TLVLEN(
13048 wmi_diag_event_log_config_fixed_param));
13049
13050 cmd->num_of_diag_events_logs = total_len;
13051
13052 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13053
13054 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13055 (total_len * sizeof(uint32_t)));
13056
13057 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13058
Govind Singh224a7312016-06-21 14:33:26 +053013059 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013060 log_level = 1;
13061 else
13062 log_level = 0;
13063
Govind Singhb53420c2016-03-09 14:32:57 +053013064 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013065 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13066 uint32_t val = wmi_handle->events_logs_list[i];
13067 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13068 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13069
13070 WMI_DIAG_ID_SET(cmd_args[count],
13071 WMI_DIAG_ID_GET(val));
13072 WMI_DIAG_TYPE_SET(cmd_args[count],
13073 WMI_DIAG_TYPE_GET(val));
13074 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13075 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013076 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013077 count++;
13078 }
13079 }
13080
13081 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13082 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013083 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013084 __func__);
13085 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013086 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013087 }
13088
Govind Singhb53420c2016-03-09 14:32:57 +053013089 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013090}
13091
13092/**
13093 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13094 * @wmi_handle: WMI handle
13095 *
13096 * This function is used to send the flush command to the FW,
13097 * that will flush the fw logs that are residue in the FW
13098 *
13099 * Return: None
13100 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013101static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013102{
13103 wmi_debug_mesg_flush_fixed_param *cmd;
13104 wmi_buf_t buf;
13105 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013106 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013107
13108 buf = wmi_buf_alloc(wmi_handle, len);
13109 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013110 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013111 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013112 }
13113
13114 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13115 WMITLV_SET_HDR(&cmd->tlv_header,
13116 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13117 WMITLV_GET_STRUCT_TLVLEN(
13118 wmi_debug_mesg_flush_fixed_param));
13119 cmd->reserved0 = 0;
13120
13121 ret = wmi_unified_cmd_send(wmi_handle,
13122 buf,
13123 len,
13124 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013125 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013126 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013127 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013128 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013129 }
Govind Singhb53420c2016-03-09 14:32:57 +053013130 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013131
Govind Singh67922e82016-04-01 16:48:57 +053013132 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013133}
13134
13135/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013136 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013137 * @wmi_handle: wmi handle
13138 * @msg: PCL structure containing the PCL and the number of channels
13139 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013140 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013141 * firmware. The DBS Manager is the consumer of this information in the WLAN
13142 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13143 * to migrate to a new channel without host driver involvement. An example of
13144 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13145 * manage the channel selection without firmware involvement.
13146 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013147 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13148 * channel list. The weights corresponds to the channels sent in
13149 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13150 * weightage compared to the non PCL channels.
13151 *
Govind Singha4836fd2016-03-07 16:45:38 +053013152 * Return: Success if the cmd is sent successfully to the firmware
13153 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013154static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013155 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013156{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013157 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013158 wmi_buf_t buf;
13159 uint8_t *buf_ptr;
13160 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013161 uint32_t chan_len;
13162
13163 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013164
13165 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013166 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013167
13168 buf = wmi_buf_alloc(wmi_handle, len);
13169 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013170 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13171 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013172 }
13173
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013174 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013175 buf_ptr = (uint8_t *) cmd;
13176 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013177 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13178 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013179
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013180 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13181 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013182 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013183 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013184
13185 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013186 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013187 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013188 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013189 for (i = 0; i < chan_len ; i++) {
13190 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013191 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013192 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013193 }
13194 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013195 WMI_PDEV_SET_PCL_CMDID)) {
13196 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013197 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013198 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013199 }
Govind Singhb53420c2016-03-09 14:32:57 +053013200 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013201}
13202
13203/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013204 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013205 * @wmi_handle: wmi handle
13206 * @msg: Structure containing the following parameters
13207 *
13208 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13209 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13210 *
13211 * Provides notification to the WLAN firmware that host driver is requesting a
13212 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13213 * configurations that include the Dual Band Simultaneous (DBS) feature.
13214 *
13215 * Return: Success if the cmd is sent successfully to the firmware
13216 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013217static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013218 uint32_t hw_mode_index)
13219{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013220 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013221 wmi_buf_t buf;
13222 uint32_t len;
13223
13224 len = sizeof(*cmd);
13225
13226 buf = wmi_buf_alloc(wmi_handle, len);
13227 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013228 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13229 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013230 }
13231
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013232 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013233 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013234 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13235 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13236
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013237 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13238 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013239 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013240 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013241
13242 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013243 WMI_PDEV_SET_HW_MODE_CMDID)) {
13244 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013245 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013246 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013247 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013248 }
13249
Govind Singhb53420c2016-03-09 14:32:57 +053013250 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013251}
13252
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013253#ifdef WLAN_POLICY_MGR_ENABLE
Govind Singha4836fd2016-03-07 16:45:38 +053013254/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013255 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013256 * @wmi_handle: wmi handle
13257 * @msg: Dual MAC config parameters
13258 *
13259 * Configures WLAN firmware with the dual MAC features
13260 *
Govind Singhb53420c2016-03-09 14:32:57 +053013261 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013262 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013263static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013264QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013265 struct policy_mgr_dual_mac_config *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013266{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013267 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013268 wmi_buf_t buf;
13269 uint32_t len;
13270
13271 len = sizeof(*cmd);
13272
13273 buf = wmi_buf_alloc(wmi_handle, len);
13274 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013275 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13276 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013277 }
13278
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013279 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013280 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013281 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013282 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013283 wmi_pdev_set_mac_config_cmd_fixed_param));
13284
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013285 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13286 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013287 cmd->concurrent_scan_config_bits = msg->scan_config;
13288 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013289 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013290 __func__, msg->scan_config, msg->fw_mode_config);
13291
13292 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013293 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13294 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013295 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013296 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013297 }
Govind Singhb53420c2016-03-09 14:32:57 +053013298 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013299}
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013300#endif
Govind Singha4836fd2016-03-07 16:45:38 +053013301
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013302#ifdef BIG_ENDIAN_HOST
13303/**
13304* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13305* @param data_len - data length
13306* @param data - pointer to data
13307*
13308* Return: QDF_STATUS - success or error status
13309*/
13310static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13311 struct fips_params *param)
13312{
13313 unsigned char *key_unaligned, *data_unaligned;
13314 int c;
13315 u_int8_t *key_aligned = NULL;
13316 u_int8_t *data_aligned = NULL;
13317
13318 /* Assigning unaligned space to copy the key */
13319 key_unaligned = qdf_mem_malloc(
13320 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13321 data_unaligned = qdf_mem_malloc(
13322 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13323
Jeff Johnsonda263992018-05-12 14:22:00 -070013324 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013325 if (key_unaligned == NULL)
13326 return QDF_STATUS_SUCCESS;
13327 /* Checking if space is aligned */
13328 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
13329 /* align to 4 */
13330 key_aligned =
13331 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
13332 FIPS_ALIGN);
13333 } else {
13334 key_aligned = (u_int8_t *)key_unaligned;
13335 }
13336
13337 /* memset and copy content from key to key aligned */
13338 OS_MEMSET(key_aligned, 0, param->key_len);
13339 OS_MEMCPY(key_aligned, param->key, param->key_len);
13340
13341 /* print a hexdump for host debug */
13342 print_hex_dump(KERN_DEBUG,
13343 "\t Aligned and Copied Key:@@@@ ",
13344 DUMP_PREFIX_NONE,
13345 16, 1, key_aligned, param->key_len, true);
13346
Jeff Johnsonda263992018-05-12 14:22:00 -070013347 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013348 if (data_unaligned == NULL)
13349 return QDF_STATUS_SUCCESS;
13350 /* Checking of space is aligned */
13351 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13352 /* align to 4 */
13353 data_aligned =
13354 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
13355 FIPS_ALIGN);
13356 } else {
13357 data_aligned = (u_int8_t *)data_unaligned;
13358 }
13359
13360 /* memset and copy content from data to data aligned */
13361 OS_MEMSET(data_aligned, 0, param->data_len);
13362 OS_MEMCPY(data_aligned, param->data, param->data_len);
13363
13364 /* print a hexdump for host debug */
13365 print_hex_dump(KERN_DEBUG,
13366 "\t Properly Aligned and Copied Data:@@@@ ",
13367 DUMP_PREFIX_NONE,
13368 16, 1, data_aligned, param->data_len, true);
13369
13370 /* converting to little Endian both key_aligned and
13371 * data_aligned*/
13372 for (c = 0; c < param->key_len/4; c++) {
13373 *((u_int32_t *)key_aligned+c) =
13374 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
13375 }
13376 for (c = 0; c < param->data_len/4; c++) {
13377 *((u_int32_t *)data_aligned+c) =
13378 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
13379 }
13380
13381 /* update endian data to key and data vectors */
13382 OS_MEMCPY(param->key, key_aligned, param->key_len);
13383 OS_MEMCPY(param->data, data_aligned, param->data_len);
13384
13385 /* clean up allocated spaces */
13386 qdf_mem_free(key_unaligned);
13387 key_unaligned = NULL;
13388 key_aligned = NULL;
13389
13390 qdf_mem_free(data_unaligned);
13391 data_unaligned = NULL;
13392 data_aligned = NULL;
13393
13394 return QDF_STATUS_SUCCESS;
13395}
13396#else
13397/**
13398* fips_align_data_be() - DUMMY for LE platform
13399*
13400* Return: QDF_STATUS - success
13401*/
13402static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13403 struct fips_params *param)
13404{
13405 return QDF_STATUS_SUCCESS;
13406}
13407#endif
13408
13409
13410/**
13411 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
13412 * @wmi_handle: wmi handle
13413 * @param: pointer to hold pdev fips param
13414 *
13415 * Return: 0 for success or error code
13416 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013417static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013418send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
13419 struct fips_params *param)
13420{
13421 wmi_pdev_fips_cmd_fixed_param *cmd;
13422 wmi_buf_t buf;
13423 uint8_t *buf_ptr;
13424 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
13425 QDF_STATUS retval = QDF_STATUS_SUCCESS;
13426
13427 /* Length TLV placeholder for array of bytes */
13428 len += WMI_TLV_HDR_SIZE;
13429 if (param->data_len)
13430 len += (param->data_len*sizeof(uint8_t));
13431
13432 /*
13433 * Data length must be multiples of 16 bytes - checked against 0xF -
13434 * and must be less than WMI_SVC_MSG_SIZE - static size of
13435 * wmi_pdev_fips_cmd structure
13436 */
13437
13438 /* do sanity on the input */
13439 if (!(((param->data_len & 0xF) == 0) &&
13440 ((param->data_len > 0) &&
13441 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
13442 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
13443 return QDF_STATUS_E_INVAL;
13444 }
13445
13446 buf = wmi_buf_alloc(wmi_handle, len);
13447 if (!buf) {
13448 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
13449 return QDF_STATUS_E_FAILURE;
13450 }
13451
13452 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13453 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
13454 WMITLV_SET_HDR(&cmd->tlv_header,
13455 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
13456 WMITLV_GET_STRUCT_TLVLEN
13457 (wmi_pdev_fips_cmd_fixed_param));
13458
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013459 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13460 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013461 if (param->key != NULL && param->data != NULL) {
13462 cmd->key_len = param->key_len;
13463 cmd->data_len = param->data_len;
13464 cmd->fips_cmd = !!(param->op);
13465
13466 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13467 return QDF_STATUS_E_FAILURE;
13468
13469 qdf_mem_copy(cmd->key, param->key, param->key_len);
13470
13471 if (param->mode == FIPS_ENGINE_AES_CTR ||
13472 param->mode == FIPS_ENGINE_AES_MIC) {
13473 cmd->mode = param->mode;
13474 } else {
13475 cmd->mode = FIPS_ENGINE_AES_CTR;
13476 }
13477 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
13478 cmd->key_len, cmd->data_len);
13479
13480 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13481 cmd->key, cmd->key_len, true);
13482 buf_ptr += sizeof(*cmd);
13483
13484 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13485
13486 buf_ptr += WMI_TLV_HDR_SIZE;
13487 if (param->data_len)
13488 qdf_mem_copy(buf_ptr,
13489 (uint8_t *) param->data, param->data_len);
13490
13491 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13492 16, 1, buf_ptr, cmd->data_len, true);
13493
13494 buf_ptr += param->data_len;
13495
13496 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13497 WMI_PDEV_FIPS_CMDID);
13498 qdf_print("%s return value %d\n", __func__, retval);
13499 } else {
13500 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
13501 wmi_buf_free(buf);
13502 retval = -QDF_STATUS_E_BADMSG;
13503 }
13504
13505 return retval;
13506}
13507
Wu Gao52c0b772018-05-17 16:14:00 +080013508#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013509/**
13510 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13511 * @wmi_handle: wmi handle
13512 * @vdev_id: vdev id
13513 * @bitmap: Event bitmap
13514 * @enable: enable/disable
13515 *
13516 * Return: CDF status
13517 */
13518static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13519 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013520 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013521 bool enable)
13522{
13523 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13524 uint16_t len;
13525 wmi_buf_t buf;
13526 int ret;
13527
13528 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13529 buf = wmi_buf_alloc(wmi_handle, len);
13530 if (!buf) {
13531 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13532 return QDF_STATUS_E_NOMEM;
13533 }
13534 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13535 WMITLV_SET_HDR(&cmd->tlv_header,
13536 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13537 WMITLV_GET_STRUCT_TLVLEN
13538 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13539 cmd->vdev_id = vdev_id;
13540 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013541 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13542 WMI_WOW_MAX_EVENT_BM_LEN);
13543
13544 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13545 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13546 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013547
13548 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13549 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13550 if (ret) {
13551 WMI_LOGE("Failed to config wow wakeup event");
13552 wmi_buf_free(buf);
13553 return QDF_STATUS_E_FAILURE;
13554 }
13555
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013556 return QDF_STATUS_SUCCESS;
13557}
13558
13559/**
13560 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13561 * @wmi_handle: wmi handle
13562 * @vdev_id: vdev id
13563 * @ptrn_id: pattern id
13564 * @ptrn: pattern
13565 * @ptrn_len: pattern length
13566 * @ptrn_offset: pattern offset
13567 * @mask: mask
13568 * @mask_len: mask length
13569 * @user: true for user configured pattern and false for default pattern
13570 * @default_patterns: default patterns
13571 *
13572 * Return: CDF status
13573 */
13574static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
13575 uint8_t vdev_id, uint8_t ptrn_id,
13576 const uint8_t *ptrn, uint8_t ptrn_len,
13577 uint8_t ptrn_offset, const uint8_t *mask,
13578 uint8_t mask_len, bool user,
13579 uint8_t default_patterns)
13580{
13581 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13582 WOW_BITMAP_PATTERN_T *bitmap_pattern;
13583 wmi_buf_t buf;
13584 uint8_t *buf_ptr;
13585 int32_t len;
13586 int ret;
13587
13588 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13589 WMI_TLV_HDR_SIZE +
13590 1 * sizeof(WOW_BITMAP_PATTERN_T) +
13591 WMI_TLV_HDR_SIZE +
13592 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13593 WMI_TLV_HDR_SIZE +
13594 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13595 WMI_TLV_HDR_SIZE +
13596 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13597 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053013598 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013599
13600 buf = wmi_buf_alloc(wmi_handle, len);
13601 if (!buf) {
13602 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13603 return QDF_STATUS_E_NOMEM;
13604 }
13605
13606 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13607 buf_ptr = (uint8_t *) cmd;
13608
13609 WMITLV_SET_HDR(&cmd->tlv_header,
13610 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13611 WMITLV_GET_STRUCT_TLVLEN
13612 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13613 cmd->vdev_id = vdev_id;
13614 cmd->pattern_id = ptrn_id;
13615
13616 cmd->pattern_type = WOW_BITMAP_PATTERN;
13617 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13618
13619 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13620 sizeof(WOW_BITMAP_PATTERN_T));
13621 buf_ptr += WMI_TLV_HDR_SIZE;
13622 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
13623
13624 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
13625 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
13626 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
13627
13628 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
13629 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
13630
13631 bitmap_pattern->pattern_offset = ptrn_offset;
13632 bitmap_pattern->pattern_len = ptrn_len;
13633
13634 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
13635 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
13636
13637 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
13638 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
13639
13640 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
13641 bitmap_pattern->pattern_id = ptrn_id;
13642
13643 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
13644 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
13645 bitmap_pattern->pattern_offset, user);
13646 WMI_LOGI("Pattern : ");
13647 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13648 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
13649
13650 WMI_LOGI("Mask : ");
13651 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13652 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
13653
13654 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
13655
13656 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13657 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13658 buf_ptr += WMI_TLV_HDR_SIZE;
13659
13660 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13661 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13662 buf_ptr += WMI_TLV_HDR_SIZE;
13663
13664 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13665 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13666 buf_ptr += WMI_TLV_HDR_SIZE;
13667
13668 /* Fill TLV for pattern_info_timeout but no data. */
13669 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13670 buf_ptr += WMI_TLV_HDR_SIZE;
13671
13672 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053013673 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013674 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053013675 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013676
13677 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13678 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13679 if (ret) {
13680 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
13681 wmi_buf_free(buf);
13682 return QDF_STATUS_E_FAILURE;
13683 }
13684
13685 return QDF_STATUS_SUCCESS;
13686}
13687
Govind Singha4836fd2016-03-07 16:45:38 +053013688/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013689 * fill_arp_offload_params_tlv() - Fill ARP offload data
13690 * @wmi_handle: wmi handle
13691 * @offload_req: offload request
13692 * @buf_ptr: buffer pointer
13693 *
13694 * To fill ARP offload data to firmware
13695 * when target goes to wow mode.
13696 *
13697 * Return: None
13698 */
13699static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013700 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013701{
13702
13703 int i;
13704 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013705 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013706
13707 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13708 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
13709 *buf_ptr += WMI_TLV_HDR_SIZE;
13710 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
13711 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
13712 WMITLV_SET_HDR(&arp_tuple->tlv_header,
13713 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
13714 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
13715
13716 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013717 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013718 /* Copy the target ip addr and flags */
13719 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
13720 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013721 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013722 WMI_IPV4_ADDR_LEN);
13723 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013724 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013725 }
13726 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
13727 }
13728}
13729
13730#ifdef WLAN_NS_OFFLOAD
13731/**
13732 * fill_ns_offload_params_tlv() - Fill NS offload data
13733 * @wmi|_handle: wmi handle
13734 * @offload_req: offload request
13735 * @buf_ptr: buffer pointer
13736 *
13737 * To fill NS offload data to firmware
13738 * when target goes to wow mode.
13739 *
13740 * Return: None
13741 */
13742static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013743 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013744{
13745
13746 int i;
13747 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013748
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013749 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13750 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13751 *buf_ptr += WMI_TLV_HDR_SIZE;
13752 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
13753 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13754 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13755 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13756 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
13757
13758 /*
13759 * Fill data only for NS offload in the first ARP tuple for LA
13760 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013761 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013762 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13763 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013764 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013765 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013766 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013767 sizeof(WMI_IPV6_ADDR));
13768 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013769 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013770 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013771 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013772 ns_tuple->flags |=
13773 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13774 }
13775 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013776 i, &ns_req->self_ipv6_addr[i],
13777 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013778
13779 /* target MAC is optional, check if it is valid,
13780 * if this is not valid, the target will use the known
13781 * local MAC address rather than the tuple
13782 */
13783 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013784 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013785 &ns_tuple->target_mac);
13786 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13787 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13788 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13789 }
13790 }
13791 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13792 }
13793}
13794
13795
13796/**
13797 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
13798 * @wmi: wmi handle
13799 * @offload_req: offload request
13800 * @buf_ptr: buffer pointer
13801 *
13802 * To fill extended NS offload extended data to firmware
13803 * when target goes to wow mode.
13804 *
13805 * Return: None
13806 */
13807static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013808 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013809{
13810 int i;
13811 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
13812 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013813
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013814 count = ns_req->num_ns_offload_count;
13815 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013816 WMI_MAX_NS_OFFLOADS;
13817
13818 /* Populate extended NS offload tuples */
13819 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13820 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13821 *buf_ptr += WMI_TLV_HDR_SIZE;
13822 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
13823 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13824 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13825 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13826 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
13827
13828 /*
13829 * Fill data only for NS offload in the first ARP tuple for LA
13830 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013831 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013832 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13833 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013834 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013835 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013836 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013837 sizeof(WMI_IPV6_ADDR));
13838 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013839 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013840 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013841 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013842 ns_tuple->flags |=
13843 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13844 }
13845 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013846 i, &ns_req->self_ipv6_addr[i],
13847 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013848
13849 /* target MAC is optional, check if it is valid,
13850 * if this is not valid, the target will use the
13851 * known local MAC address rather than the tuple
13852 */
13853 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013854 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013855 &ns_tuple->target_mac);
13856 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13857 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13858 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13859 }
13860 }
13861 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13862 }
13863}
13864#else
13865static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013866 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013867{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013868}
13869
13870static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013871 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013872{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013873}
13874#endif
13875
13876/**
Govind Singha4836fd2016-03-07 16:45:38 +053013877 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
13878 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013879 * @arp_offload_req: arp offload request
13880 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053013881 * @arp_only: flag
13882 *
13883 * To configure ARP NS off load data to firmware
13884 * when target goes to wow mode.
13885 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013886 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013887 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013888static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013889 struct pmo_arp_offload_params *arp_offload_req,
13890 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013891 uint8_t vdev_id)
13892{
Govind Singha4836fd2016-03-07 16:45:38 +053013893 int32_t res;
13894 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053013895 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053013896 wmi_buf_t buf;
13897 int32_t len;
13898 uint32_t count = 0, num_ns_ext_tuples = 0;
13899
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013900 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013901
Govind Singha4836fd2016-03-07 16:45:38 +053013902 /*
13903 * TLV place holder size for array of NS tuples
13904 * TLV place holder size for array of ARP tuples
13905 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013906 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13907 WMI_TLV_HDR_SIZE +
13908 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13909 WMI_TLV_HDR_SIZE +
13910 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013911
13912 /*
13913 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13914 * extra length for extended NS offload tuples which follows ARP offload
13915 * tuples. Host needs to fill this structure in following format:
13916 * 2 NS ofload tuples
13917 * 2 ARP offload tuples
13918 * N numbers of extended NS offload tuples if HDD has given more than
13919 * 2 NS offload addresses
13920 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013921 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013922 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013923 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13924 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013925 }
13926
13927 buf = wmi_buf_alloc(wmi_handle, len);
13928 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013929 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013930 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013931 }
13932
Vivekc5823092018-03-22 23:27:21 +053013933 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013934 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13935 WMITLV_SET_HDR(&cmd->tlv_header,
13936 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13937 WMITLV_GET_STRUCT_TLVLEN
13938 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13939 cmd->flags = 0;
13940 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013941 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013942
Govind Singhb53420c2016-03-09 14:32:57 +053013943 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013944
Govind Singha4836fd2016-03-07 16:45:38 +053013945 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013946 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13947 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13948 if (num_ns_ext_tuples)
13949 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013950
13951 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13952 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13953 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053013954 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053013955 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013956 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013957 }
13958
Govind Singhb53420c2016-03-09 14:32:57 +053013959 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013960}
13961
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013962/**
13963 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
13964 * @wmi_handle: wmi handle
13965 * @vdev_id: vdev id
13966 * @action: true for enable else false
13967 *
13968 * To enable enhance multicast offload to firmware
13969 * when target goes to wow mode.
13970 *
13971 * Return: QDF Status
13972 */
13973
13974static
13975QDF_STATUS send_enable_enhance_multicast_offload_tlv(
13976 wmi_unified_t wmi_handle,
13977 uint8_t vdev_id, bool action)
13978{
13979 QDF_STATUS status;
13980 wmi_buf_t buf;
13981 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
13982
13983 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13984 if (!buf) {
13985 WMI_LOGE("Failed to allocate buffer to send set key cmd");
13986 return QDF_STATUS_E_NOMEM;
13987 }
13988
13989 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
13990 wmi_buf_data(buf);
13991
13992 WMITLV_SET_HDR(&cmd->tlv_header,
13993 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
13994 WMITLV_GET_STRUCT_TLVLEN(
13995 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
13996
13997 cmd->vdev_id = vdev_id;
13998 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
13999 ENHANCED_MCAST_FILTER_ENABLED);
14000 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14001 __func__, action, vdev_id);
14002 status = wmi_unified_cmd_send(wmi_handle, buf,
14003 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14004 if (status != QDF_STATUS_SUCCESS) {
14005 qdf_nbuf_free(buf);
14006 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14007 __func__);
14008 }
14009
14010 return status;
14011}
14012
14013/**
14014 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14015 * @wmi_handle: wmi handle
14016 * @param evt_buf: pointer to event buffer
14017 * @param hdr: Pointer to hold header
14018 * @param bufp: Pointer to hold pointer to rx param buffer
14019 *
14020 * Return: QDF_STATUS_SUCCESS for success or error code
14021 */
14022static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14023 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14024{
14025 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14026 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14027
14028 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14029 if (!param_buf) {
14030 WMI_LOGE("gtk param_buf is NULL");
14031 return QDF_STATUS_E_INVAL;
14032 }
14033
14034 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14035 WMI_LOGE("Invalid length for GTK status");
14036 return QDF_STATUS_E_INVAL;
14037 }
14038
14039 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14040 param_buf->fixed_param;
14041 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14042 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14043 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14044 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14045 &fixed_param->replay_counter,
14046 GTK_REPLAY_COUNTER_BYTES);
14047
14048 return QDF_STATUS_SUCCESS;
14049
14050}
14051
14052#ifdef FEATURE_WLAN_RA_FILTERING
14053/**
14054 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14055 * @wmi_handle: wmi handle
14056 * @vdev_id: vdev id
14057 *
14058 * Return: CDF status
14059 */
14060static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14061 uint8_t vdev_id, uint8_t default_pattern,
14062 uint16_t rate_limit_interval)
14063{
14064
14065 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14066 wmi_buf_t buf;
14067 uint8_t *buf_ptr;
14068 int32_t len;
14069 int ret;
14070
14071 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14072 WMI_TLV_HDR_SIZE +
14073 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14074 WMI_TLV_HDR_SIZE +
14075 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14076 WMI_TLV_HDR_SIZE +
14077 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14078 WMI_TLV_HDR_SIZE +
14079 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14080 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014081 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014082
14083 buf = wmi_buf_alloc(wmi_handle, len);
14084 if (!buf) {
14085 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14086 return QDF_STATUS_E_NOMEM;
14087 }
14088
14089 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14090 buf_ptr = (uint8_t *) cmd;
14091
14092 WMITLV_SET_HDR(&cmd->tlv_header,
14093 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14094 WMITLV_GET_STRUCT_TLVLEN
14095 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14096 cmd->vdev_id = vdev_id;
14097 cmd->pattern_id = default_pattern,
14098 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14099 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14100
14101 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14102 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14103 buf_ptr += WMI_TLV_HDR_SIZE;
14104
14105 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14106 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14107 buf_ptr += WMI_TLV_HDR_SIZE;
14108
14109 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14110 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14111 buf_ptr += WMI_TLV_HDR_SIZE;
14112
14113 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14114 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14115 buf_ptr += WMI_TLV_HDR_SIZE;
14116
14117 /* Fill TLV for pattern_info_timeout but no data. */
14118 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14119 buf_ptr += WMI_TLV_HDR_SIZE;
14120
14121 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014122 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014123 buf_ptr += WMI_TLV_HDR_SIZE;
14124
Vivekc5823092018-03-22 23:27:21 +053014125 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014126
14127 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14128 rate_limit_interval, vdev_id);
14129
14130 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14131 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14132 if (ret) {
14133 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14134 wmi_buf_free(buf);
14135 return QDF_STATUS_E_FAILURE;
14136 }
14137
14138 return QDF_STATUS_SUCCESS;
14139
14140}
14141#endif /* FEATURE_WLAN_RA_FILTERING */
14142
14143/**
14144 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14145 * @wmi_handle: wmi handle
14146 * @vdev_id: vdev id
14147 * @multicastAddr: mcast address
14148 * @clearList: clear list flag
14149 *
14150 * Return: QDF_STATUS_SUCCESS for success or error code
14151 */
14152static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14153 uint8_t vdev_id,
14154 struct qdf_mac_addr multicast_addr,
14155 bool clearList)
14156{
14157 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14158 wmi_buf_t buf;
14159 int err;
14160
14161 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14162 if (!buf) {
14163 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14164 return QDF_STATUS_E_NOMEM;
14165 }
14166
14167 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14168 qdf_mem_zero(cmd, sizeof(*cmd));
14169
14170 WMITLV_SET_HDR(&cmd->tlv_header,
14171 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14172 WMITLV_GET_STRUCT_TLVLEN
14173 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14174 cmd->action =
14175 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14176 cmd->vdev_id = vdev_id;
14177 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14178
14179 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14180 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14181
14182 err = wmi_unified_cmd_send(wmi_handle, buf,
14183 sizeof(*cmd),
14184 WMI_SET_MCASTBCAST_FILTER_CMDID);
14185 if (err) {
14186 WMI_LOGE("Failed to send set_param cmd");
14187 wmi_buf_free(buf);
14188 return QDF_STATUS_E_FAILURE;
14189 }
14190
14191 return QDF_STATUS_SUCCESS;
14192}
14193
14194/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014195 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14196 * command to fw
14197 * @wmi_handle: wmi handle
14198 * @vdev_id: vdev id
14199 * @mcast_filter_params: mcast filter params
14200 *
14201 * Return: QDF_STATUS_SUCCESS for success or error code
14202 */
14203static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14204 wmi_unified_t wmi_handle,
14205 uint8_t vdev_id,
14206 struct pmo_mcast_filter_params *filter_param)
14207
14208{
14209 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14210 uint8_t *buf_ptr;
14211 wmi_buf_t buf;
14212 int err;
14213 int i;
14214 uint8_t *mac_addr_src_ptr = NULL;
14215 wmi_mac_addr *mac_addr_dst_ptr;
14216 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14217 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14218
14219 buf = wmi_buf_alloc(wmi_handle, len);
14220 if (!buf) {
14221 WMI_LOGE("Failed to allocate memory");
14222 return QDF_STATUS_E_NOMEM;
14223 }
14224
Vivekc5823092018-03-22 23:27:21 +053014225 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014226 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14227 wmi_buf_data(buf);
14228 qdf_mem_zero(cmd, sizeof(*cmd));
14229
14230 WMITLV_SET_HDR(&cmd->tlv_header,
14231 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14232 WMITLV_GET_STRUCT_TLVLEN
14233 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14234 cmd->operation =
14235 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14236 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14237 cmd->vdev_id = vdev_id;
14238 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14239
14240 buf_ptr += sizeof(*cmd);
14241 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14242 sizeof(wmi_mac_addr) *
14243 filter_param->multicast_addr_cnt);
14244
14245 if (filter_param->multicast_addr_cnt == 0)
14246 goto send_cmd;
14247
14248 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14249 mac_addr_dst_ptr = (wmi_mac_addr *)
14250 (buf_ptr + WMI_TLV_HDR_SIZE);
14251
14252 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14253 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14254 mac_addr_src_ptr += ATH_MAC_LEN;
14255 mac_addr_dst_ptr++;
14256 }
14257
14258send_cmd:
14259 err = wmi_unified_cmd_send(wmi_handle, buf,
14260 len,
14261 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14262 if (err) {
14263 WMI_LOGE("Failed to send set_param cmd");
14264 wmi_buf_free(buf);
14265 return QDF_STATUS_E_FAILURE;
14266 }
14267
14268 return QDF_STATUS_SUCCESS;
14269}
14270
14271
14272/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014273 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14274 * @wmi_handle: wmi handle
14275 * @vdev_id: vdev id
14276 * @params: GTK offload parameters
14277 *
14278 * Return: CDF status
14279 */
14280static
14281QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14282 struct pmo_gtk_req *params,
14283 bool enable_offload,
14284 uint32_t gtk_offload_opcode)
14285{
14286 int len;
14287 wmi_buf_t buf;
14288 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014289 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014290 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014291 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014292
14293 WMI_LOGD("%s Enter", __func__);
14294
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014295 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014296
14297 /* alloc wmi buffer */
14298 buf = wmi_buf_alloc(wmi_handle, len);
14299 if (!buf) {
14300 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14301 status = QDF_STATUS_E_NOMEM;
14302 goto out;
14303 }
14304
14305 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014306 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014307 WMITLV_SET_HDR(&cmd->tlv_header,
14308 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14309 WMITLV_GET_STRUCT_TLVLEN
14310 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14311
14312 cmd->vdev_id = vdev_id;
14313
14314 /* Request target to enable GTK offload */
14315 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14316 cmd->flags = gtk_offload_opcode;
14317
14318 /* Copy the keys and replay counter */
14319 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014320 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014321 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14322 GTK_REPLAY_COUNTER_BYTES);
14323 } else {
14324 cmd->flags = gtk_offload_opcode;
14325 }
14326
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014327 buf_ptr += sizeof(*cmd);
14328 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
14329 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014330
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014331 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
14332 WMITLV_SET_HDR(&ext_param->tlv_header,
14333 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
14334 WMITLV_GET_STRUCT_TLVLEN(
14335 wmi_gtk_offload_fils_tlv_param));
14336 ext_param->vdev_id = vdev_id;
14337 ext_param->flags = cmd->flags;
14338 ext_param->kek_len = params->kek_len;
14339 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
14340 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
14341 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
14342 GTK_REPLAY_COUNTER_BYTES);
14343
14344 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 +053014345 /* send the wmi command */
14346 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14347 WMI_GTK_OFFLOAD_CMDID)) {
14348 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
14349 wmi_buf_free(buf);
14350 status = QDF_STATUS_E_FAILURE;
14351 }
14352
14353out:
14354 WMI_LOGD("%s Exit", __func__);
14355 return status;
14356}
14357
14358/**
14359 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
14360 * @wmi_handle: wmi handle
14361 * @params: GTK offload params
14362 *
14363 * Return: CDF status
14364 */
14365static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
14366 wmi_unified_t wmi_handle,
14367 uint8_t vdev_id,
14368 uint64_t offload_req_opcode)
14369{
14370 int len;
14371 wmi_buf_t buf;
14372 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14373 QDF_STATUS status = QDF_STATUS_SUCCESS;
14374
14375 len = sizeof(*cmd);
14376
14377 /* alloc wmi buffer */
14378 buf = wmi_buf_alloc(wmi_handle, len);
14379 if (!buf) {
14380 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14381 status = QDF_STATUS_E_NOMEM;
14382 goto out;
14383 }
14384
14385 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14386 WMITLV_SET_HDR(&cmd->tlv_header,
14387 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14388 WMITLV_GET_STRUCT_TLVLEN
14389 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14390
14391 /* Request for GTK offload status */
14392 cmd->flags = offload_req_opcode;
14393 cmd->vdev_id = vdev_id;
14394
14395 /* send the wmi command */
14396 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14397 WMI_GTK_OFFLOAD_CMDID)) {
14398 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
14399 wmi_buf_free(buf);
14400 status = QDF_STATUS_E_FAILURE;
14401 }
14402
14403out:
14404 return status;
14405}
14406
14407/**
14408 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
14409 * @wmi_handle: wmi handler
14410 * @action_params: pointer to action_params
14411 *
14412 * Return: 0 for success, otherwise appropriate error code
14413 */
14414static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
14415 struct pmo_action_wakeup_set_params *action_params)
14416{
14417 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
14418 wmi_buf_t buf;
14419 int i;
14420 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014421 uint32_t len = 0, *cmd_args;
14422 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014423
Vivekc5823092018-03-22 23:27:21 +053014424 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014425 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
14426 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014427 if (!buf) {
14428 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
14429 return QDF_STATUS_E_NOMEM;
14430 }
14431 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014432 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014433 WMITLV_SET_HDR(&cmd->tlv_header,
14434 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
14435 WMITLV_GET_STRUCT_TLVLEN(
14436 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
14437
14438 cmd->vdev_id = action_params->vdev_id;
14439 cmd->operation = action_params->operation;
14440
14441 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
14442 cmd->action_category_map[i] =
14443 action_params->action_category_map[i];
14444
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014445 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
14446 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053014447 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014448 buf_ptr += WMI_TLV_HDR_SIZE;
14449 cmd_args = (uint32_t *) buf_ptr;
14450 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
14451 cmd_args[i] = action_params->action_per_category[i];
14452
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014453 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014454 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014455 if (err) {
14456 WMI_LOGE("Failed to send ap_ps_egap cmd");
14457 wmi_buf_free(buf);
14458 return QDF_STATUS_E_FAILURE;
14459 }
14460
14461 return QDF_STATUS_SUCCESS;
14462}
14463
14464#ifdef FEATURE_WLAN_LPHB
14465
14466/**
14467 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
14468 * @wmi_handle: wmi handle
14469 * @lphb_conf_req: configuration info
14470 *
14471 * Return: CDF status
14472 */
14473static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
14474 wmi_hb_set_enable_cmd_fixed_param *params)
14475{
14476 QDF_STATUS status;
14477 wmi_buf_t buf = NULL;
14478 uint8_t *buf_ptr;
14479 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
14480 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
14481
14482
14483 buf = wmi_buf_alloc(wmi_handle, len);
14484 if (!buf) {
14485 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14486 return QDF_STATUS_E_NOMEM;
14487 }
14488
14489 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14490 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
14491 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
14492 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
14493 WMITLV_GET_STRUCT_TLVLEN
14494 (wmi_hb_set_enable_cmd_fixed_param));
14495
14496 /* fill in values */
14497 hb_enable_fp->vdev_id = params->session;
14498 hb_enable_fp->enable = params->enable;
14499 hb_enable_fp->item = params->item;
14500 hb_enable_fp->session = params->session;
14501
14502 status = wmi_unified_cmd_send(wmi_handle, buf,
14503 len, WMI_HB_SET_ENABLE_CMDID);
14504 if (QDF_IS_STATUS_ERROR(status)) {
14505 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
14506 status);
14507 wmi_buf_free(buf);
14508 }
14509
14510 return status;
14511}
14512
14513/**
14514 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
14515 * @wmi_handle: wmi handle
14516 * @lphb_conf_req: lphb config request
14517 *
14518 * Return: CDF status
14519 */
14520static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
14521 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
14522{
14523 QDF_STATUS status;
14524 wmi_buf_t buf = NULL;
14525 uint8_t *buf_ptr;
14526 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
14527 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
14528
14529 buf = wmi_buf_alloc(wmi_handle, len);
14530 if (!buf) {
14531 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14532 return QDF_STATUS_E_NOMEM;
14533 }
14534
14535 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14536 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
14537 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
14538 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
14539 WMITLV_GET_STRUCT_TLVLEN
14540 (wmi_hb_set_tcp_params_cmd_fixed_param));
14541
14542 /* fill in values */
14543 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14544 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14545 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14546 hb_tcp_params_fp->seq = lphb_conf_req->seq;
14547 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
14548 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
14549 hb_tcp_params_fp->interval = lphb_conf_req->interval;
14550 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
14551 hb_tcp_params_fp->session = lphb_conf_req->session;
14552 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
14553 &lphb_conf_req->gateway_mac,
14554 sizeof(hb_tcp_params_fp->gateway_mac));
14555
14556 status = wmi_unified_cmd_send(wmi_handle, buf,
14557 len, WMI_HB_SET_TCP_PARAMS_CMDID);
14558 if (QDF_IS_STATUS_ERROR(status)) {
14559 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
14560 status);
14561 wmi_buf_free(buf);
14562 }
14563
14564 return status;
14565}
14566
14567/**
14568 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
14569 * @wmi_handle: wmi handle
14570 * @lphb_conf_req: lphb config request
14571 *
14572 * Return: CDF status
14573 */
14574static
14575QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14576 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
14577{
14578 QDF_STATUS status;
14579 wmi_buf_t buf = NULL;
14580 uint8_t *buf_ptr;
14581 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
14582 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
14583
14584 buf = wmi_buf_alloc(wmi_handle, len);
14585 if (!buf) {
14586 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14587 return QDF_STATUS_E_NOMEM;
14588 }
14589
14590 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14591 hb_tcp_filter_fp =
14592 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
14593 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
14594 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
14595 WMITLV_GET_STRUCT_TLVLEN
14596 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
14597
14598 /* fill in values */
14599 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
14600 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
14601 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
14602 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
14603 memcpy((void *)&hb_tcp_filter_fp->filter,
14604 (void *)&g_hb_tcp_filter_fp->filter,
14605 WMI_WLAN_HB_MAX_FILTER_SIZE);
14606
14607 status = wmi_unified_cmd_send(wmi_handle, buf,
14608 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
14609 if (QDF_IS_STATUS_ERROR(status)) {
14610 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
14611 status);
14612 wmi_buf_free(buf);
14613 }
14614
14615 return status;
14616}
14617
14618/**
14619 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
14620 * @wmi_handle: wmi handle
14621 * @lphb_conf_req: lphb config request
14622 *
14623 * Return: CDF status
14624 */
14625static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
14626 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
14627{
14628 QDF_STATUS status;
14629 wmi_buf_t buf = NULL;
14630 uint8_t *buf_ptr;
14631 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
14632 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
14633
14634 buf = wmi_buf_alloc(wmi_handle, len);
14635 if (!buf) {
14636 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14637 return QDF_STATUS_E_NOMEM;
14638 }
14639
14640 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14641 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
14642 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
14643 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
14644 WMITLV_GET_STRUCT_TLVLEN
14645 (wmi_hb_set_udp_params_cmd_fixed_param));
14646
14647 /* fill in values */
14648 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14649 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14650 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14651 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
14652 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
14653 hb_udp_params_fp->interval = lphb_conf_req->interval;
14654 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
14655 hb_udp_params_fp->session = lphb_conf_req->session;
14656 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
14657 &lphb_conf_req->gateway_mac,
14658 sizeof(lphb_conf_req->gateway_mac));
14659
14660 status = wmi_unified_cmd_send(wmi_handle, buf,
14661 len, WMI_HB_SET_UDP_PARAMS_CMDID);
14662 if (QDF_IS_STATUS_ERROR(status)) {
14663 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
14664 status);
14665 wmi_buf_free(buf);
14666 }
14667
14668 return status;
14669}
14670
14671/**
14672 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
14673 * @wmi_handle: wmi handle
14674 * @lphb_conf_req: lphb config request
14675 *
14676 * Return: CDF status
14677 */
14678static
14679QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14680 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
14681{
14682 QDF_STATUS status;
14683 wmi_buf_t buf = NULL;
14684 uint8_t *buf_ptr;
14685 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
14686 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
14687
14688 buf = wmi_buf_alloc(wmi_handle, len);
14689 if (!buf) {
14690 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14691 return QDF_STATUS_E_NOMEM;
14692 }
14693
14694 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14695 hb_udp_filter_fp =
14696 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
14697 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
14698 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
14699 WMITLV_GET_STRUCT_TLVLEN
14700 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
14701
14702 /* fill in values */
14703 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
14704 hb_udp_filter_fp->length = lphb_conf_req->length;
14705 hb_udp_filter_fp->offset = lphb_conf_req->offset;
14706 hb_udp_filter_fp->session = lphb_conf_req->session;
14707 memcpy((void *)&hb_udp_filter_fp->filter,
14708 (void *)&lphb_conf_req->filter,
14709 WMI_WLAN_HB_MAX_FILTER_SIZE);
14710
14711 status = wmi_unified_cmd_send(wmi_handle, buf,
14712 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
14713 if (QDF_IS_STATUS_ERROR(status)) {
14714 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
14715 status);
14716 wmi_buf_free(buf);
14717 }
14718
14719 return status;
14720}
14721#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014722
Dustin Brownf31f88b2017-05-12 14:01:44 -070014723static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
14724 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014725{
Dustin Brownf31f88b2017-05-12 14:01:44 -070014726 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014727 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070014728 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014729
Dustin Brownf31f88b2017-05-12 14:01:44 -070014730 if (!req) {
14731 WMI_LOGE("req is null");
14732 return QDF_STATUS_E_INVAL;
14733 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014734
Dustin Brownf31f88b2017-05-12 14:01:44 -070014735 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
14736 if (!wmi_buf) {
14737 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014738 return QDF_STATUS_E_NOMEM;
14739 }
14740
Dustin Brownf31f88b2017-05-12 14:01:44 -070014741 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014742 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070014743 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
14744 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
14745 cmd->vdev_id = req->vdev_id;
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014746 cmd->enable = req->enable;
14747 /* Set all modes in case of disable */
14748 if (!cmd->enable)
14749 cmd->hw_filter_bitmap = ((uint32_t)~0U);
14750 else
14751 cmd->hw_filter_bitmap = req->mode_bitmap;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014752
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014753 WMI_LOGD("Send %s hw filter mode: 0x%X for vdev id %d",
14754 req->enable ? "enable" : "disable", req->mode_bitmap,
14755 req->vdev_id);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014756
Dustin Brownf31f88b2017-05-12 14:01:44 -070014757 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
14758 WMI_HW_DATA_FILTER_CMDID);
14759 if (QDF_IS_STATUS_ERROR(status)) {
14760 WMI_LOGE("Failed to configure hw filter");
14761 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014762 }
14763
Dustin Brownf31f88b2017-05-12 14:01:44 -070014764 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014765}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053014766
14767/**
14768 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
14769 * @wmi_handle: wmi handle
14770 * @vdev_id: vdev id
14771 * @enable: Flag to enable/disable packet filter
14772 *
14773 * Return: QDF_STATUS_SUCCESS for success or error code
14774 */
14775static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
14776 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
14777{
14778 int32_t len;
14779 int ret = 0;
14780 wmi_buf_t buf;
14781 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
14782
14783 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
14784
14785 buf = wmi_buf_alloc(wmi_handle, len);
14786 if (!buf) {
14787 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14788 return QDF_STATUS_E_NOMEM;
14789 }
14790
14791 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
14792 WMITLV_SET_HDR(&cmd->tlv_header,
14793 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
14794 WMITLV_GET_STRUCT_TLVLEN(
14795 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
14796
14797 cmd->vdev_id = vdev_id;
14798 if (enable)
14799 cmd->enable = PACKET_FILTER_SET_ENABLE;
14800 else
14801 cmd->enable = PACKET_FILTER_SET_DISABLE;
14802
14803 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
14804 __func__, cmd->enable, vdev_id);
14805
14806 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14807 WMI_PACKET_FILTER_ENABLE_CMDID);
14808 if (ret) {
14809 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
14810 wmi_buf_free(buf);
14811 }
14812
14813 return ret;
14814}
14815
14816/**
14817 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
14818 * @wmi_handle: wmi handle
14819 * @vdev_id: vdev id
14820 * @rcv_filter_param: Packet filter parameters
14821 * @filter_id: Filter id
14822 * @enable: Flag to add/delete packet filter configuration
14823 *
14824 * Return: QDF_STATUS_SUCCESS for success or error code
14825 */
14826static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
14827 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
14828 uint8_t filter_id, bool enable)
14829{
14830 int len, i;
14831 int err = 0;
14832 wmi_buf_t buf;
14833 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
14834
14835
14836 /* allocate the memory */
14837 len = sizeof(*cmd);
14838 buf = wmi_buf_alloc(wmi_handle, len);
14839 if (!buf) {
14840 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14841 return QDF_STATUS_E_NOMEM;
14842 }
14843
14844 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
14845 WMITLV_SET_HDR(&cmd->tlv_header,
14846 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
14847 WMITLV_GET_STRUCT_TLVLEN
14848 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
14849
14850 cmd->vdev_id = vdev_id;
14851 cmd->filter_id = filter_id;
14852 if (enable)
14853 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
14854 else
14855 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
14856
14857 if (enable) {
14858 cmd->num_params = QDF_MIN(
14859 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
14860 rcv_filter_param->num_params);
14861 cmd->filter_type = rcv_filter_param->filter_type;
14862 cmd->coalesce_time = rcv_filter_param->coalesce_time;
14863
14864 for (i = 0; i < cmd->num_params; i++) {
14865 cmd->paramsData[i].proto_type =
14866 rcv_filter_param->params_data[i].protocol_layer;
14867 cmd->paramsData[i].cmp_type =
14868 rcv_filter_param->params_data[i].compare_flag;
14869 cmd->paramsData[i].data_length =
14870 rcv_filter_param->params_data[i].data_length;
14871 cmd->paramsData[i].data_offset =
14872 rcv_filter_param->params_data[i].data_offset;
14873 memcpy(&cmd->paramsData[i].compareData,
14874 rcv_filter_param->params_data[i].compare_data,
14875 sizeof(cmd->paramsData[i].compareData));
14876 memcpy(&cmd->paramsData[i].dataMask,
14877 rcv_filter_param->params_data[i].data_mask,
14878 sizeof(cmd->paramsData[i].dataMask));
14879 }
14880 }
14881
14882 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
14883 cmd->filter_action, cmd->filter_id, cmd->num_params);
14884 /* send the command along with data */
14885 err = wmi_unified_cmd_send(wmi_handle, buf, len,
14886 WMI_PACKET_FILTER_CONFIG_CMDID);
14887 if (err) {
14888 WMI_LOGE("Failed to send pkt_filter cmd");
14889 wmi_buf_free(buf);
14890 return QDF_STATUS_E_FAILURE;
14891 }
14892
14893 return QDF_STATUS_SUCCESS;
14894}
Wu Gao52c0b772018-05-17 16:14:00 +080014895#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014896
Govind Singha4836fd2016-03-07 16:45:38 +053014897/**
14898 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
14899 * @wmi_handle: wmi handle
14900 * @request: SSID hotlist set request
14901 *
Govind Singhb53420c2016-03-09 14:32:57 +053014902 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053014903 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014904static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053014905send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
14906 struct ssid_hotlist_request_params *request)
14907{
14908 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
14909 wmi_buf_t wmi_buf;
14910 uint32_t len;
14911 uint32_t array_size;
14912 uint8_t *buf_ptr;
14913
14914 /* length of fixed portion */
14915 len = sizeof(*cmd);
14916
14917 /* length of variable portion */
14918 array_size =
14919 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14920 len += WMI_TLV_HDR_SIZE + array_size;
14921
14922 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14923 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014924 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14925 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014926 }
14927
14928 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14929 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14930 buf_ptr;
14931 WMITLV_SET_HDR
14932 (&cmd->tlv_header,
14933 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
14934 WMITLV_GET_STRUCT_TLVLEN
14935 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
14936
14937 cmd->request_id = request->request_id;
14938 cmd->requestor_id = 0;
14939 cmd->vdev_id = request->session_id;
14940 cmd->table_id = 0;
14941 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
14942 cmd->total_entries = request->ssid_count;
14943 cmd->num_entries_in_page = request->ssid_count;
14944 cmd->first_entry_index = 0;
14945
14946 buf_ptr += sizeof(*cmd);
14947 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
14948
14949 if (request->ssid_count) {
14950 wmi_extscan_hotlist_ssid_entry *entry;
14951 int i;
14952
14953 buf_ptr += WMI_TLV_HDR_SIZE;
14954 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
14955 for (i = 0; i < request->ssid_count; i++) {
14956 WMITLV_SET_HDR
14957 (entry,
14958 WMITLV_TAG_ARRAY_STRUC,
14959 WMITLV_GET_STRUCT_TLVLEN
14960 (wmi_extscan_hotlist_ssid_entry));
14961 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053014962 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053014963 request->ssids[i].ssid.mac_ssid,
14964 request->ssids[i].ssid.length);
14965 entry->band = request->ssids[i].band;
14966 entry->min_rssi = request->ssids[i].rssi_low;
14967 entry->max_rssi = request->ssids[i].rssi_high;
14968 entry++;
14969 }
14970 cmd->mode = WMI_EXTSCAN_MODE_START;
14971 } else {
14972 cmd->mode = WMI_EXTSCAN_MODE_STOP;
14973 }
14974
14975 if (wmi_unified_cmd_send
14976 (wmi_handle, wmi_buf, len,
14977 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014978 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014979 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014980 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014981 }
14982
Govind Singhb53420c2016-03-09 14:32:57 +053014983 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014984}
14985
14986/**
14987 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
14988 * @wmi_handle: wmi handle
14989 * @vdev_id: vdev id
14990 *
14991 * This function sends roam synch complete event to fw.
14992 *
14993 * Return: CDF STATUS
14994 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014995static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014996 uint8_t vdev_id)
14997{
14998 wmi_roam_synch_complete_fixed_param *cmd;
14999 wmi_buf_t wmi_buf;
15000 uint8_t *buf_ptr;
15001 uint16_t len;
15002 len = sizeof(wmi_roam_synch_complete_fixed_param);
15003
15004 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15005 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015006 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15007 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015008 }
15009 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15010 buf_ptr = (uint8_t *) cmd;
15011 WMITLV_SET_HDR(&cmd->tlv_header,
15012 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15013 WMITLV_GET_STRUCT_TLVLEN
15014 (wmi_roam_synch_complete_fixed_param));
15015 cmd->vdev_id = vdev_id;
15016 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15017 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015018 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015019 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015020 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015021 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015022 }
15023
Govind Singhb53420c2016-03-09 14:32:57 +053015024 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015025}
15026
15027/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015028 * send_fw_test_cmd_tlv() - send fw test command to fw.
15029 * @wmi_handle: wmi handle
15030 * @wmi_fwtest: fw test command
15031 *
15032 * This function sends fw test command to fw.
15033 *
15034 * Return: CDF STATUS
15035 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015036static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015037QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15038 struct set_fwtest_params *wmi_fwtest)
15039{
15040 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15041 wmi_buf_t wmi_buf;
15042 uint16_t len;
15043
15044 len = sizeof(*cmd);
15045
15046 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15047 if (!wmi_buf) {
15048 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15049 return QDF_STATUS_E_NOMEM;
15050 }
15051
15052 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15053 WMITLV_SET_HDR(&cmd->tlv_header,
15054 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15055 WMITLV_GET_STRUCT_TLVLEN(
15056 wmi_fwtest_set_param_cmd_fixed_param));
15057 cmd->param_id = wmi_fwtest->arg;
15058 cmd->param_value = wmi_fwtest->value;
15059
15060 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15061 WMI_FWTEST_CMDID)) {
15062 WMI_LOGP("%s: failed to send fw test command", __func__);
15063 qdf_nbuf_free(wmi_buf);
15064 return QDF_STATUS_E_FAILURE;
15065 }
15066
15067 return QDF_STATUS_SUCCESS;
15068}
15069
15070/**
Govind Singha4836fd2016-03-07 16:45:38 +053015071 * send_unit_test_cmd_tlv() - send unit test command to fw.
15072 * @wmi_handle: wmi handle
15073 * @wmi_utest: unit test command
15074 *
15075 * This function send unit test command to fw.
15076 *
15077 * Return: CDF STATUS
15078 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015079static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015080 struct wmi_unit_test_cmd *wmi_utest)
15081{
15082 wmi_unit_test_cmd_fixed_param *cmd;
15083 wmi_buf_t wmi_buf;
15084 uint8_t *buf_ptr;
15085 int i;
15086 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015087 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015088
15089 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015090 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015091 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15092
15093 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15094 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015095 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15096 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015097 }
15098
15099 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15100 buf_ptr = (uint8_t *) cmd;
15101 WMITLV_SET_HDR(&cmd->tlv_header,
15102 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15103 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15104 cmd->vdev_id = wmi_utest->vdev_id;
15105 cmd->module_id = wmi_utest->module_id;
15106 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015107 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015108 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15109 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15110 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015111 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015112 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15113 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15114 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015115 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015116 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015117 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015118 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015119 }
15120 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15121 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015122 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015123 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015124 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015125 }
15126
Govind Singhb53420c2016-03-09 14:32:57 +053015127 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015128}
15129
15130/**
15131 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15132 * @wmi_handle: wma handle
15133 * @roaminvoke: roam invoke command
15134 *
15135 * Send roam invoke command to fw for fastreassoc.
15136 *
15137 * Return: CDF STATUS
15138 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015139static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015140 struct wmi_roam_invoke_cmd *roaminvoke,
15141 uint32_t ch_hz)
15142{
15143 wmi_roam_invoke_cmd_fixed_param *cmd;
15144 wmi_buf_t wmi_buf;
15145 u_int8_t *buf_ptr;
15146 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015147 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015148 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015149 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015150
15151 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015152 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015153 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15154 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015155 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15156 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15157 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015158 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15159 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015160 }
15161
15162 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15163 buf_ptr = (u_int8_t *) cmd;
15164 WMITLV_SET_HDR(&cmd->tlv_header,
15165 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15166 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15167 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015168 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015169 if (roaminvoke->is_same_bssid)
15170 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15171 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015172
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015173 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015174 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015175 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15176 cmd->num_buf = 1;
15177 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015178 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015179 cmd->num_buf = 0;
15180 }
Naveen Rawat77797922017-01-20 17:00:07 -080015181
Govind Singha4836fd2016-03-07 16:45:38 +053015182 cmd->roam_ap_sel_mode = 0;
15183 cmd->roam_delay = 0;
15184 cmd->num_chan = 1;
15185 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015186
Govind Singha4836fd2016-03-07 16:45:38 +053015187 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15188 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15189 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015190 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015191 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015192 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015193 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15194 (sizeof(wmi_mac_addr)));
15195 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15196 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015197
15198 /* move to next tlv i.e. bcn_prb_buf_list */
15199 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15200
15201 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15202 sizeof(wmi_tlv_buf_len_param));
15203
15204 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15205 buf_len_tlv->buf_len = roaminvoke->frame_len;
15206
15207 /* move to next tlv i.e. bcn_prb_frm */
15208 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15209 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15210 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15211
15212 /* copy frame after the header */
15213 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15214 roaminvoke->frame_buf,
15215 roaminvoke->frame_len);
15216
15217 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070015218 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat77797922017-01-20 17:00:07 -080015219 buf_ptr + WMI_TLV_HDR_SIZE,
15220 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015221 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15222 cmd->flags, cmd->roam_scan_mode,
15223 cmd->roam_ap_sel_mode, cmd->roam_delay,
15224 cmd->num_chan, cmd->num_bssid);
15225 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015226
Govind Singha4836fd2016-03-07 16:45:38 +053015227 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15228 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015229 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015230 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015231 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015232 }
15233
Govind Singhb53420c2016-03-09 14:32:57 +053015234 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015235}
15236
15237/**
15238 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15239 * @wmi_handle: wmi handle
15240 * @command: command
15241 * @vdev_id: vdev id
15242 *
15243 * This function set roam offload command to fw.
15244 *
15245 * Return: CDF status
15246 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015247static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015248 uint32_t command, uint32_t vdev_id)
15249{
Govind Singh67922e82016-04-01 16:48:57 +053015250 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015251 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15252 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015253 int len;
15254 uint8_t *buf_ptr;
15255
15256 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15257 buf = wmi_buf_alloc(wmi_handle, len);
15258 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015259 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15260 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015261 }
15262
15263 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15264
15265 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15266 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15267 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15268 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15269 cmd_fp->vdev_id = vdev_id;
15270 cmd_fp->command_arg = command;
15271
15272 status = wmi_unified_cmd_send(wmi_handle, buf,
15273 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015274 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015275 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015276 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015277 goto error;
15278 }
15279
Govind Singhb53420c2016-03-09 14:32:57 +053015280 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15281 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015282
15283error:
15284 wmi_buf_free(buf);
15285
Govind Singh67922e82016-04-01 16:48:57 +053015286 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015287}
15288
15289/**
15290 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15291 * @wmi_handle: wmi handle
15292 * @ap_profile_p: ap profile
15293 * @vdev_id: vdev id
15294 *
15295 * Send WMI_ROAM_AP_PROFILE to firmware
15296 *
15297 * Return: CDF status
15298 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015299static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015300 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015301{
Govind Singha4836fd2016-03-07 16:45:38 +053015302 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015303 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015304 int len;
15305 uint8_t *buf_ptr;
15306 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015307 wmi_roam_cnd_scoring_param *score_param;
15308 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015309
15310 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015311 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015312 buf = wmi_buf_alloc(wmi_handle, len);
15313 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015314 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15315 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015316 }
15317
15318 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15319 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15320 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15321 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15322 WMITLV_GET_STRUCT_TLVLEN
15323 (wmi_roam_ap_profile_fixed_param));
15324 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015325 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015326 roam_ap_profile_fp->id = 0;
15327 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15328
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015329 profile = (wmi_ap_profile *)buf_ptr;
15330 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015331 WMITLV_TAG_STRUC_wmi_ap_profile,
15332 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015333 profile->flags = ap_profile->profile.flags;
15334 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15335 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15336 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15337 profile->ssid.ssid_len);
15338 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15339 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15340 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15341 profile->rsn_mcastmgmtcipherset =
15342 ap_profile->profile.rsn_mcastmgmtcipherset;
15343 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15344
15345 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",
15346 profile->flags, profile->rssi_threshold,
15347 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15348 profile->rsn_authmode, profile->rsn_ucastcipherset,
15349 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15350 profile->rssi_abs_thresh);
15351
15352 buf_ptr += sizeof(wmi_ap_profile);
15353
15354 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15355 WMITLV_SET_HDR(&score_param->tlv_header,
15356 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15357 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15358 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15359 score_param->rssi_weightage_pcnt =
15360 ap_profile->param.rssi_weightage;
15361 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15362 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15363 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15364 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15365 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15366 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15367 score_param->esp_qbss_weightage_pcnt =
15368 ap_profile->param.esp_qbss_weightage;
15369 score_param->beamforming_weightage_pcnt =
15370 ap_profile->param.beamforming_weightage;
15371 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15372 score_param->oce_wan_weightage_pcnt =
15373 ap_profile->param.oce_wan_weightage;
15374
15375 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",
15376 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15377 score_param->ht_weightage_pcnt,
15378 score_param->vht_weightage_pcnt,
15379 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15380 score_param->band_weightage_pcnt,
15381 score_param->nss_weightage_pcnt,
15382 score_param->esp_qbss_weightage_pcnt,
15383 score_param->beamforming_weightage_pcnt,
15384 score_param->pcl_weightage_pcnt,
15385 score_param->oce_wan_weightage_pcnt);
15386
15387 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15388 score_param->band_scoring.score_pcnt =
15389 ap_profile->param.band_index_score;
15390 score_param->nss_scoring.score_pcnt =
15391 ap_profile->param.nss_index_score;
15392
15393 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15394 score_param->bw_scoring.score_pcnt,
15395 score_param->band_scoring.score_pcnt,
15396 score_param->nss_scoring.score_pcnt);
15397
15398 score_param->rssi_scoring.best_rssi_threshold =
15399 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15400 score_param->rssi_scoring.good_rssi_threshold =
15401 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15402 score_param->rssi_scoring.bad_rssi_threshold =
15403 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15404 score_param->rssi_scoring.good_rssi_pcnt =
15405 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15406 score_param->rssi_scoring.bad_rssi_pcnt =
15407 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15408 score_param->rssi_scoring.good_bucket_size =
15409 ap_profile->param.rssi_scoring.good_bucket_size;
15410 score_param->rssi_scoring.bad_bucket_size =
15411 ap_profile->param.rssi_scoring.bad_bucket_size;
15412 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15413 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15414
15415 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15416 score_param->rssi_scoring.best_rssi_threshold,
15417 score_param->rssi_scoring.good_rssi_threshold,
15418 score_param->rssi_scoring.bad_rssi_threshold,
15419 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15420 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15421 score_param->rssi_scoring.good_rssi_pcnt,
15422 score_param->rssi_scoring.bad_rssi_pcnt,
15423 score_param->rssi_scoring.good_bucket_size,
15424 score_param->rssi_scoring.bad_bucket_size);
15425
15426 score_param->esp_qbss_scoring.num_slot =
15427 ap_profile->param.esp_qbss_scoring.num_slot;
15428 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15429 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15430 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15431 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15432 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15433 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15434 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15435 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15436
15437 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15438 score_param->esp_qbss_scoring.num_slot,
15439 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15440 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15441 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15442 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15443
15444 score_param->oce_wan_scoring.num_slot =
15445 ap_profile->param.oce_wan_scoring.num_slot;
15446 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15447 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15448 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15449 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15450 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15451 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15452 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15453 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15454
15455 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15456 score_param->oce_wan_scoring.num_slot,
15457 score_param->oce_wan_scoring.score_pcnt3_to_0,
15458 score_param->oce_wan_scoring.score_pcnt7_to_4,
15459 score_param->oce_wan_scoring.score_pcnt11_to_8,
15460 score_param->oce_wan_scoring.score_pcnt15_to_12);
15461
Govind Singha4836fd2016-03-07 16:45:38 +053015462 status = wmi_unified_cmd_send(wmi_handle, buf,
15463 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015464 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015465 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015466 status);
Govind Singh67922e82016-04-01 16:48:57 +053015467 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015468 }
15469
Govind Singhb53420c2016-03-09 14:32:57 +053015470 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015471
Govind Singh67922e82016-04-01 16:48:57 +053015472 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015473}
15474
15475/**
15476 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15477 * @wmi_handle: wmi handle
15478 * @scan_period: scan period
15479 * @scan_age: scan age
15480 * @vdev_id: vdev id
15481 *
15482 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15483 *
15484 * Return: CDF status
15485 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015486static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015487 uint32_t scan_period,
15488 uint32_t scan_age,
15489 uint32_t vdev_id)
15490{
Govind Singh67922e82016-04-01 16:48:57 +053015491 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015492 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015493 int len;
15494 uint8_t *buf_ptr;
15495 wmi_roam_scan_period_fixed_param *scan_period_fp;
15496
15497 /* Send scan period values */
15498 len = sizeof(wmi_roam_scan_period_fixed_param);
15499 buf = wmi_buf_alloc(wmi_handle, len);
15500 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015501 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15502 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015503 }
15504
15505 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15506 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15507 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15508 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15509 WMITLV_GET_STRUCT_TLVLEN
15510 (wmi_roam_scan_period_fixed_param));
15511 /* fill in scan period values */
15512 scan_period_fp->vdev_id = vdev_id;
15513 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15514 scan_period_fp->roam_scan_age = scan_age;
15515
15516 status = wmi_unified_cmd_send(wmi_handle, buf,
15517 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015518 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015519 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015520 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015521 goto error;
15522 }
15523
Govind Singhb53420c2016-03-09 14:32:57 +053015524 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015525 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015526 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015527error:
15528 wmi_buf_free(buf);
15529
Govind Singh67922e82016-04-01 16:48:57 +053015530 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015531}
15532
15533/**
15534 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15535 * @wmi_handle: wmi handle
15536 * @chan_count: channel count
15537 * @chan_list: channel list
15538 * @list_type: list type
15539 * @vdev_id: vdev id
15540 *
15541 * Set roam offload channel list.
15542 *
15543 * Return: CDF status
15544 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015545static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015546 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015547 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015548 uint8_t list_type, uint32_t vdev_id)
15549{
Govind Singha4836fd2016-03-07 16:45:38 +053015550 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015551 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015552 int len, list_tlv_len;
15553 int i;
15554 uint8_t *buf_ptr;
15555 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053015556 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053015557
15558 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053015559 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053015560 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053015561 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053015562 }
15563 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053015564 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015565 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
15566 buf = wmi_buf_alloc(wmi_handle, len);
15567 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015568 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15569 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015570 }
15571
15572 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15573 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
15574 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
15575 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
15576 WMITLV_GET_STRUCT_TLVLEN
15577 (wmi_roam_chan_list_fixed_param));
15578 chan_list_fp->vdev_id = vdev_id;
15579 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053015580 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053015581 /* external app is controlling channel list */
15582 chan_list_fp->chan_list_type =
15583 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
15584 } else {
15585 /* umac supplied occupied channel list in LFR */
15586 chan_list_fp->chan_list_type =
15587 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
15588 }
15589
15590 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
15591 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15592 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015593 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015594 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053015595 for (i = 0; ((i < chan_list_fp->num_chan) &&
15596 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
15597 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015598 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015599 }
15600
15601 status = wmi_unified_cmd_send(wmi_handle, buf,
15602 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053015603 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015604 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015605 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015606 goto error;
15607 }
15608
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015609 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053015610 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015611error:
15612 wmi_buf_free(buf);
15613
Govind Singh67922e82016-04-01 16:48:57 +053015614 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015615}
15616
15617/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015618 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
15619 * @wmi_handle: wmi handle
15620 * @req_buf: per roam config buffer
15621 *
15622 * Return: QDF status
15623 */
15624static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
15625 struct wmi_per_roam_config_req *req_buf)
15626{
15627 wmi_buf_t buf = NULL;
15628 QDF_STATUS status;
15629 int len;
15630 uint8_t *buf_ptr;
15631 wmi_roam_per_config_fixed_param *wmi_per_config;
15632
15633 len = sizeof(wmi_roam_per_config_fixed_param);
15634 buf = wmi_buf_alloc(wmi_handle, len);
15635 if (!buf) {
15636 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15637 return QDF_STATUS_E_NOMEM;
15638 }
15639
15640 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15641 wmi_per_config =
15642 (wmi_roam_per_config_fixed_param *) buf_ptr;
15643 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
15644 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
15645 WMITLV_GET_STRUCT_TLVLEN
15646 (wmi_roam_per_config_fixed_param));
15647
15648 /* fill in per roam config values */
15649 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015650
15651 wmi_per_config->enable = req_buf->per_config.enable;
15652 wmi_per_config->high_rate_thresh =
15653 (req_buf->per_config.tx_high_rate_thresh << 16) |
15654 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
15655 wmi_per_config->low_rate_thresh =
15656 (req_buf->per_config.tx_low_rate_thresh << 16) |
15657 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
15658 wmi_per_config->pkt_err_rate_thresh_pct =
15659 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
15660 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
15661 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053015662 wmi_per_config->pkt_err_rate_mon_time =
15663 (req_buf->per_config.tx_per_mon_time << 16) |
15664 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053015665 wmi_per_config->min_candidate_rssi =
15666 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015667
15668 /* Send per roam config parameters */
15669 status = wmi_unified_cmd_send(wmi_handle, buf,
15670 len, WMI_ROAM_PER_CONFIG_CMDID);
15671 if (QDF_IS_STATUS_ERROR(status)) {
15672 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
15673 status);
15674 wmi_buf_free(buf);
15675 return status;
15676 }
15677
15678 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
15679 req_buf->per_config.enable, req_buf->vdev_id);
15680 return QDF_STATUS_SUCCESS;
15681}
15682
15683/**
Govind Singha4836fd2016-03-07 16:45:38 +053015684 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
15685 * @wmi_handle: wmi handle
15686 * @rssi_change_thresh: RSSI Change threshold
15687 * @bcn_rssi_weight: beacon RSSI weight
15688 * @vdev_id: vdev id
15689 *
15690 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
15691 *
15692 * Return: CDF status
15693 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015694static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015695 uint32_t vdev_id,
15696 int32_t rssi_change_thresh,
15697 uint32_t bcn_rssi_weight,
15698 uint32_t hirssi_delay_btw_scans)
15699{
Govind Singha4836fd2016-03-07 16:45:38 +053015700 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015701 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015702 int len;
15703 uint8_t *buf_ptr;
15704 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
15705
15706 /* Send rssi change parameters */
15707 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
15708 buf = wmi_buf_alloc(wmi_handle, len);
15709 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015710 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15711 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015712 }
15713
15714 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15715 rssi_change_fp =
15716 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
15717 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
15718 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
15719 WMITLV_GET_STRUCT_TLVLEN
15720 (wmi_roam_scan_rssi_change_threshold_fixed_param));
15721 /* fill in rssi change threshold (hysteresis) values */
15722 rssi_change_fp->vdev_id = vdev_id;
15723 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
15724 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
15725 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
15726
15727 status = wmi_unified_cmd_send(wmi_handle, buf,
15728 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053015729 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015730 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015731 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015732 goto error;
15733 }
15734
Govind Singhb53420c2016-03-09 14:32:57 +053015735 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053015736 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053015737 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
15738 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015739error:
15740 wmi_buf_free(buf);
15741
Govind Singh67922e82016-04-01 16:48:57 +053015742 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015743}
15744
Govind Singhbca3b1b2016-05-02 17:59:24 +053015745/**
15746 * send_power_dbg_cmd_tlv() - send power debug commands
15747 * @wmi_handle: wmi handle
15748 * @param: wmi power debug parameter
15749 *
15750 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
15751 *
15752 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15753 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015754static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
15755 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053015756{
15757 wmi_buf_t buf = NULL;
15758 QDF_STATUS status;
15759 int len, args_tlv_len;
15760 uint8_t *buf_ptr;
15761 uint8_t i;
15762 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
15763 uint32_t *cmd_args;
15764
15765 /* Prepare and send power debug cmd parameters */
15766 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
15767 len = sizeof(*cmd) + args_tlv_len;
15768 buf = wmi_buf_alloc(wmi_handle, len);
15769 if (!buf) {
15770 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15771 return QDF_STATUS_E_NOMEM;
15772 }
15773
15774 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15775 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
15776 WMITLV_SET_HDR(&cmd->tlv_header,
15777 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
15778 WMITLV_GET_STRUCT_TLVLEN
15779 (wmi_pdev_wal_power_debug_cmd_fixed_param));
15780
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015781 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15782 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053015783 cmd->module_id = param->module_id;
15784 cmd->num_args = param->num_args;
15785 buf_ptr += sizeof(*cmd);
15786 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15787 (param->num_args * sizeof(uint32_t)));
15788 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
15789 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080015790 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053015791 cmd_args[i] = param->args[i];
15792 WMI_LOGI("%d,", param->args[i]);
15793 }
15794
15795 status = wmi_unified_cmd_send(wmi_handle, buf,
15796 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
15797 if (QDF_IS_STATUS_ERROR(status)) {
15798 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
15799 status);
15800 goto error;
15801 }
15802
15803 return QDF_STATUS_SUCCESS;
15804error:
15805 wmi_buf_free(buf);
15806
15807 return status;
15808}
15809
Govind Singhe7f2f342016-05-23 12:12:52 +053015810/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015811 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15812 * @wmi_handle: wmi handle
15813 * @param: wmi multiple vdev restart req param
15814 *
15815 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15816 *
15817 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15818 */
15819static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15820 wmi_unified_t wmi_handle,
15821 struct multiple_vdev_restart_params *param)
15822{
15823 wmi_buf_t buf;
15824 QDF_STATUS qdf_status;
15825 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15826 int i;
15827 uint8_t *buf_ptr;
15828 uint32_t *vdev_ids;
15829 wmi_channel *chan_info;
15830 struct channel_param *tchan_info;
15831 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15832
15833 len += sizeof(wmi_channel);
15834 if (param->num_vdevs)
15835 len += sizeof(uint32_t) * param->num_vdevs;
15836
15837 buf = wmi_buf_alloc(wmi_handle, len);
15838 if (!buf) {
15839 WMI_LOGE("Failed to allocate memory\n");
15840 qdf_status = QDF_STATUS_E_NOMEM;
15841 goto end;
15842 }
15843
15844 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15845 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15846 buf_ptr;
15847
15848 WMITLV_SET_HDR(&cmd->tlv_header,
15849 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15850 WMITLV_GET_STRUCT_TLVLEN
15851 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015852 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15853 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015854 cmd->requestor_id = param->requestor_id;
15855 cmd->disable_hw_ack = param->disable_hw_ack;
15856 cmd->cac_duration_ms = param->cac_duration_ms;
15857 cmd->num_vdevs = param->num_vdevs;
15858
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015859 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
15860 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
15861 " cmd->num_vdevs: %d ",
15862 __func__, cmd->pdev_id, cmd->requestor_id,
15863 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015864 buf_ptr += sizeof(*cmd);
15865
15866 WMITLV_SET_HDR(buf_ptr,
15867 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015868 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015869 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15870 for (i = 0; i < param->num_vdevs; i++) {
15871 vdev_ids[i] = param->vdev_ids[i];
15872 }
15873
Vivekc5823092018-03-22 23:27:21 +053015874 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015875
15876 WMITLV_SET_HDR(buf_ptr,
15877 WMITLV_TAG_STRUC_wmi_channel,
15878 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015879 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015880 tchan_info = &(param->ch_param);
15881 chan_info->mhz = tchan_info->mhz;
15882 chan_info->band_center_freq1 = tchan_info->cfreq1;
15883 chan_info->band_center_freq2 = tchan_info->cfreq2;
15884 if (tchan_info->is_chan_passive)
15885 WMI_SET_CHANNEL_FLAG(chan_info,
15886 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015887 if (tchan_info->dfs_set)
15888 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
15889
Sathish Kumar45e991b2017-02-27 10:35:40 +053015890 if (tchan_info->allow_vht)
15891 WMI_SET_CHANNEL_FLAG(chan_info,
15892 WMI_CHAN_FLAG_ALLOW_VHT);
15893 else if (tchan_info->allow_ht)
15894 WMI_SET_CHANNEL_FLAG(chan_info,
15895 WMI_CHAN_FLAG_ALLOW_HT);
15896 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15897 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15898 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15899 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15900 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15901 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080015902 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015903
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015904 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
15905 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
15906 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
15907 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
15908 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
15909 "tchan_info->reg_class_id: %d ,"
15910 "tchan_info->maxregpower : %d ", __func__,
15911 tchan_info->is_chan_passive, tchan_info->dfs_set,
15912 tchan_info->allow_vht, tchan_info->allow_ht,
15913 tchan_info->antennamax, tchan_info->phy_mode,
15914 tchan_info->minpower, tchan_info->maxpower,
15915 tchan_info->maxregpower, tchan_info->reg_class_id,
15916 tchan_info->maxregpower);
15917
Sathish Kumar45e991b2017-02-27 10:35:40 +053015918 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15919 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15920
15921 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15922 WMI_LOGE("%s: Failed to send\n", __func__);
15923 wmi_buf_free(buf);
15924 }
15925
15926end:
15927 return qdf_status;
15928}
15929
15930/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015931 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15932 * @wmi_handle: wmi handle
15933 * @pdev_id: pdev id
15934 *
15935 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15936 *
15937 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15938 */
15939static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15940 uint32_t pdev_id)
15941{
15942 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
15943 wmi_buf_t buf;
15944 uint16_t len;
15945 QDF_STATUS ret;
15946
15947 len = sizeof(*cmd);
15948 buf = wmi_buf_alloc(wmi_handle, len);
15949
15950 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15951
15952 if (!buf) {
15953 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15954 return QDF_STATUS_E_NOMEM;
15955 }
15956
15957 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
15958 wmi_buf_data(buf);
15959
15960 WMITLV_SET_HDR(&cmd->tlv_header,
15961 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
15962 WMITLV_GET_STRUCT_TLVLEN(
15963 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
15964
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015965 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015966 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15967 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
15968 if (QDF_IS_STATUS_ERROR(ret)) {
15969 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15970 __func__, ret, pdev_id);
15971 wmi_buf_free(buf);
15972 return QDF_STATUS_E_FAILURE;
15973 }
15974
15975 return QDF_STATUS_SUCCESS;
15976}
15977
15978/**
15979 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
15980 * @wmi_handle: wmi handle
15981 * @pdev_id: pdev id
15982 *
15983 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
15984 *
15985 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15986 */
15987static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
15988 uint32_t pdev_id)
15989{
15990 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
15991 wmi_buf_t buf;
15992 uint16_t len;
15993 QDF_STATUS ret;
15994
15995 len = sizeof(*cmd);
15996 buf = wmi_buf_alloc(wmi_handle, len);
15997
15998 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15999
16000 if (!buf) {
16001 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16002 return QDF_STATUS_E_NOMEM;
16003 }
16004
16005 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16006 wmi_buf_data(buf);
16007
16008 WMITLV_SET_HDR(&cmd->tlv_header,
16009 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16010 WMITLV_GET_STRUCT_TLVLEN(
16011 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16012
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016013 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016014 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16015 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16016 if (QDF_IS_STATUS_ERROR(ret)) {
16017 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16018 __func__, ret, pdev_id);
16019 wmi_buf_free(buf);
16020 return QDF_STATUS_E_FAILURE;
16021 }
16022
16023 return QDF_STATUS_SUCCESS;
16024}
16025
16026/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016027 * init_cmd_send_tlv() - send initialization cmd to fw
16028 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016029 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016030 *
16031 * Return: QDF_STATUS_SUCCESS for success or error code
16032 */
16033static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016034 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016035{
16036 wmi_buf_t buf;
16037 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016038 uint8_t *buf_ptr;
16039 wmi_resource_config *resource_cfg;
16040 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016041 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016042 uint16_t idx;
16043 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016044 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016045
Kiran Venkatappa26117052016-12-23 19:58:54 +053016046 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16047 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016048 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016049
16050 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16051 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16052 WMI_TLV_HDR_SIZE +
16053 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16054
16055 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016056 if (!buf) {
16057 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16058 return QDF_STATUS_E_FAILURE;
16059 }
16060
16061 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16062 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16063 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16064
16065 host_mem_chunks = (wlan_host_memory_chunk *)
16066 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16067 + WMI_TLV_HDR_SIZE);
16068
16069 WMITLV_SET_HDR(&cmd->tlv_header,
16070 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16071 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16072
Kiran Venkatappa26117052016-12-23 19:58:54 +053016073 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016074 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16075 WMITLV_TAG_STRUC_wmi_resource_config,
16076 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16077
Kiran Venkatappa26117052016-12-23 19:58:54 +053016078 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016079 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16080 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16081 WMITLV_GET_STRUCT_TLVLEN
16082 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016083 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16084 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16085 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016086 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16087 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016088 idx, host_mem_chunks[idx].size,
16089 host_mem_chunks[idx].ptr);
16090 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016091 cmd->num_host_mem_chunks = param->num_mem_chunks;
16092 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16093
Govind Singhe7f2f342016-05-23 12:12:52 +053016094 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16095 WMITLV_TAG_ARRAY_STRUC,
16096 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016097 param->num_mem_chunks));
16098
16099 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016100 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016101
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016102 /* Fill fw_abi_vers */
16103 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016104
Abhishek Singh716c46c2016-05-04 16:24:07 +053016105 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16106 if (QDF_IS_STATUS_ERROR(ret)) {
16107 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16108 ret);
16109 wmi_buf_free(buf);
16110 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016111
Abhishek Singh716c46c2016-05-04 16:24:07 +053016112 return ret;
16113
Govind Singhe7f2f342016-05-23 12:12:52 +053016114}
16115
16116/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016117 * send_addba_send_cmd_tlv() - send addba send command to fw
16118 * @wmi_handle: wmi handle
16119 * @param: pointer to delba send params
16120 * @macaddr: peer mac address
16121 *
16122 * Send WMI_ADDBA_SEND_CMDID command to firmware
16123 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16124 */
16125static QDF_STATUS
16126send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
16127 uint8_t macaddr[IEEE80211_ADDR_LEN],
16128 struct addba_send_params *param)
16129{
16130 wmi_addba_send_cmd_fixed_param *cmd;
16131 wmi_buf_t buf;
16132 uint16_t len;
16133 QDF_STATUS ret;
16134
16135 len = sizeof(*cmd);
16136
16137 buf = wmi_buf_alloc(wmi_handle, len);
16138 if (!buf) {
16139 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16140 return QDF_STATUS_E_NOMEM;
16141 }
16142
16143 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
16144
16145 WMITLV_SET_HDR(&cmd->tlv_header,
16146 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
16147 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
16148
16149 cmd->vdev_id = param->vdev_id;
16150 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16151 cmd->tid = param->tidno;
16152 cmd->buffersize = param->buffersize;
16153
16154 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
16155 if (QDF_IS_STATUS_ERROR(ret)) {
16156 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16157 wmi_buf_free(buf);
16158 return QDF_STATUS_E_FAILURE;
16159 }
16160
16161 return QDF_STATUS_SUCCESS;
16162}
16163
16164/**
16165 * send_delba_send_cmd_tlv() - send delba send command to fw
16166 * @wmi_handle: wmi handle
16167 * @param: pointer to delba send params
16168 * @macaddr: peer mac address
16169 *
16170 * Send WMI_DELBA_SEND_CMDID command to firmware
16171 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16172 */
16173static QDF_STATUS
16174send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
16175 uint8_t macaddr[IEEE80211_ADDR_LEN],
16176 struct delba_send_params *param)
16177{
16178 wmi_delba_send_cmd_fixed_param *cmd;
16179 wmi_buf_t buf;
16180 uint16_t len;
16181 QDF_STATUS ret;
16182
16183 len = sizeof(*cmd);
16184
16185 buf = wmi_buf_alloc(wmi_handle, len);
16186 if (!buf) {
16187 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16188 return QDF_STATUS_E_NOMEM;
16189 }
16190
16191 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
16192
16193 WMITLV_SET_HDR(&cmd->tlv_header,
16194 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
16195 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
16196
16197 cmd->vdev_id = param->vdev_id;
16198 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16199 cmd->tid = param->tidno;
16200 cmd->initiator = param->initiator;
16201 cmd->reasoncode = param->reasoncode;
16202
16203 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
16204 if (QDF_IS_STATUS_ERROR(ret)) {
16205 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16206 wmi_buf_free(buf);
16207 return QDF_STATUS_E_FAILURE;
16208 }
16209
16210 return QDF_STATUS_SUCCESS;
16211}
16212
16213/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016214 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
16215 * to fw
16216 * @wmi_handle: wmi handle
16217 * @param: pointer to addba clearresp params
16218 * @macaddr: peer mac address
16219 * Return: 0 for success or error code
16220 */
16221static QDF_STATUS
16222send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
16223 uint8_t macaddr[IEEE80211_ADDR_LEN],
16224 struct addba_clearresponse_params *param)
16225{
16226 wmi_addba_clear_resp_cmd_fixed_param *cmd;
16227 wmi_buf_t buf;
16228 uint16_t len;
16229 QDF_STATUS ret;
16230
16231 len = sizeof(*cmd);
16232
16233 buf = wmi_buf_alloc(wmi_handle, len);
16234 if (!buf) {
16235 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
16236 return QDF_STATUS_E_FAILURE;
16237 }
16238 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
16239
16240 WMITLV_SET_HDR(&cmd->tlv_header,
16241 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
16242 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
16243
16244 cmd->vdev_id = param->vdev_id;
16245 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16246
16247 ret = wmi_unified_cmd_send(wmi_handle,
16248 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
16249 if (QDF_IS_STATUS_ERROR(ret)) {
16250 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16251 wmi_buf_free(buf);
16252 return QDF_STATUS_E_FAILURE;
16253 }
16254
16255 return QDF_STATUS_SUCCESS;
16256}
16257
16258/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016259 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16260 * @wmi_handle: wmi handle
16261 * @bcn_ctrl_param: pointer to bcn_offload_control param
16262 *
16263 * Return: QDF_STATUS_SUCCESS for success or error code
16264 */
16265static
16266QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16267 struct bcn_offload_control *bcn_ctrl_param)
16268{
16269 wmi_buf_t buf;
16270 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16271 QDF_STATUS ret;
16272 uint32_t len;
16273
16274 len = sizeof(*cmd);
16275
16276 buf = wmi_buf_alloc(wmi_handle, len);
16277 if (!buf) {
16278 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16279 return QDF_STATUS_E_FAILURE;
16280 }
16281
16282 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16283 WMITLV_SET_HDR(&cmd->tlv_header,
16284 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16285 WMITLV_GET_STRUCT_TLVLEN
16286 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16287 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016288 switch (bcn_ctrl_param->bcn_ctrl_op) {
16289 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016290 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016291 break;
16292 case BCN_OFFLD_CTRL_TX_ENABLE:
16293 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16294 break;
16295 case BCN_OFFLD_CTRL_SWBA_DISABLE:
16296 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
16297 break;
16298 case BCN_OFFLD_CTRL_SWBA_ENABLE:
16299 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
16300 break;
16301 default:
16302 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
16303 bcn_ctrl_param->bcn_ctrl_op);
16304 wmi_buf_free(buf);
16305 return QDF_STATUS_E_FAILURE;
16306 break;
16307 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016308 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16309 WMI_BCN_OFFLOAD_CTRL_CMDID);
16310
16311 if (QDF_IS_STATUS_ERROR(ret)) {
16312 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16313 ret);
16314 wmi_buf_free(buf);
16315 }
16316
16317 return ret;
16318}
16319
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016320#ifdef WLAN_FEATURE_NAN_CONVERGENCE
16321static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
16322 struct nan_datapath_initiator_req *ndp_req)
16323{
16324 uint16_t len;
16325 wmi_buf_t buf;
16326 uint8_t *tlv_ptr;
16327 QDF_STATUS status;
16328 wmi_channel *ch_tlv;
16329 wmi_ndp_initiator_req_fixed_param *cmd;
16330 uint32_t passphrase_len, service_name_len;
16331 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016332 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016333
16334 /*
16335 * WMI command expects 4 byte alligned len:
16336 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16337 */
16338 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
16339 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
16340 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
16341 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
16342 service_name_len =
16343 qdf_roundup(ndp_req->service_name.service_name_len, 4);
16344 /* allocated memory for fixed params as well as variable size data */
16345 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
16346 + ndp_cfg_len + ndp_app_info_len + pmk_len
16347 + passphrase_len + service_name_len;
16348
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016349 if (ndp_req->is_ipv6_addr_present)
16350 len += sizeof(*tcp_ip_param);
16351
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016352 buf = wmi_buf_alloc(wmi_handle, len);
16353 if (!buf) {
16354 WMI_LOGE("wmi_buf_alloc failed");
16355 return QDF_STATUS_E_NOMEM;
16356 }
16357
16358 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
16359 WMITLV_SET_HDR(&cmd->tlv_header,
16360 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
16361 WMITLV_GET_STRUCT_TLVLEN(
16362 wmi_ndp_initiator_req_fixed_param));
16363 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
16364 cmd->transaction_id = ndp_req->transaction_id;
16365 cmd->service_instance_id = ndp_req->service_instance_id;
16366 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
16367 &cmd->peer_discovery_mac_addr);
16368
16369 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
16370 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
16371 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
16372 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
16373 cmd->nan_csid = ndp_req->ncs_sk_type;
16374 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
16375 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
16376
16377 ch_tlv = (wmi_channel *)&cmd[1];
16378 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
16379 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
16380 ch_tlv->mhz = ndp_req->channel;
16381 tlv_ptr = (uint8_t *)&ch_tlv[1];
16382
16383 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16384 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16385 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16386 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16387
16388 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16389 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16390 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
16391 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16392
16393 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16394 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
16395 cmd->nan_pmk_len);
16396 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16397
16398 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16399 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
16400 cmd->nan_passphrase_len);
16401 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16402
16403 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16404 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16405 ndp_req->service_name.service_name,
16406 cmd->nan_servicename_len);
16407 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16408
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016409 if (ndp_req->is_ipv6_addr_present) {
16410 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16411 WMITLV_SET_HDR(tcp_ip_param,
16412 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16413 WMITLV_GET_STRUCT_TLVLEN(
16414 wmi_ndp_transport_ip_param));
16415 tcp_ip_param->ipv6_addr_present = true;
16416 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16417 ndp_req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16418 }
16419 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16420 ndp_req->is_ipv6_addr_present, ndp_req->ipv6_addr);
16421
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016422 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
16423 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
16424 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
16425 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16426 cmd->peer_discovery_mac_addr.mac_addr31to0,
16427 cmd->peer_discovery_mac_addr.mac_addr47to32);
16428
16429 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016430 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016431 ndp_req->ndp_config.ndp_cfg,
16432 ndp_req->ndp_config.ndp_cfg_len);
16433
16434 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016435 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016436 ndp_req->ndp_info.ndp_app_info,
16437 ndp_req->ndp_info.ndp_app_info_len);
16438
16439 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016440 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016441 ndp_req->pmk.pmk, cmd->nan_pmk_len);
16442
16443 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016444 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016445 ndp_req->passphrase.passphrase,
16446 cmd->nan_passphrase_len);
16447
16448 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016449 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016450 ndp_req->service_name.service_name,
16451 cmd->nan_servicename_len);
16452
16453 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
16454 WMI_NDP_INITIATOR_REQ_CMDID);
16455
16456 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16457 WMI_NDP_INITIATOR_REQ_CMDID);
16458 if (QDF_IS_STATUS_ERROR(status)) {
16459 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
16460 wmi_buf_free(buf);
16461 }
16462
16463 return status;
16464}
16465
16466static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
16467 struct nan_datapath_responder_req *req)
16468{
16469 uint16_t len;
16470 wmi_buf_t buf;
16471 uint8_t *tlv_ptr;
16472 QDF_STATUS status;
16473 wmi_ndp_responder_req_fixed_param *cmd;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016474 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016475 uint32_t passphrase_len, service_name_len;
16476 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
16477
16478 vdev_id = wlan_vdev_get_id(req->vdev);
16479 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
16480 vdev_id, req->transaction_id,
16481 req->ndp_rsp,
16482 req->ndp_instance_id,
16483 req->ndp_info.ndp_app_info_len);
16484
16485 /*
16486 * WMI command expects 4 byte alligned len:
16487 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16488 */
16489 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
16490 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
16491 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
16492 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
16493 service_name_len =
16494 qdf_roundup(req->service_name.service_name_len, 4);
16495
16496 /* allocated memory for fixed params as well as variable size data */
16497 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
16498 + pmk_len + passphrase_len + service_name_len;
16499
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016500 if (req->is_ipv6_addr_present || req->is_port_present ||
16501 req->is_protocol_present)
16502 len += sizeof(*tcp_ip_param);
16503
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016504 buf = wmi_buf_alloc(wmi_handle, len);
16505 if (!buf) {
16506 WMI_LOGE("wmi_buf_alloc failed");
16507 return QDF_STATUS_E_NOMEM;
16508 }
16509 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
16510 WMITLV_SET_HDR(&cmd->tlv_header,
16511 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
16512 WMITLV_GET_STRUCT_TLVLEN(
16513 wmi_ndp_responder_req_fixed_param));
16514 cmd->vdev_id = vdev_id;
16515 cmd->transaction_id = req->transaction_id;
16516 cmd->ndp_instance_id = req->ndp_instance_id;
16517 cmd->rsp_code = req->ndp_rsp;
16518 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
16519 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
16520 cmd->nan_pmk_len = req->pmk.pmk_len;
16521 cmd->nan_csid = req->ncs_sk_type;
16522 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
16523 cmd->nan_servicename_len = req->service_name.service_name_len;
16524
16525 tlv_ptr = (uint8_t *)&cmd[1];
16526 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16527 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16528 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16529
16530 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16531 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16532 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16533 req->ndp_info.ndp_app_info,
16534 req->ndp_info.ndp_app_info_len);
16535
16536 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16537 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16538 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
16539 cmd->nan_pmk_len);
16540
16541 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16542 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16543 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16544 req->passphrase.passphrase,
16545 cmd->nan_passphrase_len);
16546 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16547
16548 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16549 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16550 req->service_name.service_name,
16551 cmd->nan_servicename_len);
16552
16553 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16554
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016555 if (req->is_ipv6_addr_present || req->is_port_present ||
16556 req->is_protocol_present) {
16557 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16558 WMITLV_SET_HDR(tcp_ip_param,
16559 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16560 WMITLV_GET_STRUCT_TLVLEN(
16561 wmi_ndp_transport_ip_param));
16562 tcp_ip_param->ipv6_addr_present = req->is_ipv6_addr_present;
16563 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16564 req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16565
16566 tcp_ip_param->trans_port_present = req->is_port_present;
16567 tcp_ip_param->transport_port = req->port;
16568
16569 tcp_ip_param->trans_proto_present = req->is_protocol_present;
16570 tcp_ip_param->transport_protocol = req->protocol;
16571 }
16572 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16573 req->is_ipv6_addr_present, req->ipv6_addr);
16574 WMI_LOGD(FL("port: %d present: %d"), req->is_port_present, req->port);
16575 WMI_LOGD(FL("protocol: %d present: %d"),
16576 req->is_protocol_present, req->protocol);
16577
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016578 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
16579 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
16580
16581 WMI_LOGD("ndp_config len: %d",
16582 req->ndp_config.ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016583 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016584 req->ndp_config.ndp_cfg,
16585 req->ndp_config.ndp_cfg_len);
16586
16587 WMI_LOGD("ndp_app_info len: %d",
16588 req->ndp_info.ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016589 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016590 req->ndp_info.ndp_app_info,
16591 req->ndp_info.ndp_app_info_len);
16592
16593 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016594 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016595 req->pmk.pmk, cmd->nan_pmk_len);
16596
16597 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016598 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016599 req->passphrase.passphrase,
16600 cmd->nan_passphrase_len);
16601
16602 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016603 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016604 req->service_name.service_name,
16605 cmd->nan_servicename_len);
16606
16607 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
16608 WMI_NDP_RESPONDER_REQ_CMDID);
16609 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16610 WMI_NDP_RESPONDER_REQ_CMDID);
16611 if (QDF_IS_STATUS_ERROR(status)) {
16612 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
16613 wmi_buf_free(buf);
16614 }
16615 return status;
16616}
16617
16618static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
16619 struct nan_datapath_end_req *req)
16620{
16621 uint16_t len;
16622 wmi_buf_t buf;
16623 QDF_STATUS status;
16624 uint32_t ndp_end_req_len, i;
16625 wmi_ndp_end_req *ndp_end_req_lst;
16626 wmi_ndp_end_req_fixed_param *cmd;
16627
16628 /* len of tlv following fixed param */
16629 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
16630 /* above comes out to 4 byte alligned already, no need of padding */
16631 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
16632 buf = wmi_buf_alloc(wmi_handle, len);
16633 if (!buf) {
16634 WMI_LOGE("Malloc failed");
16635 return QDF_STATUS_E_NOMEM;
16636 }
16637
16638 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
16639 WMITLV_SET_HDR(&cmd->tlv_header,
16640 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
16641 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
16642
16643 cmd->transaction_id = req->transaction_id;
16644
16645 /* set tlv pointer to end of fixed param */
16646 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
16647 ndp_end_req_len);
16648
16649 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
16650 WMI_TLV_HDR_SIZE);
16651 for (i = 0; i < req->num_ndp_instances; i++) {
16652 WMITLV_SET_HDR(&ndp_end_req_lst[i],
16653 WMITLV_TAG_ARRAY_FIXED_STRUC,
16654 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
16655
16656 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
16657 }
16658
16659 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
16660 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16661 WMI_NDP_END_REQ_CMDID);
16662 if (QDF_IS_STATUS_ERROR(status)) {
16663 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
16664 wmi_buf_free(buf);
16665 }
16666
16667 return status;
16668}
16669
16670static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016671 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016672{
16673 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
16674 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
16675
16676 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
16677 fixed_params = event->fixed_param;
16678
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016679 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016680 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16681 fixed_params->vdev_id,
16682 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016683 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016684 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016685 return QDF_STATUS_E_INVAL;
16686 }
16687
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016688 rsp->transaction_id = fixed_params->transaction_id;
16689 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16690 rsp->status = fixed_params->rsp_status;
16691 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016692
16693 return QDF_STATUS_SUCCESS;
16694}
16695
16696static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016697 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016698{
16699 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
16700 wmi_ndp_indication_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016701 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016702
16703 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
16704 fixed_params =
16705 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
16706
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016707 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16708 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16709 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16710 return QDF_STATUS_E_INVAL;
16711 }
16712
16713 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16714 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16715 fixed_params->ndp_app_info_len,
16716 event->num_ndp_app_info);
16717 return QDF_STATUS_E_INVAL;
16718 }
16719
gaolezab037cf2018-05-23 14:40:32 +080016720 if (fixed_params->ndp_cfg_len >
16721 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16722 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16723 __func__, fixed_params->ndp_cfg_len);
16724 return QDF_STATUS_E_INVAL;
16725 }
16726
16727 total_array_len = fixed_params->ndp_cfg_len +
16728 sizeof(*fixed_params);
16729
16730 if (fixed_params->ndp_app_info_len >
16731 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16732 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16733 __func__, fixed_params->ndp_app_info_len);
16734 return QDF_STATUS_E_INVAL;
16735 }
16736 total_array_len += fixed_params->ndp_app_info_len;
16737
16738 if (fixed_params->nan_scid_len >
16739 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16740 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16741 __func__, fixed_params->nan_scid_len);
16742 return QDF_STATUS_E_INVAL;
16743 }
16744
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016745 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016746 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16747 fixed_params->vdev_id,
16748 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016749 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016750 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016751 return QDF_STATUS_E_INVAL;
16752 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016753 rsp->service_instance_id = fixed_params->service_instance_id;
16754 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16755 rsp->role = fixed_params->self_ndp_role;
16756 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016757
16758 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016759 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016760 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016761 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016762
16763 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
16764 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
16765 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
16766 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
16767 fixed_params->service_instance_id,
16768 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
16769 fixed_params->accept_policy,
16770 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016771 rsp->peer_mac_addr.bytes,
16772 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016773
16774 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016775 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016776 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16777
16778 WMI_LOGD("ndp_app_info - %d bytes",
16779 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016780 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016781 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16782
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016783 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
16784 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16785 rsp->ncs_sk_type = fixed_params->nan_csid;
16786 rsp->scid.scid_len = fixed_params->nan_scid_len;
Lihua Liue950ad12018-07-02 18:55:56 +080016787
16788 if (rsp->ndp_config.ndp_cfg_len > NDP_QOS_INFO_LEN)
16789 rsp->ndp_config.ndp_cfg_len = NDP_QOS_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016790 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
16791 rsp->ndp_config.ndp_cfg_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016792
16793 if (rsp->ndp_info.ndp_app_info_len > NDP_APP_INFO_LEN)
16794 rsp->ndp_info.ndp_app_info_len = NDP_APP_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016795 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16796 rsp->ndp_info.ndp_app_info_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016797
16798 if (rsp->scid.scid_len > NDP_SCID_BUF_LEN)
16799 rsp->scid.scid_len = NDP_SCID_BUF_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016800 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016801
16802 if (event->ndp_transport_ip_param &&
16803 event->num_ndp_transport_ip_param) {
16804 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16805 rsp->is_ipv6_addr_present = true;
16806 qdf_mem_copy(rsp->ipv6_addr,
16807 event->ndp_transport_ip_param->ipv6_intf_addr,
16808 WMI_NDP_IPV6_INTF_ADDR_LEN);
16809 }
16810 }
16811 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16812 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16813
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016814 WMI_LOGD("scid hex dump:");
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016815 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016816 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016817
16818 return QDF_STATUS_SUCCESS;
16819}
16820
16821static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016822 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016823{
Naveen Rawat38b21462018-05-31 15:04:16 -070016824 uint8_t i;
16825 WMI_HOST_WLAN_PHY_MODE ch_mode;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016826 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
16827 wmi_ndp_confirm_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016828 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016829
16830 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
16831 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070016832 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 -080016833 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
16834 fixed_params->ndp_instance_id, fixed_params->rsp_code,
16835 fixed_params->reason_code,
16836 fixed_params->num_active_ndps_on_peer);
Naveen Rawat38b21462018-05-31 15:04:16 -070016837 WMI_LOGE("num_ch: %d", fixed_params->num_ndp_channels);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016838
16839 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16840 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16841 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16842 return QDF_STATUS_E_INVAL;
16843 }
16844
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016845 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016846 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016847 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16848
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016849 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16850 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16851 fixed_params->ndp_app_info_len,
16852 event->num_ndp_app_info);
16853 return QDF_STATUS_E_INVAL;
16854 }
16855
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016856 WMI_LOGD("ndp_app_info - %d bytes",
16857 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016858 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016859 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16860
gaolezab037cf2018-05-23 14:40:32 +080016861 if (fixed_params->ndp_cfg_len >
16862 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16863 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16864 __func__, fixed_params->ndp_cfg_len);
16865 return QDF_STATUS_E_INVAL;
16866 }
16867
16868 total_array_len = fixed_params->ndp_cfg_len +
16869 sizeof(*fixed_params);
16870
16871 if (fixed_params->ndp_app_info_len >
16872 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16873 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16874 __func__, fixed_params->ndp_app_info_len);
16875 return QDF_STATUS_E_INVAL;
16876 }
16877
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016878 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016879 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16880 fixed_params->vdev_id,
16881 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016882 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016883 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016884 return QDF_STATUS_E_INVAL;
16885 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016886 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16887 rsp->rsp_code = fixed_params->rsp_code;
16888 rsp->reason_code = fixed_params->reason_code;
16889 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat38b21462018-05-31 15:04:16 -070016890 rsp->num_channels = fixed_params->num_ndp_channels;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016891 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016892 rsp->peer_ndi_mac_addr.bytes);
16893 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16894 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16895 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016896
Naveen Rawat38b21462018-05-31 15:04:16 -070016897 if (rsp->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
16898 WMI_LOGE(FL("too many channels"));
16899 rsp->num_channels = NAN_CH_INFO_MAX_CHANNELS;
16900 }
16901
16902 for (i = 0; i < rsp->num_channels; i++) {
16903 rsp->ch[i].channel = event->ndp_channel_list[i].mhz;
16904 rsp->ch[i].nss = event->nss_list[i];
16905 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndp_channel_list[i]);
16906 rsp->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
16907 ch_mode);
16908 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
16909 rsp->ch[i].channel,
16910 rsp->ch[i].ch_width,
16911 rsp->ch[i].nss);
16912 }
16913
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016914 if (event->ndp_transport_ip_param &&
16915 event->num_ndp_transport_ip_param) {
16916 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16917 rsp->is_ipv6_addr_present = true;
16918 qdf_mem_copy(rsp->ipv6_addr,
16919 event->ndp_transport_ip_param->ipv6_intf_addr,
16920 WMI_NDP_IPV6_INTF_ADDR_LEN);
16921 }
16922
16923 if (event->ndp_transport_ip_param->trans_port_present) {
16924 rsp->is_port_present = true;
16925 rsp->port =
16926 event->ndp_transport_ip_param->transport_port;
16927 }
16928
16929 if (event->ndp_transport_ip_param->trans_proto_present) {
16930 rsp->is_protocol_present = true;
16931 rsp->protocol =
16932 event->ndp_transport_ip_param->transport_protocol;
16933 }
16934 }
16935 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16936 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16937 WMI_LOGD(FL("port: %d present: %d"), rsp->port, rsp->is_port_present);
16938 WMI_LOGD(FL("protocol: %d present: %d"),
16939 rsp->protocol, rsp->is_protocol_present);
16940
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016941 return QDF_STATUS_SUCCESS;
16942}
16943
16944static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016945 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016946{
16947 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
16948 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
16949
16950 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
16951 fixed_params = event->fixed_param;
16952
16953 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",
16954 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016955 rsp->peer_mac_addr.bytes, rsp->transaction_id,
16956 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016957
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016958 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016959 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16960 fixed_params->vdev_id,
16961 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016962 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016963 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016964 return QDF_STATUS_E_INVAL;
16965 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016966 rsp->transaction_id = fixed_params->transaction_id;
16967 rsp->reason = fixed_params->reason_code;
16968 rsp->status = fixed_params->rsp_status;
16969 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016970 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016971 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016972
16973 return QDF_STATUS_SUCCESS;
16974}
16975
16976static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016977 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016978{
16979 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
16980 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
16981
16982 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
16983 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070016984 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 -080016985 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
16986 fixed_params->rsp_status, fixed_params->reason_code);
16987
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016988 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016989 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016990 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016991 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016992 return QDF_STATUS_E_INVAL;
16993 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016994 rsp->transaction_id = fixed_params->transaction_id;
16995 rsp->reason = fixed_params->reason_code;
16996 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016997
16998 return QDF_STATUS_SUCCESS;
16999}
17000
17001static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17002 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17003{
17004 uint32_t i, buf_size;
17005 wmi_ndp_end_indication *ind;
17006 struct qdf_mac_addr peer_addr;
17007 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17008
17009 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17010 ind = event->ndp_end_indication_list;
17011
17012 if (event->num_ndp_end_indication_list == 0) {
17013 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017014 return QDF_STATUS_E_INVAL;
17015 }
17016
17017 WMI_LOGD("number of ndp instances = %d",
17018 event->num_ndp_end_indication_list);
17019
17020 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17021 sizeof((*rsp)->ndp_map[0]))) {
17022 WMI_LOGE("num_ndp_end_ind_list %d too large",
17023 event->num_ndp_end_indication_list);
17024 return QDF_STATUS_E_INVAL;
17025 }
17026
17027 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17028 sizeof((*rsp)->ndp_map[0]);
17029 *rsp = qdf_mem_malloc(buf_size);
17030 if (!(*rsp)) {
17031 WMI_LOGE("Failed to allocate memory");
17032 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017033 }
17034
17035 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17036 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17037 if (!(*rsp)->vdev) {
17038 WMI_LOGE("vdev is null");
17039 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017040 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017041 return QDF_STATUS_E_INVAL;
17042 }
17043
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017044 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17045 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17046 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17047 peer_addr.bytes);
17048 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17049 i, ind[i].type, ind[i].reason_code,
17050 ind[i].ndp_instance_id,
17051 ind[i].num_active_ndps_on_peer);
17052 /* Add each instance entry to the list */
17053 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17054 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17055 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17056 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17057 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17058 ind[i].num_active_ndps_on_peer;
17059 (*rsp)->ndp_map[i].type = ind[i].type;
17060 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17061 }
17062
17063 return QDF_STATUS_SUCCESS;
17064}
Naveen Rawatd42ce382018-01-09 17:54:41 -080017065
17066static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,
17067 uint8_t *data, struct nan_datapath_sch_update_event *ind)
17068{
17069 uint8_t i;
17070 WMI_HOST_WLAN_PHY_MODE ch_mode;
17071 WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *event;
17072 wmi_ndl_schedule_update_fixed_param *fixed_params;
17073
17074 event = (WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *)data;
17075 fixed_params = event->fixed_param;
17076
17077 WMI_LOGD(FL("flags: %d, num_ch: %d, num_ndp_instances: %d"),
17078 fixed_params->flags, fixed_params->num_channels,
17079 fixed_params->num_ndp_instances);
17080
17081 ind->vdev =
17082 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17083 fixed_params->vdev_id,
17084 WLAN_NAN_ID);
17085 if (!ind->vdev) {
17086 WMI_LOGE("vdev is null");
17087 return QDF_STATUS_E_INVAL;
17088 }
17089
17090 ind->flags = fixed_params->flags;
17091 ind->num_channels = fixed_params->num_channels;
17092 ind->num_ndp_instances = fixed_params->num_ndp_instances;
17093 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_macaddr,
17094 ind->peer_addr.bytes);
17095
17096 if (ind->num_ndp_instances > NDP_NUM_INSTANCE_ID) {
17097 WMI_LOGE(FL("uint32 overflow"));
17098 wlan_objmgr_vdev_release_ref(ind->vdev, WLAN_NAN_ID);
17099 return QDF_STATUS_E_INVAL;
17100 }
17101
17102 qdf_mem_copy(ind->ndp_instances, event->ndp_instance_list,
17103 sizeof(uint32_t) * ind->num_ndp_instances);
17104
17105 if (ind->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
17106 WMI_LOGE(FL("too many channels"));
17107 ind->num_channels = NAN_CH_INFO_MAX_CHANNELS;
17108 }
17109 for (i = 0; i < ind->num_channels; i++) {
17110 ind->ch[i].channel = event->ndl_channel_list[i].mhz;
17111 ind->ch[i].nss = event->nss_list[i];
17112 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]);
17113 ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
17114 ch_mode);
17115 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
17116 ind->ch[i].channel,
17117 ind->ch[i].ch_width,
17118 ind->ch[i].nss);
17119 }
17120
17121 for (i = 0; i < fixed_params->num_ndp_instances; i++)
17122 WMI_LOGD(FL("instance_id[%d]: %d"),
17123 i, event->ndp_instance_list[i]);
17124
17125 return QDF_STATUS_SUCCESS;
17126}
17127
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017128#endif
17129
Naveen Rawat963ee942018-04-13 16:38:36 -070017130#ifdef QCA_SUPPORT_CP_STATS
17131/**
17132 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
17133 * @wmi_handle: wma handle
17134 * @evt_buf: event buffer
17135 * @out_buff: buffer to populated after stats extraction
17136 *
17137 * Return: status of operation
17138 */
17139static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
17140 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
17141{
17142 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17143 wmi_congestion_stats *congestion_stats;
17144
17145 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
17146 congestion_stats = param_buf->congestion_stats;
17147 if (!congestion_stats) {
17148 WMI_LOGD("%s: no cca stats in event buffer", __func__);
17149 return QDF_STATUS_E_INVAL;
17150 }
17151
17152 out_buff->vdev_id = congestion_stats->vdev_id;
17153 out_buff->congestion = congestion_stats->congestion;
17154
17155 WMI_LOGD("%s: cca stats event processed", __func__);
17156 return QDF_STATUS_SUCCESS;
17157}
17158#endif /* QCA_SUPPORT_CP_STATS */
17159
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017160/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017161 * save_service_bitmap_tlv() - save service bitmap
17162 * @wmi_handle: wmi handle
17163 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017164 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017165 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017166 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017167 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017168static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017169QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017170 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017171{
17172 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017173 struct wmi_soc *soc = wmi_handle->soc;
17174
Govind Singhe7f2f342016-05-23 12:12:52 +053017175 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17176
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017177 /* If it is already allocated, use that buffer. This can happen
17178 * during target stop/start scenarios where host allocation is skipped.
17179 */
17180 if (!soc->wmi_service_bitmap) {
17181 soc->wmi_service_bitmap =
17182 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17183 if (!soc->wmi_service_bitmap) {
17184 WMI_LOGE("Failed memory allocation for service bitmap");
17185 return QDF_STATUS_E_NOMEM;
17186 }
17187 }
17188
17189 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017190 param_buf->wmi_service_bitmap,
17191 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017192
17193 if (bitmap_buf)
17194 qdf_mem_copy(bitmap_buf,
17195 param_buf->wmi_service_bitmap,
17196 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017197
17198 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017199}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017200
17201/**
17202 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17203 * @wmi_handle: wmi handle
17204 * @param evt_buf: pointer to event buffer
17205 * @param bitmap_buf: bitmap buffer, for converged legacy support
17206 *
17207 * Return: QDF_STATUS
17208 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017209static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017210QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017211 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017212{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017213 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17214 wmi_service_available_event_fixed_param *ev;
17215 struct wmi_soc *soc = wmi_handle->soc;
17216
17217 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17218
17219 ev = param_buf->fixed_param;
17220
17221 /* If it is already allocated, use that buffer. This can happen
17222 * during target stop/start scenarios where host allocation is skipped.
17223 */
17224 if (!soc->wmi_ext_service_bitmap) {
17225 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17226 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17227 if (!soc->wmi_ext_service_bitmap) {
17228 WMI_LOGE("Failed memory allocation for service bitmap");
17229 return QDF_STATUS_E_NOMEM;
17230 }
17231 }
17232
17233 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17234 ev->wmi_service_segment_bitmap,
17235 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017236
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017237 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17238 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17239 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17240
Rajeev Kumar77901472017-02-12 02:12:17 -080017241 if (bitmap_buf)
17242 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017243 soc->wmi_ext_service_bitmap,
17244 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017245
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017246 return QDF_STATUS_SUCCESS;
17247}
Govind Singhe7f2f342016-05-23 12:12:52 +053017248/**
17249 * is_service_enabled_tlv() - Check if service enabled
17250 * @param wmi_handle: wmi handle
17251 * @param service_id: service identifier
17252 *
17253 * Return: 1 enabled, 0 disabled
17254 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017255static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17256 uint32_t service_id)
17257{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017258 struct wmi_soc *soc = wmi_handle->soc;
17259
17260 if (!soc->wmi_service_bitmap) {
17261 WMI_LOGE("WMI service bit map is not saved yet\n");
17262 return false;
17263 }
17264
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017265 /* if wmi_service_enabled was received with extended bitmap,
17266 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017267 */
17268 if (soc->wmi_ext_service_bitmap)
17269 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17270 soc->wmi_ext_service_bitmap,
17271 service_id);
17272
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080017273 if (service_id >= WMI_MAX_SERVICE) {
17274 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
17275 service_id);
17276 return false;
17277 }
17278
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017279 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17280 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017281}
Govind Singhe7f2f342016-05-23 12:12:52 +053017282
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017283static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17284 struct wlan_psoc_target_capability_info *cap)
17285{
17286 /* except LDPC all flags are common betwen legacy and here
17287 * also IBFEER is not defined for TLV
17288 */
17289 cap->ht_cap_info |= ev_target_cap & (
17290 WMI_HT_CAP_ENABLED
17291 | WMI_HT_CAP_HT20_SGI
17292 | WMI_HT_CAP_DYNAMIC_SMPS
17293 | WMI_HT_CAP_TX_STBC
17294 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17295 | WMI_HT_CAP_RX_STBC
17296 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17297 | WMI_HT_CAP_LDPC
17298 | WMI_HT_CAP_L_SIG_TXOP_PROT
17299 | WMI_HT_CAP_MPDU_DENSITY
17300 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17301 | WMI_HT_CAP_HT40_SGI);
17302 if (ev_target_cap & WMI_HT_CAP_LDPC)
17303 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17304 WMI_HOST_HT_CAP_TX_LDPC;
17305}
Govind Singhe7f2f342016-05-23 12:12:52 +053017306/**
17307 * extract_service_ready_tlv() - extract service ready event
17308 * @wmi_handle: wmi handle
17309 * @param evt_buf: pointer to received event buffer
17310 * @param cap: pointer to hold target capability information extracted from even
17311 *
17312 * Return: QDF_STATUS_SUCCESS for success or error code
17313 */
17314static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017315 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017316{
17317 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17318 wmi_service_ready_event_fixed_param *ev;
17319
17320
17321 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17322
17323 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17324 if (!ev) {
17325 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17326 return QDF_STATUS_E_FAILURE;
17327 }
17328
17329 cap->phy_capability = ev->phy_capability;
17330 cap->max_frag_entry = ev->max_frag_entry;
17331 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017332 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017333 cap->vht_cap_info = ev->vht_cap_info;
17334 cap->vht_supp_mcs = ev->vht_supp_mcs;
17335 cap->hw_min_tx_power = ev->hw_min_tx_power;
17336 cap->hw_max_tx_power = ev->hw_max_tx_power;
17337 cap->sys_cap_info = ev->sys_cap_info;
17338 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17339 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17340 cap->max_num_scan_channels = ev->max_num_scan_channels;
17341 cap->max_supported_macs = ev->max_supported_macs;
17342 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17343 cap->txrx_chainmask = ev->txrx_chainmask;
17344 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17345 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017346 cap->fw_version = ev->fw_build_vers;
17347 /* fw_version_1 is not available in TLV. */
17348 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017349
17350 return QDF_STATUS_SUCCESS;
17351}
17352
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017353/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17354 * to host internal WMI_HOST_REGDMN_MODE values.
17355 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17356 * host currently. Add this in the future if required.
17357 * 11AX (Phase II) : 11ax related values are not currently
17358 * advertised separately by FW. As part of phase II regulatory bring-up,
17359 * finalize the advertisement mechanism.
17360 * @target_wireless_mode: target wireless mode received in message
17361 *
17362 * Return: returns the host internal wireless mode.
17363 */
17364static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17365{
17366
17367 uint32_t wireless_modes = 0;
17368
17369 if (target_wireless_mode & REGDMN_MODE_11A)
17370 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17371
17372 if (target_wireless_mode & REGDMN_MODE_TURBO)
17373 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17374
17375 if (target_wireless_mode & REGDMN_MODE_11B)
17376 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17377
17378 if (target_wireless_mode & REGDMN_MODE_PUREG)
17379 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17380
17381 if (target_wireless_mode & REGDMN_MODE_11G)
17382 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
17383
17384 if (target_wireless_mode & REGDMN_MODE_108G)
17385 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
17386
17387 if (target_wireless_mode & REGDMN_MODE_108A)
17388 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
17389
17390 if (target_wireless_mode & REGDMN_MODE_XR)
17391 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
17392
17393 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
17394 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
17395
17396 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
17397 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
17398
17399 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
17400 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
17401
17402 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
17403 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
17404
17405 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
17406 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
17407
17408 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
17409 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
17410
17411 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
17412 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
17413
17414 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
17415 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
17416
17417 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
17418 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
17419
17420 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
17421 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
17422
17423 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
17424 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
17425
17426 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
17427 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
17428
17429 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
17430 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
17431
17432 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
17433 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
17434
17435 return wireless_modes;
17436}
17437
Govind Singhe7f2f342016-05-23 12:12:52 +053017438/**
17439 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
17440 * @wmi_handle: wmi handle
17441 * @param evt_buf: Pointer to event buffer
17442 * @param cap: pointer to hold HAL reg capabilities
17443 *
17444 * Return: QDF_STATUS_SUCCESS for success or error code
17445 */
17446static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017447 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017448{
17449 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17450
17451 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17452
17453 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
17454 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080017455 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053017456
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017457 cap->wireless_modes = convert_wireless_modes_tlv(
17458 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053017459
Govind Singhe7f2f342016-05-23 12:12:52 +053017460 return QDF_STATUS_SUCCESS;
17461}
17462
17463/**
17464 * extract_host_mem_req_tlv() - Extract host memory request event
17465 * @wmi_handle: wmi handle
17466 * @param evt_buf: pointer to event buffer
17467 * @param num_entries: pointer to hold number of entries requested
17468 *
17469 * Return: Number of entries requested
17470 */
17471static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
17472 void *evt_buf, uint8_t *num_entries)
17473{
17474 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17475 wmi_service_ready_event_fixed_param *ev;
17476
17477 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17478
17479 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17480 if (!ev) {
17481 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17482 return NULL;
17483 }
17484
17485 *num_entries = ev->num_mem_reqs;
17486
17487 return (host_mem_req *)param_buf->mem_reqs;
17488}
17489
17490/**
17491 * save_fw_version_in_service_ready_tlv() - Save fw version in service
17492 * ready function
17493 * @wmi_handle: wmi handle
17494 * @param evt_buf: pointer to event buffer
17495 *
17496 * Return: QDF_STATUS_SUCCESS for success or error code
17497 */
17498static QDF_STATUS
17499save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
17500{
17501 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17502 wmi_service_ready_event_fixed_param *ev;
17503
17504
17505 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17506
17507 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17508 if (!ev) {
17509 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17510 return QDF_STATUS_E_FAILURE;
17511 }
17512
17513 /*Save fw version from service ready message */
17514 /*This will be used while sending INIT message */
17515 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
17516 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017517
Govind Singhe7f2f342016-05-23 12:12:52 +053017518 return QDF_STATUS_SUCCESS;
17519}
17520
17521/**
17522 * ready_extract_init_status_tlv() - Extract init status from ready event
17523 * @wmi_handle: wmi handle
17524 * @param evt_buf: Pointer to event buffer
17525 *
17526 * Return: ready status
17527 */
17528static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
17529 void *evt_buf)
17530{
17531 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17532 wmi_ready_event_fixed_param *ev = NULL;
17533
Govind Singhe7f2f342016-05-23 12:12:52 +053017534 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17535 ev = param_buf->fixed_param;
17536
17537 qdf_print("%s:%d\n", __func__, ev->status);
17538
17539 return ev->status;
17540}
17541
17542/**
17543 * ready_extract_mac_addr_tlv() - extract mac address from ready event
17544 * @wmi_handle: wmi handle
17545 * @param evt_buf: pointer to event buffer
17546 * @param macaddr: Pointer to hold MAC address
17547 *
17548 * Return: QDF_STATUS_SUCCESS for success or error code
17549 */
17550static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17551 void *evt_buf, uint8_t *macaddr)
17552{
17553 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17554 wmi_ready_event_fixed_param *ev = NULL;
17555
17556
17557 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17558 ev = param_buf->fixed_param;
17559
17560 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17561
17562 return QDF_STATUS_SUCCESS;
17563}
17564
17565/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017566 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17567 * @wmi_handle: wmi handle
17568 * @param evt_buf: pointer to event buffer
17569 * @param macaddr: Pointer to hold number of MAC addresses
17570 *
17571 * Return: Pointer to addr list
17572 */
17573static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17574 void *evt_buf, uint8_t *num_mac)
17575{
17576 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17577 wmi_ready_event_fixed_param *ev = NULL;
17578
17579 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17580 ev = param_buf->fixed_param;
17581
17582 *num_mac = ev->num_extra_mac_addr;
17583
17584 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17585}
17586
17587/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017588 * extract_ready_params_tlv() - Extract data from ready event apart from
17589 * status, macaddr and version.
17590 * @wmi_handle: Pointer to WMI handle.
17591 * @evt_buf: Pointer to Ready event buffer.
17592 * @ev_param: Pointer to host defined struct to copy the data from event.
17593 *
17594 * Return: QDF_STATUS_SUCCESS on success.
17595 */
17596static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17597 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17598{
17599 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17600 wmi_ready_event_fixed_param *ev = NULL;
17601
17602 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17603 ev = param_buf->fixed_param;
17604
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017605 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017606 ev_param->num_dscp_table = ev->num_dscp_table;
17607 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17608 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017609 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017610 /* Agile_cap in ready event is not supported in TLV target */
17611 ev_param->agile_capability = false;
17612
17613 return QDF_STATUS_SUCCESS;
17614}
17615
17616/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017617 * extract_dbglog_data_len_tlv() - extract debuglog data length
17618 * @wmi_handle: wmi handle
17619 * @param evt_buf: pointer to event buffer
17620 *
17621 * Return: length
17622 */
17623static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017624 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017625{
17626 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17627
17628 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17629
17630 *len = param_buf->num_bufp;
17631
17632 return param_buf->bufp;
17633}
17634
17635/**
17636 * extract_vdev_start_resp_tlv() - extract vdev start response
17637 * @wmi_handle: wmi handle
17638 * @param evt_buf: pointer to event buffer
17639 * @param vdev_rsp: Pointer to hold vdev response
17640 *
17641 * Return: QDF_STATUS_SUCCESS for success or error code
17642 */
17643static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
17644 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
17645{
17646 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
17647 wmi_vdev_start_response_event_fixed_param *ev;
17648
17649 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
17650 if (!param_buf) {
17651 qdf_print("Invalid start response event buffer\n");
17652 return QDF_STATUS_E_INVAL;
17653 }
17654
17655 ev = param_buf->fixed_param;
17656 if (!ev) {
17657 qdf_print("Invalid start response event buffer\n");
17658 return QDF_STATUS_E_INVAL;
17659 }
17660
17661 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
17662
17663 vdev_rsp->vdev_id = ev->vdev_id;
17664 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017665 switch (ev->resp_type) {
17666 case WMI_VDEV_START_RESP_EVENT:
17667 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
17668 break;
17669 case WMI_VDEV_RESTART_RESP_EVENT:
17670 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
17671 break;
17672 default:
17673 qdf_print("Invalid start response event buffer\n");
17674 break;
17675 };
Govind Singhe7f2f342016-05-23 12:12:52 +053017676 vdev_rsp->status = ev->status;
17677 vdev_rsp->chain_mask = ev->chain_mask;
17678 vdev_rsp->smps_mode = ev->smps_mode;
17679 vdev_rsp->mac_id = ev->mac_id;
17680 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
17681 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
17682
17683 return QDF_STATUS_SUCCESS;
17684}
17685
17686/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053017687 * extract_vdev_delete_resp_tlv() - extract vdev delete response
17688 * @wmi_handle: wmi handle
17689 * @param evt_buf: pointer to event buffer
17690 * @param delete_rsp: Pointer to hold vdev delete response
17691 *
17692 * Return: QDF_STATUS_SUCCESS for success or error code
17693 */
17694static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
17695 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
17696{
17697 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17698 wmi_vdev_delete_resp_event_fixed_param *ev;
17699
17700 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
17701 if (!param_buf) {
17702 WMI_LOGE("Invalid vdev delete response event buffer\n");
17703 return QDF_STATUS_E_INVAL;
17704 }
17705
17706 ev = param_buf->fixed_param;
17707 if (!ev) {
17708 WMI_LOGE("Invalid vdev delete response event\n");
17709 return QDF_STATUS_E_INVAL;
17710 }
17711
17712 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
17713 delete_rsp->vdev_id = ev->vdev_id;
17714
17715 return QDF_STATUS_SUCCESS;
17716}
17717
17718
17719/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017720 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053017721 * @wmi_handle: wmi handle
17722 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017723 * @param num_vdevs: Pointer to hold num vdev
17724 *
17725 * Return: QDF_STATUS_SUCCESS for success or error code
17726 */
17727static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17728 void *evt_buf, uint32_t *num_vdevs)
17729{
17730 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17731 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
17732 uint32_t vdev_map;
17733
17734 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
17735 if (!param_buf) {
17736 qdf_print("Invalid tbtt update ext event buffer\n");
17737 return QDF_STATUS_E_INVAL;
17738 }
17739 tbtt_offset_event = param_buf->fixed_param;
17740 vdev_map = tbtt_offset_event->vdev_map;
17741 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
17742
17743 return QDF_STATUS_SUCCESS;
17744}
17745
17746/**
17747 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
17748 * @wmi_handle: wmi handle
17749 * @param evt_buf: pointer to event buffer
17750 * @param num_vdevs: Pointer to hold num vdev
17751 *
17752 * Return: QDF_STATUS_SUCCESS for success or error code
17753 */
17754static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17755 void *evt_buf, uint32_t *num_vdevs)
17756{
17757 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17758 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
17759
17760 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17761 if (!param_buf) {
17762 qdf_print("Invalid tbtt update ext event buffer\n");
17763 return QDF_STATUS_E_INVAL;
17764 }
17765 tbtt_offset_ext_event = param_buf->fixed_param;
17766
17767 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
17768
17769 return QDF_STATUS_SUCCESS;
17770}
17771
17772/**
17773 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
17774 * @wmi_handle: wmi handle
17775 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017776 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017777 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053017778 *
17779 * Return: QDF_STATUS_SUCCESS for success or error code
17780 */
17781static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017782 void *evt_buf, uint8_t idx,
17783 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017784{
17785 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17786 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017787 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053017788
17789 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
17790 if (!param_buf) {
17791 qdf_print("Invalid tbtt update event buffer\n");
17792 return QDF_STATUS_E_INVAL;
17793 }
Govind Singhe7f2f342016-05-23 12:12:52 +053017794
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017795 tbtt_offset_event = param_buf->fixed_param;
17796 vdev_map = tbtt_offset_event->vdev_map;
17797 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
17798 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
17799 return QDF_STATUS_E_INVAL;
17800 tbtt_param->tbttoffset =
17801 param_buf->tbttoffset_list[tbtt_param->vdev_id];
17802
17803 return QDF_STATUS_SUCCESS;
17804}
17805
17806/**
17807 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
17808 * @wmi_handle: wmi handle
17809 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017810 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017811 * @param tbtt_param: Pointer to tbttoffset event param
17812 *
17813 * Return: QDF_STATUS_SUCCESS for success or error code
17814 */
17815static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
17816 void *evt_buf, uint8_t idx,
17817 struct tbttoffset_params *tbtt_param)
17818{
17819 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17820 wmi_tbtt_offset_info *tbtt_offset_info;
17821
17822 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17823 if (!param_buf) {
17824 qdf_print("Invalid tbtt update event buffer\n");
17825 return QDF_STATUS_E_INVAL;
17826 }
17827 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
17828
17829 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
17830 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053017831
17832 return QDF_STATUS_SUCCESS;
17833}
17834
17835/**
17836 * extract_mgmt_rx_params_tlv() - extract management rx params from event
17837 * @wmi_handle: wmi handle
17838 * @param evt_buf: pointer to event buffer
17839 * @param hdr: Pointer to hold header
17840 * @param bufp: Pointer to hold pointer to rx param buffer
17841 *
17842 * Return: QDF_STATUS_SUCCESS for success or error code
17843 */
17844static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053017845 void *evt_buf, struct mgmt_rx_event_params *hdr,
17846 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053017847{
17848 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
17849 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017850 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053017851
17852 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
17853 if (!param_tlvs) {
17854 WMI_LOGE("Get NULL point message from FW");
17855 return QDF_STATUS_E_INVAL;
17856 }
17857
17858 ev_hdr = param_tlvs->hdr;
17859 if (!hdr) {
17860 WMI_LOGE("Rx event is NULL");
17861 return QDF_STATUS_E_INVAL;
17862 }
17863
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017864 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17865 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017866
17867 hdr->channel = ev_hdr->channel;
17868 hdr->snr = ev_hdr->snr;
17869 hdr->rate = ev_hdr->rate;
17870 hdr->phy_mode = ev_hdr->phy_mode;
17871 hdr->buf_len = ev_hdr->buf_len;
17872 hdr->status = ev_hdr->status;
17873 hdr->flags = ev_hdr->flags;
17874 hdr->rssi = ev_hdr->rssi;
17875 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017876 for (i = 0; i < ATH_MAX_ANTENNA; i++)
17877 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053017878
17879 *bufp = param_tlvs->bufp;
17880
17881 return QDF_STATUS_SUCCESS;
17882}
17883
17884/**
17885 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
17886 * @wmi_handle: wmi handle
17887 * @param evt_buf: pointer to event buffer
17888 * @param vdev_id: Pointer to hold vdev identifier
17889 *
17890 * Return: QDF_STATUS_SUCCESS for success or error code
17891 */
17892static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
17893 void *evt_buf, uint32_t *vdev_id)
17894{
17895 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
17896 wmi_vdev_stopped_event_fixed_param *resp_event;
17897
17898 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
17899 if (!param_buf) {
17900 WMI_LOGE("Invalid event buffer");
17901 return QDF_STATUS_E_INVAL;
17902 }
17903 resp_event = param_buf->fixed_param;
17904 *vdev_id = resp_event->vdev_id;
17905
17906 return QDF_STATUS_SUCCESS;
17907}
17908
17909/**
17910 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
17911 * @wmi_handle: wmi handle
17912 * @param evt_buf: pointer to event buffer
17913 * @param param: Pointer to hold roam param
17914 *
17915 * Return: QDF_STATUS_SUCCESS for success or error code
17916 */
17917static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
17918 void *evt_buf, wmi_host_roam_event *param)
17919{
17920 WMI_ROAM_EVENTID_param_tlvs *param_buf;
17921 wmi_roam_event_fixed_param *evt;
17922
17923 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
17924 if (!param_buf) {
17925 WMI_LOGE("Invalid roam event buffer");
17926 return QDF_STATUS_E_INVAL;
17927 }
17928
17929 evt = param_buf->fixed_param;
17930 qdf_mem_zero(param, sizeof(*param));
17931
17932 param->vdev_id = evt->vdev_id;
17933 param->reason = evt->reason;
17934 param->rssi = evt->rssi;
17935
17936 return QDF_STATUS_SUCCESS;
17937}
17938
17939/**
17940 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
17941 * @wmi_handle: wmi handle
17942 * @param evt_buf: pointer to event buffer
17943 * @param param: Pointer to hold vdev scan param
17944 *
17945 * Return: QDF_STATUS_SUCCESS for success or error code
17946 */
17947static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017948 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017949{
17950 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
17951 wmi_scan_event_fixed_param *evt = NULL;
17952
17953 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
17954 evt = param_buf->fixed_param;
17955
17956 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053017957
Govind Singhe7f2f342016-05-23 12:12:52 +053017958 switch (evt->event) {
17959 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017960 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017961 break;
17962 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017963 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017964 break;
17965 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017966 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053017967 break;
17968 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017969 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053017970 break;
17971 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017972 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017973 break;
17974 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017975 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017976 break;
17977 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017978 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017979 break;
17980 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017981 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017982 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053017983 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017984 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053017985 break;
17986 case WMI_SCAN_EVENT_MAX:
17987 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017988 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053017989 break;
17990 };
17991
17992 switch (evt->reason) {
17993 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017994 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053017995 break;
17996 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017997 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017998 break;
17999 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018000 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018001 break;
18002 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018003 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018004 break;
18005 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018006 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018007 break;
18008 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018009 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018010 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018011 case WMI_SCAN_REASON_SUSPENDED:
18012 param->reason = SCAN_REASON_SUSPENDED;
18013 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018014 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018015 param->reason = SCAN_REASON_MAX;
18016 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018017 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018018 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018019 break;
18020 };
18021
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018022 param->chan_freq = evt->channel_freq;
18023 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018024 param->scan_id = evt->scan_id;
18025 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018026 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018027
18028 return QDF_STATUS_SUCCESS;
18029}
18030
Frank Liu3d5e9992017-03-15 17:51:43 +080018031#ifdef CONVERGED_TDLS_ENABLE
18032/**
18033 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18034 * @wmi_handle: wmi handle
18035 * @param evt_buf: pointer to event buffer
18036 * @param param: Pointer to hold vdev tdls param
18037 *
18038 * Return: QDF_STATUS_SUCCESS for success or error code
18039 */
18040static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18041 void *evt_buf, struct tdls_event_info *param)
18042{
18043 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18044 wmi_tdls_peer_event_fixed_param *evt;
18045
18046 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18047 if (!param_buf) {
18048 WMI_LOGE("%s: NULL param_buf", __func__);
18049 return QDF_STATUS_E_NULL_VALUE;
18050 }
18051
18052 evt = param_buf->fixed_param;
18053
18054 qdf_mem_zero(param, sizeof(*param));
18055
18056 param->vdev_id = evt->vdev_id;
18057 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18058 param->peermac.bytes);
18059 switch (evt->peer_status) {
18060 case WMI_TDLS_SHOULD_DISCOVER:
18061 param->message_type = TDLS_SHOULD_DISCOVER;
18062 break;
18063 case WMI_TDLS_SHOULD_TEARDOWN:
18064 param->message_type = TDLS_SHOULD_TEARDOWN;
18065 break;
18066 case WMI_TDLS_PEER_DISCONNECTED:
18067 param->message_type = TDLS_PEER_DISCONNECTED;
18068 break;
18069 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18070 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18071 break;
18072 default:
18073 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18074 __func__, evt->peer_status);
18075 return QDF_STATUS_E_INVAL;
18076 };
18077
18078 switch (evt->peer_reason) {
18079 case WMI_TDLS_TEARDOWN_REASON_TX:
18080 param->peer_reason = TDLS_TEARDOWN_TX;
18081 break;
18082 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18083 param->peer_reason = TDLS_TEARDOWN_RSSI;
18084 break;
18085 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18086 param->peer_reason = TDLS_TEARDOWN_SCAN;
18087 break;
18088 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18089 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18090 break;
18091 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18092 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18093 break;
18094 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18095 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18096 break;
18097 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18098 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18099 break;
18100 case WMI_TDLS_ENTER_BUF_STA:
18101 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18102 break;
18103 case WMI_TDLS_EXIT_BUF_STA:
18104 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18105 break;
18106 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18107 param->peer_reason = TDLS_ENTER_BT_BUSY;
18108 break;
18109 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18110 param->peer_reason = TDLS_EXIT_BT_BUSY;
18111 break;
18112 case WMI_TDLS_SCAN_STARTED_EVENT:
18113 param->peer_reason = TDLS_SCAN_STARTED;
18114 break;
18115 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18116 param->peer_reason = TDLS_SCAN_COMPLETED;
18117 break;
18118
18119 default:
18120 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18121 __func__, evt->peer_reason, evt->peer_status);
18122 return QDF_STATUS_E_INVAL;
18123 };
18124
18125 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18126 __func__, param->peermac.bytes, param->message_type,
18127 param->peer_reason, param->vdev_id);
18128
18129 return QDF_STATUS_SUCCESS;
18130}
18131#endif
18132
Govind Singhe7f2f342016-05-23 12:12:52 +053018133/**
18134 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18135 * @wmi_handle: wmi handle
18136 * @param evt_buf: pointer to event buffer
18137 * @param param: Pointer to hold MGMT TX completion params
18138 *
18139 * Return: QDF_STATUS_SUCCESS for success or error code
18140 */
18141static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18142 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18143{
18144 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18145 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18146
18147 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18148 evt_buf;
18149 if (!param_buf) {
18150 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18151 return QDF_STATUS_E_INVAL;
18152 }
18153 cmpl_params = param_buf->fixed_param;
18154
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018155 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18156 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018157 param->desc_id = cmpl_params->desc_id;
18158 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018159 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018160
18161 return QDF_STATUS_SUCCESS;
18162}
18163
18164/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018165 * extract_offchan_data_tx_compl_param_tlv() -
18166 * extract Offchan data tx completion event params
18167 * @wmi_handle: wmi handle
18168 * @param evt_buf: pointer to event buffer
18169 * @param param: Pointer to hold offchan data TX completion params
18170 *
18171 * Return: QDF_STATUS_SUCCESS for success or error code
18172 */
18173static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18174 wmi_unified_t wmi_handle, void *evt_buf,
18175 struct wmi_host_offchan_data_tx_compl_event *param)
18176{
18177 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18178 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18179
18180 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18181 evt_buf;
18182 if (!param_buf) {
18183 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18184 return QDF_STATUS_E_INVAL;
18185 }
18186 cmpl_params = param_buf->fixed_param;
18187
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018188 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18189 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018190 param->desc_id = cmpl_params->desc_id;
18191 param->status = cmpl_params->status;
18192
18193 return QDF_STATUS_SUCCESS;
18194}
18195
18196/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018197 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18198 * status tlv
18199 * @wmi_handle: wmi handle
18200 * @param evt_buf: pointer to event buffer
18201 * @param param: Pointer to hold csa switch count status event param
18202 *
18203 * Return: QDF_STATUS_SUCCESS for success or error code
18204 */
18205static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18206 wmi_unified_t wmi_handle,
18207 void *evt_buf,
18208 struct pdev_csa_switch_count_status *param)
18209{
18210 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18211 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18212
18213 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18214 evt_buf;
18215 if (!param_buf) {
18216 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18217 return QDF_STATUS_E_INVAL;
18218 }
18219
18220 csa_status = param_buf->fixed_param;
18221
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018222 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18223 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018224 param->current_switch_count = csa_status->current_switch_count;
18225 param->num_vdevs = csa_status->num_vdevs;
18226 param->vdev_ids = param_buf->vdev_ids;
18227
18228 return QDF_STATUS_SUCCESS;
18229}
18230
18231/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018232 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18233 * param from event
18234 * @wmi_handle: wmi handle
18235 * @param evt_buf: pointer to event buffer
18236 * @param param: Pointer to hold tpc configuration
18237 *
18238 * Return: 0 for success or error code
18239 */
18240static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18241 void *evt_buf,
18242 wmi_host_pdev_tpc_config_event *param)
18243{
18244 wmi_pdev_tpc_config_event_fixed_param *event =
18245 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18246
18247 if (!event) {
18248 WMI_LOGE("Invalid event buffer");
18249 return QDF_STATUS_E_INVAL;
18250 }
18251
18252 param->pdev_id = event->pdev_id;
18253 param->regDomain = event->regDomain;
18254 param->chanFreq = event->chanFreq;
18255 param->phyMode = event->phyMode;
18256 param->twiceAntennaReduction = event->twiceAntennaReduction;
18257 param->twiceMaxRDPower = event->twiceMaxRDPower;
18258 param->powerLimit = event->powerLimit;
18259 param->rateMax = event->rateMax;
18260 param->numTxChain = event->numTxChain;
18261 param->ctl = event->ctl;
18262 param->flags = event->flags;
18263
18264 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18265 sizeof(param->maxRegAllowedPower));
18266 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18267 event->maxRegAllowedPowerAGCDD,
18268 sizeof(param->maxRegAllowedPowerAGCDD));
18269 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18270 event->maxRegAllowedPowerAGSTBC,
18271 sizeof(param->maxRegAllowedPowerAGSTBC));
18272 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18273 event->maxRegAllowedPowerAGTXBF,
18274 sizeof(param->maxRegAllowedPowerAGTXBF));
18275 WMI_LOGD("%s:extract success", __func__);
18276
18277 return QDF_STATUS_SUCCESS;
18278}
18279
18280/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018281 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018282 * @wmi_handle: wmi handle
18283 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018284 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018285 *
18286 * Return: QDF_STATUS_SUCCESS for success or error code
18287 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018288static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18289 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018290{
18291 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18292 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018293 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018294
18295 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18296 if (!param_buf) {
18297 WMI_LOGE("Invalid swba event buffer");
18298 return QDF_STATUS_E_INVAL;
18299 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018300
Govind Singhe7f2f342016-05-23 12:12:52 +053018301 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018302 *num_vdevs = swba_event->num_vdevs;
18303 if (!(*num_vdevs)) {
18304 vdev_map = swba_event->vdev_map;
18305 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18306 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018307
18308 return QDF_STATUS_SUCCESS;
18309}
18310
18311/**
18312 * extract_swba_tim_info_tlv() - extract swba tim info from event
18313 * @wmi_handle: wmi handle
18314 * @param evt_buf: pointer to event buffer
18315 * @param idx: Index to bcn info
18316 * @param tim_info: Pointer to hold tim info
18317 *
18318 * Return: QDF_STATUS_SUCCESS for success or error code
18319 */
18320static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18321 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18322{
18323 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18324 wmi_tim_info *tim_info_ev;
18325
18326 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18327 if (!param_buf) {
18328 WMI_LOGE("Invalid swba event buffer");
18329 return QDF_STATUS_E_INVAL;
18330 }
18331
18332 tim_info_ev = &param_buf->tim_info[idx];
18333
18334 tim_info->tim_len = tim_info_ev->tim_len;
18335 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18336 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18337 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18338 tim_info->tim_changed = tim_info_ev->tim_changed;
18339 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018340 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018341
18342 return QDF_STATUS_SUCCESS;
18343}
18344
18345/**
18346 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18347 * @wmi_handle: wmi handle
18348 * @param evt_buf: pointer to event buffer
18349 * @param idx: Index to bcn info
18350 * @param p2p_desc: Pointer to hold p2p NoA info
18351 *
18352 * Return: QDF_STATUS_SUCCESS for success or error code
18353 */
18354static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18355 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18356{
18357 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18358 wmi_p2p_noa_info *p2p_noa_info;
18359 uint8_t i = 0;
18360
18361 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18362 if (!param_buf) {
18363 WMI_LOGE("Invalid swba event buffer");
18364 return QDF_STATUS_E_INVAL;
18365 }
18366
18367 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18368
18369 p2p_desc->modified = false;
18370 p2p_desc->num_descriptors = 0;
18371 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18372 p2p_desc->modified = true;
18373 p2p_desc->index =
18374 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18375 p2p_desc->oppPS =
18376 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18377 p2p_desc->ctwindow =
18378 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18379 p2p_desc->num_descriptors =
18380 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18381 (p2p_noa_info);
18382 for (i = 0; i < p2p_desc->num_descriptors; i++) {
18383 p2p_desc->noa_descriptors[i].type_count =
18384 (uint8_t) p2p_noa_info->noa_descriptors[i].
18385 type_count;
18386 p2p_desc->noa_descriptors[i].duration =
18387 p2p_noa_info->noa_descriptors[i].duration;
18388 p2p_desc->noa_descriptors[i].interval =
18389 p2p_noa_info->noa_descriptors[i].interval;
18390 p2p_desc->noa_descriptors[i].start_time =
18391 p2p_noa_info->noa_descriptors[i].start_time;
18392 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018393 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018394 }
18395
18396 return QDF_STATUS_SUCCESS;
18397}
18398
Wu Gaocd3a8512017-03-13 20:17:34 +080018399#ifdef CONVERGED_P2P_ENABLE
18400/**
18401 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
18402 * @wmi_handle: wmi handle
18403 * @param evt_buf: pointer to event buffer
18404 * @param param: Pointer to hold p2p noa info
18405 *
18406 * Return: QDF_STATUS_SUCCESS for success or error code
18407 */
18408static QDF_STATUS extract_p2p_noa_ev_param_tlv(
18409 wmi_unified_t wmi_handle, void *evt_buf,
18410 struct p2p_noa_info *param)
18411{
18412 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
18413 wmi_p2p_noa_event_fixed_param *fixed_param;
18414 uint8_t i;
18415 wmi_p2p_noa_info *wmi_noa_info;
18416 uint8_t *buf_ptr;
18417 uint32_t descriptors;
18418
18419 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
18420 if (!param_tlvs) {
18421 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
18422 return QDF_STATUS_E_INVAL;
18423 }
18424
18425 if (!param) {
18426 WMI_LOGE("noa information param is null");
18427 return QDF_STATUS_E_INVAL;
18428 }
18429
18430 fixed_param = param_tlvs->fixed_param;
18431 buf_ptr = (uint8_t *) fixed_param;
18432 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
18433 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
18434
18435 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
18436 WMI_LOGE("%s: noa attr is not modified", __func__);
18437 return QDF_STATUS_E_INVAL;
18438 }
18439
18440 param->vdev_id = fixed_param->vdev_id;
18441 param->index =
18442 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
18443 param->opps_ps =
18444 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
18445 param->ct_window =
18446 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
18447 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
18448 param->num_desc = (uint8_t) descriptors;
18449
18450 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
18451 param->index, param->opps_ps, param->ct_window,
18452 param->num_desc);
18453 for (i = 0; i < param->num_desc; i++) {
18454 param->noa_desc[i].type_count =
18455 (uint8_t) wmi_noa_info->noa_descriptors[i].
18456 type_count;
18457 param->noa_desc[i].duration =
18458 wmi_noa_info->noa_descriptors[i].duration;
18459 param->noa_desc[i].interval =
18460 wmi_noa_info->noa_descriptors[i].interval;
18461 param->noa_desc[i].start_time =
18462 wmi_noa_info->noa_descriptors[i].start_time;
18463 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
18464 __func__, i, param->noa_desc[i].type_count,
18465 param->noa_desc[i].duration,
18466 param->noa_desc[i].interval,
18467 param->noa_desc[i].start_time);
18468 }
18469
18470 return QDF_STATUS_SUCCESS;
18471}
18472
18473/**
18474 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
18475 * information from event
18476 * @wmi_handle: wmi handle
18477 * @param evt_buf: pointer to event buffer
18478 * @param param: Pointer to hold p2p lo stop event information
18479 *
18480 * Return: QDF_STATUS_SUCCESS for success or error code
18481 */
18482static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
18483 wmi_unified_t wmi_handle, void *evt_buf,
18484 struct p2p_lo_event *param)
18485{
18486 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
18487 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
18488
18489 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
18490 evt_buf;
18491 if (!param_tlvs) {
18492 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
18493 return QDF_STATUS_E_INVAL;
18494 }
18495
18496 if (!param) {
18497 WMI_LOGE("lo stop event param is null");
18498 return QDF_STATUS_E_INVAL;
18499 }
18500
18501 lo_param = param_tlvs->fixed_param;
18502 param->vdev_id = lo_param->vdev_id;
18503 param->reason_code = lo_param->reason;
18504 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
18505 param->vdev_id, param->reason_code);
18506
18507 return QDF_STATUS_SUCCESS;
18508}
18509#endif /* End of CONVERGED_P2P_ENABLE */
18510
Govind Singhe7f2f342016-05-23 12:12:52 +053018511/**
18512 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
18513 * @wmi_handle: wmi handle
18514 * @param evt_buf: pointer to event buffer
18515 * @param ev: Pointer to hold peer param
18516 *
18517 * Return: QDF_STATUS_SUCCESS for success or error code
18518 */
18519static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
18520 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
18521{
18522 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
18523 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
18524
18525 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
18526 kickout_event = param_buf->fixed_param;
18527
18528 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
18529 ev->peer_macaddr);
18530
18531 ev->reason = kickout_event->reason;
18532 ev->rssi = kickout_event->rssi;
18533
18534 return QDF_STATUS_SUCCESS;
18535}
18536
18537/**
18538 * extract_all_stats_counts_tlv() - extract all stats count from event
18539 * @wmi_handle: wmi handle
18540 * @param evt_buf: pointer to event buffer
18541 * @param stats_param: Pointer to hold stats count
18542 *
18543 * Return: QDF_STATUS_SUCCESS for success or error code
18544 */
18545static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
18546 void *evt_buf, wmi_host_stats_event *stats_param)
18547{
Govind Singhe7f2f342016-05-23 12:12:52 +053018548 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018549 wmi_per_chain_rssi_stats *rssi_event;
18550 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018551
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018552 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053018553 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018554 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018555 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053018556 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018557 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053018558 return QDF_STATUS_E_FAILURE;
18559 }
18560
18561 switch (ev->stats_id) {
18562 case WMI_REQUEST_PEER_STAT:
18563 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
18564 break;
18565
18566 case WMI_REQUEST_AP_STAT:
18567 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
18568 break;
18569
18570 case WMI_REQUEST_PDEV_STAT:
18571 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
18572 break;
18573
18574 case WMI_REQUEST_VDEV_STAT:
18575 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
18576 break;
18577
18578 case WMI_REQUEST_BCNFLT_STAT:
18579 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
18580 break;
18581
18582 case WMI_REQUEST_VDEV_RATE_STAT:
18583 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
18584 break;
18585
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018586 case WMI_REQUEST_BCN_STAT:
18587 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
18588 break;
18589
Govind Singhe7f2f342016-05-23 12:12:52 +053018590 default:
18591 stats_param->stats_id = 0;
18592 break;
18593
18594 }
18595
18596 stats_param->num_pdev_stats = ev->num_pdev_stats;
18597 stats_param->num_pdev_ext_stats = 0;
18598 stats_param->num_vdev_stats = ev->num_vdev_stats;
18599 stats_param->num_peer_stats = ev->num_peer_stats;
18600 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18601 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018602 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018603 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18604 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018605
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018606 /* if chain_stats is not populated */
18607 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
18608 return QDF_STATUS_SUCCESS;
18609
18610 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
18611 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
18612 return QDF_STATUS_SUCCESS;
18613
18614 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -070018615 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018616 return QDF_STATUS_SUCCESS;
18617
18618 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
18619
Govind Singhe7f2f342016-05-23 12:12:52 +053018620 return QDF_STATUS_SUCCESS;
18621}
18622
18623/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018624 * extract_pdev_tx_stats() - extract pdev tx stats from event
18625 */
18626static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
18627{
18628 /* Tx Stats */
18629 tx->comp_queued = tx_stats->comp_queued;
18630 tx->comp_delivered = tx_stats->comp_delivered;
18631 tx->msdu_enqued = tx_stats->msdu_enqued;
18632 tx->mpdu_enqued = tx_stats->mpdu_enqued;
18633 tx->wmm_drop = tx_stats->wmm_drop;
18634 tx->local_enqued = tx_stats->local_enqued;
18635 tx->local_freed = tx_stats->local_freed;
18636 tx->hw_queued = tx_stats->hw_queued;
18637 tx->hw_reaped = tx_stats->hw_reaped;
18638 tx->underrun = tx_stats->underrun;
18639 tx->tx_abort = tx_stats->tx_abort;
18640 tx->mpdus_requed = tx_stats->mpdus_requed;
18641 tx->data_rc = tx_stats->data_rc;
18642 tx->self_triggers = tx_stats->self_triggers;
18643 tx->sw_retry_failure = tx_stats->sw_retry_failure;
18644 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
18645 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
18646 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
18647 tx->pdev_resets = tx_stats->pdev_resets;
18648 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
18649 tx->phy_underrun = tx_stats->phy_underrun;
18650 tx->txop_ovf = tx_stats->txop_ovf;
18651
18652 return;
18653}
18654
18655
18656/**
18657 * extract_pdev_rx_stats() - extract pdev rx stats from event
18658 */
18659static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
18660{
18661 /* Rx Stats */
18662 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
18663 rx->status_rcvd = rx_stats->status_rcvd;
18664 rx->r0_frags = rx_stats->r0_frags;
18665 rx->r1_frags = rx_stats->r1_frags;
18666 rx->r2_frags = rx_stats->r2_frags;
18667 /* Only TLV */
18668 rx->r3_frags = 0;
18669 rx->htt_msdus = rx_stats->htt_msdus;
18670 rx->htt_mpdus = rx_stats->htt_mpdus;
18671 rx->loc_msdus = rx_stats->loc_msdus;
18672 rx->loc_mpdus = rx_stats->loc_mpdus;
18673 rx->oversize_amsdu = rx_stats->oversize_amsdu;
18674 rx->phy_errs = rx_stats->phy_errs;
18675 rx->phy_err_drop = rx_stats->phy_err_drop;
18676 rx->mpdu_errs = rx_stats->mpdu_errs;
18677
18678 return;
18679}
18680
18681/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018682 * extract_pdev_stats_tlv() - extract pdev stats from event
18683 * @wmi_handle: wmi handle
18684 * @param evt_buf: pointer to event buffer
18685 * @param index: Index into pdev stats
18686 * @param pdev_stats: Pointer to hold pdev stats
18687 *
18688 * Return: QDF_STATUS_SUCCESS for success or error code
18689 */
18690static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
18691 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
18692{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018693 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18694 wmi_stats_event_fixed_param *ev_param;
18695 uint8_t *data;
18696
18697 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18698 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18699
18700 data = param_buf->data;
18701
18702 if (index < ev_param->num_pdev_stats) {
18703 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
18704 (index * sizeof(wmi_pdev_stats)));
18705
18706 pdev_stats->chan_nf = ev->chan_nf;
18707 pdev_stats->tx_frame_count = ev->tx_frame_count;
18708 pdev_stats->rx_frame_count = ev->rx_frame_count;
18709 pdev_stats->rx_clear_count = ev->rx_clear_count;
18710 pdev_stats->cycle_count = ev->cycle_count;
18711 pdev_stats->phy_err_count = ev->phy_err_count;
18712 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
18713
18714 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
18715 &(ev->pdev_stats.tx));
18716 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
18717 &(ev->pdev_stats.rx));
18718 }
18719
Govind Singhe7f2f342016-05-23 12:12:52 +053018720 return QDF_STATUS_SUCCESS;
18721}
18722
18723/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070018724 * extract_unit_test_tlv() - extract unit test data
18725 * @wmi_handle: wmi handle
18726 * @param evt_buf: pointer to event buffer
18727 * @param unit_test: pointer to hold unit test data
18728 * @param maxspace: Amount of space in evt_buf
18729 *
18730 * Return: QDF_STATUS_SUCCESS for success or error code
18731 */
18732static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
18733 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
18734{
18735 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
18736 wmi_unit_test_event_fixed_param *ev_param;
18737 uint32_t num_bufp;
18738 uint32_t copy_size;
18739 uint8_t *bufp;
18740
18741 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
18742 ev_param = param_buf->fixed_param;
18743 bufp = param_buf->bufp;
18744 num_bufp = param_buf->num_bufp;
18745 unit_test->vdev_id = ev_param->vdev_id;
18746 unit_test->module_id = ev_param->module_id;
18747 unit_test->diag_token = ev_param->diag_token;
18748 unit_test->flag = ev_param->flag;
18749 unit_test->payload_len = ev_param->payload_len;
18750 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
18751 ev_param->vdev_id,
18752 ev_param->module_id,
18753 ev_param->diag_token,
18754 ev_param->flag);
18755 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
18756 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
18757 bufp, num_bufp);
18758 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
18759 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
18760 unit_test->buffer_len = copy_size;
18761
18762 return QDF_STATUS_SUCCESS;
18763}
18764
18765/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018766 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
18767 * @wmi_handle: wmi handle
18768 * @param evt_buf: pointer to event buffer
18769 * @param index: Index into extended pdev stats
18770 * @param pdev_ext_stats: Pointer to hold extended pdev stats
18771 *
18772 * Return: QDF_STATUS_SUCCESS for success or error code
18773 */
18774static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
18775 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
18776{
18777 return QDF_STATUS_SUCCESS;
18778}
18779
18780/**
18781 * extract_vdev_stats_tlv() - extract vdev stats from event
18782 * @wmi_handle: wmi handle
18783 * @param evt_buf: pointer to event buffer
18784 * @param index: Index into vdev stats
18785 * @param vdev_stats: Pointer to hold vdev stats
18786 *
18787 * Return: QDF_STATUS_SUCCESS for success or error code
18788 */
18789static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
18790 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
18791{
18792 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18793 wmi_stats_event_fixed_param *ev_param;
18794 uint8_t *data;
18795
18796 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18797 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18798 data = (uint8_t *) param_buf->data;
18799
18800 if (index < ev_param->num_vdev_stats) {
18801 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
18802 ((ev_param->num_pdev_stats) *
18803 sizeof(wmi_pdev_stats)) +
18804 (index * sizeof(wmi_vdev_stats)));
18805
18806 vdev_stats->vdev_id = ev->vdev_id;
18807 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
18808 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
18809
18810 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
18811 sizeof(ev->tx_frm_cnt));
18812 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
18813 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
18814 ev->multiple_retry_cnt,
18815 sizeof(ev->multiple_retry_cnt));
18816 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
18817 sizeof(ev->fail_cnt));
18818 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
18819 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
18820 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
18821 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
18822 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
18823 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
18824 sizeof(ev->tx_rate_history));
18825 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
18826 sizeof(ev->bcn_rssi_history));
18827
18828 }
18829
18830 return QDF_STATUS_SUCCESS;
18831}
18832
18833/**
Naveen Rawatd2115722018-04-12 08:17:55 -070018834 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
18835 * buffer
18836 * @wmi_handle: wmi handle
18837 * @evt_buf: pointer to event buffer
18838 * @index: Index into vdev stats
18839 * @rssi_stats: Pointer to hold rssi stats
18840 *
18841 * Return: QDF_STATUS_SUCCESS for success or error code
18842 */
18843static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
18844 void *evt_buf, uint32_t index,
18845 struct wmi_host_per_chain_rssi_stats *rssi_stats)
18846{
18847 uint8_t *data;
18848 wmi_rssi_stats *fw_rssi_stats;
18849 wmi_per_chain_rssi_stats *rssi_event;
18850 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18851
18852 if (!evt_buf) {
18853 WMI_LOGE("evt_buf is null");
18854 return QDF_STATUS_E_NULL_VALUE;
18855 }
18856
18857 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18858 rssi_event = param_buf->chain_stats;
18859
18860 if (index >= rssi_event->num_per_chain_rssi_stats) {
18861 WMI_LOGE("invalid index");
18862 return QDF_STATUS_E_INVAL;
18863 }
18864
18865 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
18866 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
18867
18868 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
18869 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
18870 fw_rssi_stats->rssi_avg_beacon,
18871 sizeof(fw_rssi_stats->rssi_avg_beacon));
18872 qdf_mem_copy(rssi_stats->rssi_avg_data,
18873 fw_rssi_stats->rssi_avg_data,
18874 sizeof(fw_rssi_stats->rssi_avg_data));
18875 qdf_mem_copy(&rssi_stats->peer_macaddr,
18876 &fw_rssi_stats->peer_macaddr,
18877 sizeof(fw_rssi_stats->peer_macaddr));
18878
18879 return QDF_STATUS_SUCCESS;
18880}
18881
18882
18883
18884/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018885 * extract_bcn_stats_tlv() - extract bcn stats from event
18886 * @wmi_handle: wmi handle
18887 * @param evt_buf: pointer to event buffer
18888 * @param index: Index into vdev stats
18889 * @param bcn_stats: Pointer to hold bcn stats
18890 *
18891 * Return: QDF_STATUS_SUCCESS for success or error code
18892 */
18893static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
18894 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
18895{
18896 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18897 wmi_stats_event_fixed_param *ev_param;
18898 uint8_t *data;
18899
18900 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18901 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18902 data = (uint8_t *) param_buf->data;
18903
18904 if (index < ev_param->num_bcn_stats) {
18905 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
18906 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18907 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18908 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
18909 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
18910 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
18911 (index * sizeof(wmi_bcn_stats)));
18912
18913 bcn_stats->vdev_id = ev->vdev_id;
18914 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
18915 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
18916 }
18917
18918 return QDF_STATUS_SUCCESS;
18919}
18920
18921/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018922 * extract_peer_stats_tlv() - extract peer stats from event
18923 * @wmi_handle: wmi handle
18924 * @param evt_buf: pointer to event buffer
18925 * @param index: Index into peer stats
18926 * @param peer_stats: Pointer to hold peer stats
18927 *
18928 * Return: QDF_STATUS_SUCCESS for success or error code
18929 */
18930static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
18931 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
18932{
18933 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18934 wmi_stats_event_fixed_param *ev_param;
18935 uint8_t *data;
18936
18937 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18938 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18939 data = (uint8_t *) param_buf->data;
18940
18941 if (index < ev_param->num_peer_stats) {
18942 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
18943 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18944 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18945 (index * sizeof(wmi_peer_stats)));
18946
18947 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
18948
18949 OS_MEMCPY(&(peer_stats->peer_macaddr),
18950 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
18951
18952 peer_stats->peer_rssi = ev->peer_rssi;
18953 peer_stats->peer_tx_rate = ev->peer_tx_rate;
18954 peer_stats->peer_rx_rate = ev->peer_rx_rate;
18955 }
18956
18957 return QDF_STATUS_SUCCESS;
18958}
18959
18960/**
18961 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
18962 * @wmi_handle: wmi handle
18963 * @param evt_buf: pointer to event buffer
18964 * @param index: Index into bcn fault stats
18965 * @param bcnflt_stats: Pointer to hold bcn fault stats
18966 *
18967 * Return: QDF_STATUS_SUCCESS for success or error code
18968 */
18969static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
18970 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
18971{
18972 return QDF_STATUS_SUCCESS;
18973}
18974
18975/**
18976 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
18977 * @wmi_handle: wmi handle
18978 * @param evt_buf: pointer to event buffer
18979 * @param index: Index into extended peer stats
18980 * @param peer_extd_stats: Pointer to hold extended peer stats
18981 *
18982 * Return: QDF_STATUS_SUCCESS for success or error code
18983 */
18984static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
18985 void *evt_buf, uint32_t index,
18986 wmi_host_peer_extd_stats *peer_extd_stats)
18987{
18988 return QDF_STATUS_SUCCESS;
18989}
18990
18991/**
18992 * extract_chan_stats_tlv() - extract chan stats from event
18993 * @wmi_handle: wmi handle
18994 * @param evt_buf: pointer to event buffer
18995 * @param index: Index into chan stats
18996 * @param vdev_extd_stats: Pointer to hold chan stats
18997 *
18998 * Return: QDF_STATUS_SUCCESS for success or error code
18999 */
19000static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19001 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19002{
19003 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19004 wmi_stats_event_fixed_param *ev_param;
19005 uint8_t *data;
19006
19007 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19008 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19009 data = (uint8_t *) param_buf->data;
19010
19011 if (index < ev_param->num_chan_stats) {
19012 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19013 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19014 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19015 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19016 (index * sizeof(wmi_chan_stats)));
19017
19018
Jeff Johnson79eaacb2018-05-06 17:53:18 -070019019 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +053019020 chan_stats->chan_mhz = ev->chan_mhz;
19021 chan_stats->sampling_period_us = ev->sampling_period_us;
19022 chan_stats->rx_clear_count = ev->rx_clear_count;
19023 chan_stats->tx_duration_us = ev->tx_duration_us;
19024 chan_stats->rx_duration_us = ev->rx_duration_us;
19025 }
19026
19027 return QDF_STATUS_SUCCESS;
19028}
19029
19030/**
19031 * extract_profile_ctx_tlv() - extract profile context from event
19032 * @wmi_handle: wmi handle
19033 * @param evt_buf: pointer to event buffer
19034 * @idx: profile stats index to extract
19035 * @param profile_ctx: Pointer to hold profile context
19036 *
19037 * Return: QDF_STATUS_SUCCESS for success or error code
19038 */
19039static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19040 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19041{
19042 return QDF_STATUS_SUCCESS;
19043}
19044
19045/**
19046 * extract_profile_data_tlv() - extract profile data from event
19047 * @wmi_handle: wmi handle
19048 * @param evt_buf: pointer to event buffer
19049 * @param profile_data: Pointer to hold profile data
19050 *
19051 * Return: QDF_STATUS_SUCCESS for success or error code
19052 */
19053static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19054 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19055{
19056
19057 return QDF_STATUS_SUCCESS;
19058}
19059
19060/**
19061 * extract_chan_info_event_tlv() - extract chan information from event
19062 * @wmi_handle: wmi handle
19063 * @param evt_buf: pointer to event buffer
19064 * @param chan_info: Pointer to hold chan information
19065 *
19066 * Return: QDF_STATUS_SUCCESS for success or error code
19067 */
19068static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19069 void *evt_buf, wmi_host_chan_info_event *chan_info)
19070{
19071 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19072 wmi_chan_info_event_fixed_param *ev;
19073
19074 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19075
19076 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19077 if (!ev) {
19078 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19079 return QDF_STATUS_E_FAILURE;
19080 }
19081
19082 chan_info->err_code = ev->err_code;
19083 chan_info->freq = ev->freq;
19084 chan_info->cmd_flags = ev->cmd_flags;
19085 chan_info->noise_floor = ev->noise_floor;
19086 chan_info->rx_clear_count = ev->rx_clear_count;
19087 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019088 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19089 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019090 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19091 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19092 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019093 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19094 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19095 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19096 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19097 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19098 chan_info->rx_frame_count = ev->rx_frame_count;
19099 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19100 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019101
19102 return QDF_STATUS_SUCCESS;
19103}
19104
19105/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019106 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19107 * @wmi_handle: WMI handle
19108 * @param evt_buf: Pointer to event buffer
19109 * @param param: Pointer to hold data
19110 *
19111 * Return : QDF_STATUS_SUCCESS for success or error code
19112 */
19113static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19114 uint8_t *evt_buf,
19115 struct wmi_host_pdev_utf_event *event)
19116{
19117 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019118 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019119
19120 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19121 event->data = param_buf->data;
19122 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019123 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019124 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019125 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019126 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019127
19128 return QDF_STATUS_SUCCESS;
19129}
Govind Singhe7f2f342016-05-23 12:12:52 +053019130
Kiran Venkatappa06520822016-08-10 23:55:40 +053019131/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019132 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19133 * @wmi_handle: wmi handle
19134 * @param evt_buf: pointer to event buffer
19135 * @param param: Pointer to hold evt buf
19136 *
19137 * Return: QDF_STATUS_SUCCESS for success or error code
19138 */
19139static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19140 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19141{
19142 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19143 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19144 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19145 uint8_t i = 0, j = 0;
19146
19147 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19148 if (!param_buf)
19149 return QDF_STATUS_E_INVAL;
19150
19151 hw_caps = param_buf->soc_hw_mode_caps;
19152 if (!hw_caps)
19153 return QDF_STATUS_E_INVAL;
19154
19155 if (!hw_caps->num_chainmask_tables)
19156 return QDF_STATUS_E_INVAL;
19157
19158 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19159
19160 if (chainmask_caps == NULL)
19161 return QDF_STATUS_E_INVAL;
19162
19163 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19164
19165 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19166 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19167
19168 chainmask_table[i].cap_list[j].chainmask =
19169 chainmask_caps->chainmask;
19170
19171 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19172 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19173
19174 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19175 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19176
19177 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19178 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19179
19180 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19181 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19182
19183 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19184 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19185
19186 chainmask_table[i].cap_list[j].chain_mask_2G =
19187 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19188
19189 chainmask_table[i].cap_list[j].chain_mask_5G =
19190 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19191
19192 chainmask_table[i].cap_list[j].chain_mask_tx =
19193 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19194
19195 chainmask_table[i].cap_list[j].chain_mask_rx =
19196 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19197
19198 chainmask_table[i].cap_list[j].supports_aDFS =
19199 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19200
19201 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19202 chainmask_caps->supported_flags,
19203 chainmask_caps->chainmask
19204 );
19205 chainmask_caps++;
19206 }
19207 }
19208
19209 return QDF_STATUS_SUCCESS;
19210}
19211
19212/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019213 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19214 * from event
19215 * @wmi_handle: wmi handle
19216 * @param evt_buf: pointer to event buffer
19217 * @param param: Pointer to hold evt buf
19218 *
19219 * Return: QDF_STATUS_SUCCESS for success or error code
19220 */
19221static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019222 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019223{
19224 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19225 wmi_service_ready_ext_event_fixed_param *ev;
19226 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19227 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019228 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19229 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019230
19231 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19232 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019233 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019234
19235 ev = param_buf->fixed_param;
19236 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019237 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019238
19239 /* Move this to host based bitmap */
19240 param->default_conc_scan_config_bits =
19241 ev->default_conc_scan_config_bits;
19242 param->default_fw_config_bits = ev->default_fw_config_bits;
19243 param->he_cap_info = ev->he_cap_info;
19244 param->mpdu_density = ev->mpdu_density;
19245 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019246 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019247 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019248 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19249
19250 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019251 if (hw_caps)
19252 param->num_hw_modes = hw_caps->num_hw_modes;
19253 else
19254 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019255
19256 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019257 if (reg_caps)
19258 param->num_phy = reg_caps->num_phy;
19259 else
19260 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019261
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019262 if (hw_caps) {
19263 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
19264 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
19265 } else
19266 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019267
19268 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19269
19270 if (chain_mask_combo == NULL)
19271 return QDF_STATUS_SUCCESS;
19272
19273 qdf_print("Dumping chain mask combo data\n");
19274
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019275 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019276
19277 qdf_print("table_id : %d Num valid chainmasks: %d\n",
19278 chain_mask_combo->chainmask_table_id,
19279 chain_mask_combo->num_valid_chainmask
19280 );
19281
19282 param->chainmask_table[i].table_id =
19283 chain_mask_combo->chainmask_table_id;
19284 param->chainmask_table[i].num_valid_chainmasks =
19285 chain_mask_combo->num_valid_chainmask;
19286 chain_mask_combo++;
19287 }
19288 qdf_print("chain mask combo end\n");
19289
Kiran Venkatappa06520822016-08-10 23:55:40 +053019290 return QDF_STATUS_SUCCESS;
19291}
19292
19293/**
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019294 * extract_sar_cap_service_ready_ext_tlv() -
19295 * extract SAR cap from service ready event
19296 * @wmi_handle: wmi handle
19297 * @event: pointer to event buffer
19298 * @ext_param: extended target info
19299 *
19300 * Return: QDF_STATUS_SUCCESS for success or error code
19301 */
19302static QDF_STATUS extract_sar_cap_service_ready_ext_tlv(
19303 wmi_unified_t wmi_handle,
19304 uint8_t *event,
19305 struct wlan_psoc_host_service_ext_param *ext_param)
19306{
19307 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19308 WMI_SAR_CAPABILITIES *sar_caps;
19309
19310 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19311
19312 sar_caps = param_buf->sar_caps;
19313 if (!sar_caps)
19314 return QDF_STATUS_E_INVAL;
19315
19316 ext_param->sar_version = sar_caps->active_version;
19317
19318 return QDF_STATUS_SUCCESS;
19319}
19320
19321/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019322 * extract_hw_mode_cap_service_ready_ext_tlv() -
19323 * extract HW mode cap from service ready event
19324 * @wmi_handle: wmi handle
19325 * @param evt_buf: pointer to event buffer
19326 * @param param: Pointer to hold evt buf
19327 * @param hw_mode_idx: hw mode idx should be less than num_mode
19328 *
19329 * Return: QDF_STATUS_SUCCESS for success or error code
19330 */
19331static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19332 wmi_unified_t wmi_handle,
19333 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019334 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019335{
19336 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19337 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19338
19339 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19340 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019341 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019342
19343 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019344 if (!hw_caps)
19345 return QDF_STATUS_E_INVAL;
19346
Kiran Venkatappa06520822016-08-10 23:55:40 +053019347 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019348 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019349
19350 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19351 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19352
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019353 param->hw_mode_config_type =
19354 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19355
Kiran Venkatappa06520822016-08-10 23:55:40 +053019356 return QDF_STATUS_SUCCESS;
19357}
19358
19359/**
19360 * extract_mac_phy_cap_service_ready_ext_tlv() -
19361 * extract MAC phy cap from service ready event
19362 * @wmi_handle: wmi handle
19363 * @param evt_buf: pointer to event buffer
19364 * @param param: Pointer to hold evt buf
19365 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019366 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019367 *
19368 * Return: QDF_STATUS_SUCCESS for success or error code
19369 */
19370static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19371 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019372 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019373 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019374{
19375 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019376 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019377 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19378 uint32_t phy_map;
19379 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019380
19381 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19382 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019383 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019384
19385 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019386 if (!hw_caps)
19387 return QDF_STATUS_E_INVAL;
19388
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019389 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19390 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19391 break;
19392
19393 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19394 while (phy_map) {
19395 phy_map >>= 1;
19396 phy_idx++;
19397 }
19398 }
19399
19400 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019401 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019402
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019403 phy_idx += phy_id;
19404 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019405 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019406
19407 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019408
19409 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019410 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19411 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019412 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019413 param->supports_11b =
19414 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19415 param->supports_11g =
19416 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19417 param->supports_11a =
19418 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19419 param->supports_11n =
19420 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19421 param->supports_11ac =
19422 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19423 param->supports_11ax =
19424 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019425
19426 param->supported_bands = mac_phy_caps->supported_bands;
19427 param->ampdu_density = mac_phy_caps->ampdu_density;
19428 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19429 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19430 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19431 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19432 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19433 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19434 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19435 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19436 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19437 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19438 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19439 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19440 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19441 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19442 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19443 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019444 qdf_mem_copy(&param->he_cap_phy_info_2G,
19445 &mac_phy_caps->he_cap_phy_info_2G,
19446 sizeof(param->he_cap_phy_info_2G));
19447 qdf_mem_copy(&param->he_cap_phy_info_5G,
19448 &mac_phy_caps->he_cap_phy_info_5G,
19449 sizeof(param->he_cap_phy_info_5G));
19450 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19451 sizeof(param->he_ppet2G));
19452 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19453 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019454 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019455
19456 return QDF_STATUS_SUCCESS;
19457}
19458
19459/**
19460 * extract_reg_cap_service_ready_ext_tlv() -
19461 * extract REG cap from service ready event
19462 * @wmi_handle: wmi handle
19463 * @param evt_buf: pointer to event buffer
19464 * @param param: Pointer to hold evt buf
19465 * @param phy_idx: phy idx should be less than num_mode
19466 *
19467 * Return: QDF_STATUS_SUCCESS for success or error code
19468 */
19469static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
19470 wmi_unified_t wmi_handle,
19471 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019472 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019473{
19474 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19475 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
19476 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
19477
19478 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19479 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019480 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019481
19482 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019483 if (!reg_caps)
19484 return QDF_STATUS_E_INVAL;
19485
Kiran Venkatappa06520822016-08-10 23:55:40 +053019486 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019487 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019488
19489 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
19490
19491 param->phy_id = ext_reg_cap->phy_id;
19492 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
19493 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
19494 param->regcap1 = ext_reg_cap->regcap1;
19495 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053019496 param->wireless_modes = convert_wireless_modes_tlv(
19497 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019498 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
19499 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
19500 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
19501 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
19502
19503 return QDF_STATUS_SUCCESS;
19504}
19505
Sathish Kumarf396c722017-11-17 17:30:41 +053019506static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
19507 wmi_unified_t wmi_handle,
19508 uint8_t *event, uint8_t idx,
19509 struct wlan_psoc_host_dbr_ring_caps *param)
19510{
19511 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19512 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
19513
19514 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19515 if (!param_buf)
19516 return QDF_STATUS_E_INVAL;
19517
19518 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
19519
19520 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19521 dbr_ring_caps->pdev_id);
19522 param->mod_id = dbr_ring_caps->mod_id;
19523 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
19524 param->min_buf_size = dbr_ring_caps->min_buf_size;
19525 param->min_buf_align = dbr_ring_caps->min_buf_align;
19526
19527 return QDF_STATUS_SUCCESS;
19528}
19529
19530static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
19531 uint8_t *event, struct direct_buf_rx_rsp *param)
19532{
19533 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19534 wmi_dma_buf_release_fixed_param *ev;
19535
19536 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19537 if (!param_buf)
19538 return QDF_STATUS_E_INVAL;
19539
19540 ev = param_buf->fixed_param;
19541 if (!ev)
19542 return QDF_STATUS_E_INVAL;
19543
19544 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19545 ev->pdev_id);
19546 param->mod_id = ev->mod_id;
19547 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019548 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053019549 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
19550 param->pdev_id, param->mod_id, param->num_buf_release_entry);
19551
19552 return QDF_STATUS_SUCCESS;
19553}
19554
19555static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
19556 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
19557{
19558 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19559 wmi_dma_buf_release_entry *entry;
19560
19561 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19562 if (!param_buf)
19563 return QDF_STATUS_E_INVAL;
19564
19565 entry = &param_buf->entries[idx];
19566
19567 if (!entry) {
19568 WMI_LOGE("%s: Entry is NULL\n", __func__);
19569 return QDF_STATUS_E_FAILURE;
19570 }
19571
19572 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
19573
19574 param->paddr_lo = entry->paddr_lo;
19575 param->paddr_hi = entry->paddr_hi;
19576
19577 return QDF_STATUS_SUCCESS;
19578}
19579
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019580static QDF_STATUS extract_dbr_buf_metadata_tlv(
19581 wmi_unified_t wmi_handle, uint8_t *event,
19582 uint8_t idx, struct direct_buf_rx_metadata *param)
19583{
19584 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19585 wmi_dma_buf_release_spectral_meta_data *entry;
19586
19587 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19588 if (!param_buf)
19589 return QDF_STATUS_E_INVAL;
19590
19591 entry = &param_buf->meta_data[idx];
19592
19593 if (!entry) {
19594 WMI_LOGE("%s: Entry is NULL\n", __func__);
19595 return QDF_STATUS_E_FAILURE;
19596 }
19597
19598 qdf_mem_copy(param->noisefloor, entry->noise_floor,
19599 sizeof(entry->noise_floor));
19600 return QDF_STATUS_SUCCESS;
19601}
19602
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019603/**
19604 * extract_dcs_interference_type_tlv() - extract dcs interference type
19605 * from event
19606 * @wmi_handle: wmi handle
19607 * @param evt_buf: pointer to event buffer
19608 * @param param: Pointer to hold dcs interference param
19609 *
19610 * Return: 0 for success or error code
19611 */
19612static QDF_STATUS extract_dcs_interference_type_tlv(
19613 wmi_unified_t wmi_handle,
19614 void *evt_buf, struct wmi_host_dcs_interference_param *param)
19615{
19616 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19617
19618 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19619 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019620 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019621
19622 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019623 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19624 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019625
19626 return QDF_STATUS_SUCCESS;
19627}
19628
19629/*
19630 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
19631 * @wmi_handle: wmi handle
19632 * @param evt_buf: pointer to event buffer
19633 * @param cw_int: Pointer to hold cw interference
19634 *
19635 * Return: 0 for success or error code
19636 */
19637static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
19638 void *evt_buf,
19639 wmi_host_ath_dcs_cw_int *cw_int)
19640{
19641 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19642 wlan_dcs_cw_int *ev;
19643
19644 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19645 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019646 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019647
19648 ev = param_buf->cw_int;
19649
19650 cw_int->channel = ev->channel;
19651
19652 return QDF_STATUS_SUCCESS;
19653}
19654
19655/**
19656 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
19657 * @wmi_handle: wmi handle
19658 * @param evt_buf: pointer to event buffer
19659 * @param wlan_stat: Pointer to hold wlan stats
19660 *
19661 * Return: 0 for success or error code
19662 */
19663static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
19664 void *evt_buf,
19665 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
19666{
19667 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19668 wlan_dcs_im_tgt_stats_t *ev;
19669
19670 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19671 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019672 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019673
19674 ev = param_buf->wlan_stat;
19675 wlan_stat->reg_tsf32 = ev->reg_tsf32;
19676 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
19677 wlan_stat->tx_waste_time = ev->tx_waste_time;
19678 wlan_stat->rx_time = ev->rx_time;
19679 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
19680 wlan_stat->mib_stats.listen_time = ev->listen_time;
19681 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
19682 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
19683 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
19684 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
19685 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
19686 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
19687 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
19688 wlan_stat->chan_nf = ev->chan_nf;
19689 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19690
19691 return QDF_STATUS_SUCCESS;
19692}
19693
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019694/**
19695 * extract_thermal_stats_tlv() - extract thermal stats from event
19696 * @wmi_handle: wmi handle
19697 * @param evt_buf: Pointer to event buffer
19698 * @param temp: Pointer to hold extracted temperature
19699 * @param level: Pointer to hold extracted level
19700 *
19701 * Return: 0 for success or error code
19702 */
19703static QDF_STATUS
19704extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
19705 void *evt_buf, uint32_t *temp,
19706 uint32_t *level, uint32_t *pdev_id)
19707{
19708 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19709 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
19710
19711 param_buf =
19712 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19713 if (!param_buf)
19714 return QDF_STATUS_E_INVAL;
19715
19716 tt_stats_event = param_buf->fixed_param;
19717
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019718 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19719 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019720 *temp = tt_stats_event->temp;
19721 *level = tt_stats_event->level;
19722
19723 return QDF_STATUS_SUCCESS;
19724}
19725
19726/**
19727 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
19728 * @wmi_handle: wmi handle
19729 * @param evt_buf: pointer to event buffer
19730 * @param idx: Index to level stats
19731 * @param levelcount: Pointer to hold levelcount
19732 * @param dccount: Pointer to hold dccount
19733 *
19734 * Return: 0 for success or error code
19735 */
19736static QDF_STATUS
19737extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
19738 void *evt_buf, uint8_t idx, uint32_t *levelcount,
19739 uint32_t *dccount)
19740{
19741 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19742 wmi_therm_throt_level_stats_info *tt_level_info;
19743
19744 param_buf =
19745 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19746 if (!param_buf)
19747 return QDF_STATUS_E_INVAL;
19748
19749 tt_level_info = param_buf->therm_throt_level_stats_info;
19750
19751 if (idx < THERMAL_LEVELS) {
19752 *levelcount = tt_level_info[idx].level_count;
19753 *dccount = tt_level_info[idx].dc_count;
19754 return QDF_STATUS_SUCCESS;
19755 }
19756
19757 return QDF_STATUS_E_FAILURE;
19758}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019759#ifdef BIG_ENDIAN_HOST
19760/**
19761 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
19762 * @param data_len - data length
19763 * @param data - pointer to data
19764 *
19765 * Return: QDF_STATUS - success or error status
19766 */
19767static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19768{
19769 uint8_t *data_aligned = NULL;
19770 int c;
19771 unsigned char *data_unaligned;
19772
19773 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
19774 FIPS_ALIGN));
19775 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -070019776 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019777 if (data_unaligned == NULL)
19778 return QDF_STATUS_E_FAILURE;
19779
19780 /* Checking if space is alligned */
19781 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
19782 /* align the data space */
19783 data_aligned =
19784 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
19785 } else {
19786 data_aligned = (u_int8_t *)data_unaligned;
19787 }
19788
19789 /* memset and copy content from data to data aligned */
19790 OS_MEMSET(data_aligned, 0, data_len);
19791 OS_MEMCPY(data_aligned, data, data_len);
19792 /* Endianness to LE */
19793 for (c = 0; c < data_len/4; c++) {
19794 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019795 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019796 }
19797
19798 /* Copy content to event->data */
19799 OS_MEMCPY(data, data_aligned, data_len);
19800
19801 /* clean up allocated space */
19802 qdf_mem_free(data_unaligned);
19803 data_aligned = NULL;
19804 data_unaligned = NULL;
19805
19806 /*************************************************************/
19807
19808 return QDF_STATUS_SUCCESS;
19809}
19810#else
19811/**
19812 * fips_conv_data_be() - DUMMY for LE platform
19813 *
19814 * Return: QDF_STATUS - success
19815 */
19816static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19817{
19818 return QDF_STATUS_SUCCESS;
19819}
19820#endif
19821
19822/**
19823 * extract_fips_event_data_tlv() - extract fips event data
19824 * @wmi_handle: wmi handle
19825 * @param evt_buf: pointer to event buffer
19826 * @param param: pointer FIPS event params
19827 *
19828 * Return: 0 for success or error code
19829 */
19830static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
19831 void *evt_buf, struct wmi_host_fips_event_param *param)
19832{
19833 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
19834 wmi_pdev_fips_event_fixed_param *event;
19835
19836 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
19837 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
19838
19839 if (fips_conv_data_be(event->data_len, param_buf->data) !=
19840 QDF_STATUS_SUCCESS)
19841 return QDF_STATUS_E_FAILURE;
19842
19843 param->data = (uint32_t *)param_buf->data;
19844 param->data_len = event->data_len;
19845 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019846 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19847 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019848
19849 return QDF_STATUS_SUCCESS;
19850}
19851
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019852/*
19853 * extract_peer_delete_response_event_tlv() - extract peer delete response event
19854 * @wmi_handle: wmi handle
19855 * @param evt_buf: pointer to event buffer
19856 * @param vdev_id: Pointer to hold vdev_id
19857 * @param mac_addr: Pointer to hold peer mac address
19858 *
19859 * Return: QDF_STATUS_SUCCESS for success or error code
19860 */
19861static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
19862 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
19863{
19864 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
19865 wmi_peer_delete_resp_event_fixed_param *ev;
19866
19867 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
19868
19869 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
19870 if (!ev) {
19871 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
19872 return QDF_STATUS_E_FAILURE;
19873 }
19874
19875 param->vdev_id = ev->vdev_id;
19876 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
19877 &param->mac_address.bytes[0]);
19878
19879 return QDF_STATUS_SUCCESS;
19880}
19881
Govind Singhecf03cd2016-05-12 12:45:51 +053019882static bool is_management_record_tlv(uint32_t cmd_id)
19883{
jiad36c94d22018-01-22 15:37:03 +080019884 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
19885 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
19886 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053019887 return true;
jiad36c94d22018-01-22 15:37:03 +080019888 }
Govind Singhe7f2f342016-05-23 12:12:52 +053019889
Govind Singhecf03cd2016-05-12 12:45:51 +053019890 return false;
19891}
19892
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053019893static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19894{
19895 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
19896
19897 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
19898
19899 switch (set_cmd->param_id) {
19900 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
19901 case WMI_VDEV_PARAM_DTIM_POLICY:
19902 return HTC_TX_PACKET_TAG_AUTO_PM;
19903 default:
19904 break;
19905 }
19906
19907 return 0;
19908}
19909
19910static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19911{
19912 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
19913
19914 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
19915
19916 switch (ps_cmd->param) {
19917 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
19918 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
19919 case WMI_STA_PS_ENABLE_QPOWER:
19920 return HTC_TX_PACKET_TAG_AUTO_PM;
19921 default:
19922 break;
19923 }
19924
19925 return 0;
19926}
19927
19928static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
19929 uint32_t cmd_id)
19930{
19931 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
19932 return 0;
19933
19934 switch (cmd_id) {
19935 case WMI_VDEV_SET_PARAM_CMDID:
19936 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
19937 case WMI_STA_POWERSAVE_PARAM_CMDID:
19938 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
19939 default:
19940 break;
19941 }
19942
19943 return 0;
19944}
19945
19946static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
19947{
19948 uint16_t tag = 0;
19949
19950 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
19951 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
19952 __func__);
19953 return tag;
19954 }
19955
19956 if (wmi_handle->tag_crash_inject)
19957 tag = HTC_TX_PACKET_TAG_AUTO_PM;
19958
19959 wmi_handle->tag_crash_inject = false;
19960 return tag;
19961}
19962
19963/**
19964 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
19965 * @wmi_handle: WMI handle
19966 * @buf: WMI buffer
19967 * @cmd_id: WMI command Id
19968 *
19969 * Return htc_tx_tag
19970 */
19971static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
19972 wmi_buf_t buf,
19973 uint32_t cmd_id)
19974{
19975 uint16_t htc_tx_tag = 0;
19976
19977 switch (cmd_id) {
19978 case WMI_WOW_ENABLE_CMDID:
19979 case WMI_PDEV_SUSPEND_CMDID:
19980 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
19981 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
19982 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
19983 case WMI_PDEV_RESUME_CMDID:
19984 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
19985 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
19986#ifdef FEATURE_WLAN_D0WOW
19987 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
19988#endif
19989 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
19990 break;
19991 case WMI_FORCE_FW_HANG_CMDID:
19992 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
19993 break;
19994 case WMI_VDEV_SET_PARAM_CMDID:
19995 case WMI_STA_POWERSAVE_PARAM_CMDID:
19996 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
19997 default:
19998 break;
19999 }
20000
20001 return htc_tx_tag;
20002}
20003
Sathish Kumard3ab1002017-02-07 17:10:59 +053020004/**
20005 * extract_channel_hopping_event_tlv() - extract channel hopping param
20006 * from event
20007 * @wmi_handle: wmi handle
20008 * @param evt_buf: pointer to event buffer
20009 * @param ch_hopping: Pointer to hold channel hopping param
20010 *
20011 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20012 */
20013static QDF_STATUS extract_channel_hopping_event_tlv(
20014 wmi_unified_t wmi_handle, void *evt_buf,
20015 wmi_host_pdev_channel_hopping_event *ch_hopping)
20016{
20017 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20018 wmi_pdev_channel_hopping_event_fixed_param *event;
20019
20020 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20021 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20022 param_buf->fixed_param;
20023
20024 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20025 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020026 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20027 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020028
20029 return QDF_STATUS_SUCCESS;
20030}
20031
20032/**
20033 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20034 * @wmi_handle: wmi handle
20035 * @param evt_buf: pointer to event buffer
20036 * @param param: Pointer to hold tpc param
20037 *
20038 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20039 */
20040static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20041 void *evt_buf,
20042 wmi_host_pdev_tpc_event *param)
20043{
20044 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20045 wmi_pdev_tpc_event_fixed_param *event;
20046
20047 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20048 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20049
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020050 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20051 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020052 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20053
20054 return QDF_STATUS_SUCCESS;
20055}
20056
nobeljf74583b2018-01-25 16:35:36 -080020057/**
20058 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20059 * power param from event
20060 * @wmi_handle: wmi handle
20061 * @param evt_buf: pointer to event buffer
20062 * @param param: Pointer to hold nf cal power param
20063 *
20064 * Return: 0 for success or error code
20065 */
20066static QDF_STATUS
20067extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20068 void *evt_buf,
20069 wmi_host_pdev_nfcal_power_all_channels_event *param)
20070{
20071 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20072 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20073 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20074 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20075 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20076 uint32_t i;
20077
20078 param_buf =
20079 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20080 event = param_buf->fixed_param;
20081 ch_nfdbr = param_buf->nfdbr;
20082 ch_nfdbm = param_buf->nfdbm;
20083 ch_freqnum = param_buf->freqnum;
20084
20085 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20086 event->pdev_id, param_buf->num_nfdbr,
20087 param_buf->num_nfdbm, param_buf->num_freqnum);
20088
20089 if (param_buf->num_nfdbr >
20090 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20091 WMI_LOGE("invalid number of nfdBr");
20092 return QDF_STATUS_E_FAILURE;
20093 }
20094
20095 if (param_buf->num_nfdbm >
20096 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20097 WMI_LOGE("invalid number of nfdBm");
20098 return QDF_STATUS_E_FAILURE;
20099 }
20100
20101 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20102 WMI_LOGE("invalid number of freqNum");
20103 return QDF_STATUS_E_FAILURE;
20104 }
20105
20106 for (i = 0; i < param_buf->num_nfdbr; i++) {
20107 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20108 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20109 ch_nfdbr++;
20110 ch_nfdbm++;
20111 }
20112
20113 for (i = 0; i < param_buf->num_freqnum; i++) {
20114 param->freqnum[i] = ch_freqnum->freqNum;
20115 ch_freqnum++;
20116 }
20117
Keyur Parekh2c0bab62018-05-16 13:15:38 -070020118 param->pdev_id = wmi_handle->ops->
20119 convert_pdev_id_target_to_host(event->pdev_id);
nobeljf74583b2018-01-25 16:35:36 -080020120
20121 return QDF_STATUS_SUCCESS;
20122}
20123
Sathish Kumard3ab1002017-02-07 17:10:59 +053020124
20125#ifdef BIG_ENDIAN_HOST
20126/**
20127 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20128 * @param data_len - data length
20129 * @param data - pointer to data
20130 *
20131 * Return: QDF_STATUS - success or error status
20132 */
20133static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20134{
20135 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020136 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020137 /* Skip swapping the first word */
20138 datap += sizeof(uint32_t);
20139 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20140 i++, datap += sizeof(uint32_t)) {
20141 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20142 }
20143
20144 return QDF_STATUS_SUCCESS;
20145}
20146#else
20147/**
20148 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20149 * @param data_len - data length
20150 * @param data - pointer to data
20151 *
20152 * Return: QDF_STATUS - success or error status
20153 */
20154static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20155{
20156 return QDF_STATUS_SUCCESS;
20157}
20158#endif
20159
20160/**
20161 * extract_wds_addr_event_tlv() - extract wds address from event
20162 * @wmi_handle: wmi handle
20163 * @param evt_buf: pointer to event buffer
20164 * @param wds_ev: Pointer to hold wds address
20165 *
20166 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20167 */
20168static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20169 void *evt_buf,
20170 uint16_t len, wds_addr_event_t *wds_ev)
20171{
20172 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20173 wmi_wds_addr_event_fixed_param *ev;
20174 int i;
20175
20176 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20177 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20178
20179 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20180 return QDF_STATUS_E_FAILURE;
20181
20182 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20183 sizeof(wds_ev->event_type));
20184 for (i = 0; i < 4; i++) {
20185 wds_ev->peer_mac[i] =
20186 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20187 wds_ev->dest_mac[i] =
20188 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20189 }
20190 for (i = 0; i < 2; i++) {
20191 wds_ev->peer_mac[4+i] =
20192 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20193 wds_ev->dest_mac[4+i] =
20194 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20195 }
20196 return QDF_STATUS_SUCCESS;
20197}
20198
20199/**
20200 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20201 * from event
20202 * @wmi_handle: wmi handle
20203 * @param evt_buf: pointer to event buffer
20204 * @param ev: Pointer to hold peer param and ps state
20205 *
20206 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20207 */
20208static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20209 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20210{
20211 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20212 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20213
20214 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20215 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20216 param_buf->fixed_param;
20217
20218 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20219 ev->peer_ps_state = event->peer_ps_state;
20220
20221 return QDF_STATUS_SUCCESS;
20222}
20223
20224/**
20225 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20226 * @wmi_handle: wmi handle
20227 * @param evt_buf: pointer to event buffer
20228 * @param inst_rssi_resp: Pointer to hold inst rssi response
20229 *
20230 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20231 */
20232static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20233 wmi_unified_t wmi_handle, void *evt_buf,
20234 wmi_host_inst_stats_resp *inst_rssi_resp)
20235{
20236 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20237 wmi_inst_rssi_stats_resp_fixed_param *event;
20238
20239 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20240 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20241
20242 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20243 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20244 inst_rssi_resp->iRSSI = event->iRSSI;
20245
20246 return QDF_STATUS_SUCCESS;
20247}
20248
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020249static struct cur_reg_rule
20250*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20251 wmi_regulatory_rule_struct *wmi_reg_rule)
20252{
20253 struct cur_reg_rule *reg_rule_ptr;
20254 uint32_t count;
20255
20256 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20257
20258 if (NULL == reg_rule_ptr) {
20259 WMI_LOGE("memory allocation failure");
20260 return NULL;
20261 }
20262
20263 for (count = 0; count < num_reg_rules; count++) {
20264 reg_rule_ptr[count].start_freq =
20265 WMI_REG_RULE_START_FREQ_GET(
20266 wmi_reg_rule[count].freq_info);
20267 reg_rule_ptr[count].end_freq =
20268 WMI_REG_RULE_END_FREQ_GET(
20269 wmi_reg_rule[count].freq_info);
20270 reg_rule_ptr[count].max_bw =
20271 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020272 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020273 reg_rule_ptr[count].reg_power =
20274 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020275 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020276 reg_rule_ptr[count].ant_gain =
20277 WMI_REG_RULE_ANTENNA_GAIN_GET(
20278 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020279 reg_rule_ptr[count].flags =
20280 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020281 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020282 }
20283
20284 return reg_rule_ptr;
20285}
20286
20287static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20288 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20289 struct cur_regulatory_info *reg_info, uint32_t len)
20290{
20291 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20292 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20293 wmi_regulatory_rule_struct *wmi_reg_rule;
20294 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20295
20296 WMI_LOGD("processing regulatory channel list");
20297
20298 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20299 if (!param_buf) {
20300 WMI_LOGE("invalid channel list event buf");
20301 return QDF_STATUS_E_FAILURE;
20302 }
20303
20304 chan_list_event_hdr = param_buf->fixed_param;
20305
20306 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20307 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20308 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020309 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020310 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20311 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020312 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020313 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020314 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020315 reg_info->ctry_code = chan_list_event_hdr->country_id;
20316 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20317 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20318 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20319 else if (chan_list_event_hdr->status_code ==
20320 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20321 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20322 else if (chan_list_event_hdr->status_code ==
20323 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20324 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20325 else if (chan_list_event_hdr->status_code ==
20326 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20327 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20328 else if (chan_list_event_hdr->status_code ==
20329 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20330 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20331 else if (chan_list_event_hdr->status_code ==
20332 WMI_REG_SET_CC_STATUS_FAIL)
20333 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20334
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020335 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20336 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20337 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20338 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20339
20340 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20341 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20342
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020343 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20344 __func__, reg_info->alpha2, reg_info->dfs_region,
20345 reg_info->min_bw_2g, reg_info->max_bw_2g,
20346 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020347
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020348 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20349 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020350 wmi_reg_rule =
20351 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20352 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20353 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020354 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20355 wmi_reg_rule);
20356 wmi_reg_rule += num_2g_reg_rules;
20357
20358 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20359 wmi_reg_rule);
20360
20361 WMI_LOGD("processed regulatory channel list");
20362
20363 return QDF_STATUS_SUCCESS;
20364}
20365
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020366static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20367 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20368 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20369{
20370 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20371 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20372
20373 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20374 if (!param_buf) {
20375 WMI_LOGE("invalid 11d country event buf");
20376 return QDF_STATUS_E_FAILURE;
20377 }
20378
20379 reg_11d_country_event = param_buf->fixed_param;
20380
20381 qdf_mem_copy(reg_11d_country->alpha2,
20382 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20383
20384 WMI_LOGD("processed 11d country event, new cc %s",
20385 reg_11d_country->alpha2);
20386
20387 return QDF_STATUS_SUCCESS;
20388}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020389
20390static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20391 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20392 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20393{
20394 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20395 wmi_avoid_freq_range_desc *afr_desc;
20396 uint32_t num_freq_ranges, freq_range_idx;
20397 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20398 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20399
20400 if (!param_buf) {
20401 WMI_LOGE("Invalid channel avoid event buffer");
20402 return QDF_STATUS_E_INVAL;
20403 }
20404
20405 afr_fixed_param = param_buf->fixed_param;
20406 if (!afr_fixed_param) {
20407 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20408 return QDF_STATUS_E_INVAL;
20409 }
20410
20411 if (!ch_avoid_ind) {
20412 WMI_LOGE("Invalid channel avoid indication buffer");
20413 return QDF_STATUS_E_INVAL;
20414 }
20415 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20416 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20417 afr_fixed_param->num_freq_ranges;
20418
20419 WMI_LOGD("Channel avoid event received with %d ranges",
20420 num_freq_ranges);
20421
20422 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20423 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20424 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20425 freq_range_idx++) {
20426 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20427 afr_desc->start_freq;
20428 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20429 afr_desc->end_freq;
20430 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20431 freq_range_idx, afr_desc->tlv_header,
20432 afr_desc->start_freq, afr_desc->end_freq);
20433 afr_desc++;
20434 }
20435
20436 return QDF_STATUS_SUCCESS;
20437}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020438#ifdef DFS_COMPONENT_ENABLE
20439/**
20440 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20441 * @wmi_handle: wma handle
20442 * @evt_buf: event buffer
20443 * @vdev_id: vdev id
20444 * @len: length of buffer
20445 *
20446 * Return: 0 for success or error code
20447 */
20448static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20449 uint8_t *evt_buf,
20450 uint32_t *vdev_id,
20451 uint32_t len)
20452{
20453 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20454 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20455
20456 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20457 if (!param_tlvs) {
20458 WMI_LOGE("invalid cac complete event buf");
20459 return QDF_STATUS_E_FAILURE;
20460 }
20461
20462 cac_event = param_tlvs->fixed_param;
20463 *vdev_id = cac_event->vdev_id;
20464 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20465
20466 return QDF_STATUS_SUCCESS;
20467}
20468
20469/**
20470 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20471 * @wmi_handle: wma handle
20472 * @evt_buf: event buffer
20473 * @radar_found: radar found event info
20474 * @len: length of buffer
20475 *
20476 * Return: 0 for success or error code
20477 */
20478static QDF_STATUS extract_dfs_radar_detection_event_tlv(
20479 wmi_unified_t wmi_handle,
20480 uint8_t *evt_buf,
20481 struct radar_found_info *radar_found,
20482 uint32_t len)
20483{
20484 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
20485 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
20486
20487 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
20488 if (!param_tlv) {
20489 WMI_LOGE("invalid radar detection event buf");
20490 return QDF_STATUS_E_FAILURE;
20491 }
20492
20493 radar_event = param_tlv->fixed_param;
Arif Hussainb522ac92018-06-27 10:51:06 -070020494 radar_found->pdev_id = convert_target_pdev_id_to_host_pdev_id(
20495 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020496 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020497 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020498 radar_found->chan_width = radar_event->chan_width;
20499 radar_found->detector_id = radar_event->detector_id;
20500 radar_found->segment_id = radar_event->segment_id;
20501 radar_found->timestamp = radar_event->timestamp;
20502 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020503 radar_found->freq_offset = radar_event->freq_offset;
20504 radar_found->sidx = radar_event->sidx;
20505
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020506 WMI_LOGI("processed radar found event pdev %d,"
20507 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
20508 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
20509 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
20510 "is_chirp %d,detection mode %d\n",
Arif Hussainb522ac92018-06-27 10:51:06 -070020511 radar_event->pdev_id, radar_found->pdev_id,
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020512 radar_event->timestamp, radar_event->chan_freq,
20513 radar_event->chan_width, radar_event->detector_id,
20514 radar_event->freq_offset, radar_event->segment_id,
20515 radar_event->sidx, radar_event->is_chirp,
20516 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020517
20518 return QDF_STATUS_SUCCESS;
20519}
bings1ea12532017-12-18 16:56:53 +080020520
20521#ifdef QCA_MCL_DFS_SUPPORT
20522/**
20523 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
20524 * @wmi_handle: wma handle
20525 * @evt_buf: event buffer
20526 * @wlan_radar_event: Pointer to struct radar_event_info
20527 * @len: length of buffer
20528 *
20529 * Return: QDF_STATUS
20530 */
20531static QDF_STATUS extract_wlan_radar_event_info_tlv(
20532 wmi_unified_t wmi_handle,
20533 uint8_t *evt_buf,
20534 struct radar_event_info *wlan_radar_event,
20535 uint32_t len)
20536{
20537 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
20538 wmi_dfs_radar_event_fixed_param *radar_event;
20539
20540 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
20541 if (!param_tlv) {
20542 WMI_LOGE("invalid wlan radar event buf");
20543 return QDF_STATUS_E_FAILURE;
20544 }
20545
20546 radar_event = param_tlv->fixed_param;
20547 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
20548 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
20549 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
20550 wlan_radar_event->rssi = radar_event->rssi;
20551 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
20552 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
20553 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
20554 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080020555 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
20556 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +080020557 if (radar_event->pulse_flags &
20558 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
20559 wlan_radar_event->is_psidx_diff_valid = true;
20560 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
20561 } else {
20562 wlan_radar_event->is_psidx_diff_valid = false;
20563 }
20564
bings1ea12532017-12-18 16:56:53 +080020565 wlan_radar_event->pdev_id = radar_event->pdev_id;
20566
20567 return QDF_STATUS_SUCCESS;
20568}
20569#else
20570static QDF_STATUS extract_wlan_radar_event_info_tlv(
20571 wmi_unified_t wmi_handle,
20572 uint8_t *evt_buf,
20573 struct radar_event_info *wlan_radar_event,
20574 uint32_t len)
20575{
20576 return QDF_STATUS_SUCCESS;
20577}
20578#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020579#endif
20580
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020581/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020582 * send_get_rcpi_cmd_tlv() - send request for rcpi value
20583 * @wmi_handle: wmi handle
20584 * @get_rcpi_param: rcpi params
20585 *
20586 * Return: QDF status
20587 */
20588static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
20589 struct rcpi_req *get_rcpi_param)
20590{
20591 wmi_buf_t buf;
20592 wmi_request_rcpi_cmd_fixed_param *cmd;
20593 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
20594
20595 buf = wmi_buf_alloc(wmi_handle, len);
20596 if (!buf) {
20597 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
20598 return QDF_STATUS_E_NOMEM;
20599 }
20600
20601 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
20602 WMITLV_SET_HDR(&cmd->tlv_header,
20603 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
20604 WMITLV_GET_STRUCT_TLVLEN
20605 (wmi_request_rcpi_cmd_fixed_param));
20606
20607 cmd->vdev_id = get_rcpi_param->vdev_id;
20608 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
20609 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070020610
20611 switch (get_rcpi_param->measurement_type) {
20612
20613 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20614 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20615 break;
20616
20617 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
20618 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
20619 break;
20620
20621 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20622 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20623 break;
20624
20625 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
20626 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
20627 break;
20628
20629 default:
20630 /*
20631 * invalid rcpi measurement type, fall back to
20632 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
20633 */
20634 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20635 break;
20636 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020637 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
20638 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20639 WMI_REQUEST_RCPI_CMDID)) {
20640
20641 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
20642 __func__);
20643 wmi_buf_free(buf);
20644 return QDF_STATUS_E_FAILURE;
20645 }
20646
20647 return QDF_STATUS_SUCCESS;
20648}
20649
20650/**
20651 * extract_rcpi_response_event_tlv() - Extract RCPI event params
20652 * @wmi_handle: wmi handle
20653 * @evt_buf: pointer to event buffer
20654 * @res: pointer to hold rcpi response from firmware
20655 *
20656 * Return: QDF_STATUS_SUCCESS for successful event parse
20657 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
20658 */
20659static QDF_STATUS
20660extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
20661 void *evt_buf, struct rcpi_res *res)
20662{
20663 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
20664 wmi_update_rcpi_event_fixed_param *event;
20665
20666 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
20667 if (!param_buf) {
20668 WMI_LOGE(FL("Invalid rcpi event"));
20669 return QDF_STATUS_E_INVAL;
20670 }
20671
20672 event = param_buf->fixed_param;
20673 res->vdev_id = event->vdev_id;
20674 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
20675
20676 switch (event->measurement_type) {
20677
20678 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20679 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20680 break;
20681
20682 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
20683 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
20684 break;
20685
20686 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20687 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20688 break;
20689
20690 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
20691 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
20692 break;
20693
20694 default:
20695 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
20696 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
20697 return QDF_STATUS_E_FAILURE;
20698 }
20699
20700 if (event->status)
20701 return QDF_STATUS_E_FAILURE;
20702 else
20703 return QDF_STATUS_SUCCESS;
20704}
20705
20706/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020707 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
20708 * host to target defines. For legacy there is not conversion
20709 * required. Just return pdev_id as it is.
20710 * @param pdev_id: host pdev_id to be converted.
20711 * Return: target pdev_id after conversion.
20712 */
20713static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
20714 uint32_t pdev_id)
20715{
20716 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
20717 return WMI_PDEV_ID_SOC;
20718
20719 /*No conversion required*/
20720 return pdev_id;
20721}
20722
20723/**
20724 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
20725 * target to host defines. For legacy there is not conversion
20726 * required. Just return pdev_id as it is.
20727 * @param pdev_id: target pdev_id to be converted.
20728 * Return: host pdev_id after conversion.
20729 */
20730static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
20731 uint32_t pdev_id)
20732{
20733 /*No conversion required*/
20734 return pdev_id;
20735}
20736
20737/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020738 * send_set_country_cmd_tlv() - WMI scan channel list function
20739 * @param wmi_handle : handle to WMI.
20740 * @param param : pointer to hold scan channel list parameter
20741 *
20742 * Return: 0 on success and -ve on failure.
20743 */
20744static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
20745 struct set_country *params)
20746{
20747 wmi_buf_t buf;
20748 QDF_STATUS qdf_status;
20749 wmi_set_current_country_cmd_fixed_param *cmd;
20750 uint16_t len = sizeof(*cmd);
20751
20752 buf = wmi_buf_alloc(wmi_handle, len);
20753 if (!buf) {
20754 WMI_LOGE("Failed to allocate memory");
20755 qdf_status = QDF_STATUS_E_NOMEM;
20756 goto end;
20757 }
20758
20759 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
20760 WMITLV_SET_HDR(&cmd->tlv_header,
20761 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
20762 WMITLV_GET_STRUCT_TLVLEN
20763 (wmi_set_current_country_cmd_fixed_param));
20764
20765 WMI_LOGD("setting cuurnet country to %s", params->country);
20766
20767 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
20768
20769 cmd->pdev_id = params->pdev_id;
20770
20771 qdf_status = wmi_unified_cmd_send(wmi_handle,
20772 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
20773
20774 if (QDF_IS_STATUS_ERROR(qdf_status)) {
20775 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
20776 wmi_buf_free(buf);
20777 }
20778
20779end:
20780 return qdf_status;
20781}
20782
Abhijit Pradhand38a2692017-06-29 12:32:20 +053020783#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
20784 WMI_SET_BITS(alpha, 0, 8, val0); \
20785 WMI_SET_BITS(alpha, 8, 8, val1); \
20786 WMI_SET_BITS(alpha, 16, 8, val2); \
20787 } while (0)
20788
20789static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
20790 uint8_t pdev_id, struct cc_regdmn_s *rd)
20791{
20792 wmi_set_init_country_cmd_fixed_param *cmd;
20793 uint16_t len;
20794 wmi_buf_t buf;
20795 int ret;
20796
20797 len = sizeof(wmi_set_init_country_cmd_fixed_param);
20798 buf = wmi_buf_alloc(wmi_handle, len);
20799 if (!buf) {
20800 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
20801 return QDF_STATUS_E_NOMEM;
20802 }
20803 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
20804 WMITLV_SET_HDR(&cmd->tlv_header,
20805 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
20806 WMITLV_GET_STRUCT_TLVLEN
20807 (wmi_set_init_country_cmd_fixed_param));
20808
20809 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
20810
20811 if (rd->flags == CC_IS_SET) {
20812 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
20813 cmd->country_code.country_id = rd->cc.country_code;
20814 } else if (rd->flags == ALPHA_IS_SET) {
20815 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
20816 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
20817 rd->cc.alpha[0],
20818 rd->cc.alpha[1],
20819 rd->cc.alpha[2]);
20820 } else if (rd->flags == REGDMN_IS_SET) {
20821 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
20822 cmd->country_code.domain_code = rd->cc.regdmn_id;
20823 }
20824
20825 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
20826 WMI_SET_INIT_COUNTRY_CMDID);
20827 if (ret) {
20828 WMI_LOGE("Failed to config wow wakeup event");
20829 wmi_buf_free(buf);
20830 return QDF_STATUS_E_FAILURE;
20831 }
20832
20833 return QDF_STATUS_SUCCESS;
20834}
20835
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053020836/**
20837 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
20838 * configuration params
20839 * @wmi_handle: wmi handler
20840 * @limit_off_chan_param: pointer to wmi_off_chan_param
20841 *
20842 * Return: 0 for success and non zero for failure
20843 */
20844static
20845QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
20846 struct wmi_limit_off_chan_param *limit_off_chan_param)
20847{
20848 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
20849 wmi_buf_t buf;
20850 uint32_t len = sizeof(*cmd);
20851 int err;
20852
20853 buf = wmi_buf_alloc(wmi_handle, len);
20854 if (!buf) {
20855 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
20856 __func__);
20857 return QDF_STATUS_E_NOMEM;
20858 }
20859
20860 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
20861
20862 WMITLV_SET_HDR(&cmd->tlv_header,
20863 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
20864 WMITLV_GET_STRUCT_TLVLEN(
20865 wmi_vdev_limit_offchan_cmd_fixed_param));
20866
20867 cmd->vdev_id = limit_off_chan_param->vdev_id;
20868
20869 cmd->flags &= 0;
20870 if (limit_off_chan_param->status)
20871 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
20872 if (limit_off_chan_param->skip_dfs_chans)
20873 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
20874
20875 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
20876 cmd->rest_time = limit_off_chan_param->rest_time;
20877
20878 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
20879 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
20880 cmd->rest_time);
20881
20882 err = wmi_unified_cmd_send(wmi_handle, buf,
20883 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
20884 if (QDF_IS_STATUS_ERROR(err)) {
20885 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
20886 wmi_buf_free(buf);
20887 return QDF_STATUS_E_FAILURE;
20888 }
20889
20890 return QDF_STATUS_SUCCESS;
20891}
20892
Anurag Chouhan97f00422017-09-11 14:56:30 +053020893/**
20894 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
20895 * @wmi_handle: wmi handler
20896 * @req_buf: set arp stats request buffer
20897 *
20898 * Return: 0 for success and non zero for failure
20899 */
20900static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20901 struct set_arp_stats *req_buf)
20902{
20903 wmi_buf_t buf = NULL;
20904 QDF_STATUS status;
20905 int len;
20906 uint8_t *buf_ptr;
20907 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
20908
20909 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020910 if (req_buf->pkt_type_bitmap) {
20911 len += WMI_TLV_HDR_SIZE;
20912 len += sizeof(wmi_vdev_set_connectivity_check_stats);
20913 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053020914 buf = wmi_buf_alloc(wmi_handle, len);
20915 if (!buf) {
20916 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20917 return QDF_STATUS_E_NOMEM;
20918 }
20919
20920 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20921 wmi_set_arp =
20922 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
20923 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
20924 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
20925 WMITLV_GET_STRUCT_TLVLEN
20926 (wmi_vdev_set_arp_stats_cmd_fixed_param));
20927
20928 /* fill in per roam config values */
20929 wmi_set_arp->vdev_id = req_buf->vdev_id;
20930
20931 wmi_set_arp->set_clr = req_buf->flag;
20932 wmi_set_arp->pkt_type = req_buf->pkt_type;
20933 wmi_set_arp->ipv4 = req_buf->ip_addr;
20934
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020935 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
20936 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
20937 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
20938
20939 /*
20940 * pkt_type_bitmap should be non-zero to ensure
20941 * presence of additional stats.
20942 */
20943 if (req_buf->pkt_type_bitmap) {
20944 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
20945
20946 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
20947 WMITLV_SET_HDR(buf_ptr,
20948 WMITLV_TAG_ARRAY_STRUC,
20949 sizeof(wmi_vdev_set_connectivity_check_stats));
20950 buf_ptr += WMI_TLV_HDR_SIZE;
20951 wmi_set_connect_stats =
20952 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
20953 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
20954 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
20955 WMITLV_GET_STRUCT_TLVLEN(
20956 wmi_vdev_set_connectivity_check_stats));
20957 wmi_set_connect_stats->pkt_type_bitmap =
20958 req_buf->pkt_type_bitmap;
20959 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
20960 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
20961 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
20962
20963 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
20964 wmi_set_connect_stats->pkt_type_bitmap,
20965 wmi_set_connect_stats->tcp_src_port,
20966 wmi_set_connect_stats->tcp_dst_port,
20967 wmi_set_connect_stats->icmp_ipv4);
20968 }
20969
Anurag Chouhan97f00422017-09-11 14:56:30 +053020970 /* Send per roam config parameters */
20971 status = wmi_unified_cmd_send(wmi_handle, buf,
20972 len, WMI_VDEV_SET_ARP_STAT_CMDID);
20973 if (QDF_IS_STATUS_ERROR(status)) {
20974 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
20975 status);
20976 goto error;
20977 }
20978
20979 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
20980 req_buf->flag, req_buf->vdev_id);
20981 return QDF_STATUS_SUCCESS;
20982error:
20983 wmi_buf_free(buf);
20984
20985 return status;
20986}
20987
20988/**
20989 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
20990 * @wmi_handle: wmi handler
20991 * @req_buf: get arp stats request buffer
20992 *
20993 * Return: 0 for success and non zero for failure
20994 */
20995static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20996 struct get_arp_stats *req_buf)
20997{
20998 wmi_buf_t buf = NULL;
20999 QDF_STATUS status;
21000 int len;
21001 uint8_t *buf_ptr;
21002 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21003
21004 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21005 buf = wmi_buf_alloc(wmi_handle, len);
21006 if (!buf) {
21007 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21008 return QDF_STATUS_E_NOMEM;
21009 }
21010
21011 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21012 get_arp_stats =
21013 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21014 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21015 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21016 WMITLV_GET_STRUCT_TLVLEN
21017 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21018
21019 /* fill in arp stats req cmd values */
21020 get_arp_stats->vdev_id = req_buf->vdev_id;
21021
21022 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21023 /* Send per roam config parameters */
21024 status = wmi_unified_cmd_send(wmi_handle, buf,
21025 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21026 if (QDF_IS_STATUS_ERROR(status)) {
21027 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21028 status);
21029 goto error;
21030 }
21031
21032 return QDF_STATUS_SUCCESS;
21033error:
21034 wmi_buf_free(buf);
21035
21036 return status;
21037}
21038
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021039/**
21040 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21041 * @wmi_handle: wmi handler
21042 * @pmk_info: pointer to PMK cache entry
21043 * @vdev_id: vdev id
21044 *
21045 * Return: 0 for success and non zero for failure
21046 */
21047static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21048 struct wmi_unified_pmk_cache *pmk_info)
21049{
21050 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21051 wmi_buf_t buf;
21052 QDF_STATUS status;
21053 uint8_t *buf_ptr;
21054 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021055 uint32_t len = sizeof(*cmd);
21056
21057 if (pmk_info->pmk_len)
21058 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021059
21060 buf = wmi_buf_alloc(wmi_handle, len);
21061 if (!buf) {
21062 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21063 __func__);
21064 return QDF_STATUS_E_NOMEM;
21065 }
21066
21067 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21068 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21069
21070 WMITLV_SET_HDR(&cmd->tlv_header,
21071 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21072 WMITLV_GET_STRUCT_TLVLEN(
21073 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21074
21075 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021076
21077 /* If pmk_info->pmk_len is 0, this is a flush request */
21078 if (!pmk_info->pmk_len) {
21079 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21080 cmd->num_cache = 0;
21081 goto send_cmd;
21082 }
21083
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021084 cmd->num_cache = 1;
21085 buf_ptr += sizeof(*cmd);
21086
21087 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21088 sizeof(*pmksa));
21089 buf_ptr += WMI_TLV_HDR_SIZE;
21090
21091 pmksa = (wmi_pmk_cache *)buf_ptr;
21092 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21093 WMITLV_GET_STRUCT_TLVLEN
21094 (wmi_pmk_cache));
21095 pmksa->pmk_len = pmk_info->pmk_len;
21096 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21097 pmksa->pmkid_len = pmk_info->pmkid_len;
21098 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21099 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21100 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21101 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21102 pmksa->ssid.ssid_len);
21103 pmksa->cache_id = pmk_info->cache_id;
21104 pmksa->cat_flag = pmk_info->cat_flag;
21105 pmksa->action_flag = pmk_info->action_flag;
21106
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021107send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021108 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21109 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21110 if (status != QDF_STATUS_SUCCESS) {
21111 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21112 __func__, status);
21113 wmi_buf_free(buf);
21114 }
21115
21116 return status;
21117}
21118
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021119/**
21120 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21121 * @wmi_handle: wmi handle
21122 * @param: reserved param
21123 *
21124 * Return: 0 for success or error code
21125 */
21126static QDF_STATUS
21127send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21128 uint32_t param)
21129{
21130 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21131 wmi_buf_t buf;
21132 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21133
21134 buf = wmi_buf_alloc(wmi_handle, len);
21135 if (!buf) {
21136 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21137 return QDF_STATUS_E_FAILURE;
21138 }
21139 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21140 WMITLV_SET_HDR(&cmd->tlv_header,
21141 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21142 WMITLV_GET_STRUCT_TLVLEN
21143 (wmi_pdev_check_cal_version_cmd_fixed_param));
21144 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21145 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21146 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21147 wmi_buf_free(buf);
21148 return QDF_STATUS_E_FAILURE;
21149 }
21150
21151 return QDF_STATUS_SUCCESS;
21152}
21153
21154/**
21155 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21156 * @wmi_handle: wmi handle
21157 * @param evt_buf: pointer to event buffer
21158 * @param param: Pointer to hold peer caldata version data
21159 *
21160 * Return: 0 for success or error code
21161 */
21162static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21163 wmi_unified_t wmi_handle,
21164 void *evt_buf,
21165 wmi_host_pdev_check_cal_version_event *param)
21166{
21167 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21168 wmi_pdev_check_cal_version_event_fixed_param *event;
21169
21170 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21171 if (!param_tlvs) {
21172 WMI_LOGE("invalid cal version event buf");
21173 return QDF_STATUS_E_FAILURE;
21174 }
21175 event = param_tlvs->fixed_param;
21176 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21177 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21178 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21179 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21180
21181 param->software_cal_version = event->software_cal_version;
21182 param->board_cal_version = event->board_cal_version;
21183 param->cal_ok = event->cal_status;
21184
21185 return QDF_STATUS_SUCCESS;
21186}
21187
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021188/*
21189 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21190 * @wmi_handle: wmi handle
21191 * @params: pointer to wmi_btm_config
21192 *
21193 * Return: QDF_STATUS
21194 */
21195static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21196 struct wmi_btm_config *params)
21197{
21198
21199 wmi_btm_config_fixed_param *cmd;
21200 wmi_buf_t buf;
21201 uint32_t len;
21202
21203 len = sizeof(*cmd);
21204 buf = wmi_buf_alloc(wmi_handle, len);
21205 if (!buf) {
21206 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21207 return QDF_STATUS_E_NOMEM;
21208 }
21209
21210 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21211 WMITLV_SET_HDR(&cmd->tlv_header,
21212 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21213 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21214 cmd->vdev_id = params->vdev_id;
21215 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021216 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21217 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21218 cmd->stick_time_seconds = params->btm_sticky_time;
21219
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021220 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21221 WMI_ROAM_BTM_CONFIG_CMDID)) {
21222 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21223 __func__);
21224 wmi_buf_free(buf);
21225 return QDF_STATUS_E_FAILURE;
21226 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021227
21228 return QDF_STATUS_SUCCESS;
21229}
21230
21231/**
21232 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21233 * configurations to firmware.
21234 * @wmi_handle: wmi handle
21235 * @obss_cfg_param: obss detection configurations
21236 *
21237 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21238 *
21239 * Return: QDF_STATUS
21240 */
21241static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21242 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21243{
21244 wmi_buf_t buf;
21245 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21246 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21247
21248 buf = wmi_buf_alloc(wmi_handle, len);
21249 if (!buf) {
21250 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21251 return QDF_STATUS_E_NOMEM;
21252 }
21253
21254 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21255 WMITLV_SET_HDR(&cmd->tlv_header,
21256 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21257 WMITLV_GET_STRUCT_TLVLEN
21258 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21259
21260 cmd->vdev_id = obss_cfg_param->vdev_id;
21261 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21262 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21263 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21264 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21265 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21266 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21267 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21268 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021269
21270 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21271 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21272 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21273 wmi_buf_free(buf);
21274 return QDF_STATUS_E_FAILURE;
21275 }
21276
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021277 return QDF_STATUS_SUCCESS;
21278}
21279
Arif Hussain33d98502018-01-12 13:15:04 -080021280/**
21281 * extract_obss_detection_info_tlv() - Extract obss detection info
21282 * received from firmware.
21283 * @evt_buf: pointer to event buffer
21284 * @obss_detection: Pointer to hold obss detection info
21285 *
21286 * Return: QDF_STATUS
21287 */
21288static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21289 struct wmi_obss_detect_info
21290 *obss_detection)
21291{
21292 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21293 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21294
21295 if (!obss_detection) {
21296 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21297 return QDF_STATUS_E_INVAL;
21298 }
21299
21300 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21301 if (!param_buf) {
21302 WMI_LOGE("%s: Invalid evt_buf", __func__);
21303 return QDF_STATUS_E_INVAL;
21304 }
21305
21306 fix_param = param_buf->fixed_param;
21307 obss_detection->vdev_id = fix_param->vdev_id;
21308 obss_detection->matched_detection_masks =
21309 fix_param->matched_detection_masks;
21310 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21311 &obss_detection->matched_bssid_addr[0]);
21312 switch (fix_param->reason) {
21313 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21314 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21315 break;
21316 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21317 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21318 break;
21319 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21320 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21321 break;
21322 default:
21323 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21324 return QDF_STATUS_E_INVAL;
21325 }
21326
21327 return QDF_STATUS_SUCCESS;
21328}
21329
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021330/**
21331 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21332 * @wmi_handle: wmi handler
21333 * @params: pointer to 11k offload params
21334 *
21335 * Return: 0 for success and non zero for failure
21336 */
21337static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21338 struct wmi_11k_offload_params *params)
21339{
21340 wmi_11k_offload_report_fixed_param *cmd;
21341 wmi_buf_t buf;
21342 QDF_STATUS status;
21343 uint8_t *buf_ptr;
21344 wmi_neighbor_report_11k_offload_tlv_param
21345 *neighbor_report_offload_params;
21346 wmi_neighbor_report_offload *neighbor_report_offload;
21347
21348 uint32_t len = sizeof(*cmd);
21349
21350 if (params->offload_11k_bitmask &
21351 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21352 len += WMI_TLV_HDR_SIZE +
21353 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21354
21355 buf = wmi_buf_alloc(wmi_handle, len);
21356 if (!buf) {
21357 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21358 __func__);
21359 return QDF_STATUS_E_NOMEM;
21360 }
21361
21362 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21363 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21364
21365 WMITLV_SET_HDR(&cmd->tlv_header,
21366 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21367 WMITLV_GET_STRUCT_TLVLEN(
21368 wmi_11k_offload_report_fixed_param));
21369
21370 cmd->vdev_id = params->vdev_id;
21371 cmd->offload_11k = params->offload_11k_bitmask;
21372
21373 if (params->offload_11k_bitmask &
21374 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21375 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21376
21377 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21378 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21379 buf_ptr += WMI_TLV_HDR_SIZE;
21380
21381 neighbor_report_offload_params =
21382 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21383 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21384 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21385 WMITLV_GET_STRUCT_TLVLEN(
21386 wmi_neighbor_report_11k_offload_tlv_param));
21387
21388 neighbor_report_offload = &neighbor_report_offload_params->
21389 neighbor_rep_ofld_params;
21390
21391 neighbor_report_offload->time_offset =
21392 params->neighbor_report_params.time_offset;
21393 neighbor_report_offload->low_rssi_offset =
21394 params->neighbor_report_params.low_rssi_offset;
21395 neighbor_report_offload->bmiss_count_trigger =
21396 params->neighbor_report_params.bmiss_count_trigger;
21397 neighbor_report_offload->per_threshold_offset =
21398 params->neighbor_report_params.per_threshold_offset;
21399 neighbor_report_offload->neighbor_report_cache_timeout =
21400 params->neighbor_report_params.
21401 neighbor_report_cache_timeout;
21402 neighbor_report_offload->max_neighbor_report_req_cap =
21403 params->neighbor_report_params.
21404 max_neighbor_report_req_cap;
21405 neighbor_report_offload->ssid.ssid_len =
21406 params->neighbor_report_params.ssid.length;
21407 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21408 &params->neighbor_report_params.ssid.mac_ssid,
21409 neighbor_report_offload->ssid.ssid_len);
21410 }
21411
21412 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21413 WMI_11K_OFFLOAD_REPORT_CMDID);
21414 if (status != QDF_STATUS_SUCCESS) {
21415 WMI_LOGE("%s: failed to send 11k offload command %d",
21416 __func__, status);
21417 wmi_buf_free(buf);
21418 }
21419
21420 return status;
21421}
21422
21423/**
21424 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
21425 * command
21426 * @wmi_handle: wmi handler
21427 * @params: pointer to neighbor report invoke params
21428 *
21429 * Return: 0 for success and non zero for failure
21430 */
21431static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
21432 struct wmi_invoke_neighbor_report_params *params)
21433{
21434 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
21435 wmi_buf_t buf;
21436 QDF_STATUS status;
21437 uint8_t *buf_ptr;
21438 uint32_t len = sizeof(*cmd);
21439
21440 buf = wmi_buf_alloc(wmi_handle, len);
21441 if (!buf) {
21442 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
21443 __func__);
21444 return QDF_STATUS_E_NOMEM;
21445 }
21446
21447 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21448 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
21449
21450 WMITLV_SET_HDR(&cmd->tlv_header,
21451 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
21452 WMITLV_GET_STRUCT_TLVLEN(
21453 wmi_11k_offload_invoke_neighbor_report_fixed_param));
21454
21455 cmd->vdev_id = params->vdev_id;
21456 cmd->flags = params->send_resp_to_host;
21457
21458 cmd->ssid.ssid_len = params->ssid.length;
21459 qdf_mem_copy(cmd->ssid.ssid,
21460 &params->ssid.mac_ssid,
21461 cmd->ssid.ssid_len);
21462
21463 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21464 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
21465 if (status != QDF_STATUS_SUCCESS) {
21466 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
21467 __func__, status);
21468 wmi_buf_free(buf);
21469 }
21470
21471 return status;
21472}
21473
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021474#ifdef WLAN_SUPPORT_GREEN_AP
21475static QDF_STATUS extract_green_ap_egap_status_info_tlv(
21476 uint8_t *evt_buf,
21477 struct wlan_green_ap_egap_status_info *egap_status_info_params)
21478{
21479 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
21480 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
21481 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
21482
21483 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
21484 if (!param_buf) {
21485 WMI_LOGE("Invalid EGAP Info status event buffer");
21486 return QDF_STATUS_E_INVAL;
21487 }
21488
21489 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
21490 param_buf->fixed_param;
21491 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
21492 param_buf->chainmask_list;
21493
21494 egap_status_info_params->status = egap_info_event->status;
21495 egap_status_info_params->mac_id = chainmask_event->mac_id;
21496 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
21497 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
21498
21499 return QDF_STATUS_SUCCESS;
21500}
21501#endif
21502
Arif Hussainec5cd3c2018-01-22 01:19:36 -080021503/*
21504 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
21505 * updating bss color change within firmware when AP announces bss color change.
21506 * @wmi_handle: wmi handle
21507 * @vdev_id: vdev ID
21508 * @enable: enable bss color change within firmware
21509 *
21510 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
21511 *
21512 * Return: QDF_STATUS
21513 */
21514static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
21515 uint32_t vdev_id,
21516 bool enable)
21517{
21518 wmi_buf_t buf;
21519 wmi_bss_color_change_enable_fixed_param *cmd;
21520 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
21521
21522 buf = wmi_buf_alloc(wmi_handle, len);
21523 if (!buf) {
21524 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21525 return QDF_STATUS_E_NOMEM;
21526 }
21527
21528 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
21529 WMITLV_SET_HDR(&cmd->tlv_header,
21530 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
21531 WMITLV_GET_STRUCT_TLVLEN
21532 (wmi_bss_color_change_enable_fixed_param));
21533 cmd->vdev_id = vdev_id;
21534 cmd->enable = enable;
21535 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21536 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
21537 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
21538 wmi_buf_free(buf);
21539 return QDF_STATUS_E_FAILURE;
21540 }
21541
21542 return QDF_STATUS_SUCCESS;
21543}
21544
21545/**
21546 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
21547 * configurations to firmware.
21548 * @wmi_handle: wmi handle
21549 * @cfg_param: obss detection configurations
21550 *
21551 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
21552 *
21553 * Return: QDF_STATUS
21554 */
21555static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
21556 wmi_unified_t wmi_handle,
21557 struct wmi_obss_color_collision_cfg_param *cfg_param)
21558{
21559 wmi_buf_t buf;
21560 wmi_obss_color_collision_det_config_fixed_param *cmd;
21561 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
21562
21563 buf = wmi_buf_alloc(wmi_handle, len);
21564 if (!buf) {
21565 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21566 return QDF_STATUS_E_NOMEM;
21567 }
21568
21569 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
21570 buf);
21571 WMITLV_SET_HDR(&cmd->tlv_header,
21572 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
21573 WMITLV_GET_STRUCT_TLVLEN
21574 (wmi_obss_color_collision_det_config_fixed_param));
21575 cmd->vdev_id = cfg_param->vdev_id;
21576 cmd->flags = cfg_param->flags;
21577 cmd->current_bss_color = cfg_param->current_bss_color;
21578 cmd->detection_period_ms = cfg_param->detection_period_ms;
21579 cmd->scan_period_ms = cfg_param->scan_period_ms;
21580 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
21581
21582 switch (cfg_param->evt_type) {
21583 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
21584 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
21585 break;
21586 case OBSS_COLOR_COLLISION_DETECTION:
21587 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
21588 break;
21589 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21590 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21591 break;
21592 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
21593 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
21594 break;
21595 default:
21596 WMI_LOGE("%s: invalid event type: %d",
21597 __func__, cfg_param->evt_type);
21598 wmi_buf_free(buf);
21599 return QDF_STATUS_E_FAILURE;
21600 }
21601
21602 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21603 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
21604 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
21605 __func__, cfg_param->vdev_id);
21606 wmi_buf_free(buf);
21607 return QDF_STATUS_E_FAILURE;
21608 }
21609
21610 return QDF_STATUS_SUCCESS;
21611}
21612
21613/**
21614 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
21615 * received from firmware.
21616 * @evt_buf: pointer to event buffer
21617 * @info: Pointer to hold bss collision info
21618 *
21619 * Return: QDF_STATUS
21620 */
21621static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
21622 struct wmi_obss_color_collision_info *info)
21623{
21624 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
21625 wmi_obss_color_collision_evt_fixed_param *fix_param;
21626
21627 if (!info) {
21628 WMI_LOGE("%s: Invalid obss color buffer", __func__);
21629 return QDF_STATUS_E_INVAL;
21630 }
21631
21632 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
21633 evt_buf;
21634 if (!param_buf) {
21635 WMI_LOGE("%s: Invalid evt_buf", __func__);
21636 return QDF_STATUS_E_INVAL;
21637 }
21638
21639 fix_param = param_buf->fixed_param;
21640 info->vdev_id = fix_param->vdev_id;
21641 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
21642 info->obss_color_bitmap_bit32to63 =
21643 fix_param->bss_color_bitmap_bit32to63;
21644
21645 switch (fix_param->evt_type) {
21646 case WMI_BSS_COLOR_COLLISION_DISABLE:
21647 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
21648 break;
21649 case WMI_BSS_COLOR_COLLISION_DETECTION:
21650 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
21651 break;
21652 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21653 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21654 break;
21655 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
21656 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
21657 break;
21658 default:
21659 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
21660 __func__, fix_param->evt_type, fix_param->vdev_id);
21661 return QDF_STATUS_E_FAILURE;
21662 }
21663
21664 return QDF_STATUS_SUCCESS;
21665}
21666
Arif Hussaine0eb7302018-03-01 14:40:59 -080021667/*
21668 * extract_comb_phyerr_tlv() - extract comb phy error from event
21669 * @wmi_handle: wmi handle
21670 * @evt_buf: pointer to event buffer
21671 * @datalen: data length of event buffer
21672 * @buf_offset: Pointer to hold value of current event buffer offset
21673 * post extraction
21674 * @phyerr: Pointer to hold phyerr
21675 *
21676 * Return: QDF_STATUS
21677 */
21678static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
21679 void *evt_buf,
21680 uint16_t datalen,
21681 uint16_t *buf_offset,
21682 wmi_host_phyerr_t *phyerr)
21683{
21684 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
21685 wmi_comb_phyerr_rx_hdr *pe_hdr;
21686
21687 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
21688 if (!param_tlvs) {
21689 WMI_LOGD("%s: Received null data from FW", __func__);
21690 return QDF_STATUS_E_FAILURE;
21691 }
21692
21693 pe_hdr = param_tlvs->hdr;
21694 if (!pe_hdr) {
21695 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
21696 return QDF_STATUS_E_FAILURE;
21697 }
21698
21699 /* Ensure it's at least the size of the header */
21700 if (datalen < sizeof(*pe_hdr)) {
21701 WMI_LOGD("%s: Expected minimum size %zu, received %d",
21702 __func__, sizeof(*pe_hdr), datalen);
21703 return QDF_STATUS_E_FAILURE;
21704 }
21705
21706 phyerr->pdev_id = wmi_handle->ops->
21707 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
21708 phyerr->tsf64 = pe_hdr->tsf_l32;
21709 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
21710 phyerr->bufp = param_tlvs->bufp;
21711 phyerr->buf_len = pe_hdr->buf_len;
21712 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
21713 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
21714 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
21715
21716 return QDF_STATUS_SUCCESS;
21717}
21718
21719/**
21720 * extract_single_phyerr_tlv() - extract single phy error from event
21721 * @wmi_handle: wmi handle
21722 * @evt_buf: pointer to event buffer
21723 * @datalen: data length of event buffer
21724 * @buf_offset: Pointer to hold value of current event buffer offset
21725 * post extraction
21726 * @phyerr: Pointer to hold phyerr
21727 *
21728 * Return: QDF_STATUS
21729 */
21730static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
21731 void *evt_buf,
21732 uint16_t datalen,
21733 uint16_t *buf_offset,
21734 wmi_host_phyerr_t *phyerr)
21735{
21736 wmi_single_phyerr_rx_event *ev;
21737 uint16_t n = *buf_offset;
21738 uint8_t *data = (uint8_t *)evt_buf;
21739
21740 if (n < datalen) {
21741 if ((datalen - n) < sizeof(ev->hdr)) {
21742 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
21743 __func__, datalen, n, sizeof(ev->hdr));
21744 return QDF_STATUS_E_FAILURE;
21745 }
21746
21747 /*
21748 * Obtain a pointer to the beginning of the current event.
21749 * data[0] is the beginning of the WMI payload.
21750 */
21751 ev = (wmi_single_phyerr_rx_event *)&data[n];
21752
21753 /*
21754 * Sanity check the buffer length of the event against
21755 * what we currently have.
21756 *
21757 * Since buf_len is 32 bits, we check if it overflows
21758 * a large 32 bit value. It's not 0x7fffffff because
21759 * we increase n by (buf_len + sizeof(hdr)), which would
21760 * in itself cause n to overflow.
21761 *
21762 * If "int" is 64 bits then this becomes a moot point.
21763 */
21764 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
21765 WMI_LOGD("%s: buf_len is garbage 0x%x",
21766 __func__, ev->hdr.buf_len);
21767 return QDF_STATUS_E_FAILURE;
21768 }
21769
21770 if ((n + ev->hdr.buf_len) > datalen) {
21771 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
21772 __func__, n, ev->hdr.buf_len, datalen);
21773 return QDF_STATUS_E_FAILURE;
21774 }
21775
21776 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
21777 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
21778 phyerr->bufp = &ev->bufp[0];
21779 phyerr->buf_len = ev->hdr.buf_len;
21780 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
21781
21782 /*
21783 * Advance the buffer pointer to the next PHY error.
21784 * buflen is the length of this payload, so we need to
21785 * advance past the current header _AND_ the payload.
21786 */
21787 n += sizeof(*ev) + ev->hdr.buf_len;
21788 }
21789 *buf_offset = n;
21790
21791 return QDF_STATUS_SUCCESS;
21792}
21793
Govind Singh5eb51532016-03-09 11:34:12 +053021794struct wmi_ops tlv_ops = {
21795 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
21796 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
21797 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053021798 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
21799 .send_hidden_ssid_vdev_restart_cmd =
21800 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021801 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
21802 .send_peer_param_cmd = send_peer_param_cmd_tlv,
21803 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021804 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021805 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021806 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070021807 .send_peer_rx_reorder_queue_setup_cmd =
21808 send_peer_rx_reorder_queue_setup_cmd_tlv,
21809 .send_peer_rx_reorder_queue_remove_cmd =
21810 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053021811 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
21812 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
21813 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021814 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
21815 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080021816 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021817 .send_suspend_cmd = send_suspend_cmd_tlv,
21818 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080021819#ifdef FEATURE_WLAN_D0WOW
21820 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
21821 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
21822#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021823 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
21824 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
21825 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
21826 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021827#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053021828 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021829#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021830 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
21831 .send_stats_request_cmd = send_stats_request_cmd_tlv,
21832 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053021833 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070021834 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021835 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021836 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021837 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
21838 .send_scan_start_cmd = send_scan_start_cmd_tlv,
21839 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
21840 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021841 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021842 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021843 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
21844 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021845 .send_set_sta_uapsd_auto_trig_cmd =
21846 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021847 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
21848 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
21849 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080021850#ifdef CONVERGED_P2P_ENABLE
21851 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
21852 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
21853#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053021854 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
21855 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021856#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053021857 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
21858 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
21859 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
21860 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
21861 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
21862 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
21863 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021864 .send_ocb_start_timing_advert_cmd =
21865 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021866 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
21867 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
21868 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
21869 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
21870#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053021871 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
21872 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
21873 .send_set_mcc_channel_time_latency_cmd =
21874 send_set_mcc_channel_time_latency_cmd_tlv,
21875 .send_set_mcc_channel_time_quota_cmd =
21876 send_set_mcc_channel_time_quota_cmd_tlv,
21877 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
21878 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053021879 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021880 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
21881 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
21882 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021883 .send_probe_rsp_tmpl_send_cmd =
21884 send_probe_rsp_tmpl_send_cmd_tlv,
21885 .send_p2p_go_set_beacon_ie_cmd =
21886 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053021887 .send_setup_install_key_cmd =
21888 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021889 .send_set_gateway_params_cmd =
21890 send_set_gateway_params_cmd_tlv,
21891 .send_set_rssi_monitoring_cmd =
21892 send_set_rssi_monitoring_cmd_tlv,
21893 .send_scan_probe_setoui_cmd =
21894 send_scan_probe_setoui_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021895 .send_roam_scan_offload_rssi_thresh_cmd =
21896 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070021897 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021898 .send_roam_scan_filter_cmd =
21899 send_roam_scan_filter_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053021900#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053021901 .send_ipa_offload_control_cmd =
21902 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053021903#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053021904 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
21905 .send_plm_start_cmd = send_plm_start_cmd_tlv,
21906 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
21907 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070021908 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021909 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080021910#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053021911 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
21912 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
21913 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080021914#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053021915 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021916 .send_snr_request_cmd = send_snr_request_cmd_tlv,
21917 .send_snr_cmd = send_snr_cmd_tlv,
21918 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080021919#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021920 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
21921 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
21922 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
21923 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053021924 .send_multiple_add_clear_mcbc_filter_cmd =
21925 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070021926 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021927 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
21928 .send_process_gtk_offload_getinfo_cmd =
21929 send_process_gtk_offload_getinfo_cmd_tlv,
21930 .send_enable_enhance_multicast_offload_cmd =
21931 send_enable_enhance_multicast_offload_tlv,
21932 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
21933#ifdef FEATURE_WLAN_RA_FILTERING
21934 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
21935#endif
21936 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021937 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
21938 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021939 .send_lphb_config_tcp_pkt_filter_cmd =
21940 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021941 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
21942 .send_lphb_config_udp_pkt_filter_cmd =
21943 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053021944 .send_enable_disable_packet_filter_cmd =
21945 send_enable_disable_packet_filter_cmd_tlv,
21946 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080021947#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021948#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053021949 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
21950 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021951 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021952 .send_roam_scan_offload_mode_cmd =
21953 send_roam_scan_offload_mode_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053021954#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053021955 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053021956#endif
Govind Singh87542482016-06-08 19:40:11 +053021957 .send_roam_scan_offload_ap_profile_cmd =
21958 send_roam_scan_offload_ap_profile_cmd_tlv,
21959#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053021960#ifdef WLAN_SUPPORT_GREEN_AP
21961 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
21962 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021963 .extract_green_ap_egap_status_info =
21964 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053021965#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053021966 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
21967 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021968 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080021969 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021970 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070021971#ifdef WLAN_FEATURE_CIF_CFR
21972 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
21973#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053021974 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021975 .send_dfs_phyerr_filter_offload_en_cmd =
21976 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021977 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
21978 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
21979 .send_del_ts_cmd = send_del_ts_cmd_tlv,
21980 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
21981 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021982 .send_process_add_periodic_tx_ptrn_cmd =
21983 send_process_add_periodic_tx_ptrn_cmd_tlv,
21984 .send_process_del_periodic_tx_ptrn_cmd =
21985 send_process_del_periodic_tx_ptrn_cmd_tlv,
21986 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
21987 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
21988 .send_set_app_type2_params_in_fw_cmd =
21989 send_set_app_type2_params_in_fw_cmd_tlv,
21990 .send_set_auto_shutdown_timer_cmd =
21991 send_set_auto_shutdown_timer_cmd_tlv,
21992 .send_nan_req_cmd = send_nan_req_cmd_tlv,
21993 .send_process_dhcpserver_offload_cmd =
21994 send_process_dhcpserver_offload_cmd_tlv,
21995 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
21996 .send_process_ch_avoid_update_cmd =
21997 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053021998 .send_pdev_set_regdomain_cmd =
21999 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022000 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22001 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22002 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22003 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022004 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022005 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022006 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022007 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022008 .send_set_base_macaddr_indicate_cmd =
22009 send_set_base_macaddr_indicate_cmd_tlv,
22010 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22011 .send_enable_specific_fw_logs_cmd =
22012 send_enable_specific_fw_logs_cmd_tlv,
22013 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022014 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022015 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022016#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022017 .send_pdev_set_dual_mac_config_cmd =
22018 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022019#endif
Govind Singha4836fd2016-03-07 16:45:38 +053022020 .send_app_type1_params_in_fw_cmd =
22021 send_app_type1_params_in_fw_cmd_tlv,
22022 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22023 .send_process_roam_synch_complete_cmd =
22024 send_process_roam_synch_complete_cmd_tlv,
22025 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22026 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22027 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022028 .send_roam_scan_offload_scan_period_cmd =
22029 send_roam_scan_offload_scan_period_cmd_tlv,
22030 .send_roam_scan_offload_chan_list_cmd =
22031 send_roam_scan_offload_chan_list_cmd_tlv,
22032 .send_roam_scan_offload_rssi_change_cmd =
22033 send_roam_scan_offload_rssi_change_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022034#ifdef FEATURE_WLAN_APF
22035 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
22036 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
22037 .send_apf_write_work_memory_cmd =
22038 wmi_send_apf_write_work_memory_cmd_tlv,
22039 .send_apf_read_work_memory_cmd =
22040 wmi_send_apf_read_work_memory_cmd_tlv,
22041 .extract_apf_read_memory_resp_event =
22042 wmi_extract_apf_read_memory_resp_event_tlv,
22043#endif /* FEATURE_WLAN_APF */
Gupta, Kapil2e685982016-04-25 19:14:19 +053022044 .send_adapt_dwelltime_params_cmd =
22045 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022046 .send_dbs_scan_sel_params_cmd =
22047 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022048 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022049 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22050 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22051 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22052 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22053 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22054 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022055 .send_vdev_set_custom_aggr_size_cmd =
22056 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022057 .send_vdev_set_qdepth_thresh_cmd =
22058 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022059 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22060 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22061 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022062 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22063 .send_smart_ant_set_training_info_cmd =
22064 send_smart_ant_set_training_info_cmd_tlv,
22065 .send_smart_ant_set_node_config_cmd =
22066 send_smart_ant_set_node_config_cmd_tlv,
22067 .send_set_atf_cmd = send_set_atf_cmd_tlv,
22068 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22069 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022070 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22071 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22072 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22073 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022074 .send_periodic_chan_stats_config_cmd =
22075 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022076 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22077 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22078 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022079 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22080 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22081 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22082 .send_vdev_spectral_configure_cmd =
22083 send_vdev_spectral_configure_cmd_tlv,
22084 .send_vdev_spectral_enable_cmd =
22085 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022086 .send_thermal_mitigation_param_cmd =
22087 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022088 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22089 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022090 .send_process_update_edca_param_cmd =
22091 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022092 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022093 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022094 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022095 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22096 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022097 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022098 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22099 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22100 .extract_host_mem_req = extract_host_mem_req_tlv,
22101 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022102 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022103 .is_service_enabled = is_service_enabled_tlv,
22104 .save_fw_version = save_fw_version_in_service_ready_tlv,
22105 .ready_extract_init_status = ready_extract_init_status_tlv,
22106 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022107 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022108 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022109 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22110 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022111 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022112 .extract_tbttoffset_update_params =
22113 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022114 .extract_ext_tbttoffset_update_params =
22115 extract_ext_tbttoffset_update_params_tlv,
22116 .extract_tbttoffset_num_vdevs =
22117 extract_tbttoffset_num_vdevs_tlv,
22118 .extract_ext_tbttoffset_num_vdevs =
22119 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022120 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22121 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22122 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22123 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022124#ifdef CONVERGED_TDLS_ENABLE
22125 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22126#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022127 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022128 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022129 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22130 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022131#ifdef CONVERGED_P2P_ENABLE
22132 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22133 .extract_p2p_lo_stop_ev_param =
22134 extract_p2p_lo_stop_ev_param_tlv,
22135#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022136 .extract_offchan_data_tx_compl_param =
22137 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022138 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22139 .extract_all_stats_count = extract_all_stats_counts_tlv,
22140 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022141 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022142 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22143 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070022144 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022145 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022146 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022147 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22148 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22149 .extract_chan_stats = extract_chan_stats_tlv,
22150 .extract_profile_ctx = extract_profile_ctx_tlv,
22151 .extract_profile_data = extract_profile_data_tlv,
22152 .extract_chan_info_event = extract_chan_info_event_tlv,
22153 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022154 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022155#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022156 .send_encrypt_decrypt_send_cmd =
22157 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022158 .extract_encrypt_decrypt_resp_event =
22159 extract_encrypt_decrypt_resp_event_tlv,
22160#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022161 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022162 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22163 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022164 .extract_sar2_result_event = extract_sar2_result_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022165 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022166 .send_multiple_vdev_restart_req_cmd =
22167 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022168 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22169 .extract_hw_mode_cap_service_ready_ext =
22170 extract_hw_mode_cap_service_ready_ext_tlv,
22171 .extract_mac_phy_cap_service_ready_ext =
22172 extract_mac_phy_cap_service_ready_ext_tlv,
22173 .extract_reg_cap_service_ready_ext =
22174 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022175 .extract_dbr_ring_cap_service_ready_ext =
22176 extract_dbr_ring_cap_service_ready_ext_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022177 .extract_sar_cap_service_ready_ext =
22178 extract_sar_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022179 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22180 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022181 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022182 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022183 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022184 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22185 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22186 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022187 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022188 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022189 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022190 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022191 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022192 .extract_pdev_csa_switch_count_status =
22193 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022194 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022195 .extract_pdev_tpc_config_ev_param =
22196 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022197 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022198 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22199 .extract_peer_sta_ps_statechange_ev =
22200 extract_peer_sta_ps_statechange_ev_tlv,
22201 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022202 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080022203 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22204 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022205 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022206 extract_reg_chan_list_update_event_tlv,
22207 .extract_chainmask_tables =
22208 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022209 .extract_thermal_stats = extract_thermal_stats_tlv,
22210 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022211 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22212 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022213#ifdef DFS_COMPONENT_ENABLE
22214 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22215 .extract_dfs_radar_detection_event =
22216 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022217 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022218#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022219 .convert_pdev_id_host_to_target =
22220 convert_host_pdev_id_to_target_pdev_id_legacy,
22221 .convert_pdev_id_target_to_host =
22222 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022223
22224 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22225 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22226 .extract_reg_11d_new_country_event =
22227 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022228 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022229 .send_limit_off_chan_cmd =
22230 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022231 .extract_reg_ch_avoid_event =
22232 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022233 .send_pdev_caldata_version_check_cmd =
22234 send_pdev_caldata_version_check_cmd_tlv,
22235 .extract_pdev_caldata_version_check_ev_param =
22236 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022237 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22238 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022239 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22240#if defined(WLAN_FEATURE_FILS_SK)
22241 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22242#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022243 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022244#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22245 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22246 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22247 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22248 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22249 .extract_ndp_ind = extract_ndp_ind_tlv,
22250 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22251 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22252 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22253 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
Naveen Rawatd42ce382018-01-09 17:54:41 -080022254 .extract_ndp_sch_update = extract_ndp_sch_update_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022255#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022256 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022257 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022258 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022259#ifdef WLAN_SUPPORT_FILS
22260 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22261 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22262 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22263#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022264 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22265 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022266 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22267 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22268 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22269 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022270 .send_bss_color_change_enable_cmd =
22271 send_bss_color_change_enable_cmd_tlv,
22272 .send_obss_color_collision_cfg_cmd =
22273 send_obss_color_collision_cfg_cmd_tlv,
22274 .extract_obss_color_collision_info =
22275 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022276 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22277 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070022278#ifdef QCA_SUPPORT_CP_STATS
22279 .extract_cca_stats = extract_cca_stats_tlv,
22280#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022281};
22282
Govind Singhe7f2f342016-05-23 12:12:52 +053022283/**
22284 * populate_tlv_event_id() - populates wmi event ids
22285 *
22286 * @param event_ids: Pointer to hold event ids
22287 * Return: None
22288 */
22289static void populate_tlv_events_id(uint32_t *event_ids)
22290{
22291 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22292 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22293 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22294 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22295 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22296 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22297 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22298 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22299 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22300 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22301 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22302 event_ids[wmi_service_ready_ext_event_id] =
22303 WMI_SERVICE_READY_EXT_EVENTID;
22304 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22305 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22306 event_ids[wmi_vdev_install_key_complete_event_id] =
22307 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22308 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22309 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22310
22311 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22312 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22313 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22314 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22315 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22316 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22317 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22318 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022319 event_ids[wmi_peer_delete_response_event_id] =
22320 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022321 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22322 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22323 event_ids[wmi_tbttoffset_update_event_id] =
22324 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022325 event_ids[wmi_ext_tbttoffset_update_event_id] =
22326 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022327 event_ids[wmi_offload_bcn_tx_status_event_id] =
22328 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22329 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22330 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22331 event_ids[wmi_mgmt_tx_completion_event_id] =
22332 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022333 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22334 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022335 event_ids[wmi_tx_delba_complete_event_id] =
22336 WMI_TX_DELBA_COMPLETE_EVENTID;
22337 event_ids[wmi_tx_addba_complete_event_id] =
22338 WMI_TX_ADDBA_COMPLETE_EVENTID;
22339 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22340
22341 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22342
22343 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22344 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22345
22346 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022347 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022348
22349 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22350
22351 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022352 event_ids[wmi_p2p_lo_stop_event_id] =
22353 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022354 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22355 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022356 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022357 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22358 event_ids[wmi_wow_initial_wakeup_event_id] =
22359 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22360
22361 event_ids[wmi_rtt_meas_report_event_id] =
22362 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22363 event_ids[wmi_tsf_meas_report_event_id] =
22364 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22365 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22366 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22367 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22368 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22369 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022370 event_ids[wmi_diag_event_id_log_supported_event_id] =
22371 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22372 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22373 event_ids[wmi_nlo_scan_complete_event_id] =
22374 WMI_NLO_SCAN_COMPLETE_EVENTID;
22375 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22376 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22377
22378 event_ids[wmi_gtk_offload_status_event_id] =
22379 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22380 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22381 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22382 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22383
22384 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22385
22386 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22387
22388 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22389 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22390 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22391 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22392 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22393 event_ids[wmi_wlan_profile_data_event_id] =
22394 WMI_WLAN_PROFILE_DATA_EVENTID;
22395 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22396 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22397 event_ids[wmi_vdev_get_keepalive_event_id] =
22398 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22399 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22400
22401 event_ids[wmi_diag_container_event_id] =
22402 WMI_DIAG_DATA_CONTAINER_EVENTID;
22403
22404 event_ids[wmi_host_auto_shutdown_event_id] =
22405 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22406
22407 event_ids[wmi_update_whal_mib_stats_event_id] =
22408 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22409
22410 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22411 event_ids[wmi_update_vdev_rate_stats_event_id] =
22412 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22413
22414 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022415 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022416
22417 /** Set OCB Sched Response, deprecated */
22418 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
22419
22420 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
22421 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
22422 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
22423
22424 /* GPIO Event */
22425 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
22426 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
22427
22428 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
22429 event_ids[wmi_rfkill_state_change_event_id] =
22430 WMI_RFKILL_STATE_CHANGE_EVENTID;
22431
22432 /* TDLS Event */
22433 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
22434
22435 event_ids[wmi_batch_scan_enabled_event_id] =
22436 WMI_BATCH_SCAN_ENABLED_EVENTID;
22437 event_ids[wmi_batch_scan_result_event_id] =
22438 WMI_BATCH_SCAN_RESULT_EVENTID;
22439 /* OEM Event */
22440 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
22441 event_ids[wmi_oem_meas_report_event_id] =
22442 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
22443 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
22444
22445 /* NAN Event */
22446 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
22447
22448 /* LPI Event */
22449 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
22450 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
22451 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
22452
22453 /* ExtScan events */
22454 event_ids[wmi_extscan_start_stop_event_id] =
22455 WMI_EXTSCAN_START_STOP_EVENTID;
22456 event_ids[wmi_extscan_operation_event_id] =
22457 WMI_EXTSCAN_OPERATION_EVENTID;
22458 event_ids[wmi_extscan_table_usage_event_id] =
22459 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
22460 event_ids[wmi_extscan_cached_results_event_id] =
22461 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
22462 event_ids[wmi_extscan_wlan_change_results_event_id] =
22463 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
22464 event_ids[wmi_extscan_hotlist_match_event_id] =
22465 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
22466 event_ids[wmi_extscan_capabilities_event_id] =
22467 WMI_EXTSCAN_CAPABILITIES_EVENTID;
22468 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
22469 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
22470
22471 /* mDNS offload events */
22472 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
22473
22474 /* SAP Authentication offload events */
22475 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
22476 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
22477
22478 /** Out-of-context-of-bss (OCB) events */
22479 event_ids[wmi_ocb_set_config_resp_event_id] =
22480 WMI_OCB_SET_CONFIG_RESP_EVENTID;
22481 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
22482 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
22483 event_ids[wmi_dcc_get_stats_resp_event_id] =
22484 WMI_DCC_GET_STATS_RESP_EVENTID;
22485 event_ids[wmi_dcc_update_ndl_resp_event_id] =
22486 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
22487 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
22488 /* System-On-Chip events */
22489 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
22490 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
22491 event_ids[wmi_soc_hw_mode_transition_event_id] =
22492 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
22493 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
22494 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022495 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053022496 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
22497 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022498 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053022499 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
22500 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22501 event_ids[wmi_peer_sta_ps_statechg_event_id] =
22502 WMI_PEER_STA_PS_STATECHG_EVENTID;
22503 event_ids[wmi_pdev_channel_hopping_event_id] =
22504 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022505 event_ids[wmi_offchan_data_tx_completion_event] =
22506 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022507 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
22508 event_ids[wmi_dfs_radar_detection_event_id] =
22509 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022510 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070022511 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053022512 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053022513 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022514 event_ids[wmi_service_available_event_id] =
22515 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022516 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022517 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022518 /* NDP events */
22519 event_ids[wmi_ndp_initiator_rsp_event_id] =
22520 WMI_NDP_INITIATOR_RSP_EVENTID;
22521 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
22522 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
22523 event_ids[wmi_ndp_responder_rsp_event_id] =
22524 WMI_NDP_RESPONDER_RSP_EVENTID;
22525 event_ids[wmi_ndp_end_indication_event_id] =
22526 WMI_NDP_END_INDICATION_EVENTID;
22527 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080022528 event_ids[wmi_ndl_schedule_update_event_id] =
22529 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022530
22531 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
22532 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
22533 event_ids[wmi_pdev_chip_power_stats_event_id] =
22534 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
22535 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
22536 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
22537 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022538 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022539 WMI_BPF_CAPABILIY_INFO_EVENTID;
22540 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
22541 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
22542 event_ids[wmi_report_rx_aggr_failure_event_id] =
22543 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
22544 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
22545 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
22546 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
22547 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
22548 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
22549 event_ids[wmi_pdev_hw_mode_transition_event_id] =
22550 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
22551 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
22552 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
22553 event_ids[wmi_coex_bt_activity_event_id] =
22554 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
22555 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
22556 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
22557 event_ids[wmi_radio_tx_power_level_stats_event_id] =
22558 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
22559 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053022560 event_ids[wmi_dma_buf_release_event_id] =
22561 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022562 event_ids[wmi_sap_obss_detection_report_event_id] =
22563 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022564 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080022565 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022566 event_ids[wmi_obss_color_collision_report_event_id] =
22567 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080022568 event_ids[wmi_pdev_div_rssi_antid_event_id] =
22569 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070022570 event_ids[wmi_twt_enable_complete_event_id] =
22571 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022572 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
22573 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022574 event_ids[wmi_wlan_sar2_result_event_id] = WMI_SAR2_RESULT_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022575}
22576
Soumya Bhat488092d2017-03-22 14:41:01 +053022577/**
22578 * populate_tlv_service() - populates wmi services
22579 *
22580 * @param wmi_service: Pointer to hold wmi_service
22581 * Return: None
22582 */
22583static void populate_tlv_service(uint32_t *wmi_service)
22584{
22585 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022586 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022587 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
22588 wmi_service[wmi_service_roam_scan_offload] =
22589 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
22590 wmi_service[wmi_service_bcn_miss_offload] =
22591 WMI_SERVICE_BCN_MISS_OFFLOAD;
22592 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
22593 wmi_service[wmi_service_sta_advanced_pwrsave] =
22594 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
22595 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
22596 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
22597 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
22598 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
22599 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
22600 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
22601 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
22602 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
22603 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
22604 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
22605 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
22606 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
22607 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
22608 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
22609 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
22610 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
22611 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
22612 wmi_service[wmi_service_packet_power_save] =
22613 WMI_SERVICE_PACKET_POWER_SAVE;
22614 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
22615 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
22616 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
22617 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
22618 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
22619 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
22620 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
22621 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
22622 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
22623 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
22624 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
22625 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
22626 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
22627 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
22628 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
22629 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
22630 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
22631 wmi_service[wmi_service_mcc_bcn_interval_change] =
22632 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
22633 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
22634 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
22635 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
22636 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
22637 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
22638 wmi_service[wmi_service_lte_ant_share_support] =
22639 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
22640 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
22641 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
22642 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
22643 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
22644 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
22645 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
22646 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
22647 wmi_service[wmi_service_bcn_txrate_override] =
22648 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
22649 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
22650 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
22651 wmi_service[wmi_service_estimate_linkspeed] =
22652 WMI_SERVICE_ESTIMATE_LINKSPEED;
22653 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
22654 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
22655 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
22656 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
22657 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
22658 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
22659 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
22660 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
22661 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
22662 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
22663 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
22664 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
22665 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
22666 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
22667 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
22668 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
22669 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
22670 wmi_service[wmi_service_sap_auth_offload] =
22671 WMI_SERVICE_SAP_AUTH_OFFLOAD;
22672 wmi_service[wmi_service_dual_band_simultaneous_support] =
22673 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
22674 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
22675 wmi_service[wmi_service_ap_arpns_offload] =
22676 WMI_SERVICE_AP_ARPNS_OFFLOAD;
22677 wmi_service[wmi_service_per_band_chainmask_support] =
22678 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
22679 wmi_service[wmi_service_packet_filter_offload] =
22680 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
22681 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
22682 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
22683 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
22684 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
22685 wmi_service[wmi_service_multiple_vdev_restart] =
22686 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
22687
22688 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
22689 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
22690 wmi_service[wmi_service_smart_antenna_sw_support] =
22691 WMI_SERVICE_UNAVAILABLE;
22692 wmi_service[wmi_service_smart_antenna_hw_support] =
22693 WMI_SERVICE_UNAVAILABLE;
22694 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053022695 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022696 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053022697 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
22698 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
22699 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
22700 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
22701 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
22702 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
22703 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
22704 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053022705 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
22706 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
22707 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022708 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022709 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
22710 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
22711 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
22712 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
22713 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
22714 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022715 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
22716 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
22717 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
22718 wmi_service[wmi_service_unified_wow_capability] =
22719 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
22720 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022721 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022722 wmi_service[wmi_service_sync_delete_cmds] =
22723 WMI_SERVICE_SYNC_DELETE_CMDS;
22724 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
22725 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
22726 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
22727 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
22728 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
22729 wmi_service[wmi_service_deprecated_replace] =
22730 WMI_SERVICE_DEPRECATED_REPLACE;
22731 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
22732 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
22733 wmi_service[wmi_service_enhanced_mcast_filter] =
22734 WMI_SERVICE_ENHANCED_MCAST_FILTER;
22735 wmi_service[wmi_service_half_rate_quarter_rate_support] =
22736 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
22737 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
22738 wmi_service[wmi_service_p2p_listen_offload_support] =
22739 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
22740 wmi_service[wmi_service_mark_first_wakeup_packet] =
22741 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
22742 wmi_service[wmi_service_multiple_mcast_filter_set] =
22743 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
22744 wmi_service[wmi_service_host_managed_rx_reorder] =
22745 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
22746 wmi_service[wmi_service_flash_rdwr_support] =
22747 WMI_SERVICE_FLASH_RDWR_SUPPORT;
22748 wmi_service[wmi_service_wlan_stats_report] =
22749 WMI_SERVICE_WLAN_STATS_REPORT;
22750 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
22751 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
22752 wmi_service[wmi_service_dfs_phyerr_offload] =
22753 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
22754 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
22755 wmi_service[wmi_service_fw_mem_dump_support] =
22756 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
22757 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
22758 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
22759 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
22760 wmi_service[wmi_service_hw_data_filtering] =
22761 WMI_SERVICE_HW_DATA_FILTERING;
22762 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
22763 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053022764 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053022765 wmi_service[wmi_service_extended_nss_support] =
22766 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053022767 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022768 wmi_service[wmi_service_bcn_offload_start_stop_support] =
22769 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053022770 wmi_service[wmi_service_offchan_data_tid_support] =
22771 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053022772 wmi_service[wmi_service_support_dma] =
22773 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022774 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
22775 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
22776 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080022777 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
22778 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053022779 wmi_service[wmi_service_11k_neighbour_report_support] =
22780 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080022781 wmi_service[wmi_service_ap_obss_detection_offload] =
22782 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
22783 wmi_service[wmi_service_bss_color_offload] =
22784 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053022785 wmi_service[wmi_service_gmac_offload_support] =
22786 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080022787 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
22788 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
22789 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
22790 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070022791 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
22792 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053022793 wmi_service[wmi_service_listen_interval_offload_support] =
22794 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022795
Soumya Bhat488092d2017-03-22 14:41:01 +053022796}
22797
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022798#ifndef CONFIG_MCL
22799
Govind Singhe7f2f342016-05-23 12:12:52 +053022800/**
22801 * populate_pdev_param_tlv() - populates pdev params
22802 *
22803 * @param pdev_param: Pointer to hold pdev params
22804 * Return: None
22805 */
22806static void populate_pdev_param_tlv(uint32_t *pdev_param)
22807{
22808 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
22809 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
22810 pdev_param[wmi_pdev_param_txpower_limit2g] =
22811 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
22812 pdev_param[wmi_pdev_param_txpower_limit5g] =
22813 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
22814 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
22815 pdev_param[wmi_pdev_param_beacon_gen_mode] =
22816 WMI_PDEV_PARAM_BEACON_GEN_MODE;
22817 pdev_param[wmi_pdev_param_beacon_tx_mode] =
22818 WMI_PDEV_PARAM_BEACON_TX_MODE;
22819 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
22820 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
22821 pdev_param[wmi_pdev_param_protection_mode] =
22822 WMI_PDEV_PARAM_PROTECTION_MODE;
22823 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
22824 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
22825 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
22826 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
22827 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
22828 pdev_param[wmi_pdev_param_sta_kickout_th] =
22829 WMI_PDEV_PARAM_STA_KICKOUT_TH;
22830 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
22831 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
22832 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
22833 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
22834 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
22835 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
22836 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
22837 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
22838 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
22839 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
22840 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
22841 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
22842 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
22843 pdev_param[wmi_pdev_param_ltr_sleep_override] =
22844 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
22845 pdev_param[wmi_pdev_param_ltr_rx_override] =
22846 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
22847 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
22848 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
22849 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
22850 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
22851 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
22852 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
22853 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
22854 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
22855 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
22856 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
22857 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
22858 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
22859 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
22860 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
22861 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
22862 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
22863 pdev_param[wmi_pdev_param_peer_stats_update_period] =
22864 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
22865 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
22866 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
22867 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
22868 pdev_param[wmi_pdev_param_arp_ac_override] =
22869 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
22870 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
22871 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
22872 pdev_param[wmi_pdev_param_ani_poll_period] =
22873 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
22874 pdev_param[wmi_pdev_param_ani_listen_period] =
22875 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
22876 pdev_param[wmi_pdev_param_ani_ofdm_level] =
22877 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
22878 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
22879 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
22880 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
22881 pdev_param[wmi_pdev_param_idle_ps_config] =
22882 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
22883 pdev_param[wmi_pdev_param_power_gating_sleep] =
22884 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
22885 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
22886 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
22887 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
22888 pdev_param[wmi_pdev_param_hw_rfkill_config] =
22889 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
22890 pdev_param[wmi_pdev_param_low_power_rf_enable] =
22891 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
22892 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
22893 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
22894 pdev_param[wmi_pdev_param_power_collapse_enable] =
22895 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
22896 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
22897 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
22898 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
22899 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
22900 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
22901 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
22902 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
22903 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
22904 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
22905 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
22906 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
22907 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
22908 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
22909 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
22910 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
22911 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
22912 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
22913 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
22914 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
22915 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
22916 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
22917 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
22918 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
22919 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
22920 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
22921 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
22922 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
22923 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
22924 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
22925 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
22926 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
22927 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
22928 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
22929 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
22930 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
22931 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
22932 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
22933 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
22934 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
22935 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
22936 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
22937 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
22938 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
22939 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022940 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
22941 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
22942 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053022943 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
22944 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022945 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053022946 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022947 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
22948 pdev_param[wmi_pdev_param_proxy_sta_mode] =
22949 WMI_PDEV_PARAM_PROXY_STA_MODE;
22950 pdev_param[wmi_pdev_param_mu_group_policy] =
22951 WMI_PDEV_PARAM_MU_GROUP_POLICY;
22952 pdev_param[wmi_pdev_param_noise_detection] =
22953 WMI_PDEV_PARAM_NOISE_DETECTION;
22954 pdev_param[wmi_pdev_param_noise_threshold] =
22955 WMI_PDEV_PARAM_NOISE_THRESHOLD;
22956 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
22957 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
22958 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022959 pdev_param[wmi_pdev_param_atf_strict_sch] =
22960 WMI_PDEV_PARAM_ATF_STRICT_SCH;
22961 pdev_param[wmi_pdev_param_atf_sched_duration] =
22962 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022963 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
22964 pdev_param[wmi_pdev_param_sensitivity_level] =
22965 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
22966 pdev_param[wmi_pdev_param_signed_txpower_2g] =
22967 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
22968 pdev_param[wmi_pdev_param_signed_txpower_5g] =
22969 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070022970 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
22971 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
22972 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
22973 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022974 pdev_param[wmi_pdev_param_cca_threshold] =
22975 WMI_PDEV_PARAM_CCA_THRESHOLD;
22976 pdev_param[wmi_pdev_param_rts_fixed_rate] =
22977 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053022978 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022979 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
22980 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
22981 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
22982 pdev_param[wmi_pdev_param_arp_srcaddr] =
22983 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
22984 pdev_param[wmi_pdev_param_arp_dstaddr] =
22985 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
22986 pdev_param[wmi_pdev_param_txpower_decr_db] =
22987 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053022988 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
22989 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022990 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
22991 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053022992 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022993 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022994 pdev_param[wmi_pdev_param_cust_txpower_scale] =
22995 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022996 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
22997 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053022998 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
22999 WMI_UNAVAILABLE_PARAM;
Sathish Kumar210b4062018-07-03 17:25:11 +053023000 pdev_param[wmi_pdev_param_igmpmld_override] =
23001 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23002 pdev_param[wmi_pdev_param_igmpmld_tid] =
23003 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023004 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23005 pdev_param[wmi_pdev_param_block_interbss] =
23006 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023007 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023008 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23009 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23010 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023011 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023012 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023013 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23014 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023015 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023016 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23017 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023018 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23019 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23020 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23021 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
Sathish Kumara059f412017-03-22 19:10:28 +053023022 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23023 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23024 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23025 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23026 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23027 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23028 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23029 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23030 pdev_param[wmi_pdev_param_fast_channel_reset] =
23031 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23032 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023033 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023034 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023035}
23036
23037/**
23038 * populate_vdev_param_tlv() - populates vdev params
23039 *
23040 * @param vdev_param: Pointer to hold vdev params
23041 * Return: None
23042 */
23043static void populate_vdev_param_tlv(uint32_t *vdev_param)
23044{
23045 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23046 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23047 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23048 vdev_param[wmi_vdev_param_beacon_interval] =
23049 WMI_VDEV_PARAM_BEACON_INTERVAL;
23050 vdev_param[wmi_vdev_param_listen_interval] =
23051 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23052 vdev_param[wmi_vdev_param_multicast_rate] =
23053 WMI_VDEV_PARAM_MULTICAST_RATE;
23054 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23055 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23056 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23057 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23058 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23059 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23060 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23061 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23062 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23063 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23064 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23065 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23066 vdev_param[wmi_vdev_param_bmiss_count_max] =
23067 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23068 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23069 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23070 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23071 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23072 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23073 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23074 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23075 vdev_param[wmi_vdev_param_disable_htprotection] =
23076 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23077 vdev_param[wmi_vdev_param_sta_quickkickout] =
23078 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23079 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23080 vdev_param[wmi_vdev_param_protection_mode] =
23081 WMI_VDEV_PARAM_PROTECTION_MODE;
23082 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23083 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23084 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23085 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23086 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23087 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23088 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23089 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23090 vdev_param[wmi_vdev_param_bcast_data_rate] =
23091 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23092 vdev_param[wmi_vdev_param_mcast_data_rate] =
23093 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23094 vdev_param[wmi_vdev_param_mcast_indicate] =
23095 WMI_VDEV_PARAM_MCAST_INDICATE;
23096 vdev_param[wmi_vdev_param_dhcp_indicate] =
23097 WMI_VDEV_PARAM_DHCP_INDICATE;
23098 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23099 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23100 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23101 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23102 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23103 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23104 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23105 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23106 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23107 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23108 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23109 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23110 vdev_param[wmi_vdev_param_packet_powersave] =
23111 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23112 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23113 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23114 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23115 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23116 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23117 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23118 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23119 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23120 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23121 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23122 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23123 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23124 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23125 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23126 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23127 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23128 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23129 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23130 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23131 vdev_param[wmi_vdev_param_roam_fw_offload] =
23132 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23133 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23134 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23135 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23136 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23137 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23138 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23139 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23140 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23141 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23142 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23143 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23144 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23145 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23146 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23147 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23148 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23149 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23150 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23151 vdev_param[wmi_vdev_param_inactivity_cnt] =
23152 WMI_VDEV_PARAM_INACTIVITY_CNT;
23153 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23154 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23155 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23156 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23157 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23158 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23159 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23160 vdev_param[wmi_vdev_param_rx_leak_window] =
23161 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23162 vdev_param[wmi_vdev_param_stats_avg_factor] =
23163 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23164 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23165 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23166 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23167 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23168 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23169 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023170 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23171 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023172 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023173 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23174 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23175 WMI_VDEV_PARAM_HE_RANGE_EXT;
23176 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23177 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023178 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023179 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23180 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23181 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23182 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23183 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23184 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23185 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023186 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23187 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23188 vdev_param[wmi_vdev_param_rc_num_retries] =
23189 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23190 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23191 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23192 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23193 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23194 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23195 vdev_param[wmi_vdev_param_vht80_ratemask] =
23196 WMI_VDEV_PARAM_VHT80_RATEMASK;
23197 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23198 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23199 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023200 vdev_param[wmi_vdev_param_set_he_ltf] =
23201 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053023202 vdev_param[wmi_vdev_param_disable_cabq] =
23203 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053023204 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23205 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023206 vdev_param[wmi_vdev_param_set_ba_mode] =
23207 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023208 vdev_param[wmi_vdev_param_capabilities] =
23209 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023210 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23211 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023212}
23213#endif
23214
Govind Singh5eb51532016-03-09 11:34:12 +053023215/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023216 * populate_target_defines_tlv() - Populate target defines and params
23217 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023218 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023219 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023220 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023221#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023222static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023223{
Govind Singhe7f2f342016-05-23 12:12:52 +053023224 populate_pdev_param_tlv(wmi_handle->pdev_param);
23225 populate_vdev_param_tlv(wmi_handle->vdev_param);
23226}
23227#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023228static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23229{ }
23230#endif
23231
23232/**
Zhang Qian537fca62018-01-03 16:33:24 +080023233 * wmi_ocb_ut_attach() - Attach OCB test framework
23234 * @wmi_handle: wmi handle
23235 *
23236 * Return: None
23237 */
23238#ifdef WLAN_OCB_UT
23239void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23240#else
23241static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23242{
23243 return;
23244}
23245#endif
23246
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023247/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023248 * wmi_tlv_attach() - Attach TLV APIs
23249 *
23250 * Return: None
23251 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023252void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023253{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023254 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023255 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023256 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023257#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023258 /* Skip saving WMI_CMD_HDR and TLV HDR */
23259 wmi_handle->log_info.buf_offset_command = 8;
23260 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023261 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023262#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023263 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023264 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023265 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023266 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080023267 wmi_extscan_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023268}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023269qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023270
23271/**
23272 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23273 *
23274 * Return: None
23275 */
23276void wmi_tlv_init(void)
23277{
23278 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23279}