blob: 18e5bfcd87791c8a22f7eabb1985117960b8c31e [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
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053030#ifdef WLAN_FEATURE_ACTION_OUI
31#include "wmi_unified_action_oui_tlv.h"
32#endif
Wu Gaocd3a8512017-03-13 20:17:34 +080033#ifdef CONVERGED_P2P_ENABLE
34#include "wlan_p2p_public_struct.h"
35#endif
Wu Gao52c0b772018-05-17 16:14:00 +080036#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Dustin Brownf31f88b2017-05-12 14:01:44 -070037#include "wlan_pmo_hw_filter_public_struct.h"
38#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053039#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053040#ifdef WLAN_SUPPORT_GREEN_AP
41#include "wlan_green_ap_api.h"
42#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053043
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080044#ifdef WLAN_FEATURE_NAN_CONVERGENCE
45#include "nan_public_structs.h"
46#endif
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070047#include "wmi_unified_twt_api.h"
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080048
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080049#ifdef WLAN_POLICY_MGR_ENABLE
50#include "wlan_policy_mgr_public_struct.h"
51#endif
52
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053053/* HTC service ids for WMI for multi-radio */
54static const uint32_t multi_svc_ids[] = {WMI_CONTROL_SVC,
55 WMI_CONTROL_SVC_WMAC1,
56 WMI_CONTROL_SVC_WMAC2};
57
Arif Hussainb522ac92018-06-27 10:51:06 -070058/**
59 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
60 * host to target defines.
61 * @param pdev_id: host pdev_id to be converted.
62 * Return: target pdev_id after conversion.
63 */
64static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
65{
66 switch (pdev_id) {
67 case WMI_HOST_PDEV_ID_SOC:
68 return WMI_PDEV_ID_SOC;
69 case WMI_HOST_PDEV_ID_0:
70 return WMI_PDEV_ID_1ST;
71 case WMI_HOST_PDEV_ID_1:
72 return WMI_PDEV_ID_2ND;
73 case WMI_HOST_PDEV_ID_2:
74 return WMI_PDEV_ID_3RD;
75 }
76
77 QDF_ASSERT(0);
78
79 return WMI_PDEV_ID_SOC;
80}
81
82/**
83 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
84 * target to host defines.
85 * @param pdev_id: target pdev_id to be converted.
86 * Return: host pdev_id after conversion.
87 */
88static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
89{
90 switch (pdev_id) {
91 case WMI_PDEV_ID_SOC:
92 return WMI_HOST_PDEV_ID_SOC;
93 case WMI_PDEV_ID_1ST:
94 return WMI_HOST_PDEV_ID_0;
95 case WMI_PDEV_ID_2ND:
96 return WMI_HOST_PDEV_ID_1;
97 case WMI_PDEV_ID_3RD:
98 return WMI_HOST_PDEV_ID_2;
99 }
100
101 QDF_ASSERT(0);
102
103 return WMI_HOST_PDEV_ID_SOC;
104}
105
106/**
107 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
108 *
109 * Return None.
110 */
111static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
112{
113 wmi_handle->ops->convert_pdev_id_host_to_target =
114 convert_host_pdev_id_to_target_pdev_id;
115 wmi_handle->ops->convert_pdev_id_target_to_host =
116 convert_target_pdev_id_to_host_pdev_id;
117}
118
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530119/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
120 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530121 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530122 * @cmd: pointer target vdev create command buffer
123 * @param: pointer host params for vdev create
124 *
125 * Return: None
126 */
127#ifdef CONFIG_MCL
128static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530129 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530130 wmi_vdev_create_cmd_fixed_param * cmd,
131 struct vdev_create_params *param)
132{
133 cmd->pdev_id = WMI_PDEV_ID_SOC;
134}
135#else
136static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530137 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530138 wmi_vdev_create_cmd_fixed_param * cmd,
139 struct vdev_create_params *param)
140{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530141 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
142 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530143}
144#endif
145
Govind Singh5eb51532016-03-09 11:34:12 +0530146/**
147 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
148 * @wmi_handle: wmi handle
149 * @param: pointer to hold vdev create parameter
150 * @macaddr: vdev mac address
151 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530152 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530153 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530154static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530155 uint8_t macaddr[IEEE80211_ADDR_LEN],
156 struct vdev_create_params *param)
157{
158 wmi_vdev_create_cmd_fixed_param *cmd;
159 wmi_buf_t buf;
160 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +0530161 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700162 int num_bands = 2;
163 uint8_t *buf_ptr;
164 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +0530165
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700166 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530167 buf = wmi_buf_alloc(wmi_handle, len);
168 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530169 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530170 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530171 }
172 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
173 WMITLV_SET_HDR(&cmd->tlv_header,
174 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
175 WMITLV_GET_STRUCT_TLVLEN
176 (wmi_vdev_create_cmd_fixed_param));
177 cmd->vdev_id = param->if_id;
178 cmd->vdev_type = param->type;
179 cmd->vdev_subtype = param->subtype;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -0700180 cmd->flags = param->mbssid_flags;
181 cmd->vdevid_trans = param->vdevid_trans;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700182 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530183 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530184 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700185 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
186 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530187 macaddr[0], macaddr[1], macaddr[2],
188 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700189 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
190 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
191 (num_bands * sizeof(wmi_vdev_txrx_streams)));
192 buf_ptr += WMI_TLV_HDR_SIZE;
193
Govind Singh224a7312016-06-21 14:33:26 +0530194 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700195 param->type, param->subtype,
196 param->nss_2g, param->nss_5g);
197 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
198 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
199 txrx_streams->supported_tx_streams = param->nss_2g;
200 txrx_streams->supported_rx_streams = param->nss_2g;
201 WMITLV_SET_HDR(&txrx_streams->tlv_header,
202 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
203 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
204
205 txrx_streams++;
206 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
207 txrx_streams->supported_tx_streams = param->nss_5g;
208 txrx_streams->supported_rx_streams = param->nss_5g;
209 WMITLV_SET_HDR(&txrx_streams->tlv_header,
210 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
211 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530212 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530213 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530214 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530215 wmi_buf_free(buf);
216 }
217
218 return ret;
219}
220
221/**
222 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
223 * @wmi_handle: wmi handle
224 * @if_id: vdev id
225 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530226 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530227 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530228static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530229 uint8_t if_id)
230{
231 wmi_vdev_delete_cmd_fixed_param *cmd;
232 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530233 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530234
235 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
236 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530237 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530238 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530239 }
240
241 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
242 WMITLV_SET_HDR(&cmd->tlv_header,
243 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
244 WMITLV_GET_STRUCT_TLVLEN
245 (wmi_vdev_delete_cmd_fixed_param));
246 cmd->vdev_id = if_id;
247 ret = wmi_unified_cmd_send(wmi_handle, buf,
248 sizeof(wmi_vdev_delete_cmd_fixed_param),
249 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530250 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530251 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530252 wmi_buf_free(buf);
253 }
Govind Singhb53420c2016-03-09 14:32:57 +0530254 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530255
256 return ret;
257}
258
259/**
260 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
261 * @wmi: wmi handle
262 * @vdev_id: vdev id
263 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530264 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530265 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530266static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530267 uint8_t vdev_id)
268{
269 wmi_vdev_stop_cmd_fixed_param *cmd;
270 wmi_buf_t buf;
271 int32_t len = sizeof(*cmd);
272
273 buf = wmi_buf_alloc(wmi, len);
274 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530275 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530276 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530277 }
278 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
279 WMITLV_SET_HDR(&cmd->tlv_header,
280 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
281 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
282 cmd->vdev_id = vdev_id;
283 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530284 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530285 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530286 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530287 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530288 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530289
290 return 0;
291}
292
293/**
294 * send_vdev_down_cmd_tlv() - send vdev down command to fw
295 * @wmi: wmi handle
296 * @vdev_id: vdev id
297 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530298 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530299 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530300static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530301{
302 wmi_vdev_down_cmd_fixed_param *cmd;
303 wmi_buf_t buf;
304 int32_t len = sizeof(*cmd);
305
306 buf = wmi_buf_alloc(wmi, len);
307 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530308 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530309 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530310 }
311 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
312 WMITLV_SET_HDR(&cmd->tlv_header,
313 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
314 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
315 cmd->vdev_id = vdev_id;
316 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530317 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530318 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530319 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530320 }
Govind Singhb53420c2016-03-09 14:32:57 +0530321 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530322
323 return 0;
324}
325
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530326#ifdef CONFIG_MCL
327static inline void copy_channel_info(
328 wmi_vdev_start_request_cmd_fixed_param * cmd,
329 wmi_channel *chan,
330 struct vdev_start_params *req)
331{
332 chan->mhz = req->chan_freq;
333
334 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
335
336 chan->band_center_freq1 = req->band_center_freq1;
337 chan->band_center_freq2 = req->band_center_freq2;
338
339 if (req->is_half_rate)
340 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
341 else if (req->is_quarter_rate)
342 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
343
Naveen Rawat44f2f432016-12-01 12:58:57 -0800344 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530345 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
346 cmd->disable_hw_ack = req->dis_hw_ack;
347 }
348
349 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
350 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
351
352}
353#else
354static inline void copy_channel_info(
355 wmi_vdev_start_request_cmd_fixed_param * cmd,
356 wmi_channel *chan,
357 struct vdev_start_params *req)
358{
359 chan->mhz = req->channel.mhz;
360
361 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
362
363 chan->band_center_freq1 = req->channel.cfreq1;
364 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800365 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530366
367 if (req->channel.half_rate)
368 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
369 else if (req->channel.quarter_rate)
370 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
371
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800372 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
373
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530374 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530375 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530376 cmd->disable_hw_ack = req->disable_hw_ack;
377 }
378
Krishna Rao0b952ea2017-03-20 13:30:10 +0530379 if (req->channel.dfs_set_cfreq2)
380 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
381
Kai Chen4710d462017-12-15 14:06:06 -0800382 /* According to firmware both reg power and max tx power
383 * on set channel power is used and set it to max reg
384 * power from regulatory.
385 */
386 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
387 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530388 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800389 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
390 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
391 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530392
393}
394#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530395/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530396 * send_vdev_start_cmd_tlv() - send vdev start request to fw
397 * @wmi_handle: wmi handle
398 * @req: vdev start params
399 *
400 * Return: QDF status
401 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530402static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530403 struct vdev_start_params *req)
404{
405 wmi_vdev_start_request_cmd_fixed_param *cmd;
406 wmi_buf_t buf;
407 wmi_channel *chan;
408 int32_t len, ret;
409 uint8_t *buf_ptr;
410
411 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
412 buf = wmi_buf_alloc(wmi_handle, len);
413 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530414 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530415 return QDF_STATUS_E_NOMEM;
416 }
417 buf_ptr = (uint8_t *) wmi_buf_data(buf);
418 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
419 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
420 WMITLV_SET_HDR(&cmd->tlv_header,
421 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
422 WMITLV_GET_STRUCT_TLVLEN
423 (wmi_vdev_start_request_cmd_fixed_param));
424 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
425 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
426 cmd->vdev_id = req->vdev_id;
427
428 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530429 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530430
431 cmd->beacon_interval = req->beacon_intval;
432 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530433
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800434 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
435 if (req->bcn_tx_rate_code)
436 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
437
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530438 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530439 cmd->beacon_interval = req->beacon_intval;
440 cmd->dtim_period = req->dtim_period;
441
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530442 /* Copy the SSID */
443 if (req->ssid.length) {
444 if (req->ssid.length < sizeof(cmd->ssid.ssid))
445 cmd->ssid.ssid_len = req->ssid.length;
446 else
447 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
448 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
449 cmd->ssid.ssid_len);
450 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530451
452 if (req->hidden_ssid)
453 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
454
455 if (req->pmf_enabled)
456 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530457 }
458
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700459 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530460 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530461 cmd->preferred_rx_streams = req->preferred_rx_streams;
462 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700463 cmd->cac_duration_ms = req->cac_duration_ms;
464 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700465 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530466
467 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
468 sizeof(wmi_channel));
469 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
470 cmd->num_noa_descriptors *
471 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800472 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530473 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
474 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800475 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
476 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
477 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530478 req->is_dfs, req->beacon_intval, cmd->dtim_period,
479 chan->band_center_freq1, chan->band_center_freq2,
480 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700481 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700482 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800483 req->regdomain, req->he_ops,
484 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530485
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530486 if (req->is_restart)
487 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
488 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530489 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530490 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
491 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530492 if (ret) {
493 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530494 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530495 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530496 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530497
498 return QDF_STATUS_SUCCESS;
499}
500
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530501/**
502 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
503 * @wmi_handle: wmi handle
504 * @restart_params: vdev restart params
505 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530506 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530507 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530508static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530509 struct hidden_ssid_vdev_restart_params *restart_params)
510{
511 wmi_vdev_start_request_cmd_fixed_param *cmd;
512 wmi_buf_t buf;
513 wmi_channel *chan;
514 int32_t len;
515 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530516 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530517
518 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
519 buf = wmi_buf_alloc(wmi_handle, len);
520 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530521 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530522 return QDF_STATUS_E_NOMEM;
523 }
524 buf_ptr = (uint8_t *) wmi_buf_data(buf);
525 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
526 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
527
528 WMITLV_SET_HDR(&cmd->tlv_header,
529 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
530 WMITLV_GET_STRUCT_TLVLEN
531 (wmi_vdev_start_request_cmd_fixed_param));
532
533 WMITLV_SET_HDR(&chan->tlv_header,
534 WMITLV_TAG_STRUC_wmi_channel,
535 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
536
537 cmd->vdev_id = restart_params->session_id;
538 cmd->ssid.ssid_len = restart_params->ssid_len;
539 qdf_mem_copy(cmd->ssid.ssid,
540 restart_params->ssid,
541 cmd->ssid.ssid_len);
542 cmd->flags = restart_params->flags;
543 cmd->requestor_id = restart_params->requestor_id;
544 cmd->disable_hw_ack = restart_params->disable_hw_ack;
545
546 chan->mhz = restart_params->mhz;
547 chan->band_center_freq1 =
548 restart_params->band_center_freq1;
549 chan->band_center_freq2 =
550 restart_params->band_center_freq2;
551 chan->info = restart_params->info;
552 chan->reg_info_1 = restart_params->reg_info_1;
553 chan->reg_info_2 = restart_params->reg_info_2;
554
555 cmd->num_noa_descriptors = 0;
556 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
557 sizeof(wmi_channel));
558 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
559 cmd->num_noa_descriptors *
560 sizeof(wmi_p2p_noa_descriptor));
561
562 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
563 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530564 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530565 wmi_buf_free(buf);
566 return QDF_STATUS_E_FAILURE;
567 }
568 return QDF_STATUS_SUCCESS;
569}
570
571
572/**
Govind Singh5eb51532016-03-09 11:34:12 +0530573 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
574 * @wmi: wmi handle
575 * @peer_addr: peer mac address
576 * @param: pointer to hold peer flush tid parameter
577 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -0700578 * Return: 0 for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530579 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530580static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530581 uint8_t peer_addr[IEEE80211_ADDR_LEN],
582 struct peer_flush_params *param)
583{
584 wmi_peer_flush_tids_cmd_fixed_param *cmd;
585 wmi_buf_t buf;
586 int32_t len = sizeof(*cmd);
587
588 buf = wmi_buf_alloc(wmi, len);
589 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530590 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530591 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530592 }
593 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
594 WMITLV_SET_HDR(&cmd->tlv_header,
595 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
596 WMITLV_GET_STRUCT_TLVLEN
597 (wmi_peer_flush_tids_cmd_fixed_param));
598 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
599 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
600 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530601 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530602 peer_addr, param->vdev_id,
603 param->peer_tid_bitmap);
604 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530605 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530606 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530607 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530608 }
609
610 return 0;
611}
612
613/**
614 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
615 * @wmi: wmi handle
616 * @peer_addr: peer mac addr
617 * @vdev_id: vdev id
618 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530619 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530620 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530621static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530622 uint8_t peer_addr[IEEE80211_ADDR_LEN],
623 uint8_t vdev_id)
624{
625 wmi_peer_delete_cmd_fixed_param *cmd;
626 wmi_buf_t buf;
627 int32_t len = sizeof(*cmd);
628 buf = wmi_buf_alloc(wmi, len);
629 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530630 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530631 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530632 }
633 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
634 WMITLV_SET_HDR(&cmd->tlv_header,
635 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
636 WMITLV_GET_STRUCT_TLVLEN
637 (wmi_peer_delete_cmd_fixed_param));
638 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
639 cmd->vdev_id = vdev_id;
640
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800641 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530642 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530643 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530644 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530645 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530646 }
Govind Singh5eb51532016-03-09 11:34:12 +0530647
648 return 0;
649}
650
651/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530652 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
653 * to target id.
654 * @targ_paramid: Target parameter id to hold the result.
655 * @peer_param_id: host param id.
656 *
657 * Return: QDF_STATUS_SUCCESS for success
658 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
659 */
660#ifdef CONFIG_MCL
661static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
662 uint32_t *targ_paramid,
663 uint32_t peer_param_id)
664{
665 *targ_paramid = peer_param_id;
666 return QDF_STATUS_SUCCESS;
667}
Mohit Khannab9e1e542018-07-24 15:28:04 -0700668
669/**
670 * crash_on_send_peer_rx_reorder_queue_remove_cmd() - crash on reorder queue cmd
671 *
672 * On MCL side, we are suspecting this cmd to trigger drop of ARP
673 * response frames from REO by the FW. This function causes a crash if this
674 * command is sent out by the host, so we can track this issue. Ideally no one
675 * should be calling this API from the MCL side
676 *
677 * Return: None
678 */
679static void crash_on_send_peer_rx_reorder_queue_remove_cmd(void)
680{
681 QDF_BUG(0);
682}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530683#else
684static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
685 uint32_t *targ_paramid,
686 uint32_t peer_param_id)
687{
688 switch (peer_param_id) {
689 case WMI_HOST_PEER_MIMO_PS_STATE:
690 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
691 break;
692 case WMI_HOST_PEER_AMPDU:
693 *targ_paramid = WMI_PEER_AMPDU;
694 break;
695 case WMI_HOST_PEER_AUTHORIZE:
696 *targ_paramid = WMI_PEER_AUTHORIZE;
697 break;
698 case WMI_HOST_PEER_CHWIDTH:
699 *targ_paramid = WMI_PEER_CHWIDTH;
700 break;
701 case WMI_HOST_PEER_NSS:
702 *targ_paramid = WMI_PEER_NSS;
703 break;
704 case WMI_HOST_PEER_USE_4ADDR:
705 *targ_paramid = WMI_PEER_USE_4ADDR;
706 break;
707 case WMI_HOST_PEER_MEMBERSHIP:
708 *targ_paramid = WMI_PEER_MEMBERSHIP;
709 break;
710 case WMI_HOST_PEER_USERPOS:
711 *targ_paramid = WMI_PEER_USERPOS;
712 break;
713 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
714 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
715 break;
716 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
717 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
718 break;
719 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
720 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
721 break;
722 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
723 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
724 break;
725 case WMI_HOST_PEER_PHYMODE:
726 *targ_paramid = WMI_PEER_PHYMODE;
727 break;
728 case WMI_HOST_PEER_USE_FIXED_PWR:
729 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
730 break;
731 case WMI_HOST_PEER_PARAM_FIXED_RATE:
732 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
733 break;
734 case WMI_HOST_PEER_SET_MU_WHITELIST:
735 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
736 break;
737 case WMI_HOST_PEER_SET_MAC_TX_RATE:
738 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
739 break;
740 case WMI_HOST_PEER_SET_MIN_TX_RATE:
741 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
742 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530743 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
744 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
745 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530746 case WMI_HOST_PEER_NSS_VHT160:
747 *targ_paramid = WMI_PEER_NSS_VHT160;
748 break;
749 case WMI_HOST_PEER_NSS_VHT80_80:
750 *targ_paramid = WMI_PEER_NSS_VHT80_80;
751 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530752 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
753 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
754 break;
755 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
756 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
757 break;
758 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
759 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
760 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530761 case WMI_HOST_PEER_PARAM_MU_ENABLE:
762 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
763 break;
764 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
765 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
766 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530767 default:
768 return QDF_STATUS_E_NOSUPPORT;
769 }
770
771 return QDF_STATUS_SUCCESS;
772}
Mohit Khannab9e1e542018-07-24 15:28:04 -0700773
774static void crash_on_send_peer_rx_reorder_queue_remove_cmd(void)
775{
776 /* No-OP */
777}
778
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530779#endif
780/**
Govind Singh5eb51532016-03-09 11:34:12 +0530781 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530782 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530783 * @peer_addr: peer mac address
784 * @param : pointer to hold peer set parameter
785 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530786 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530787 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530788static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530789 uint8_t peer_addr[IEEE80211_ADDR_LEN],
790 struct peer_set_params *param)
791{
792 wmi_peer_set_param_cmd_fixed_param *cmd;
793 wmi_buf_t buf;
794 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530795 uint32_t param_id;
796
797 if (convert_host_peer_id_to_target_id_tlv(&param_id,
798 param->param_id) != QDF_STATUS_SUCCESS)
799 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530800
801 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
802 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530803 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530804 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530805 }
806 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
807 WMITLV_SET_HDR(&cmd->tlv_header,
808 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
809 WMITLV_GET_STRUCT_TLVLEN
810 (wmi_peer_set_param_cmd_fixed_param));
811 cmd->vdev_id = param->vdev_id;
812 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530813 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530814 cmd->param_value = param->param_value;
815 err = wmi_unified_cmd_send(wmi, buf,
816 sizeof(wmi_peer_set_param_cmd_fixed_param),
817 WMI_PEER_SET_PARAM_CMDID);
818 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530819 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530820 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530821 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530822 }
823
824 return 0;
825}
826
827/**
828 * send_vdev_up_cmd_tlv() - send vdev up command in fw
829 * @wmi: wmi handle
830 * @bssid: bssid
831 * @vdev_up_params: pointer to hold vdev up parameter
832 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530833 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530834 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530835static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530836 uint8_t bssid[IEEE80211_ADDR_LEN],
837 struct vdev_up_params *params)
838{
839 wmi_vdev_up_cmd_fixed_param *cmd;
840 wmi_buf_t buf;
841 int32_t len = sizeof(*cmd);
842
Govind Singhb53420c2016-03-09 14:32:57 +0530843 WMI_LOGD("%s: VDEV_UP", __func__);
844 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530845 params->vdev_id, params->assoc_id, bssid);
846 buf = wmi_buf_alloc(wmi, len);
847 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530848 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530849 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530850 }
851 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
852 WMITLV_SET_HDR(&cmd->tlv_header,
853 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
854 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
855 cmd->vdev_id = params->vdev_id;
856 cmd->vdev_assoc_id = params->assoc_id;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -0700857 cmd->profile_idx = params->profile_idx;
858 cmd->profile_num = params->profile_num;
859 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->trans_bssid, &cmd->trans_bssid);
Govind Singh5eb51532016-03-09 11:34:12 +0530860 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
861 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530862 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530863 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530864 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530865 }
866
867 return 0;
868}
869
870/**
871 * send_peer_create_cmd_tlv() - send peer create command to fw
872 * @wmi: wmi handle
873 * @peer_addr: peer mac address
874 * @peer_type: peer type
875 * @vdev_id: vdev id
876 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530877 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530878 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530879static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530880 struct peer_create_params *param)
881{
882 wmi_peer_create_cmd_fixed_param *cmd;
883 wmi_buf_t buf;
884 int32_t len = sizeof(*cmd);
885
886 buf = wmi_buf_alloc(wmi, len);
887 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530888 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530889 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530890 }
891 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
892 WMITLV_SET_HDR(&cmd->tlv_header,
893 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
894 WMITLV_GET_STRUCT_TLVLEN
895 (wmi_peer_create_cmd_fixed_param));
896 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
897 cmd->peer_type = param->peer_type;
898 cmd->vdev_id = param->vdev_id;
899
900 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530901 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530902 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530903 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530904 }
Govind Singhb53420c2016-03-09 14:32:57 +0530905 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530906 param->vdev_id);
907
908 return 0;
909}
910
911/**
Leo Changeee40872016-09-28 13:43:36 -0700912 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
913 * command to fw
914 * @wmi: wmi handle
915 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
916 *
917 * Return: 0 for success or error code
918 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700919static
Leo Changeee40872016-09-28 13:43:36 -0700920QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
921 struct rx_reorder_queue_setup_params *param)
922{
923 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
924 wmi_buf_t buf;
925 int32_t len = sizeof(*cmd);
926
927 buf = wmi_buf_alloc(wmi, len);
928 if (!buf) {
929 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
930 return QDF_STATUS_E_NOMEM;
931 }
932 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
933 WMITLV_SET_HDR(&cmd->tlv_header,
934 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
935 WMITLV_GET_STRUCT_TLVLEN
936 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
937 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
938 cmd->vdev_id = param->vdev_id;
939 cmd->tid = param->tid;
940 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
941 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
942 cmd->queue_no = param->queue_no;
Gyanranjan Hazarikad6c4d782018-07-25 23:26:16 -0700943 cmd->ba_window_size_valid = param->ba_window_size_valid;
944 cmd->ba_window_size = param->ba_window_size;
945
Leo Changeee40872016-09-28 13:43:36 -0700946
947 if (wmi_unified_cmd_send(wmi, buf, len,
948 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
949 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
950 __func__);
951 qdf_nbuf_free(buf);
952 return QDF_STATUS_E_FAILURE;
953 }
954 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
955 param->peer_macaddr, param->vdev_id, param->tid);
956
957 return QDF_STATUS_SUCCESS;
958}
959
960/**
961 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
962 * command to fw
963 * @wmi: wmi handle
964 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
965 *
966 * Return: 0 for success or error code
967 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700968static
Leo Changeee40872016-09-28 13:43:36 -0700969QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
970 struct rx_reorder_queue_remove_params *param)
971{
972 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
973 wmi_buf_t buf;
974 int32_t len = sizeof(*cmd);
975
Mohit Khannab9e1e542018-07-24 15:28:04 -0700976 crash_on_send_peer_rx_reorder_queue_remove_cmd();
977
Leo Changeee40872016-09-28 13:43:36 -0700978 buf = wmi_buf_alloc(wmi, len);
979 if (!buf) {
980 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
981 return QDF_STATUS_E_NOMEM;
982 }
983 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
984 wmi_buf_data(buf);
985 WMITLV_SET_HDR(&cmd->tlv_header,
986 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
987 WMITLV_GET_STRUCT_TLVLEN
988 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
989 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
990 cmd->vdev_id = param->vdev_id;
991 cmd->tid_mask = param->peer_tid_bitmap;
992
993 if (wmi_unified_cmd_send(wmi, buf, len,
994 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
995 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
996 __func__);
997 qdf_nbuf_free(buf);
998 return QDF_STATUS_E_FAILURE;
999 }
1000 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
1001 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
1002
1003 return QDF_STATUS_SUCCESS;
1004}
1005
1006/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301007 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
1008 * @wmi_handle: wmi handle
1009 * @param: pointer holding peer details
1010 *
1011 * Return: 0 for success or error code
1012 */
1013static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1014 struct peer_add_wds_entry_params *param)
1015{
1016 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
1017 wmi_buf_t buf;
1018 int len = sizeof(*cmd);
1019
1020 buf = wmi_buf_alloc(wmi_handle, len);
1021 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05301022 qdf_print("%s: wmi_buf_alloc failed", __func__);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301023 return QDF_STATUS_E_FAILURE;
1024 }
1025 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
1026 WMITLV_SET_HDR(&cmd->tlv_header,
1027 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
1028 WMITLV_GET_STRUCT_TLVLEN
1029 (wmi_peer_add_wds_entry_cmd_fixed_param));
1030 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
1031 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001032 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1033 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301034
1035 return wmi_unified_cmd_send(wmi_handle, buf, len,
1036 WMI_PEER_ADD_WDS_ENTRY_CMDID);
1037}
1038
1039/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +05301040 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301041 * @wmi_handle: wmi handle
1042 * @param: pointer holding peer details
1043 *
1044 * Return: 0 for success or error code
1045 */
1046static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1047 struct peer_del_wds_entry_params *param)
1048{
1049 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
1050 wmi_buf_t buf;
1051 int len = sizeof(*cmd);
1052
1053 buf = wmi_buf_alloc(wmi_handle, len);
1054 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05301055 qdf_print("%s: wmi_buf_alloc failed", __func__);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301056 return QDF_STATUS_E_NOMEM;
1057 }
1058 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1059 WMITLV_SET_HDR(&cmd->tlv_header,
1060 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
1061 WMITLV_GET_STRUCT_TLVLEN
1062 (wmi_peer_remove_wds_entry_cmd_fixed_param));
1063 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001064 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301065 return wmi_unified_cmd_send(wmi_handle, buf, len,
1066 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
1067}
1068
1069/**
1070 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
1071 * @wmi_handle: wmi handle
1072 * @param: pointer holding peer details
1073 *
1074 * Return: 0 for success or error code
1075 */
1076static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1077 struct peer_update_wds_entry_params *param)
1078{
1079 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
1080 wmi_buf_t buf;
1081 int len = sizeof(*cmd);
1082
1083 buf = wmi_buf_alloc(wmi_handle, len);
1084 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05301085 qdf_print("%s: wmi_buf_alloc failed", __func__);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301086 return QDF_STATUS_E_NOMEM;
1087 }
1088
1089 /* wmi_buf_alloc returns zeroed command buffer */
1090 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1091 WMITLV_SET_HDR(&cmd->tlv_header,
1092 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
1093 WMITLV_GET_STRUCT_TLVLEN
1094 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001095 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1096 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301097 if (param->wds_macaddr)
1098 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
1099 &cmd->wds_macaddr);
1100 if (param->peer_macaddr)
1101 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1102 &cmd->peer_macaddr);
1103 return wmi_unified_cmd_send(wmi_handle, buf, len,
1104 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1105}
1106
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001107/**
1108 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1109 * @wmi_handle: wmi handle
1110 * @param: pointer to get tpc config params
1111 *
1112 * Return: 0 for success or error code
1113 */
1114static QDF_STATUS
1115send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1116 uint32_t param)
1117{
1118 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1119 wmi_buf_t buf;
1120 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1121
1122 buf = wmi_buf_alloc(wmi_handle, len);
1123 if (!buf) {
1124 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1125 return QDF_STATUS_E_NOMEM;
1126 }
1127 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1128 WMITLV_SET_HDR(&cmd->tlv_header,
1129 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1130 WMITLV_GET_STRUCT_TLVLEN
1131 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1132
1133 cmd->param = param;
1134 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1135 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1136 WMI_LOGE("Send pdev get tpc config cmd failed");
1137 wmi_buf_free(buf);
1138 return QDF_STATUS_E_FAILURE;
1139
1140 }
1141 WMI_LOGD("%s:send success", __func__);
1142
1143 return QDF_STATUS_SUCCESS;
1144}
1145
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301146#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301147/**
Govind Singh5eb51532016-03-09 11:34:12 +05301148 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1149 * @wmi_handle: wmi handle
1150 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301151 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301152 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301153 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301154 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301155static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301156 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301157{
1158 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1159 wmi_buf_t buf;
1160 int32_t len = sizeof(*cmd);
1161
Govind Singhb53420c2016-03-09 14:32:57 +05301162 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301163
1164 buf = wmi_buf_alloc(wmi_handle, len);
1165 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301166 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301167 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301168 }
1169
1170 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1171 WMITLV_SET_HDR(&cmd->tlv_header,
1172 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1173 WMITLV_GET_STRUCT_TLVLEN
1174 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301175 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301176 cmd->enable = value;
1177
1178 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1179 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301180 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301181 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301182 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301183 }
1184
1185 return 0;
1186}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301187#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301188
1189/**
1190 * send_pdev_utf_cmd_tlv() - send utf command to fw
1191 * @wmi_handle: wmi handle
1192 * @param: pointer to pdev_utf_params
1193 * @mac_id: mac id to have radio context
1194 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301195 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301196 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301197static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301198send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1199 struct pdev_utf_params *param,
1200 uint8_t mac_id)
1201{
1202 wmi_buf_t buf;
1203 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001204 /* if param->len is 0 no data is sent, return error */
1205 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301206 static uint8_t msgref = 1;
1207 uint8_t segNumber = 0, segInfo, numSegments;
1208 uint16_t chunk_len, total_bytes;
1209 uint8_t *bufpos;
1210 struct seg_hdr_info segHdrInfo;
1211
1212 bufpos = param->utf_payload;
1213 total_bytes = param->len;
1214 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1215 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1216 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1217
1218 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1219 numSegments++;
1220
1221 while (param->len) {
1222 if (param->len > MAX_WMI_UTF_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -07001223 chunk_len = MAX_WMI_UTF_LEN; /* MAX message */
Govind Singh5eb51532016-03-09 11:34:12 +05301224 else
1225 chunk_len = param->len;
1226
1227 buf = wmi_buf_alloc(wmi_handle,
1228 (chunk_len + sizeof(segHdrInfo) +
1229 WMI_TLV_HDR_SIZE));
1230 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301231 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301232 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301233 }
1234
1235 cmd = (uint8_t *) wmi_buf_data(buf);
1236
1237 segHdrInfo.len = total_bytes;
1238 segHdrInfo.msgref = msgref;
1239 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1240 segHdrInfo.segmentInfo = segInfo;
1241 segHdrInfo.pad = 0;
1242
Govind Singhb53420c2016-03-09 14:32:57 +05301243 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301244 " segHdrInfo.segmentInfo = %d",
1245 __func__, segHdrInfo.len, segHdrInfo.msgref,
1246 segHdrInfo.segmentInfo);
1247
Govind Singhb53420c2016-03-09 14:32:57 +05301248 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301249 "chunk len %d", __func__, total_bytes, segNumber,
1250 numSegments, chunk_len);
1251
1252 segNumber++;
1253
1254 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1255 (chunk_len + sizeof(segHdrInfo)));
1256 cmd += WMI_TLV_HDR_SIZE;
1257 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1258 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1259
1260 ret = wmi_unified_cmd_send(wmi_handle, buf,
1261 (chunk_len + sizeof(segHdrInfo) +
1262 WMI_TLV_HDR_SIZE),
1263 WMI_PDEV_UTF_CMDID);
1264
Govind Singh67922e82016-04-01 16:48:57 +05301265 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301266 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301267 wmi_buf_free(buf);
1268 break;
1269 }
1270
1271 param->len -= chunk_len;
1272 bufpos += chunk_len;
1273 }
1274
1275 msgref++;
1276
1277 return ret;
1278}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301279#ifdef CONFIG_MCL
1280static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1281 uint32_t host_param)
1282{
1283 return host_param;
1284}
1285#else
1286static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1287 uint32_t host_param)
1288{
1289 if (host_param < wmi_pdev_param_max)
1290 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301291
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301292 return WMI_UNAVAILABLE_PARAM;
1293}
1294#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301295/**
1296 * send_pdev_param_cmd_tlv() - set pdev parameters
1297 * @wmi_handle: wmi handle
1298 * @param: pointer to pdev parameter
1299 * @mac_id: radio context
1300 *
1301 * Return: 0 on success, errno on failure
1302 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301303static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301304send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1305 struct pdev_params *param,
1306 uint8_t mac_id)
1307{
Govind Singh67922e82016-04-01 16:48:57 +05301308 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301309 wmi_pdev_set_param_cmd_fixed_param *cmd;
1310 wmi_buf_t buf;
1311 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301312 uint32_t pdev_param;
1313
1314 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1315 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1316 WMI_LOGW("%s: Unavailable param %d\n",
1317 __func__, param->param_id);
1318 return QDF_STATUS_E_INVAL;
1319 }
Govind Singh5eb51532016-03-09 11:34:12 +05301320
1321 buf = wmi_buf_alloc(wmi_handle, len);
1322 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301323 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301324 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301325 }
1326 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1327 WMITLV_SET_HDR(&cmd->tlv_header,
1328 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1329 WMITLV_GET_STRUCT_TLVLEN
1330 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301331 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301332 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301333 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301334 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301335 param->param_value);
1336 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1337 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301338 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301339 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301340 wmi_buf_free(buf);
1341 }
1342 return ret;
1343}
1344
1345/**
1346 * send_suspend_cmd_tlv() - WMI suspend function
1347 * @param wmi_handle : handle to WMI.
1348 * @param param : pointer to hold suspend parameter
1349 * @mac_id: radio context
1350 *
1351 * Return 0 on success and -ve on failure.
1352 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301353static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301354 struct suspend_params *param,
1355 uint8_t mac_id)
1356{
1357 wmi_pdev_suspend_cmd_fixed_param *cmd;
1358 wmi_buf_t wmibuf;
1359 uint32_t len = sizeof(*cmd);
1360 int32_t ret;
1361
1362 /*
Jeff Johnson19a59fe2018-05-06 16:10:43 -07001363 * send the command to Target to ignore the
Govind Singh5eb51532016-03-09 11:34:12 +05301364 * PCIE reset so as to ensure that Host and target
1365 * states are in sync
1366 */
1367 wmibuf = wmi_buf_alloc(wmi_handle, len);
1368 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301369 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301370
1371 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1372 WMITLV_SET_HDR(&cmd->tlv_header,
1373 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1374 WMITLV_GET_STRUCT_TLVLEN
1375 (wmi_pdev_suspend_cmd_fixed_param));
1376 if (param->disable_target_intr)
1377 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1378 else
1379 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301380
1381 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1382
Govind Singh5eb51532016-03-09 11:34:12 +05301383 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1384 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301385 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301386 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301387 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301388 }
1389
1390 return ret;
1391}
1392
1393/**
1394 * send_resume_cmd_tlv() - WMI resume function
1395 * @param wmi_handle : handle to WMI.
1396 * @mac_id: radio context
1397 *
1398 * Return: 0 on success and -ve on failure.
1399 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301400static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301401 uint8_t mac_id)
1402{
1403 wmi_buf_t wmibuf;
1404 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301405 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301406
1407 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1408 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301409 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301410 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1411 WMITLV_SET_HDR(&cmd->tlv_header,
1412 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1413 WMITLV_GET_STRUCT_TLVLEN
1414 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301415 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301416 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1417 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301418 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301419 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301420 wmi_buf_free(wmibuf);
1421 }
1422
1423 return ret;
1424}
1425
Will Huang422ac9a2017-11-17 13:19:16 +08001426#ifdef FEATURE_WLAN_D0WOW
1427/**
1428 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1429 * @param wmi_handle: handle to WMI.
1430 * @mac_id: radio context
1431 *
1432 * Return: 0 on success and error code on failure.
1433 */
1434static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1435 uint8_t mac_id)
1436{
1437 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1438 wmi_buf_t buf;
1439 int32_t len;
1440 QDF_STATUS status;
1441
1442 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1443
1444 buf = wmi_buf_alloc(wmi_handle, len);
1445 if (!buf) {
1446 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1447 return QDF_STATUS_E_NOMEM;
1448 }
1449 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1450 WMITLV_SET_HDR(&cmd->tlv_header,
1451 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1452 WMITLV_GET_STRUCT_TLVLEN
1453 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1454
1455 cmd->enable = true;
1456
1457 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1458 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1459 if (QDF_IS_STATUS_ERROR(status))
1460 wmi_buf_free(buf);
1461
1462 return status;
1463}
1464
1465/**
1466 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1467 * @param wmi_handle: handle to WMI.
1468 * @mac_id: radio context
1469 *
1470 * Return: 0 on success and error code on failure.
1471 */
1472static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1473 uint8_t mac_id)
1474{
1475 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1476 wmi_buf_t buf;
1477 int32_t len;
1478 QDF_STATUS status;
1479
1480 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1481
1482 buf = wmi_buf_alloc(wmi_handle, len);
1483 if (!buf) {
1484 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1485 return QDF_STATUS_E_NOMEM;
1486 }
1487 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1488 WMITLV_SET_HDR(&cmd->tlv_header,
1489 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1490 WMITLV_GET_STRUCT_TLVLEN
1491 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1492
1493 cmd->enable = false;
1494
1495 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1496 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1497 if (QDF_IS_STATUS_ERROR(status))
1498 wmi_buf_free(buf);
1499
1500 return status;
1501}
1502#endif
1503
Govind Singh5eb51532016-03-09 11:34:12 +05301504/**
1505 * send_wow_enable_cmd_tlv() - WMI wow enable function
1506 * @param wmi_handle : handle to WMI.
1507 * @param param : pointer to hold wow enable parameter
1508 * @mac_id: radio context
1509 *
1510 * Return: 0 on success and -ve on failure.
1511 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301512static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301513 struct wow_cmd_params *param,
1514 uint8_t mac_id)
1515{
1516 wmi_wow_enable_cmd_fixed_param *cmd;
1517 wmi_buf_t buf;
1518 int32_t len;
1519 int32_t ret;
1520
1521 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1522
1523 buf = wmi_buf_alloc(wmi_handle, len);
1524 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301525 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1526 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301527 }
1528 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1529 WMITLV_SET_HDR(&cmd->tlv_header,
1530 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1531 WMITLV_GET_STRUCT_TLVLEN
1532 (wmi_wow_enable_cmd_fixed_param));
1533 cmd->enable = param->enable;
1534 if (param->can_suspend_link)
1535 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1536 else
1537 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001538 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301539
Govind Singhb53420c2016-03-09 14:32:57 +05301540 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301541 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1542 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1543
1544 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1545 WMI_WOW_ENABLE_CMDID);
1546 if (ret)
1547 wmi_buf_free(buf);
1548
1549 return ret;
1550}
1551
1552/**
1553 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301554 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301555 * @peer_addr: peer mac address
1556 * @param: pointer to ap_ps parameter structure
1557 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301558 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301559 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301560static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301561 uint8_t *peer_addr,
1562 struct ap_ps_params *param)
1563{
1564 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1565 wmi_buf_t buf;
1566 int32_t err;
1567
1568 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1569 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301570 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301571 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301572 }
1573 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1574 WMITLV_SET_HDR(&cmd->tlv_header,
1575 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1576 WMITLV_GET_STRUCT_TLVLEN
1577 (wmi_ap_ps_peer_cmd_fixed_param));
1578 cmd->vdev_id = param->vdev_id;
1579 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1580 cmd->param = param->param;
1581 cmd->value = param->value;
1582 err = wmi_unified_cmd_send(wmi_handle, buf,
1583 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1584 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301585 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301586 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301587 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301588 }
1589
1590 return 0;
1591}
1592
1593/**
1594 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301595 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301596 * @peer_addr: peer mac address
1597 * @param: pointer to sta_ps parameter structure
1598 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301599 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301600 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301601static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301602 struct sta_ps_params *param)
1603{
1604 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1605 wmi_buf_t buf;
1606 int32_t len = sizeof(*cmd);
1607
1608 buf = wmi_buf_alloc(wmi_handle, len);
1609 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301610 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301611 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301612 }
1613
1614 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1615 WMITLV_SET_HDR(&cmd->tlv_header,
1616 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1617 WMITLV_GET_STRUCT_TLVLEN
1618 (wmi_sta_powersave_param_cmd_fixed_param));
1619 cmd->vdev_id = param->vdev_id;
1620 cmd->param = param->param;
1621 cmd->value = param->value;
1622
1623 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1624 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301625 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301626 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301627 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301628 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301629 }
1630
1631 return 0;
1632}
1633
1634/**
1635 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301636 * @wmi_handle: wmi handle
Jeff Johnsonbbd428c2018-05-06 17:02:16 -07001637 * @param: ponirt to crash inject parameter structure
Govind Singh5eb51532016-03-09 11:34:12 +05301638 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301639 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301640 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301641static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301642 struct crash_inject *param)
1643{
1644 int32_t ret = 0;
1645 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1646 uint16_t len = sizeof(*cmd);
1647 wmi_buf_t buf;
1648
1649 buf = wmi_buf_alloc(wmi_handle, len);
1650 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301651 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301652 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301653 }
1654
1655 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1656 WMITLV_SET_HDR(&cmd->tlv_header,
1657 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1658 WMITLV_GET_STRUCT_TLVLEN
1659 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1660 cmd->type = param->type;
1661 cmd->delay_time_ms = param->delay_time_ms;
1662
1663 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1664 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301665 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301666 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301667 __func__, ret);
1668 wmi_buf_free(buf);
1669 }
1670
1671 return ret;
1672}
1673
Wen Gongca174012018-04-20 16:56:28 +08001674#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +05301675/**
1676 * send_dbglog_cmd_tlv() - set debug log level
1677 * @param wmi_handle : handle to WMI.
1678 * @param param : pointer to hold dbglog level parameter
1679 *
1680 * Return: 0 on success and -ve on failure.
1681 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301682 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301683send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1684 struct dbglog_params *dbglog_param)
1685{
1686 wmi_buf_t buf;
1687 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001688 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301689 int32_t i;
1690 int32_t len;
1691 int8_t *buf_ptr;
1692 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1693
Alok Kumar240afea2017-08-30 14:45:34 +05301694 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301695
1696 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1697 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1698 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1699 buf = wmi_buf_alloc(wmi_handle, len);
1700 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001701 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301702
1703 configmsg =
1704 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1705 buf_ptr = (int8_t *) configmsg;
1706 WMITLV_SET_HDR(&configmsg->tlv_header,
1707 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1708 WMITLV_GET_STRUCT_TLVLEN
1709 (wmi_debug_log_config_cmd_fixed_param));
1710 configmsg->dbg_log_param = dbglog_param->param;
1711 configmsg->value = dbglog_param->val;
1712 /* Filling in the data part of second tlv -- should
1713 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301714 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301715 sizeof
1716 (wmi_debug_log_config_cmd_fixed_param)
1717 + WMI_TLV_HDR_SIZE);
1718 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1719 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301720 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301721 if (dbglog_param->module_id_bitmap) {
1722 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1723 module_id_bitmap_array[i] =
1724 dbglog_param->module_id_bitmap[i];
1725 }
1726 }
1727
1728 status = wmi_unified_cmd_send(wmi_handle, buf,
1729 len, WMI_DBGLOG_CFG_CMDID);
1730
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001731 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301732 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301733
1734 return status;
1735}
Wen Gongca174012018-04-20 16:56:28 +08001736#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301737
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301738#ifdef CONFIG_MCL
1739static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1740 uint32_t host_param)
1741{
1742 return host_param;
1743}
1744#else
1745static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1746 uint32_t host_param)
1747{
1748 if (host_param < wmi_vdev_param_max)
1749 return wmi_handle->vdev_param[host_param];
1750
1751 return WMI_UNAVAILABLE_PARAM;
1752}
1753#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301754/**
1755 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1756 * @param wmi_handle : handle to WMI.
1757 * @param macaddr : MAC address
1758 * @param param : pointer to hold vdev set parameter
1759 *
1760 * Return: 0 on success and -ve on failure.
1761 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301762static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301763 struct vdev_set_params *param)
1764{
Govind Singh67922e82016-04-01 16:48:57 +05301765 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301766 wmi_vdev_set_param_cmd_fixed_param *cmd;
1767 wmi_buf_t buf;
1768 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301769 uint32_t vdev_param;
1770
1771 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1772 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1773 WMI_LOGW("%s:Vdev param %d not available", __func__,
1774 param->param_id);
1775 return QDF_STATUS_E_INVAL;
1776
1777 }
Govind Singh5eb51532016-03-09 11:34:12 +05301778
1779 buf = wmi_buf_alloc(wmi_handle, len);
1780 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301781 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301782 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301783 }
1784 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1785 WMITLV_SET_HDR(&cmd->tlv_header,
1786 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1787 WMITLV_GET_STRUCT_TLVLEN
1788 (wmi_vdev_set_param_cmd_fixed_param));
1789 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301790 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301791 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301792 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001793 cmd->vdev_id, cmd->param_id, cmd->param_value);
Govind Singh5eb51532016-03-09 11:34:12 +05301794 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1795 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301796 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301797 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301798 wmi_buf_free(buf);
1799 }
1800
1801 return ret;
1802}
1803
1804/**
1805 * send_stats_request_cmd_tlv() - WMI request stats function
1806 * @param wmi_handle : handle to WMI.
1807 * @param macaddr : MAC address
1808 * @param param : pointer to hold stats request parameter
1809 *
1810 * Return: 0 on success and -ve on failure.
1811 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301812static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301813 uint8_t macaddr[IEEE80211_ADDR_LEN],
1814 struct stats_request_params *param)
1815{
Govind Singhd3156eb2016-02-26 17:50:39 +05301816 int32_t ret;
1817 wmi_request_stats_cmd_fixed_param *cmd;
1818 wmi_buf_t buf;
1819 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1820
1821 buf = wmi_buf_alloc(wmi_handle, len);
1822 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301823 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1824 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301825 }
1826
1827 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1828 WMITLV_SET_HDR(&cmd->tlv_header,
1829 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1830 WMITLV_GET_STRUCT_TLVLEN
1831 (wmi_request_stats_cmd_fixed_param));
1832 cmd->stats_id = param->stats_id;
1833 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301834 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1835 param->pdev_id);
1836 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001837
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301838 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1839 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001840
1841 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1842 WMI_REQUEST_STATS_CMDID);
1843
Govind Singhd3156eb2016-02-26 17:50:39 +05301844 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301845 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301846 wmi_buf_free(buf);
1847 }
1848
1849 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301850}
1851
Govind Singh87542482016-06-08 19:40:11 +05301852#ifdef CONFIG_WIN
1853/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001854 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301855 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001856 * @param PKTLOG_EVENT : packet log event
1857 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301858 *
1859 * Return: 0 on success and -ve on failure.
1860 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301861static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001862 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301863{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001864 int32_t ret;
1865 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1866 wmi_buf_t buf;
1867 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1868
1869 buf = wmi_buf_alloc(wmi_handle, len);
1870 if (!buf) {
1871 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1872 return -QDF_STATUS_E_NOMEM;
1873 }
1874
1875 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1876 WMITLV_SET_HDR(&cmd->tlv_header,
1877 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1878 WMITLV_GET_STRUCT_TLVLEN
1879 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1880 cmd->evlist = PKTLOG_EVENT;
1881 cmd->pdev_id = mac_id;
1882 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1883 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1884 if (ret) {
1885 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1886 wmi_buf_free(buf);
1887 }
1888
1889 return ret;
1890}
1891
1892/**
1893 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1894 * @param wmi_handle : handle to WMI.
1895 * @mac_id: mac id to have radio context
1896 *
1897 * Return: 0 on success and -ve on failure.
1898 */
1899static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001900 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001901{
1902 int32_t ret;
1903 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1904 wmi_buf_t buf;
1905 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1906
1907 buf = wmi_buf_alloc(wmi_handle, len);
1908 if (!buf) {
1909 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1910 return -QDF_STATUS_E_NOMEM;
1911 }
1912
1913 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1914 WMITLV_SET_HDR(&cmd->tlv_header,
1915 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1916 WMITLV_GET_STRUCT_TLVLEN
1917 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1918 cmd->pdev_id = mac_id;
1919 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1920 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1921 if (ret) {
1922 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1923 wmi_buf_free(buf);
1924 }
1925
1926 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301927}
1928#else
Govind Singh5eb51532016-03-09 11:34:12 +05301929/**
Keyur Parekhde522342017-08-18 14:01:05 -07001930 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1931 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301932 * @param wmi_handle : handle to WMI.
1933 * @param macaddr : MAC address
1934 * @param param : pointer to hold stats request parameter
1935 *
1936 * Return: 0 on success and -ve on failure.
1937 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301938static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301939 uint8_t macaddr[IEEE80211_ADDR_LEN],
1940 struct packet_enable_params *param)
1941{
1942 return 0;
1943}
Keyur Parekhde522342017-08-18 14:01:05 -07001944/**
1945 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1946 * packet-log
1947 * @param wmi_handle : handle to WMI.
1948 * @mac_id: mac id to have radio context
1949 *
1950 * Return: 0 on success and -ve on failure.
1951 */
1952static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1953 uint8_t mac_id)
1954{
1955 return 0;
1956}
Govind Singh87542482016-06-08 19:40:11 +05301957#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301958
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301959#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1960/**
1961 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1962 * sync time between bwtween host and firmware
1963 * @param wmi_handle : handle to WMI.
1964 *
1965 * Return: None
1966 */
1967static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1968{
1969 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07001970 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301971 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1972 int32_t len;
1973 qdf_time_t time_ms;
1974
1975 len = sizeof(*time_stamp);
1976 buf = wmi_buf_alloc(wmi_handle, len);
1977
1978 if (!buf) {
1979 WMI_LOGP(FL("wmi_buf_alloc failed"));
1980 return;
1981 }
1982 time_stamp =
1983 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1984 (wmi_buf_data(buf));
1985 WMITLV_SET_HDR(&time_stamp->tlv_header,
1986 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1987 WMITLV_GET_STRUCT_TLVLEN(
1988 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1989
1990 time_ms = qdf_get_time_of_the_day_ms();
1991 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1992 time_stamp->time_stamp_low = time_ms &
1993 WMI_FW_TIME_STAMP_LOW_MASK;
1994 /*
1995 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1996 * wont exceed 27 bit
1997 */
1998 time_stamp->time_stamp_high = 0;
1999 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
2000 time_stamp->mode, time_stamp->time_stamp_low,
2001 time_stamp->time_stamp_high);
2002
2003 status = wmi_unified_cmd_send(wmi_handle, buf,
2004 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
2005 if (status) {
2006 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
2007 wmi_buf_free(buf);
2008 }
2009
2010}
2011
Subrat Mishrad7c7a562017-09-27 14:41:20 +05302012#ifdef WLAN_SUPPORT_FILS
2013/**
2014 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
2015 * @wmi_handle: wmi handle
2016 * @evt_buf: pointer to event buffer
2017 * @vdev_id: pointer to hold vdev id
2018 *
2019 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
2020 */
2021static QDF_STATUS
2022extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
2023 void *evt_buf, uint32_t *vdev_id)
2024{
2025 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
2026 wmi_host_swfda_event_fixed_param *swfda_event;
2027
2028 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
2029 if (!param_buf) {
2030 WMI_LOGE("Invalid swfda event buffer");
2031 return QDF_STATUS_E_INVAL;
2032 }
2033 swfda_event = param_buf->fixed_param;
2034 *vdev_id = swfda_event->vdev_id;
2035
2036 return QDF_STATUS_SUCCESS;
2037}
2038
2039/**
2040 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
2041 * @wmi_handle: wmi handle
2042 * @param: pointer to hold FILS discovery enable param
2043 *
2044 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
2045 */
2046static QDF_STATUS
2047send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
2048 struct config_fils_params *param)
2049{
2050 wmi_enable_fils_cmd_fixed_param *cmd;
2051 wmi_buf_t buf;
2052 QDF_STATUS status;
2053 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
2054
2055 buf = wmi_buf_alloc(wmi_handle, len);
2056 if (!buf) {
2057 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2058 return QDF_STATUS_E_NOMEM;
2059 }
2060 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
2061 WMITLV_SET_HDR(&cmd->tlv_header,
2062 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
2063 WMITLV_GET_STRUCT_TLVLEN(
2064 wmi_enable_fils_cmd_fixed_param));
2065 cmd->vdev_id = param->vdev_id;
2066 cmd->fd_period = param->fd_period;
2067 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
2068 param->fd_period, param->vdev_id);
2069
2070 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2071 WMI_ENABLE_FILS_CMDID);
2072 if (status != QDF_STATUS_SUCCESS) {
2073 wmi_buf_free(buf);
2074 return QDF_STATUS_E_FAILURE;
2075 }
2076
2077 return QDF_STATUS_SUCCESS;
2078}
2079
2080/**
2081 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
2082 * @wmi_handle: wmi handle
2083 * @param: pointer to hold FD send cmd parameter
2084 *
2085 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
2086 */
2087static QDF_STATUS
2088send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
2089 struct fd_params *param)
2090{
2091 QDF_STATUS ret;
2092 wmi_fd_send_from_host_cmd_fixed_param *cmd;
2093 wmi_buf_t wmi_buf;
2094 qdf_dma_addr_t dma_addr;
2095
2096 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2097 if (!wmi_buf) {
2098 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2099 return QDF_STATUS_E_NOMEM;
2100 }
2101 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2102 WMITLV_SET_HDR(&cmd->tlv_header,
2103 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2104 WMITLV_GET_STRUCT_TLVLEN(
2105 wmi_fd_send_from_host_cmd_fixed_param));
2106 cmd->vdev_id = param->vdev_id;
2107 cmd->data_len = qdf_nbuf_len(param->wbuf);
2108 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2109 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2110 cmd->frame_ctrl = param->frame_ctrl;
2111
2112 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2113 WMI_PDEV_SEND_FD_CMDID);
2114 if (ret != QDF_STATUS_SUCCESS) {
2115 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2116 __func__, ret);
2117 wmi_buf_free(wmi_buf);
2118 }
2119
2120 return ret;
2121}
2122#endif /* WLAN_SUPPORT_FILS */
2123
Sathish Kumarfd347372017-02-13 12:29:09 +05302124static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302125 struct beacon_params *param)
2126{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302127 QDF_STATUS ret;
2128 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2129 wmi_buf_t wmi_buf;
2130 qdf_dma_addr_t dma_addr;
2131 uint32_t dtim_flag = 0;
2132
2133 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2134 if (!wmi_buf) {
2135 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2136 return QDF_STATUS_E_NOMEM;
2137 }
2138 if (param->is_dtim_count_zero) {
2139 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2140 if (param->is_bitctl_reqd) {
2141 /* deliver CAB traffic in next DTIM beacon */
2142 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2143 }
2144 }
2145 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2146 WMITLV_SET_HDR(&cmd->tlv_header,
2147 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2148 WMITLV_GET_STRUCT_TLVLEN
2149 (wmi_bcn_send_from_host_cmd_fixed_param));
2150 cmd->vdev_id = param->vdev_id;
2151 cmd->data_len = qdf_nbuf_len(param->wbuf);
2152 cmd->frame_ctrl = param->frame_ctrl;
2153 cmd->dtim_flag = dtim_flag;
2154 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2155 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2156#if defined(HTT_PADDR64)
2157 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2158#endif
2159 cmd->bcn_antenna = param->bcn_txant;
2160
2161 ret = wmi_unified_cmd_send(wmi_handle,
2162 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2163 if (ret != QDF_STATUS_SUCCESS) {
2164 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2165 wmi_buf_free(wmi_buf);
2166 }
2167
2168 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302169}
2170
2171/**
2172 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2173 * @param wmi_handle : handle to WMI.
2174 * @param param : pointer to hold beacon send cmd parameter
2175 *
2176 * Return: 0 on success and -ve on failure.
2177 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302178static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302179 struct beacon_tmpl_params *param)
2180{
2181 int32_t ret;
2182 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2183 wmi_bcn_prb_info *bcn_prb_info;
2184 wmi_buf_t wmi_buf;
2185 uint8_t *buf_ptr;
2186 uint32_t wmi_buf_len;
2187
2188 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2189 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2190 param->tmpl_len_aligned;
2191 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2192 if (!wmi_buf) {
2193 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2194 return QDF_STATUS_E_NOMEM;
2195 }
2196 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2197 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2198 WMITLV_SET_HDR(&cmd->tlv_header,
2199 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2200 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2201 cmd->vdev_id = param->vdev_id;
2202 cmd->tim_ie_offset = param->tim_ie_offset;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -07002203 cmd->mbssid_ie_offset = param->mbssid_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302204 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2205 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Subrat Mishraa667b1c2018-08-02 15:02:04 +05302206 cmd->esp_ie_offset = param->esp_ie_offset;
Govind Singh87542482016-06-08 19:40:11 +05302207 cmd->buf_len = param->tmpl_len;
2208 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2209
2210 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2211 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2212 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2213 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2214 bcn_prb_info->caps = 0;
2215 bcn_prb_info->erp = 0;
2216 buf_ptr += sizeof(wmi_bcn_prb_info);
2217
2218 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2219 buf_ptr += WMI_TLV_HDR_SIZE;
2220 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2221
2222 ret = wmi_unified_cmd_send(wmi_handle,
2223 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2224 if (ret) {
2225 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2226 wmi_buf_free(wmi_buf);
2227 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302228
Govind Singh87542482016-06-08 19:40:11 +05302229 return 0;
2230}
Govind Singh5eb51532016-03-09 11:34:12 +05302231
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302232#ifdef CONFIG_MCL
2233static inline void copy_peer_flags_tlv(
2234 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2235 struct peer_assoc_params *param)
2236{
2237 cmd->peer_flags = param->peer_flags;
2238}
2239#else
2240static inline void copy_peer_flags_tlv(
2241 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2242 struct peer_assoc_params *param)
2243{
2244 /*
2245 * The target only needs a subset of the flags maintained in the host.
2246 * Just populate those flags and send it down
2247 */
2248 cmd->peer_flags = 0;
2249
2250 /*
2251 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2252 */
2253 if (param->is_wme_set) {
2254
2255 if (param->qos_flag)
2256 cmd->peer_flags |= WMI_PEER_QOS;
2257 if (param->apsd_flag)
2258 cmd->peer_flags |= WMI_PEER_APSD;
2259 if (param->ht_flag)
2260 cmd->peer_flags |= WMI_PEER_HT;
2261 if (param->bw_40)
2262 cmd->peer_flags |= WMI_PEER_40MHZ;
2263 if (param->bw_80)
2264 cmd->peer_flags |= WMI_PEER_80MHZ;
2265 if (param->bw_160)
2266 cmd->peer_flags |= WMI_PEER_160MHZ;
2267
2268 /* Typically if STBC is enabled for VHT it should be enabled
2269 * for HT as well
2270 **/
2271 if (param->stbc_flag)
2272 cmd->peer_flags |= WMI_PEER_STBC;
2273
2274 /* Typically if LDPC is enabled for VHT it should be enabled
2275 * for HT as well
2276 **/
2277 if (param->ldpc_flag)
2278 cmd->peer_flags |= WMI_PEER_LDPC;
2279
2280 if (param->static_mimops_flag)
2281 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2282 if (param->dynamic_mimops_flag)
2283 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2284 if (param->spatial_mux_flag)
2285 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2286 if (param->vht_flag)
2287 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002288 if (param->he_flag)
2289 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302290 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002291
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302292 if (param->is_pmf_enabled)
2293 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302294 /*
2295 * Suppress authorization for all AUTH modes that need 4-way handshake
2296 * (during re-association).
2297 * Authorization will be done for these modes on key installation.
2298 */
2299 if (param->auth_flag)
2300 cmd->peer_flags |= WMI_PEER_AUTH;
2301 if (param->need_ptk_4_way)
2302 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2303 else
2304 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2305 if (param->need_gtk_2_way)
2306 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2307 /* safe mode bypass the 4-way handshake */
2308 if (param->safe_mode_enabled)
2309 cmd->peer_flags &=
2310 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2311 /* Disable AMSDU for station transmit, if user configures it */
2312 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2313 * it
2314 * if (param->amsdu_disable) Add after FW support
2315 **/
2316
2317 /* Target asserts if node is marked HT and all MCS is set to 0.
2318 * Mark the node as non-HT if all the mcs rates are disabled through
2319 * iwpriv
2320 **/
2321 if (param->peer_ht_rates.num_rates == 0)
2322 cmd->peer_flags &= ~WMI_PEER_HT;
Kiran Venkatappa54c2afd2018-07-30 12:04:42 +05302323
2324 if (param->twt_requester)
2325 cmd->peer_flags |= WMI_PEER_TWT_REQ;
2326
2327 if (param->twt_responder)
2328 cmd->peer_flags |= WMI_PEER_TWT_RESP;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302329}
2330#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302331
2332#ifdef CONFIG_MCL
2333static inline void copy_peer_mac_addr_tlv(
2334 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2335 struct peer_assoc_params *param)
2336{
2337 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2338 sizeof(param->peer_macaddr));
2339}
2340#else
2341static inline void copy_peer_mac_addr_tlv(
2342 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2343 struct peer_assoc_params *param)
2344{
2345 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2346}
2347#endif
2348
Govind Singh5eb51532016-03-09 11:34:12 +05302349/**
2350 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2351 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302352 * @param param : pointer to peer assoc parameter
2353 *
2354 * Return: 0 on success and -ve on failure.
2355 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302356static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302357 struct peer_assoc_params *param)
2358{
Govind Singhd3156eb2016-02-26 17:50:39 +05302359 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2360 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002361 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302362 wmi_buf_t buf;
2363 int32_t len;
2364 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302365 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302366 uint32_t peer_legacy_rates_align;
2367 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002368 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302369
2370
2371 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2372 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302373
2374 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002375 (peer_legacy_rates_align * sizeof(uint8_t)) +
2376 WMI_TLV_HDR_SIZE +
2377 (peer_ht_rates_align * sizeof(uint8_t)) +
2378 sizeof(wmi_vht_rate_set) +
2379 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2380 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302381
2382 buf = wmi_buf_alloc(wmi_handle, len);
2383 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302384 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302385 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302386 }
2387
2388 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2389 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2390 WMITLV_SET_HDR(&cmd->tlv_header,
2391 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2392 WMITLV_GET_STRUCT_TLVLEN
2393 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302394
Govind Singhd3156eb2016-02-26 17:50:39 +05302395 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302396
Govind Singhd3156eb2016-02-26 17:50:39 +05302397 cmd->peer_new_assoc = param->peer_new_assoc;
2398 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302399
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302400 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302401 copy_peer_mac_addr_tlv(cmd, param);
2402
Govind Singhd3156eb2016-02-26 17:50:39 +05302403 cmd->peer_rate_caps = param->peer_rate_caps;
2404 cmd->peer_caps = param->peer_caps;
2405 cmd->peer_listen_intval = param->peer_listen_intval;
2406 cmd->peer_ht_caps = param->peer_ht_caps;
2407 cmd->peer_max_mpdu = param->peer_max_mpdu;
2408 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302409 cmd->peer_vht_caps = param->peer_vht_caps;
2410 cmd->peer_phymode = param->peer_phymode;
2411
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002412 /* Update 11ax capabilities */
2413 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2414 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002415 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2416 sizeof(param->peer_he_cap_phyinfo));
2417 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2418 sizeof(param->peer_ppet));
2419
Govind Singhd3156eb2016-02-26 17:50:39 +05302420 /* Update peer legacy rate information */
2421 buf_ptr += sizeof(*cmd);
2422 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302423 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302424 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302425 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302426 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302427 param->peer_legacy_rates.num_rates);
2428
2429 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002430 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302431 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302432 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302433 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302434 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302435 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302436 param->peer_ht_rates.num_rates);
2437
2438 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002439 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302440 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2441 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2442
2443 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302444
2445 /* Update bandwidth-NSS mapping */
2446 cmd->peer_bw_rxnss_override = 0;
2447 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2448
Govind Singhd3156eb2016-02-26 17:50:39 +05302449 mcs = (wmi_vht_rate_set *) buf_ptr;
2450 if (param->vht_capable) {
2451 mcs->rx_max_rate = param->rx_max_rate;
2452 mcs->rx_mcs_set = param->rx_mcs_set;
2453 mcs->tx_max_rate = param->tx_max_rate;
2454 mcs->tx_mcs_set = param->tx_mcs_set;
2455 }
2456
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002457 /* HE Rates */
2458 cmd->peer_he_mcs = param->peer_he_mcs_count;
2459 buf_ptr += sizeof(wmi_vht_rate_set);
2460 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2461 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2462 buf_ptr += WMI_TLV_HDR_SIZE;
2463
2464 /* Loop through the HE rate set */
2465 for (i = 0; i < param->peer_he_mcs_count; i++) {
2466 he_mcs = (wmi_he_rate_set *) buf_ptr;
2467 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2468 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2469
2470 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2471 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2472 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2473 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2474 buf_ptr += sizeof(wmi_he_rate_set);
2475 }
2476
2477
Govind Singhb53420c2016-03-09 14:32:57 +05302478 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302479 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2480 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002481 "cmd->peer_vht_caps %x "
2482 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302483 "HE phy %x %x %x "
2484 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302485 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2486 cmd->peer_rate_caps, cmd->peer_caps,
2487 cmd->peer_listen_intval, cmd->peer_ht_caps,
2488 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2489 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002490 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2491 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302492 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2493 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302494
2495 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2496 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302497 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302498 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302499 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302500 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302501 }
2502
2503 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302504}
2505
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302506/* copy_scan_notify_events() - Helper routine to copy scan notify events
2507 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302508static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302509 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302510 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302511{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302512
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302513 /* Scan events subscription */
2514 if (param->scan_ev_started)
2515 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2516 if (param->scan_ev_completed)
2517 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2518 if (param->scan_ev_bss_chan)
2519 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2520 if (param->scan_ev_foreign_chan)
2521 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2522 if (param->scan_ev_dequeued)
2523 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2524 if (param->scan_ev_preempted)
2525 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2526 if (param->scan_ev_start_failed)
2527 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2528 if (param->scan_ev_restarted)
2529 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2530 if (param->scan_ev_foreign_chn_exit)
2531 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2532 if (param->scan_ev_suspended)
2533 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2534 if (param->scan_ev_resumed)
2535 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302536
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302537 /** Set scan control flags */
2538 cmd->scan_ctrl_flags = 0;
2539 if (param->scan_f_passive)
2540 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2541 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302542 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302543 if (param->scan_f_promisc_mode)
2544 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2545 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302546 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302547 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302548 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302549 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302550 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302551 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302552 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302553 if (param->scan_f_ofdm_rates)
2554 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2555 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302556 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302557 if (param->scan_f_filter_prb_req)
2558 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2559 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302560 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302561 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302562 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302563 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302564 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302565 if (param->scan_f_force_active_dfs_chn)
2566 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2567 if (param->scan_f_add_tpc_ie_in_probe)
2568 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2569 if (param->scan_f_add_ds_ie_in_probe)
2570 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2571 if (param->scan_f_add_spoofed_mac_in_probe)
2572 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2573 if (param->scan_f_add_rand_seq_in_probe)
2574 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2575 if (param->scan_f_en_ie_whitelist_in_probe)
2576 cmd->scan_ctrl_flags |=
2577 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302578
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302579 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2580 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2581 param->adaptive_dwell_time_mode);
2582}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302583
2584/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302585static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302586 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302587{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302588 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302589}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302590
Govind Singh5eb51532016-03-09 11:34:12 +05302591/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302592 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2593 * @mac: random mac addr
2594 * @mask: random mac mask
2595 * @mac_addr: wmi random mac
2596 * @mac_mask: wmi random mac mask
2597 *
2598 * Return None.
2599 */
2600static inline
2601void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2602 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2603{
2604 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2605 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2606}
2607
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302608/*
2609 * wmi_fill_vendor_oui() - fill vendor OUIs
2610 * @buf_ptr: pointer to wmi tlv buffer
2611 * @num_vendor_oui: number of vendor OUIs to be filled
2612 * @param_voui: pointer to OUI buffer
2613 *
2614 * This function populates the wmi tlv buffer when vendor specific OUIs are
2615 * present.
2616 *
2617 * Return: None
2618 */
2619static inline
2620void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2621 uint32_t *pvoui)
2622{
2623 wmi_vendor_oui *voui = NULL;
2624 uint32_t i;
2625
2626 voui = (wmi_vendor_oui *)buf_ptr;
2627
2628 for (i = 0; i < num_vendor_oui; i++) {
2629 WMITLV_SET_HDR(&voui[i].tlv_header,
2630 WMITLV_TAG_STRUC_wmi_vendor_oui,
2631 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2632 voui[i].oui_type_subtype = pvoui[i];
2633 }
2634}
2635
2636/*
2637 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2638 * @ie_bitmap: output pointer to ie bit map in cmd
2639 * @num_vendor_oui: output pointer to num vendor OUIs
2640 * @ie_whitelist: input parameter
2641 *
2642 * This function populates the IE whitelist attrs of scan, pno and
2643 * scan oui commands for ie_whitelist parameter.
2644 *
2645 * Return: None
2646 */
2647static inline
2648void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2649 uint32_t *num_vendor_oui,
2650 struct probe_req_whitelist_attr *ie_whitelist)
2651{
2652 uint32_t i = 0;
2653
2654 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2655 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2656
2657 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2658}
2659
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302660/**
Govind Singh5eb51532016-03-09 11:34:12 +05302661 * send_scan_start_cmd_tlv() - WMI scan start function
2662 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302663 * @param param : pointer to hold scan start cmd parameter
2664 *
2665 * Return: 0 on success and -ve on failure.
2666 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302667static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302668 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302669{
Govind Singhd3156eb2016-02-26 17:50:39 +05302670 int32_t ret = 0;
2671 int32_t i;
2672 wmi_buf_t wmi_buf;
2673 wmi_start_scan_cmd_fixed_param *cmd;
2674 uint8_t *buf_ptr;
2675 uint32_t *tmp_ptr;
2676 wmi_ssid *ssid = NULL;
2677 wmi_mac_addr *bssid;
2678 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302679 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302680 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302681 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302682
2683 /* Length TLV placeholder for array of uint32_t */
2684 len += WMI_TLV_HDR_SIZE;
2685 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302686 if (params->chan_list.num_chan)
2687 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302688
2689 /* Length TLV placeholder for array of wmi_ssid structures */
2690 len += WMI_TLV_HDR_SIZE;
2691 if (params->num_ssids)
2692 len += params->num_ssids * sizeof(wmi_ssid);
2693
2694 /* Length TLV placeholder for array of wmi_mac_addr structures */
2695 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302696 if (params->num_bssid)
2697 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302698
2699 /* Length TLV placeholder for array of bytes */
2700 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302701 if (params->extraie.len)
2702 extraie_len_with_pad =
2703 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002704 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302705
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302706 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2707 if (ie_whitelist->num_vendor_oui)
2708 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2709
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302710 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2711 if (params->scan_f_wide_band)
2712 phymode_roundup =
2713 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2714 sizeof(uint32_t));
2715 len += phymode_roundup;
2716
Govind Singhd3156eb2016-02-26 17:50:39 +05302717 /* Allocate the memory */
2718 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2719 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302720 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302721 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302722 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302723 }
2724 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2725 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2726 WMITLV_SET_HDR(&cmd->tlv_header,
2727 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2728 WMITLV_GET_STRUCT_TLVLEN
2729 (wmi_start_scan_cmd_fixed_param));
2730
2731 cmd->scan_id = params->scan_id;
2732 cmd->scan_req_id = params->scan_req_id;
2733 cmd->vdev_id = params->vdev_id;
2734 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302735
2736 copy_scan_event_cntrl_flags(cmd, params);
2737
Govind Singhd3156eb2016-02-26 17:50:39 +05302738 cmd->dwell_time_active = params->dwell_time_active;
Arif Hussain397f08c2018-07-23 18:10:34 -07002739 cmd->dwell_time_active_2g = params->dwell_time_active_2g;
Govind Singhd3156eb2016-02-26 17:50:39 +05302740 cmd->dwell_time_passive = params->dwell_time_passive;
2741 cmd->min_rest_time = params->min_rest_time;
2742 cmd->max_rest_time = params->max_rest_time;
2743 cmd->repeat_probe_time = params->repeat_probe_time;
2744 cmd->probe_spacing_time = params->probe_spacing_time;
2745 cmd->idle_time = params->idle_time;
2746 cmd->max_scan_time = params->max_scan_time;
2747 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302748 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302749 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302750 cmd->num_bssid = params->num_bssid;
2751 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302752 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302753 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302754 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2755
2756 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2757
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302758 if (params->scan_random.randomize)
2759 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2760 params->scan_random.mac_mask,
2761 &cmd->mac_addr,
2762 &cmd->mac_mask);
2763
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302764 if (ie_whitelist->white_list)
2765 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2766 &cmd->num_vendor_oui,
2767 ie_whitelist);
2768
Govind Singhd3156eb2016-02-26 17:50:39 +05302769 buf_ptr += sizeof(*cmd);
2770 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302771 for (i = 0; i < params->chan_list.num_chan; ++i)
2772 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302773
2774 WMITLV_SET_HDR(buf_ptr,
2775 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302776 (params->chan_list.num_chan * sizeof(uint32_t)));
2777 buf_ptr += WMI_TLV_HDR_SIZE +
2778 (params->chan_list.num_chan * sizeof(uint32_t));
2779
Govind Singh4eacd2b2016-03-07 14:24:22 +05302780 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302781 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302782 goto error;
2783 }
2784
2785 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2786 (params->num_ssids * sizeof(wmi_ssid)));
2787
2788 if (params->num_ssids) {
2789 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2790 for (i = 0; i < params->num_ssids; ++i) {
2791 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302792 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302793 params->ssid[i].length);
2794 ssid++;
2795 }
2796 }
2797 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2798
2799 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2800 (params->num_bssid * sizeof(wmi_mac_addr)));
2801 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302802
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302803 if (params->num_bssid) {
2804 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302805 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2806 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302807 bssid++;
2808 }
2809 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302810
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302811 buf_ptr += WMI_TLV_HDR_SIZE +
2812 (params->num_bssid * sizeof(wmi_mac_addr));
2813
2814 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2815 if (params->extraie.len)
2816 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2817 params);
2818
2819 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302820
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302821 /* probe req ie whitelisting */
2822 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2823 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2824
2825 buf_ptr += WMI_TLV_HDR_SIZE;
2826
2827 if (cmd->num_vendor_oui) {
2828 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2829 ie_whitelist->voui);
2830 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2831 }
2832
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302833 /* Add phy mode TLV if it's a wide band scan */
2834 if (params->scan_f_wide_band) {
2835 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2836 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2837 for (i = 0; i < params->chan_list.num_chan; ++i)
2838 buf_ptr[i] =
2839 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2840 buf_ptr += phymode_roundup;
2841 } else {
2842 /* Add ZERO legth phy mode TLV */
2843 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2844 }
2845
Santosh Anbu1e11b472018-03-07 15:33:27 +05302846 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002847 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302848 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302849 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302850 wmi_buf_free(wmi_buf);
2851 }
2852 return ret;
2853error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302854 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302855 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302856}
2857
2858/**
2859 * send_scan_stop_cmd_tlv() - WMI scan start function
2860 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302861 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302862 *
2863 * Return: 0 on success and -ve on failure.
2864 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302865static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302866 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302867{
Govind Singhd3156eb2016-02-26 17:50:39 +05302868 wmi_stop_scan_cmd_fixed_param *cmd;
2869 int ret;
2870 int len = sizeof(*cmd);
2871 wmi_buf_t wmi_buf;
2872
2873 /* Allocate the memory */
2874 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2875 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302876 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302877 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302878 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302879 goto error;
2880 }
2881
2882 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2883 WMITLV_SET_HDR(&cmd->tlv_header,
2884 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2885 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2886 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302887 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302888 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302889 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2890 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302891 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302892 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2893 /* Cancelling all scans */
2894 cmd->req_type = WMI_SCAN_STOP_ALL;
2895 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2896 /* Cancelling VAP scans */
2897 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2898 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2899 /* Cancelling specific scan */
2900 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302901 } else {
2902 WMI_LOGE("%s: Invalid Command : ", __func__);
2903 wmi_buf_free(wmi_buf);
2904 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302905 }
2906
Santosh Anbu1e11b472018-03-07 15:33:27 +05302907 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002908 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302909 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302910 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302911 wmi_buf_free(wmi_buf);
2912 }
2913
2914error:
2915 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302916}
2917
Govind Singh87542482016-06-08 19:40:11 +05302918#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302919/**
2920 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2921 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302922 * @param param : pointer to hold scan channel list parameter
2923 *
2924 * Return: 0 on success and -ve on failure.
2925 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302926static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302927 struct scan_chan_list_params *chan_list)
2928{
2929 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302930 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302931 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302932 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302933 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302934 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302935 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2936
2937 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2938 buf = wmi_buf_alloc(wmi_handle, len);
2939 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302940 WMI_LOGE("Failed to allocate memory");
2941 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302942 goto end;
2943 }
2944
2945 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2946 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2947 WMITLV_SET_HDR(&cmd->tlv_header,
2948 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2949 WMITLV_GET_STRUCT_TLVLEN
2950 (wmi_scan_chan_list_cmd_fixed_param));
2951
Govind Singhb53420c2016-03-09 14:32:57 +05302952 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302953
2954 cmd->num_scan_chans = chan_list->num_scan_chans;
2955 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2956 WMITLV_TAG_ARRAY_STRUC,
2957 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302958 chan_info = (wmi_channel_param *)
2959 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302960 tchan_info = chan_list->chan_info;
2961
2962 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2963 WMITLV_SET_HDR(&chan_info->tlv_header,
2964 WMITLV_TAG_STRUC_wmi_channel,
2965 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2966 chan_info->mhz = tchan_info->mhz;
2967 chan_info->band_center_freq1 =
2968 tchan_info->band_center_freq1;
2969 chan_info->band_center_freq2 =
2970 tchan_info->band_center_freq2;
2971 chan_info->info = tchan_info->info;
2972 chan_info->reg_info_1 = tchan_info->reg_info_1;
2973 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302974 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302975
2976 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2977 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2978 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2979 tchan_info++;
2980 chan_info++;
2981 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302982 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2983 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302984
Anish Natarajdd855152017-03-20 12:49:08 +05302985 qdf_status = wmi_unified_cmd_send(wmi_handle,
2986 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302987
Govind Singh67922e82016-04-01 16:48:57 +05302988 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302989 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302990 wmi_buf_free(buf);
2991 }
Govind Singh67922e82016-04-01 16:48:57 +05302992
Govind Singhd3156eb2016-02-26 17:50:39 +05302993end:
Govind Singhb53420c2016-03-09 14:32:57 +05302994 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302995}
Govind Singh87542482016-06-08 19:40:11 +05302996#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302997static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302998 struct scan_chan_list_params *chan_list)
2999{
3000 wmi_buf_t buf;
3001 QDF_STATUS qdf_status;
3002 wmi_scan_chan_list_cmd_fixed_param *cmd;
3003 int i;
3004 uint8_t *buf_ptr;
3005 wmi_channel *chan_info;
3006 struct channel_param *tchan_info;
3007 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05303008
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303009 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05303010 buf = wmi_buf_alloc(wmi_handle, len);
3011 if (!buf) {
3012 WMI_LOGE("Failed to allocate memory");
3013 qdf_status = QDF_STATUS_E_NOMEM;
3014 goto end;
3015 }
3016
3017 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3018 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
3019 WMITLV_SET_HDR(&cmd->tlv_header,
3020 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
3021 WMITLV_GET_STRUCT_TLVLEN
3022 (wmi_scan_chan_list_cmd_fixed_param));
3023
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303024 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05303025
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05303026 if (chan_list->append)
3027 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
3028
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303029 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3030 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303031 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05303032 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
3033 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303034 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05303035 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
3036 tchan_info = &(chan_list->ch_param[0]);
3037
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303038 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05303039 WMITLV_SET_HDR(&chan_info->tlv_header,
3040 WMITLV_TAG_STRUC_wmi_channel,
3041 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3042 chan_info->mhz = tchan_info->mhz;
3043 chan_info->band_center_freq1 =
3044 tchan_info->cfreq1;
3045 chan_info->band_center_freq2 =
3046 tchan_info->cfreq2;
3047
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303048 if (tchan_info->is_chan_passive)
3049 WMI_SET_CHANNEL_FLAG(chan_info,
3050 WMI_CHAN_FLAG_PASSIVE);
3051
3052 if (tchan_info->allow_vht)
3053 WMI_SET_CHANNEL_FLAG(chan_info,
3054 WMI_CHAN_FLAG_ALLOW_VHT);
3055 else if (tchan_info->allow_ht)
3056 WMI_SET_CHANNEL_FLAG(chan_info,
3057 WMI_CHAN_FLAG_ALLOW_HT);
3058 WMI_SET_CHANNEL_MODE(chan_info,
3059 tchan_info->phy_mode);
3060
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05303061 if (tchan_info->half_rate)
3062 WMI_SET_CHANNEL_FLAG(chan_info,
3063 WMI_CHAN_FLAG_HALF_RATE);
3064
3065 if (tchan_info->quarter_rate)
3066 WMI_SET_CHANNEL_FLAG(chan_info,
3067 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303068
3069 /* also fill in power information */
3070 WMI_SET_CHANNEL_MIN_POWER(chan_info,
3071 tchan_info->minpower);
3072 WMI_SET_CHANNEL_MAX_POWER(chan_info,
3073 tchan_info->maxpower);
3074 WMI_SET_CHANNEL_REG_POWER(chan_info,
3075 tchan_info->maxregpower);
3076 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
3077 tchan_info->antennamax);
3078 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
3079 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08003080 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
3081 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303082
Govind Singh87542482016-06-08 19:40:11 +05303083 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
3084
Govind Singh87542482016-06-08 19:40:11 +05303085 tchan_info++;
3086 chan_info++;
3087 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303088 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3089 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05303090
Anish Natarajdd855152017-03-20 12:49:08 +05303091 qdf_status = wmi_unified_cmd_send(
3092 wmi_handle,
3093 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05303094
3095 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3096 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
3097 wmi_buf_free(buf);
3098 }
3099
3100end:
3101 return qdf_status;
3102}
3103#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05303104
3105/**
3106 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3107 *
3108 * @bufp: Pointer to buffer
3109 * @param: Pointer to tx param
3110 *
3111 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3112 */
3113static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3114 struct tx_send_params param)
3115{
3116 wmi_tx_send_params *tx_param;
3117 QDF_STATUS status = QDF_STATUS_SUCCESS;
3118
3119 if (!bufp) {
3120 status = QDF_STATUS_E_FAILURE;
3121 return status;
3122 }
3123 tx_param = (wmi_tx_send_params *)bufp;
3124 WMITLV_SET_HDR(&tx_param->tlv_header,
3125 WMITLV_TAG_STRUC_wmi_tx_send_params,
3126 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3127 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3128 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3129 param.mcs_mask);
3130 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3131 param.nss_mask);
3132 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3133 param.retry_limit);
3134 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3135 param.chain_mask);
3136 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3137 param.bw_mask);
3138 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3139 param.preamble_type);
3140 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3141 param.frame_type);
3142
3143 return status;
3144}
3145
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303146#ifdef CONFIG_HL_SUPPORT
3147/**
3148 * send_mgmt_cmd_tlv() - WMI scan start function
3149 * @wmi_handle : handle to WMI.
3150 * @param : pointer to hold mgmt cmd parameter
3151 *
3152 * Return: 0 on success and -ve on failure.
3153 */
3154static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
3155 struct wmi_mgmt_params *param)
3156{
3157 wmi_buf_t buf;
3158 uint8_t *bufp;
3159 int32_t cmd_len;
3160 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3161 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3162 mgmt_tx_dl_frm_len;
3163
3164 if (param->frm_len > mgmt_tx_dl_frm_len) {
3165 WMI_LOGE("%s:mgmt frame len %u exceeds %u",
3166 __func__, param->frm_len, mgmt_tx_dl_frm_len);
3167 return QDF_STATUS_E_INVAL;
3168 }
3169
3170 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
3171 WMI_TLV_HDR_SIZE +
3172 roundup(bufp_len, sizeof(uint32_t));
3173
3174 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
3175 if (!buf) {
3176 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3177 return QDF_STATUS_E_NOMEM;
3178 }
3179
3180 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3181 bufp = (uint8_t *) cmd;
3182 WMITLV_SET_HDR(&cmd->tlv_header,
3183 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3184 WMITLV_GET_STRUCT_TLVLEN
3185 (wmi_mgmt_tx_send_cmd_fixed_param));
3186
3187 cmd->vdev_id = param->vdev_id;
3188
3189 cmd->desc_id = param->desc_id;
3190 cmd->chanfreq = param->chanfreq;
3191 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3192 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3193 sizeof(uint32_t)));
3194 bufp += WMI_TLV_HDR_SIZE;
3195 qdf_mem_copy(bufp, param->pdata, bufp_len);
3196
3197 cmd->frame_len = param->frm_len;
3198 cmd->buf_len = bufp_len;
3199 cmd->tx_params_valid = param->tx_params_valid;
3200
3201 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
3202 bufp, cmd->vdev_id, cmd->chanfreq);
3203
3204 bufp += roundup(bufp_len, sizeof(uint32_t));
3205 if (param->tx_params_valid) {
3206 if (populate_tx_send_params(bufp, param->tx_param) !=
3207 QDF_STATUS_SUCCESS) {
3208 WMI_LOGE("%s: Populate TX send params failed",
3209 __func__);
3210 goto free_buf;
3211 }
3212 cmd_len += sizeof(wmi_tx_send_params);
3213 }
3214
3215 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3216 WMI_MGMT_TX_SEND_CMDID)) {
3217 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
3218 goto free_buf;
3219 }
3220 return QDF_STATUS_SUCCESS;
3221
3222free_buf:
3223 wmi_buf_free(buf);
3224 return QDF_STATUS_E_FAILURE;
3225}
3226#else
Govind Singhd3156eb2016-02-26 17:50:39 +05303227/**
3228 * send_mgmt_cmd_tlv() - WMI scan start function
3229 * @wmi_handle : handle to WMI.
3230 * @param : pointer to hold mgmt cmd parameter
3231 *
3232 * Return: 0 on success and -ve on failure.
3233 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303234static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303235 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303236{
Govind Singh427ee5a2016-02-26 18:09:36 +05303237 wmi_buf_t buf;
3238 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3239 int32_t cmd_len;
3240 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303241 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303242 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303243 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303244 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3245 mgmt_tx_dl_frm_len;
3246
3247 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303248 WMI_TLV_HDR_SIZE +
3249 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303250
Sathish Kumar5b636932017-06-28 14:40:32 +05303251 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303252 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303253 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3254 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303255 }
3256
3257 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3258 bufp = (uint8_t *) cmd;
3259 WMITLV_SET_HDR(&cmd->tlv_header,
3260 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3261 WMITLV_GET_STRUCT_TLVLEN
3262 (wmi_mgmt_tx_send_cmd_fixed_param));
3263
3264 cmd->vdev_id = param->vdev_id;
3265
Govind Singh224a7312016-06-21 14:33:26 +05303266 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303267 cmd->chanfreq = param->chanfreq;
3268 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3269 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3270 sizeof(uint32_t)));
3271 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303272 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303273
3274 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3275 QDF_DMA_TO_DEVICE);
3276 if (status != QDF_STATUS_SUCCESS) {
3277 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303278 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303279 }
3280
Govind Singhb53420c2016-03-09 14:32:57 +05303281 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303282 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003283#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303284 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3285#endif
3286 cmd->frame_len = param->frm_len;
3287 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303288 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303289
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003290 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003291 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003292
Sathish Kumar5b636932017-06-28 14:40:32 +05303293 bufp += roundup(bufp_len, sizeof(uint32_t));
3294 if (param->tx_params_valid) {
3295 status = populate_tx_send_params(bufp, param->tx_param);
3296 if (status != QDF_STATUS_SUCCESS) {
3297 WMI_LOGE("%s: Populate TX send params failed",
3298 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303299 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303300 }
3301 cmd_len += sizeof(wmi_tx_send_params);
3302 }
3303
Govind Singh427ee5a2016-02-26 18:09:36 +05303304 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3305 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303306 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303307 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303308 }
Govind Singhb53420c2016-03-09 14:32:57 +05303309 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303310
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303311unmap_tx_frame:
3312 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3313 QDF_DMA_TO_DEVICE);
3314free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303315 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303316 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303317}
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303318#endif /* CONFIG_HL_SUPPORT */
Govind Singh427ee5a2016-02-26 18:09:36 +05303319
3320/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303321 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3322 * @wmi_handle : handle to WMI.
3323 * @param : pointer to offchan data tx cmd parameter
3324 *
3325 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3326 */
3327static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3328 struct wmi_offchan_data_tx_params *param)
3329{
3330 wmi_buf_t buf;
3331 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3332 int32_t cmd_len;
3333 uint64_t dma_addr;
3334 void *qdf_ctx = param->qdf_ctx;
3335 uint8_t *bufp;
3336 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3337 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303338 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303339
3340 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303341 WMI_TLV_HDR_SIZE +
3342 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303343
Sathish Kumar5b636932017-06-28 14:40:32 +05303344 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303345 if (!buf) {
3346 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3347 return QDF_STATUS_E_NOMEM;
3348 }
3349
3350 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3351 bufp = (uint8_t *) cmd;
3352 WMITLV_SET_HDR(&cmd->tlv_header,
3353 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3354 WMITLV_GET_STRUCT_TLVLEN
3355 (wmi_offchan_data_tx_send_cmd_fixed_param));
3356
3357 cmd->vdev_id = param->vdev_id;
3358
3359 cmd->desc_id = param->desc_id;
3360 cmd->chanfreq = param->chanfreq;
3361 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3362 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3363 sizeof(uint32_t)));
3364 bufp += WMI_TLV_HDR_SIZE;
3365 qdf_mem_copy(bufp, param->pdata, bufp_len);
3366 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3367 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3368 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3369#if defined(HTT_PADDR64)
3370 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3371#endif
3372 cmd->frame_len = param->frm_len;
3373 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303374 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303375
3376 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3377 bufp, cmd->vdev_id, cmd->chanfreq);
3378
Sathish Kumar5b636932017-06-28 14:40:32 +05303379 bufp += roundup(bufp_len, sizeof(uint32_t));
3380 if (param->tx_params_valid) {
3381 status = populate_tx_send_params(bufp, param->tx_param);
3382 if (status != QDF_STATUS_SUCCESS) {
3383 WMI_LOGE("%s: Populate TX send params failed",
3384 __func__);
3385 goto err1;
3386 }
3387 cmd_len += sizeof(wmi_tx_send_params);
3388 }
3389
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303390 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3391 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3392 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303393 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303394 }
3395
3396 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303397
3398err1:
3399 wmi_buf_free(buf);
3400 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303401}
3402
3403/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303404 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3405 * @wmi_handle: wmi handle
3406 * @param_value: parameter value
3407 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303408 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303409 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303410static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303411 uint32_t param_value)
3412{
Govind Singh67922e82016-04-01 16:48:57 +05303413 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303414 wmi_modem_power_state_cmd_param *cmd;
3415 wmi_buf_t buf;
3416 uint16_t len = sizeof(*cmd);
3417
3418 buf = wmi_buf_alloc(wmi_handle, len);
3419 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303420 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303421 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303422 }
3423 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3424 WMITLV_SET_HDR(&cmd->tlv_header,
3425 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3426 WMITLV_GET_STRUCT_TLVLEN
3427 (wmi_modem_power_state_cmd_param));
3428 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303429 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303430 param_value);
3431 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3432 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303433 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303434 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303435 wmi_buf_free(buf);
3436 }
Govind Singh67922e82016-04-01 16:48:57 +05303437
Govind Singh427ee5a2016-02-26 18:09:36 +05303438 return ret;
3439}
3440
3441/**
3442 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3443 * @wmi_handle: wmi handle
3444 * @vdev_id: vdev id
3445 * @val: value
3446 *
Govind Singhe7f2f342016-05-23 12:12:52 +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_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303450 uint32_t vdev_id, uint8_t val)
3451{
3452 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3453 wmi_buf_t buf;
3454 int32_t len = sizeof(*cmd);
3455
Govind Singhb53420c2016-03-09 14:32:57 +05303456 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303457
3458 buf = wmi_buf_alloc(wmi_handle, len);
3459 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303460 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303461 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303462 }
3463 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3464 WMITLV_SET_HDR(&cmd->tlv_header,
3465 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3466 WMITLV_GET_STRUCT_TLVLEN
3467 (wmi_sta_powersave_mode_cmd_fixed_param));
3468 cmd->vdev_id = vdev_id;
3469 if (val)
3470 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3471 else
3472 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3473
3474 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3475 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303476 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303477 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303478 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303479 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303480 }
Govind Singh5eb51532016-03-09 11:34:12 +05303481 return 0;
3482}
3483
Govind Singh427ee5a2016-02-26 18:09:36 +05303484/**
3485 * send_set_mimops_cmd_tlv() - set MIMO powersave
3486 * @wmi_handle: wmi handle
3487 * @vdev_id: vdev id
3488 * @value: value
3489 *
Govind Singhb53420c2016-03-09 14:32:57 +05303490 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303491 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303492static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303493 uint8_t vdev_id, int value)
3494{
Govind Singh67922e82016-04-01 16:48:57 +05303495 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303496 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3497 wmi_buf_t buf;
3498 uint16_t len = sizeof(*cmd);
3499
3500 buf = wmi_buf_alloc(wmi_handle, len);
3501 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303502 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303503 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303504 }
3505 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3506 WMITLV_SET_HDR(&cmd->tlv_header,
3507 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3508 WMITLV_GET_STRUCT_TLVLEN
3509 (wmi_sta_smps_force_mode_cmd_fixed_param));
3510
3511 cmd->vdev_id = vdev_id;
3512
Houston Hoffmanb5168052016-04-14 02:18:01 -07003513 /* WMI_SMPS_FORCED_MODE values do not directly map
3514 * to SM power save values defined in the specification.
3515 * Make sure to send the right mapping.
3516 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303517 switch (value) {
3518 case 0:
3519 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3520 break;
3521 case 1:
3522 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3523 break;
3524 case 2:
3525 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3526 break;
3527 case 3:
3528 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3529 break;
3530 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303531 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303532 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303533 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303534 }
3535
Govind Singhb53420c2016-03-09 14:32:57 +05303536 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303537
3538 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3539 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303540 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303541 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303542 wmi_buf_free(buf);
3543 }
3544
3545 return ret;
3546}
3547
3548/**
3549 * send_set_smps_params_cmd_tlv() - set smps params
3550 * @wmi_handle: wmi handle
3551 * @vdev_id: vdev id
3552 * @value: value
3553 *
Govind Singhb53420c2016-03-09 14:32:57 +05303554 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303555 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303556static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303557 int value)
3558{
Govind Singh67922e82016-04-01 16:48:57 +05303559 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303560 wmi_sta_smps_param_cmd_fixed_param *cmd;
3561 wmi_buf_t buf;
3562 uint16_t len = sizeof(*cmd);
3563
3564 buf = wmi_buf_alloc(wmi_handle, len);
3565 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303566 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303567 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303568 }
3569 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3570 WMITLV_SET_HDR(&cmd->tlv_header,
3571 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3572 WMITLV_GET_STRUCT_TLVLEN
3573 (wmi_sta_smps_param_cmd_fixed_param));
3574
3575 cmd->vdev_id = vdev_id;
3576 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3577 cmd->param =
3578 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3579
Govind Singhb53420c2016-03-09 14:32:57 +05303580 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303581 cmd->param);
3582
3583 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3584 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303585 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303586 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303587 wmi_buf_free(buf);
3588 }
3589
3590 return ret;
3591}
3592
3593/**
3594 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3595 * @wmi_handle: wmi handle
3596 * @noa: p2p power save parameters
3597 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303598 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303599 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303600static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303601 struct p2p_ps_params *noa)
3602{
3603 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3604 wmi_p2p_noa_descriptor *noa_discriptor;
3605 wmi_buf_t buf;
3606 uint8_t *buf_ptr;
3607 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303608 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303609 uint32_t duration;
3610
Govind Singhb53420c2016-03-09 14:32:57 +05303611 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303612 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3613 buf = wmi_buf_alloc(wmi_handle, len);
3614 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303615 WMI_LOGE("Failed to allocate memory");
3616 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303617 goto end;
3618 }
3619
3620 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3621 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3622 WMITLV_SET_HDR(&cmd->tlv_header,
3623 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3624 WMITLV_GET_STRUCT_TLVLEN
3625 (wmi_p2p_set_noa_cmd_fixed_param));
3626 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3627 cmd->vdev_id = noa->session_id;
3628 cmd->enable = (duration) ? true : false;
3629 cmd->num_noa = 1;
3630
3631 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3632 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3633 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3634 sizeof
3635 (wmi_p2p_set_noa_cmd_fixed_param)
3636 + WMI_TLV_HDR_SIZE);
3637 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3638 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3639 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3640 noa_discriptor->type_count = noa->count;
3641 noa_discriptor->duration = duration;
3642 noa_discriptor->interval = noa->interval;
3643 noa_discriptor->start_time = 0;
3644
Govind Singhb53420c2016-03-09 14:32:57 +05303645 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303646 cmd->vdev_id, noa->count, noa_discriptor->duration,
3647 noa->interval);
3648 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3649 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303650 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303651 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303652 wmi_buf_free(buf);
3653 }
3654
3655end:
Govind Singhb53420c2016-03-09 14:32:57 +05303656 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303657 return status;
3658}
3659
3660
3661/**
3662 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3663 * @wmi_handle: wmi handle
3664 * @noa: p2p opp power save parameters
3665 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303666 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303667 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303668static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303669 struct p2p_ps_params *oppps)
3670{
3671 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3672 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303673 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303674
Govind Singhb53420c2016-03-09 14:32:57 +05303675 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303676 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3677 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303678 WMI_LOGE("Failed to allocate memory");
3679 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303680 goto end;
3681 }
3682
3683 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3684 WMITLV_SET_HDR(&cmd->tlv_header,
3685 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3686 WMITLV_GET_STRUCT_TLVLEN
3687 (wmi_p2p_set_oppps_cmd_fixed_param));
3688 cmd->vdev_id = oppps->session_id;
3689 if (oppps->ctwindow)
3690 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3691
3692 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303693 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303694 cmd->vdev_id, oppps->ctwindow);
3695 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3696 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303697 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303698 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303699 wmi_buf_free(buf);
3700 }
3701
3702end:
Govind Singhb53420c2016-03-09 14:32:57 +05303703 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303704 return status;
3705}
3706
Rachit Kankane9cd0c752018-07-31 16:26:38 +05303707#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +08003708/**
3709 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3710 * @wmi_handle: wmi handle
3711 * @param: p2p listen offload start parameters
3712 *
3713 * Return: QDF status
3714 */
3715static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3716 struct p2p_lo_start *param)
3717{
3718 wmi_buf_t buf;
3719 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3720 int32_t len = sizeof(*cmd);
3721 uint8_t *buf_ptr;
3722 QDF_STATUS status;
3723 int device_types_len_aligned;
3724 int probe_resp_len_aligned;
3725
3726 if (!param) {
3727 WMI_LOGE("lo start param is null");
3728 return QDF_STATUS_E_INVAL;
3729 }
3730
3731 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3732
3733 device_types_len_aligned =
3734 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303735 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003736 probe_resp_len_aligned =
3737 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303738 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003739
3740 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3741 probe_resp_len_aligned;
3742
3743 buf = wmi_buf_alloc(wmi_handle, len);
3744 if (!buf) {
3745 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3746 __func__);
3747 return QDF_STATUS_E_NOMEM;
3748 }
3749
3750 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3751 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3752
3753 WMITLV_SET_HDR(&cmd->tlv_header,
3754 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3755 WMITLV_GET_STRUCT_TLVLEN(
3756 wmi_p2p_lo_start_cmd_fixed_param));
3757
3758 cmd->vdev_id = param->vdev_id;
3759 cmd->ctl_flags = param->ctl_flags;
3760 cmd->channel = param->freq;
3761 cmd->period = param->period;
3762 cmd->interval = param->interval;
3763 cmd->count = param->count;
3764 cmd->device_types_len = param->dev_types_len;
3765 cmd->prob_resp_len = param->probe_resp_len;
3766
3767 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3768 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3769 device_types_len_aligned);
3770 buf_ptr += WMI_TLV_HDR_SIZE;
3771 qdf_mem_copy(buf_ptr, param->device_types,
3772 param->dev_types_len);
3773
3774 buf_ptr += device_types_len_aligned;
3775 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3776 probe_resp_len_aligned);
3777 buf_ptr += WMI_TLV_HDR_SIZE;
3778 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3779 param->probe_resp_len);
3780
3781 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3782 cmd->channel, cmd->period, cmd->interval, cmd->count);
3783
3784 status = wmi_unified_cmd_send(wmi_handle,
3785 buf, len,
3786 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3787 if (status != QDF_STATUS_SUCCESS) {
3788 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3789 __func__, status);
3790 wmi_buf_free(buf);
3791 return status;
3792 }
3793
3794 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3795
3796 return QDF_STATUS_SUCCESS;
3797}
3798
3799/**
3800 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3801 * @wmi_handle: wmi handle
3802 * @param: p2p listen offload stop parameters
3803 *
3804 * Return: QDF status
3805 */
3806static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3807 uint8_t vdev_id)
3808{
3809 wmi_buf_t buf;
3810 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3811 int32_t len;
3812 QDF_STATUS status;
3813
3814 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3815
3816 len = sizeof(*cmd);
3817 buf = wmi_buf_alloc(wmi_handle, len);
3818 if (!buf) {
3819 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3820 __func__);
3821 return QDF_STATUS_E_NOMEM;
3822 }
3823 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3824
3825 WMITLV_SET_HDR(&cmd->tlv_header,
3826 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3827 WMITLV_GET_STRUCT_TLVLEN(
3828 wmi_p2p_lo_stop_cmd_fixed_param));
3829
3830 cmd->vdev_id = vdev_id;
3831
3832 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3833
3834 status = wmi_unified_cmd_send(wmi_handle,
3835 buf, len,
3836 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3837 if (status != QDF_STATUS_SUCCESS) {
3838 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3839 __func__, status);
3840 wmi_buf_free(buf);
3841 return status;
3842 }
3843
3844 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3845
3846 return QDF_STATUS_SUCCESS;
3847}
Rachit Kankane9cd0c752018-07-31 16:26:38 +05303848#endif /* End of FEATURE_P2P_LISTEN_OFFLOAD */
Wu Gaocd3a8512017-03-13 20:17:34 +08003849
Govind Singh427ee5a2016-02-26 18:09:36 +05303850/**
3851 * send_get_temperature_cmd_tlv() - get pdev temperature req
3852 * @wmi_handle: wmi handle
3853 *
Govind Singhb53420c2016-03-09 14:32:57 +05303854 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303855 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303856static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303857{
3858 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3859 wmi_buf_t wmi_buf;
3860 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3861 uint8_t *buf_ptr;
3862
3863 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303864 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3865 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303866 }
3867
3868 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3869 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303870 WMI_LOGE(FL("wmi_buf_alloc failed"));
3871 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303872 }
3873
3874 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3875
3876 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3877 WMITLV_SET_HDR(&cmd->tlv_header,
3878 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3879 WMITLV_GET_STRUCT_TLVLEN
3880 (wmi_pdev_get_temperature_cmd_fixed_param));
3881
3882 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3883 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303884 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303885 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303886 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303887 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303888
Govind Singhb53420c2016-03-09 14:32:57 +05303889 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303890}
3891
3892/**
3893 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3894 * @wmi_handle: wmi handle
3895 * @vdevid: vdev id
3896 * @peer_addr: peer mac address
3897 * @auto_triggerparam: auto trigger parameters
3898 * @num_ac: number of access category
3899 *
3900 * This function sets the trigger
3901 * uapsd params such as service interval, delay interval
3902 * and suspend interval which will be used by the firmware
3903 * to send trigger frames periodically when there is no
3904 * traffic on the transmit side.
3905 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303906 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303907 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303908static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303909 struct sta_uapsd_trig_params *param)
3910{
3911 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303912 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303913 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3914 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3915 uint32_t i;
3916 wmi_buf_t buf;
3917 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003918 struct sta_uapsd_params *uapsd_param;
3919 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303920
3921 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3922 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303923 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303924 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303925 }
3926
3927 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3928 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3929 WMITLV_SET_HDR(&cmd->tlv_header,
3930 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3931 WMITLV_GET_STRUCT_TLVLEN
3932 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3933 cmd->vdev_id = param->vdevid;
3934 cmd->num_ac = param->num_ac;
3935 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3936
3937 /* TLV indicating array of structures to follow */
3938 buf_ptr += sizeof(*cmd);
3939 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3940
3941 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303942
3943 /*
3944 * Update tag and length for uapsd auto trigger params (this will take
3945 * care of updating tag and length if it is not pre-filled by caller).
3946 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003947 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3948 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303949 for (i = 0; i < param->num_ac; i++) {
3950 WMITLV_SET_HDR((buf_ptr +
3951 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3952 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3953 WMITLV_GET_STRUCT_TLVLEN
3954 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003955 trig_param->wmm_ac = uapsd_param->wmm_ac;
3956 trig_param->user_priority = uapsd_param->user_priority;
3957 trig_param->service_interval = uapsd_param->service_interval;
3958 trig_param->suspend_interval = uapsd_param->suspend_interval;
3959 trig_param->delay_interval = uapsd_param->delay_interval;
3960 trig_param++;
3961 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303962 }
3963
3964 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3965 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303966 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303967 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303968 wmi_buf_free(buf);
3969 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303970
Govind Singh427ee5a2016-02-26 18:09:36 +05303971 return ret;
3972}
3973
Zhang Qian11c0de32018-01-05 16:50:53 +08003974#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303975/**
3976 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3977 * @wmi_handle: pointer to the wmi handle
3978 * @utc: pointer to the UTC time struct
3979 *
3980 * Return: 0 on succes
3981 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303982static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303983 struct ocb_utc_param *utc)
3984{
Govind Singh67922e82016-04-01 16:48:57 +05303985 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303986 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3987 uint8_t *buf_ptr;
3988 uint32_t len, i;
3989 wmi_buf_t buf;
3990
3991 len = sizeof(*cmd);
3992 buf = wmi_buf_alloc(wmi_handle, len);
3993 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303994 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303995 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303996 }
3997
3998 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3999 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
4000 WMITLV_SET_HDR(&cmd->tlv_header,
4001 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
4002 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
4003 cmd->vdev_id = utc->vdev_id;
4004
4005 for (i = 0; i < SIZE_UTC_TIME; i++)
4006 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
4007
4008 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
4009 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
4010
4011 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4012 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304013 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304014 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304015 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304016 }
4017
Govind Singh67922e82016-04-01 16:48:57 +05304018 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304019}
4020
4021/**
4022 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
4023 * frames on a channel
4024 * @wmi_handle: pointer to the wmi handle
4025 * @timing_advert: pointer to the timing advertisement struct
4026 *
4027 * Return: 0 on succes
4028 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304029static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304030 struct ocb_timing_advert_param *timing_advert)
4031{
Govind Singh67922e82016-04-01 16:48:57 +05304032 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304033 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
4034 uint8_t *buf_ptr;
4035 uint32_t len, len_template;
4036 wmi_buf_t buf;
4037
4038 len = sizeof(*cmd) +
4039 WMI_TLV_HDR_SIZE;
4040
4041 len_template = timing_advert->template_length;
4042 /* Add padding to the template if needed */
4043 if (len_template % 4 != 0)
4044 len_template += 4 - (len_template % 4);
4045 len += len_template;
4046
4047 buf = wmi_buf_alloc(wmi_handle, len);
4048 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304049 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304050 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304051 }
4052
4053 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4054 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
4055 WMITLV_SET_HDR(&cmd->tlv_header,
4056 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
4057 WMITLV_GET_STRUCT_TLVLEN(
4058 wmi_ocb_start_timing_advert_cmd_fixed_param));
4059 cmd->vdev_id = timing_advert->vdev_id;
4060 cmd->repeat_rate = timing_advert->repeat_rate;
4061 cmd->channel_freq = timing_advert->chan_freq;
4062 cmd->timestamp_offset = timing_advert->timestamp_offset;
4063 cmd->time_value_offset = timing_advert->time_value_offset;
4064 cmd->timing_advert_template_length = timing_advert->template_length;
4065 buf_ptr += sizeof(*cmd);
4066
4067 /* Add the timing advert template */
4068 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4069 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05304070 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05304071 (uint8_t *)timing_advert->template_value,
4072 timing_advert->template_length);
4073
4074 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4075 WMI_OCB_START_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 start 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_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
4086 * on a channel
4087 * @wmi_handle: pointer to the wmi handle
4088 * @timing_advert: pointer to the timing advertisement struct
4089 *
4090 * Return: 0 on succes
4091 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304092static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304093 struct ocb_timing_advert_param *timing_advert)
4094{
Govind Singh67922e82016-04-01 16:48:57 +05304095 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304096 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
4097 uint8_t *buf_ptr;
4098 uint32_t len;
4099 wmi_buf_t buf;
4100
4101 len = sizeof(*cmd);
4102 buf = wmi_buf_alloc(wmi_handle, len);
4103 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304104 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304105 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304106 }
4107
4108 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4109 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
4110 WMITLV_SET_HDR(&cmd->tlv_header,
4111 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
4112 WMITLV_GET_STRUCT_TLVLEN(
4113 wmi_ocb_stop_timing_advert_cmd_fixed_param));
4114 cmd->vdev_id = timing_advert->vdev_id;
4115 cmd->channel_freq = timing_advert->chan_freq;
4116
4117 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4118 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304119 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304120 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304121 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304122 }
4123
Govind Singh67922e82016-04-01 16:48:57 +05304124 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304125}
4126
4127/**
4128 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
4129 * @wmi_handle: pointer to the wmi handle
4130 * @request: pointer to the request
4131 *
4132 * Return: 0 on succes
4133 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304134static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304135 uint8_t vdev_id)
4136{
Govind Singhb53420c2016-03-09 14:32:57 +05304137 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304138 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
4139 uint8_t *buf_ptr;
4140 wmi_buf_t buf;
4141 int32_t len;
4142
4143 len = sizeof(*cmd);
4144 buf = wmi_buf_alloc(wmi_handle, len);
4145 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304146 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304147 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304148 }
4149 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4150
4151 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304152 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304153 WMITLV_SET_HDR(&cmd->tlv_header,
4154 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
4155 WMITLV_GET_STRUCT_TLVLEN(
4156 wmi_ocb_get_tsf_timer_cmd_fixed_param));
4157 cmd->vdev_id = vdev_id;
4158
4159 /* Send the WMI command */
4160 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4161 WMI_OCB_GET_TSF_TIMER_CMDID);
4162 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304163 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304164 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304165 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304166 }
4167
Govind Singh67922e82016-04-01 16:48:57 +05304168 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304169}
4170
4171/**
4172 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
4173 * @wmi_handle: pointer to the wmi handle
4174 * @get_stats_param: pointer to the dcc stats
4175 *
4176 * Return: 0 on succes
4177 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304178static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004179 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304180{
Govind Singh67922e82016-04-01 16:48:57 +05304181 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304182 wmi_dcc_get_stats_cmd_fixed_param *cmd;
4183 wmi_dcc_channel_stats_request *channel_stats_array;
4184 wmi_buf_t buf;
4185 uint8_t *buf_ptr;
4186 uint32_t len;
4187 uint32_t i;
4188
4189 /* Validate the input */
4190 if (get_stats_param->request_array_len !=
4191 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304192 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304193 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304194 }
4195
4196 /* Allocate memory for the WMI command */
4197 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4198 get_stats_param->request_array_len;
4199
4200 buf = wmi_buf_alloc(wmi_handle, len);
4201 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304202 WMI_LOGE(FL("wmi_buf_alloc failed"));
4203 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304204 }
4205
4206 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304207 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304208
4209 /* Populate the WMI command */
4210 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4211 buf_ptr += sizeof(*cmd);
4212
4213 WMITLV_SET_HDR(&cmd->tlv_header,
4214 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4215 WMITLV_GET_STRUCT_TLVLEN(
4216 wmi_dcc_get_stats_cmd_fixed_param));
4217 cmd->vdev_id = get_stats_param->vdev_id;
4218 cmd->num_channels = get_stats_param->channel_count;
4219
4220 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4221 get_stats_param->request_array_len);
4222 buf_ptr += WMI_TLV_HDR_SIZE;
4223
4224 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304225 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304226 get_stats_param->request_array_len);
4227 for (i = 0; i < cmd->num_channels; i++)
4228 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4229 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4230 WMITLV_GET_STRUCT_TLVLEN(
4231 wmi_dcc_channel_stats_request));
4232
4233 /* Send the WMI command */
4234 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4235 WMI_DCC_GET_STATS_CMDID);
4236
Govind Singh67922e82016-04-01 16:48:57 +05304237 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304238 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304239 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304240 }
4241
Govind Singh67922e82016-04-01 16:48:57 +05304242 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304243}
4244
4245/**
4246 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4247 * @wmi_handle: pointer to the wmi handle
4248 * @vdev_id: vdev id
4249 * @dcc_stats_bitmap: dcc status bitmap
4250 *
4251 * Return: 0 on succes
4252 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304253static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304254 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4255{
Govind Singh67922e82016-04-01 16:48:57 +05304256 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304257 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4258 wmi_buf_t buf;
4259 uint8_t *buf_ptr;
4260 uint32_t len;
4261
4262 /* Allocate memory for the WMI command */
4263 len = sizeof(*cmd);
4264
4265 buf = wmi_buf_alloc(wmi_handle, len);
4266 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304267 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304268 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304269 }
4270
4271 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304272 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304273
4274 /* Populate the WMI command */
4275 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4276
4277 WMITLV_SET_HDR(&cmd->tlv_header,
4278 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4279 WMITLV_GET_STRUCT_TLVLEN(
4280 wmi_dcc_clear_stats_cmd_fixed_param));
4281 cmd->vdev_id = vdev_id;
4282 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4283
4284 /* Send the WMI command */
4285 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4286 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304287 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304288 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304289 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304290 }
4291
Govind Singh67922e82016-04-01 16:48:57 +05304292 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304293}
4294
4295/**
4296 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4297 * @wmi_handle: pointer to the wmi handle
4298 * @update_ndl_param: pointer to the request parameters
4299 *
4300 * Return: 0 on success
4301 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304302static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004303 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304304{
Govind Singhb53420c2016-03-09 14:32:57 +05304305 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304306 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4307 wmi_dcc_ndl_chan *ndl_chan_array;
4308 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4309 uint32_t active_state_count;
4310 wmi_buf_t buf;
4311 uint8_t *buf_ptr;
4312 uint32_t len;
4313 uint32_t i;
4314
4315 /* validate the input */
4316 if (update_ndl_param->dcc_ndl_chan_list_len !=
4317 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304318 WMI_LOGE(FL("Invalid parameter"));
4319 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304320 }
4321 active_state_count = 0;
4322 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4323 for (i = 0; i < update_ndl_param->channel_count; i++)
4324 active_state_count +=
4325 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4326 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4327 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304328 WMI_LOGE(FL("Invalid parameter"));
4329 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304330 }
4331
4332 /* Allocate memory for the WMI command */
4333 len = sizeof(*cmd) +
4334 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4335 WMI_TLV_HDR_SIZE +
4336 update_ndl_param->dcc_ndl_active_state_list_len;
4337
4338 buf = wmi_buf_alloc(wmi_handle, len);
4339 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304340 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304341 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304342 }
4343
4344 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304345 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304346
4347 /* Populate the WMI command */
4348 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4349 buf_ptr += sizeof(*cmd);
4350
4351 WMITLV_SET_HDR(&cmd->tlv_header,
4352 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4353 WMITLV_GET_STRUCT_TLVLEN(
4354 wmi_dcc_update_ndl_cmd_fixed_param));
4355 cmd->vdev_id = update_ndl_param->vdev_id;
4356 cmd->num_channel = update_ndl_param->channel_count;
4357
4358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4359 update_ndl_param->dcc_ndl_chan_list_len);
4360 buf_ptr += WMI_TLV_HDR_SIZE;
4361
4362 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304363 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304364 update_ndl_param->dcc_ndl_chan_list_len);
4365 for (i = 0; i < cmd->num_channel; i++)
4366 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4367 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4368 WMITLV_GET_STRUCT_TLVLEN(
4369 wmi_dcc_ndl_chan));
4370 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4371
4372 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4373 update_ndl_param->dcc_ndl_active_state_list_len);
4374 buf_ptr += WMI_TLV_HDR_SIZE;
4375
4376 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304377 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304378 update_ndl_param->dcc_ndl_active_state_list,
4379 update_ndl_param->dcc_ndl_active_state_list_len);
4380 for (i = 0; i < active_state_count; i++) {
4381 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4382 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4383 WMITLV_GET_STRUCT_TLVLEN(
4384 wmi_dcc_ndl_active_state_config));
4385 }
4386 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4387
4388 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304389 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304390 WMI_DCC_UPDATE_NDL_CMDID);
4391 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304392 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304393 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304394 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304395 }
4396
Govind Singh67922e82016-04-01 16:48:57 +05304397 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304398}
4399
4400/**
4401 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4402 * @wmi_handle: pointer to the wmi handle
4403 * @config: the OCB configuration
4404 *
4405 * Return: 0 on success
4406 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304407static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004408 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304409{
Govind Singh67922e82016-04-01 16:48:57 +05304410 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304411 wmi_ocb_set_config_cmd_fixed_param *cmd;
4412 wmi_channel *chan;
4413 wmi_ocb_channel *ocb_chan;
4414 wmi_qos_parameter *qos_param;
4415 wmi_dcc_ndl_chan *ndl_chan;
4416 wmi_dcc_ndl_active_state_config *ndl_active_config;
4417 wmi_ocb_schedule_element *sched_elem;
4418 uint8_t *buf_ptr;
4419 wmi_buf_t buf;
4420 int32_t len;
4421 int32_t i, j, active_state_count;
4422
4423 /*
4424 * Validate the dcc_ndl_chan_list_len and count the number of active
4425 * states. Validate dcc_ndl_active_state_list_len.
4426 */
4427 active_state_count = 0;
4428 if (config->dcc_ndl_chan_list_len) {
4429 if (!config->dcc_ndl_chan_list ||
4430 config->dcc_ndl_chan_list_len !=
4431 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304432 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304433 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304434 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304435 }
4436
4437 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4438 i < config->channel_count; ++i, ++ndl_chan)
4439 active_state_count +=
4440 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4441
4442 if (active_state_count) {
4443 if (!config->dcc_ndl_active_state_list ||
4444 config->dcc_ndl_active_state_list_len !=
4445 active_state_count *
4446 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304447 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304448 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304449 }
4450 }
4451 }
4452
4453 len = sizeof(*cmd) +
4454 WMI_TLV_HDR_SIZE + config->channel_count *
4455 sizeof(wmi_channel) +
4456 WMI_TLV_HDR_SIZE + config->channel_count *
4457 sizeof(wmi_ocb_channel) +
4458 WMI_TLV_HDR_SIZE + config->channel_count *
4459 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4460 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4461 WMI_TLV_HDR_SIZE + active_state_count *
4462 sizeof(wmi_dcc_ndl_active_state_config) +
4463 WMI_TLV_HDR_SIZE + config->schedule_size *
4464 sizeof(wmi_ocb_schedule_element);
4465 buf = wmi_buf_alloc(wmi_handle, len);
4466 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304467 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304468 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304469 }
4470
4471 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4472 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4473 WMITLV_SET_HDR(&cmd->tlv_header,
4474 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4475 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004476 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304477 cmd->channel_count = config->channel_count;
4478 cmd->schedule_size = config->schedule_size;
4479 cmd->flags = config->flags;
4480 buf_ptr += sizeof(*cmd);
4481
4482 /* Add the wmi_channel info */
4483 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4484 config->channel_count*sizeof(wmi_channel));
4485 buf_ptr += WMI_TLV_HDR_SIZE;
4486 for (i = 0; i < config->channel_count; i++) {
4487 chan = (wmi_channel *)buf_ptr;
4488 WMITLV_SET_HDR(&chan->tlv_header,
4489 WMITLV_TAG_STRUC_wmi_channel,
4490 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4491 chan->mhz = config->channels[i].chan_freq;
4492 chan->band_center_freq1 = config->channels[i].chan_freq;
4493 chan->band_center_freq2 = 0;
4494 chan->info = 0;
4495
Zhang Qian11c0de32018-01-05 16:50:53 +08004496 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304497 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4498 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4499 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4500 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4501 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4502 config->channels[i].antenna_max);
4503
4504 if (config->channels[i].bandwidth < 10)
4505 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4506 else if (config->channels[i].bandwidth < 20)
4507 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4508 buf_ptr += sizeof(*chan);
4509 }
4510
4511 /* Add the wmi_ocb_channel info */
4512 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4513 config->channel_count*sizeof(wmi_ocb_channel));
4514 buf_ptr += WMI_TLV_HDR_SIZE;
4515 for (i = 0; i < config->channel_count; i++) {
4516 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4517 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4518 WMITLV_TAG_STRUC_wmi_ocb_channel,
4519 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4520 ocb_chan->bandwidth = config->channels[i].bandwidth;
4521 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4522 config->channels[i].mac_address.bytes,
4523 &ocb_chan->mac_address);
4524 buf_ptr += sizeof(*ocb_chan);
4525 }
4526
4527 /* Add the wmi_qos_parameter info */
4528 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4529 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4530 buf_ptr += WMI_TLV_HDR_SIZE;
4531 /* WMI_MAX_NUM_AC parameters for each channel */
4532 for (i = 0; i < config->channel_count; i++) {
4533 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4534 qos_param = (wmi_qos_parameter *)buf_ptr;
4535 WMITLV_SET_HDR(&qos_param->tlv_header,
4536 WMITLV_TAG_STRUC_wmi_qos_parameter,
4537 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4538 qos_param->aifsn =
4539 config->channels[i].qos_params[j].aifsn;
4540 qos_param->cwmin =
4541 config->channels[i].qos_params[j].cwmin;
4542 qos_param->cwmax =
4543 config->channels[i].qos_params[j].cwmax;
4544 buf_ptr += sizeof(*qos_param);
4545 }
4546 }
4547
4548 /* Add the wmi_dcc_ndl_chan (per channel) */
4549 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4550 config->dcc_ndl_chan_list_len);
4551 buf_ptr += WMI_TLV_HDR_SIZE;
4552 if (config->dcc_ndl_chan_list_len) {
4553 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304554 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304555 config->dcc_ndl_chan_list_len);
4556 for (i = 0; i < config->channel_count; i++)
4557 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4558 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4559 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4560 buf_ptr += config->dcc_ndl_chan_list_len;
4561 }
4562
4563 /* Add the wmi_dcc_ndl_active_state_config */
4564 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4565 sizeof(wmi_dcc_ndl_active_state_config));
4566 buf_ptr += WMI_TLV_HDR_SIZE;
4567 if (active_state_count) {
4568 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304569 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304570 config->dcc_ndl_active_state_list,
4571 active_state_count * sizeof(*ndl_active_config));
4572 for (i = 0; i < active_state_count; ++i)
4573 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4574 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4575 WMITLV_GET_STRUCT_TLVLEN(
4576 wmi_dcc_ndl_active_state_config));
4577 buf_ptr += active_state_count *
4578 sizeof(*ndl_active_config);
4579 }
4580
4581 /* Add the wmi_ocb_schedule_element info */
4582 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4583 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4584 buf_ptr += WMI_TLV_HDR_SIZE;
4585 for (i = 0; i < config->schedule_size; i++) {
4586 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4587 WMITLV_SET_HDR(&sched_elem->tlv_header,
4588 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4589 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4590 sched_elem->channel_freq = config->schedule[i].chan_freq;
4591 sched_elem->total_duration = config->schedule[i].total_duration;
4592 sched_elem->guard_interval = config->schedule[i].guard_interval;
4593 buf_ptr += sizeof(*sched_elem);
4594 }
4595
4596
4597 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4598 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304599 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304600 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304601 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304602 }
4603
Govind Singh67922e82016-04-01 16:48:57 +05304604 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304605}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304606
4607/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004608 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4609 * @wmi_handle: wmi handle
4610 * @evt_buf: wmi event buffer
4611 * @status: status buffer
4612 *
4613 * Return: QDF_STATUS_SUCCESS on success
4614 */
4615static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4616 void *evt_buf,
4617 uint32_t *status)
4618{
4619 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4620 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4621
4622 param_tlvs = evt_buf;
4623 fix_param = param_tlvs->fixed_param;
4624
4625 *status = fix_param->status;
4626 return QDF_STATUS_SUCCESS;
4627}
4628
4629/**
4630 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4631 * @wmi_handle: wmi handle
4632 * @evt_buf: wmi event buffer
4633 * @resp: response buffer
4634 *
4635 * Return: QDF_STATUS_SUCCESS on success
4636 */
4637static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4638 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4639{
4640 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4641 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4642
4643 param_tlvs = evt_buf;
4644 fix_param = param_tlvs->fixed_param;
4645 resp->vdev_id = fix_param->vdev_id;
4646 resp->timer_high = fix_param->tsf_timer_high;
4647 resp->timer_low = fix_param->tsf_timer_low;
4648
4649 return QDF_STATUS_SUCCESS;
4650}
4651
4652/**
4653 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4654 * @wmi_handle: wmi handle
4655 * @evt_buf: wmi event buffer
4656 * @resp: response buffer
4657 *
4658 * Return: QDF_STATUS_SUCCESS on success
4659 */
4660static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4661 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4662{
4663 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4664 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4665
4666 param_tlvs = evt_buf;
4667 fix_param = param_tlvs->fixed_param;
4668 resp->vdev_id = fix_param->vdev_id;
4669 resp->status = fix_param->status;
4670 return QDF_STATUS_SUCCESS;
4671}
4672
4673/**
4674 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4675 * @wmi_handle: wmi handle
4676 * @evt_buf: wmi event buffer
4677 * @resp: response buffer
4678 *
4679 * Since length of stats is variable, buffer for DCC stats will be allocated
4680 * in this function. The caller must free the buffer.
4681 *
4682 * Return: QDF_STATUS_SUCCESS on success
4683 */
4684static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4685 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4686{
4687 struct ocb_dcc_get_stats_response *response;
4688 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4689 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4690
4691 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4692 fix_param = param_tlvs->fixed_param;
4693
4694 /* Allocate and populate the response */
4695 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4696 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4697 WMI_LOGE("%s: too many channels:%d", __func__,
4698 fix_param->num_channels);
4699 QDF_ASSERT(0);
4700 *resp = NULL;
4701 return QDF_STATUS_E_INVAL;
4702 }
4703 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4704 sizeof(wmi_dcc_ndl_stats_per_channel));
4705 *resp = response;
4706 if (!response)
4707 return QDF_STATUS_E_NOMEM;
4708
4709 response->vdev_id = fix_param->vdev_id;
4710 response->num_channels = fix_param->num_channels;
4711 response->channel_stats_array_len =
4712 fix_param->num_channels *
4713 sizeof(wmi_dcc_ndl_stats_per_channel);
4714 response->channel_stats_array = ((uint8_t *)response) +
4715 sizeof(*response);
4716 qdf_mem_copy(response->channel_stats_array,
4717 param_tlvs->stats_per_channel_list,
4718 response->channel_stats_array_len);
4719
4720 return QDF_STATUS_SUCCESS;
4721}
4722#endif
4723
4724/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304725 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4726 * @wmi_handle: wmi handle
4727 * @mcc_adaptive_scheduler: enable/disable
4728 *
4729 * This function enable/disable mcc adaptive scheduler in fw.
4730 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -07004731 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304732 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304733static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004734 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4735 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304736{
Govind Singh67922e82016-04-01 16:48:57 +05304737 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304738 wmi_buf_t buf = 0;
4739 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4740 uint16_t len =
4741 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4742
4743 buf = wmi_buf_alloc(wmi_handle, len);
4744 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304745 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4746 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304747 }
4748 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4749 wmi_buf_data(buf);
4750
4751 WMITLV_SET_HDR(&cmd->tlv_header,
4752 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4753 WMITLV_GET_STRUCT_TLVLEN
4754 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4755 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304756 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304757
4758 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4759 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304760 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304761 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304762 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304763 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304764 }
Govind Singh67922e82016-04-01 16:48:57 +05304765
4766 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304767}
4768
4769/**
4770 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4771 * @wmi: wmi handle
4772 * @mcc_channel: mcc channel
4773 * @mcc_channel_time_latency: MCC channel time latency.
4774 *
4775 * Currently used to set time latency for an MCC vdev/adapter using operating
4776 * channel of it and channel number. The info is provided run time using
4777 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4778 *
4779 * Return: CDF status
4780 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304781static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304782 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4783{
Govind Singh67922e82016-04-01 16:48:57 +05304784 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304785 wmi_buf_t buf = 0;
4786 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4787 uint16_t len = 0;
4788 uint8_t *buf_ptr = NULL;
4789 wmi_resmgr_chan_latency chan_latency;
4790 /* Note: we only support MCC time latency for a single channel */
4791 uint32_t num_channels = 1;
4792 uint32_t chan1_freq = mcc_channel_freq;
4793 uint32_t latency_chan1 = mcc_channel_time_latency;
4794
4795
4796 /* If 0ms latency is provided, then FW will set to a default.
4797 * Otherwise, latency must be at least 30ms.
4798 */
4799 if ((latency_chan1 > 0) &&
4800 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304801 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304802 "Minimum is 30ms (or 0 to use default value by "
4803 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304804 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304805 }
4806
4807 /* Set WMI CMD for channel time latency here */
4808 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4809 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4810 num_channels * sizeof(wmi_resmgr_chan_latency);
4811 buf = wmi_buf_alloc(wmi_handle, len);
4812 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304813 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4814 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304815 }
4816 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4817 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4818 wmi_buf_data(buf);
4819 WMITLV_SET_HDR(&cmdTL->tlv_header,
4820 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4821 WMITLV_GET_STRUCT_TLVLEN
4822 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4823 cmdTL->num_chans = num_channels;
4824 /* Update channel time latency information for home channel(s) */
4825 buf_ptr += sizeof(*cmdTL);
4826 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4827 num_channels * sizeof(wmi_resmgr_chan_latency));
4828 buf_ptr += WMI_TLV_HDR_SIZE;
4829 chan_latency.chan_mhz = chan1_freq;
4830 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304831 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304832 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4833 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304834 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304835 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304836 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304837 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304838 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304839 }
Govind Singh67922e82016-04-01 16:48:57 +05304840
4841 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304842}
4843
4844/**
4845 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4846 * @wmi: wmi handle
4847 * @adapter_1_chan_number: adapter 1 channel number
4848 * @adapter_1_quota: adapter 1 quota
4849 * @adapter_2_chan_number: adapter 2 channel number
4850 *
4851 * Return: CDF status
4852 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304853static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304854 uint32_t adapter_1_chan_freq,
4855 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4856{
Govind Singh67922e82016-04-01 16:48:57 +05304857 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304858 wmi_buf_t buf = 0;
4859 uint16_t len = 0;
4860 uint8_t *buf_ptr = NULL;
4861 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4862 wmi_resmgr_chan_time_quota chan_quota;
4863 uint32_t quota_chan1 = adapter_1_quota;
4864 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4865 uint32_t quota_chan2 = 100 - quota_chan1;
4866 /* Note: setting time quota for MCC requires info for 2 channels */
4867 uint32_t num_channels = 2;
4868 uint32_t chan1_freq = adapter_1_chan_freq;
4869 uint32_t chan2_freq = adapter_2_chan_freq;
4870
Govind Singhb53420c2016-03-09 14:32:57 +05304871 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304872 "freq2:%dMHz, Quota2:%dms", __func__,
4873 chan1_freq, quota_chan1, chan2_freq,
4874 quota_chan2);
4875
4876 /*
4877 * Perform sanity check on time quota values provided.
4878 */
4879 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4880 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304881 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304882 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304883 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304884 }
4885 /* Set WMI CMD for channel time quota here */
4886 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4887 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4888 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4889 buf = wmi_buf_alloc(wmi_handle, len);
4890 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304891 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4892 QDF_ASSERT(0);
4893 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304894 }
4895 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4896 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4897 wmi_buf_data(buf);
4898 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4899 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4900 WMITLV_GET_STRUCT_TLVLEN
4901 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4902 cmdTQ->num_chans = num_channels;
4903
4904 /* Update channel time quota information for home channel(s) */
4905 buf_ptr += sizeof(*cmdTQ);
4906 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4907 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4908 buf_ptr += WMI_TLV_HDR_SIZE;
4909 chan_quota.chan_mhz = chan1_freq;
4910 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304911 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304912 /* Construct channel and quota record for the 2nd MCC mode. */
4913 buf_ptr += sizeof(chan_quota);
4914 chan_quota.chan_mhz = chan2_freq;
4915 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304916 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304917
4918 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4919 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304920 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304921 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304922 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304923 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304924 }
Govind Singh67922e82016-04-01 16:48:57 +05304925
4926 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304927}
4928
4929/**
4930 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4931 * @wmi_handle: Pointer to wmi handle
4932 * @thermal_info: Thermal command information
4933 *
4934 * This function sends the thermal management command
4935 * to the firmware
4936 *
Govind Singhb53420c2016-03-09 14:32:57 +05304937 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304938 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304939static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304940 struct thermal_cmd_params *thermal_info)
4941{
4942 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4943 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304944 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304945 uint32_t len = 0;
4946
4947 len = sizeof(*cmd);
4948
4949 buf = wmi_buf_alloc(wmi_handle, len);
4950 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304951 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4952 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304953 }
4954
4955 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4956
4957 WMITLV_SET_HDR(&cmd->tlv_header,
4958 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4959 WMITLV_GET_STRUCT_TLVLEN
4960 (wmi_thermal_mgmt_cmd_fixed_param));
4961
4962 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4963 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4964 cmd->enable = thermal_info->thermal_enable;
4965
Govind Singhb53420c2016-03-09 14:32:57 +05304966 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304967 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4968
4969 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4970 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304971 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304972 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304973 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304974 }
4975
Govind Singh67922e82016-04-01 16:48:57 +05304976 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304977}
4978
4979
4980/**
4981 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304982 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304983 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4984 *
4985 * This function sends down the LRO configuration parameters to
4986 * the firmware to enable LRO, sets the TCP flags and sets the
4987 * seed values for the toeplitz hash generation
4988 *
Govind Singhb53420c2016-03-09 14:32:57 +05304989 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304990 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304991static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304992 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4993{
4994 wmi_lro_info_cmd_fixed_param *cmd;
4995 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304996 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304997
4998
4999 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5000 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305001 WMI_LOGE("Failed to allocate buffer to send set key cmd");
5002 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305003 }
5004
5005 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
5006
5007 WMITLV_SET_HDR(&cmd->tlv_header,
5008 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
5009 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
5010
5011 cmd->lro_enable = wmi_lro_cmd->lro_enable;
5012 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
5013 wmi_lro_cmd->tcp_flag);
5014 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
5015 wmi_lro_cmd->tcp_flag_mask);
5016 cmd->toeplitz_hash_ipv4_0_3 =
5017 wmi_lro_cmd->toeplitz_hash_ipv4[0];
5018 cmd->toeplitz_hash_ipv4_4_7 =
5019 wmi_lro_cmd->toeplitz_hash_ipv4[1];
5020 cmd->toeplitz_hash_ipv4_8_11 =
5021 wmi_lro_cmd->toeplitz_hash_ipv4[2];
5022 cmd->toeplitz_hash_ipv4_12_15 =
5023 wmi_lro_cmd->toeplitz_hash_ipv4[3];
5024 cmd->toeplitz_hash_ipv4_16 =
5025 wmi_lro_cmd->toeplitz_hash_ipv4[4];
5026
5027 cmd->toeplitz_hash_ipv6_0_3 =
5028 wmi_lro_cmd->toeplitz_hash_ipv6[0];
5029 cmd->toeplitz_hash_ipv6_4_7 =
5030 wmi_lro_cmd->toeplitz_hash_ipv6[1];
5031 cmd->toeplitz_hash_ipv6_8_11 =
5032 wmi_lro_cmd->toeplitz_hash_ipv6[2];
5033 cmd->toeplitz_hash_ipv6_12_15 =
5034 wmi_lro_cmd->toeplitz_hash_ipv6[3];
5035 cmd->toeplitz_hash_ipv6_16_19 =
5036 wmi_lro_cmd->toeplitz_hash_ipv6[4];
5037 cmd->toeplitz_hash_ipv6_20_23 =
5038 wmi_lro_cmd->toeplitz_hash_ipv6[5];
5039 cmd->toeplitz_hash_ipv6_24_27 =
5040 wmi_lro_cmd->toeplitz_hash_ipv6[6];
5041 cmd->toeplitz_hash_ipv6_28_31 =
5042 wmi_lro_cmd->toeplitz_hash_ipv6[7];
5043 cmd->toeplitz_hash_ipv6_32_35 =
5044 wmi_lro_cmd->toeplitz_hash_ipv6[8];
5045 cmd->toeplitz_hash_ipv6_36_39 =
5046 wmi_lro_cmd->toeplitz_hash_ipv6[9];
5047 cmd->toeplitz_hash_ipv6_40 =
5048 wmi_lro_cmd->toeplitz_hash_ipv6[10];
5049
Govind Singhb53420c2016-03-09 14:32:57 +05305050 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05305051 cmd->lro_enable, cmd->tcp_flag_u32);
5052
5053 status = wmi_unified_cmd_send(wmi_handle, buf,
5054 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305055 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305056 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305057 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305058 }
5059
Govind Singh67922e82016-04-01 16:48:57 +05305060 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305061}
5062
Govind Singh4eacd2b2016-03-07 14:24:22 +05305063/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305064 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
5065 * @wmi_handle: Pointer to wmi handle
5066 * @rate_report_params: Pointer to peer rate report parameters
5067 *
5068 *
5069 * Return: QDF_STATUS_SUCCESS for success otherwise failure
5070 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305071static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305072 struct wmi_peer_rate_report_params *rate_report_params)
5073{
5074 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
5075 wmi_buf_t buf = NULL;
5076 QDF_STATUS status = 0;
5077 uint32_t len = 0;
5078 uint32_t i, j;
5079
5080 len = sizeof(*cmd);
5081
5082 buf = wmi_buf_alloc(wmi_handle, len);
5083 if (!buf) {
5084 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
5085 return QDF_STATUS_E_FAILURE;
5086 }
5087
5088 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
5089 wmi_buf_data(buf);
5090
5091 WMITLV_SET_HDR(
5092 &cmd->tlv_header,
5093 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
5094 WMITLV_GET_STRUCT_TLVLEN(
5095 wmi_peer_set_rate_report_condition_fixed_param));
5096
5097 cmd->enable_rate_report = rate_report_params->rate_report_enable;
5098 cmd->report_backoff_time = rate_report_params->backoff_time;
5099 cmd->report_timer_period = rate_report_params->timer_period;
5100 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
5101 cmd->cond_per_phy[i].val_cond_flags =
5102 rate_report_params->report_per_phy[i].cond_flags;
5103 cmd->cond_per_phy[i].rate_delta.min_delta =
5104 rate_report_params->report_per_phy[i].delta.delta_min;
5105 cmd->cond_per_phy[i].rate_delta.percentage =
5106 rate_report_params->report_per_phy[i].delta.percent;
5107 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
5108 cmd->cond_per_phy[i].rate_threshold[j] =
5109 rate_report_params->report_per_phy[i].
5110 report_rate_threshold[j];
5111 }
5112 }
5113
5114 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
5115 cmd->enable_rate_report,
5116 cmd->report_backoff_time, cmd->report_timer_period);
5117
5118 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5119 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
5120 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305121 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305122 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
5123 __func__);
5124 }
5125 return status;
5126}
5127
5128/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05305129 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
5130 * @wmi_handle: wmi handle
5131 * @param: bcn ll cmd parameter
5132 *
Govind Singhb53420c2016-03-09 14:32:57 +05305133 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305134 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305135static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305136 wmi_bcn_send_from_host_cmd_fixed_param *param)
5137{
5138 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
5139 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05305140 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305141
5142 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5143 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305144 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5145 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305146 }
5147
5148 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
5149 WMITLV_SET_HDR(&cmd->tlv_header,
5150 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
5151 WMITLV_GET_STRUCT_TLVLEN
5152 (wmi_bcn_send_from_host_cmd_fixed_param));
5153 cmd->vdev_id = param->vdev_id;
5154 cmd->data_len = param->data_len;
5155 cmd->frame_ctrl = param->frame_ctrl;
5156 cmd->frag_ptr = param->frag_ptr;
5157 cmd->dtim_flag = param->dtim_flag;
5158
5159 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
5160 WMI_PDEV_SEND_BCN_CMDID);
5161
Govind Singh67922e82016-04-01 16:48:57 +05305162 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305163 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305164 wmi_buf_free(wmi_buf);
5165 }
5166
5167 return ret;
5168}
5169
5170/**
5171 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
5172 * @wmi_handle: wmi handle
5173 * @vdev_id: vdev id
5174 * @max_retries: max retries
5175 * @retry_interval: retry interval
5176 * This function sets sta query related parameters in fw.
5177 *
Govind Singhb53420c2016-03-09 14:32:57 +05305178 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305179 */
5180
Sathish Kumarfd347372017-02-13 12:29:09 +05305181static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305182 uint8_t vdev_id, uint32_t max_retries,
5183 uint32_t retry_interval)
5184{
5185 wmi_buf_t buf;
5186 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5187 int len;
5188
5189 len = sizeof(*cmd);
5190 buf = wmi_buf_alloc(wmi_handle, len);
5191 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305192 WMI_LOGE(FL("wmi_buf_alloc failed"));
5193 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305194 }
5195
5196 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5197 WMITLV_SET_HDR(&cmd->tlv_header,
5198 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5199 WMITLV_GET_STRUCT_TLVLEN
5200 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5201
5202
5203 cmd->vdev_id = vdev_id;
5204 cmd->sa_query_max_retry_count = max_retries;
5205 cmd->sa_query_retry_interval = retry_interval;
5206
Govind Singhb53420c2016-03-09 14:32:57 +05305207 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305208 vdev_id, retry_interval, max_retries);
5209
5210 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5211 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305212 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305213 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305214 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305215 }
5216
Govind Singhb53420c2016-03-09 14:32:57 +05305217 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305218 return 0;
5219}
5220
5221/**
5222 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5223 * @wmi_handle: wmi handle
5224 * @params: sta keep alive parameter
5225 *
5226 * This function sets keep alive related parameters in fw.
5227 *
5228 * Return: CDF status
5229 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305230static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305231 struct sta_params *params)
5232{
5233 wmi_buf_t buf;
5234 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5235 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5236 uint8_t *buf_ptr;
5237 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305238 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305239
Govind Singhb53420c2016-03-09 14:32:57 +05305240 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305241
Govind Singh4eacd2b2016-03-07 14:24:22 +05305242 len = sizeof(*cmd) + sizeof(*arp_rsp);
5243 buf = wmi_buf_alloc(wmi_handle, len);
5244 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305245 WMI_LOGE("wmi_buf_alloc failed");
5246 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305247 }
5248
5249 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5250 buf_ptr = (uint8_t *) cmd;
5251 WMITLV_SET_HDR(&cmd->tlv_header,
5252 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5253 WMITLV_GET_STRUCT_TLVLEN
5254 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5255 cmd->interval = params->timeperiod;
5256 cmd->enable = (params->timeperiod) ? 1 : 0;
5257 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305258 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305259 params->timeperiod, params->method);
5260 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5261 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5262 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5263 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5264
c_manjee2772b9c2017-01-23 15:14:13 +05305265 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5266 (params->method ==
5267 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305268 if ((NULL == params->hostv4addr) ||
5269 (NULL == params->destv4addr) ||
5270 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005271 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5272 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305273 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305274 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305275 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305276 }
c_manjee2772b9c2017-01-23 15:14:13 +05305277 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305278 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305279 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305280 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305281 WMI_IPV4_ADDR_LEN);
5282 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5283 } else {
5284 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5285 }
5286
Govind Singh67922e82016-04-01 16:48:57 +05305287 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5288 WMI_STA_KEEPALIVE_CMDID);
5289 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305290 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305291 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305292 }
5293
Govind Singhb53420c2016-03-09 14:32:57 +05305294 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305295 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305296}
5297
5298/**
5299 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5300 * @wmi_handle: wmi handle
5301 * @if_id: vdev id
5302 * @gtx_info: GTX config params
5303 *
5304 * This function set GTX related params in firmware.
5305 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305306 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305307 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305308static 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 +05305309 struct wmi_gtx_config *gtx_info)
5310{
5311 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5312 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305313 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305314 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305315
Govind Singh4eacd2b2016-03-07 14:24:22 +05305316 buf = wmi_buf_alloc(wmi_handle, len);
5317 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305318 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305319 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305320 }
5321 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5322 WMITLV_SET_HDR(&cmd->tlv_header,
5323 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5324 WMITLV_GET_STRUCT_TLVLEN
5325 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5326 cmd->vdev_id = if_id;
5327
5328 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5329 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5330 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5331 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5332 cmd->gtxPERMargin = gtx_info->gtx_margin;
5333 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5334 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5335 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5336
Govind Singhb53420c2016-03-09 14:32:57 +05305337 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305338 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5339 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5340 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5341 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5342
Abhishek Singh716c46c2016-05-04 16:24:07 +05305343 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305344 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305345 if (QDF_IS_STATUS_ERROR(ret)) {
5346 WMI_LOGE("Failed to set GTX PARAMS");
5347 wmi_buf_free(buf);
5348 }
5349 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305350}
5351
5352/**
5353 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5354 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305355 * @vdev_id: vdev id.
5356 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305357 *
5358 * This function updates EDCA parameters to the target
5359 *
5360 * Return: CDF Status
5361 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305362static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005363 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305364 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305365{
5366 uint8_t *buf_ptr;
5367 wmi_buf_t buf;
5368 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305369 wmi_wmm_vparams *wmm_param;
5370 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305371 int len = sizeof(*cmd);
5372 int ac;
5373
5374 buf = wmi_buf_alloc(wmi_handle, len);
5375
5376 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305377 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5378 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305379 }
5380
5381 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5382 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5383 WMITLV_SET_HDR(&cmd->tlv_header,
5384 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5385 WMITLV_GET_STRUCT_TLVLEN
5386 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5387 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005388 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305389
5390 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5391 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305392 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305393 WMITLV_SET_HDR(&wmm_param->tlv_header,
5394 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5395 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5396 wmm_param->cwmin = twmm_param->cwmin;
5397 wmm_param->cwmax = twmm_param->cwmax;
5398 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005399 if (mu_edca_param)
5400 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5401 else
5402 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305403 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305404 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305405 }
5406
5407 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5408 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5409 goto fail;
5410
Govind Singhb53420c2016-03-09 14:32:57 +05305411 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305412
5413fail:
5414 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305415 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5416 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305417}
5418
5419/**
5420 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5421 * @wmi_handle: wmi handle
5422 * @vdev_id: vdev id
5423 * @probe_rsp_info: probe response info
5424 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305425 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305426 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305427static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305428 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005429 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305430{
5431 wmi_prb_tmpl_cmd_fixed_param *cmd;
5432 wmi_bcn_prb_info *bcn_prb_info;
5433 wmi_buf_t wmi_buf;
5434 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5435 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305436 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305437
Govind Singhb53420c2016-03-09 14:32:57 +05305438 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305439
Krunal Soni89426862017-11-14 15:42:48 -08005440 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305441 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305442
5443 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5444 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5445 tmpl_len_aligned;
5446
5447 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305448 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305449 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305450 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305451 }
5452
5453 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5454 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305455 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305456 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305457 }
5458
5459 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5460
5461 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5462 WMITLV_SET_HDR(&cmd->tlv_header,
5463 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5464 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5465 cmd->vdev_id = vdev_id;
5466 cmd->buf_len = tmpl_len;
5467 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5468
5469 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5470 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5471 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5472 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5473 bcn_prb_info->caps = 0;
5474 bcn_prb_info->erp = 0;
5475 buf_ptr += sizeof(wmi_bcn_prb_info);
5476
5477 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5478 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005479 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305480
5481 ret = wmi_unified_cmd_send(wmi_handle,
5482 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305483 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305484 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305485 wmi_buf_free(wmi_buf);
5486 }
5487
5488 return ret;
5489}
5490
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305491#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305492#define WPI_IV_LEN 16
5493
5494/**
5495 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5496 *
5497 * @dest_tx: destination address of tsc key counter
5498 * @src_tx: source address of tsc key counter
5499 * @dest_rx: destination address of rsc key counter
5500 * @src_rx: source address of rsc key counter
5501 *
5502 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5503 *
5504 * Return: None
5505 *
5506 */
5507static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5508 uint8_t *dest_rx, uint8_t *src_rx)
5509{
5510 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5511 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5512}
5513#else
5514static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5515 uint8_t *dest_rx, uint8_t *src_rx)
5516{
5517 return;
5518}
5519#endif
5520
5521/**
5522 * send_setup_install_key_cmd_tlv() - set key parameters
5523 * @wmi_handle: wmi handle
5524 * @key_params: key parameters
5525 *
5526 * This function fills structure from information
5527 * passed in key_params.
5528 *
5529 * Return: QDF_STATUS_SUCCESS - success
5530 * QDF_STATUS_E_FAILURE - failure
5531 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5532 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305533static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305534 struct set_key_params *key_params)
5535{
5536 wmi_vdev_install_key_cmd_fixed_param *cmd;
5537 wmi_buf_t buf;
5538 uint8_t *buf_ptr;
5539 uint32_t len;
5540 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305541 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305542
5543 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5544 WMI_TLV_HDR_SIZE;
5545
5546 buf = wmi_buf_alloc(wmi_handle, len);
5547 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305548 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305549 return QDF_STATUS_E_NOMEM;
5550 }
5551
5552 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5553 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5554 WMITLV_SET_HDR(&cmd->tlv_header,
5555 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5556 WMITLV_GET_STRUCT_TLVLEN
5557 (wmi_vdev_install_key_cmd_fixed_param));
5558 cmd->vdev_id = key_params->vdev_id;
5559 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305560
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305561
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305562 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5563 cmd->key_flags |= key_params->key_flags;
5564 cmd->key_cipher = key_params->key_cipher;
5565 if ((key_params->key_txmic_len) &&
5566 (key_params->key_rxmic_len)) {
5567 cmd->key_txmic_len = key_params->key_txmic_len;
5568 cmd->key_rxmic_len = key_params->key_rxmic_len;
5569 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305570#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305571 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5572 key_params->tx_iv,
5573 cmd->wpi_key_rsc_counter,
5574 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305575#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305576 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5577 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5578 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305579 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305580 qdf_mem_copy((void *)key_data,
5581 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005582 if (key_params->key_rsc_counter)
5583 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5584 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305585 cmd->key_len = key_params->key_len;
5586
5587 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5588 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305589 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305590 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305591
Govind Singh67922e82016-04-01 16:48:57 +05305592 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305593}
5594
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305595/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005596 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5597 * @wmi_handle: wmi handle
5598 * @params: sar limit params
5599 *
5600 * Return: QDF_STATUS_SUCCESS for success or error code
5601 */
5602static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5603 struct sar_limit_cmd_params *sar_limit_params)
5604{
5605 wmi_buf_t buf;
5606 QDF_STATUS qdf_status;
5607 wmi_sar_limits_cmd_fixed_param *cmd;
5608 int i;
5609 uint8_t *buf_ptr;
5610 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5611 struct sar_limit_cmd_row *sar_rows_list;
5612 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5613
5614 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5615 buf = wmi_buf_alloc(wmi_handle, len);
5616 if (!buf) {
5617 WMI_LOGE("Failed to allocate memory");
5618 qdf_status = QDF_STATUS_E_NOMEM;
5619 goto end;
5620 }
5621
5622 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5623 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5624 WMITLV_SET_HDR(&cmd->tlv_header,
5625 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5626 WMITLV_GET_STRUCT_TLVLEN
5627 (wmi_sar_limits_cmd_fixed_param));
5628 cmd->sar_enable = sar_limit_params->sar_enable;
5629 cmd->commit_limits = sar_limit_params->commit_limits;
5630 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5631
5632 WMI_LOGD("no of sar rows = %d, len = %d",
5633 sar_limit_params->num_limit_rows, len);
5634 buf_ptr += sizeof(*cmd);
5635 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5636 sizeof(wmi_sar_limit_cmd_row) *
5637 sar_limit_params->num_limit_rows);
5638 if (cmd->num_limit_rows == 0)
5639 goto send_sar_limits;
5640
5641 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5642 (buf_ptr + WMI_TLV_HDR_SIZE);
5643 sar_rows_list = sar_limit_params->sar_limit_row_list;
5644
5645 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5646 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5647 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5648 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5649 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5650 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5651 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5652 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5653 wmi_sar_rows_list->validity_bitmap =
5654 sar_rows_list->validity_bitmap;
5655 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5656 i, wmi_sar_rows_list->band_id,
5657 wmi_sar_rows_list->chain_id,
5658 wmi_sar_rows_list->mod_id,
5659 wmi_sar_rows_list->limit_value,
5660 wmi_sar_rows_list->validity_bitmap);
5661 sar_rows_list++;
5662 wmi_sar_rows_list++;
5663 }
5664send_sar_limits:
5665 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5666 WMI_SAR_LIMITS_CMDID);
5667
5668 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5669 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5670 wmi_buf_free(buf);
5671 }
5672
5673end:
5674 return qdf_status;
5675}
5676
Jeff Johnson4783f902017-12-14 15:50:16 -08005677static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5678{
5679 wmi_sar_get_limits_cmd_fixed_param *cmd;
5680 wmi_buf_t wmi_buf;
5681 uint32_t len;
5682 QDF_STATUS status;
5683
5684 WMI_LOGD(FL("Enter"));
5685
5686 len = sizeof(*cmd);
5687 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5688 if (!wmi_buf) {
5689 WMI_LOGP(FL("failed to allocate memory for msg"));
5690 return QDF_STATUS_E_NOMEM;
5691 }
5692
5693 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5694
5695 WMITLV_SET_HDR(&cmd->tlv_header,
5696 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5697 WMITLV_GET_STRUCT_TLVLEN
5698 (wmi_sar_get_limits_cmd_fixed_param));
5699
5700 cmd->reserved = 0;
5701
5702 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5703 WMI_SAR_GET_LIMITS_CMDID);
5704 if (QDF_IS_STATUS_ERROR(status)) {
5705 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5706 wmi_buf_free(wmi_buf);
5707 }
5708
5709 WMI_LOGD(FL("Exit"));
5710
5711 return status;
5712}
5713
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07005714/**
5715 * wmi_sar2_result_string() - return string conversion of sar2 result
5716 * @result: sar2 result value
5717 *
5718 * This utility function helps log string conversion of sar2 result.
5719 *
5720 * Return: string conversion of sar 2 result, if match found;
5721 * "Unknown response" otherwise.
5722 */
5723static const char *wmi_sar2_result_string(uint32_t result)
5724{
5725 switch (result) {
5726 CASE_RETURN_STRING(WMI_SAR2_SUCCESS);
5727 CASE_RETURN_STRING(WMI_SAR2_INVALID_ANTENNA_INDEX);
5728 CASE_RETURN_STRING(WMI_SAR2_INVALID_TABLE_INDEX);
5729 CASE_RETURN_STRING(WMI_SAR2_STATE_ERROR);
5730 CASE_RETURN_STRING(WMI_SAR2_BDF_NO_TABLE);
5731 default:
5732 return "Unknown response";
5733 }
5734}
5735
5736/**
5737 * extract_sar2_result_event_tlv() - process sar response event from FW.
5738 * @handle: wma handle
5739 * @event: event buffer
5740 * @len: buffer length
5741 *
5742 * Return: 0 for success or error code
5743 */
5744static QDF_STATUS extract_sar2_result_event_tlv(void *handle,
5745 uint8_t *event,
5746 uint32_t len)
5747{
5748 wmi_sar2_result_event_fixed_param *sar2_fixed_param;
5749
5750 WMI_SAR2_RESULT_EVENTID_param_tlvs *param_buf =
5751 (WMI_SAR2_RESULT_EVENTID_param_tlvs *)event;
5752
5753 if (!param_buf) {
5754 WMI_LOGI("Invalid sar2 result event buffer");
5755 return QDF_STATUS_E_INVAL;
5756 }
5757
5758 sar2_fixed_param = param_buf->fixed_param;
5759 if (!sar2_fixed_param) {
5760 WMI_LOGI("Invalid sar2 result event fixed param buffer");
5761 return QDF_STATUS_E_INVAL;
5762 }
5763
5764 WMI_LOGI("SAR2 result: %s",
5765 wmi_sar2_result_string(sar2_fixed_param->result));
5766
5767 return QDF_STATUS_SUCCESS;
5768}
5769
Jeff Johnson4783f902017-12-14 15:50:16 -08005770static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5771 uint8_t *evt_buf,
5772 struct sar_limit_event *event)
5773{
5774 wmi_sar_get_limits_event_fixed_param *fixed_param;
5775 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5776 wmi_sar_get_limit_event_row *row_in;
5777 struct sar_limit_event_row *row_out;
5778 uint32_t row;
5779
5780 if (!evt_buf) {
5781 WMI_LOGE(FL("input event is NULL"));
5782 return QDF_STATUS_E_INVAL;
5783 }
5784 if (!event) {
5785 WMI_LOGE(FL("output event is NULL"));
5786 return QDF_STATUS_E_INVAL;
5787 }
5788
5789 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5790
5791 fixed_param = param_buf->fixed_param;
5792 if (!fixed_param) {
5793 WMI_LOGE(FL("Invalid fixed param"));
5794 return QDF_STATUS_E_INVAL;
5795 }
5796
5797 event->sar_enable = fixed_param->sar_enable;
5798 event->num_limit_rows = fixed_param->num_limit_rows;
5799
5800 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5801 QDF_ASSERT(0);
5802 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5803 event->num_limit_rows,
5804 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5805 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5806 }
5807
5808 row_in = param_buf->sar_get_limits;
5809 row_out = &event->sar_limit_row[0];
5810 for (row = 0; row < event->num_limit_rows; row++) {
5811 row_out->band_id = row_in->band_id;
5812 row_out->chain_id = row_in->chain_id;
5813 row_out->mod_id = row_in->mod_id;
5814 row_out->limit_value = row_in->limit_value;
5815 row_out++;
5816 row_in++;
5817 }
5818
5819 return QDF_STATUS_SUCCESS;
5820}
5821
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305822#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005823/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305824 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5825 * @wmi_handle: wmi handle
5826 * @params: encrypt/decrypt params
5827 *
5828 * Return: QDF_STATUS_SUCCESS for success or error code
5829 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005830static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305831QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305832 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305833{
5834 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5835 wmi_buf_t wmi_buf;
5836 uint8_t *buf_ptr;
5837 QDF_STATUS ret;
5838 uint32_t len;
5839
5840 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5841
5842 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305843 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305844 WMI_TLV_HDR_SIZE;
5845 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5846 if (!wmi_buf) {
5847 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5848 __func__);
5849 return QDF_STATUS_E_NOMEM;
5850 }
5851
5852 buf_ptr = wmi_buf_data(wmi_buf);
5853 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5854
5855 WMITLV_SET_HDR(&cmd->tlv_header,
5856 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5857 WMITLV_GET_STRUCT_TLVLEN(
5858 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5859
5860 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5861 cmd->key_flag = encrypt_decrypt_params->key_flag;
5862 cmd->key_idx = encrypt_decrypt_params->key_idx;
5863 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5864 cmd->key_len = encrypt_decrypt_params->key_len;
5865 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5866 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5867
5868 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5869 encrypt_decrypt_params->key_len);
5870
5871 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5872 MAX_MAC_HEADER_LEN);
5873
5874 cmd->data_len = encrypt_decrypt_params->data_len;
5875
5876 if (cmd->data_len) {
5877 buf_ptr += sizeof(*cmd);
5878 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5879 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305880 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305881 buf_ptr += WMI_TLV_HDR_SIZE;
5882 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5883 encrypt_decrypt_params->data_len);
5884 }
5885
5886 /* This conversion is to facilitate data to FW in little endian */
5887 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5888 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5889 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5890 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5891 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5892 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5893
5894 ret = wmi_unified_cmd_send(wmi_handle,
5895 wmi_buf, len,
5896 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5897 if (QDF_IS_STATUS_ERROR(ret)) {
5898 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5899 wmi_buf_free(wmi_buf);
5900 }
5901
5902 return ret;
5903}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305904
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305905/**
5906 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5907 * params from event
5908 * @wmi_handle: wmi handle
5909 * @evt_buf: pointer to event buffer
5910 * @resp: Pointer to hold resp parameters
5911 *
5912 * Return: QDF_STATUS_SUCCESS for success or error code
5913 */
5914static
5915QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5916 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5917{
5918 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5919 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5920
5921 param_buf = evt_buf;
5922 if (!param_buf) {
5923 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5924 return QDF_STATUS_E_INVAL;
5925 }
5926
5927 data_event = param_buf->fixed_param;
5928
5929 resp->vdev_id = data_event->vdev_id;
5930 resp->status = data_event->status;
5931
Yeshwanth Sriram Guntukaa79e7f22018-06-22 18:25:45 +05305932 if ((data_event->data_length > param_buf->num_enc80211_frame) ||
5933 (data_event->data_length > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE -
5934 sizeof(*data_event))) {
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305935 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5936 data_event->data_length,
5937 param_buf->num_enc80211_frame);
5938 return QDF_STATUS_E_INVAL;
5939 }
5940
5941 resp->data_len = data_event->data_length;
5942
5943 if (resp->data_len)
5944 resp->data = (uint8_t *)param_buf->enc80211_frame;
5945
5946 return QDF_STATUS_SUCCESS;
5947}
5948#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305949
Govind Singh4eacd2b2016-03-07 14:24:22 +05305950/**
5951 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5952 * @wmi_handle: wmi handle
5953 * @vdev_id: vdev id
5954 * @p2p_ie: p2p IE
5955 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305956 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305957 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305958static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05305959 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305960{
Govind Singh67922e82016-04-01 16:48:57 +05305961 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305962 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5963 wmi_buf_t wmi_buf;
5964 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5965 uint8_t *buf_ptr;
5966
5967 ie_len = (uint32_t) (p2p_ie[1] + 2);
5968
5969 /* More than one P2P IE may be included in a single frame.
5970 If multiple P2P IEs are present, the complete P2P attribute
5971 data consists of the concatenation of the P2P Attribute
5972 fields of the P2P IEs. The P2P Attributes field of each
5973 P2P IE may be any length up to the maximum (251 octets).
5974 In this case host sends one P2P IE to firmware so the length
5975 should not exceed more than 251 bytes
5976 */
5977 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305978 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305979 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305980 }
5981
Vivekc5823092018-03-22 23:27:21 +05305982 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305983
5984 wmi_buf_len =
5985 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5986 WMI_TLV_HDR_SIZE;
5987
5988 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5989 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305990 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305991 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305992 }
5993
5994 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5995
5996 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5997 WMITLV_SET_HDR(&cmd->tlv_header,
5998 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5999 WMITLV_GET_STRUCT_TLVLEN
6000 (wmi_p2p_go_set_beacon_ie_fixed_param));
6001 cmd->vdev_id = vdev_id;
6002 cmd->ie_buf_len = ie_len;
6003
6004 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
6005 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
6006 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05306007 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306008
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05306009 WMI_LOGD("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306010
6011 ret = wmi_unified_cmd_send(wmi_handle,
6012 wmi_buf, wmi_buf_len,
6013 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05306014 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306015 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306016 wmi_buf_free(wmi_buf);
6017 }
6018
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05306019 WMI_LOGD("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306020 return ret;
6021}
6022
6023/**
6024 * send_set_gateway_params_cmd_tlv() - set gateway parameters
6025 * @wmi_handle: wmi handle
6026 * @req: gateway parameter update request structure
6027 *
6028 * This function reads the incoming @req and fill in the destination
6029 * WMI structure and sends down the gateway configs down to the firmware
6030 *
Govind Singhb53420c2016-03-09 14:32:57 +05306031 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05306032 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306033static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306034 struct gateway_update_req_param *req)
6035{
6036 wmi_roam_subnet_change_config_fixed_param *cmd;
6037 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05306038 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306039 int len = sizeof(*cmd);
6040
6041 buf = wmi_buf_alloc(wmi_handle, len);
6042 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306043 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6044 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306045 }
6046
6047 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
6048 WMITLV_SET_HDR(&cmd->tlv_header,
6049 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
6050 WMITLV_GET_STRUCT_TLVLEN(
6051 wmi_roam_subnet_change_config_fixed_param));
6052
6053 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05306054 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
6055 QDF_IPV4_ADDR_SIZE);
6056 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
6057 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306058 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
6059 &cmd->inet_gw_mac_addr);
6060 cmd->max_retries = req->max_retries;
6061 cmd->timeout = req->timeout;
6062 cmd->num_skip_subnet_change_detection_bssid_list = 0;
6063 cmd->flag = 0;
6064 if (req->ipv4_addr_type)
6065 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
6066
6067 if (req->ipv6_addr_type)
6068 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
6069
6070 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6071 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306072 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306073 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306074 ret);
6075 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306076 }
6077
Govind Singh67922e82016-04-01 16:48:57 +05306078 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306079}
6080
6081/**
6082 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
6083 * @wmi_handle: wmi handle
6084 * @req: rssi monitoring request structure
6085 *
6086 * This function reads the incoming @req and fill in the destination
6087 * WMI structure and send down the rssi monitoring configs down to the firmware
6088 *
6089 * Return: 0 on success; error number otherwise
6090 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306091static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306092 struct rssi_monitor_param *req)
6093{
6094 wmi_rssi_breach_monitor_config_fixed_param *cmd;
6095 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05306096 QDF_STATUS ret;
6097 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306098
6099 buf = wmi_buf_alloc(wmi_handle, len);
6100 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306101 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6102 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306103 }
6104
6105 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
6106 WMITLV_SET_HDR(&cmd->tlv_header,
6107 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
6108 WMITLV_GET_STRUCT_TLVLEN(
6109 wmi_rssi_breach_monitor_config_fixed_param));
6110
6111 cmd->vdev_id = req->session_id;
6112 cmd->request_id = req->request_id;
6113 cmd->lo_rssi_reenable_hysteresis = 0;
6114 cmd->hi_rssi_reenable_histeresis = 0;
6115 cmd->min_report_interval = 0;
6116 cmd->max_num_report = 1;
6117 if (req->control) {
6118 /* enable one threshold for each min/max */
6119 cmd->enabled_bitmap = 0x09;
6120 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
6121 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
6122 } else {
6123 cmd->enabled_bitmap = 0;
6124 cmd->low_rssi_breach_threshold[0] = 0;
6125 cmd->hi_rssi_breach_threshold[0] = 0;
6126 }
6127
6128 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6129 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306130 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306131 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05306132 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306133 }
6134
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07006135 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
6136
Govind Singh67922e82016-04-01 16:48:57 +05306137 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306138}
6139
6140/**
6141 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
6142 * @wmi_handle: wmi handle
6143 * @psetoui: OUI parameters
6144 *
6145 * set scan probe OUI parameters in firmware
6146 *
6147 * Return: CDF status
6148 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306149static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306150 struct scan_mac_oui *psetoui)
6151{
6152 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
6153 wmi_buf_t wmi_buf;
6154 uint32_t len;
6155 uint8_t *buf_ptr;
6156 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306157 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306158
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306159 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
6160 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
6161
Govind Singh4eacd2b2016-03-07 14:24:22 +05306162 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6163 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306164 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6165 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306166 }
6167 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6168 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
6169 WMITLV_SET_HDR(&cmd->tlv_header,
6170 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
6171 WMITLV_GET_STRUCT_TLVLEN
6172 (wmi_scan_prob_req_oui_cmd_fixed_param));
6173
6174 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05306175 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05306176 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
6177 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05306178 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306179 cmd->prob_req_oui);
6180
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05306181 cmd->vdev_id = psetoui->vdev_id;
6182 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
6183 if (psetoui->enb_probe_req_sno_randomization)
6184 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
6185
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306186 if (ie_whitelist->white_list) {
6187 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
6188 &cmd->num_vendor_oui,
6189 ie_whitelist);
6190 cmd->flags |=
6191 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
6192 }
6193
6194 buf_ptr += sizeof(*cmd);
6195 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6196 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
6197 buf_ptr += WMI_TLV_HDR_SIZE;
6198
6199 if (cmd->num_vendor_oui != 0) {
6200 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
6201 ie_whitelist->voui);
6202 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
6203 }
6204
Govind Singh4eacd2b2016-03-07 14:24:22 +05306205 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6206 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306207 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306208 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306209 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306210 }
Govind Singhb53420c2016-03-09 14:32:57 +05306211 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306212}
6213
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306214#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306215/**
6216 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6217 * @wmi_handle: wmi handle
6218 * @roam_req: Roam scan offload params
6219 * @buf_ptr: command buffer to send
6220 * @fils_tlv_len: fils tlv length
6221 *
6222 * Return: Updated buffer pointer
6223 */
6224static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6225 struct roam_offload_scan_params *roam_req,
6226 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6227{
6228 wmi_roam_fils_offload_tlv_param *fils_tlv;
6229 wmi_erp_info *erp_info;
6230 struct roam_fils_params *roam_fils_params;
6231
6232 if (!roam_req->add_fils_tlv)
6233 return buf_ptr;
6234
6235 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6236 sizeof(*fils_tlv));
6237 buf_ptr += WMI_TLV_HDR_SIZE;
6238
6239 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6240 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6241 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6242 WMITLV_GET_STRUCT_TLVLEN
6243 (wmi_roam_fils_offload_tlv_param));
6244
6245 roam_fils_params = &roam_req->roam_fils_params;
6246 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6247
6248 erp_info->username_length = roam_fils_params->username_length;
6249 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6250 erp_info->username_length);
6251
6252 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6253
6254 erp_info->rRk_length = roam_fils_params->rrk_length;
6255 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6256 erp_info->rRk_length);
6257
6258 erp_info->rIk_length = roam_fils_params->rik_length;
6259 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6260 erp_info->rIk_length);
6261
6262 erp_info->realm_len = roam_fils_params->realm_len;
6263 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6264 erp_info->realm_len);
6265
6266 buf_ptr += sizeof(*fils_tlv);
6267 return buf_ptr;
6268}
6269#else
6270static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6271 struct roam_offload_scan_params *roam_req,
6272 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6273{
6274 return buf_ptr;
6275}
6276#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306277/**
6278 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6279 * @wmi_handle: wmi handle
6280 * @scan_cmd_fp: start scan command ptr
6281 * @roam_req: roam request param
6282 *
6283 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6284 * of WMI_ROAM_SCAN_MODE.
6285 *
6286 * Return: QDF status
6287 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306288static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306289 wmi_start_scan_cmd_fixed_param *
6290 scan_cmd_fp,
6291 struct roam_offload_scan_params *roam_req)
6292{
6293 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306294 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306295 int len;
6296 uint8_t *buf_ptr;
6297 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306298
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306299#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6300 int auth_mode = roam_req->auth_mode;
6301 wmi_roam_offload_tlv_param *roam_offload_params;
6302 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6303 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6304 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306305 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306306 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306307#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6308 /* Need to create a buf with roam_scan command at
6309 * front and piggyback with scan command */
6310 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6311#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6312 (2 * WMI_TLV_HDR_SIZE) +
6313#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6314 sizeof(wmi_start_scan_cmd_fixed_param);
6315#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006316 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306317 if (roam_req->is_roam_req_valid &&
6318 roam_req->roam_offload_enabled) {
6319 len += sizeof(wmi_roam_offload_tlv_param);
6320 len += WMI_TLV_HDR_SIZE;
6321 if ((auth_mode != WMI_AUTH_NONE) &&
6322 ((auth_mode != WMI_AUTH_OPEN) ||
6323 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306324 roam_req->mdid.mdie_present &&
6325 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306326 roam_req->is_ese_assoc)) {
6327 len += WMI_TLV_HDR_SIZE;
6328 if (roam_req->is_ese_assoc)
6329 len +=
6330 sizeof(wmi_roam_ese_offload_tlv_param);
6331 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6332 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6333 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306334 roam_req->mdid.mdie_present &&
6335 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306336 len +=
6337 sizeof(wmi_roam_11r_offload_tlv_param);
6338 else
6339 len +=
6340 sizeof(wmi_roam_11i_offload_tlv_param);
6341 } else {
6342 len += WMI_TLV_HDR_SIZE;
6343 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306344
6345 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6346 + roundup(roam_req->assoc_ie_length,
6347 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306348
6349 if (roam_req->add_fils_tlv) {
6350 fils_tlv_len = sizeof(
6351 wmi_roam_fils_offload_tlv_param);
6352 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6353 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306354 } else {
6355 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306356 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306357 __func__, roam_req->roam_offload_enabled);
6358 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306359 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306360 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306361 }
6362 if (roam_req->is_roam_req_valid &&
6363 roam_req->roam_offload_enabled) {
6364 roam_req->mode = roam_req->mode |
6365 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6366 }
6367#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6368
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306369 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6370 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6371 len = sizeof(wmi_roam_scan_mode_fixed_param);
6372
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306373 buf = wmi_buf_alloc(wmi_handle, len);
6374 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306375 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306376 return QDF_STATUS_E_NOMEM;
6377 }
6378
6379 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6380 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6381 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6382 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6383 WMITLV_GET_STRUCT_TLVLEN
6384 (wmi_roam_scan_mode_fixed_param));
6385
Abhinav Kumar334355f2018-04-06 17:18:52 +05306386 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6387 roam_req->roam_trigger_reason_bitmask;
6388 roam_scan_mode_fp->min_delay_btw_scans =
6389 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306390 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6391 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306392 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6393 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6394 roam_scan_mode_fp->flags |=
6395 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306396 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306397 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306398
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306399 /* Fill in scan parameters suitable for roaming scan */
6400 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306401
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306402 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6403 sizeof(wmi_start_scan_cmd_fixed_param));
6404 /* Ensure there is no additional IEs */
6405 scan_cmd_fp->ie_len = 0;
6406 WMITLV_SET_HDR(buf_ptr,
6407 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6408 WMITLV_GET_STRUCT_TLVLEN
6409 (wmi_start_scan_cmd_fixed_param));
6410#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6411 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6412 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6413 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6414 sizeof(wmi_roam_offload_tlv_param));
6415 buf_ptr += WMI_TLV_HDR_SIZE;
6416 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6417 WMITLV_SET_HDR(buf_ptr,
6418 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6419 WMITLV_GET_STRUCT_TLVLEN
6420 (wmi_roam_offload_tlv_param));
6421 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6422 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6423 roam_offload_params->select_5g_margin =
6424 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306425 roam_offload_params->handoff_delay_for_rx =
6426 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306427 roam_offload_params->reassoc_failure_timeout =
6428 roam_req->reassoc_failure_timeout;
6429
6430 /* Fill the capabilities */
6431 roam_offload_params->capability =
6432 roam_req->roam_offload_params.capability;
6433 roam_offload_params->ht_caps_info =
6434 roam_req->roam_offload_params.ht_caps_info;
6435 roam_offload_params->ampdu_param =
6436 roam_req->roam_offload_params.ampdu_param;
6437 roam_offload_params->ht_ext_cap =
6438 roam_req->roam_offload_params.ht_ext_cap;
6439 roam_offload_params->ht_txbf =
6440 roam_req->roam_offload_params.ht_txbf;
6441 roam_offload_params->asel_cap =
6442 roam_req->roam_offload_params.asel_cap;
6443 roam_offload_params->qos_caps =
6444 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006445 roam_offload_params->qos_enabled =
6446 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306447 roam_offload_params->wmm_caps =
6448 roam_req->roam_offload_params.wmm_caps;
6449 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6450 (uint8_t *)roam_req->roam_offload_params.mcsset,
6451 ROAM_OFFLOAD_NUM_MCS_SET);
6452
6453 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6454 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6455 * they are filled in the same order.Depending on the
6456 * authentication type, the other mode TLV's are nullified
6457 * and only headers are filled.*/
6458 if ((auth_mode != WMI_AUTH_NONE) &&
6459 ((auth_mode != WMI_AUTH_OPEN) ||
6460 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306461 && roam_req->mdid.mdie_present &&
6462 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306463 roam_req->is_ese_assoc)) {
6464 if (roam_req->is_ese_assoc) {
6465 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6466 WMITLV_GET_STRUCT_TLVLEN(0));
6467 buf_ptr += WMI_TLV_HDR_SIZE;
6468 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6469 WMITLV_GET_STRUCT_TLVLEN(0));
6470 buf_ptr += WMI_TLV_HDR_SIZE;
6471 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6472 sizeof(wmi_roam_ese_offload_tlv_param));
6473 buf_ptr += WMI_TLV_HDR_SIZE;
6474 roam_offload_ese =
6475 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6476 qdf_mem_copy(roam_offload_ese->krk,
6477 roam_req->krk,
6478 sizeof(roam_req->krk));
6479 qdf_mem_copy(roam_offload_ese->btk,
6480 roam_req->btk,
6481 sizeof(roam_req->btk));
6482 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6483 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6484 WMITLV_GET_STRUCT_TLVLEN
6485 (wmi_roam_ese_offload_tlv_param));
6486 buf_ptr +=
6487 sizeof(wmi_roam_ese_offload_tlv_param);
6488 } else if (auth_mode == WMI_AUTH_FT_RSNA
6489 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6490 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306491 && roam_req->mdid.mdie_present &&
6492 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306493 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6494 0);
6495 buf_ptr += WMI_TLV_HDR_SIZE;
6496 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6497 sizeof(wmi_roam_11r_offload_tlv_param));
6498 buf_ptr += WMI_TLV_HDR_SIZE;
6499 roam_offload_11r =
6500 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6501 roam_offload_11r->r0kh_id_len =
6502 roam_req->rokh_id_length;
6503 qdf_mem_copy(roam_offload_11r->r0kh_id,
6504 roam_req->rokh_id,
6505 roam_offload_11r->r0kh_id_len);
6506 qdf_mem_copy(roam_offload_11r->psk_msk,
6507 roam_req->psk_pmk,
6508 sizeof(roam_req->psk_pmk));
6509 roam_offload_11r->psk_msk_len =
6510 roam_req->pmk_len;
6511 roam_offload_11r->mdie_present =
6512 roam_req->mdid.mdie_present;
6513 roam_offload_11r->mdid =
6514 roam_req->mdid.mobility_domain;
6515 if (auth_mode == WMI_AUTH_OPEN) {
6516 /* If FT-Open ensure pmk length
6517 and r0khid len are zero */
6518 roam_offload_11r->r0kh_id_len = 0;
6519 roam_offload_11r->psk_msk_len = 0;
6520 }
6521 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6522 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6523 WMITLV_GET_STRUCT_TLVLEN
6524 (wmi_roam_11r_offload_tlv_param));
6525 buf_ptr +=
6526 sizeof(wmi_roam_11r_offload_tlv_param);
6527 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6528 WMITLV_GET_STRUCT_TLVLEN(0));
6529 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006530 WMI_LOGD("psk_msk_len = %d",
6531 roam_offload_11r->psk_msk_len);
6532 if (roam_offload_11r->psk_msk_len)
6533 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6534 QDF_TRACE_LEVEL_DEBUG,
6535 roam_offload_11r->psk_msk,
6536 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306537 } else {
6538 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6539 sizeof(wmi_roam_11i_offload_tlv_param));
6540 buf_ptr += WMI_TLV_HDR_SIZE;
6541 roam_offload_11i =
6542 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006543
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006544 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006545 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306546 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6547 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006548 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306549 } else {
6550 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6551 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006552 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006553 }
6554 if (roam_req->roam_key_mgmt_offload_enabled &&
6555 roam_req->fw_pmksa_cache) {
6556 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6557 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006558 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006559 } else {
6560 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6561 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006562 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306563 }
6564
6565 qdf_mem_copy(roam_offload_11i->pmk,
6566 roam_req->psk_pmk,
6567 sizeof(roam_req->psk_pmk));
6568 roam_offload_11i->pmk_len = roam_req->pmk_len;
6569 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6570 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6571 WMITLV_GET_STRUCT_TLVLEN
6572 (wmi_roam_11i_offload_tlv_param));
6573 buf_ptr +=
6574 sizeof(wmi_roam_11i_offload_tlv_param);
6575 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6576 0);
6577 buf_ptr += WMI_TLV_HDR_SIZE;
6578 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6579 0);
6580 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006581 WMI_LOGD("pmk_len = %d",
6582 roam_offload_11i->pmk_len);
6583 if (roam_offload_11i->pmk_len)
6584 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6585 QDF_TRACE_LEVEL_DEBUG,
6586 roam_offload_11i->pmk,
6587 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306588 }
6589 } else {
6590 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6591 WMITLV_GET_STRUCT_TLVLEN(0));
6592 buf_ptr += WMI_TLV_HDR_SIZE;
6593 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6594 WMITLV_GET_STRUCT_TLVLEN(0));
6595 buf_ptr += WMI_TLV_HDR_SIZE;
6596 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6597 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306598 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306599 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306600
6601 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6602 sizeof(*assoc_ies));
6603 buf_ptr += WMI_TLV_HDR_SIZE;
6604
6605 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6606 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6607 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6608 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6609 assoc_ies->buf_len = roam_req->assoc_ie_length;
6610
6611 buf_ptr += sizeof(*assoc_ies);
6612
6613 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6614 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6615 buf_ptr += WMI_TLV_HDR_SIZE;
6616
6617 if (assoc_ies->buf_len != 0) {
6618 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6619 assoc_ies->buf_len);
6620 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306621 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6622 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6623 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306624 } else {
6625 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6626 WMITLV_GET_STRUCT_TLVLEN(0));
6627 buf_ptr += WMI_TLV_HDR_SIZE;
6628 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6629 WMITLV_GET_STRUCT_TLVLEN(0));
6630 buf_ptr += WMI_TLV_HDR_SIZE;
6631 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6632 WMITLV_GET_STRUCT_TLVLEN(0));
6633 buf_ptr += WMI_TLV_HDR_SIZE;
6634 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6635 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306636 buf_ptr += WMI_TLV_HDR_SIZE;
6637 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6638 WMITLV_GET_STRUCT_TLVLEN(0));
6639 buf_ptr += WMI_TLV_HDR_SIZE;
6640 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6641 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306642 }
6643#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306644
6645send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306646 status = wmi_unified_cmd_send(wmi_handle, buf,
6647 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306648 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306649 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306650 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6651 status);
6652 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306653 }
6654
Govind Singh67922e82016-04-01 16:48:57 +05306655 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306656}
6657
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006658static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6659 struct wmi_mawc_roam_params *params)
6660{
6661 wmi_buf_t buf = NULL;
6662 QDF_STATUS status;
6663 int len;
6664 uint8_t *buf_ptr;
6665 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6666
6667 len = sizeof(*wmi_roam_mawc_params);
6668 buf = wmi_buf_alloc(wmi_handle, len);
6669 if (!buf) {
6670 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6671 return QDF_STATUS_E_NOMEM;
6672 }
6673
6674 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6675 wmi_roam_mawc_params =
6676 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6677 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6678 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6679 WMITLV_GET_STRUCT_TLVLEN
6680 (wmi_roam_configure_mawc_cmd_fixed_param));
6681 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6682 if (params->enable)
6683 wmi_roam_mawc_params->enable = 1;
6684 else
6685 wmi_roam_mawc_params->enable = 0;
6686 wmi_roam_mawc_params->traffic_load_threshold =
6687 params->traffic_load_threshold;
6688 wmi_roam_mawc_params->best_ap_rssi_threshold =
6689 params->best_ap_rssi_threshold;
6690 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6691 params->rssi_stationary_high_adjust;
6692 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6693 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006694 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6695 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6696 wmi_roam_mawc_params->traffic_load_threshold,
6697 wmi_roam_mawc_params->best_ap_rssi_threshold,
6698 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6699 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006700
6701 status = wmi_unified_cmd_send(wmi_handle, buf,
6702 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6703 if (QDF_IS_STATUS_ERROR(status)) {
6704 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6705 status);
6706 wmi_buf_free(buf);
6707 return status;
6708 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006709
6710 return QDF_STATUS_SUCCESS;
6711}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306712
6713/**
6714 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6715 * rssi threashold
6716 * @wmi_handle: wmi handle
6717 * @roam_req: Roaming request buffer
6718 *
6719 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6720 *
6721 * Return: QDF status
6722 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306723static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306724 struct roam_offload_scan_rssi_params *roam_req)
6725{
6726 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306727 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306728 int len;
6729 uint8_t *buf_ptr;
6730 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6731 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6732 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306733 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006734 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306735
6736 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6737 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6738 len += sizeof(wmi_roam_scan_extended_threshold_param);
6739 len += WMI_TLV_HDR_SIZE;
6740 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306741 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6742 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006743 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6744 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306745 buf = wmi_buf_alloc(wmi_handle, len);
6746 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306747 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306748 return QDF_STATUS_E_NOMEM;
6749 }
6750
6751 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6752 rssi_threshold_fp =
6753 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6754 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6755 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6756 WMITLV_GET_STRUCT_TLVLEN
6757 (wmi_roam_scan_rssi_threshold_fixed_param));
6758 /* fill in threshold values */
6759 rssi_threshold_fp->vdev_id = roam_req->session_id;
6760 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6761 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6762 rssi_threshold_fp->hirssi_scan_max_count =
6763 roam_req->hi_rssi_scan_max_count;
6764 rssi_threshold_fp->hirssi_scan_delta =
6765 roam_req->hi_rssi_scan_rssi_delta;
6766 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006767 rssi_threshold_fp->rssi_thresh_offset_5g =
6768 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306769
6770 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6771 WMITLV_SET_HDR(buf_ptr,
6772 WMITLV_TAG_ARRAY_STRUC,
6773 sizeof(wmi_roam_scan_extended_threshold_param));
6774 buf_ptr += WMI_TLV_HDR_SIZE;
6775 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6776
6777 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6778 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6779 ext_thresholds->boost_threshold_5g =
6780 roam_req->boost_threshold_5g;
6781
6782 ext_thresholds->boost_algorithm_5g =
6783 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6784 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6785 ext_thresholds->penalty_algorithm_5g =
6786 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6787 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6788 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6789 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6790 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6791
6792 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6793 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6794 WMITLV_GET_STRUCT_TLVLEN
6795 (wmi_roam_scan_extended_threshold_param));
6796 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6797 WMITLV_SET_HDR(buf_ptr,
6798 WMITLV_TAG_ARRAY_STRUC,
6799 sizeof(wmi_roam_earlystop_rssi_thres_param));
6800 buf_ptr += WMI_TLV_HDR_SIZE;
6801 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6802 early_stop_thresholds->roam_earlystop_thres_min =
6803 roam_req->roam_earlystop_thres_min;
6804 early_stop_thresholds->roam_earlystop_thres_max =
6805 roam_req->roam_earlystop_thres_max;
6806 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6807 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6808 WMITLV_GET_STRUCT_TLVLEN
6809 (wmi_roam_earlystop_rssi_thres_param));
6810
Gupta, Kapil7e652922016-04-12 15:02:00 +05306811 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6812 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6813 sizeof(wmi_roam_dense_thres_param));
6814 buf_ptr += WMI_TLV_HDR_SIZE;
6815 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6816 dense_thresholds->roam_dense_rssi_thres_offset =
6817 roam_req->dense_rssi_thresh_offset;
6818 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6819 dense_thresholds->roam_dense_traffic_thres =
6820 roam_req->traffic_threshold;
6821 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6822 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6823 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6824 WMITLV_GET_STRUCT_TLVLEN
6825 (wmi_roam_dense_thres_param));
6826
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006827 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6828 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6829 sizeof(wmi_roam_bg_scan_roaming_param));
6830 buf_ptr += WMI_TLV_HDR_SIZE;
6831 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6832 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6833 roam_req->bg_scan_bad_rssi_thresh;
6834 bg_scan_params->roam_bg_scan_client_bitmap =
6835 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306836 bg_scan_params->bad_rssi_thresh_offset_2g =
6837 roam_req->roam_bad_rssi_thresh_offset_2g;
6838 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006839 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6840 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6841 WMITLV_GET_STRUCT_TLVLEN
6842 (wmi_roam_bg_scan_roaming_param));
6843
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306844 status = wmi_unified_cmd_send(wmi_handle, buf,
6845 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306846 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306847 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306848 status);
6849 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306850 }
6851
Govind Singh67922e82016-04-01 16:48:57 +05306852 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306853}
6854
6855/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306856 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6857 * configuration params
6858 * @wma_handle: wma handler
6859 * @dwelltime_params: pointer to dwelltime_params
6860 *
6861 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6862 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006863static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306864QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6865 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6866{
6867 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6868 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6869 wmi_buf_t buf;
6870 uint8_t *buf_ptr;
6871 int32_t err;
6872 int len;
6873
6874 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6875 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6876 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6877 buf = wmi_buf_alloc(wmi_handle, len);
6878 if (!buf) {
6879 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6880 __func__);
6881 return QDF_STATUS_E_NOMEM;
6882 }
6883 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6884 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6885 WMITLV_SET_HDR(&dwell_param->tlv_header,
6886 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6887 WMITLV_GET_STRUCT_TLVLEN
6888 (wmi_scan_adaptive_dwell_config_fixed_param));
6889
6890 dwell_param->enable = dwelltime_params->is_enabled;
6891 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6892 WMITLV_SET_HDR(buf_ptr,
6893 WMITLV_TAG_ARRAY_STRUC,
6894 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6895 buf_ptr += WMI_TLV_HDR_SIZE;
6896
6897 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6898 WMITLV_SET_HDR(&cmd->tlv_header,
6899 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6900 WMITLV_GET_STRUCT_TLVLEN(
6901 wmi_scan_adaptive_dwell_parameters_tlv));
6902
6903 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6904 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6905 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6906 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6907 err = wmi_unified_cmd_send(wmi_handle, buf,
6908 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6909 if (err) {
6910 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6911 wmi_buf_free(buf);
6912 return QDF_STATUS_E_FAILURE;
6913 }
6914
6915 return QDF_STATUS_SUCCESS;
6916}
6917
Nitesh Shah52323d02017-05-22 15:49:00 +05306918/**
6919 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6920 * configuration params
6921 * @wmi_handle: wmi handler
6922 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6923 *
6924 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6925 */
6926static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6927 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6928{
6929 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6930 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6931 wmi_buf_t buf;
6932 uint8_t *buf_ptr;
6933 QDF_STATUS err;
6934 uint32_t i;
6935 int len;
6936
6937 len = sizeof(*dbs_scan_param);
6938 len += WMI_TLV_HDR_SIZE;
6939 len += dbs_scan_params->num_clients * sizeof(*cmd);
6940
6941 buf = wmi_buf_alloc(wmi_handle, len);
6942 if (!buf) {
6943 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6944 return QDF_STATUS_E_NOMEM;
6945 }
6946
6947 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6948 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6949 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6950 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6951 WMITLV_GET_STRUCT_TLVLEN
6952 (wmi_scan_dbs_duty_cycle_fixed_param));
6953
6954 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6955 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6956 buf_ptr += sizeof(*dbs_scan_param);
6957 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6958 (sizeof(*cmd) * dbs_scan_params->num_clients));
6959 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6960
6961 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6962 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6963 WMITLV_SET_HDR(&cmd->tlv_header,
6964 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6965 WMITLV_GET_STRUCT_TLVLEN(
6966 wmi_scan_dbs_duty_cycle_tlv_param));
6967 cmd->module_id = dbs_scan_params->module_id[i];
6968 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6969 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6970 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6971 }
6972
6973 err = wmi_unified_cmd_send(wmi_handle, buf,
6974 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6975 if (QDF_IS_STATUS_ERROR(err)) {
6976 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6977 wmi_buf_free(buf);
6978 return QDF_STATUS_E_FAILURE;
6979 }
6980
6981 return QDF_STATUS_SUCCESS;
6982}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306983
6984/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306985 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6986 * @wmi_handle: wmi handle
6987 * @roam_req: Request which contains the filters
6988 *
6989 * There are filters such as whitelist, blacklist and preferred
6990 * list that need to be applied to the scan results to form the
6991 * probable candidates for roaming.
6992 *
Jeff Johnsonda263992018-05-12 14:22:00 -07006993 * Return: Return success upon successfully passing the
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306994 * parameters to the firmware, otherwise failure.
6995 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306996static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306997 struct roam_scan_filter_params *roam_req)
6998{
6999 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05307000 QDF_STATUS status;
7001 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307002 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307003 uint8_t *buf_ptr;
7004 wmi_roam_filter_fixed_param *roam_filter;
7005 uint8_t *bssid_src_ptr = NULL;
7006 wmi_mac_addr *bssid_dst_ptr = NULL;
7007 wmi_ssid *ssid_ptr = NULL;
7008 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307009 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307010 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307011
7012 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05307013
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307014 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05307015 if (roam_req->num_bssid_black_list)
7016 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
7017 len += WMI_TLV_HDR_SIZE;
7018 if (roam_req->num_ssid_white_list)
7019 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
7020 len += 2 * WMI_TLV_HDR_SIZE;
7021 if (roam_req->num_bssid_preferred_list) {
7022 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05307023 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05307024 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307025 len += WMI_TLV_HDR_SIZE;
7026 if (roam_req->lca_disallow_config_present) {
7027 len += sizeof(*blist_param);
7028 blist_len = sizeof(*blist_param);
7029 }
7030
7031 len += WMI_TLV_HDR_SIZE;
7032 if (roam_req->num_rssi_rejection_ap)
7033 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307034
7035 buf = wmi_buf_alloc(wmi_handle, len);
7036 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307037 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307038 return QDF_STATUS_E_NOMEM;
7039 }
7040
7041 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7042 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
7043 WMITLV_SET_HDR(&roam_filter->tlv_header,
7044 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
7045 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
7046 /* fill in fixed values */
7047 roam_filter->vdev_id = roam_req->session_id;
7048 roam_filter->flags = 0;
7049 roam_filter->op_bitmap = roam_req->op_bitmap;
7050 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
7051 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
7052 roam_filter->num_bssid_preferred_list =
7053 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307054 roam_filter->num_rssi_rejection_ap =
7055 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307056 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
7057
7058 WMITLV_SET_HDR((buf_ptr),
7059 WMITLV_TAG_ARRAY_FIXED_STRUC,
7060 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
7061 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
7062 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7063 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
7064 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
7065 bssid_src_ptr += ATH_MAC_LEN;
7066 bssid_dst_ptr++;
7067 }
7068 buf_ptr += WMI_TLV_HDR_SIZE +
7069 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
7070 WMITLV_SET_HDR((buf_ptr),
7071 WMITLV_TAG_ARRAY_FIXED_STRUC,
7072 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
7073 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
7074 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
7075 qdf_mem_copy(&ssid_ptr->ssid,
7076 &roam_req->ssid_allowed_list[i].mac_ssid,
7077 roam_req->ssid_allowed_list[i].length);
7078 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
7079 ssid_ptr++;
7080 }
7081 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
7082 sizeof(wmi_ssid));
7083 WMITLV_SET_HDR((buf_ptr),
7084 WMITLV_TAG_ARRAY_FIXED_STRUC,
7085 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
7086 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
7087 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7088 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7089 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
7090 (wmi_mac_addr *)bssid_dst_ptr);
7091 bssid_src_ptr += ATH_MAC_LEN;
7092 bssid_dst_ptr++;
7093 }
7094 buf_ptr += WMI_TLV_HDR_SIZE +
7095 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
7096 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7097 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
7098 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
7099 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7100 *bssid_preferred_factor_ptr =
7101 roam_req->bssid_favored_factor[i];
7102 bssid_preferred_factor_ptr++;
7103 }
7104 buf_ptr += WMI_TLV_HDR_SIZE +
7105 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
7106
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307107 WMITLV_SET_HDR(buf_ptr,
7108 WMITLV_TAG_ARRAY_STRUC, blist_len);
7109 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307110 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307111 blist_param =
7112 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
7113 WMITLV_SET_HDR(&blist_param->tlv_header,
7114 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
7115 WMITLV_GET_STRUCT_TLVLEN(
7116 wmi_roam_lca_disallow_config_tlv_param));
7117
7118 blist_param->disallow_duration = roam_req->disallow_duration;
7119 blist_param->rssi_channel_penalization =
7120 roam_req->rssi_channel_penalization;
7121 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05307122 blist_param->disallow_lca_enable_source_bitmap =
7123 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
7124 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307125 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
7126 }
7127
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307128 WMITLV_SET_HDR(buf_ptr,
7129 WMITLV_TAG_ARRAY_STRUC,
7130 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
7131 buf_ptr += WMI_TLV_HDR_SIZE;
7132 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
7133 rssi_rej =
7134 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7135 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7136 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7137 WMITLV_GET_STRUCT_TLVLEN(
7138 wmi_roam_rssi_rejection_oce_config_param));
7139 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7140 roam_req->rssi_rejection_ap[i].bssid.bytes,
7141 &rssi_rej->bssid);
7142 rssi_rej->remaining_disallow_duration =
7143 roam_req->rssi_rejection_ap[i].remaining_duration;
7144 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05307145 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307146 buf_ptr +=
7147 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7148 }
7149
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307150 status = wmi_unified_cmd_send(wmi_handle, buf,
7151 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307152 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307153 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307154 status);
7155 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307156 }
Govind Singh67922e82016-04-01 16:48:57 +05307157
7158 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307159}
7160
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307161#if defined(WLAN_FEATURE_FILS_SK)
7162static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7163 struct hlp_params *params)
7164{
7165 uint32_t len;
7166 uint8_t *buf_ptr;
7167 wmi_buf_t buf = NULL;
7168 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7169
7170 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7171 len += WMI_TLV_HDR_SIZE;
7172 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7173
7174 buf = wmi_buf_alloc(wmi_handle, len);
7175 if (!buf) {
7176 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7177 return QDF_STATUS_E_NOMEM;
7178 }
7179
7180 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7181 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7182 WMITLV_SET_HDR(&hlp_params->tlv_header,
7183 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7184 WMITLV_GET_STRUCT_TLVLEN(
7185 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7186
7187 hlp_params->vdev_id = params->vdev_id;
7188 hlp_params->size = params->hlp_ie_len;
7189 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7190
7191 buf_ptr += sizeof(*hlp_params);
7192
7193 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7194 round_up(params->hlp_ie_len,
7195 sizeof(uint32_t)));
7196 buf_ptr += WMI_TLV_HDR_SIZE;
7197 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7198
7199 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7200 hlp_params->vdev_id, hlp_params->size);
7201 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7202 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7203 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7204 wmi_buf_free(buf);
7205 return QDF_STATUS_E_FAILURE;
7206 }
7207
7208 return QDF_STATUS_SUCCESS;
7209}
7210#endif
7211
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307212#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307213/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7214 * @wmi_handle: wmi handle
7215 * @ipa_offload: ipa offload control parameter
7216 *
7217 * Returns: 0 on success, error number otherwise
7218 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307219static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307220 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307221{
7222 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7223 wmi_buf_t wmi_buf;
7224 uint32_t len;
7225 u_int8_t *buf_ptr;
7226
7227 len = sizeof(*cmd);
7228 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7229 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307230 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7231 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307232 }
7233
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007234 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307235 ipa_offload->offload_type, ipa_offload->enable);
7236
7237 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7238
7239 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7240 WMITLV_SET_HDR(&cmd->tlv_header,
7241 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7242 WMITLV_GET_STRUCT_TLVLEN(
7243 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7244
7245 cmd->offload_type = ipa_offload->offload_type;
7246 cmd->vdev_id = ipa_offload->vdev_id;
7247 cmd->enable = ipa_offload->enable;
7248
7249 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7250 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307251 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307252 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307253 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307254 }
7255
Govind Singhb53420c2016-03-09 14:32:57 +05307256 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307257}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307258#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307259
7260/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307261 * send_plm_stop_cmd_tlv() - plm stop request
7262 * @wmi_handle: wmi handle
7263 * @plm: plm request parameters
7264 *
7265 * This function request FW to stop PLM.
7266 *
7267 * Return: CDF status
7268 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307269static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307270 const struct plm_req_params *plm)
7271{
7272 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7273 int32_t len;
7274 wmi_buf_t buf;
7275 uint8_t *buf_ptr;
7276 int ret;
7277
7278 len = sizeof(*cmd);
7279 buf = wmi_buf_alloc(wmi_handle, len);
7280 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307281 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7282 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307283 }
7284
7285 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7286
7287 buf_ptr = (uint8_t *) cmd;
7288
7289 WMITLV_SET_HDR(&cmd->tlv_header,
7290 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7291 WMITLV_GET_STRUCT_TLVLEN
7292 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7293
7294 cmd->vdev_id = plm->session_id;
7295
7296 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307297 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307298
7299 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7300 WMI_VDEV_PLMREQ_STOP_CMDID);
7301 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307302 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307303 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307304 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307305 }
7306
Govind Singhb53420c2016-03-09 14:32:57 +05307307 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307308}
7309
7310/**
7311 * send_plm_start_cmd_tlv() - plm start request
7312 * @wmi_handle: wmi handle
7313 * @plm: plm request parameters
7314 *
7315 * This function request FW to start PLM.
7316 *
7317 * Return: CDF status
7318 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307319static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307320 const struct plm_req_params *plm,
7321 uint32_t *gchannel_list)
7322{
7323 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7324 uint32_t *channel_list;
7325 int32_t len;
7326 wmi_buf_t buf;
7327 uint8_t *buf_ptr;
7328 uint8_t count;
7329 int ret;
7330
7331 /* TLV place holder for channel_list */
7332 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7333 len += sizeof(uint32_t) * plm->plm_num_ch;
7334
7335 buf = wmi_buf_alloc(wmi_handle, len);
7336 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307337 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7338 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307339 }
7340 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7341
7342 buf_ptr = (uint8_t *) cmd;
7343
7344 WMITLV_SET_HDR(&cmd->tlv_header,
7345 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7346 WMITLV_GET_STRUCT_TLVLEN
7347 (wmi_vdev_plmreq_start_cmd_fixed_param));
7348
7349 cmd->vdev_id = plm->session_id;
7350
7351 cmd->meas_token = plm->meas_token;
7352 cmd->dialog_token = plm->diag_token;
7353 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307354 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307355 cmd->off_duration = plm->meas_duration;
7356 cmd->burst_cycle = plm->burst_len;
7357 cmd->tx_power = plm->desired_tx_pwr;
7358 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7359 cmd->num_chans = plm->plm_num_ch;
7360
7361 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7362
Govind Singhb53420c2016-03-09 14:32:57 +05307363 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7364 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7365 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7366 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7367 WMI_LOGD("off_duration: %d", cmd->off_duration);
7368 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7369 WMI_LOGD("tx_power: %d", cmd->tx_power);
7370 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307371
7372 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7373 (cmd->num_chans * sizeof(uint32_t)));
7374
7375 buf_ptr += WMI_TLV_HDR_SIZE;
7376 if (cmd->num_chans) {
7377 channel_list = (uint32_t *) buf_ptr;
7378 for (count = 0; count < cmd->num_chans; count++) {
7379 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307380 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307381 channel_list[count] =
7382 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307383 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307384 }
7385 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7386 }
7387
7388 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7389 WMI_VDEV_PLMREQ_START_CMDID);
7390 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307391 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307392 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307393 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307394 }
7395
Govind Singhb53420c2016-03-09 14:32:57 +05307396 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307397}
7398
7399/**
7400 * send_pno_stop_cmd_tlv() - PNO stop request
7401 * @wmi_handle: wmi handle
7402 * @vdev_id: vdev id
7403 *
7404 * This function request FW to stop ongoing PNO operation.
7405 *
7406 * Return: CDF status
7407 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307408static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307409{
7410 wmi_nlo_config_cmd_fixed_param *cmd;
7411 int32_t len = sizeof(*cmd);
7412 wmi_buf_t buf;
7413 uint8_t *buf_ptr;
7414 int ret;
7415
7416 /*
7417 * TLV place holder for array of structures nlo_configured_parameters
7418 * TLV place holder for array of uint32_t channel_list
7419 * TLV place holder for chnl prediction cfg
7420 */
7421 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7422 buf = wmi_buf_alloc(wmi_handle, len);
7423 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307424 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7425 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307426 }
7427
7428 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7429 buf_ptr = (uint8_t *) cmd;
7430
7431 WMITLV_SET_HDR(&cmd->tlv_header,
7432 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7433 WMITLV_GET_STRUCT_TLVLEN
7434 (wmi_nlo_config_cmd_fixed_param));
7435
7436 cmd->vdev_id = vdev_id;
7437 cmd->flags = WMI_NLO_CONFIG_STOP;
7438 buf_ptr += sizeof(*cmd);
7439
7440 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7441 buf_ptr += WMI_TLV_HDR_SIZE;
7442
7443 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7444 buf_ptr += WMI_TLV_HDR_SIZE;
7445
7446 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7447 buf_ptr += WMI_TLV_HDR_SIZE;
7448
7449
7450 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7451 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7452 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307453 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307454 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307455 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307456 }
7457
Govind Singhb53420c2016-03-09 14:32:57 +05307458 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307459}
7460
7461/**
Govind Singhccb0c272016-04-01 16:30:08 +05307462 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7463 * @buf_ptr: Buffer passed by upper layers
7464 * @pno: Buffer to be sent to the firmware
7465 *
7466 * Copy the PNO Channel prediction configuration parameters
7467 * passed by the upper layers to a WMI format TLV and send it
7468 * down to the firmware.
7469 *
7470 * Return: None
7471 */
7472static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7473 struct pno_scan_req_params *pno)
7474{
7475 nlo_channel_prediction_cfg *channel_prediction_cfg =
7476 (nlo_channel_prediction_cfg *) buf_ptr;
7477 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7478 WMITLV_TAG_ARRAY_BYTE,
7479 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307480#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307481 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7482 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7483 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7484 channel_prediction_cfg->full_scan_period_ms =
7485 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307486#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307487 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7488 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7489 channel_prediction_cfg->enable,
7490 channel_prediction_cfg->top_k_num,
7491 channel_prediction_cfg->stationary_threshold,
7492 channel_prediction_cfg->full_scan_period_ms);
7493}
7494
7495/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007496 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7497 * @wmi_handle: wmi handle
7498 * @params: configuration parameters
7499 *
7500 * Return: QDF_STATUS
7501 */
7502static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7503 struct nlo_mawc_params *params)
7504{
7505 wmi_buf_t buf = NULL;
7506 QDF_STATUS status;
7507 int len;
7508 uint8_t *buf_ptr;
7509 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7510
7511 len = sizeof(*wmi_nlo_mawc_params);
7512 buf = wmi_buf_alloc(wmi_handle, len);
7513 if (!buf) {
7514 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7515 return QDF_STATUS_E_NOMEM;
7516 }
7517
7518 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7519 wmi_nlo_mawc_params =
7520 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7521 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7522 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7523 WMITLV_GET_STRUCT_TLVLEN
7524 (wmi_nlo_configure_mawc_cmd_fixed_param));
7525 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7526 if (params->enable)
7527 wmi_nlo_mawc_params->enable = 1;
7528 else
7529 wmi_nlo_mawc_params->enable = 0;
7530 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7531 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7532 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07007533 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7534 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7535 wmi_nlo_mawc_params->exp_backoff_ratio,
7536 wmi_nlo_mawc_params->init_scan_interval,
7537 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007538
7539 status = wmi_unified_cmd_send(wmi_handle, buf,
7540 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7541 if (QDF_IS_STATUS_ERROR(status)) {
7542 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7543 status);
7544 wmi_buf_free(buf);
7545 return QDF_STATUS_E_FAILURE;
7546 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007547
7548 return QDF_STATUS_SUCCESS;
7549}
7550
7551/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307552 * send_pno_start_cmd_tlv() - PNO start request
7553 * @wmi_handle: wmi handle
7554 * @pno: PNO request
7555 *
7556 * This function request FW to start PNO request.
7557 * Request: CDF status
7558 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307559static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307560 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307561{
7562 wmi_nlo_config_cmd_fixed_param *cmd;
7563 nlo_configured_parameters *nlo_list;
7564 uint32_t *channel_list;
7565 int32_t len;
7566 wmi_buf_t buf;
7567 uint8_t *buf_ptr;
7568 uint8_t i;
7569 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307570 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307571 connected_nlo_rssi_params *nlo_relative_rssi;
7572 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307573
7574 /*
7575 * TLV place holder for array nlo_configured_parameters(nlo_list)
7576 * TLV place holder for array of uint32_t channel_list
7577 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307578 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307579 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05307580 */
7581 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307582 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307583 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307584
Abhishek Singh5987b632017-03-03 22:09:07 +05307585 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307586 WMI_NLO_MAX_CHAN);
7587 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307588 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307589 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307590 len += sizeof(enlo_candidate_score_params);
7591 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307592 len += sizeof(connected_nlo_rssi_params);
7593 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307594
7595 buf = wmi_buf_alloc(wmi_handle, len);
7596 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307597 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7598 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307599 }
7600
7601 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7602
7603 buf_ptr = (uint8_t *) cmd;
7604 WMITLV_SET_HDR(&cmd->tlv_header,
7605 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7606 WMITLV_GET_STRUCT_TLVLEN
7607 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307608 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307609 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7610
Govind Singh87542482016-06-08 19:40:11 +05307611#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307612 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307613 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307614#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307615 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307616 cmd->active_dwell_time = pno->active_dwell_time;
7617 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307618
Manjeet Singhcd2dc062016-08-11 15:31:34 +05307619 if (pno->do_passive_scan)
7620 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307621 /* Copy scan interval */
7622 cmd->fast_scan_period = pno->fast_scan_period;
7623 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007624 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307625 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007626 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307627 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307628 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307629 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307630
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307631 /* mac randomization attributes */
7632 if (pno->scan_random.randomize) {
7633 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7634 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7635 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7636 pno->scan_random.mac_mask,
7637 &cmd->mac_addr,
7638 &cmd->mac_mask);
7639 }
7640
Govind Singh4eacd2b2016-03-07 14:24:22 +05307641 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7642
Abhishek Singh5987b632017-03-03 22:09:07 +05307643 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307644 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307645 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7646 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7647 buf_ptr += WMI_TLV_HDR_SIZE;
7648
7649 nlo_list = (nlo_configured_parameters *) buf_ptr;
7650 for (i = 0; i < cmd->no_of_ssids; i++) {
7651 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7652 WMITLV_TAG_ARRAY_BYTE,
7653 WMITLV_GET_STRUCT_TLVLEN
7654 (nlo_configured_parameters));
7655 /* Copy ssid and it's length */
7656 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307657 nlo_list[i].ssid.ssid.ssid_len =
7658 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307659 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307660 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307661 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307662 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307663 nlo_list[i].ssid.ssid.ssid_len,
7664 (char *)nlo_list[i].ssid.ssid.ssid,
7665 nlo_list[i].ssid.ssid.ssid_len);
7666
7667 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307668 if (pno->networks_list[i].rssi_thresh &&
7669 pno->networks_list[i].rssi_thresh >
7670 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307671 nlo_list[i].rssi_cond.valid = true;
7672 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307673 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307674 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307675 nlo_list[i].rssi_cond.rssi);
7676 }
7677 nlo_list[i].bcast_nw_type.valid = true;
7678 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307679 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007680 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307681 nlo_list[i].bcast_nw_type.bcast_nw_type);
7682 }
7683 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7684
7685 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307686 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307687 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307688 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307689 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7690 (cmd->num_of_channels * sizeof(uint32_t)));
7691 buf_ptr += WMI_TLV_HDR_SIZE;
7692
7693 channel_list = (uint32_t *) buf_ptr;
7694 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307695 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307696
7697 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307698 channel_list[i] =
7699 wlan_chan_to_freq(pno->
7700 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307701
Govind Singhb53420c2016-03-09 14:32:57 +05307702 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307703 }
7704 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7705 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7706 sizeof(nlo_channel_prediction_cfg));
7707 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307708 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307709 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307710 /** TODO: Discrete firmware doesn't have command/option to configure
7711 * App IE which comes from wpa_supplicant as of part PNO start request.
7712 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307713 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
7714 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7715 buf_ptr += sizeof(enlo_candidate_score_params);
7716
7717 if (ie_whitelist->white_list) {
7718 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
7719 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
7720 &cmd->num_vendor_oui,
7721 ie_whitelist);
7722 }
7723
7724 /* ie white list */
7725 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7726 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
7727 buf_ptr += WMI_TLV_HDR_SIZE;
7728 if (cmd->num_vendor_oui != 0) {
7729 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
7730 ie_whitelist->voui);
7731 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
7732 }
7733
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307734 if (pno->relative_rssi_set)
7735 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
7736
7737 /*
7738 * Firmware calculation using connected PNO params:
7739 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
7740 * deduction of rssi_pref for chosen band_pref and
7741 * addition of rssi_pref for remaining bands (other than chosen band).
7742 */
7743 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
7744 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
7745 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
7746 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
7747 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
7748 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
7749 buf_ptr += sizeof(*nlo_relative_rssi);
7750
7751 /*
7752 * As of now Kernel and Host supports one band and rssi preference.
7753 * Firmware supports array of band and rssi preferences
7754 */
7755 cmd->num_cnlo_band_pref = 1;
7756 WMITLV_SET_HDR(buf_ptr,
7757 WMITLV_TAG_ARRAY_STRUC,
7758 cmd->num_cnlo_band_pref *
7759 sizeof(connected_nlo_bss_band_rssi_pref));
7760 buf_ptr += WMI_TLV_HDR_SIZE;
7761
7762 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
7763 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
7764 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
7765 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
7766 WMITLV_GET_STRUCT_TLVLEN(
7767 connected_nlo_bss_band_rssi_pref));
7768 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
7769 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
7770 WMI_LOGI("band_pref %d, rssi_pref %d",
7771 nlo_band_rssi[i].band,
7772 nlo_band_rssi[i].rssi_pref);
7773 }
7774 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
7775
Govind Singh4eacd2b2016-03-07 14:24:22 +05307776 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7777 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7778 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307779 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307780 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307781 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307782 }
7783
Govind Singhb53420c2016-03-09 14:32:57 +05307784 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307785}
7786
7787/* send_set_ric_req_cmd_tlv() - set ric request element
7788 * @wmi_handle: wmi handle
7789 * @msg: message
7790 * @is_add_ts: is addts required
7791 *
7792 * This function sets ric request element for 11r roaming.
7793 *
7794 * Return: CDF status
7795 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307796static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307797 void *msg, uint8_t is_add_ts)
7798{
7799 wmi_ric_request_fixed_param *cmd;
7800 wmi_ric_tspec *tspec_param;
7801 wmi_buf_t buf;
7802 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307803 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307804 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7805 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7806
7807 buf = wmi_buf_alloc(wmi_handle, len);
7808 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307809 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7810 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307811 }
7812
7813 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7814
7815 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7816 WMITLV_SET_HDR(&cmd->tlv_header,
7817 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7818 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7819 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007820 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307821 else
7822 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7823 cmd->num_ric_request = 1;
7824 cmd->is_add_ric = is_add_ts;
7825
7826 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7827 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7828
7829 buf_ptr += WMI_TLV_HDR_SIZE;
7830 tspec_param = (wmi_ric_tspec *) buf_ptr;
7831 WMITLV_SET_HDR(&tspec_param->tlv_header,
7832 WMITLV_TAG_STRUC_wmi_ric_tspec,
7833 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7834
7835 if (is_add_ts)
7836 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307837#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307838 else
7839 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307840#endif
7841 if (ptspecIE) {
7842 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307843#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307844 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7845 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307846#else
Govind Singh87542482016-06-08 19:40:11 +05307847 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7848 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307849#endif /* ANI_LITTLE_BIT_ENDIAN */
7850
Govind Singh87542482016-06-08 19:40:11 +05307851 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7852 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7853 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7854 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7855 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7856 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7857 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7858 tspec_param->min_data_rate = ptspecIE->minDataRate;
7859 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7860 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7861 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7862 tspec_param->delay_bound = ptspecIE->delayBound;
7863 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7864 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7865 tspec_param->medium_time = 0;
7866 }
Govind Singhb53420c2016-03-09 14:32:57 +05307867 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307868
7869 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7870 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307871 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307872 __func__);
7873 if (is_add_ts)
7874 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307875 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307876 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307877 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307878 }
7879
Govind Singhb53420c2016-03-09 14:32:57 +05307880 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307881}
7882
Qiwei Cai1ccba222018-05-21 16:49:39 +08007883#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +05307884/**
7885 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7886 * @wmi_handle: wmi handle
7887 * @clear_req: ll stats clear request command params
7888 *
Govind Singhb53420c2016-03-09 14:32:57 +05307889 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307890 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307891static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307892 const struct ll_stats_clear_params *clear_req,
7893 uint8_t addr[IEEE80211_ADDR_LEN])
7894{
7895 wmi_clear_link_stats_cmd_fixed_param *cmd;
7896 int32_t len;
7897 wmi_buf_t buf;
7898 uint8_t *buf_ptr;
7899 int ret;
7900
7901 len = sizeof(*cmd);
7902 buf = wmi_buf_alloc(wmi_handle, len);
7903
7904 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307905 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7906 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307907 }
7908
7909 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307910 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307911 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7912
7913 WMITLV_SET_HDR(&cmd->tlv_header,
7914 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7915 WMITLV_GET_STRUCT_TLVLEN
7916 (wmi_clear_link_stats_cmd_fixed_param));
7917
7918 cmd->stop_stats_collection_req = clear_req->stop_req;
7919 cmd->vdev_id = clear_req->sta_id;
7920 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7921
7922 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7923 &cmd->peer_macaddr);
7924
Govind Singhb53420c2016-03-09 14:32:57 +05307925 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7926 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7927 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7928 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7929 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307930 cmd->peer_macaddr); */
7931
7932 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7933 WMI_CLEAR_LINK_STATS_CMDID);
7934 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307935 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307936 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307937 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307938 }
7939
Govind Singhb53420c2016-03-09 14:32:57 +05307940 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7941 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307942}
7943
7944/**
7945 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7946 * @wmi_handle: wmi handle
7947 * @setReq: ll stats set request command params
7948 *
Govind Singhb53420c2016-03-09 14:32:57 +05307949 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307950 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307951static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307952 const struct ll_stats_set_params *set_req)
7953{
7954 wmi_start_link_stats_cmd_fixed_param *cmd;
7955 int32_t len;
7956 wmi_buf_t buf;
7957 uint8_t *buf_ptr;
7958 int ret;
7959
7960 len = sizeof(*cmd);
7961 buf = wmi_buf_alloc(wmi_handle, len);
7962
7963 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307964 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7965 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307966 }
7967
7968 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307969 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307970 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7971
7972 WMITLV_SET_HDR(&cmd->tlv_header,
7973 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7974 WMITLV_GET_STRUCT_TLVLEN
7975 (wmi_start_link_stats_cmd_fixed_param));
7976
7977 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7978 cmd->aggressive_statistics_gathering =
7979 set_req->aggressive_statistics_gathering;
7980
Govind Singhb53420c2016-03-09 14:32:57 +05307981 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7982 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7983 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307984
7985 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7986 WMI_START_LINK_STATS_CMDID);
7987 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307988 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307989 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307990 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307991 }
7992
Govind Singhb53420c2016-03-09 14:32:57 +05307993 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307994}
7995
7996/**
7997 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7998 * @wmi_handle:wmi handle
7999 * @get_req:ll stats get request command params
8000 * @addr: mac address
8001 *
Govind Singhb53420c2016-03-09 14:32:57 +05308002 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308003 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308004static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308005 const struct ll_stats_get_params *get_req,
8006 uint8_t addr[IEEE80211_ADDR_LEN])
8007{
8008 wmi_request_link_stats_cmd_fixed_param *cmd;
8009 int32_t len;
8010 wmi_buf_t buf;
8011 uint8_t *buf_ptr;
8012 int ret;
8013
8014 len = sizeof(*cmd);
8015 buf = wmi_buf_alloc(wmi_handle, len);
8016
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308017 if (!buf) {
8018 WMI_LOGE("%s: buf allocation failed", __func__);
8019 return QDF_STATUS_E_NOMEM;
8020 }
8021
Govind Singh4eacd2b2016-03-07 14:24:22 +05308022 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308023 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308024 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8025
8026 WMITLV_SET_HDR(&cmd->tlv_header,
8027 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8028 WMITLV_GET_STRUCT_TLVLEN
8029 (wmi_request_link_stats_cmd_fixed_param));
8030
8031 cmd->request_id = get_req->req_id;
8032 cmd->stats_type = get_req->param_id_mask;
8033 cmd->vdev_id = get_req->sta_id;
8034
8035 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8036 &cmd->peer_macaddr);
8037
Govind Singhb53420c2016-03-09 14:32:57 +05308038 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008039 WMI_LOGD("Request ID : %u", cmd->request_id);
8040 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308041 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8042 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308043
8044 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8045 WMI_REQUEST_LINK_STATS_CMDID);
8046 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308047 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308048 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308049 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308050 }
8051
Govind Singhb53420c2016-03-09 14:32:57 +05308052 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308053}
Qiwei Cai1ccba222018-05-21 16:49:39 +08008054#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308055
Govind Singh20c5dac2016-03-07 15:33:31 +05308056/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308057 * send_congestion_cmd_tlv() - send request to fw to get CCA
8058 * @wmi_handle: wmi handle
8059 * @vdev_id: vdev id
8060 *
8061 * Return: CDF status
8062 */
8063static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05308064 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308065{
8066 wmi_buf_t buf;
8067 wmi_request_stats_cmd_fixed_param *cmd;
8068 uint8_t len;
8069 uint8_t *buf_ptr;
8070
8071 len = sizeof(*cmd);
8072 buf = wmi_buf_alloc(wmi_handle, len);
8073 if (!buf) {
8074 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8075 return QDF_STATUS_E_FAILURE;
8076 }
8077
8078 buf_ptr = wmi_buf_data(buf);
8079 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8080 WMITLV_SET_HDR(&cmd->tlv_header,
8081 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8082 WMITLV_GET_STRUCT_TLVLEN
8083 (wmi_request_stats_cmd_fixed_param));
8084
8085 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8086 cmd->vdev_id = vdev_id;
8087 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8088 cmd->vdev_id, cmd->stats_id);
8089
8090 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8091 WMI_REQUEST_STATS_CMDID)) {
8092 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8093 __func__);
8094 wmi_buf_free(buf);
8095 return QDF_STATUS_E_FAILURE;
8096 }
8097
8098 return QDF_STATUS_SUCCESS;
8099}
8100
8101/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308102 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8103 * @wmi_handle: wmi handle
8104 * @rssi_req: get RSSI request
8105 *
8106 * Return: CDF status
8107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308108static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308109{
8110 wmi_buf_t buf;
8111 wmi_request_stats_cmd_fixed_param *cmd;
8112 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8113
8114 buf = wmi_buf_alloc(wmi_handle, len);
8115 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308116 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8117 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308118 }
8119
8120 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8121 WMITLV_SET_HDR(&cmd->tlv_header,
8122 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8123 WMITLV_GET_STRUCT_TLVLEN
8124 (wmi_request_stats_cmd_fixed_param));
8125 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8126 if (wmi_unified_cmd_send
8127 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308128 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308129 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308130 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308131 }
8132
Govind Singhb53420c2016-03-09 14:32:57 +05308133 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308134}
8135
8136/**
8137 * send_snr_cmd_tlv() - get RSSI from fw
8138 * @wmi_handle: wmi handle
8139 * @vdev_id: vdev id
8140 *
8141 * Return: CDF status
8142 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308143static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308144{
8145 wmi_buf_t buf;
8146 wmi_request_stats_cmd_fixed_param *cmd;
8147 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8148
8149 buf = wmi_buf_alloc(wmi_handle, len);
8150 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308151 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8152 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308153 }
8154
8155 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8156 cmd->vdev_id = vdev_id;
8157
8158 WMITLV_SET_HDR(&cmd->tlv_header,
8159 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8160 WMITLV_GET_STRUCT_TLVLEN
8161 (wmi_request_stats_cmd_fixed_param));
8162 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8163 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8164 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308165 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308166 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308167 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308168 }
8169
Govind Singhb53420c2016-03-09 14:32:57 +05308170 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308171}
8172
8173/**
8174 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8175 * @wmi_handle: wmi handle
8176 * @link_status: get link params
8177 *
8178 * Return: CDF status
8179 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308180static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308181 struct link_status_params *link_status)
8182{
8183 wmi_buf_t buf;
8184 wmi_request_stats_cmd_fixed_param *cmd;
8185 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8186
8187 buf = wmi_buf_alloc(wmi_handle, len);
8188 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308189 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8190 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308191 }
8192
8193 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8194 WMITLV_SET_HDR(&cmd->tlv_header,
8195 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8196 WMITLV_GET_STRUCT_TLVLEN
8197 (wmi_request_stats_cmd_fixed_param));
8198 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8199 cmd->vdev_id = link_status->session_id;
8200 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8201 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308202 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308203 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308204 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308205 }
8206
Govind Singhb53420c2016-03-09 14:32:57 +05308207 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308208}
8209
Govind Singh20c5dac2016-03-07 15:33:31 +05308210/**
8211 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8212 * @wmi_handle: wmi handle
8213 * @ta_dhcp_ind: DHCP indication parameter
8214 *
8215 * Return: CDF Status
8216 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308217static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308218 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8219{
Govind Singh67922e82016-04-01 16:48:57 +05308220 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308221 wmi_buf_t buf = NULL;
8222 uint8_t *buf_ptr;
8223 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8224 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8225
8226
8227 buf = wmi_buf_alloc(wmi_handle, len);
8228 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308229 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8230 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308231 }
8232
8233 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8234 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8235 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8236 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8237 WMITLV_GET_STRUCT_TLVLEN
8238 (wmi_peer_set_param_cmd_fixed_param));
8239
8240 /* fill in values */
8241 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8242 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8243 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308244 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308245 &ta_dhcp_ind->peer_macaddr,
8246 sizeof(ta_dhcp_ind->peer_macaddr));
8247
8248 status = wmi_unified_cmd_send(wmi_handle, buf,
8249 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308250 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308251 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308252 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308253 wmi_buf_free(buf);
8254 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308255
Govind Singh67922e82016-04-01 16:48:57 +05308256 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308257}
8258
8259/**
8260 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8261 * @wmi_handle: wmi handle
8262 * @pLinkSpeed: link speed info
8263 *
8264 * Return: CDF status
8265 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308266static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308267 wmi_mac_addr peer_macaddr)
8268{
8269 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8270 wmi_buf_t wmi_buf;
8271 uint32_t len;
8272 uint8_t *buf_ptr;
8273
8274 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8275 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8276 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308277 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8278 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308279 }
8280 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8281
8282 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8283 WMITLV_SET_HDR(&cmd->tlv_header,
8284 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8285 WMITLV_GET_STRUCT_TLVLEN
8286 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8287
8288 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308289 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308290 &peer_macaddr,
8291 sizeof(peer_macaddr));
8292
8293
8294 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8295 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308296 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308297 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308298 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308299 }
Govind Singhb53420c2016-03-09 14:32:57 +05308300 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308301}
8302
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308303#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308304/**
8305 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8306 * @wmi_handle: wmi handler
8307 * @egap_params: pointer to egap_params
8308 *
8309 * Return: 0 for success, otherwise appropriate error code
8310 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308311static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308312 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308313{
8314 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8315 wmi_buf_t buf;
8316 int32_t err;
8317
8318 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8319 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308320 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8321 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308322 }
8323 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8324 WMITLV_SET_HDR(&cmd->tlv_header,
8325 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8326 WMITLV_GET_STRUCT_TLVLEN(
8327 wmi_ap_ps_egap_param_cmd_fixed_param));
8328
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308329 cmd->enable = egap_params->host_enable_egap;
8330 cmd->inactivity_time = egap_params->egap_inactivity_time;
8331 cmd->wait_time = egap_params->egap_wait_time;
8332 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308333 err = wmi_unified_cmd_send(wmi_handle, buf,
8334 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8335 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308336 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308337 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308338 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308339 }
8340
Govind Singhb53420c2016-03-09 14:32:57 +05308341 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308342}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308343#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308344
8345/**
8346 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8347 * @wmi_handl: wmi handle
8348 * @cmd: Profiling command index
8349 * @value1: parameter1 value
8350 * @value2: parameter2 value
8351 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308352 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308353 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308354static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308355 uint32_t cmd, uint32_t value1, uint32_t value2)
8356{
8357 wmi_buf_t buf;
8358 int32_t len = 0;
8359 int ret;
8360 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8361 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8362 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8363 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8364
8365 switch (cmd) {
8366 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8367 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8368 buf = wmi_buf_alloc(wmi_handle, len);
8369 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308370 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308371 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308372 }
8373 prof_trig_cmd =
8374 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8375 wmi_buf_data(buf);
8376 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8377 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8378 WMITLV_GET_STRUCT_TLVLEN
8379 (wmi_wlan_profile_trigger_cmd_fixed_param));
8380 prof_trig_cmd->enable = value1;
8381 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8382 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8383 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308384 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308385 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308386 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308387 return ret;
8388 }
8389 break;
8390
8391 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8392 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8393 buf = wmi_buf_alloc(wmi_handle, len);
8394 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308395 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308396 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308397 }
8398 profile_getdata_cmd =
8399 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8400 wmi_buf_data(buf);
8401 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8402 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8403 WMITLV_GET_STRUCT_TLVLEN
8404 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8405 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8406 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8407 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308408 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308409 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308410 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308411 return ret;
8412 }
8413 break;
8414
8415 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8416 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8417 buf = wmi_buf_alloc(wmi_handle, len);
8418 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308419 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308420 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308421 }
8422 hist_intvl_cmd =
8423 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8424 wmi_buf_data(buf);
8425 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8426 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8427 WMITLV_GET_STRUCT_TLVLEN
8428 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8429 hist_intvl_cmd->profile_id = value1;
8430 hist_intvl_cmd->value = value2;
8431 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8432 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8433 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308434 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308435 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308436 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308437 return ret;
8438 }
8439 break;
8440
8441 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8442 len =
8443 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8444 buf = wmi_buf_alloc(wmi_handle, len);
8445 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308446 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308447 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308448 }
8449 profile_enable_cmd =
8450 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8451 wmi_buf_data(buf);
8452 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8453 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8454 WMITLV_GET_STRUCT_TLVLEN
8455 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8456 profile_enable_cmd->profile_id = value1;
8457 profile_enable_cmd->enable = value2;
8458 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8459 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8460 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308461 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308462 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308463 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308464 return ret;
8465 }
8466 break;
8467
8468 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308469 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308470 break;
8471 }
8472
8473 return 0;
8474}
8475
Paul Zhang92ab8d32017-12-08 16:08:00 +08008476static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
8477 struct wlm_latency_level_param *params)
8478{
8479 wmi_wlm_config_cmd_fixed_param *cmd;
8480 wmi_buf_t buf;
8481 uint32_t len = sizeof(*cmd);
8482 static uint32_t ll[4] = {100, 60, 40, 20};
8483
8484 buf = wmi_buf_alloc(wmi_handle, len);
8485 if (!buf) {
8486 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8487 return QDF_STATUS_E_NOMEM;
8488 }
8489 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
8490 WMITLV_SET_HDR(&cmd->tlv_header,
8491 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
8492 WMITLV_GET_STRUCT_TLVLEN
8493 (wmi_wlm_config_cmd_fixed_param));
8494 cmd->vdev_id = params->vdev_id;
8495 cmd->latency_level = params->wlm_latency_level;
8496 cmd->ul_latency = ll[params->wlm_latency_level];
8497 cmd->dl_latency = ll[params->wlm_latency_level];
8498 cmd->flags = params->wlm_latency_flags;
8499 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8500 WMI_WLM_CONFIG_CMDID)) {
8501 WMI_LOGE("%s: Failed to send setting latency config command",
8502 __func__);
8503 wmi_buf_free(buf);
8504 return QDF_STATUS_E_FAILURE;
8505 }
8506
8507 return 0;
8508}
Govind Singh20c5dac2016-03-07 15:33:31 +05308509/**
8510 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8511 * @wmi_handle: wmi handle
8512 * @vdev_id: vdev id
8513 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308514 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308515 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308516static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308517{
8518 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8519 wmi_buf_t buf;
8520 int32_t len = sizeof(*cmd);
8521
Govind Singhb53420c2016-03-09 14:32:57 +05308522 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308523 buf = wmi_buf_alloc(wmi_handle, len);
8524 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308525 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308526 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308527 }
8528 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8529 wmi_buf_data(buf);
8530 WMITLV_SET_HDR(&cmd->tlv_header,
8531 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8532 WMITLV_GET_STRUCT_TLVLEN
8533 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8534 cmd->vdev_id = vdev_id;
8535 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8536 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8537 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308538 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308539 __func__);
8540 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308541 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308542 }
8543
8544 return 0;
8545}
8546
8547/**
8548 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8549 * @wmi_handle: wmi handle
8550 * @vdev_id: vdev id
8551 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308552 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308553 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308554static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308555 uint8_t vdev_id)
8556{
8557 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8558 wmi_buf_t buf;
8559 int32_t len = sizeof(*cmd);
8560
Govind Singhb53420c2016-03-09 14:32:57 +05308561 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308562 buf = wmi_buf_alloc(wmi_handle, len);
8563 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308564 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308565 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308566 }
8567 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8568 WMITLV_SET_HDR(&cmd->tlv_header,
8569 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8570 WMITLV_GET_STRUCT_TLVLEN
8571 (wmi_csa_offload_enable_cmd_fixed_param));
8572 cmd->vdev_id = vdev_id;
8573 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8574 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8575 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308576 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308577 __func__);
8578 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308579 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308580 }
8581
8582 return 0;
8583}
8584
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008585#ifdef WLAN_FEATURE_CIF_CFR
8586/**
8587 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8588 * @wmi_handle: wmi handle
8589 * @data_len: len of dma cfg req
8590 * @data: dma cfg req
8591 *
8592 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8593 */
8594static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8595 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8596{
8597 wmi_buf_t buf;
8598 uint8_t *cmd;
8599 QDF_STATUS ret;
8600
8601 WMITLV_SET_HDR(cfg,
8602 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8603 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8604
8605 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8606 if (!buf) {
8607 WMI_LOGE(FL("wmi_buf_alloc failed"));
8608 return QDF_STATUS_E_FAILURE;
8609 }
8610
8611 cmd = (uint8_t *) wmi_buf_data(buf);
8612 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8613 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8614 sizeof(*cfg));
8615 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8616 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8617 if (QDF_IS_STATUS_ERROR(ret)) {
8618 WMI_LOGE(FL(":wmi cmd send failed"));
8619 wmi_buf_free(buf);
8620 }
8621
8622 return ret;
8623}
8624#endif
8625
Govind Singh20c5dac2016-03-07 15:33:31 +05308626/**
Sathish Kumarf396c722017-11-17 17:30:41 +05308627 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
8628 * @wmi_handle: wmi handle
8629 * @data_len: len of dma cfg req
8630 * @data: dma cfg req
8631 *
8632 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8633 */
8634static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8635 struct direct_buf_rx_cfg_req *cfg)
8636{
8637 wmi_buf_t buf;
8638 wmi_dma_ring_cfg_req_fixed_param *cmd;
8639 QDF_STATUS ret;
8640 int32_t len = sizeof(*cmd);
8641
8642 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8643 if (!buf) {
8644 WMI_LOGE(FL("wmi_buf_alloc failed"));
8645 return QDF_STATUS_E_FAILURE;
8646 }
8647
8648 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
8649
8650 WMITLV_SET_HDR(&cmd->tlv_header,
8651 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
8652 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
8653
8654 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8655 cfg->pdev_id);
8656 cmd->mod_id = cfg->mod_id;
8657 cmd->base_paddr_lo = cfg->base_paddr_lo;
8658 cmd->base_paddr_hi = cfg->base_paddr_hi;
8659 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
8660 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
8661 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
8662 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
8663 cmd->num_elems = cfg->num_elems;
8664 cmd->buf_size = cfg->buf_size;
8665 cmd->num_resp_per_event = cfg->num_resp_per_event;
8666 cmd->event_timeout_ms = cfg->event_timeout_ms;
8667
8668 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
8669 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
8670 "head idx paddr hi %x tail idx paddr lo %x"
8671 "tail idx addr hi %x num elems %d buf size %d num resp %d"
8672 "event timeout %d\n", __func__, cmd->pdev_id,
8673 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
8674 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
8675 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
8676 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
8677 cmd->event_timeout_ms);
8678 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8679 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
8680 if (QDF_IS_STATUS_ERROR(ret)) {
8681 WMI_LOGE(FL(":wmi cmd send failed"));
8682 wmi_buf_free(buf);
8683 }
8684
8685 return ret;
8686}
8687
8688/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008689 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8690 * @wmi_handle: wmi handle
8691 * @start_11d_scan: 11d scan start request parameters
8692 *
8693 * This function request FW to start 11d scan.
8694 *
8695 * Return: QDF status
8696 */
8697static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8698 struct reg_start_11d_scan_req *start_11d_scan)
8699{
8700 wmi_11d_scan_start_cmd_fixed_param *cmd;
8701 int32_t len;
8702 wmi_buf_t buf;
8703 int ret;
8704
8705 len = sizeof(*cmd);
8706 buf = wmi_buf_alloc(wmi_handle, len);
8707 if (!buf) {
8708 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8709 return QDF_STATUS_E_NOMEM;
8710 }
8711
8712 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8713
8714 WMITLV_SET_HDR(&cmd->tlv_header,
8715 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8716 WMITLV_GET_STRUCT_TLVLEN
8717 (wmi_11d_scan_start_cmd_fixed_param));
8718
8719 cmd->vdev_id = start_11d_scan->vdev_id;
8720 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8721 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8722
8723 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8724
8725 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8726 WMI_11D_SCAN_START_CMDID);
8727 if (ret) {
8728 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8729 wmi_buf_free(buf);
8730 return QDF_STATUS_E_FAILURE;
8731 }
8732
8733 return QDF_STATUS_SUCCESS;
8734}
8735
8736/**
8737 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8738 * @wmi_handle: wmi handle
8739 * @start_11d_scan: 11d scan stop request parameters
8740 *
8741 * This function request FW to stop 11d scan.
8742 *
8743 * Return: QDF status
8744 */
8745static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8746 struct reg_stop_11d_scan_req *stop_11d_scan)
8747{
8748 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8749 int32_t len;
8750 wmi_buf_t buf;
8751 int ret;
8752
8753 len = sizeof(*cmd);
8754 buf = wmi_buf_alloc(wmi_handle, len);
8755 if (!buf) {
8756 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8757 return QDF_STATUS_E_NOMEM;
8758 }
8759
8760 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8761
8762 WMITLV_SET_HDR(&cmd->tlv_header,
8763 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8764 WMITLV_GET_STRUCT_TLVLEN
8765 (wmi_11d_scan_stop_cmd_fixed_param));
8766
8767 cmd->vdev_id = stop_11d_scan->vdev_id;
8768
8769 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8770
8771 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8772 WMI_11D_SCAN_STOP_CMDID);
8773 if (ret) {
8774 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8775 wmi_buf_free(buf);
8776 return QDF_STATUS_E_FAILURE;
8777 }
8778
8779 return QDF_STATUS_SUCCESS;
8780}
8781
8782/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308783 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8784 * @wmi_handle: wmi handle
8785 * @startOemDataReq: start request params
8786 *
8787 * Return: CDF status
8788 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308789static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008790 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308791 uint8_t *data)
8792{
8793 wmi_buf_t buf;
8794 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308795 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308796
8797 buf = wmi_buf_alloc(wmi_handle,
8798 (data_len + WMI_TLV_HDR_SIZE));
8799 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308800 WMI_LOGE(FL("wmi_buf_alloc failed"));
8801 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308802 }
8803
8804 cmd = (uint8_t *) wmi_buf_data(buf);
8805
8806 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8807 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308808 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308809 data_len);
8810
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008811 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308812 data_len);
8813
8814 ret = wmi_unified_cmd_send(wmi_handle, buf,
8815 (data_len +
8816 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8817
Govind Singh67922e82016-04-01 16:48:57 +05308818 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308819 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308820 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308821 }
8822
Govind Singh67922e82016-04-01 16:48:57 +05308823 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308824}
8825
8826/**
8827 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8828 * @wmi_handle: wmi handle
8829 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8830 *
8831 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8832 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8833 * to firmware based on phyerr filtering
8834 * offload status.
8835 *
8836 * Return: 1 success, 0 failure
8837 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308838static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308839send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8840 bool dfs_phyerr_filter_offload)
8841{
8842 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8843 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8844 wmi_buf_t buf;
8845 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308846 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308847
8848
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008849 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308850 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308851 __func__);
8852 len = sizeof(*disable_phyerr_offload_cmd);
8853 buf = wmi_buf_alloc(wmi_handle, len);
8854 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308855 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308856 return 0;
8857 }
8858 disable_phyerr_offload_cmd =
8859 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8860 wmi_buf_data(buf);
8861
8862 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8863 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8864 WMITLV_GET_STRUCT_TLVLEN
8865 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8866
8867 /*
8868 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8869 * to the firmware to disable the phyerror
8870 * filtering offload.
8871 */
8872 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8873 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308874 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308875 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308876 __func__, ret);
8877 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308878 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308879 }
Govind Singhb53420c2016-03-09 14:32:57 +05308880 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308881 __func__);
8882 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308883 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308884 __func__);
8885
8886 len = sizeof(*enable_phyerr_offload_cmd);
8887 buf = wmi_buf_alloc(wmi_handle, len);
8888 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308889 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8890 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308891 }
8892
8893 enable_phyerr_offload_cmd =
8894 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8895 wmi_buf_data(buf);
8896
8897 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8898 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8899 WMITLV_GET_STRUCT_TLVLEN
8900 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8901
8902 /*
8903 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8904 * to the firmware to enable the phyerror
8905 * filtering offload.
8906 */
8907 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8908 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8909
Govind Singh67922e82016-04-01 16:48:57 +05308910 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308911 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308912 __func__, ret);
8913 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308914 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308915 }
Govind Singhb53420c2016-03-09 14:32:57 +05308916 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308917 __func__);
8918 }
8919
Govind Singhb53420c2016-03-09 14:32:57 +05308920 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308921}
8922
Naveen Rawata5817e72017-10-26 18:50:19 -07008923/**
8924 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
8925 * will wake up host after specified time is elapsed
8926 * @wmi_handle: wmi handle
8927 * @vdev_id: vdev id
8928 * @cookie: value to identify reason why host set up wake call.
8929 * @time: time in ms
8930 *
8931 * Return: QDF status
8932 */
8933static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8934 uint8_t vdev_id, uint32_t cookie, uint32_t time)
8935{
8936 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
8937 wmi_buf_t buf;
8938 uint8_t *buf_ptr;
8939 int32_t len;
8940 int ret;
8941
8942 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
8943 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
8944 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
8945 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
8946 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05308947 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
8948 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008949
8950 buf = wmi_buf_alloc(wmi_handle, len);
8951 if (!buf) {
8952 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8953 return QDF_STATUS_E_NOMEM;
8954 }
8955
8956 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8957 buf_ptr = (uint8_t *) cmd;
8958
8959 WMITLV_SET_HDR(&cmd->tlv_header,
8960 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
8961 WMITLV_GET_STRUCT_TLVLEN
8962 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
8963 cmd->vdev_id = vdev_id;
8964 cmd->pattern_id = cookie,
8965 cmd->pattern_type = WOW_TIMER_PATTERN;
8966 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
8967
8968 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
8969 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8970 buf_ptr += WMI_TLV_HDR_SIZE;
8971
8972 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
8973 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8974 buf_ptr += WMI_TLV_HDR_SIZE;
8975
8976 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
8977 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8978 buf_ptr += WMI_TLV_HDR_SIZE;
8979
8980 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
8981 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8982 buf_ptr += WMI_TLV_HDR_SIZE;
8983
8984 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05308985 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008986 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308987 *((uint32_t *) buf_ptr) = time;
8988 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008989
8990 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05308991 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008992 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308993 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07008994
8995 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
8996 __func__, time, vdev_id);
8997
8998 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8999 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9000 if (ret) {
9001 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9002 __func__);
9003 wmi_buf_free(buf);
9004 return QDF_STATUS_E_FAILURE;
9005 }
9006
9007 return QDF_STATUS_SUCCESS;
9008}
9009
Govind Singh20c5dac2016-03-07 15:33:31 +05309010#if !defined(REMOVE_PKT_LOG)
9011/**
9012 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9013 * @wmi_handle: wmi handle
9014 * @pktlog_event: pktlog event
9015 * @cmd_id: pktlog cmd id
9016 *
9017 * Return: CDF status
9018 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309019static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309020 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309021 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309022{
9023 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9024 WMI_CMD_ID CMD_ID;
9025 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9026 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9027 int len = 0;
9028 wmi_buf_t buf;
9029
9030 PKTLOG_EVENT = pktlog_event;
9031 CMD_ID = cmd_id;
9032
9033 switch (CMD_ID) {
9034 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9035 len = sizeof(*cmd);
9036 buf = wmi_buf_alloc(wmi_handle, len);
9037 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309038 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9039 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309040 }
9041 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9042 wmi_buf_data(buf);
9043 WMITLV_SET_HDR(&cmd->tlv_header,
9044 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9045 WMITLV_GET_STRUCT_TLVLEN
9046 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9047 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309048 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9049 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309050 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9051 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309052 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9053 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309054 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309055 goto wmi_send_failed;
9056 }
9057 break;
9058 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9059 len = sizeof(*disable_cmd);
9060 buf = wmi_buf_alloc(wmi_handle, len);
9061 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309062 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9063 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309064 }
9065 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9066 wmi_buf_data(buf);
9067 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9068 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9069 WMITLV_GET_STRUCT_TLVLEN
9070 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309071 disable_cmd->pdev_id =
9072 wmi_handle->ops->convert_pdev_id_host_to_target(
9073 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309074 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9075 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309076 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309077 goto wmi_send_failed;
9078 }
9079 break;
9080 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309081 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309082 break;
9083 }
9084
Govind Singhb53420c2016-03-09 14:32:57 +05309085 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309086
9087wmi_send_failed:
9088 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309089 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309090}
9091#endif /* REMOVE_PKT_LOG */
9092
9093/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309094 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9095 * @wmi_handle: wmi handle
9096 * @ptrn_id: pattern id
9097 * @vdev_id: vdev id
9098 *
9099 * Return: CDF status
9100 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309101static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9102 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309103{
9104 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9105 wmi_buf_t buf;
9106 int32_t len;
9107 int ret;
9108
9109 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9110
9111
9112 buf = wmi_buf_alloc(wmi_handle, len);
9113 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309114 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9115 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309116 }
9117
9118 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9119
9120 WMITLV_SET_HDR(&cmd->tlv_header,
9121 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9122 WMITLV_GET_STRUCT_TLVLEN(
9123 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9124 cmd->vdev_id = vdev_id;
9125 cmd->pattern_id = ptrn_id;
9126 cmd->pattern_type = WOW_BITMAP_PATTERN;
9127
Govind Singhb53420c2016-03-09 14:32:57 +05309128 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309129 cmd->pattern_id, vdev_id);
9130
9131 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9132 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9133 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309134 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309135 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309136 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309137 }
9138
Govind Singhb53420c2016-03-09 14:32:57 +05309139 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309140}
9141
9142/**
9143 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9144 * @wmi_handle: wmi handle
9145 *
9146 * Sends host wakeup indication to FW. On receiving this indication,
9147 * FW will come out of WOW.
9148 *
9149 * Return: CDF status
9150 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309151static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309152{
9153 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9154 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309155 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309156 int32_t len;
9157 int ret;
9158
9159 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9160
9161 buf = wmi_buf_alloc(wmi_handle, len);
9162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309163 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9164 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309165 }
9166
9167 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9168 wmi_buf_data(buf);
9169 WMITLV_SET_HDR(&cmd->tlv_header,
9170 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9171 WMITLV_GET_STRUCT_TLVLEN
9172 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9173
9174
9175 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9176 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9177 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309178 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309179 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309180 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309181 }
9182
Govind Singhb53420c2016-03-09 14:32:57 +05309183 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309184}
9185
9186/**
9187 * send_del_ts_cmd_tlv() - send DELTS request to fw
9188 * @wmi_handle: wmi handle
9189 * @msg: delts params
9190 *
9191 * Return: CDF status
9192 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309193static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309194 uint8_t ac)
9195{
9196 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9197 wmi_buf_t buf;
9198 int32_t len = sizeof(*cmd);
9199
9200 buf = wmi_buf_alloc(wmi_handle, len);
9201 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309202 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9203 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309204 }
9205 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9206 WMITLV_SET_HDR(&cmd->tlv_header,
9207 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9208 WMITLV_GET_STRUCT_TLVLEN
9209 (wmi_vdev_wmm_delts_cmd_fixed_param));
9210 cmd->vdev_id = vdev_id;
9211 cmd->ac = ac;
9212
Govind Singhb53420c2016-03-09 14:32:57 +05309213 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309214 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9215 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9216 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309217 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309218 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309219 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309220 }
9221
Govind Singhb53420c2016-03-09 14:32:57 +05309222 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309223}
9224
9225/**
9226 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9227 * @wmi_handle: handle to wmi
9228 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9229 *
Govind Singhb53420c2016-03-09 14:32:57 +05309230 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309231 * ADD_TS requestes to firmware in loop for all the ACs with
9232 * active flow.
9233 *
9234 * Return: CDF status
9235 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309236static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309237 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9238{
9239 int i = 0;
9240 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9241 wmi_buf_t buf;
9242 int32_t len = sizeof(*cmd);
9243
9244 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9245 /* if flow in this AC is active */
9246 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9247 /*
9248 * as per implementation of wma_add_ts_req() we
9249 * are not waiting any response from firmware so
9250 * apart from sending ADDTS to firmware just send
9251 * success to upper layers
9252 */
Govind Singhb53420c2016-03-09 14:32:57 +05309253 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309254
9255 buf = wmi_buf_alloc(wmi_handle, len);
9256 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309257 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9258 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309259 }
9260 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9261 wmi_buf_data(buf);
9262 WMITLV_SET_HDR(&cmd->tlv_header,
9263 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9264 WMITLV_GET_STRUCT_TLVLEN
9265 (wmi_vdev_wmm_addts_cmd_fixed_param));
Rajasekaran Kalidoss81f8de22018-08-04 00:17:18 +05309266 cmd->vdev_id = aggr_qos_rsp_msg->vdev_id;
Govind Singh20c5dac2016-03-07 15:33:31 +05309267 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309268 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309269 traffic.userPrio);
9270 cmd->medium_time_us =
9271 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9272 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309273 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309274 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9275 cmd->medium_time_us, cmd->downgrade_type);
9276 if (wmi_unified_cmd_send
9277 (wmi_handle, buf, len,
9278 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309279 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309280 __func__);
9281 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309282 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309283 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309284 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309285 }
9286 }
9287 }
9288
Govind Singhb53420c2016-03-09 14:32:57 +05309289 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309290}
9291
9292/**
9293 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9294 * @wmi_handle: wmi handle
9295 * @msg: ADDTS params
9296 *
9297 * Return: CDF status
9298 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309299static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309300 struct add_ts_param *msg)
9301{
9302 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9303 wmi_buf_t buf;
9304 int32_t len = sizeof(*cmd);
9305
Govind Singhb53420c2016-03-09 14:32:57 +05309306 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309307
9308 buf = wmi_buf_alloc(wmi_handle, len);
9309 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309310 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9311 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309312 }
9313 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9314 WMITLV_SET_HDR(&cmd->tlv_header,
9315 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9316 WMITLV_GET_STRUCT_TLVLEN
9317 (wmi_vdev_wmm_addts_cmd_fixed_param));
9318 cmd->vdev_id = msg->sme_session_id;
9319 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9320 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9321 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309322 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309323 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9324 cmd->downgrade_type, __func__, __LINE__);
9325 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9326 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309327 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9328 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309329 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309330 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309331 }
9332
Govind Singhb53420c2016-03-09 14:32:57 +05309333 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309334}
9335
9336/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309337 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9338 * @wmi_handle: wmi handle
9339 * @pAddPeriodicTxPtrnParams: tx ptrn params
9340 *
9341 * Retrun: CDF status
9342 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309343static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309344 struct periodic_tx_pattern *
9345 pAddPeriodicTxPtrnParams,
9346 uint8_t vdev_id)
9347{
9348 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9349 wmi_buf_t wmi_buf;
9350 uint32_t len;
9351 uint8_t *buf_ptr;
9352 uint32_t ptrn_len, ptrn_len_aligned;
9353 int j;
9354
9355 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9356 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9357 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9358 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9359
9360 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9361 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309362 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9363 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309364 }
9365
9366 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9367
9368 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9369 WMITLV_SET_HDR(&cmd->tlv_header,
9370 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9371 WMITLV_GET_STRUCT_TLVLEN
9372 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9373
9374 /* Pass the pattern id to delete for the corresponding vdev id */
9375 cmd->vdev_id = vdev_id;
9376 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9377 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9378 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9379
9380 /* Pattern info */
9381 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9382 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9383 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309384 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309385 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309386 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309387
Govind Singhb53420c2016-03-09 14:32:57 +05309388 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309389 __func__, cmd->pattern_id, cmd->vdev_id);
9390
9391 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9392 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309393 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309394 __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_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9403 * @wmi_handle: wmi handle
9404 * @vdev_id: vdev id
9405 * @pattern_id: pattern id
9406 *
9407 * Retrun: CDF status
9408 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309409static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309410 uint8_t vdev_id,
9411 uint8_t pattern_id)
9412{
9413 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9414 wmi_buf_t wmi_buf;
9415 uint32_t len =
9416 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9417
9418 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9419 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309420 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9421 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309422 }
9423
9424 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9425 wmi_buf_data(wmi_buf);
9426 WMITLV_SET_HDR(&cmd->tlv_header,
9427 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9428 WMITLV_GET_STRUCT_TLVLEN
9429 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9430
9431 /* Pass the pattern id to delete for the corresponding vdev id */
9432 cmd->vdev_id = vdev_id;
9433 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309434 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309435 __func__, cmd->pattern_id, cmd->vdev_id);
9436
9437 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9438 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309439 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309440 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309441 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309442 }
Govind Singhb53420c2016-03-09 14:32:57 +05309443 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309444}
9445
9446/**
9447 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9448 * @wmi_handle: wmi handle
9449 * @preq: stats ext params
9450 *
9451 * Return: CDF status
9452 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309453static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309454 struct stats_ext_params *preq)
9455{
Govind Singh67922e82016-04-01 16:48:57 +05309456 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309457 wmi_req_stats_ext_cmd_fixed_param *cmd;
9458 wmi_buf_t buf;
Pragaspathi Thilagaraj5920a4b2018-05-16 18:51:32 +05309459 size_t len;
Govind Singh20c5dac2016-03-07 15:33:31 +05309460 uint8_t *buf_ptr;
9461
9462 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9463
9464 buf = wmi_buf_alloc(wmi_handle, len);
9465 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309466 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309467 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309468 }
9469
9470 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9471 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9472
9473 WMITLV_SET_HDR(&cmd->tlv_header,
9474 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9475 WMITLV_GET_STRUCT_TLVLEN
9476 (wmi_req_stats_ext_cmd_fixed_param));
9477 cmd->vdev_id = preq->vdev_id;
9478 cmd->data_len = preq->request_data_len;
9479
Govind Singhb53420c2016-03-09 14:32:57 +05309480 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309481 __func__, preq->request_data_len, preq->vdev_id);
9482
9483 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9484 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9485
9486 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309487 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309488
9489 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9490 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309491 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309492 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309493 ret);
9494 wmi_buf_free(buf);
9495 }
9496
9497 return ret;
9498}
9499
9500/**
9501 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9502 * @wmi_handle: wmi handle
9503 * @params: ext wow params
9504 *
9505 * Return:0 for success or error code
9506 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309507static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309508 struct ext_wow_params *params)
9509{
9510 wmi_extwow_enable_cmd_fixed_param *cmd;
9511 wmi_buf_t buf;
9512 int32_t len;
9513 int ret;
9514
9515 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9516 buf = wmi_buf_alloc(wmi_handle, len);
9517 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309518 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9519 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309520 }
9521
9522 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9523
9524 WMITLV_SET_HDR(&cmd->tlv_header,
9525 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9526 WMITLV_GET_STRUCT_TLVLEN
9527 (wmi_extwow_enable_cmd_fixed_param));
9528
9529 cmd->vdev_id = params->vdev_id;
9530 cmd->type = params->type;
9531 cmd->wakeup_pin_num = params->wakeup_pin_num;
9532
Govind Singhb53420c2016-03-09 14:32:57 +05309533 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309534 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9535
9536 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9537 WMI_EXTWOW_ENABLE_CMDID);
9538 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309539 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309540 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309541 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309542 }
9543
Govind Singhb53420c2016-03-09 14:32:57 +05309544 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309545
9546}
9547
9548/**
9549 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9550 * @wmi_handle: wmi handle
9551 * @app_type1_params: app type1 params
9552 *
9553 * Return: CDF status
9554 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309555static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309556 struct app_type1_params *app_type1_params)
9557{
9558 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9559 wmi_buf_t buf;
9560 int32_t len;
9561 int ret;
9562
9563 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9564 buf = wmi_buf_alloc(wmi_handle, len);
9565 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309566 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9567 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309568 }
9569
9570 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9571 wmi_buf_data(buf);
9572
9573 WMITLV_SET_HDR(&cmd->tlv_header,
9574 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9575 WMITLV_GET_STRUCT_TLVLEN
9576 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9577
9578 cmd->vdev_id = app_type1_params->vdev_id;
9579 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9580 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309581 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309582 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309583 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309584 cmd->passwd_len = app_type1_params->pass_length;
9585
Govind Singhb53420c2016-03-09 14:32:57 +05309586 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309587 "identification_id %.8s id_length %u "
9588 "password %.16s pass_length %u",
9589 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9590 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9591
9592 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9593 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9594 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309595 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309596 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309597 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309598 }
9599
Govind Singhb53420c2016-03-09 14:32:57 +05309600 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309601}
9602
9603/**
9604 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9605 * @wmi_handle: wmi handle
9606 * @appType2Params: app type2 params
9607 *
9608 * Return: CDF status
9609 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309610static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309611 struct app_type2_params *appType2Params)
9612{
9613 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9614 wmi_buf_t buf;
9615 int32_t len;
9616 int ret;
9617
9618 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9619 buf = wmi_buf_alloc(wmi_handle, len);
9620 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309621 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9622 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309623 }
9624
9625 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9626 wmi_buf_data(buf);
9627
9628 WMITLV_SET_HDR(&cmd->tlv_header,
9629 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9630 WMITLV_GET_STRUCT_TLVLEN
9631 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9632
9633 cmd->vdev_id = appType2Params->vdev_id;
9634
Govind Singhb53420c2016-03-09 14:32:57 +05309635 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309636 cmd->rc4_key_len = appType2Params->rc4_key_len;
9637
9638 cmd->ip_id = appType2Params->ip_id;
9639 cmd->ip_device_ip = appType2Params->ip_device_ip;
9640 cmd->ip_server_ip = appType2Params->ip_server_ip;
9641
9642 cmd->tcp_src_port = appType2Params->tcp_src_port;
9643 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9644 cmd->tcp_seq = appType2Params->tcp_seq;
9645 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9646
9647 cmd->keepalive_init = appType2Params->keepalive_init;
9648 cmd->keepalive_min = appType2Params->keepalive_min;
9649 cmd->keepalive_max = appType2Params->keepalive_max;
9650 cmd->keepalive_inc = appType2Params->keepalive_inc;
9651
9652 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9653 &cmd->gateway_mac);
9654 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9655 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9656
Govind Singhb53420c2016-03-09 14:32:57 +05309657 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309658 "rc4_key %.16s rc4_key_len %u "
9659 "ip_id %x ip_device_ip %x ip_server_ip %x "
9660 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9661 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9662 "keepalive_max %u keepalive_inc %u "
9663 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9664 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9665 cmd->rc4_key, cmd->rc4_key_len,
9666 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9667 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9668 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9669 cmd->keepalive_max, cmd->keepalive_inc,
9670 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9671
9672 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9673 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9674 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309675 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309676 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309677 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309678 }
9679
Govind Singhb53420c2016-03-09 14:32:57 +05309680 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309681
9682}
9683
9684/**
9685 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9686 * @wmi_handle: wmi handle
9687 * @timer_val: auto shutdown timer value
9688 *
9689 * Return: CDF status
9690 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309691static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309692 uint32_t timer_val)
9693{
Govind Singh67922e82016-04-01 16:48:57 +05309694 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309695 wmi_buf_t buf = NULL;
9696 uint8_t *buf_ptr;
9697 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9698 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9699
Govind Singhb53420c2016-03-09 14:32:57 +05309700 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309701 __func__, timer_val);
9702
9703 buf = wmi_buf_alloc(wmi_handle, len);
9704 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309705 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9706 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309707 }
9708
9709 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9710 wmi_auto_sh_cmd =
9711 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9712 wmi_auto_sh_cmd->timer_value = timer_val;
9713
9714 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9715 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9716 WMITLV_GET_STRUCT_TLVLEN
9717 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9718
9719 status = wmi_unified_cmd_send(wmi_handle, buf,
9720 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309721 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309722 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309723 __func__, status);
9724 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309725 }
9726
Govind Singh67922e82016-04-01 16:48:57 +05309727 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309728}
9729
9730/**
9731 * send_nan_req_cmd_tlv() - to send nan request to target
9732 * @wmi_handle: wmi handle
9733 * @nan_req: request data which will be non-null
9734 *
9735 * Return: CDF status
9736 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309737static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309738 struct nan_req_params *nan_req)
9739{
Govind Singh67922e82016-04-01 16:48:57 +05309740 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309741 wmi_nan_cmd_param *cmd;
9742 wmi_buf_t buf;
9743 uint16_t len = sizeof(*cmd);
9744 uint16_t nan_data_len, nan_data_len_aligned;
9745 uint8_t *buf_ptr;
9746
9747 /*
9748 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9749 * +------------+----------+-----------------------+--------------+
9750 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9751 * +------------+----------+-----------------------+--------------+
9752 */
9753 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309754 WMI_LOGE("%s:nan req is not valid", __func__);
9755 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309756 }
9757 nan_data_len = nan_req->request_data_len;
9758 nan_data_len_aligned = roundup(nan_req->request_data_len,
9759 sizeof(uint32_t));
Naveen Rawatd30dad62018-05-08 09:40:10 -07009760 if (nan_data_len_aligned < nan_req->request_data_len) {
9761 WMI_LOGE("%s: integer overflow while rounding up data_len",
9762 __func__);
9763 return QDF_STATUS_E_FAILURE;
9764 }
9765
9766 if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
9767 WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen",
9768 __func__);
9769 return QDF_STATUS_E_FAILURE;
9770 }
9771
Govind Singh20c5dac2016-03-07 15:33:31 +05309772 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9773 buf = wmi_buf_alloc(wmi_handle, len);
9774 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309775 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9776 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309777 }
9778 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9779 cmd = (wmi_nan_cmd_param *) buf_ptr;
9780 WMITLV_SET_HDR(&cmd->tlv_header,
9781 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9782 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9783 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309784 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309785 __func__, nan_req->request_data_len);
9786 buf_ptr += sizeof(wmi_nan_cmd_param);
9787 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9788 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309789 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309790
9791 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9792 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309793 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309794 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309795 __func__, ret);
9796 wmi_buf_free(buf);
9797 }
9798
9799 return ret;
9800}
9801
9802/**
9803 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9804 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -07009805 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +05309806 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309807 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309808 */
Jeff Johnsona87370f2017-10-04 19:19:20 -07009809static QDF_STATUS
9810send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
9811 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +05309812{
9813 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9814 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309815 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309816
9817 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9818 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309819 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309820 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309821 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309822 }
9823
9824 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309825
9826 WMITLV_SET_HDR(&cmd->tlv_header,
9827 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9828 WMITLV_GET_STRUCT_TLVLEN
9829 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -07009830 cmd->vdev_id = params->vdev_id;
9831 cmd->enable = params->dhcp_offload_enabled;
9832 cmd->num_client = params->dhcp_client_num;
9833 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +05309834 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309835 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309836 sizeof(*cmd),
9837 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309838 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309839 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309840 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309841 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309842 }
Govind Singhb53420c2016-03-09 14:32:57 +05309843 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -07009844 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309845
9846 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309847}
9848
9849/**
9850 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9851 * @wmi_handle: wmi handle
9852 * @flashing: flashing request
9853 *
9854 * Return: CDF status
9855 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309856static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309857 struct flashing_req_params *flashing)
9858{
9859 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309860 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309861 wmi_buf_t buf;
9862 uint8_t *buf_ptr;
9863 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9864
9865 buf = wmi_buf_alloc(wmi_handle, len);
9866 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309867 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309868 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309869 }
9870 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9871 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9872 WMITLV_SET_HDR(&cmd->tlv_header,
9873 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9874 WMITLV_GET_STRUCT_TLVLEN
9875 (wmi_set_led_flashing_cmd_fixed_param));
9876 cmd->pattern_id = flashing->pattern_id;
9877 cmd->led_x0 = flashing->led_x0;
9878 cmd->led_x1 = flashing->led_x1;
9879
9880 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9881 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309882 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309883 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309884 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309885 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309886 }
Govind Singh67922e82016-04-01 16:48:57 +05309887
9888 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309889}
9890
9891/**
9892 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9893 * @wmi_handle: wmi handle
9894 * @ch_avoid_update_req: channel avoid update params
9895 *
9896 * Return: CDF status
9897 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309898static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309899{
Govind Singh67922e82016-04-01 16:48:57 +05309900 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309901 wmi_buf_t buf = NULL;
9902 uint8_t *buf_ptr;
9903 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9904 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9905
9906
9907 buf = wmi_buf_alloc(wmi_handle, len);
9908 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309909 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9910 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309911 }
9912
9913 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9914 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9915 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9916 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9917 WMITLV_GET_STRUCT_TLVLEN
9918 (wmi_chan_avoid_update_cmd_param));
9919
9920 status = wmi_unified_cmd_send(wmi_handle, buf,
9921 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309922 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309923 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309924 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9925 " returned Error %d", status);
9926 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309927 }
9928
Govind Singh67922e82016-04-01 16:48:57 +05309929 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309930}
9931
9932/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309933 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9934 * @wmi_handle: wmi handle
9935 * @param: pointer to pdev regdomain params
9936 *
9937 * Return: 0 for success or error code
9938 */
9939static QDF_STATUS
9940send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9941 struct pdev_set_regdomain_params *param)
9942{
9943 wmi_buf_t buf;
9944 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9945 int32_t len = sizeof(*cmd);
9946
9947
9948 buf = wmi_buf_alloc(wmi_handle, len);
9949 if (!buf) {
9950 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9951 return QDF_STATUS_E_NOMEM;
9952 }
9953 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9954 WMITLV_SET_HDR(&cmd->tlv_header,
9955 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9956 WMITLV_GET_STRUCT_TLVLEN
9957 (wmi_pdev_set_regdomain_cmd_fixed_param));
9958
9959 cmd->reg_domain = param->currentRDinuse;
9960 cmd->reg_domain_2G = param->currentRD2G;
9961 cmd->reg_domain_5G = param->currentRD5G;
9962 cmd->conformance_test_limit_2G = param->ctl_2G;
9963 cmd->conformance_test_limit_5G = param->ctl_5G;
9964 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309965 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9966 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309967
9968 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9969 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9970 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9971 __func__);
9972 wmi_buf_free(buf);
9973 return QDF_STATUS_E_FAILURE;
9974 }
9975
9976 return QDF_STATUS_SUCCESS;
9977}
9978
9979/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309980 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9981 * @wmi_handle: wmi handle
9982 * @reg_dmn: reg domain
9983 * @regdmn2G: 2G reg domain
9984 * @regdmn5G: 5G reg domain
9985 * @ctl2G: 2G test limit
9986 * @ctl5G: 5G test limit
9987 *
9988 * Return: none
9989 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309990static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309991 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309992 uint16_t regdmn5G, uint8_t ctl2G,
9993 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309994{
9995 wmi_buf_t buf;
9996 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9997 int32_t len = sizeof(*cmd);
9998
9999
10000 buf = wmi_buf_alloc(wmi_handle, len);
10001 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010002 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10003 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010004 }
10005 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10006 WMITLV_SET_HDR(&cmd->tlv_header,
10007 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10008 WMITLV_GET_STRUCT_TLVLEN
10009 (wmi_pdev_set_regdomain_cmd_fixed_param));
10010 cmd->reg_domain = reg_dmn;
10011 cmd->reg_domain_2G = regdmn2G;
10012 cmd->reg_domain_5G = regdmn5G;
10013 cmd->conformance_test_limit_2G = ctl2G;
10014 cmd->conformance_test_limit_5G = ctl5G;
10015
10016 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10017 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010018 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010019 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010020 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010021 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010022 }
10023
Govind Singhb53420c2016-03-09 14:32:57 +053010024 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010025}
10026
10027
10028/**
10029 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10030 * @wmi_handle: wmi handle
10031 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10032 *
10033 * This function sets tdls off channel mode
10034 *
10035 * Return: 0 on success; Negative errno otherwise
10036 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010037static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010038 struct tdls_channel_switch_params *chan_switch_params)
10039{
10040 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10041 wmi_buf_t wmi_buf;
10042 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10043
10044 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10045 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010046 WMI_LOGE(FL("wmi_buf_alloc failed"));
10047 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010048 }
10049 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10050 wmi_buf_data(wmi_buf);
10051 WMITLV_SET_HDR(&cmd->tlv_header,
10052 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10053 WMITLV_GET_STRUCT_TLVLEN(
10054 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10055
10056 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10057 &cmd->peer_macaddr);
10058 cmd->vdev_id = chan_switch_params->vdev_id;
10059 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10060 cmd->is_peer_responder = chan_switch_params->is_responder;
10061 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10062 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10063 cmd->offchan_oper_class = chan_switch_params->oper_class;
10064
Govind Singhb53420c2016-03-09 14:32:57 +053010065 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010066 cmd->peer_macaddr.mac_addr31to0,
10067 cmd->peer_macaddr.mac_addr47to32);
10068
Govind Singhb53420c2016-03-09 14:32:57 +053010069 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010070 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10071 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10072 ),
10073 cmd->vdev_id,
10074 cmd->offchan_mode,
10075 cmd->offchan_num,
10076 cmd->offchan_bw_bitmap,
10077 cmd->is_peer_responder,
10078 cmd->offchan_oper_class);
10079
10080 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10081 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010082 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010083 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010084 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010085 }
10086
10087
Govind Singhb53420c2016-03-09 14:32:57 +053010088 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010089}
10090
10091/**
10092 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10093 * @wmi_handle: wmi handle
10094 * @pwmaTdlsparams: TDLS params
10095 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -070010096 * Return: 0 for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010097 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010098static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010099 void *tdls_param, uint8_t tdls_state)
10100{
10101 wmi_tdls_set_state_cmd_fixed_param *cmd;
10102 wmi_buf_t wmi_buf;
10103
10104 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10105 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10106
10107 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10108 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010109 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10110 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010111 }
10112 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10113 WMITLV_SET_HDR(&cmd->tlv_header,
10114 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10115 WMITLV_GET_STRUCT_TLVLEN
10116 (wmi_tdls_set_state_cmd_fixed_param));
10117 cmd->vdev_id = wmi_tdls->vdev_id;
10118 cmd->state = tdls_state;
10119 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10120 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10121 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10122 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10123 cmd->rssi_delta = wmi_tdls->rssi_delta;
10124 cmd->tdls_options = wmi_tdls->tdls_options;
10125 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10126 cmd->tdls_peer_traffic_response_timeout_ms =
10127 wmi_tdls->peer_traffic_response_timeout;
10128 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10129 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10130 cmd->tdls_puapsd_rx_frame_threshold =
10131 wmi_tdls->puapsd_rx_frame_threshold;
10132 cmd->teardown_notification_ms =
10133 wmi_tdls->teardown_notification_ms;
10134 cmd->tdls_peer_kickout_threshold =
10135 wmi_tdls->tdls_peer_kickout_threshold;
10136
Govind Singhb53420c2016-03-09 14:32:57 +053010137 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010138 "notification_interval_ms: %d, "
10139 "tx_discovery_threshold: %d, "
10140 "tx_teardown_threshold: %d, "
10141 "rssi_teardown_threshold: %d, "
10142 "rssi_delta: %d, "
10143 "tdls_options: 0x%x, "
10144 "tdls_peer_traffic_ind_window: %d, "
10145 "tdls_peer_traffic_response_timeout: %d, "
10146 "tdls_puapsd_mask: 0x%x, "
10147 "tdls_puapsd_inactivity_time: %d, "
10148 "tdls_puapsd_rx_frame_threshold: %d, "
10149 "teardown_notification_ms: %d, "
10150 "tdls_peer_kickout_threshold: %d",
10151 __func__, tdls_state, cmd->state,
10152 cmd->notification_interval_ms,
10153 cmd->tx_discovery_threshold,
10154 cmd->tx_teardown_threshold,
10155 cmd->rssi_teardown_threshold,
10156 cmd->rssi_delta,
10157 cmd->tdls_options,
10158 cmd->tdls_peer_traffic_ind_window,
10159 cmd->tdls_peer_traffic_response_timeout_ms,
10160 cmd->tdls_puapsd_mask,
10161 cmd->tdls_puapsd_inactivity_time_ms,
10162 cmd->tdls_puapsd_rx_frame_threshold,
10163 cmd->teardown_notification_ms,
10164 cmd->tdls_peer_kickout_threshold);
10165
10166 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10167 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010168 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010169 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010170 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010171 }
Govind Singhb53420c2016-03-09 14:32:57 +053010172 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010173
Govind Singhb53420c2016-03-09 14:32:57 +053010174 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010175}
10176
10177/**
10178 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10179 * @wmi_handle: wmi handle
10180 * @peerStateParams: TDLS peer state params
10181 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010182 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010183 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010184static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010185 struct tdls_peer_state_params *peerStateParams,
10186 uint32_t *ch_mhz)
10187{
10188 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10189 wmi_tdls_peer_capabilities *peer_cap;
10190 wmi_channel *chan_info;
10191 wmi_buf_t wmi_buf;
10192 uint8_t *buf_ptr;
10193 uint32_t i;
10194 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10195 sizeof(wmi_tdls_peer_capabilities);
10196
10197
10198 len += WMI_TLV_HDR_SIZE +
10199 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10200
10201 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10202 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010203 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10204 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010205 }
10206
10207 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10208 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10209 WMITLV_SET_HDR(&cmd->tlv_header,
10210 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10211 WMITLV_GET_STRUCT_TLVLEN
10212 (wmi_tdls_peer_update_cmd_fixed_param));
10213
10214 cmd->vdev_id = peerStateParams->vdevId;
10215 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10216 &cmd->peer_macaddr);
10217
10218
10219 cmd->peer_state = peerStateParams->peerState;
10220
Govind Singhb53420c2016-03-09 14:32:57 +053010221 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010222 "peer_macaddr.mac_addr31to0: 0x%x, "
10223 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10224 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10225 cmd->peer_macaddr.mac_addr31to0,
10226 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10227
10228 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10229 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10230 WMITLV_SET_HDR(&peer_cap->tlv_header,
10231 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10232 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10233
10234 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10235 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10236 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10237 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10238 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10239 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10240 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10241 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10242
10243 /* Ack and More Data Ack are sent as 0, so no need to set
10244 * but fill SP
10245 */
10246 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10247 peerStateParams->peerCap.peerMaxSp);
10248
10249 peer_cap->buff_sta_support =
10250 peerStateParams->peerCap.peerBuffStaSupport;
10251 peer_cap->off_chan_support =
10252 peerStateParams->peerCap.peerOffChanSupport;
10253 peer_cap->peer_curr_operclass =
10254 peerStateParams->peerCap.peerCurrOperClass;
10255 /* self curr operclass is not being used and so pass op class for
10256 * preferred off chan in it.
10257 */
10258 peer_cap->self_curr_operclass =
10259 peerStateParams->peerCap.opClassForPrefOffChan;
10260 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10261 peer_cap->peer_operclass_len =
10262 peerStateParams->peerCap.peerOperClassLen;
10263
Govind Singhb53420c2016-03-09 14:32:57 +053010264 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010265 __func__, peer_cap->peer_operclass_len);
10266 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10267 peer_cap->peer_operclass[i] =
10268 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010269 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010270 __func__, i, peer_cap->peer_operclass[i]);
10271 }
10272
10273 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10274 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10275 peer_cap->pref_offchan_bw =
10276 peerStateParams->peerCap.prefOffChanBandwidth;
10277
Govind Singhb53420c2016-03-09 14:32:57 +053010278 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010279 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10280 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10281 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10282 " %d, pref_offchan_bw: %d",
10283 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10284 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10285 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10286 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10287 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10288
10289 /* next fill variable size array of peer chan info */
10290 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10291 WMITLV_SET_HDR(buf_ptr,
10292 WMITLV_TAG_ARRAY_STRUC,
10293 sizeof(wmi_channel) *
10294 peerStateParams->peerCap.peerChanLen);
10295 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10296
10297 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10298 WMITLV_SET_HDR(&chan_info->tlv_header,
10299 WMITLV_TAG_STRUC_wmi_channel,
10300 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10301 chan_info->mhz = ch_mhz[i];
10302 chan_info->band_center_freq1 = chan_info->mhz;
10303 chan_info->band_center_freq2 = 0;
10304
Govind Singhb53420c2016-03-09 14:32:57 +053010305 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010306
10307 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10308 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010309 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010310 peerStateParams->peerCap.peerChan[i].chanId,
10311 peerStateParams->peerCap.peerChan[i].dfsSet);
10312 }
10313
10314 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10315 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10316 else
10317 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10318
10319 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10320 peerStateParams->peerCap.
10321 peerChan[i].pwr);
10322
10323 WMI_SET_CHANNEL_REG_POWER(chan_info,
10324 peerStateParams->peerCap.peerChan[i].
10325 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010326 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010327 peerStateParams->peerCap.peerChan[i].pwr);
10328
10329 chan_info++;
10330 }
10331
10332 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10333 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010334 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010335 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010336 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010337 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010338 }
10339
10340
Govind Singhb53420c2016-03-09 14:32:57 +053010341 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010342}
10343
10344/*
Govind Singh20c5dac2016-03-07 15:33:31 +053010345 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10346 * @wmi_handle: Pointer to WMi handle
10347 * @ie_data: Pointer for ie data
10348 *
10349 * This function sends IE information to firmware
10350 *
Govind Singhb53420c2016-03-09 14:32:57 +053010351 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010352 *
10353 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010354static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010355 struct vdev_ie_info_param *ie_info)
10356{
10357 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10358 wmi_buf_t buf;
10359 uint8_t *buf_ptr;
10360 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010361 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010362
10363
10364 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10365 /* Allocate memory for the WMI command */
10366 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10367
10368 buf = wmi_buf_alloc(wmi_handle, len);
10369 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010370 WMI_LOGE(FL("wmi_buf_alloc failed"));
10371 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010372 }
10373
10374 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010375 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010376
10377 /* Populate the WMI command */
10378 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10379
10380 WMITLV_SET_HDR(&cmd->tlv_header,
10381 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10382 WMITLV_GET_STRUCT_TLVLEN(
10383 wmi_vdev_set_ie_cmd_fixed_param));
10384 cmd->vdev_id = ie_info->vdev_id;
10385 cmd->ie_id = ie_info->ie_id;
10386 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010387 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010388
Govind Singhb53420c2016-03-09 14:32:57 +053010389 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010390 ie_info->length, ie_info->vdev_id);
10391
10392 buf_ptr += sizeof(*cmd);
10393 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10394 buf_ptr += WMI_TLV_HDR_SIZE;
10395
Govind Singhb53420c2016-03-09 14:32:57 +053010396 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010397
10398 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10399 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010400 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010401 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010402 wmi_buf_free(buf);
10403 }
10404
10405 return ret;
10406}
10407
Sathish Kumar497bef42017-03-01 14:02:36 +053010408/**
10409 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10410 *
10411 * @param wmi_handle : handle to WMI.
10412 * @param param : pointer to antenna param
10413 *
10414 * This function sends smart antenna enable command to FW
10415 *
10416 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10417 */
10418static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10419 struct smart_ant_enable_params *param)
10420{
10421 /* Send WMI COMMAND to Enable */
10422 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10423 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10424 wmi_buf_t buf;
10425 uint8_t *buf_ptr;
10426 int len = 0;
10427 QDF_STATUS ret;
10428 int loop = 0;
10429
10430 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10431 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10432 buf = wmi_buf_alloc(wmi_handle, len);
10433
10434 if (!buf) {
10435 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10436 return QDF_STATUS_E_NOMEM;
10437 }
10438
10439 buf_ptr = wmi_buf_data(buf);
10440 qdf_mem_zero(buf_ptr, len);
10441 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10442
10443 WMITLV_SET_HDR(&cmd->tlv_header,
10444 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10445 WMITLV_GET_STRUCT_TLVLEN(
10446 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10447
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010448 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10449 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010450 cmd->enable = param->enable;
10451 cmd->mode = param->mode;
10452 cmd->rx_antenna = param->rx_antenna;
10453 cmd->tx_default_antenna = param->rx_antenna;
10454
10455 /* TLV indicating array of structures to follow */
10456 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10457 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10458 WMI_HAL_MAX_SANTENNA *
10459 sizeof(wmi_pdev_smart_ant_gpio_handle));
10460
10461 buf_ptr += WMI_TLV_HDR_SIZE;
10462 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10463
10464 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10465 WMITLV_SET_HDR(&gpio_param->tlv_header,
10466 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10467 WMITLV_GET_STRUCT_TLVLEN(
10468 wmi_pdev_smart_ant_gpio_handle));
10469 if (param->mode == SMART_ANT_MODE_SERIAL) {
10470 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10471 gpio_param->gpio_pin = param->gpio_pin[loop];
10472 gpio_param->gpio_func = param->gpio_func[loop];
10473 } else {
10474 gpio_param->gpio_pin = 0;
10475 gpio_param->gpio_func = 0;
10476 }
10477 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10478 gpio_param->gpio_pin = param->gpio_pin[loop];
10479 gpio_param->gpio_func = param->gpio_func[loop];
10480 }
10481 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010482 gpio_param->pdev_id =
10483 wmi_handle->ops->convert_pdev_id_host_to_target(
10484 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010485 gpio_param++;
10486 }
10487
10488 ret = wmi_unified_cmd_send(wmi_handle,
10489 buf,
10490 len,
10491 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10492
10493 if (ret != 0) {
10494 WMI_LOGE(" %s :WMI Failed\n", __func__);
10495 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10496 cmd->enable,
10497 cmd->mode,
10498 cmd->rx_antenna,
10499 param->gpio_pin[0], param->gpio_pin[1],
10500 param->gpio_pin[2], param->gpio_pin[3],
10501 param->gpio_func[0], param->gpio_func[1],
10502 param->gpio_func[2], param->gpio_func[3],
10503 ret);
10504 wmi_buf_free(buf);
10505 }
10506
10507 return ret;
10508}
10509
10510/**
10511 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10512 *
10513 * @param wmi_handle : handle to WMI.
10514 * @param param : pointer to rx antenna param
10515 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10516 */
10517static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10518 struct smart_ant_rx_ant_params *param)
10519{
10520 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10521 wmi_buf_t buf;
10522 uint8_t *buf_ptr;
10523 uint32_t len;
10524 QDF_STATUS ret;
10525
10526 len = sizeof(*cmd);
10527 buf = wmi_buf_alloc(wmi_handle, len);
10528 WMI_LOGD("%s:\n", __func__);
10529 if (!buf) {
10530 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10531 return QDF_STATUS_E_NOMEM;
10532 }
10533
10534 buf_ptr = wmi_buf_data(buf);
10535 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10536 WMITLV_SET_HDR(&cmd->tlv_header,
10537 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10538 WMITLV_GET_STRUCT_TLVLEN(
10539 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10540 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010541 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10542 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010543
10544 ret = wmi_unified_cmd_send(wmi_handle,
10545 buf,
10546 len,
10547 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10548
10549 if (ret != 0) {
10550 WMI_LOGE(" %s :WMI Failed\n", __func__);
10551 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10552 __func__,
10553 cmd->rx_antenna,
10554 ret);
10555 wmi_buf_free(buf);
10556 }
10557
10558 return ret;
10559}
10560
10561/**
10562 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10563 * @wmi_handle: wmi handle
10564 * @param: pointer to hold ctl table param
10565 *
10566 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10567 */
10568static QDF_STATUS
10569send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10570 struct ctl_table_params *param)
10571{
10572 uint16_t len, ctl_tlv_len;
10573 uint8_t *buf_ptr;
10574 wmi_buf_t buf;
10575 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10576 uint32_t *ctl_array;
10577
10578 if (!param->ctl_array)
10579 return QDF_STATUS_E_FAILURE;
10580
Sathish Kumar497bef42017-03-01 14:02:36 +053010581 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053010582 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053010583 len = sizeof(*cmd) + ctl_tlv_len;
10584
10585 buf = wmi_buf_alloc(wmi_handle, len);
10586 if (!buf) {
10587 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10588 return QDF_STATUS_E_FAILURE;
10589 }
10590
10591 buf_ptr = wmi_buf_data(buf);
10592 qdf_mem_zero(buf_ptr, len);
10593
10594 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10595
10596 WMITLV_SET_HDR(&cmd->tlv_header,
10597 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10598 WMITLV_GET_STRUCT_TLVLEN(
10599 wmi_pdev_set_ctl_table_cmd_fixed_param));
10600 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010601 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10602 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010603
10604 buf_ptr += sizeof(*cmd);
10605 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10606 (cmd->ctl_len));
10607 buf_ptr += WMI_TLV_HDR_SIZE;
10608 ctl_array = (uint32_t *)buf_ptr;
10609
10610 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10611 sizeof(param->ctl_band));
10612 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10613 param->ctl_cmd_len -
10614 sizeof(param->ctl_band));
10615
10616 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10617 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10618 WMI_LOGE("%s:Failed to send command\n", __func__);
10619 wmi_buf_free(buf);
10620 return QDF_STATUS_E_FAILURE;
10621 }
10622
10623 return QDF_STATUS_SUCCESS;
10624}
10625
10626/**
10627 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10628 * @wmi_handle: wmi handle
10629 * @param: pointer to hold mimogain table param
10630 *
10631 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10632 */
10633static QDF_STATUS
10634send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10635 struct mimogain_table_params *param)
10636{
10637 uint16_t len, table_tlv_len;
10638 wmi_buf_t buf;
10639 uint8_t *buf_ptr;
10640 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10641 uint32_t *gain_table;
10642
10643 if (!param->array_gain)
10644 return QDF_STATUS_E_FAILURE;
10645
10646 /* len must be multiple of a single array gain table */
10647 if (param->tbl_len %
10648 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10649 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10650 WMI_LOGE("Array gain table len not correct\n");
10651 return QDF_STATUS_E_FAILURE;
10652 }
10653
10654 table_tlv_len = WMI_TLV_HDR_SIZE +
10655 roundup(param->tbl_len, sizeof(uint32_t));
10656 len = sizeof(*cmd) + table_tlv_len;
10657
10658 buf = wmi_buf_alloc(wmi_handle, len);
10659 if (!buf) {
10660 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10661 return QDF_STATUS_E_FAILURE;
10662 }
10663
10664 buf_ptr = wmi_buf_data(buf);
10665 qdf_mem_zero(buf_ptr, len);
10666
10667 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10668
10669 WMITLV_SET_HDR(&cmd->tlv_header,
10670 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10671 WMITLV_GET_STRUCT_TLVLEN(
10672 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10673
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010674 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10675 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010676 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10677 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10678 param->multichain_gain_bypass);
10679
10680 buf_ptr += sizeof(*cmd);
10681 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10682 (param->tbl_len));
10683 buf_ptr += WMI_TLV_HDR_SIZE;
10684 gain_table = (uint32_t *)buf_ptr;
10685
10686 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10687 param->array_gain,
10688 param->tbl_len);
10689
10690 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10691 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10692 return QDF_STATUS_E_FAILURE;
10693 }
10694
10695 return QDF_STATUS_SUCCESS;
10696}
10697
10698/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010699 * enum packet_power_tlv_flags: target defined
10700 * packet power rate flags for TLV
10701 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
10702 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
10703 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
10704 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
10705 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
10706 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
10707 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
10708 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
10709 * @WMI_TLV_FLAG_STBC: STBC is set
10710 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
10711 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
10712 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
10713 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
10714 * @WMI_TLV_FLAG_RTSENA: RTS enabled
10715 * @WMI_TLV_FLAG_CTSENA: CTS enabled
10716 * @WMI_TLV_FLAG_LDPC: LDPC is set
10717 * @WMI_TLV_FLAG_SGI: Short gaurd interval
10718 * @WMI_TLV_FLAG_SU: SU Data
10719 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
10720 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
10721 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
10722 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
10723 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
10724 *
10725 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
10726 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
10727 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
10728 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
10729 */
10730enum packet_power_tlv_flags {
10731 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
10732 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
10733 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
10734 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
10735 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
10736 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
10737 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
10738 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
10739 WMI_TLV_FLAG_STBC = 0x00000100,
10740 WMI_TLV_FLAG_40MHZ = 0x00000200,
10741 WMI_TLV_FLAG_80MHZ = 0x00000300,
10742 WMI_TLV_FLAG_160MHZ = 0x00000400,
10743 WMI_TLV_FLAG_TXBF = 0x00000800,
10744 WMI_TLV_FLAG_RTSENA = 0x00001000,
10745 WMI_TLV_FLAG_CTSENA = 0x00002000,
10746 WMI_TLV_FLAG_LDPC = 0x00004000,
10747 WMI_TLV_FLAG_SGI = 0x00008000,
10748 WMI_TLV_FLAG_SU = 0x00100000,
10749 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
10750 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
10751 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
10752 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
10753 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
10754
10755 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
10756 WMI_TLV_FLAG_BW_MASK = 0x3,
10757 WMI_TLV_FLAG_BW_SHIFT = 9,
10758 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
10759 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
10760};
10761
10762/**
10763 * convert_to_power_info_rate_flags() - convert packet_power_info_params
10764 * to FW understandable format
10765 * @param: pointer to hold packet power info param
10766 *
10767 * @return FW understandable 32 bit rate flags
10768 */
10769static uint32_t
10770convert_to_power_info_rate_flags(struct packet_power_info_params *param)
10771{
10772 uint32_t rateflags = 0;
10773
10774 if (param->chainmask)
10775 rateflags |=
10776 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
10777 if (param->chan_width)
10778 rateflags |=
10779 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
10780 << WMI_TLV_FLAG_BW_SHIFT);
10781 if (param->su_mu_ofdma)
10782 rateflags |=
10783 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
10784 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
10785 if (param->rate_flags & WMI_HOST_FLAG_STBC)
10786 rateflags |= WMI_TLV_FLAG_STBC;
10787 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
10788 rateflags |= WMI_TLV_FLAG_LDPC;
10789 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
10790 rateflags |= WMI_TLV_FLAG_TXBF;
10791 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
10792 rateflags |= WMI_TLV_FLAG_RTSENA;
10793 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
10794 rateflags |= WMI_TLV_FLAG_CTSENA;
10795 if (param->rate_flags & WMI_HOST_FLAG_SGI)
10796 rateflags |= WMI_TLV_FLAG_SGI;
10797
10798 return rateflags;
10799}
10800
10801/**
Sathish Kumar497bef42017-03-01 14:02:36 +053010802 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10803 * info to fw
10804 * @wmi_handle: wmi handle
10805 * @param: pointer to hold packet power info param
10806 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010807 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053010808 */
10809static QDF_STATUS
10810send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10811 struct packet_power_info_params *param)
10812{
10813 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10814 wmi_buf_t wmibuf;
10815 uint8_t *buf_ptr;
10816 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10817
10818 wmibuf = wmi_buf_alloc(wmi_handle, len);
10819 if (wmibuf == NULL)
10820 return QDF_STATUS_E_NOMEM;
10821
10822 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10823
10824 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10825 WMITLV_SET_HDR(&cmd->tlv_header,
10826 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10827 WMITLV_GET_STRUCT_TLVLEN(
10828 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010829 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10830 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010831 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053010832 cmd->nss = param->nss;
10833 cmd->preamble = param->preamble;
10834 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010835
10836 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
10837 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
10838 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
10839 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
10840
Sathish Kumar497bef42017-03-01 14:02:36 +053010841 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10842 WMI_PDEV_GET_TPC_CMDID)) {
10843 WMI_LOGE(FL("Failed to get tpc command\n"));
10844 wmi_buf_free(wmibuf);
10845 return QDF_STATUS_E_FAILURE;
10846 }
10847
10848 return QDF_STATUS_SUCCESS;
10849}
10850
10851/**
10852 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10853 * @wmi_handle: wmi handle
10854 * @param: pointer to hold config ratemask params
10855 *
10856 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10857 */
10858static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10859 struct config_ratemask_params *param)
10860{
10861 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10862 wmi_buf_t buf;
10863 int32_t len = sizeof(*cmd);
10864
10865 buf = wmi_buf_alloc(wmi_handle, len);
10866 if (!buf) {
10867 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10868 return QDF_STATUS_E_FAILURE;
10869 }
10870 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10871 WMITLV_SET_HDR(&cmd->tlv_header,
10872 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10873 WMITLV_GET_STRUCT_TLVLEN(
10874 wmi_vdev_config_ratemask_cmd_fixed_param));
10875 cmd->vdev_id = param->vdev_id;
10876 cmd->type = param->type;
10877 cmd->mask_lower32 = param->lower32;
10878 cmd->mask_higher32 = param->higher32;
Rhythm Patwab5ca01d2018-06-19 10:43:00 -070010879 cmd->mask_lower32_2 = param->lower32_2;
10880 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X"
10881 "mask_l32 = 0x%X mask_h32 = 0x%X mask_l32_2 = 0x%X\n",
10882 param->vdev_id, param->type, param->lower32,
10883 param->higher32, param->lower32_2);
Sathish Kumar497bef42017-03-01 14:02:36 +053010884
10885 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10886 WMI_VDEV_RATEMASK_CMDID)) {
10887 WMI_LOGE("Seting vdev ratemask failed\n");
10888 wmi_buf_free(buf);
10889 return QDF_STATUS_E_FAILURE;
10890 }
10891
10892 return QDF_STATUS_SUCCESS;
10893}
10894
10895/**
Sathish Kumar6011c742017-11-08 14:49:58 +053010896 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
10897 * @param: param sent from the host side
10898 * @cmd: param to be sent to the fw side
10899 */
10900static inline void copy_custom_aggr_bitmap(
10901 struct set_custom_aggr_size_params *param,
10902 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
10903{
10904 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
10905 param->ac);
10906 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
10907 param->aggr_type);
10908 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10909 param->tx_aggr_size_disable);
10910 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10911 param->rx_aggr_size_disable);
10912 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
10913 param->tx_ac_enable);
10914}
10915
10916/**
10917 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
10918 * @wmi_handle: wmi handle
10919 * @param: pointer to hold custom aggr size params
10920 *
10921 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10922 */
10923static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
10924 wmi_unified_t wmi_handle,
10925 struct set_custom_aggr_size_params *param)
10926{
10927 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
10928 wmi_buf_t buf;
10929 int32_t len = sizeof(*cmd);
10930
10931 buf = wmi_buf_alloc(wmi_handle, len);
10932 if (!buf) {
10933 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10934 return QDF_STATUS_E_FAILURE;
10935 }
10936 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
10937 wmi_buf_data(buf);
10938 WMITLV_SET_HDR(&cmd->tlv_header,
10939 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
10940 WMITLV_GET_STRUCT_TLVLEN(
10941 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
10942 cmd->vdev_id = param->vdev_id;
10943 cmd->tx_aggr_size = param->tx_aggr_size;
10944 cmd->rx_aggr_size = param->rx_aggr_size;
10945 copy_custom_aggr_bitmap(param, cmd);
10946
10947 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
10948 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
10949 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
10950 "tx_ac_enable=0x%X\n",
10951 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
10952 param->ac, param->aggr_type, param->tx_aggr_size_disable,
10953 param->rx_aggr_size_disable, param->tx_ac_enable);
10954
10955 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10956 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
10957 WMI_LOGE("Seting custom aggregation size failed\n");
10958 wmi_buf_free(buf);
10959 return QDF_STATUS_E_FAILURE;
10960 }
10961
10962 return QDF_STATUS_SUCCESS;
10963}
10964
10965/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053010966 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
10967 * @param wmi_handle : handle to WMI.
10968 * @param param : pointer to tx antenna param
10969 *
10970 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10971 */
10972
10973static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
10974 struct set_qdepth_thresh_params *param)
10975{
10976 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
10977 wmi_msduq_qdepth_thresh_update *cmd_update;
10978 wmi_buf_t buf;
10979 int32_t len = 0;
10980 int i;
10981 uint8_t *buf_ptr;
10982 QDF_STATUS ret;
10983
10984 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
10985 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
10986 return QDF_STATUS_E_INVAL;
10987 }
10988
10989 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10990 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
10991 param->num_of_msduq_updates);
10992 buf = wmi_buf_alloc(wmi_handle, len);
10993
10994 if (!buf) {
10995 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10996 return QDF_STATUS_E_NOMEM;
10997 }
10998
10999 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11000 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11001 buf_ptr;
11002
11003 WMITLV_SET_HDR(&cmd->tlv_header,
11004 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11005 , WMITLV_GET_STRUCT_TLVLEN(
11006 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11007
11008 cmd->pdev_id =
11009 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11010 cmd->vdev_id = param->vdev_id;
11011 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11012 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11013
11014 buf_ptr += sizeof(
11015 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11016 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11017 param->num_of_msduq_updates *
11018 sizeof(wmi_msduq_qdepth_thresh_update));
11019 buf_ptr += WMI_TLV_HDR_SIZE;
11020 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11021
11022 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11023 WMITLV_SET_HDR(&cmd_update->tlv_header,
11024 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11025 WMITLV_GET_STRUCT_TLVLEN(
11026 wmi_msduq_qdepth_thresh_update));
11027 cmd_update->tid_num = param->update_params[i].tid_num;
11028 cmd_update->msduq_update_mask =
11029 param->update_params[i].msduq_update_mask;
11030 cmd_update->qdepth_thresh_value =
11031 param->update_params[i].qdepth_thresh_value;
11032 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11033 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11034 " update mask=0x%X thresh val=0x%X\n",
11035 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11036 cmd->peer_mac_address.mac_addr31to0,
11037 cmd->peer_mac_address.mac_addr47to32,
11038 cmd_update->msduq_update_mask,
11039 cmd_update->qdepth_thresh_value);
11040 cmd_update++;
11041 }
11042
11043 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11044 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11045
11046 if (ret != 0) {
11047 WMI_LOGE(" %s :WMI Failed\n", __func__);
11048 wmi_buf_free(buf);
11049 }
11050
11051 return ret;
11052}
11053
11054/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011055 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11056 * @wmi_handle: wmi handle
11057 * @param: pointer to hold vap dscp tid map param
11058 *
11059 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11060 */
11061static QDF_STATUS
11062send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11063 struct vap_dscp_tid_map_params *param)
11064{
11065 wmi_buf_t buf;
11066 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11067 int32_t len = sizeof(*cmd);
11068
11069 buf = wmi_buf_alloc(wmi_handle, len);
11070 if (!buf) {
11071 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11072 return QDF_STATUS_E_FAILURE;
11073 }
11074
11075 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11076 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053011077 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053011078
11079 cmd->vdev_id = param->vdev_id;
11080 cmd->enable_override = 0;
11081
11082 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11083 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11084 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11085 WMI_LOGE("Failed to set dscp cmd\n");
11086 wmi_buf_free(buf);
11087 return QDF_STATUS_E_FAILURE;
11088 }
11089
11090 return QDF_STATUS_SUCCESS;
11091}
11092
11093/**
11094 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11095 * @wmi_handle: wmi handle
11096 * @macaddr: vdev mac address
11097 * @param: pointer to hold neigbour rx param
11098 *
11099 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11100 */
11101static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11102 uint8_t macaddr[IEEE80211_ADDR_LEN],
11103 struct set_neighbour_rx_params *param)
11104{
11105 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11106 wmi_buf_t buf;
11107 int32_t len = sizeof(*cmd);
11108
11109 buf = wmi_buf_alloc(wmi_handle, len);
11110 if (!buf) {
11111 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11112 return QDF_STATUS_E_FAILURE;
11113 }
11114 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11115 WMITLV_SET_HDR(&cmd->tlv_header,
11116 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11117 WMITLV_GET_STRUCT_TLVLEN(
11118 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11119 cmd->vdev_id = param->vdev_id;
11120 cmd->bssid_idx = param->idx;
11121 cmd->action = param->action;
11122 cmd->type = param->type;
11123 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11124 cmd->flag = 0;
11125
11126 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11127 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11128 WMI_LOGE("Failed to set neighbour rx param\n");
11129 wmi_buf_free(buf);
11130 return QDF_STATUS_E_FAILURE;
11131 }
11132
11133 return QDF_STATUS_SUCCESS;
11134}
11135
11136/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011137 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011138 * @param wmi_handle : handle to WMI.
11139 * @param macaddr : vdev mac address
11140 * @param param : pointer to tx antenna param
11141 *
11142 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11143 */
11144static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11145 uint8_t macaddr[IEEE80211_ADDR_LEN],
11146 struct smart_ant_tx_ant_params *param)
11147{
11148 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11149 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11150 wmi_buf_t buf;
11151 int32_t len = 0;
11152 int i;
11153 uint8_t *buf_ptr;
11154 QDF_STATUS ret;
11155
11156 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11157 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11158 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11159 buf = wmi_buf_alloc(wmi_handle, len);
11160
11161 if (!buf) {
11162 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11163 return QDF_STATUS_E_NOMEM;
11164 }
11165
11166 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11167 qdf_mem_zero(buf_ptr, len);
11168 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11169
11170 WMITLV_SET_HDR(&cmd->tlv_header,
11171 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11172 WMITLV_GET_STRUCT_TLVLEN(
11173 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11174
11175 cmd->vdev_id = param->vdev_id;
11176 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11177
11178 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11179 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11180 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11181 buf_ptr += WMI_TLV_HDR_SIZE;
11182 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11183
11184 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11185 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11186 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11187 WMITLV_GET_STRUCT_TLVLEN(
11188 wmi_peer_smart_ant_set_tx_antenna_series));
11189 ant_tx_series->antenna_series = param->antenna_array[i];
11190 ant_tx_series++;
11191 }
11192
11193 ret = wmi_unified_cmd_send(wmi_handle,
11194 buf,
11195 len,
11196 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11197
11198 if (ret != 0) {
11199 WMI_LOGE(" %s :WMI Failed\n", __func__);
11200 wmi_buf_free(buf);
11201 }
11202
11203 return ret;
11204}
11205
Sathish Kumar02c3b542017-02-22 17:24:45 +053011206/**
11207 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11208 * @wmi_handle: wmi handle
11209 * @param: pointer to hold ant switch tbl param
11210 *
11211 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11212 */
11213static QDF_STATUS
11214send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11215 struct ant_switch_tbl_params *param)
11216{
11217 uint8_t len;
11218 wmi_buf_t buf;
11219 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11220 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11221 uint8_t *buf_ptr;
11222
11223 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11224 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11225 buf = wmi_buf_alloc(wmi_handle, len);
11226
11227 if (!buf) {
11228 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11229 return QDF_STATUS_E_NOMEM;
11230 }
11231
11232 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11233 qdf_mem_zero(buf_ptr, len);
11234 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11235
11236 WMITLV_SET_HDR(&cmd->tlv_header,
11237 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11238 WMITLV_GET_STRUCT_TLVLEN(
11239 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11240
11241 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11242 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011243 cmd->mac_id =
11244 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011245
11246 /* TLV indicating array of structures to follow */
11247 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11248 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11249 sizeof(wmi_pdev_set_ant_ctrl_chain));
11250 buf_ptr += WMI_TLV_HDR_SIZE;
11251 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11252
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011253 ctrl_chain->pdev_id =
11254 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011255 ctrl_chain->antCtrlChain = param->antCtrlChain;
11256
11257 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11258 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11259 wmi_buf_free(buf);
11260 return QDF_STATUS_E_FAILURE;
11261 }
11262
11263 return QDF_STATUS_SUCCESS;
11264}
11265
11266/**
11267 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11268 * training information function
11269 * @param wmi_handle : handle to WMI.
11270 * @macaddr : vdev mac address
11271 * @param param : pointer to tx antenna param
11272 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11273 */
11274static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11275 wmi_unified_t wmi_handle,
11276 uint8_t macaddr[IEEE80211_ADDR_LEN],
11277 struct smart_ant_training_info_params *param)
11278{
11279 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11280 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11281 wmi_buf_t buf;
11282 uint8_t *buf_ptr;
11283 int32_t len = 0;
11284 QDF_STATUS ret;
11285 int loop;
11286
11287 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11288 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11289 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11290 buf = wmi_buf_alloc(wmi_handle, len);
11291
11292 if (!buf) {
11293 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11294 return QDF_STATUS_E_NOMEM;
11295 }
11296
11297 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11298 qdf_mem_zero(buf_ptr, len);
11299 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11300
11301 WMITLV_SET_HDR(&cmd->tlv_header,
11302 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11303 WMITLV_GET_STRUCT_TLVLEN(
11304 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11305
11306 cmd->vdev_id = param->vdev_id;
11307 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11308 cmd->num_pkts = param->numpkts;
11309
11310 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11311 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11312 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11313 WMI_SMART_ANT_MAX_RATE_SERIES);
11314
11315 buf_ptr += WMI_TLV_HDR_SIZE;
11316 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11317
11318 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11319 WMITLV_SET_HDR(&train_param->tlv_header,
11320 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11321 WMITLV_GET_STRUCT_TLVLEN(
11322 wmi_peer_smart_ant_set_train_antenna_param));
11323 train_param->train_rate_series = param->rate_array[loop];
11324 train_param->train_antenna_series = param->antenna_array[loop];
11325 train_param->rc_flags = 0;
11326 WMI_LOGI(FL("Series number:%d\n"), loop);
11327 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11328 train_param->train_rate_series,
11329 train_param->train_antenna_series);
11330 train_param++;
11331 }
11332
11333 ret = wmi_unified_cmd_send(wmi_handle,
11334 buf,
11335 len,
11336 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11337
11338 if (ret != 0) {
11339 WMI_LOGE(" %s :WMI Failed\n", __func__);
11340 wmi_buf_free(buf);
11341 return QDF_STATUS_E_FAILURE;
11342 }
11343
11344 return ret;
11345}
11346
11347/**
11348 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11349 * configuration function
11350 * @param wmi_handle : handle to WMI.
11351 * @macaddr : vdev mad address
11352 * @param param : pointer to tx antenna param
11353 *
11354 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11355 */
11356static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
11357 wmi_unified_t wmi_handle,
11358 uint8_t macaddr[IEEE80211_ADDR_LEN],
11359 struct smart_ant_node_config_params *param)
11360{
11361 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
11362 wmi_buf_t buf;
11363 uint8_t *buf_ptr;
11364 int32_t len = 0, args_tlv_len;
11365 int ret;
11366 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053011367 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011368
Vivekc5823092018-03-22 23:27:21 +053011369 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011370 len = sizeof(*cmd) + args_tlv_len;
11371
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070011372 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053011373 WMI_LOGE("%s: Can't send a command with %d arguments\n",
11374 __func__, param->args_count);
11375 return QDF_STATUS_E_FAILURE;
11376 }
11377
11378 buf = wmi_buf_alloc(wmi_handle, len);
11379 if (!buf) {
11380 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11381 return QDF_STATUS_E_NOMEM;
11382 }
11383
11384 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
11385 wmi_buf_data(buf);
11386 buf_ptr = (uint8_t *)cmd;
11387 WMITLV_SET_HDR(&cmd->tlv_header,
11388 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
11389 WMITLV_GET_STRUCT_TLVLEN(
11390 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
11391 cmd->vdev_id = param->vdev_id;
11392 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11393 cmd->cmd_id = param->cmd_id;
11394 cmd->args_count = param->args_count;
11395 buf_ptr += sizeof(
11396 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
11397 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053011398 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011399 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053011400 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011401
11402 for (i = 0; i < param->args_count; i++) {
11403 node_config_args[i] = param->args_arr[i];
11404 WMI_LOGI("%d", param->args_arr[i]);
11405 }
11406
11407 ret = wmi_unified_cmd_send(wmi_handle,
11408 buf,
11409 len,
11410 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
11411
11412 if (ret != 0) {
11413 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
11414 __func__, param->cmd_id, macaddr[0],
11415 macaddr[1], macaddr[2], macaddr[3],
11416 macaddr[4], macaddr[5], ret);
11417 wmi_buf_free(buf);
11418 }
11419
11420 return ret;
11421}
11422
Jeffin Mammen095050b2018-07-24 14:20:08 +053011423#ifdef WLAN_ATF_ENABLE
Sathish Kumar02c3b542017-02-22 17:24:45 +053011424/**
11425 * send_set_atf_cmd_tlv() - send set atf command to fw
11426 * @wmi_handle: wmi handle
11427 * @param: pointer to set atf param
11428 *
11429 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11430 */
11431static QDF_STATUS
11432send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
11433 struct set_atf_params *param)
11434{
11435 wmi_atf_peer_info *peer_info;
11436 wmi_peer_atf_request_fixed_param *cmd;
11437 wmi_buf_t buf;
11438 uint8_t *buf_ptr;
11439 int i;
11440 int32_t len = 0;
11441 QDF_STATUS retval;
11442
11443 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11444 len += param->num_peers * sizeof(wmi_atf_peer_info);
11445 buf = wmi_buf_alloc(wmi_handle, len);
11446 if (!buf) {
11447 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11448 return QDF_STATUS_E_FAILURE;
11449 }
11450 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11451 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
11452 WMITLV_SET_HDR(&cmd->tlv_header,
11453 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
11454 WMITLV_GET_STRUCT_TLVLEN(
11455 wmi_peer_atf_request_fixed_param));
11456 cmd->num_peers = param->num_peers;
11457
11458 buf_ptr += sizeof(*cmd);
11459 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11460 sizeof(wmi_atf_peer_info) *
11461 cmd->num_peers);
11462 buf_ptr += WMI_TLV_HDR_SIZE;
11463 peer_info = (wmi_atf_peer_info *)buf_ptr;
11464
11465 for (i = 0; i < cmd->num_peers; i++) {
11466 WMITLV_SET_HDR(&peer_info->tlv_header,
11467 WMITLV_TAG_STRUC_wmi_atf_peer_info,
11468 WMITLV_GET_STRUCT_TLVLEN(
11469 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011470 qdf_mem_copy(&(peer_info->peer_macaddr),
11471 &(param->peer_info[i].peer_macaddr),
11472 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011473 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011474 peer_info->vdev_id = param->peer_info[i].vdev_id;
11475 peer_info->pdev_id =
11476 wmi_handle->ops->convert_pdev_id_host_to_target(
11477 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011478 /*
11479 * TLV definition for peer atf request fixed param combines
11480 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11481 * stats and atf extension stats as two different
11482 * implementations.
11483 * Need to discuss with FW on this.
11484 *
11485 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11486 * peer_info->atf_units_reserved =
11487 * param->peer_ext_info[i].atf_index_reserved;
11488 */
11489 peer_info++;
11490 }
11491
11492 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11493 WMI_PEER_ATF_REQUEST_CMDID);
11494
11495 if (retval != QDF_STATUS_SUCCESS) {
11496 WMI_LOGE("%s : WMI Failed\n", __func__);
11497 wmi_buf_free(buf);
11498 }
11499
11500 return retval;
11501}
Jeffin Mammen095050b2018-07-24 14:20:08 +053011502#endif
Sathish Kumar02c3b542017-02-22 17:24:45 +053011503
11504/**
11505 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11506 * @wmi_handle: wmi handle
11507 * @param: pointer to hold fwtest param
11508 *
11509 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11510 */
11511static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11512 struct set_fwtest_params *param)
11513{
11514 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11515 wmi_buf_t buf;
11516 int32_t len = sizeof(*cmd);
11517
11518 buf = wmi_buf_alloc(wmi_handle, len);
11519
11520 if (!buf) {
11521 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11522 return QDF_STATUS_E_FAILURE;
11523 }
11524
11525 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11526 WMITLV_SET_HDR(&cmd->tlv_header,
11527 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11528 WMITLV_GET_STRUCT_TLVLEN(
11529 wmi_fwtest_set_param_cmd_fixed_param));
11530 cmd->param_id = param->arg;
11531 cmd->param_value = param->value;
11532
11533 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11534 WMI_LOGE("Setting FW test param failed\n");
11535 wmi_buf_free(buf);
11536 return QDF_STATUS_E_FAILURE;
11537 }
11538
11539 return QDF_STATUS_SUCCESS;
11540}
11541
11542/**
11543 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11544 * @wmi_handle: wmi handle
11545 * @param: pointer to qboost params
11546 * @macaddr: vdev mac address
11547 *
11548 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11549 */
11550static QDF_STATUS
11551send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11552 uint8_t macaddr[IEEE80211_ADDR_LEN],
11553 struct set_qboost_params *param)
11554{
11555 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11556 wmi_buf_t buf;
11557 int32_t len;
11558 QDF_STATUS ret;
11559
11560 len = sizeof(*cmd);
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_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11569 WMITLV_SET_HDR(&cmd->tlv_header,
11570 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11571 WMITLV_GET_STRUCT_TLVLEN(
11572 WMI_QBOOST_CFG_CMD_fixed_param));
11573 cmd->vdev_id = param->vdev_id;
11574 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11575 cmd->qb_enable = param->value;
11576
11577 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11578 WMI_QBOOST_CFG_CMDID);
11579
11580 if (ret != 0) {
11581 WMI_LOGE("Setting qboost cmd failed\n");
11582 wmi_buf_free(buf);
11583 }
11584
11585 return ret;
11586}
11587
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011588/**
11589 * send_gpio_config_cmd_tlv() - send gpio config to fw
11590 * @wmi_handle: wmi handle
11591 * @param: pointer to hold gpio config param
11592 *
11593 * Return: 0 for success or error code
11594 */
11595static QDF_STATUS
11596send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
11597 struct gpio_config_params *param)
11598{
11599 wmi_gpio_config_cmd_fixed_param *cmd;
11600 wmi_buf_t buf;
11601 int32_t len;
11602 QDF_STATUS ret;
11603
11604 len = sizeof(*cmd);
11605
11606 /* Sanity Checks */
11607 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
11608 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
11609 return QDF_STATUS_E_FAILURE;
11610 }
11611
11612 buf = wmi_buf_alloc(wmi_handle, len);
11613 if (!buf) {
11614 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11615 return QDF_STATUS_E_FAILURE;
11616 }
11617
11618 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
11619 WMITLV_SET_HDR(&cmd->tlv_header,
11620 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
11621 WMITLV_GET_STRUCT_TLVLEN(
11622 wmi_gpio_config_cmd_fixed_param));
11623 cmd->gpio_num = param->gpio_num;
11624 cmd->input = param->input;
11625 cmd->pull_type = param->pull_type;
11626 cmd->intr_mode = param->intr_mode;
11627
11628 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11629 WMI_GPIO_CONFIG_CMDID);
11630
11631 if (ret != 0) {
11632 WMI_LOGE("Sending GPIO config cmd failed\n");
11633 wmi_buf_free(buf);
11634 }
11635
11636 return ret;
11637}
11638
11639/**
11640 * send_gpio_output_cmd_tlv() - send gpio output to fw
11641 * @wmi_handle: wmi handle
11642 * @param: pointer to hold gpio output param
11643 *
11644 * Return: 0 for success or error code
11645 */
11646static QDF_STATUS
11647send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
11648 struct gpio_output_params *param)
11649{
11650 wmi_gpio_output_cmd_fixed_param *cmd;
11651 wmi_buf_t buf;
11652 int32_t len;
11653 QDF_STATUS ret;
11654
11655 len = sizeof(*cmd);
11656
11657 buf = wmi_buf_alloc(wmi_handle, len);
11658 if (!buf) {
11659 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11660 return QDF_STATUS_E_FAILURE;
11661 }
11662
11663 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
11664 WMITLV_SET_HDR(&cmd->tlv_header,
11665 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
11666 WMITLV_GET_STRUCT_TLVLEN(
11667 wmi_gpio_output_cmd_fixed_param));
11668 cmd->gpio_num = param->gpio_num;
11669 cmd->set = param->set;
11670
11671 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11672 WMI_GPIO_OUTPUT_CMDID);
11673
11674 if (ret != 0) {
11675 WMI_LOGE("Sending GPIO output cmd failed\n");
11676 wmi_buf_free(buf);
11677 }
11678
11679 return ret;
11680
11681}
11682
11683/**
11684 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
11685 *
11686 * @param wmi_handle : handle to WMI.
11687 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11688 */
11689static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
11690{
11691 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
11692 wmi_buf_t buf;
11693 QDF_STATUS ret;
11694 int32_t len;
11695
11696 len = sizeof(*cmd);
11697
11698 buf = wmi_buf_alloc(wmi_handle, len);
11699 if (!buf) {
11700 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11701 return QDF_STATUS_E_FAILURE;
11702 }
11703
11704 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
11705 WMITLV_SET_HDR(&cmd->tlv_header,
11706 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
11707 WMITLV_GET_STRUCT_TLVLEN(
11708 wmi_pdev_dfs_disable_cmd_fixed_param));
11709 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011710 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11711 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011712
11713 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11714 WMI_PDEV_DFS_DISABLE_CMDID);
11715
11716 if (ret != 0) {
11717 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
11718 wmi_buf_free(buf);
11719 }
11720
11721 return ret;
11722}
11723
11724/**
11725 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
11726 *
11727 * @param wmi_handle : handle to WMI.
11728 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11729 */
11730static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11731{
11732 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11733 wmi_buf_t buf;
11734 QDF_STATUS ret;
11735 int32_t len;
11736
11737 len = sizeof(*cmd);
11738
11739 buf = wmi_buf_alloc(wmi_handle, len);
11740 if (!buf) {
11741 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11742 return QDF_STATUS_E_FAILURE;
11743 }
11744
11745 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11746 WMITLV_SET_HDR(&cmd->tlv_header,
11747 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
11748 WMITLV_GET_STRUCT_TLVLEN(
11749 wmi_pdev_dfs_enable_cmd_fixed_param));
11750 /* Reserved for future use */
11751 cmd->reserved0 = 0;
11752
11753 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11754 WMI_PDEV_DFS_ENABLE_CMDID);
11755
11756 if (ret != 0) {
11757 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
11758 wmi_buf_free(buf);
11759 }
11760
11761 return ret;
11762}
11763
11764/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011765 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
11766 * to fw
11767 * @wmi_handle: wmi handle
11768 * @param: pointer to hold periodic chan stats param
11769 *
11770 * Return: 0 for success or error code
11771 */
11772static QDF_STATUS
11773send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
11774 struct periodic_chan_stats_params *param)
11775{
11776 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
11777 wmi_buf_t buf;
11778 QDF_STATUS ret;
11779 int32_t len;
11780
11781 len = sizeof(*cmd);
11782
11783 buf = wmi_buf_alloc(wmi_handle, len);
11784 if (!buf) {
11785 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11786 return QDF_STATUS_E_FAILURE;
11787 }
11788
11789 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
11790 wmi_buf_data(buf);
11791 WMITLV_SET_HDR(&cmd->tlv_header,
11792 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
11793 WMITLV_GET_STRUCT_TLVLEN(
11794 wmi_set_periodic_channel_stats_config_fixed_param));
11795 cmd->enable = param->enable;
11796 cmd->stats_period = param->stats_period;
11797 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11798 param->pdev_id);
11799
11800 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11801 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
11802
11803 if (ret != 0) {
11804 WMI_LOGE("Sending periodic chan stats config failed");
11805 wmi_buf_free(buf);
11806 }
11807
11808 return ret;
11809}
11810
11811/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011812 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
11813 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080011814 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011815 *
11816 * Return: 0 for success or error code
11817 */
11818static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080011819send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011820{
11821 wmi_buf_t buf;
11822 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080011823 wmi_pdev_get_nfcal_power_fixed_param *cmd;
11824 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011825
nobeljf74583b2018-01-25 16:35:36 -080011826 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011827 if (buf == NULL)
11828 return QDF_STATUS_E_NOMEM;
11829
nobeljf74583b2018-01-25 16:35:36 -080011830 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
11831 WMITLV_SET_HDR(&cmd->tlv_header,
11832 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
11833 WMITLV_GET_STRUCT_TLVLEN
11834 (wmi_pdev_get_nfcal_power_fixed_param));
11835 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
11836
11837 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011838 WMI_PDEV_GET_NFCAL_POWER_CMDID);
11839 if (ret != 0) {
11840 WMI_LOGE("Sending get nfcal power cmd failed\n");
11841 wmi_buf_free(buf);
11842 }
11843
11844 return ret;
11845}
11846
11847/**
11848 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
11849 * @wmi_handle: wmi handle
11850 * @param: pointer to ht ie param
11851 *
11852 * Return: 0 for success or error code
11853 */
11854static QDF_STATUS
11855send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11856 struct ht_ie_params *param)
11857{
11858 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
11859 wmi_buf_t buf;
11860 QDF_STATUS ret;
11861 int32_t len;
11862 uint8_t *buf_ptr;
11863
11864 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11865 roundup(param->ie_len, sizeof(uint32_t));
11866
11867 buf = wmi_buf_alloc(wmi_handle, len);
11868 if (!buf) {
11869 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11870 return QDF_STATUS_E_FAILURE;
11871 }
11872
11873 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11874 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
11875 WMITLV_SET_HDR(&cmd->tlv_header,
11876 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
11877 WMITLV_GET_STRUCT_TLVLEN(
11878 wmi_pdev_set_ht_ie_cmd_fixed_param));
11879 cmd->reserved0 = 0;
11880 cmd->ie_len = param->ie_len;
11881 cmd->tx_streams = param->tx_streams;
11882 cmd->rx_streams = param->rx_streams;
11883
11884 buf_ptr += sizeof(*cmd);
11885 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11886 buf_ptr += WMI_TLV_HDR_SIZE;
11887 if (param->ie_len)
11888 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11889 cmd->ie_len);
11890
11891 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11892 WMI_PDEV_SET_HT_CAP_IE_CMDID);
11893
11894 if (ret != 0) {
11895 WMI_LOGE("Sending set ht ie cmd failed\n");
11896 wmi_buf_free(buf);
11897 }
11898
11899 return ret;
11900}
11901
11902/**
11903 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
11904 * @wmi_handle: wmi handle
11905 * @param: pointer to vht ie param
11906 *
11907 * Return: 0 for success or error code
11908 */
11909static QDF_STATUS
11910send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11911 struct vht_ie_params *param)
11912{
11913 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
11914 wmi_buf_t buf;
11915 QDF_STATUS ret;
11916 int32_t len;
11917 uint8_t *buf_ptr;
11918
11919 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11920 roundup(param->ie_len, sizeof(uint32_t));
11921
11922 buf = wmi_buf_alloc(wmi_handle, len);
11923 if (!buf) {
11924 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11925 return QDF_STATUS_E_FAILURE;
11926 }
11927
11928 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11929 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
11930 WMITLV_SET_HDR(&cmd->tlv_header,
11931 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
11932 WMITLV_GET_STRUCT_TLVLEN(
11933 wmi_pdev_set_vht_ie_cmd_fixed_param));
11934 cmd->reserved0 = 0;
11935 cmd->ie_len = param->ie_len;
11936 cmd->tx_streams = param->tx_streams;
11937 cmd->rx_streams = param->rx_streams;
11938
11939 buf_ptr += sizeof(*cmd);
11940 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11941 buf_ptr += WMI_TLV_HDR_SIZE;
11942 if (param->ie_len)
11943 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11944 cmd->ie_len);
11945
11946 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11947 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11948
11949 if (ret != 0) {
11950 WMI_LOGE("Sending set vht ie cmd failed\n");
11951 wmi_buf_free(buf);
11952 }
11953
11954 return ret;
11955}
11956
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011957/**
11958 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11959 * @wmi_handle: wmi handle
11960 * @param: pointer to quiet mode params
11961 *
11962 * Return: 0 for success or error code
11963 */
11964static QDF_STATUS
11965send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11966 struct set_quiet_mode_params *param)
11967{
11968 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11969 wmi_buf_t buf;
11970 QDF_STATUS ret;
11971 int32_t len;
11972
11973 len = sizeof(*quiet_cmd);
11974 buf = wmi_buf_alloc(wmi_handle, len);
11975 if (!buf) {
11976 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11977 return QDF_STATUS_E_FAILURE;
11978 }
11979
11980 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11981 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11982 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11983 WMITLV_GET_STRUCT_TLVLEN(
11984 wmi_pdev_set_quiet_cmd_fixed_param));
11985 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11986 quiet_cmd->enabled = param->enabled;
11987 quiet_cmd->period = (param->period)*(param->intval);
11988 quiet_cmd->duration = param->duration;
11989 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011990 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11991 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011992
11993 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11994 WMI_PDEV_SET_QUIET_MODE_CMDID);
11995
11996 if (ret != 0) {
11997 WMI_LOGE("Sending set quiet cmd failed\n");
11998 wmi_buf_free(buf);
11999 }
12000
12001 return ret;
12002}
12003
12004/**
12005 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12006 * @wmi_handle: wmi handle
12007 * @param: pointer to set bwf param
12008 *
12009 * Return: 0 for success or error code
12010 */
12011static QDF_STATUS
12012send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12013 struct set_bwf_params *param)
12014{
12015 wmi_bwf_peer_info *peer_info;
12016 wmi_peer_bwf_request_fixed_param *cmd;
12017 wmi_buf_t buf;
12018 QDF_STATUS retval;
12019 int32_t len;
12020 uint8_t *buf_ptr;
12021 int i;
12022
12023 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12024 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12025 buf = wmi_buf_alloc(wmi_handle, len);
12026 if (!buf) {
12027 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12028 return QDF_STATUS_E_FAILURE;
12029 }
12030 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12031 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12032 WMITLV_SET_HDR(&cmd->tlv_header,
12033 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12034 WMITLV_GET_STRUCT_TLVLEN(
12035 wmi_peer_bwf_request_fixed_param));
12036 cmd->num_peers = param->num_peers;
12037
12038 buf_ptr += sizeof(*cmd);
12039 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12040 sizeof(wmi_bwf_peer_info) *
12041 cmd->num_peers);
12042 buf_ptr += WMI_TLV_HDR_SIZE;
12043 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12044
12045 for (i = 0; i < cmd->num_peers; i++) {
12046 WMITLV_SET_HDR(&peer_info->tlv_header,
12047 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12048 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12049 peer_info->bwf_guaranteed_bandwidth =
12050 param->peer_info[i].throughput;
12051 peer_info->bwf_max_airtime =
12052 param->peer_info[i].max_airtime;
12053 peer_info->bwf_peer_priority =
12054 param->peer_info[i].priority;
12055 qdf_mem_copy(&peer_info->peer_macaddr,
12056 &param->peer_info[i].peer_macaddr,
12057 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012058 peer_info->vdev_id =
12059 param->peer_info[i].vdev_id;
12060 peer_info->pdev_id =
12061 wmi_handle->ops->convert_pdev_id_host_to_target(
12062 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012063 peer_info++;
12064 }
12065
12066 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12067 WMI_PEER_BWF_REQUEST_CMDID);
12068
12069 if (retval != QDF_STATUS_SUCCESS) {
12070 WMI_LOGE("%s : WMI Failed\n", __func__);
12071 wmi_buf_free(buf);
12072 }
12073
12074 return retval;
12075}
12076
12077/**
12078 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12079 * @wmi_handle: wmi handle
12080 * @param: pointer to hold mcast update param
12081 *
12082 * Return: 0 for success or error code
12083 */
12084static QDF_STATUS
12085send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12086 struct mcast_group_update_params *param)
12087{
12088 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12089 wmi_buf_t buf;
12090 QDF_STATUS ret;
12091 int32_t len;
12092 int offset = 0;
12093 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12094
12095 len = sizeof(*cmd);
12096 buf = wmi_buf_alloc(wmi_handle, len);
12097 if (!buf) {
12098 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12099 return QDF_STATUS_E_FAILURE;
12100 }
12101 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12102 WMITLV_SET_HDR(&cmd->tlv_header,
12103 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12104 WMITLV_GET_STRUCT_TLVLEN(
12105 wmi_peer_mcast_group_cmd_fixed_param));
12106 /* confirm the buffer is 4-byte aligned */
12107 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12108 qdf_mem_zero(cmd, sizeof(*cmd));
12109
12110 cmd->vdev_id = param->vap_id;
12111 /* construct the message assuming our endianness matches the target */
12112 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12113 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12114 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12115 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12116 if (param->is_action_delete)
12117 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12118
12119 if (param->is_mcast_addr_len)
12120 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12121
12122 if (param->is_filter_mode_snoop)
12123 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12124
12125 /* unicast address spec only applies for non-wildcard cases */
12126 if (!param->wildcard && param->ucast_mac_addr) {
12127 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12128 &cmd->ucast_mac_addr);
12129 }
Amar Singhal5593c902017-10-03 13:00:29 -070012130
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012131 if (param->mcast_ip_addr) {
12132 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12133 sizeof(cmd->mcast_ip_addr));
12134 offset = sizeof(cmd->mcast_ip_addr) -
12135 param->mcast_ip_addr_bytes;
12136 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12137 param->mcast_ip_addr,
12138 param->mcast_ip_addr_bytes);
12139 }
12140 if (!param->mask)
12141 param->mask = &dummymask[0];
12142
12143 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12144 param->mask,
12145 param->mcast_ip_addr_bytes);
12146
12147 if (param->srcs && param->nsrcs) {
12148 cmd->num_filter_addr = param->nsrcs;
12149 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12150 sizeof(cmd->filter_addr));
12151
12152 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12153 param->nsrcs * param->mcast_ip_addr_bytes);
12154 }
12155
12156 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12157 WMI_PEER_MCAST_GROUP_CMDID);
12158
12159 if (ret != QDF_STATUS_SUCCESS) {
12160 WMI_LOGE("%s : WMI Failed\n", __func__);
12161 wmi_buf_free(buf);
12162 }
12163
12164 return ret;
12165}
12166
12167/**
12168 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12169 * command to fw
12170 * @wmi_handle: wmi handle
12171 * @param: pointer to hold spectral config parameter
12172 *
12173 * Return: 0 for success or error code
12174 */
12175static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12176 struct vdev_spectral_configure_params *param)
12177{
12178 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12179 wmi_buf_t buf;
12180 QDF_STATUS ret;
12181 int32_t len;
12182
12183 len = sizeof(*cmd);
12184 buf = wmi_buf_alloc(wmi_handle, len);
12185 if (!buf) {
12186 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12187 return QDF_STATUS_E_FAILURE;
12188 }
12189
12190 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12191 WMITLV_SET_HDR(&cmd->tlv_header,
12192 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12193 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012194 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012195
12196 cmd->vdev_id = param->vdev_id;
12197 cmd->spectral_scan_count = param->count;
12198 cmd->spectral_scan_period = param->period;
12199 cmd->spectral_scan_priority = param->spectral_pri;
12200 cmd->spectral_scan_fft_size = param->fft_size;
12201 cmd->spectral_scan_gc_ena = param->gc_enable;
12202 cmd->spectral_scan_restart_ena = param->restart_enable;
12203 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12204 cmd->spectral_scan_init_delay = param->init_delay;
12205 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12206 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12207 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12208 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12209 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12210 cmd->spectral_scan_pwr_format = param->pwr_format;
12211 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12212 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012213 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012214 cmd->spectral_scan_chn_mask = param->chn_mask;
12215
12216 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12217 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12218
12219 if (ret != 0) {
12220 WMI_LOGE("Sending set quiet cmd failed\n");
12221 wmi_buf_free(buf);
12222 }
12223
12224 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12225 __func__);
12226
12227 WMI_LOGI("vdev_id = %u\n"
12228 "spectral_scan_count = %u\n"
12229 "spectral_scan_period = %u\n"
12230 "spectral_scan_priority = %u\n"
12231 "spectral_scan_fft_size = %u\n"
12232 "spectral_scan_gc_ena = %u\n"
12233 "spectral_scan_restart_ena = %u\n"
12234 "spectral_scan_noise_floor_ref = %u\n"
12235 "spectral_scan_init_delay = %u\n"
12236 "spectral_scan_nb_tone_thr = %u\n"
12237 "spectral_scan_str_bin_thr = %u\n"
12238 "spectral_scan_wb_rpt_mode = %u\n"
12239 "spectral_scan_rssi_rpt_mode = %u\n"
12240 "spectral_scan_rssi_thr = %u\n"
12241 "spectral_scan_pwr_format = %u\n"
12242 "spectral_scan_rpt_mode = %u\n"
12243 "spectral_scan_bin_scale = %u\n"
12244 "spectral_scan_dBm_adj = %u\n"
12245 "spectral_scan_chn_mask = %u\n",
12246 param->vdev_id,
12247 param->count,
12248 param->period,
12249 param->spectral_pri,
12250 param->fft_size,
12251 param->gc_enable,
12252 param->restart_enable,
12253 param->noise_floor_ref,
12254 param->init_delay,
12255 param->nb_tone_thr,
12256 param->str_bin_thr,
12257 param->wb_rpt_mode,
12258 param->rssi_rpt_mode,
12259 param->rssi_thr,
12260 param->pwr_format,
12261 param->rpt_mode,
12262 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012263 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012264 param->chn_mask);
12265 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12266
12267 return ret;
12268}
12269
12270/**
12271 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12272 * command to fw
12273 * @wmi_handle: wmi handle
12274 * @param: pointer to hold spectral enable parameter
12275 *
12276 * Return: 0 for success or error code
12277 */
12278static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12279 struct vdev_spectral_enable_params *param)
12280{
12281 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12282 wmi_buf_t buf;
12283 QDF_STATUS ret;
12284 int32_t len;
12285
12286 len = sizeof(*cmd);
12287 buf = wmi_buf_alloc(wmi_handle, len);
12288 if (!buf) {
12289 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12290 return QDF_STATUS_E_FAILURE;
12291 }
12292
12293 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12294 WMITLV_SET_HDR(&cmd->tlv_header,
12295 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12296 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012297 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012298
12299 cmd->vdev_id = param->vdev_id;
12300
12301 if (param->active_valid) {
12302 cmd->trigger_cmd = param->active ? 1 : 2;
12303 /* 1: Trigger, 2: Clear Trigger */
12304 } else {
12305 cmd->trigger_cmd = 0; /* 0: Ignore */
12306 }
12307
12308 if (param->enabled_valid) {
12309 cmd->enable_cmd = param->enabled ? 1 : 2;
12310 /* 1: Enable 2: Disable */
12311 } else {
12312 cmd->enable_cmd = 0; /* 0: Ignore */
12313 }
12314
12315 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12316 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12317
12318 if (ret != 0) {
12319 WMI_LOGE("Sending scan enable CMD failed\n");
12320 wmi_buf_free(buf);
12321 }
12322
12323 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12324
12325 WMI_LOGI("vdev_id = %u\n"
12326 "trigger_cmd = %u\n"
12327 "enable_cmd = %u\n",
12328 cmd->vdev_id,
12329 cmd->trigger_cmd,
12330 cmd->enable_cmd);
12331
12332 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12333
12334 return ret;
12335}
12336
12337/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012338 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12339 * @param wmi_handle : handle to WMI.
12340 * @param param : pointer to hold thermal mitigation param
12341 *
12342 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12343 */
12344static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12345 wmi_unified_t wmi_handle,
12346 struct thermal_mitigation_params *param)
12347{
12348 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12349 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12350 wmi_buf_t buf = NULL;
12351 uint8_t *buf_ptr = NULL;
12352 int error;
12353 int32_t len;
12354 int i;
12355
12356 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
12357 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
12358
12359 buf = wmi_buf_alloc(wmi_handle, len);
12360 if (!buf) {
12361 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12362 return QDF_STATUS_E_NOMEM;
12363 }
12364 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
12365
12366 /* init fixed params */
12367 WMITLV_SET_HDR(tt_conf,
12368 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
12369 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
12370
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012371 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12372 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012373 tt_conf->enable = param->enable;
12374 tt_conf->dc = param->dc;
12375 tt_conf->dc_per_event = param->dc_per_event;
12376 tt_conf->therm_throt_levels = THERMAL_LEVELS;
12377
12378 buf_ptr = (uint8_t *) ++tt_conf;
12379 /* init TLV params */
12380 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12381 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
12382
12383 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
12384 for (i = 0; i < THERMAL_LEVELS; i++) {
12385 WMITLV_SET_HDR(&lvl_conf->tlv_header,
12386 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
12387 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
12388 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
12389 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
12390 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
12391 lvl_conf->prio = param->levelconf[i].priority;
12392 lvl_conf++;
12393 }
12394
12395 error = wmi_unified_cmd_send(wmi_handle, buf, len,
12396 WMI_THERM_THROT_SET_CONF_CMDID);
12397 if (QDF_IS_STATUS_ERROR(error)) {
12398 wmi_buf_free(buf);
12399 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
12400 }
12401
12402 return error;
12403}
12404
12405/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012406 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
12407 * @wmi_handle: wmi handle
12408 * @param: pointer to pdev_qvit_params
12409 *
12410 * Return: 0 for success or error code
12411 */
12412static QDF_STATUS
12413send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
12414 struct pdev_qvit_params *param)
12415{
12416 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012417 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012418 uint8_t *cmd;
12419 static uint8_t msgref = 1;
12420 uint8_t segnumber = 0, seginfo, numsegments;
12421 uint16_t chunk_len, total_bytes;
12422 uint8_t *bufpos;
12423 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
12424
12425 bufpos = param->utf_payload;
12426 total_bytes = param->len;
12427 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
12428 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
12429 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
12430
12431 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
12432 numsegments++;
12433
12434 while (param->len) {
12435 if (param->len > MAX_WMI_QVIT_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -070012436 chunk_len = MAX_WMI_QVIT_LEN; /* MAX message */
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012437 else
12438 chunk_len = param->len;
12439
12440 buf = wmi_buf_alloc(wmi_handle,
12441 (chunk_len + sizeof(seghdrinfo) +
12442 WMI_TLV_HDR_SIZE));
12443 if (!buf) {
12444 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12445 return QDF_STATUS_E_NOMEM;
12446 }
12447
12448 cmd = (uint8_t *) wmi_buf_data(buf);
12449
12450 seghdrinfo.len = total_bytes;
12451 seghdrinfo.msgref = msgref;
12452 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
12453 seghdrinfo.segmentInfo = seginfo;
12454
12455 segnumber++;
12456
12457 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
12458 (chunk_len + sizeof(seghdrinfo)));
12459 cmd += WMI_TLV_HDR_SIZE;
12460 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
12461 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
12462
12463 ret = wmi_unified_cmd_send(wmi_handle, buf,
12464 (chunk_len + sizeof(seghdrinfo) +
12465 WMI_TLV_HDR_SIZE),
12466 WMI_PDEV_QVIT_CMDID);
12467
12468 if (ret != 0) {
12469 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
12470 wmi_buf_free(buf);
12471 break;
12472 }
12473
12474 param->len -= chunk_len;
12475 bufpos += chunk_len;
12476 }
12477 msgref++;
12478
12479 return ret;
12480}
12481
12482/**
12483 * send_wmm_update_cmd_tlv() - send wmm update command to fw
12484 * @wmi_handle: wmi handle
12485 * @param: pointer to wmm update param
12486 *
12487 * Return: 0 for success or error code
12488 */
12489static QDF_STATUS
12490send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
12491 struct wmm_update_params *param)
12492{
12493 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
12494 wmi_wmm_params *wmm_param;
12495 wmi_buf_t buf;
12496 QDF_STATUS ret;
12497 int32_t len;
12498 int ac = 0;
12499 struct wmi_host_wmeParams *wmep;
12500 uint8_t *buf_ptr;
12501
12502 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
12503 buf = wmi_buf_alloc(wmi_handle, len);
12504 if (!buf) {
12505 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12506 return QDF_STATUS_E_FAILURE;
12507 }
12508
12509 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12510 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
12511 WMITLV_SET_HDR(&cmd->tlv_header,
12512 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
12513 WMITLV_GET_STRUCT_TLVLEN
12514 (wmi_pdev_set_wmm_params_cmd_fixed_param));
12515
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012516 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012517
12518 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
12519
12520 for (ac = 0; ac < WME_NUM_AC; ac++) {
12521 wmep = &param->wmep_array[ac];
12522 wmm_param = (wmi_wmm_params *)buf_ptr;
12523 WMITLV_SET_HDR(&wmm_param->tlv_header,
12524 WMITLV_TAG_STRUC_wmi_wmm_params,
12525 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
12526 wmm_param->aifs = wmep->wmep_aifsn;
12527 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
12528 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
12529 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
12530 wmm_param->acm = wmep->wmep_acm;
12531 wmm_param->no_ack = wmep->wmep_noackPolicy;
12532 buf_ptr += sizeof(wmi_wmm_params);
12533 }
12534 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12535 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12536
12537 if (ret != 0) {
12538 WMI_LOGE("Sending WMM update CMD failed\n");
12539 wmi_buf_free(buf);
12540 }
12541
12542 return ret;
12543}
12544
Sathish Kumar80f4f382017-04-24 11:36:00 +053012545/**
12546 * send_coex_config_cmd_tlv() - send coex config command to fw
12547 * @wmi_handle: wmi handle
12548 * @param: pointer to coex config param
12549 *
12550 * Return: 0 for success or error code
12551 */
12552static QDF_STATUS
12553send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12554 struct coex_config_params *param)
12555{
12556 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12557 wmi_buf_t buf;
12558 QDF_STATUS ret;
12559 int32_t len;
12560
12561 len = sizeof(*cmd);
12562 buf = wmi_buf_alloc(wmi_handle, len);
12563 if (!buf) {
12564 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12565 return QDF_STATUS_E_FAILURE;
12566 }
12567
12568 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12569 WMITLV_SET_HDR(&cmd->tlv_header,
12570 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12571 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012572 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012573
12574 cmd->vdev_id = param->vdev_id;
12575 cmd->config_type = param->config_type;
12576 cmd->config_arg1 = param->config_arg1;
12577 cmd->config_arg2 = param->config_arg2;
12578 cmd->config_arg3 = param->config_arg3;
12579 cmd->config_arg4 = param->config_arg4;
12580 cmd->config_arg5 = param->config_arg5;
12581 cmd->config_arg6 = param->config_arg6;
12582
12583 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12584 WMI_COEX_CONFIG_CMDID);
12585
12586 if (ret != 0) {
12587 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12588 wmi_buf_free(buf);
12589 }
12590
12591 return ret;
12592}
12593
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012594
12595#ifdef WLAN_SUPPORT_TWT
12596static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12597 target_resource_config *tgt_res_cfg)
12598{
12599 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
12600 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
12601}
12602#else
12603static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12604 target_resource_config *tgt_res_cfg)
12605{
12606 resource_cfg->twt_ap_pdev_count = 0;
12607 resource_cfg->twt_ap_sta_count = 0;
12608}
12609#endif
12610
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012611static
Govind Singh9ddd5162016-03-07 16:30:32 +053012612void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053012613 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053012614{
Govind Singhe7f2f342016-05-23 12:12:52 +053012615 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053012616 resource_cfg->num_peers = tgt_res_cfg->num_peers;
12617 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
12618 resource_cfg->num_offload_reorder_buffs =
12619 tgt_res_cfg->num_offload_reorder_buffs;
12620 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
12621 resource_cfg->num_tids = tgt_res_cfg->num_tids;
12622 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
12623 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
12624 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
12625 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
12626 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
12627 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
12628 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
12629 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
12630 resource_cfg->scan_max_pending_req =
12631 tgt_res_cfg->scan_max_pending_req;
12632 resource_cfg->bmiss_offload_max_vdev =
12633 tgt_res_cfg->bmiss_offload_max_vdev;
12634 resource_cfg->roam_offload_max_vdev =
12635 tgt_res_cfg->roam_offload_max_vdev;
12636 resource_cfg->roam_offload_max_ap_profiles =
12637 tgt_res_cfg->roam_offload_max_ap_profiles;
12638 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
12639 resource_cfg->num_mcast_table_elems =
12640 tgt_res_cfg->num_mcast_table_elems;
12641 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
12642 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
12643 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
12644 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
12645 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
12646 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
12647 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
12648 resource_cfg->vow_config = tgt_res_cfg->vow_config;
12649 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
12650 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
12651 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
12652 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
12653 resource_cfg->num_tdls_conn_table_entries =
12654 tgt_res_cfg->num_tdls_conn_table_entries;
12655 resource_cfg->beacon_tx_offload_max_vdev =
12656 tgt_res_cfg->beacon_tx_offload_max_vdev;
12657 resource_cfg->num_multicast_filter_entries =
12658 tgt_res_cfg->num_multicast_filter_entries;
12659 resource_cfg->num_wow_filters =
12660 tgt_res_cfg->num_wow_filters;
12661 resource_cfg->num_keep_alive_pattern =
12662 tgt_res_cfg->num_keep_alive_pattern;
12663 resource_cfg->keep_alive_pattern_size =
12664 tgt_res_cfg->keep_alive_pattern_size;
12665 resource_cfg->max_tdls_concurrent_sleep_sta =
12666 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
12667 resource_cfg->max_tdls_concurrent_buffer_sta =
12668 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
12669 resource_cfg->wmi_send_separate =
12670 tgt_res_cfg->wmi_send_separate;
12671 resource_cfg->num_ocb_vdevs =
12672 tgt_res_cfg->num_ocb_vdevs;
12673 resource_cfg->num_ocb_channels =
12674 tgt_res_cfg->num_ocb_channels;
12675 resource_cfg->num_ocb_schedules =
12676 tgt_res_cfg->num_ocb_schedules;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053012677 resource_cfg->bpf_instruction_size = tgt_res_cfg->apf_instruction_size;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053012678 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
12679 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012680 resource_cfg->max_num_dbs_scan_duty_cycle =
12681 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080012682 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080012683 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
12684 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -070012685 resource_cfg->max_bssid_indicator = tgt_res_cfg->max_bssid_indicator;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012686 if (tgt_res_cfg->atf_config)
12687 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
12688 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
12689 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
12690 resource_cfg->flag1, 1);
12691 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
12692 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
12693 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053012694 if (tgt_res_cfg->cce_disable)
12695 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012696
12697 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Govind Singh9ddd5162016-03-07 16:30:32 +053012698}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012699
12700/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
12701 * @wmi_handle: pointer to wmi handle
12702 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -070012703 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012704 * @param: point host parameters for init command
12705 *
12706 * Return: Updated pointer of buf_ptr.
12707 */
12708static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
12709 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
12710{
12711 uint16_t idx;
12712
12713 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
12714 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
12715 wmi_pdev_band_to_mac *band_to_mac;
12716
12717 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
12718 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
12719 sizeof(wmi_resource_config) +
12720 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
12721 sizeof(wlan_host_memory_chunk)));
12722
12723 WMITLV_SET_HDR(&hw_mode->tlv_header,
12724 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12725 (WMITLV_GET_STRUCT_TLVLEN
12726 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
12727
12728 hw_mode->hw_mode_index = param->hw_mode_id;
12729 hw_mode->num_band_to_mac = param->num_band_to_mac;
12730
12731 buf_ptr = (uint8_t *) (hw_mode + 1);
12732 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
12733 WMI_TLV_HDR_SIZE);
12734 for (idx = 0; idx < param->num_band_to_mac; idx++) {
12735 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
12736 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
12737 WMITLV_GET_STRUCT_TLVLEN
12738 (wmi_pdev_band_to_mac));
12739 band_to_mac[idx].pdev_id =
12740 wmi_handle->ops->convert_pdev_id_host_to_target(
12741 param->band_to_mac[idx].pdev_id);
12742 band_to_mac[idx].start_freq =
12743 param->band_to_mac[idx].start_freq;
12744 band_to_mac[idx].end_freq =
12745 param->band_to_mac[idx].end_freq;
12746 }
12747 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
12748 (param->num_band_to_mac *
12749 sizeof(wmi_pdev_band_to_mac)) +
12750 WMI_TLV_HDR_SIZE;
12751
12752 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12753 (param->num_band_to_mac *
12754 sizeof(wmi_pdev_band_to_mac)));
12755 }
12756
12757 return buf_ptr;
12758}
12759
12760static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
12761 wmi_init_cmd_fixed_param *cmd)
12762{
12763 int num_whitelist;
12764 wmi_abi_version my_vers;
12765
12766 num_whitelist = sizeof(version_whitelist) /
12767 sizeof(wmi_whitelist_version_info);
12768 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12769 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12770 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12771 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
12772 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
12773 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
12774
12775 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
12776 &my_vers,
12777 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
12778 &cmd->host_abi_vers);
12779
12780 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
12781 __func__,
12782 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
12783 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
12784 cmd->host_abi_vers.abi_version_ns_0,
12785 cmd->host_abi_vers.abi_version_ns_1,
12786 cmd->host_abi_vers.abi_version_ns_2,
12787 cmd->host_abi_vers.abi_version_ns_3);
12788
12789 /* Save version sent from host -
12790 * Will be used to check ready event
12791 */
12792 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
12793 sizeof(wmi_abi_version));
12794}
12795
Sathish Kumarfd347372017-02-13 12:29:09 +053012796static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053012797{
12798 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12799 wmi_service_ready_event_fixed_param *ev;
12800
12801
12802 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12803
12804 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12805 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053012806 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012807
12808 /*Save fw version from service ready message */
12809 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053012810 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012811 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012812
Govind Singhb53420c2016-03-09 14:32:57 +053012813 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012814}
12815
12816/**
12817 * wmi_unified_save_fw_version_cmd() - save fw version
12818 * @wmi_handle: pointer to wmi handle
12819 * @res_cfg: resource config
12820 * @num_mem_chunks: no of mem chunck
12821 * @mem_chunk: pointer to mem chunck structure
12822 *
12823 * This function sends IE information to firmware
12824 *
Govind Singhb53420c2016-03-09 14:32:57 +053012825 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012826 *
12827 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012828static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012829 void *evt_buf)
12830{
12831 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12832 wmi_ready_event_fixed_param *ev = NULL;
12833
12834 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12835 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012836 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
12837 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012838 &ev->fw_abi_vers)) {
12839 /*
12840 * Error: Our host version and the given firmware version
12841 * are incompatible.
12842 **/
Govind Singhb53420c2016-03-09 14:32:57 +053012843 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053012844 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
12845 __func__,
12846 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
12847 abi_version_0),
12848 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
12849 abi_version_0),
12850 wmi_handle->final_abi_vers.abi_version_ns_0,
12851 wmi_handle->final_abi_vers.abi_version_ns_1,
12852 wmi_handle->final_abi_vers.abi_version_ns_2,
12853 wmi_handle->final_abi_vers.abi_version_ns_3,
12854 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
12855 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
12856 ev->fw_abi_vers.abi_version_ns_0,
12857 ev->fw_abi_vers.abi_version_ns_1,
12858 ev->fw_abi_vers.abi_version_ns_2,
12859 ev->fw_abi_vers.abi_version_ns_3);
12860
Govind Singhb53420c2016-03-09 14:32:57 +053012861 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012862 }
Govind Singhb53420c2016-03-09 14:32:57 +053012863 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012864 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053012865 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012866 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053012867
Govind Singhb53420c2016-03-09 14:32:57 +053012868 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012869}
Govind Singha4836fd2016-03-07 16:45:38 +053012870
12871/**
12872 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
12873 * @wmi_handle: wmi handle
12874 * @custom_addr: base mac address
12875 *
Govind Singhe7f2f342016-05-23 12:12:52 +053012876 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053012877 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012878static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012879 uint8_t *custom_addr)
12880{
12881 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
12882 wmi_buf_t buf;
12883 int err;
12884
12885 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12886 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012887 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053012888 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012889 }
12890
12891 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012892 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053012893
12894 WMITLV_SET_HDR(&cmd->tlv_header,
12895 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
12896 WMITLV_GET_STRUCT_TLVLEN
12897 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
12898 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012899 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12900 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012901 err = wmi_unified_cmd_send(wmi_handle, buf,
12902 sizeof(*cmd),
12903 WMI_PDEV_SET_BASE_MACADDR_CMDID);
12904 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053012905 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053012906 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012907 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012908 }
12909
12910 return 0;
12911}
12912
12913/**
12914 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
12915 * @handle: wmi handle
12916 * @event: Event received from FW
12917 * @len: Length of the event
12918 *
12919 * Enables the low frequency events and disables the high frequency
12920 * events. Bit 17 indicates if the event if low/high frequency.
12921 * 1 - high frequency, 0 - low frequency
12922 *
12923 * Return: 0 on successfully enabling/disabling the events
12924 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012925static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012926 uint8_t *event,
12927 uint32_t len)
12928{
12929 uint32_t num_of_diag_events_logs;
12930 wmi_diag_event_log_config_fixed_param *cmd;
12931 wmi_buf_t buf;
12932 uint8_t *buf_ptr;
12933 uint32_t *cmd_args, *evt_args;
12934 uint32_t buf_len, i;
12935
12936 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12937 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12938
Govind Singhb53420c2016-03-09 14:32:57 +053012939 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012940
12941 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12942 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012943 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012944 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012945 }
12946 wmi_event = param_buf->fixed_param;
12947 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070012948
12949 if (num_of_diag_events_logs >
12950 param_buf->num_diag_events_logs_list) {
12951 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
12952 num_of_diag_events_logs,
12953 param_buf->num_diag_events_logs_list);
12954 return QDF_STATUS_E_INVAL;
12955 }
12956
Govind Singha4836fd2016-03-07 16:45:38 +053012957 evt_args = param_buf->diag_events_logs_list;
12958 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012959 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012960 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012961 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012962 }
12963
Govind Singhb53420c2016-03-09 14:32:57 +053012964 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012965 __func__, num_of_diag_events_logs);
12966
12967 /* Free any previous allocation */
12968 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012969 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012970
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070012971 if (num_of_diag_events_logs >
12972 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
12973 WMI_LOGE("%s: excess num of logs:%d", __func__,
12974 num_of_diag_events_logs);
12975 QDF_ASSERT(0);
12976 return QDF_STATUS_E_INVAL;
12977 }
Govind Singha4836fd2016-03-07 16:45:38 +053012978 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012979 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012980 sizeof(uint32_t));
12981 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012982 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012983 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012984 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012985 }
12986 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12987
12988 /* Prepare the send buffer */
12989 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12990 (num_of_diag_events_logs * sizeof(uint32_t));
12991
12992 buf = wmi_buf_alloc(wmi_handle, buf_len);
12993 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012994 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12995 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012996 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012997 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012998 }
12999
13000 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13001 buf_ptr = (uint8_t *) cmd;
13002
13003 WMITLV_SET_HDR(&cmd->tlv_header,
13004 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13005 WMITLV_GET_STRUCT_TLVLEN(
13006 wmi_diag_event_log_config_fixed_param));
13007
13008 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13009
13010 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13011
13012 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13013 (num_of_diag_events_logs * sizeof(uint32_t)));
13014
13015 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13016
13017 /* Populate the events */
13018 for (i = 0; i < num_of_diag_events_logs; i++) {
13019 /* Low freq (0) - Enable (1) the event
13020 * High freq (1) - Disable (0) the event
13021 */
13022 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13023 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13024 /* Set the event ID */
13025 WMI_DIAG_ID_SET(cmd_args[i],
13026 WMI_DIAG_ID_GET(evt_args[i]));
13027 /* Set the type */
13028 WMI_DIAG_TYPE_SET(cmd_args[i],
13029 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013030 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013031 wmi_handle->events_logs_list[i] = evt_args[i];
13032 }
13033
13034 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13035 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013036 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013037 __func__);
13038 wmi_buf_free(buf);
13039 /* Not clearing events_logs_list, though wmi cmd failed.
13040 * Host can still have this list
13041 */
Govind Singh67922e82016-04-01 16:48:57 +053013042 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013043 }
13044
13045 return 0;
13046}
13047
13048/**
13049 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13050 * @wmi_handle: wmi handle
13051 * @start_log: Start logging related parameters
13052 *
13053 * Send the command to the FW based on which specific logging of diag
13054 * event/log id can be started/stopped
13055 *
13056 * Return: None
13057 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013058static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013059 struct wmi_wifi_start_log *start_log)
13060{
13061 wmi_diag_event_log_config_fixed_param *cmd;
13062 wmi_buf_t buf;
13063 uint8_t *buf_ptr;
13064 uint32_t len, count, log_level, i;
13065 uint32_t *cmd_args;
13066 uint32_t total_len;
13067 count = 0;
13068
13069 if (!wmi_handle->events_logs_list) {
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +053013070 WMI_LOGD("%s: Not received event/log list from FW, yet",
13071 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013072 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013073 }
13074 /* total_len stores the number of events where BITS 17 and 18 are set.
13075 * i.e., events of high frequency (17) and for extended debugging (18)
13076 */
13077 total_len = 0;
13078 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13079 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13080 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13081 total_len++;
13082 }
13083
13084 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13085 (total_len * sizeof(uint32_t));
13086
13087 buf = wmi_buf_alloc(wmi_handle, len);
13088 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013089 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013090 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013091 }
13092 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13093 buf_ptr = (uint8_t *) cmd;
13094
13095 WMITLV_SET_HDR(&cmd->tlv_header,
13096 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13097 WMITLV_GET_STRUCT_TLVLEN(
13098 wmi_diag_event_log_config_fixed_param));
13099
13100 cmd->num_of_diag_events_logs = total_len;
13101
13102 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13103
13104 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13105 (total_len * sizeof(uint32_t)));
13106
13107 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13108
Govind Singh224a7312016-06-21 14:33:26 +053013109 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013110 log_level = 1;
13111 else
13112 log_level = 0;
13113
Govind Singhb53420c2016-03-09 14:32:57 +053013114 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013115 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13116 uint32_t val = wmi_handle->events_logs_list[i];
13117 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13118 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13119
13120 WMI_DIAG_ID_SET(cmd_args[count],
13121 WMI_DIAG_ID_GET(val));
13122 WMI_DIAG_TYPE_SET(cmd_args[count],
13123 WMI_DIAG_TYPE_GET(val));
13124 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13125 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013126 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013127 count++;
13128 }
13129 }
13130
13131 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13132 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013133 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013134 __func__);
13135 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013136 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013137 }
13138
Govind Singhb53420c2016-03-09 14:32:57 +053013139 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013140}
13141
13142/**
13143 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13144 * @wmi_handle: WMI handle
13145 *
13146 * This function is used to send the flush command to the FW,
13147 * that will flush the fw logs that are residue in the FW
13148 *
13149 * Return: None
13150 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013151static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013152{
13153 wmi_debug_mesg_flush_fixed_param *cmd;
13154 wmi_buf_t buf;
13155 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013156 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013157
13158 buf = wmi_buf_alloc(wmi_handle, len);
13159 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013160 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013161 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013162 }
13163
13164 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13165 WMITLV_SET_HDR(&cmd->tlv_header,
13166 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13167 WMITLV_GET_STRUCT_TLVLEN(
13168 wmi_debug_mesg_flush_fixed_param));
13169 cmd->reserved0 = 0;
13170
13171 ret = wmi_unified_cmd_send(wmi_handle,
13172 buf,
13173 len,
13174 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013175 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013176 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013177 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013178 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013179 }
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +053013180 WMI_LOGD("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013181
Govind Singh67922e82016-04-01 16:48:57 +053013182 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013183}
13184
13185/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013186 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013187 * @wmi_handle: wmi handle
13188 * @msg: PCL structure containing the PCL and the number of channels
13189 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013190 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013191 * firmware. The DBS Manager is the consumer of this information in the WLAN
13192 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13193 * to migrate to a new channel without host driver involvement. An example of
13194 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13195 * manage the channel selection without firmware involvement.
13196 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013197 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13198 * channel list. The weights corresponds to the channels sent in
13199 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13200 * weightage compared to the non PCL channels.
13201 *
Govind Singha4836fd2016-03-07 16:45:38 +053013202 * Return: Success if the cmd is sent successfully to the firmware
13203 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013204static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013205 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013206{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013207 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013208 wmi_buf_t buf;
13209 uint8_t *buf_ptr;
13210 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013211 uint32_t chan_len;
13212
13213 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013214
13215 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013216 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013217
13218 buf = wmi_buf_alloc(wmi_handle, len);
13219 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013220 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13221 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013222 }
13223
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013224 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013225 buf_ptr = (uint8_t *) cmd;
13226 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013227 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13228 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013229
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013230 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13231 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013232 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013233 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013234
13235 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013236 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013237 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013238 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013239 for (i = 0; i < chan_len ; i++) {
13240 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013241 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013242 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013243 }
13244 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013245 WMI_PDEV_SET_PCL_CMDID)) {
13246 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013247 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013248 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013249 }
Govind Singhb53420c2016-03-09 14:32:57 +053013250 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013251}
13252
13253/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013254 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013255 * @wmi_handle: wmi handle
13256 * @msg: Structure containing the following parameters
13257 *
13258 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13259 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13260 *
13261 * Provides notification to the WLAN firmware that host driver is requesting a
13262 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13263 * configurations that include the Dual Band Simultaneous (DBS) feature.
13264 *
13265 * Return: Success if the cmd is sent successfully to the firmware
13266 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013267static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013268 uint32_t hw_mode_index)
13269{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013270 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013271 wmi_buf_t buf;
13272 uint32_t len;
13273
13274 len = sizeof(*cmd);
13275
13276 buf = wmi_buf_alloc(wmi_handle, len);
13277 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013278 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13279 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013280 }
13281
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013282 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013283 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013284 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13285 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13286
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013287 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13288 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013289 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013290 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013291
13292 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013293 WMI_PDEV_SET_HW_MODE_CMDID)) {
13294 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013295 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013296 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013297 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013298 }
13299
Govind Singhb53420c2016-03-09 14:32:57 +053013300 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013301}
13302
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013303#ifdef WLAN_POLICY_MGR_ENABLE
Govind Singha4836fd2016-03-07 16:45:38 +053013304/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013305 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013306 * @wmi_handle: wmi handle
13307 * @msg: Dual MAC config parameters
13308 *
13309 * Configures WLAN firmware with the dual MAC features
13310 *
Govind Singhb53420c2016-03-09 14:32:57 +053013311 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013312 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013313static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013314QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013315 struct policy_mgr_dual_mac_config *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013316{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013317 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013318 wmi_buf_t buf;
13319 uint32_t len;
13320
13321 len = sizeof(*cmd);
13322
13323 buf = wmi_buf_alloc(wmi_handle, len);
13324 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013325 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13326 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013327 }
13328
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013329 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013330 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013331 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013332 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013333 wmi_pdev_set_mac_config_cmd_fixed_param));
13334
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013335 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13336 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013337 cmd->concurrent_scan_config_bits = msg->scan_config;
13338 cmd->fw_mode_config_bits = msg->fw_mode_config;
Yeshwanth Sriram Guntuka03a37812018-08-16 15:55:25 +053013339 WMI_LOGD("%s: scan_config:%x fw_mode_config:%x",
13340 __func__, msg->scan_config, msg->fw_mode_config);
Govind Singha4836fd2016-03-07 16:45:38 +053013341
13342 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013343 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13344 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013345 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013346 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013347 }
Govind Singhb53420c2016-03-09 14:32:57 +053013348 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013349}
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013350#endif
Govind Singha4836fd2016-03-07 16:45:38 +053013351
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013352#ifdef BIG_ENDIAN_HOST
13353/**
13354* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13355* @param data_len - data length
13356* @param data - pointer to data
13357*
13358* Return: QDF_STATUS - success or error status
13359*/
13360static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13361 struct fips_params *param)
13362{
13363 unsigned char *key_unaligned, *data_unaligned;
13364 int c;
13365 u_int8_t *key_aligned = NULL;
13366 u_int8_t *data_aligned = NULL;
13367
13368 /* Assigning unaligned space to copy the key */
13369 key_unaligned = qdf_mem_malloc(
13370 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13371 data_unaligned = qdf_mem_malloc(
13372 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13373
Jeff Johnsonda263992018-05-12 14:22:00 -070013374 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013375 if (key_unaligned == NULL)
13376 return QDF_STATUS_SUCCESS;
13377 /* Checking if space is aligned */
13378 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
13379 /* align to 4 */
13380 key_aligned =
13381 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
13382 FIPS_ALIGN);
13383 } else {
13384 key_aligned = (u_int8_t *)key_unaligned;
13385 }
13386
13387 /* memset and copy content from key to key aligned */
13388 OS_MEMSET(key_aligned, 0, param->key_len);
13389 OS_MEMCPY(key_aligned, param->key, param->key_len);
13390
13391 /* print a hexdump for host debug */
13392 print_hex_dump(KERN_DEBUG,
13393 "\t Aligned and Copied Key:@@@@ ",
13394 DUMP_PREFIX_NONE,
13395 16, 1, key_aligned, param->key_len, true);
13396
Jeff Johnsonda263992018-05-12 14:22:00 -070013397 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013398 if (data_unaligned == NULL)
13399 return QDF_STATUS_SUCCESS;
13400 /* Checking of space is aligned */
13401 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13402 /* align to 4 */
13403 data_aligned =
13404 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
13405 FIPS_ALIGN);
13406 } else {
13407 data_aligned = (u_int8_t *)data_unaligned;
13408 }
13409
13410 /* memset and copy content from data to data aligned */
13411 OS_MEMSET(data_aligned, 0, param->data_len);
13412 OS_MEMCPY(data_aligned, param->data, param->data_len);
13413
13414 /* print a hexdump for host debug */
13415 print_hex_dump(KERN_DEBUG,
13416 "\t Properly Aligned and Copied Data:@@@@ ",
13417 DUMP_PREFIX_NONE,
13418 16, 1, data_aligned, param->data_len, true);
13419
13420 /* converting to little Endian both key_aligned and
13421 * data_aligned*/
13422 for (c = 0; c < param->key_len/4; c++) {
13423 *((u_int32_t *)key_aligned+c) =
13424 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
13425 }
13426 for (c = 0; c < param->data_len/4; c++) {
13427 *((u_int32_t *)data_aligned+c) =
13428 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
13429 }
13430
13431 /* update endian data to key and data vectors */
13432 OS_MEMCPY(param->key, key_aligned, param->key_len);
13433 OS_MEMCPY(param->data, data_aligned, param->data_len);
13434
13435 /* clean up allocated spaces */
13436 qdf_mem_free(key_unaligned);
13437 key_unaligned = NULL;
13438 key_aligned = NULL;
13439
13440 qdf_mem_free(data_unaligned);
13441 data_unaligned = NULL;
13442 data_aligned = NULL;
13443
13444 return QDF_STATUS_SUCCESS;
13445}
13446#else
13447/**
13448* fips_align_data_be() - DUMMY for LE platform
13449*
13450* Return: QDF_STATUS - success
13451*/
13452static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13453 struct fips_params *param)
13454{
13455 return QDF_STATUS_SUCCESS;
13456}
13457#endif
13458
13459
13460/**
13461 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
13462 * @wmi_handle: wmi handle
13463 * @param: pointer to hold pdev fips param
13464 *
13465 * Return: 0 for success or error code
13466 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013467static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013468send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
13469 struct fips_params *param)
13470{
13471 wmi_pdev_fips_cmd_fixed_param *cmd;
13472 wmi_buf_t buf;
13473 uint8_t *buf_ptr;
13474 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
13475 QDF_STATUS retval = QDF_STATUS_SUCCESS;
13476
13477 /* Length TLV placeholder for array of bytes */
13478 len += WMI_TLV_HDR_SIZE;
13479 if (param->data_len)
13480 len += (param->data_len*sizeof(uint8_t));
13481
13482 /*
13483 * Data length must be multiples of 16 bytes - checked against 0xF -
13484 * and must be less than WMI_SVC_MSG_SIZE - static size of
13485 * wmi_pdev_fips_cmd structure
13486 */
13487
13488 /* do sanity on the input */
13489 if (!(((param->data_len & 0xF) == 0) &&
13490 ((param->data_len > 0) &&
13491 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
13492 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
13493 return QDF_STATUS_E_INVAL;
13494 }
13495
13496 buf = wmi_buf_alloc(wmi_handle, len);
13497 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013498 qdf_print("%s:wmi_buf_alloc failed", __func__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013499 return QDF_STATUS_E_FAILURE;
13500 }
13501
13502 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13503 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
13504 WMITLV_SET_HDR(&cmd->tlv_header,
13505 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
13506 WMITLV_GET_STRUCT_TLVLEN
13507 (wmi_pdev_fips_cmd_fixed_param));
13508
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013509 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13510 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013511 if (param->key != NULL && param->data != NULL) {
13512 cmd->key_len = param->key_len;
13513 cmd->data_len = param->data_len;
13514 cmd->fips_cmd = !!(param->op);
13515
13516 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13517 return QDF_STATUS_E_FAILURE;
13518
13519 qdf_mem_copy(cmd->key, param->key, param->key_len);
13520
13521 if (param->mode == FIPS_ENGINE_AES_CTR ||
13522 param->mode == FIPS_ENGINE_AES_MIC) {
13523 cmd->mode = param->mode;
13524 } else {
13525 cmd->mode = FIPS_ENGINE_AES_CTR;
13526 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013527 qdf_print("Key len = %d, Data len = %d",
13528 cmd->key_len, cmd->data_len);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013529
13530 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13531 cmd->key, cmd->key_len, true);
13532 buf_ptr += sizeof(*cmd);
13533
13534 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13535
13536 buf_ptr += WMI_TLV_HDR_SIZE;
13537 if (param->data_len)
13538 qdf_mem_copy(buf_ptr,
13539 (uint8_t *) param->data, param->data_len);
13540
13541 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13542 16, 1, buf_ptr, cmd->data_len, true);
13543
13544 buf_ptr += param->data_len;
13545
13546 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13547 WMI_PDEV_FIPS_CMDID);
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013548 qdf_print("%s return value %d", __func__, retval);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013549 } else {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013550 qdf_print("\n%s:%d Key or Data is NULL", __func__, __LINE__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013551 wmi_buf_free(buf);
13552 retval = -QDF_STATUS_E_BADMSG;
13553 }
13554
13555 return retval;
13556}
13557
Wu Gao52c0b772018-05-17 16:14:00 +080013558#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013559/**
13560 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13561 * @wmi_handle: wmi handle
13562 * @vdev_id: vdev id
13563 * @bitmap: Event bitmap
13564 * @enable: enable/disable
13565 *
13566 * Return: CDF status
13567 */
13568static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13569 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013570 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013571 bool enable)
13572{
13573 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13574 uint16_t len;
13575 wmi_buf_t buf;
13576 int ret;
13577
13578 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13579 buf = wmi_buf_alloc(wmi_handle, len);
13580 if (!buf) {
13581 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13582 return QDF_STATUS_E_NOMEM;
13583 }
13584 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13585 WMITLV_SET_HDR(&cmd->tlv_header,
13586 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13587 WMITLV_GET_STRUCT_TLVLEN
13588 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13589 cmd->vdev_id = vdev_id;
13590 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013591 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13592 WMI_WOW_MAX_EVENT_BM_LEN);
13593
13594 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13595 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13596 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013597
13598 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13599 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13600 if (ret) {
13601 WMI_LOGE("Failed to config wow wakeup event");
13602 wmi_buf_free(buf);
13603 return QDF_STATUS_E_FAILURE;
13604 }
13605
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013606 return QDF_STATUS_SUCCESS;
13607}
13608
13609/**
13610 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13611 * @wmi_handle: wmi handle
13612 * @vdev_id: vdev id
13613 * @ptrn_id: pattern id
13614 * @ptrn: pattern
13615 * @ptrn_len: pattern length
13616 * @ptrn_offset: pattern offset
13617 * @mask: mask
13618 * @mask_len: mask length
13619 * @user: true for user configured pattern and false for default pattern
13620 * @default_patterns: default patterns
13621 *
13622 * Return: CDF status
13623 */
13624static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
13625 uint8_t vdev_id, uint8_t ptrn_id,
13626 const uint8_t *ptrn, uint8_t ptrn_len,
13627 uint8_t ptrn_offset, const uint8_t *mask,
13628 uint8_t mask_len, bool user,
13629 uint8_t default_patterns)
13630{
13631 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13632 WOW_BITMAP_PATTERN_T *bitmap_pattern;
13633 wmi_buf_t buf;
13634 uint8_t *buf_ptr;
13635 int32_t len;
13636 int ret;
13637
13638 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13639 WMI_TLV_HDR_SIZE +
13640 1 * sizeof(WOW_BITMAP_PATTERN_T) +
13641 WMI_TLV_HDR_SIZE +
13642 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13643 WMI_TLV_HDR_SIZE +
13644 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13645 WMI_TLV_HDR_SIZE +
13646 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13647 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053013648 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013649
13650 buf = wmi_buf_alloc(wmi_handle, len);
13651 if (!buf) {
13652 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13653 return QDF_STATUS_E_NOMEM;
13654 }
13655
13656 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13657 buf_ptr = (uint8_t *) cmd;
13658
13659 WMITLV_SET_HDR(&cmd->tlv_header,
13660 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13661 WMITLV_GET_STRUCT_TLVLEN
13662 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13663 cmd->vdev_id = vdev_id;
13664 cmd->pattern_id = ptrn_id;
13665
13666 cmd->pattern_type = WOW_BITMAP_PATTERN;
13667 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13668
13669 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13670 sizeof(WOW_BITMAP_PATTERN_T));
13671 buf_ptr += WMI_TLV_HDR_SIZE;
13672 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
13673
13674 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
13675 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
13676 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
13677
13678 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
13679 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
13680
13681 bitmap_pattern->pattern_offset = ptrn_offset;
13682 bitmap_pattern->pattern_len = ptrn_len;
13683
13684 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
13685 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
13686
13687 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
13688 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
13689
13690 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
13691 bitmap_pattern->pattern_id = ptrn_id;
13692
Manjunathappa Prakash6cbc6632018-08-14 18:18:10 -070013693 WMI_LOGD("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013694 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
13695 bitmap_pattern->pattern_offset, user);
Manjunathappa Prakash6cbc6632018-08-14 18:18:10 -070013696 WMI_LOGD("Pattern : ");
13697 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
13698 &bitmap_pattern->patternbuf[0],
13699 bitmap_pattern->pattern_len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013700
Manjunathappa Prakash6cbc6632018-08-14 18:18:10 -070013701 WMI_LOGD("Mask : ");
13702 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
13703 &bitmap_pattern->bitmaskbuf[0],
13704 bitmap_pattern->pattern_len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013705
13706 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
13707
13708 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13709 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13710 buf_ptr += WMI_TLV_HDR_SIZE;
13711
13712 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13713 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13714 buf_ptr += WMI_TLV_HDR_SIZE;
13715
13716 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13717 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13718 buf_ptr += WMI_TLV_HDR_SIZE;
13719
13720 /* Fill TLV for pattern_info_timeout but no data. */
13721 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13722 buf_ptr += WMI_TLV_HDR_SIZE;
13723
13724 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053013725 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013726 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053013727 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013728
13729 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13730 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13731 if (ret) {
13732 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
13733 wmi_buf_free(buf);
13734 return QDF_STATUS_E_FAILURE;
13735 }
13736
13737 return QDF_STATUS_SUCCESS;
13738}
13739
Govind Singha4836fd2016-03-07 16:45:38 +053013740/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013741 * fill_arp_offload_params_tlv() - Fill ARP offload data
13742 * @wmi_handle: wmi handle
13743 * @offload_req: offload request
13744 * @buf_ptr: buffer pointer
13745 *
13746 * To fill ARP offload data to firmware
13747 * when target goes to wow mode.
13748 *
13749 * Return: None
13750 */
13751static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013752 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013753{
13754
13755 int i;
13756 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013757 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013758
13759 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13760 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
13761 *buf_ptr += WMI_TLV_HDR_SIZE;
13762 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
13763 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
13764 WMITLV_SET_HDR(&arp_tuple->tlv_header,
13765 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
13766 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
13767
13768 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013769 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013770 /* Copy the target ip addr and flags */
13771 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
13772 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013773 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013774 WMI_IPV4_ADDR_LEN);
13775 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013776 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013777 }
13778 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
13779 }
13780}
13781
13782#ifdef WLAN_NS_OFFLOAD
13783/**
13784 * fill_ns_offload_params_tlv() - Fill NS offload data
13785 * @wmi|_handle: wmi handle
13786 * @offload_req: offload request
13787 * @buf_ptr: buffer pointer
13788 *
13789 * To fill NS offload data to firmware
13790 * when target goes to wow mode.
13791 *
13792 * Return: None
13793 */
13794static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013795 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013796{
13797
13798 int i;
13799 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013800
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013801 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13802 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13803 *buf_ptr += WMI_TLV_HDR_SIZE;
13804 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
13805 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13806 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13807 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13808 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
13809
13810 /*
13811 * Fill data only for NS offload in the first ARP tuple for LA
13812 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013813 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013814 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13815 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013816 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013817 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013818 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013819 sizeof(WMI_IPV6_ADDR));
13820 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013821 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013822 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013823 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013824 ns_tuple->flags |=
13825 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13826 }
13827 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013828 i, &ns_req->self_ipv6_addr[i],
13829 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013830
13831 /* target MAC is optional, check if it is valid,
13832 * if this is not valid, the target will use the known
13833 * local MAC address rather than the tuple
13834 */
13835 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013836 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013837 &ns_tuple->target_mac);
13838 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13839 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13840 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13841 }
13842 }
13843 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13844 }
13845}
13846
13847
13848/**
13849 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
13850 * @wmi: wmi handle
13851 * @offload_req: offload request
13852 * @buf_ptr: buffer pointer
13853 *
13854 * To fill extended NS offload extended data to firmware
13855 * when target goes to wow mode.
13856 *
13857 * Return: None
13858 */
13859static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013860 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013861{
13862 int i;
13863 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
13864 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013865
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013866 count = ns_req->num_ns_offload_count;
13867 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013868 WMI_MAX_NS_OFFLOADS;
13869
13870 /* Populate extended NS offload tuples */
13871 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13872 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13873 *buf_ptr += WMI_TLV_HDR_SIZE;
13874 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
13875 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13876 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13877 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13878 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
13879
13880 /*
13881 * Fill data only for NS offload in the first ARP tuple for LA
13882 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013883 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013884 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13885 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013886 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013887 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013888 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013889 sizeof(WMI_IPV6_ADDR));
13890 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013891 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013892 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013893 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013894 ns_tuple->flags |=
13895 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13896 }
13897 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013898 i, &ns_req->self_ipv6_addr[i],
13899 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013900
13901 /* target MAC is optional, check if it is valid,
13902 * if this is not valid, the target will use the
13903 * known local MAC address rather than the tuple
13904 */
13905 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013906 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013907 &ns_tuple->target_mac);
13908 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13909 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13910 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13911 }
13912 }
13913 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13914 }
13915}
13916#else
13917static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013918 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013919{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013920}
13921
13922static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013923 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013924{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013925}
13926#endif
13927
13928/**
Govind Singha4836fd2016-03-07 16:45:38 +053013929 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
13930 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013931 * @arp_offload_req: arp offload request
13932 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053013933 * @arp_only: flag
13934 *
13935 * To configure ARP NS off load data to firmware
13936 * when target goes to wow mode.
13937 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013938 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013939 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013940static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013941 struct pmo_arp_offload_params *arp_offload_req,
13942 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013943 uint8_t vdev_id)
13944{
Govind Singha4836fd2016-03-07 16:45:38 +053013945 int32_t res;
13946 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053013947 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053013948 wmi_buf_t buf;
13949 int32_t len;
13950 uint32_t count = 0, num_ns_ext_tuples = 0;
13951
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013952 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013953
Govind Singha4836fd2016-03-07 16:45:38 +053013954 /*
13955 * TLV place holder size for array of NS tuples
13956 * TLV place holder size for array of ARP tuples
13957 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013958 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13959 WMI_TLV_HDR_SIZE +
13960 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13961 WMI_TLV_HDR_SIZE +
13962 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013963
13964 /*
13965 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13966 * extra length for extended NS offload tuples which follows ARP offload
13967 * tuples. Host needs to fill this structure in following format:
13968 * 2 NS ofload tuples
13969 * 2 ARP offload tuples
13970 * N numbers of extended NS offload tuples if HDD has given more than
13971 * 2 NS offload addresses
13972 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013973 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013974 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013975 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13976 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013977 }
13978
13979 buf = wmi_buf_alloc(wmi_handle, len);
13980 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013981 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013982 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013983 }
13984
Vivekc5823092018-03-22 23:27:21 +053013985 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013986 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13987 WMITLV_SET_HDR(&cmd->tlv_header,
13988 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13989 WMITLV_GET_STRUCT_TLVLEN
13990 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13991 cmd->flags = 0;
13992 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013993 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013994
Govind Singhb53420c2016-03-09 14:32:57 +053013995 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013996
Govind Singha4836fd2016-03-07 16:45:38 +053013997 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013998 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13999 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14000 if (num_ns_ext_tuples)
14001 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014002
14003 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14004 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14005 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014006 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014007 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014008 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014009 }
14010
Govind Singhb53420c2016-03-09 14:32:57 +053014011 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014012}
14013
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014014/**
14015 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14016 * @wmi_handle: wmi handle
14017 * @vdev_id: vdev id
14018 * @action: true for enable else false
14019 *
14020 * To enable enhance multicast offload to firmware
14021 * when target goes to wow mode.
14022 *
14023 * Return: QDF Status
14024 */
14025
14026static
14027QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14028 wmi_unified_t wmi_handle,
14029 uint8_t vdev_id, bool action)
14030{
14031 QDF_STATUS status;
14032 wmi_buf_t buf;
14033 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14034
14035 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14036 if (!buf) {
14037 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14038 return QDF_STATUS_E_NOMEM;
14039 }
14040
14041 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14042 wmi_buf_data(buf);
14043
14044 WMITLV_SET_HDR(&cmd->tlv_header,
14045 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14046 WMITLV_GET_STRUCT_TLVLEN(
14047 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14048
14049 cmd->vdev_id = vdev_id;
14050 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14051 ENHANCED_MCAST_FILTER_ENABLED);
14052 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14053 __func__, action, vdev_id);
14054 status = wmi_unified_cmd_send(wmi_handle, buf,
14055 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14056 if (status != QDF_STATUS_SUCCESS) {
14057 qdf_nbuf_free(buf);
14058 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14059 __func__);
14060 }
14061
14062 return status;
14063}
14064
14065/**
14066 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14067 * @wmi_handle: wmi handle
14068 * @param evt_buf: pointer to event buffer
14069 * @param hdr: Pointer to hold header
14070 * @param bufp: Pointer to hold pointer to rx param buffer
14071 *
14072 * Return: QDF_STATUS_SUCCESS for success or error code
14073 */
14074static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14075 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14076{
14077 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14078 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14079
14080 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14081 if (!param_buf) {
14082 WMI_LOGE("gtk param_buf is NULL");
14083 return QDF_STATUS_E_INVAL;
14084 }
14085
14086 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14087 WMI_LOGE("Invalid length for GTK status");
14088 return QDF_STATUS_E_INVAL;
14089 }
14090
14091 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14092 param_buf->fixed_param;
14093 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14094 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14095 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14096 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14097 &fixed_param->replay_counter,
14098 GTK_REPLAY_COUNTER_BYTES);
14099
14100 return QDF_STATUS_SUCCESS;
14101
14102}
14103
14104#ifdef FEATURE_WLAN_RA_FILTERING
14105/**
14106 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14107 * @wmi_handle: wmi handle
14108 * @vdev_id: vdev id
14109 *
14110 * Return: CDF status
14111 */
14112static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14113 uint8_t vdev_id, uint8_t default_pattern,
14114 uint16_t rate_limit_interval)
14115{
14116
14117 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14118 wmi_buf_t buf;
14119 uint8_t *buf_ptr;
14120 int32_t len;
14121 int ret;
14122
14123 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14124 WMI_TLV_HDR_SIZE +
14125 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14126 WMI_TLV_HDR_SIZE +
14127 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14128 WMI_TLV_HDR_SIZE +
14129 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14130 WMI_TLV_HDR_SIZE +
14131 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14132 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014133 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014134
14135 buf = wmi_buf_alloc(wmi_handle, len);
14136 if (!buf) {
14137 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14138 return QDF_STATUS_E_NOMEM;
14139 }
14140
14141 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14142 buf_ptr = (uint8_t *) cmd;
14143
14144 WMITLV_SET_HDR(&cmd->tlv_header,
14145 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14146 WMITLV_GET_STRUCT_TLVLEN
14147 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14148 cmd->vdev_id = vdev_id;
14149 cmd->pattern_id = default_pattern,
14150 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14151 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14152
14153 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14154 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14155 buf_ptr += WMI_TLV_HDR_SIZE;
14156
14157 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14158 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14159 buf_ptr += WMI_TLV_HDR_SIZE;
14160
14161 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14162 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14163 buf_ptr += WMI_TLV_HDR_SIZE;
14164
14165 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14166 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14167 buf_ptr += WMI_TLV_HDR_SIZE;
14168
14169 /* Fill TLV for pattern_info_timeout but no data. */
14170 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14171 buf_ptr += WMI_TLV_HDR_SIZE;
14172
14173 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014174 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014175 buf_ptr += WMI_TLV_HDR_SIZE;
14176
Vivekc5823092018-03-22 23:27:21 +053014177 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014178
14179 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14180 rate_limit_interval, vdev_id);
14181
14182 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14183 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14184 if (ret) {
14185 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14186 wmi_buf_free(buf);
14187 return QDF_STATUS_E_FAILURE;
14188 }
14189
14190 return QDF_STATUS_SUCCESS;
14191
14192}
14193#endif /* FEATURE_WLAN_RA_FILTERING */
14194
14195/**
14196 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14197 * @wmi_handle: wmi handle
14198 * @vdev_id: vdev id
14199 * @multicastAddr: mcast address
14200 * @clearList: clear list flag
14201 *
14202 * Return: QDF_STATUS_SUCCESS for success or error code
14203 */
14204static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14205 uint8_t vdev_id,
14206 struct qdf_mac_addr multicast_addr,
14207 bool clearList)
14208{
14209 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14210 wmi_buf_t buf;
14211 int err;
14212
14213 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14214 if (!buf) {
14215 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14216 return QDF_STATUS_E_NOMEM;
14217 }
14218
14219 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14220 qdf_mem_zero(cmd, sizeof(*cmd));
14221
14222 WMITLV_SET_HDR(&cmd->tlv_header,
14223 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14224 WMITLV_GET_STRUCT_TLVLEN
14225 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14226 cmd->action =
14227 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14228 cmd->vdev_id = vdev_id;
14229 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14230
14231 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14232 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14233
14234 err = wmi_unified_cmd_send(wmi_handle, buf,
14235 sizeof(*cmd),
14236 WMI_SET_MCASTBCAST_FILTER_CMDID);
14237 if (err) {
14238 WMI_LOGE("Failed to send set_param cmd");
14239 wmi_buf_free(buf);
14240 return QDF_STATUS_E_FAILURE;
14241 }
14242
14243 return QDF_STATUS_SUCCESS;
14244}
14245
14246/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014247 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14248 * command to fw
14249 * @wmi_handle: wmi handle
14250 * @vdev_id: vdev id
14251 * @mcast_filter_params: mcast filter params
14252 *
14253 * Return: QDF_STATUS_SUCCESS for success or error code
14254 */
14255static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14256 wmi_unified_t wmi_handle,
14257 uint8_t vdev_id,
14258 struct pmo_mcast_filter_params *filter_param)
14259
14260{
14261 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14262 uint8_t *buf_ptr;
14263 wmi_buf_t buf;
14264 int err;
14265 int i;
14266 uint8_t *mac_addr_src_ptr = NULL;
14267 wmi_mac_addr *mac_addr_dst_ptr;
14268 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14269 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14270
14271 buf = wmi_buf_alloc(wmi_handle, len);
14272 if (!buf) {
14273 WMI_LOGE("Failed to allocate memory");
14274 return QDF_STATUS_E_NOMEM;
14275 }
14276
Vivekc5823092018-03-22 23:27:21 +053014277 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014278 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14279 wmi_buf_data(buf);
14280 qdf_mem_zero(cmd, sizeof(*cmd));
14281
14282 WMITLV_SET_HDR(&cmd->tlv_header,
14283 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14284 WMITLV_GET_STRUCT_TLVLEN
14285 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14286 cmd->operation =
14287 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14288 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14289 cmd->vdev_id = vdev_id;
14290 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14291
14292 buf_ptr += sizeof(*cmd);
14293 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14294 sizeof(wmi_mac_addr) *
14295 filter_param->multicast_addr_cnt);
14296
14297 if (filter_param->multicast_addr_cnt == 0)
14298 goto send_cmd;
14299
14300 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14301 mac_addr_dst_ptr = (wmi_mac_addr *)
14302 (buf_ptr + WMI_TLV_HDR_SIZE);
14303
14304 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14305 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14306 mac_addr_src_ptr += ATH_MAC_LEN;
14307 mac_addr_dst_ptr++;
14308 }
14309
14310send_cmd:
14311 err = wmi_unified_cmd_send(wmi_handle, buf,
14312 len,
14313 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14314 if (err) {
14315 WMI_LOGE("Failed to send set_param cmd");
14316 wmi_buf_free(buf);
14317 return QDF_STATUS_E_FAILURE;
14318 }
14319
14320 return QDF_STATUS_SUCCESS;
14321}
14322
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014323static void
14324fill_fils_tlv_params(WMI_GTK_OFFLOAD_CMD_fixed_param *cmd,
14325 uint8_t vdev_id,
14326 struct pmo_gtk_req *params)
14327{
14328 uint8_t *buf_ptr;
14329 wmi_gtk_offload_fils_tlv_param *ext_param;
14330
14331 buf_ptr = (uint8_t *) cmd + sizeof(*cmd);
14332 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14333 sizeof(*ext_param));
14334 buf_ptr += WMI_TLV_HDR_SIZE;
14335
14336 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
14337 WMITLV_SET_HDR(&ext_param->tlv_header,
14338 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
14339 WMITLV_GET_STRUCT_TLVLEN(
14340 wmi_gtk_offload_fils_tlv_param));
14341 ext_param->vdev_id = vdev_id;
14342 ext_param->flags = cmd->flags;
14343 ext_param->kek_len = params->kek_len;
14344 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
14345 qdf_mem_copy(ext_param->KCK, params->kck,
14346 WMI_GTK_OFFLOAD_KCK_BYTES);
14347 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
14348 GTK_REPLAY_COUNTER_BYTES);
14349}
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014350
14351/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014352 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14353 * @wmi_handle: wmi handle
14354 * @vdev_id: vdev id
14355 * @params: GTK offload parameters
14356 *
14357 * Return: CDF status
14358 */
14359static
14360QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14361 struct pmo_gtk_req *params,
14362 bool enable_offload,
14363 uint32_t gtk_offload_opcode)
14364{
14365 int len;
14366 wmi_buf_t buf;
14367 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14368 QDF_STATUS status = QDF_STATUS_SUCCESS;
14369
14370 WMI_LOGD("%s Enter", __func__);
14371
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014372 len = sizeof(*cmd);
14373
14374 if (params->is_fils_connection)
14375 len += WMI_TLV_HDR_SIZE +
14376 sizeof(wmi_gtk_offload_fils_tlv_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014377
14378 /* alloc wmi buffer */
14379 buf = wmi_buf_alloc(wmi_handle, len);
14380 if (!buf) {
14381 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14382 status = QDF_STATUS_E_NOMEM;
14383 goto out;
14384 }
14385
14386 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14387 WMITLV_SET_HDR(&cmd->tlv_header,
14388 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14389 WMITLV_GET_STRUCT_TLVLEN
14390 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14391
14392 cmd->vdev_id = vdev_id;
14393
14394 /* Request target to enable GTK offload */
14395 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14396 cmd->flags = gtk_offload_opcode;
14397
14398 /* Copy the keys and replay counter */
14399 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014400 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014401 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14402 GTK_REPLAY_COUNTER_BYTES);
14403 } else {
14404 cmd->flags = gtk_offload_opcode;
14405 }
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014406 if (params->is_fils_connection)
14407 fill_fils_tlv_params(cmd, vdev_id, params);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014408
14409 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 +053014410 /* send the wmi command */
14411 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14412 WMI_GTK_OFFLOAD_CMDID)) {
14413 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
14414 wmi_buf_free(buf);
14415 status = QDF_STATUS_E_FAILURE;
14416 }
14417
14418out:
14419 WMI_LOGD("%s Exit", __func__);
14420 return status;
14421}
14422
14423/**
14424 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
14425 * @wmi_handle: wmi handle
14426 * @params: GTK offload params
14427 *
14428 * Return: CDF status
14429 */
14430static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
14431 wmi_unified_t wmi_handle,
14432 uint8_t vdev_id,
14433 uint64_t offload_req_opcode)
14434{
14435 int len;
14436 wmi_buf_t buf;
14437 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14438 QDF_STATUS status = QDF_STATUS_SUCCESS;
14439
14440 len = sizeof(*cmd);
14441
14442 /* alloc wmi buffer */
14443 buf = wmi_buf_alloc(wmi_handle, len);
14444 if (!buf) {
14445 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14446 status = QDF_STATUS_E_NOMEM;
14447 goto out;
14448 }
14449
14450 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14451 WMITLV_SET_HDR(&cmd->tlv_header,
14452 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14453 WMITLV_GET_STRUCT_TLVLEN
14454 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14455
14456 /* Request for GTK offload status */
14457 cmd->flags = offload_req_opcode;
14458 cmd->vdev_id = vdev_id;
14459
14460 /* send the wmi command */
14461 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14462 WMI_GTK_OFFLOAD_CMDID)) {
14463 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
14464 wmi_buf_free(buf);
14465 status = QDF_STATUS_E_FAILURE;
14466 }
14467
14468out:
14469 return status;
14470}
14471
14472/**
14473 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
14474 * @wmi_handle: wmi handler
14475 * @action_params: pointer to action_params
14476 *
14477 * Return: 0 for success, otherwise appropriate error code
14478 */
14479static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
14480 struct pmo_action_wakeup_set_params *action_params)
14481{
14482 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
14483 wmi_buf_t buf;
14484 int i;
14485 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014486 uint32_t len = 0, *cmd_args;
14487 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014488
Vivekc5823092018-03-22 23:27:21 +053014489 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014490 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
14491 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014492 if (!buf) {
14493 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
14494 return QDF_STATUS_E_NOMEM;
14495 }
14496 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014497 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014498 WMITLV_SET_HDR(&cmd->tlv_header,
14499 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
14500 WMITLV_GET_STRUCT_TLVLEN(
14501 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
14502
14503 cmd->vdev_id = action_params->vdev_id;
14504 cmd->operation = action_params->operation;
14505
14506 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
14507 cmd->action_category_map[i] =
14508 action_params->action_category_map[i];
14509
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014510 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
14511 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053014512 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014513 buf_ptr += WMI_TLV_HDR_SIZE;
14514 cmd_args = (uint32_t *) buf_ptr;
14515 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
14516 cmd_args[i] = action_params->action_per_category[i];
14517
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014518 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014519 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014520 if (err) {
14521 WMI_LOGE("Failed to send ap_ps_egap cmd");
14522 wmi_buf_free(buf);
14523 return QDF_STATUS_E_FAILURE;
14524 }
14525
14526 return QDF_STATUS_SUCCESS;
14527}
14528
14529#ifdef FEATURE_WLAN_LPHB
14530
14531/**
14532 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
14533 * @wmi_handle: wmi handle
14534 * @lphb_conf_req: configuration info
14535 *
14536 * Return: CDF status
14537 */
14538static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
14539 wmi_hb_set_enable_cmd_fixed_param *params)
14540{
14541 QDF_STATUS status;
14542 wmi_buf_t buf = NULL;
14543 uint8_t *buf_ptr;
14544 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
14545 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
14546
14547
14548 buf = wmi_buf_alloc(wmi_handle, len);
14549 if (!buf) {
14550 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14551 return QDF_STATUS_E_NOMEM;
14552 }
14553
14554 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14555 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
14556 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
14557 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
14558 WMITLV_GET_STRUCT_TLVLEN
14559 (wmi_hb_set_enable_cmd_fixed_param));
14560
14561 /* fill in values */
14562 hb_enable_fp->vdev_id = params->session;
14563 hb_enable_fp->enable = params->enable;
14564 hb_enable_fp->item = params->item;
14565 hb_enable_fp->session = params->session;
14566
14567 status = wmi_unified_cmd_send(wmi_handle, buf,
14568 len, WMI_HB_SET_ENABLE_CMDID);
14569 if (QDF_IS_STATUS_ERROR(status)) {
14570 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
14571 status);
14572 wmi_buf_free(buf);
14573 }
14574
14575 return status;
14576}
14577
14578/**
14579 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
14580 * @wmi_handle: wmi handle
14581 * @lphb_conf_req: lphb config request
14582 *
14583 * Return: CDF status
14584 */
14585static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
14586 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
14587{
14588 QDF_STATUS status;
14589 wmi_buf_t buf = NULL;
14590 uint8_t *buf_ptr;
14591 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
14592 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
14593
14594 buf = wmi_buf_alloc(wmi_handle, len);
14595 if (!buf) {
14596 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14597 return QDF_STATUS_E_NOMEM;
14598 }
14599
14600 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14601 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
14602 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
14603 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
14604 WMITLV_GET_STRUCT_TLVLEN
14605 (wmi_hb_set_tcp_params_cmd_fixed_param));
14606
14607 /* fill in values */
14608 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14609 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14610 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14611 hb_tcp_params_fp->seq = lphb_conf_req->seq;
14612 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
14613 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
14614 hb_tcp_params_fp->interval = lphb_conf_req->interval;
14615 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
14616 hb_tcp_params_fp->session = lphb_conf_req->session;
14617 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
14618 &lphb_conf_req->gateway_mac,
14619 sizeof(hb_tcp_params_fp->gateway_mac));
14620
14621 status = wmi_unified_cmd_send(wmi_handle, buf,
14622 len, WMI_HB_SET_TCP_PARAMS_CMDID);
14623 if (QDF_IS_STATUS_ERROR(status)) {
14624 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
14625 status);
14626 wmi_buf_free(buf);
14627 }
14628
14629 return status;
14630}
14631
14632/**
14633 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
14634 * @wmi_handle: wmi handle
14635 * @lphb_conf_req: lphb config request
14636 *
14637 * Return: CDF status
14638 */
14639static
14640QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14641 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
14642{
14643 QDF_STATUS status;
14644 wmi_buf_t buf = NULL;
14645 uint8_t *buf_ptr;
14646 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
14647 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
14648
14649 buf = wmi_buf_alloc(wmi_handle, len);
14650 if (!buf) {
14651 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14652 return QDF_STATUS_E_NOMEM;
14653 }
14654
14655 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14656 hb_tcp_filter_fp =
14657 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
14658 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
14659 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
14660 WMITLV_GET_STRUCT_TLVLEN
14661 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
14662
14663 /* fill in values */
14664 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
14665 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
14666 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
14667 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
14668 memcpy((void *)&hb_tcp_filter_fp->filter,
14669 (void *)&g_hb_tcp_filter_fp->filter,
14670 WMI_WLAN_HB_MAX_FILTER_SIZE);
14671
14672 status = wmi_unified_cmd_send(wmi_handle, buf,
14673 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
14674 if (QDF_IS_STATUS_ERROR(status)) {
14675 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
14676 status);
14677 wmi_buf_free(buf);
14678 }
14679
14680 return status;
14681}
14682
14683/**
14684 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
14685 * @wmi_handle: wmi handle
14686 * @lphb_conf_req: lphb config request
14687 *
14688 * Return: CDF status
14689 */
14690static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
14691 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
14692{
14693 QDF_STATUS status;
14694 wmi_buf_t buf = NULL;
14695 uint8_t *buf_ptr;
14696 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
14697 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
14698
14699 buf = wmi_buf_alloc(wmi_handle, len);
14700 if (!buf) {
14701 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14702 return QDF_STATUS_E_NOMEM;
14703 }
14704
14705 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14706 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
14707 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
14708 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
14709 WMITLV_GET_STRUCT_TLVLEN
14710 (wmi_hb_set_udp_params_cmd_fixed_param));
14711
14712 /* fill in values */
14713 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14714 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14715 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14716 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
14717 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
14718 hb_udp_params_fp->interval = lphb_conf_req->interval;
14719 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
14720 hb_udp_params_fp->session = lphb_conf_req->session;
14721 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
14722 &lphb_conf_req->gateway_mac,
14723 sizeof(lphb_conf_req->gateway_mac));
14724
14725 status = wmi_unified_cmd_send(wmi_handle, buf,
14726 len, WMI_HB_SET_UDP_PARAMS_CMDID);
14727 if (QDF_IS_STATUS_ERROR(status)) {
14728 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
14729 status);
14730 wmi_buf_free(buf);
14731 }
14732
14733 return status;
14734}
14735
14736/**
14737 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
14738 * @wmi_handle: wmi handle
14739 * @lphb_conf_req: lphb config request
14740 *
14741 * Return: CDF status
14742 */
14743static
14744QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14745 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
14746{
14747 QDF_STATUS status;
14748 wmi_buf_t buf = NULL;
14749 uint8_t *buf_ptr;
14750 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
14751 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
14752
14753 buf = wmi_buf_alloc(wmi_handle, len);
14754 if (!buf) {
14755 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14756 return QDF_STATUS_E_NOMEM;
14757 }
14758
14759 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14760 hb_udp_filter_fp =
14761 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
14762 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
14763 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
14764 WMITLV_GET_STRUCT_TLVLEN
14765 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
14766
14767 /* fill in values */
14768 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
14769 hb_udp_filter_fp->length = lphb_conf_req->length;
14770 hb_udp_filter_fp->offset = lphb_conf_req->offset;
14771 hb_udp_filter_fp->session = lphb_conf_req->session;
14772 memcpy((void *)&hb_udp_filter_fp->filter,
14773 (void *)&lphb_conf_req->filter,
14774 WMI_WLAN_HB_MAX_FILTER_SIZE);
14775
14776 status = wmi_unified_cmd_send(wmi_handle, buf,
14777 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
14778 if (QDF_IS_STATUS_ERROR(status)) {
14779 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
14780 status);
14781 wmi_buf_free(buf);
14782 }
14783
14784 return status;
14785}
14786#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014787
Dustin Brownf31f88b2017-05-12 14:01:44 -070014788static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
14789 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014790{
Dustin Brownf31f88b2017-05-12 14:01:44 -070014791 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014792 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070014793 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014794
Dustin Brownf31f88b2017-05-12 14:01:44 -070014795 if (!req) {
14796 WMI_LOGE("req is null");
14797 return QDF_STATUS_E_INVAL;
14798 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014799
Dustin Brownf31f88b2017-05-12 14:01:44 -070014800 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
14801 if (!wmi_buf) {
14802 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014803 return QDF_STATUS_E_NOMEM;
14804 }
14805
Dustin Brownf31f88b2017-05-12 14:01:44 -070014806 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014807 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070014808 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
14809 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
14810 cmd->vdev_id = req->vdev_id;
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014811 cmd->enable = req->enable;
14812 /* Set all modes in case of disable */
14813 if (!cmd->enable)
14814 cmd->hw_filter_bitmap = ((uint32_t)~0U);
14815 else
14816 cmd->hw_filter_bitmap = req->mode_bitmap;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014817
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014818 WMI_LOGD("Send %s hw filter mode: 0x%X for vdev id %d",
14819 req->enable ? "enable" : "disable", req->mode_bitmap,
14820 req->vdev_id);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014821
Dustin Brownf31f88b2017-05-12 14:01:44 -070014822 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
14823 WMI_HW_DATA_FILTER_CMDID);
14824 if (QDF_IS_STATUS_ERROR(status)) {
14825 WMI_LOGE("Failed to configure hw filter");
14826 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014827 }
14828
Dustin Brownf31f88b2017-05-12 14:01:44 -070014829 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014830}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053014831
14832/**
14833 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
14834 * @wmi_handle: wmi handle
14835 * @vdev_id: vdev id
14836 * @enable: Flag to enable/disable packet filter
14837 *
14838 * Return: QDF_STATUS_SUCCESS for success or error code
14839 */
14840static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
14841 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
14842{
14843 int32_t len;
14844 int ret = 0;
14845 wmi_buf_t buf;
14846 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
14847
14848 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
14849
14850 buf = wmi_buf_alloc(wmi_handle, len);
14851 if (!buf) {
14852 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14853 return QDF_STATUS_E_NOMEM;
14854 }
14855
14856 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
14857 WMITLV_SET_HDR(&cmd->tlv_header,
14858 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
14859 WMITLV_GET_STRUCT_TLVLEN(
14860 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
14861
14862 cmd->vdev_id = vdev_id;
14863 if (enable)
14864 cmd->enable = PACKET_FILTER_SET_ENABLE;
14865 else
14866 cmd->enable = PACKET_FILTER_SET_DISABLE;
14867
14868 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
14869 __func__, cmd->enable, vdev_id);
14870
14871 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14872 WMI_PACKET_FILTER_ENABLE_CMDID);
14873 if (ret) {
14874 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
14875 wmi_buf_free(buf);
14876 }
14877
14878 return ret;
14879}
14880
14881/**
14882 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
14883 * @wmi_handle: wmi handle
14884 * @vdev_id: vdev id
14885 * @rcv_filter_param: Packet filter parameters
14886 * @filter_id: Filter id
14887 * @enable: Flag to add/delete packet filter configuration
14888 *
14889 * Return: QDF_STATUS_SUCCESS for success or error code
14890 */
14891static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
14892 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
14893 uint8_t filter_id, bool enable)
14894{
14895 int len, i;
14896 int err = 0;
14897 wmi_buf_t buf;
14898 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
14899
14900
14901 /* allocate the memory */
14902 len = sizeof(*cmd);
14903 buf = wmi_buf_alloc(wmi_handle, len);
14904 if (!buf) {
14905 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14906 return QDF_STATUS_E_NOMEM;
14907 }
14908
14909 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
14910 WMITLV_SET_HDR(&cmd->tlv_header,
14911 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
14912 WMITLV_GET_STRUCT_TLVLEN
14913 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
14914
14915 cmd->vdev_id = vdev_id;
14916 cmd->filter_id = filter_id;
14917 if (enable)
14918 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
14919 else
14920 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
14921
14922 if (enable) {
14923 cmd->num_params = QDF_MIN(
14924 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
14925 rcv_filter_param->num_params);
14926 cmd->filter_type = rcv_filter_param->filter_type;
14927 cmd->coalesce_time = rcv_filter_param->coalesce_time;
14928
14929 for (i = 0; i < cmd->num_params; i++) {
14930 cmd->paramsData[i].proto_type =
14931 rcv_filter_param->params_data[i].protocol_layer;
14932 cmd->paramsData[i].cmp_type =
14933 rcv_filter_param->params_data[i].compare_flag;
14934 cmd->paramsData[i].data_length =
14935 rcv_filter_param->params_data[i].data_length;
14936 cmd->paramsData[i].data_offset =
14937 rcv_filter_param->params_data[i].data_offset;
14938 memcpy(&cmd->paramsData[i].compareData,
14939 rcv_filter_param->params_data[i].compare_data,
14940 sizeof(cmd->paramsData[i].compareData));
14941 memcpy(&cmd->paramsData[i].dataMask,
14942 rcv_filter_param->params_data[i].data_mask,
14943 sizeof(cmd->paramsData[i].dataMask));
14944 }
14945 }
14946
14947 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
14948 cmd->filter_action, cmd->filter_id, cmd->num_params);
14949 /* send the command along with data */
14950 err = wmi_unified_cmd_send(wmi_handle, buf, len,
14951 WMI_PACKET_FILTER_CONFIG_CMDID);
14952 if (err) {
14953 WMI_LOGE("Failed to send pkt_filter cmd");
14954 wmi_buf_free(buf);
14955 return QDF_STATUS_E_FAILURE;
14956 }
14957
14958 return QDF_STATUS_SUCCESS;
14959}
Wu Gao52c0b772018-05-17 16:14:00 +080014960#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014961
Govind Singha4836fd2016-03-07 16:45:38 +053014962/**
14963 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
14964 * @wmi_handle: wmi handle
14965 * @request: SSID hotlist set request
14966 *
Govind Singhb53420c2016-03-09 14:32:57 +053014967 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053014968 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014969static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053014970send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
14971 struct ssid_hotlist_request_params *request)
14972{
14973 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
14974 wmi_buf_t wmi_buf;
14975 uint32_t len;
14976 uint32_t array_size;
14977 uint8_t *buf_ptr;
14978
14979 /* length of fixed portion */
14980 len = sizeof(*cmd);
14981
14982 /* length of variable portion */
14983 array_size =
14984 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14985 len += WMI_TLV_HDR_SIZE + array_size;
14986
14987 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14988 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014989 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14990 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014991 }
14992
14993 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14994 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14995 buf_ptr;
14996 WMITLV_SET_HDR
14997 (&cmd->tlv_header,
14998 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
14999 WMITLV_GET_STRUCT_TLVLEN
15000 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15001
15002 cmd->request_id = request->request_id;
15003 cmd->requestor_id = 0;
15004 cmd->vdev_id = request->session_id;
15005 cmd->table_id = 0;
15006 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15007 cmd->total_entries = request->ssid_count;
15008 cmd->num_entries_in_page = request->ssid_count;
15009 cmd->first_entry_index = 0;
15010
15011 buf_ptr += sizeof(*cmd);
15012 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15013
15014 if (request->ssid_count) {
15015 wmi_extscan_hotlist_ssid_entry *entry;
15016 int i;
15017
15018 buf_ptr += WMI_TLV_HDR_SIZE;
15019 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15020 for (i = 0; i < request->ssid_count; i++) {
15021 WMITLV_SET_HDR
15022 (entry,
15023 WMITLV_TAG_ARRAY_STRUC,
15024 WMITLV_GET_STRUCT_TLVLEN
15025 (wmi_extscan_hotlist_ssid_entry));
15026 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015027 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015028 request->ssids[i].ssid.mac_ssid,
15029 request->ssids[i].ssid.length);
15030 entry->band = request->ssids[i].band;
15031 entry->min_rssi = request->ssids[i].rssi_low;
15032 entry->max_rssi = request->ssids[i].rssi_high;
15033 entry++;
15034 }
15035 cmd->mode = WMI_EXTSCAN_MODE_START;
15036 } else {
15037 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15038 }
15039
15040 if (wmi_unified_cmd_send
15041 (wmi_handle, wmi_buf, len,
15042 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015043 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015044 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015045 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015046 }
15047
Govind Singhb53420c2016-03-09 14:32:57 +053015048 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015049}
15050
15051/**
15052 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15053 * @wmi_handle: wmi handle
15054 * @vdev_id: vdev id
15055 *
15056 * This function sends roam synch complete event to fw.
15057 *
15058 * Return: CDF STATUS
15059 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015060static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015061 uint8_t vdev_id)
15062{
15063 wmi_roam_synch_complete_fixed_param *cmd;
15064 wmi_buf_t wmi_buf;
15065 uint8_t *buf_ptr;
15066 uint16_t len;
15067 len = sizeof(wmi_roam_synch_complete_fixed_param);
15068
15069 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15070 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015071 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15072 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015073 }
15074 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15075 buf_ptr = (uint8_t *) cmd;
15076 WMITLV_SET_HDR(&cmd->tlv_header,
15077 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15078 WMITLV_GET_STRUCT_TLVLEN
15079 (wmi_roam_synch_complete_fixed_param));
15080 cmd->vdev_id = vdev_id;
15081 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15082 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015083 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015084 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015085 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015086 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015087 }
15088
Govind Singhb53420c2016-03-09 14:32:57 +053015089 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015090}
15091
15092/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015093 * send_fw_test_cmd_tlv() - send fw test command to fw.
15094 * @wmi_handle: wmi handle
15095 * @wmi_fwtest: fw test command
15096 *
15097 * This function sends fw test command to fw.
15098 *
15099 * Return: CDF STATUS
15100 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015101static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015102QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15103 struct set_fwtest_params *wmi_fwtest)
15104{
15105 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15106 wmi_buf_t wmi_buf;
15107 uint16_t len;
15108
15109 len = sizeof(*cmd);
15110
15111 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15112 if (!wmi_buf) {
15113 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15114 return QDF_STATUS_E_NOMEM;
15115 }
15116
15117 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15118 WMITLV_SET_HDR(&cmd->tlv_header,
15119 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15120 WMITLV_GET_STRUCT_TLVLEN(
15121 wmi_fwtest_set_param_cmd_fixed_param));
15122 cmd->param_id = wmi_fwtest->arg;
15123 cmd->param_value = wmi_fwtest->value;
15124
15125 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15126 WMI_FWTEST_CMDID)) {
15127 WMI_LOGP("%s: failed to send fw test command", __func__);
15128 qdf_nbuf_free(wmi_buf);
15129 return QDF_STATUS_E_FAILURE;
15130 }
15131
15132 return QDF_STATUS_SUCCESS;
15133}
15134
15135/**
Govind Singha4836fd2016-03-07 16:45:38 +053015136 * send_unit_test_cmd_tlv() - send unit test command to fw.
15137 * @wmi_handle: wmi handle
15138 * @wmi_utest: unit test command
15139 *
15140 * This function send unit test command to fw.
15141 *
15142 * Return: CDF STATUS
15143 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015144static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015145 struct wmi_unit_test_cmd *wmi_utest)
15146{
15147 wmi_unit_test_cmd_fixed_param *cmd;
15148 wmi_buf_t wmi_buf;
15149 uint8_t *buf_ptr;
15150 int i;
15151 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015152 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015153
15154 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015155 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015156 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15157
15158 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15159 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015160 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15161 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015162 }
15163
15164 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15165 buf_ptr = (uint8_t *) cmd;
15166 WMITLV_SET_HDR(&cmd->tlv_header,
15167 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15168 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15169 cmd->vdev_id = wmi_utest->vdev_id;
15170 cmd->module_id = wmi_utest->module_id;
15171 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015172 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015173 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15174 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15175 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015176 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015177 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15178 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15179 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015180 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015181 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015182 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015183 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015184 }
15185 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15186 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015187 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015188 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015189 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015190 }
15191
Govind Singhb53420c2016-03-09 14:32:57 +053015192 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015193}
15194
15195/**
15196 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15197 * @wmi_handle: wma handle
15198 * @roaminvoke: roam invoke command
15199 *
15200 * Send roam invoke command to fw for fastreassoc.
15201 *
15202 * Return: CDF STATUS
15203 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015204static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015205 struct wmi_roam_invoke_cmd *roaminvoke,
15206 uint32_t ch_hz)
15207{
15208 wmi_roam_invoke_cmd_fixed_param *cmd;
15209 wmi_buf_t wmi_buf;
15210 u_int8_t *buf_ptr;
15211 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015212 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015213 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015214 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015215
15216 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015217 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015218 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15219 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015220 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15221 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15222 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015223 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15224 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015225 }
15226
15227 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15228 buf_ptr = (u_int8_t *) cmd;
15229 WMITLV_SET_HDR(&cmd->tlv_header,
15230 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15231 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15232 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015233 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015234 if (roaminvoke->is_same_bssid)
15235 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15236 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015237
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015238 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015239 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015240 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15241 cmd->num_buf = 1;
15242 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015243 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015244 cmd->num_buf = 0;
15245 }
Naveen Rawat77797922017-01-20 17:00:07 -080015246
Govind Singha4836fd2016-03-07 16:45:38 +053015247 cmd->roam_ap_sel_mode = 0;
15248 cmd->roam_delay = 0;
15249 cmd->num_chan = 1;
15250 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015251
Govind Singha4836fd2016-03-07 16:45:38 +053015252 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15253 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15254 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015255 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015256 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015257 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015258 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15259 (sizeof(wmi_mac_addr)));
15260 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15261 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015262
15263 /* move to next tlv i.e. bcn_prb_buf_list */
15264 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15265
15266 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15267 sizeof(wmi_tlv_buf_len_param));
15268
15269 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15270 buf_len_tlv->buf_len = roaminvoke->frame_len;
15271
15272 /* move to next tlv i.e. bcn_prb_frm */
15273 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15274 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15275 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15276
15277 /* copy frame after the header */
15278 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15279 roaminvoke->frame_buf,
15280 roaminvoke->frame_len);
15281
15282 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070015283 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat77797922017-01-20 17:00:07 -080015284 buf_ptr + WMI_TLV_HDR_SIZE,
15285 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015286 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15287 cmd->flags, cmd->roam_scan_mode,
15288 cmd->roam_ap_sel_mode, cmd->roam_delay,
15289 cmd->num_chan, cmd->num_bssid);
15290 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015291
Govind Singha4836fd2016-03-07 16:45:38 +053015292 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15293 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015294 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015295 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015296 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015297 }
15298
Govind Singhb53420c2016-03-09 14:32:57 +053015299 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015300}
15301
15302/**
15303 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15304 * @wmi_handle: wmi handle
15305 * @command: command
15306 * @vdev_id: vdev id
15307 *
15308 * This function set roam offload command to fw.
15309 *
15310 * Return: CDF status
15311 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015312static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015313 uint32_t command, uint32_t vdev_id)
15314{
Govind Singh67922e82016-04-01 16:48:57 +053015315 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015316 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15317 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015318 int len;
15319 uint8_t *buf_ptr;
15320
15321 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15322 buf = wmi_buf_alloc(wmi_handle, len);
15323 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015324 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15325 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015326 }
15327
15328 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15329
15330 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15331 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15332 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15333 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15334 cmd_fp->vdev_id = vdev_id;
15335 cmd_fp->command_arg = command;
15336
15337 status = wmi_unified_cmd_send(wmi_handle, buf,
15338 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015339 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015340 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015341 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015342 goto error;
15343 }
15344
Govind Singhb53420c2016-03-09 14:32:57 +053015345 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15346 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015347
15348error:
15349 wmi_buf_free(buf);
15350
Govind Singh67922e82016-04-01 16:48:57 +053015351 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015352}
15353
15354/**
15355 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15356 * @wmi_handle: wmi handle
15357 * @ap_profile_p: ap profile
15358 * @vdev_id: vdev id
15359 *
15360 * Send WMI_ROAM_AP_PROFILE to firmware
15361 *
15362 * Return: CDF status
15363 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015364static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015365 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015366{
Govind Singha4836fd2016-03-07 16:45:38 +053015367 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015368 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015369 int len;
15370 uint8_t *buf_ptr;
15371 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015372 wmi_roam_cnd_scoring_param *score_param;
15373 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015374
15375 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015376 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015377 buf = wmi_buf_alloc(wmi_handle, len);
15378 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015379 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15380 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015381 }
15382
15383 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15384 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15385 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15386 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15387 WMITLV_GET_STRUCT_TLVLEN
15388 (wmi_roam_ap_profile_fixed_param));
15389 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015390 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015391 roam_ap_profile_fp->id = 0;
15392 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15393
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015394 profile = (wmi_ap_profile *)buf_ptr;
15395 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015396 WMITLV_TAG_STRUC_wmi_ap_profile,
15397 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015398 profile->flags = ap_profile->profile.flags;
15399 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15400 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15401 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15402 profile->ssid.ssid_len);
15403 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15404 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15405 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15406 profile->rsn_mcastmgmtcipherset =
15407 ap_profile->profile.rsn_mcastmgmtcipherset;
15408 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15409
15410 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",
15411 profile->flags, profile->rssi_threshold,
15412 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15413 profile->rsn_authmode, profile->rsn_ucastcipherset,
15414 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15415 profile->rssi_abs_thresh);
15416
15417 buf_ptr += sizeof(wmi_ap_profile);
15418
15419 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15420 WMITLV_SET_HDR(&score_param->tlv_header,
15421 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15422 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15423 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15424 score_param->rssi_weightage_pcnt =
15425 ap_profile->param.rssi_weightage;
15426 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15427 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15428 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15429 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15430 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15431 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15432 score_param->esp_qbss_weightage_pcnt =
15433 ap_profile->param.esp_qbss_weightage;
15434 score_param->beamforming_weightage_pcnt =
15435 ap_profile->param.beamforming_weightage;
15436 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15437 score_param->oce_wan_weightage_pcnt =
15438 ap_profile->param.oce_wan_weightage;
15439
15440 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",
15441 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15442 score_param->ht_weightage_pcnt,
15443 score_param->vht_weightage_pcnt,
15444 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15445 score_param->band_weightage_pcnt,
15446 score_param->nss_weightage_pcnt,
15447 score_param->esp_qbss_weightage_pcnt,
15448 score_param->beamforming_weightage_pcnt,
15449 score_param->pcl_weightage_pcnt,
15450 score_param->oce_wan_weightage_pcnt);
15451
15452 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15453 score_param->band_scoring.score_pcnt =
15454 ap_profile->param.band_index_score;
15455 score_param->nss_scoring.score_pcnt =
15456 ap_profile->param.nss_index_score;
15457
15458 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15459 score_param->bw_scoring.score_pcnt,
15460 score_param->band_scoring.score_pcnt,
15461 score_param->nss_scoring.score_pcnt);
15462
15463 score_param->rssi_scoring.best_rssi_threshold =
15464 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15465 score_param->rssi_scoring.good_rssi_threshold =
15466 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15467 score_param->rssi_scoring.bad_rssi_threshold =
15468 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15469 score_param->rssi_scoring.good_rssi_pcnt =
15470 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15471 score_param->rssi_scoring.bad_rssi_pcnt =
15472 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15473 score_param->rssi_scoring.good_bucket_size =
15474 ap_profile->param.rssi_scoring.good_bucket_size;
15475 score_param->rssi_scoring.bad_bucket_size =
15476 ap_profile->param.rssi_scoring.bad_bucket_size;
15477 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15478 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15479
15480 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15481 score_param->rssi_scoring.best_rssi_threshold,
15482 score_param->rssi_scoring.good_rssi_threshold,
15483 score_param->rssi_scoring.bad_rssi_threshold,
15484 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15485 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15486 score_param->rssi_scoring.good_rssi_pcnt,
15487 score_param->rssi_scoring.bad_rssi_pcnt,
15488 score_param->rssi_scoring.good_bucket_size,
15489 score_param->rssi_scoring.bad_bucket_size);
15490
15491 score_param->esp_qbss_scoring.num_slot =
15492 ap_profile->param.esp_qbss_scoring.num_slot;
15493 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15494 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15495 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15496 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15497 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15498 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15499 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15500 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15501
15502 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15503 score_param->esp_qbss_scoring.num_slot,
15504 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15505 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15506 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15507 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15508
15509 score_param->oce_wan_scoring.num_slot =
15510 ap_profile->param.oce_wan_scoring.num_slot;
15511 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15512 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15513 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15514 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15515 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15516 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15517 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15518 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15519
15520 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15521 score_param->oce_wan_scoring.num_slot,
15522 score_param->oce_wan_scoring.score_pcnt3_to_0,
15523 score_param->oce_wan_scoring.score_pcnt7_to_4,
15524 score_param->oce_wan_scoring.score_pcnt11_to_8,
15525 score_param->oce_wan_scoring.score_pcnt15_to_12);
15526
Govind Singha4836fd2016-03-07 16:45:38 +053015527 status = wmi_unified_cmd_send(wmi_handle, buf,
15528 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015529 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015530 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015531 status);
Govind Singh67922e82016-04-01 16:48:57 +053015532 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015533 }
15534
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +053015535 WMI_LOGD("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015536
Govind Singh67922e82016-04-01 16:48:57 +053015537 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015538}
15539
15540/**
15541 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15542 * @wmi_handle: wmi handle
15543 * @scan_period: scan period
15544 * @scan_age: scan age
15545 * @vdev_id: vdev id
15546 *
15547 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15548 *
15549 * Return: CDF status
15550 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015551static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015552 uint32_t scan_period,
15553 uint32_t scan_age,
15554 uint32_t vdev_id)
15555{
Govind Singh67922e82016-04-01 16:48:57 +053015556 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015557 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015558 int len;
15559 uint8_t *buf_ptr;
15560 wmi_roam_scan_period_fixed_param *scan_period_fp;
15561
15562 /* Send scan period values */
15563 len = sizeof(wmi_roam_scan_period_fixed_param);
15564 buf = wmi_buf_alloc(wmi_handle, len);
15565 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015566 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15567 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015568 }
15569
15570 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15571 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15572 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15573 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15574 WMITLV_GET_STRUCT_TLVLEN
15575 (wmi_roam_scan_period_fixed_param));
15576 /* fill in scan period values */
15577 scan_period_fp->vdev_id = vdev_id;
15578 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15579 scan_period_fp->roam_scan_age = scan_age;
15580
15581 status = wmi_unified_cmd_send(wmi_handle, buf,
15582 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015583 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015584 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015585 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015586 goto error;
15587 }
15588
Govind Singhb53420c2016-03-09 14:32:57 +053015589 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015590 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015591 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015592error:
15593 wmi_buf_free(buf);
15594
Govind Singh67922e82016-04-01 16:48:57 +053015595 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015596}
15597
15598/**
15599 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15600 * @wmi_handle: wmi handle
15601 * @chan_count: channel count
15602 * @chan_list: channel list
15603 * @list_type: list type
15604 * @vdev_id: vdev id
15605 *
15606 * Set roam offload channel list.
15607 *
15608 * Return: CDF status
15609 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015610static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015611 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015612 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015613 uint8_t list_type, uint32_t vdev_id)
15614{
Govind Singha4836fd2016-03-07 16:45:38 +053015615 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015616 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015617 int len, list_tlv_len;
15618 int i;
15619 uint8_t *buf_ptr;
15620 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053015621 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053015622
15623 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053015624 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053015625 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053015626 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053015627 }
15628 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053015629 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015630 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
15631 buf = wmi_buf_alloc(wmi_handle, len);
15632 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015633 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15634 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015635 }
15636
15637 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15638 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
15639 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
15640 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
15641 WMITLV_GET_STRUCT_TLVLEN
15642 (wmi_roam_chan_list_fixed_param));
15643 chan_list_fp->vdev_id = vdev_id;
15644 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053015645 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053015646 /* external app is controlling channel list */
15647 chan_list_fp->chan_list_type =
15648 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
15649 } else {
15650 /* umac supplied occupied channel list in LFR */
15651 chan_list_fp->chan_list_type =
15652 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
15653 }
15654
15655 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
15656 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15657 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015658 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015659 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053015660 for (i = 0; ((i < chan_list_fp->num_chan) &&
15661 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
15662 roam_chan_list_array[i] = chan_list[i];
Sandeep Puligilla412b36f2018-07-02 11:43:07 -070015663 WMI_LOGD("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015664 }
15665
15666 status = wmi_unified_cmd_send(wmi_handle, buf,
15667 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053015668 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015669 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015670 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015671 goto error;
15672 }
15673
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015674 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053015675 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015676error:
15677 wmi_buf_free(buf);
15678
Govind Singh67922e82016-04-01 16:48:57 +053015679 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015680}
15681
15682/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015683 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
15684 * @wmi_handle: wmi handle
15685 * @req_buf: per roam config buffer
15686 *
15687 * Return: QDF status
15688 */
15689static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
15690 struct wmi_per_roam_config_req *req_buf)
15691{
15692 wmi_buf_t buf = NULL;
15693 QDF_STATUS status;
15694 int len;
15695 uint8_t *buf_ptr;
15696 wmi_roam_per_config_fixed_param *wmi_per_config;
15697
15698 len = sizeof(wmi_roam_per_config_fixed_param);
15699 buf = wmi_buf_alloc(wmi_handle, len);
15700 if (!buf) {
15701 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15702 return QDF_STATUS_E_NOMEM;
15703 }
15704
15705 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15706 wmi_per_config =
15707 (wmi_roam_per_config_fixed_param *) buf_ptr;
15708 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
15709 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
15710 WMITLV_GET_STRUCT_TLVLEN
15711 (wmi_roam_per_config_fixed_param));
15712
15713 /* fill in per roam config values */
15714 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015715
15716 wmi_per_config->enable = req_buf->per_config.enable;
15717 wmi_per_config->high_rate_thresh =
15718 (req_buf->per_config.tx_high_rate_thresh << 16) |
15719 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
15720 wmi_per_config->low_rate_thresh =
15721 (req_buf->per_config.tx_low_rate_thresh << 16) |
15722 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
15723 wmi_per_config->pkt_err_rate_thresh_pct =
15724 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
15725 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
15726 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053015727 wmi_per_config->pkt_err_rate_mon_time =
15728 (req_buf->per_config.tx_per_mon_time << 16) |
15729 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053015730 wmi_per_config->min_candidate_rssi =
15731 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015732
15733 /* Send per roam config parameters */
15734 status = wmi_unified_cmd_send(wmi_handle, buf,
15735 len, WMI_ROAM_PER_CONFIG_CMDID);
15736 if (QDF_IS_STATUS_ERROR(status)) {
15737 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
Sandeep Puligilla3dd74122018-08-18 12:42:41 -070015738 status);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015739 wmi_buf_free(buf);
15740 return status;
15741 }
Sandeep Puligilla3dd74122018-08-18 12:42:41 -070015742 WMI_LOGD(FL("per roam enable=%d, vdev=%d"),
15743 req_buf->per_config.enable, req_buf->vdev_id);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015744
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015745 return QDF_STATUS_SUCCESS;
15746}
15747
15748/**
Govind Singha4836fd2016-03-07 16:45:38 +053015749 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
15750 * @wmi_handle: wmi handle
15751 * @rssi_change_thresh: RSSI Change threshold
15752 * @bcn_rssi_weight: beacon RSSI weight
15753 * @vdev_id: vdev id
15754 *
15755 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
15756 *
15757 * Return: CDF status
15758 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015759static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015760 uint32_t vdev_id,
15761 int32_t rssi_change_thresh,
15762 uint32_t bcn_rssi_weight,
15763 uint32_t hirssi_delay_btw_scans)
15764{
Govind Singha4836fd2016-03-07 16:45:38 +053015765 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015766 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015767 int len;
15768 uint8_t *buf_ptr;
15769 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
15770
15771 /* Send rssi change parameters */
15772 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
15773 buf = wmi_buf_alloc(wmi_handle, len);
15774 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015775 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15776 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015777 }
15778
15779 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15780 rssi_change_fp =
15781 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
15782 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
15783 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
15784 WMITLV_GET_STRUCT_TLVLEN
15785 (wmi_roam_scan_rssi_change_threshold_fixed_param));
15786 /* fill in rssi change threshold (hysteresis) values */
15787 rssi_change_fp->vdev_id = vdev_id;
15788 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
15789 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
15790 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
15791
15792 status = wmi_unified_cmd_send(wmi_handle, buf,
15793 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053015794 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015795 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015796 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015797 goto error;
15798 }
15799
Sandeep Puligilla3dd74122018-08-18 12:42:41 -070015800 WMI_LOGD(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
15801 rssi_change_thresh, bcn_rssi_weight);
15802 WMI_LOGD(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
Govind Singhb53420c2016-03-09 14:32:57 +053015803 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015804error:
15805 wmi_buf_free(buf);
15806
Govind Singh67922e82016-04-01 16:48:57 +053015807 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015808}
15809
Govind Singhbca3b1b2016-05-02 17:59:24 +053015810/**
15811 * send_power_dbg_cmd_tlv() - send power debug commands
15812 * @wmi_handle: wmi handle
15813 * @param: wmi power debug parameter
15814 *
15815 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
15816 *
15817 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15818 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015819static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
15820 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053015821{
15822 wmi_buf_t buf = NULL;
15823 QDF_STATUS status;
15824 int len, args_tlv_len;
15825 uint8_t *buf_ptr;
15826 uint8_t i;
15827 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
15828 uint32_t *cmd_args;
15829
15830 /* Prepare and send power debug cmd parameters */
15831 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
15832 len = sizeof(*cmd) + args_tlv_len;
15833 buf = wmi_buf_alloc(wmi_handle, len);
15834 if (!buf) {
15835 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15836 return QDF_STATUS_E_NOMEM;
15837 }
15838
15839 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15840 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
15841 WMITLV_SET_HDR(&cmd->tlv_header,
15842 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
15843 WMITLV_GET_STRUCT_TLVLEN
15844 (wmi_pdev_wal_power_debug_cmd_fixed_param));
15845
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015846 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15847 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053015848 cmd->module_id = param->module_id;
15849 cmd->num_args = param->num_args;
15850 buf_ptr += sizeof(*cmd);
15851 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15852 (param->num_args * sizeof(uint32_t)));
15853 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
15854 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080015855 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053015856 cmd_args[i] = param->args[i];
15857 WMI_LOGI("%d,", param->args[i]);
15858 }
15859
15860 status = wmi_unified_cmd_send(wmi_handle, buf,
15861 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
15862 if (QDF_IS_STATUS_ERROR(status)) {
15863 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
15864 status);
15865 goto error;
15866 }
15867
15868 return QDF_STATUS_SUCCESS;
15869error:
15870 wmi_buf_free(buf);
15871
15872 return status;
15873}
15874
Govind Singhe7f2f342016-05-23 12:12:52 +053015875/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015876 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15877 * @wmi_handle: wmi handle
15878 * @param: wmi multiple vdev restart req param
15879 *
15880 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15881 *
15882 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15883 */
15884static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15885 wmi_unified_t wmi_handle,
15886 struct multiple_vdev_restart_params *param)
15887{
15888 wmi_buf_t buf;
15889 QDF_STATUS qdf_status;
15890 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15891 int i;
15892 uint8_t *buf_ptr;
15893 uint32_t *vdev_ids;
15894 wmi_channel *chan_info;
15895 struct channel_param *tchan_info;
15896 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15897
15898 len += sizeof(wmi_channel);
15899 if (param->num_vdevs)
15900 len += sizeof(uint32_t) * param->num_vdevs;
15901
15902 buf = wmi_buf_alloc(wmi_handle, len);
15903 if (!buf) {
15904 WMI_LOGE("Failed to allocate memory\n");
15905 qdf_status = QDF_STATUS_E_NOMEM;
15906 goto end;
15907 }
15908
15909 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15910 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15911 buf_ptr;
15912
15913 WMITLV_SET_HDR(&cmd->tlv_header,
15914 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15915 WMITLV_GET_STRUCT_TLVLEN
15916 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015917 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15918 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015919 cmd->requestor_id = param->requestor_id;
15920 cmd->disable_hw_ack = param->disable_hw_ack;
15921 cmd->cac_duration_ms = param->cac_duration_ms;
15922 cmd->num_vdevs = param->num_vdevs;
15923
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015924 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
15925 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
15926 " cmd->num_vdevs: %d ",
15927 __func__, cmd->pdev_id, cmd->requestor_id,
15928 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015929 buf_ptr += sizeof(*cmd);
15930
15931 WMITLV_SET_HDR(buf_ptr,
15932 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015933 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015934 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15935 for (i = 0; i < param->num_vdevs; i++) {
15936 vdev_ids[i] = param->vdev_ids[i];
15937 }
15938
Vivekc5823092018-03-22 23:27:21 +053015939 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015940
15941 WMITLV_SET_HDR(buf_ptr,
15942 WMITLV_TAG_STRUC_wmi_channel,
15943 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015944 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015945 tchan_info = &(param->ch_param);
15946 chan_info->mhz = tchan_info->mhz;
15947 chan_info->band_center_freq1 = tchan_info->cfreq1;
15948 chan_info->band_center_freq2 = tchan_info->cfreq2;
15949 if (tchan_info->is_chan_passive)
15950 WMI_SET_CHANNEL_FLAG(chan_info,
15951 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015952 if (tchan_info->dfs_set)
15953 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
15954
Sathish Kumar45e991b2017-02-27 10:35:40 +053015955 if (tchan_info->allow_vht)
15956 WMI_SET_CHANNEL_FLAG(chan_info,
15957 WMI_CHAN_FLAG_ALLOW_VHT);
15958 else if (tchan_info->allow_ht)
15959 WMI_SET_CHANNEL_FLAG(chan_info,
15960 WMI_CHAN_FLAG_ALLOW_HT);
15961 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15962 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15963 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15964 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15965 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15966 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080015967 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015968
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015969 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
15970 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
15971 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
15972 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
15973 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
15974 "tchan_info->reg_class_id: %d ,"
15975 "tchan_info->maxregpower : %d ", __func__,
15976 tchan_info->is_chan_passive, tchan_info->dfs_set,
15977 tchan_info->allow_vht, tchan_info->allow_ht,
15978 tchan_info->antennamax, tchan_info->phy_mode,
15979 tchan_info->minpower, tchan_info->maxpower,
15980 tchan_info->maxregpower, tchan_info->reg_class_id,
15981 tchan_info->maxregpower);
15982
Sathish Kumar45e991b2017-02-27 10:35:40 +053015983 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15984 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15985
15986 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15987 WMI_LOGE("%s: Failed to send\n", __func__);
15988 wmi_buf_free(buf);
15989 }
15990
15991end:
15992 return qdf_status;
15993}
15994
15995/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015996 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15997 * @wmi_handle: wmi handle
15998 * @pdev_id: pdev id
15999 *
16000 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16001 *
16002 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16003 */
16004static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16005 uint32_t pdev_id)
16006{
16007 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16008 wmi_buf_t buf;
16009 uint16_t len;
16010 QDF_STATUS ret;
16011
16012 len = sizeof(*cmd);
16013 buf = wmi_buf_alloc(wmi_handle, len);
16014
16015 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16016
16017 if (!buf) {
16018 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16019 return QDF_STATUS_E_NOMEM;
16020 }
16021
16022 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16023 wmi_buf_data(buf);
16024
16025 WMITLV_SET_HDR(&cmd->tlv_header,
16026 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16027 WMITLV_GET_STRUCT_TLVLEN(
16028 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16029
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016030 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016031 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16032 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16033 if (QDF_IS_STATUS_ERROR(ret)) {
16034 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16035 __func__, ret, pdev_id);
16036 wmi_buf_free(buf);
16037 return QDF_STATUS_E_FAILURE;
16038 }
16039
16040 return QDF_STATUS_SUCCESS;
16041}
16042
16043/**
16044 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16045 * @wmi_handle: wmi handle
16046 * @pdev_id: pdev id
16047 *
16048 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16049 *
16050 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16051 */
16052static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16053 uint32_t pdev_id)
16054{
16055 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16056 wmi_buf_t buf;
16057 uint16_t len;
16058 QDF_STATUS ret;
16059
16060 len = sizeof(*cmd);
16061 buf = wmi_buf_alloc(wmi_handle, len);
16062
16063 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16064
16065 if (!buf) {
16066 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16067 return QDF_STATUS_E_NOMEM;
16068 }
16069
16070 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16071 wmi_buf_data(buf);
16072
16073 WMITLV_SET_HDR(&cmd->tlv_header,
16074 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16075 WMITLV_GET_STRUCT_TLVLEN(
16076 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16077
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016078 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016079 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16080 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16081 if (QDF_IS_STATUS_ERROR(ret)) {
16082 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16083 __func__, ret, pdev_id);
16084 wmi_buf_free(buf);
16085 return QDF_STATUS_E_FAILURE;
16086 }
16087
16088 return QDF_STATUS_SUCCESS;
16089}
16090
16091/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016092 * init_cmd_send_tlv() - send initialization cmd to fw
16093 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016094 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016095 *
16096 * Return: QDF_STATUS_SUCCESS for success or error code
16097 */
16098static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016099 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016100{
16101 wmi_buf_t buf;
16102 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016103 uint8_t *buf_ptr;
16104 wmi_resource_config *resource_cfg;
16105 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016106 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016107 uint16_t idx;
16108 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016109 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016110
Kiran Venkatappa26117052016-12-23 19:58:54 +053016111 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16112 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016113 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016114
16115 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16116 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16117 WMI_TLV_HDR_SIZE +
16118 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16119
16120 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016121 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053016122 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053016123 return QDF_STATUS_E_FAILURE;
16124 }
16125
16126 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16127 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16128 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16129
16130 host_mem_chunks = (wlan_host_memory_chunk *)
16131 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16132 + WMI_TLV_HDR_SIZE);
16133
16134 WMITLV_SET_HDR(&cmd->tlv_header,
16135 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16136 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16137
Kiran Venkatappa26117052016-12-23 19:58:54 +053016138 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016139 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16140 WMITLV_TAG_STRUC_wmi_resource_config,
16141 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16142
Kiran Venkatappa26117052016-12-23 19:58:54 +053016143 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016144 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16145 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16146 WMITLV_GET_STRUCT_TLVLEN
16147 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016148 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16149 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16150 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016151 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16152 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016153 idx, host_mem_chunks[idx].size,
16154 host_mem_chunks[idx].ptr);
16155 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016156 cmd->num_host_mem_chunks = param->num_mem_chunks;
16157 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16158
Govind Singhe7f2f342016-05-23 12:12:52 +053016159 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16160 WMITLV_TAG_ARRAY_STRUC,
16161 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016162 param->num_mem_chunks));
16163
16164 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016165 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016166
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016167 /* Fill fw_abi_vers */
16168 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016169
Abhishek Singh716c46c2016-05-04 16:24:07 +053016170 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16171 if (QDF_IS_STATUS_ERROR(ret)) {
16172 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16173 ret);
16174 wmi_buf_free(buf);
16175 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016176
Abhishek Singh716c46c2016-05-04 16:24:07 +053016177 return ret;
16178
Govind Singhe7f2f342016-05-23 12:12:52 +053016179}
16180
16181/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016182 * send_addba_send_cmd_tlv() - send addba send command to fw
16183 * @wmi_handle: wmi handle
16184 * @param: pointer to delba send params
16185 * @macaddr: peer mac address
16186 *
16187 * Send WMI_ADDBA_SEND_CMDID command to firmware
16188 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16189 */
16190static QDF_STATUS
16191send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
16192 uint8_t macaddr[IEEE80211_ADDR_LEN],
16193 struct addba_send_params *param)
16194{
16195 wmi_addba_send_cmd_fixed_param *cmd;
16196 wmi_buf_t buf;
16197 uint16_t len;
16198 QDF_STATUS ret;
16199
16200 len = sizeof(*cmd);
16201
16202 buf = wmi_buf_alloc(wmi_handle, len);
16203 if (!buf) {
16204 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16205 return QDF_STATUS_E_NOMEM;
16206 }
16207
16208 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
16209
16210 WMITLV_SET_HDR(&cmd->tlv_header,
16211 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
16212 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
16213
16214 cmd->vdev_id = param->vdev_id;
16215 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16216 cmd->tid = param->tidno;
16217 cmd->buffersize = param->buffersize;
16218
16219 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
16220 if (QDF_IS_STATUS_ERROR(ret)) {
16221 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16222 wmi_buf_free(buf);
16223 return QDF_STATUS_E_FAILURE;
16224 }
16225
16226 return QDF_STATUS_SUCCESS;
16227}
16228
16229/**
16230 * send_delba_send_cmd_tlv() - send delba send command to fw
16231 * @wmi_handle: wmi handle
16232 * @param: pointer to delba send params
16233 * @macaddr: peer mac address
16234 *
16235 * Send WMI_DELBA_SEND_CMDID command to firmware
16236 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16237 */
16238static QDF_STATUS
16239send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
16240 uint8_t macaddr[IEEE80211_ADDR_LEN],
16241 struct delba_send_params *param)
16242{
16243 wmi_delba_send_cmd_fixed_param *cmd;
16244 wmi_buf_t buf;
16245 uint16_t len;
16246 QDF_STATUS ret;
16247
16248 len = sizeof(*cmd);
16249
16250 buf = wmi_buf_alloc(wmi_handle, len);
16251 if (!buf) {
16252 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16253 return QDF_STATUS_E_NOMEM;
16254 }
16255
16256 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
16257
16258 WMITLV_SET_HDR(&cmd->tlv_header,
16259 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
16260 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
16261
16262 cmd->vdev_id = param->vdev_id;
16263 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16264 cmd->tid = param->tidno;
16265 cmd->initiator = param->initiator;
16266 cmd->reasoncode = param->reasoncode;
16267
16268 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
16269 if (QDF_IS_STATUS_ERROR(ret)) {
16270 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16271 wmi_buf_free(buf);
16272 return QDF_STATUS_E_FAILURE;
16273 }
16274
16275 return QDF_STATUS_SUCCESS;
16276}
16277
16278/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016279 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
16280 * to fw
16281 * @wmi_handle: wmi handle
16282 * @param: pointer to addba clearresp params
16283 * @macaddr: peer mac address
16284 * Return: 0 for success or error code
16285 */
16286static QDF_STATUS
16287send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
16288 uint8_t macaddr[IEEE80211_ADDR_LEN],
16289 struct addba_clearresponse_params *param)
16290{
16291 wmi_addba_clear_resp_cmd_fixed_param *cmd;
16292 wmi_buf_t buf;
16293 uint16_t len;
16294 QDF_STATUS ret;
16295
16296 len = sizeof(*cmd);
16297
16298 buf = wmi_buf_alloc(wmi_handle, len);
16299 if (!buf) {
16300 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
16301 return QDF_STATUS_E_FAILURE;
16302 }
16303 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
16304
16305 WMITLV_SET_HDR(&cmd->tlv_header,
16306 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
16307 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
16308
16309 cmd->vdev_id = param->vdev_id;
16310 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16311
16312 ret = wmi_unified_cmd_send(wmi_handle,
16313 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
16314 if (QDF_IS_STATUS_ERROR(ret)) {
16315 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16316 wmi_buf_free(buf);
16317 return QDF_STATUS_E_FAILURE;
16318 }
16319
16320 return QDF_STATUS_SUCCESS;
16321}
16322
16323/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016324 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16325 * @wmi_handle: wmi handle
16326 * @bcn_ctrl_param: pointer to bcn_offload_control param
16327 *
16328 * Return: QDF_STATUS_SUCCESS for success or error code
16329 */
16330static
16331QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16332 struct bcn_offload_control *bcn_ctrl_param)
16333{
16334 wmi_buf_t buf;
16335 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16336 QDF_STATUS ret;
16337 uint32_t len;
16338
16339 len = sizeof(*cmd);
16340
16341 buf = wmi_buf_alloc(wmi_handle, len);
16342 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053016343 qdf_print("%s: wmi_buf_alloc failed", __func__);
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016344 return QDF_STATUS_E_FAILURE;
16345 }
16346
16347 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16348 WMITLV_SET_HDR(&cmd->tlv_header,
16349 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16350 WMITLV_GET_STRUCT_TLVLEN
16351 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16352 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016353 switch (bcn_ctrl_param->bcn_ctrl_op) {
16354 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016355 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016356 break;
16357 case BCN_OFFLD_CTRL_TX_ENABLE:
16358 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16359 break;
16360 case BCN_OFFLD_CTRL_SWBA_DISABLE:
16361 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
16362 break;
16363 case BCN_OFFLD_CTRL_SWBA_ENABLE:
16364 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
16365 break;
16366 default:
16367 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
16368 bcn_ctrl_param->bcn_ctrl_op);
16369 wmi_buf_free(buf);
16370 return QDF_STATUS_E_FAILURE;
16371 break;
16372 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016373 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16374 WMI_BCN_OFFLOAD_CTRL_CMDID);
16375
16376 if (QDF_IS_STATUS_ERROR(ret)) {
16377 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16378 ret);
16379 wmi_buf_free(buf);
16380 }
16381
16382 return ret;
16383}
16384
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016385#ifdef WLAN_FEATURE_NAN_CONVERGENCE
16386static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
16387 struct nan_datapath_initiator_req *ndp_req)
16388{
16389 uint16_t len;
16390 wmi_buf_t buf;
16391 uint8_t *tlv_ptr;
16392 QDF_STATUS status;
16393 wmi_channel *ch_tlv;
16394 wmi_ndp_initiator_req_fixed_param *cmd;
16395 uint32_t passphrase_len, service_name_len;
16396 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016397 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016398
16399 /*
16400 * WMI command expects 4 byte alligned len:
16401 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16402 */
16403 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
16404 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
16405 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
16406 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
16407 service_name_len =
16408 qdf_roundup(ndp_req->service_name.service_name_len, 4);
16409 /* allocated memory for fixed params as well as variable size data */
16410 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
16411 + ndp_cfg_len + ndp_app_info_len + pmk_len
16412 + passphrase_len + service_name_len;
16413
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016414 if (ndp_req->is_ipv6_addr_present)
16415 len += sizeof(*tcp_ip_param);
16416
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016417 buf = wmi_buf_alloc(wmi_handle, len);
16418 if (!buf) {
16419 WMI_LOGE("wmi_buf_alloc failed");
16420 return QDF_STATUS_E_NOMEM;
16421 }
16422
16423 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
16424 WMITLV_SET_HDR(&cmd->tlv_header,
16425 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
16426 WMITLV_GET_STRUCT_TLVLEN(
16427 wmi_ndp_initiator_req_fixed_param));
16428 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
16429 cmd->transaction_id = ndp_req->transaction_id;
16430 cmd->service_instance_id = ndp_req->service_instance_id;
16431 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
16432 &cmd->peer_discovery_mac_addr);
16433
16434 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
16435 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
16436 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
16437 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
16438 cmd->nan_csid = ndp_req->ncs_sk_type;
16439 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
16440 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
16441
16442 ch_tlv = (wmi_channel *)&cmd[1];
16443 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
16444 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
16445 ch_tlv->mhz = ndp_req->channel;
16446 tlv_ptr = (uint8_t *)&ch_tlv[1];
16447
16448 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16449 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16450 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16451 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16452
16453 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16454 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16455 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
16456 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16457
16458 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16459 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
16460 cmd->nan_pmk_len);
16461 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16462
16463 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16464 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
16465 cmd->nan_passphrase_len);
16466 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16467
16468 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16469 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16470 ndp_req->service_name.service_name,
16471 cmd->nan_servicename_len);
16472 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16473
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016474 if (ndp_req->is_ipv6_addr_present) {
16475 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16476 WMITLV_SET_HDR(tcp_ip_param,
16477 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16478 WMITLV_GET_STRUCT_TLVLEN(
16479 wmi_ndp_transport_ip_param));
16480 tcp_ip_param->ipv6_addr_present = true;
16481 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16482 ndp_req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16483 }
16484 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16485 ndp_req->is_ipv6_addr_present, ndp_req->ipv6_addr);
16486
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016487 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
16488 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
16489 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
16490 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16491 cmd->peer_discovery_mac_addr.mac_addr31to0,
16492 cmd->peer_discovery_mac_addr.mac_addr47to32);
16493
16494 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016495 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016496 ndp_req->ndp_config.ndp_cfg,
16497 ndp_req->ndp_config.ndp_cfg_len);
16498
16499 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016500 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016501 ndp_req->ndp_info.ndp_app_info,
16502 ndp_req->ndp_info.ndp_app_info_len);
16503
16504 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016505 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016506 ndp_req->pmk.pmk, cmd->nan_pmk_len);
16507
16508 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016509 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016510 ndp_req->passphrase.passphrase,
16511 cmd->nan_passphrase_len);
16512
16513 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016514 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016515 ndp_req->service_name.service_name,
16516 cmd->nan_servicename_len);
16517
16518 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
16519 WMI_NDP_INITIATOR_REQ_CMDID);
16520
16521 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16522 WMI_NDP_INITIATOR_REQ_CMDID);
16523 if (QDF_IS_STATUS_ERROR(status)) {
16524 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
16525 wmi_buf_free(buf);
16526 }
16527
16528 return status;
16529}
16530
16531static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
16532 struct nan_datapath_responder_req *req)
16533{
16534 uint16_t len;
16535 wmi_buf_t buf;
16536 uint8_t *tlv_ptr;
16537 QDF_STATUS status;
16538 wmi_ndp_responder_req_fixed_param *cmd;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016539 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016540 uint32_t passphrase_len, service_name_len;
16541 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
16542
16543 vdev_id = wlan_vdev_get_id(req->vdev);
16544 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
16545 vdev_id, req->transaction_id,
16546 req->ndp_rsp,
16547 req->ndp_instance_id,
16548 req->ndp_info.ndp_app_info_len);
16549
16550 /*
16551 * WMI command expects 4 byte alligned len:
16552 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16553 */
16554 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
16555 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
16556 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
16557 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
16558 service_name_len =
16559 qdf_roundup(req->service_name.service_name_len, 4);
16560
16561 /* allocated memory for fixed params as well as variable size data */
16562 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
16563 + pmk_len + passphrase_len + service_name_len;
16564
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016565 if (req->is_ipv6_addr_present || req->is_port_present ||
16566 req->is_protocol_present)
16567 len += sizeof(*tcp_ip_param);
16568
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016569 buf = wmi_buf_alloc(wmi_handle, len);
16570 if (!buf) {
16571 WMI_LOGE("wmi_buf_alloc failed");
16572 return QDF_STATUS_E_NOMEM;
16573 }
16574 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
16575 WMITLV_SET_HDR(&cmd->tlv_header,
16576 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
16577 WMITLV_GET_STRUCT_TLVLEN(
16578 wmi_ndp_responder_req_fixed_param));
16579 cmd->vdev_id = vdev_id;
16580 cmd->transaction_id = req->transaction_id;
16581 cmd->ndp_instance_id = req->ndp_instance_id;
16582 cmd->rsp_code = req->ndp_rsp;
16583 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
16584 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
16585 cmd->nan_pmk_len = req->pmk.pmk_len;
16586 cmd->nan_csid = req->ncs_sk_type;
16587 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
16588 cmd->nan_servicename_len = req->service_name.service_name_len;
16589
16590 tlv_ptr = (uint8_t *)&cmd[1];
16591 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16592 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16593 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16594
16595 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16596 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16597 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16598 req->ndp_info.ndp_app_info,
16599 req->ndp_info.ndp_app_info_len);
16600
16601 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16602 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16603 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
16604 cmd->nan_pmk_len);
16605
16606 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16607 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16608 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16609 req->passphrase.passphrase,
16610 cmd->nan_passphrase_len);
16611 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16612
16613 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16614 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16615 req->service_name.service_name,
16616 cmd->nan_servicename_len);
16617
16618 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16619
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016620 if (req->is_ipv6_addr_present || req->is_port_present ||
16621 req->is_protocol_present) {
16622 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16623 WMITLV_SET_HDR(tcp_ip_param,
16624 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16625 WMITLV_GET_STRUCT_TLVLEN(
16626 wmi_ndp_transport_ip_param));
16627 tcp_ip_param->ipv6_addr_present = req->is_ipv6_addr_present;
16628 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16629 req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16630
16631 tcp_ip_param->trans_port_present = req->is_port_present;
16632 tcp_ip_param->transport_port = req->port;
16633
16634 tcp_ip_param->trans_proto_present = req->is_protocol_present;
16635 tcp_ip_param->transport_protocol = req->protocol;
16636 }
16637 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16638 req->is_ipv6_addr_present, req->ipv6_addr);
16639 WMI_LOGD(FL("port: %d present: %d"), req->is_port_present, req->port);
16640 WMI_LOGD(FL("protocol: %d present: %d"),
16641 req->is_protocol_present, req->protocol);
16642
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016643 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
16644 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
16645
16646 WMI_LOGD("ndp_config len: %d",
16647 req->ndp_config.ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016648 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016649 req->ndp_config.ndp_cfg,
16650 req->ndp_config.ndp_cfg_len);
16651
16652 WMI_LOGD("ndp_app_info len: %d",
16653 req->ndp_info.ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016654 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016655 req->ndp_info.ndp_app_info,
16656 req->ndp_info.ndp_app_info_len);
16657
16658 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016659 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016660 req->pmk.pmk, cmd->nan_pmk_len);
16661
16662 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016663 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016664 req->passphrase.passphrase,
16665 cmd->nan_passphrase_len);
16666
16667 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016668 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016669 req->service_name.service_name,
16670 cmd->nan_servicename_len);
16671
16672 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
16673 WMI_NDP_RESPONDER_REQ_CMDID);
16674 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16675 WMI_NDP_RESPONDER_REQ_CMDID);
16676 if (QDF_IS_STATUS_ERROR(status)) {
16677 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
16678 wmi_buf_free(buf);
16679 }
16680 return status;
16681}
16682
16683static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
16684 struct nan_datapath_end_req *req)
16685{
16686 uint16_t len;
16687 wmi_buf_t buf;
16688 QDF_STATUS status;
16689 uint32_t ndp_end_req_len, i;
16690 wmi_ndp_end_req *ndp_end_req_lst;
16691 wmi_ndp_end_req_fixed_param *cmd;
16692
16693 /* len of tlv following fixed param */
16694 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
16695 /* above comes out to 4 byte alligned already, no need of padding */
16696 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
16697 buf = wmi_buf_alloc(wmi_handle, len);
16698 if (!buf) {
16699 WMI_LOGE("Malloc failed");
16700 return QDF_STATUS_E_NOMEM;
16701 }
16702
16703 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
16704 WMITLV_SET_HDR(&cmd->tlv_header,
16705 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
16706 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
16707
16708 cmd->transaction_id = req->transaction_id;
16709
16710 /* set tlv pointer to end of fixed param */
16711 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
16712 ndp_end_req_len);
16713
16714 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
16715 WMI_TLV_HDR_SIZE);
16716 for (i = 0; i < req->num_ndp_instances; i++) {
16717 WMITLV_SET_HDR(&ndp_end_req_lst[i],
16718 WMITLV_TAG_ARRAY_FIXED_STRUC,
16719 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
16720
16721 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
16722 }
16723
16724 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
16725 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16726 WMI_NDP_END_REQ_CMDID);
16727 if (QDF_IS_STATUS_ERROR(status)) {
16728 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
16729 wmi_buf_free(buf);
16730 }
16731
16732 return status;
16733}
16734
16735static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016736 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016737{
16738 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
16739 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
16740
16741 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
16742 fixed_params = event->fixed_param;
16743
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016744 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016745 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16746 fixed_params->vdev_id,
16747 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016748 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016749 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016750 return QDF_STATUS_E_INVAL;
16751 }
16752
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016753 rsp->transaction_id = fixed_params->transaction_id;
16754 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16755 rsp->status = fixed_params->rsp_status;
16756 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016757
16758 return QDF_STATUS_SUCCESS;
16759}
16760
16761static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016762 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016763{
16764 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
16765 wmi_ndp_indication_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016766 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016767
16768 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
16769 fixed_params =
16770 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
16771
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016772 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16773 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16774 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16775 return QDF_STATUS_E_INVAL;
16776 }
16777
16778 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16779 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16780 fixed_params->ndp_app_info_len,
16781 event->num_ndp_app_info);
16782 return QDF_STATUS_E_INVAL;
16783 }
16784
gaolezab037cf2018-05-23 14:40:32 +080016785 if (fixed_params->ndp_cfg_len >
16786 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16787 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16788 __func__, fixed_params->ndp_cfg_len);
16789 return QDF_STATUS_E_INVAL;
16790 }
16791
16792 total_array_len = fixed_params->ndp_cfg_len +
16793 sizeof(*fixed_params);
16794
16795 if (fixed_params->ndp_app_info_len >
16796 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16797 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16798 __func__, fixed_params->ndp_app_info_len);
16799 return QDF_STATUS_E_INVAL;
16800 }
16801 total_array_len += fixed_params->ndp_app_info_len;
16802
16803 if (fixed_params->nan_scid_len >
16804 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16805 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16806 __func__, fixed_params->nan_scid_len);
16807 return QDF_STATUS_E_INVAL;
16808 }
16809
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016810 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016811 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16812 fixed_params->vdev_id,
16813 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016814 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016815 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016816 return QDF_STATUS_E_INVAL;
16817 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016818 rsp->service_instance_id = fixed_params->service_instance_id;
16819 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16820 rsp->role = fixed_params->self_ndp_role;
16821 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016822
16823 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016824 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016825 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016826 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016827
16828 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
16829 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
16830 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
16831 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
16832 fixed_params->service_instance_id,
16833 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
16834 fixed_params->accept_policy,
16835 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016836 rsp->peer_mac_addr.bytes,
16837 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016838
16839 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016840 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016841 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16842
16843 WMI_LOGD("ndp_app_info - %d bytes",
16844 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016845 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016846 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16847
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016848 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
16849 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16850 rsp->ncs_sk_type = fixed_params->nan_csid;
16851 rsp->scid.scid_len = fixed_params->nan_scid_len;
Lihua Liue950ad12018-07-02 18:55:56 +080016852
16853 if (rsp->ndp_config.ndp_cfg_len > NDP_QOS_INFO_LEN)
16854 rsp->ndp_config.ndp_cfg_len = NDP_QOS_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016855 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
16856 rsp->ndp_config.ndp_cfg_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016857
16858 if (rsp->ndp_info.ndp_app_info_len > NDP_APP_INFO_LEN)
16859 rsp->ndp_info.ndp_app_info_len = NDP_APP_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016860 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16861 rsp->ndp_info.ndp_app_info_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016862
16863 if (rsp->scid.scid_len > NDP_SCID_BUF_LEN)
16864 rsp->scid.scid_len = NDP_SCID_BUF_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016865 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016866
16867 if (event->ndp_transport_ip_param &&
16868 event->num_ndp_transport_ip_param) {
16869 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16870 rsp->is_ipv6_addr_present = true;
16871 qdf_mem_copy(rsp->ipv6_addr,
16872 event->ndp_transport_ip_param->ipv6_intf_addr,
16873 WMI_NDP_IPV6_INTF_ADDR_LEN);
16874 }
16875 }
16876 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16877 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16878
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016879 WMI_LOGD("scid hex dump:");
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016880 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016881 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016882
16883 return QDF_STATUS_SUCCESS;
16884}
16885
16886static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016887 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016888{
Naveen Rawat38b21462018-05-31 15:04:16 -070016889 uint8_t i;
16890 WMI_HOST_WLAN_PHY_MODE ch_mode;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016891 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
16892 wmi_ndp_confirm_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016893 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016894
16895 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
16896 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070016897 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 -080016898 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
16899 fixed_params->ndp_instance_id, fixed_params->rsp_code,
16900 fixed_params->reason_code,
16901 fixed_params->num_active_ndps_on_peer);
Naveen Rawat38b21462018-05-31 15:04:16 -070016902 WMI_LOGE("num_ch: %d", fixed_params->num_ndp_channels);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016903
16904 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16905 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16906 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16907 return QDF_STATUS_E_INVAL;
16908 }
16909
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016910 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016911 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016912 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16913
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016914 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16915 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16916 fixed_params->ndp_app_info_len,
16917 event->num_ndp_app_info);
16918 return QDF_STATUS_E_INVAL;
16919 }
16920
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016921 WMI_LOGD("ndp_app_info - %d bytes",
16922 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016923 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016924 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16925
gaolezab037cf2018-05-23 14:40:32 +080016926 if (fixed_params->ndp_cfg_len >
16927 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16928 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16929 __func__, fixed_params->ndp_cfg_len);
16930 return QDF_STATUS_E_INVAL;
16931 }
16932
16933 total_array_len = fixed_params->ndp_cfg_len +
16934 sizeof(*fixed_params);
16935
16936 if (fixed_params->ndp_app_info_len >
16937 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16938 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16939 __func__, fixed_params->ndp_app_info_len);
16940 return QDF_STATUS_E_INVAL;
16941 }
16942
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016943 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016944 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16945 fixed_params->vdev_id,
16946 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016947 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016948 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016949 return QDF_STATUS_E_INVAL;
16950 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016951 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16952 rsp->rsp_code = fixed_params->rsp_code;
16953 rsp->reason_code = fixed_params->reason_code;
16954 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat38b21462018-05-31 15:04:16 -070016955 rsp->num_channels = fixed_params->num_ndp_channels;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016956 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016957 rsp->peer_ndi_mac_addr.bytes);
16958 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16959 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16960 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016961
Naveen Rawat38b21462018-05-31 15:04:16 -070016962 if (rsp->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
16963 WMI_LOGE(FL("too many channels"));
16964 rsp->num_channels = NAN_CH_INFO_MAX_CHANNELS;
16965 }
16966
16967 for (i = 0; i < rsp->num_channels; i++) {
16968 rsp->ch[i].channel = event->ndp_channel_list[i].mhz;
16969 rsp->ch[i].nss = event->nss_list[i];
16970 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndp_channel_list[i]);
16971 rsp->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
16972 ch_mode);
16973 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
16974 rsp->ch[i].channel,
16975 rsp->ch[i].ch_width,
16976 rsp->ch[i].nss);
16977 }
16978
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016979 if (event->ndp_transport_ip_param &&
16980 event->num_ndp_transport_ip_param) {
16981 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16982 rsp->is_ipv6_addr_present = true;
16983 qdf_mem_copy(rsp->ipv6_addr,
16984 event->ndp_transport_ip_param->ipv6_intf_addr,
16985 WMI_NDP_IPV6_INTF_ADDR_LEN);
16986 }
16987
16988 if (event->ndp_transport_ip_param->trans_port_present) {
16989 rsp->is_port_present = true;
16990 rsp->port =
16991 event->ndp_transport_ip_param->transport_port;
16992 }
16993
16994 if (event->ndp_transport_ip_param->trans_proto_present) {
16995 rsp->is_protocol_present = true;
16996 rsp->protocol =
16997 event->ndp_transport_ip_param->transport_protocol;
16998 }
16999 }
17000 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
17001 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
17002 WMI_LOGD(FL("port: %d present: %d"), rsp->port, rsp->is_port_present);
17003 WMI_LOGD(FL("protocol: %d present: %d"),
17004 rsp->protocol, rsp->is_protocol_present);
17005
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017006 return QDF_STATUS_SUCCESS;
17007}
17008
17009static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017010 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017011{
17012 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17013 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17014
17015 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17016 fixed_params = event->fixed_param;
17017
17018 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",
17019 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017020 rsp->peer_mac_addr.bytes, rsp->transaction_id,
17021 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017022
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017023 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017024 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17025 fixed_params->vdev_id,
17026 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017027 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017028 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017029 return QDF_STATUS_E_INVAL;
17030 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017031 rsp->transaction_id = fixed_params->transaction_id;
17032 rsp->reason = fixed_params->reason_code;
17033 rsp->status = fixed_params->rsp_status;
17034 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017035 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017036 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017037
17038 return QDF_STATUS_SUCCESS;
17039}
17040
17041static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017042 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017043{
17044 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17045 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17046
17047 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17048 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017049 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 -080017050 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17051 fixed_params->rsp_status, fixed_params->reason_code);
17052
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017053 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017054 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017055 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017056 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017057 return QDF_STATUS_E_INVAL;
17058 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017059 rsp->transaction_id = fixed_params->transaction_id;
17060 rsp->reason = fixed_params->reason_code;
17061 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017062
17063 return QDF_STATUS_SUCCESS;
17064}
17065
17066static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17067 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17068{
17069 uint32_t i, buf_size;
17070 wmi_ndp_end_indication *ind;
17071 struct qdf_mac_addr peer_addr;
17072 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17073
17074 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17075 ind = event->ndp_end_indication_list;
17076
17077 if (event->num_ndp_end_indication_list == 0) {
17078 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017079 return QDF_STATUS_E_INVAL;
17080 }
17081
17082 WMI_LOGD("number of ndp instances = %d",
17083 event->num_ndp_end_indication_list);
17084
17085 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17086 sizeof((*rsp)->ndp_map[0]))) {
17087 WMI_LOGE("num_ndp_end_ind_list %d too large",
17088 event->num_ndp_end_indication_list);
17089 return QDF_STATUS_E_INVAL;
17090 }
17091
17092 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17093 sizeof((*rsp)->ndp_map[0]);
17094 *rsp = qdf_mem_malloc(buf_size);
17095 if (!(*rsp)) {
17096 WMI_LOGE("Failed to allocate memory");
17097 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017098 }
17099
17100 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17101 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17102 if (!(*rsp)->vdev) {
17103 WMI_LOGE("vdev is null");
17104 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017105 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017106 return QDF_STATUS_E_INVAL;
17107 }
17108
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017109 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17110 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17111 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17112 peer_addr.bytes);
17113 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17114 i, ind[i].type, ind[i].reason_code,
17115 ind[i].ndp_instance_id,
17116 ind[i].num_active_ndps_on_peer);
17117 /* Add each instance entry to the list */
17118 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17119 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17120 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17121 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17122 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17123 ind[i].num_active_ndps_on_peer;
17124 (*rsp)->ndp_map[i].type = ind[i].type;
17125 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17126 }
17127
17128 return QDF_STATUS_SUCCESS;
17129}
Naveen Rawatd42ce382018-01-09 17:54:41 -080017130
17131static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,
17132 uint8_t *data, struct nan_datapath_sch_update_event *ind)
17133{
17134 uint8_t i;
17135 WMI_HOST_WLAN_PHY_MODE ch_mode;
17136 WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *event;
17137 wmi_ndl_schedule_update_fixed_param *fixed_params;
17138
17139 event = (WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *)data;
17140 fixed_params = event->fixed_param;
17141
17142 WMI_LOGD(FL("flags: %d, num_ch: %d, num_ndp_instances: %d"),
17143 fixed_params->flags, fixed_params->num_channels,
17144 fixed_params->num_ndp_instances);
17145
17146 ind->vdev =
17147 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17148 fixed_params->vdev_id,
17149 WLAN_NAN_ID);
17150 if (!ind->vdev) {
17151 WMI_LOGE("vdev is null");
17152 return QDF_STATUS_E_INVAL;
17153 }
17154
17155 ind->flags = fixed_params->flags;
17156 ind->num_channels = fixed_params->num_channels;
17157 ind->num_ndp_instances = fixed_params->num_ndp_instances;
17158 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_macaddr,
17159 ind->peer_addr.bytes);
17160
17161 if (ind->num_ndp_instances > NDP_NUM_INSTANCE_ID) {
17162 WMI_LOGE(FL("uint32 overflow"));
17163 wlan_objmgr_vdev_release_ref(ind->vdev, WLAN_NAN_ID);
17164 return QDF_STATUS_E_INVAL;
17165 }
17166
17167 qdf_mem_copy(ind->ndp_instances, event->ndp_instance_list,
17168 sizeof(uint32_t) * ind->num_ndp_instances);
17169
17170 if (ind->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
17171 WMI_LOGE(FL("too many channels"));
17172 ind->num_channels = NAN_CH_INFO_MAX_CHANNELS;
17173 }
17174 for (i = 0; i < ind->num_channels; i++) {
17175 ind->ch[i].channel = event->ndl_channel_list[i].mhz;
17176 ind->ch[i].nss = event->nss_list[i];
17177 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]);
17178 ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
17179 ch_mode);
17180 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
17181 ind->ch[i].channel,
17182 ind->ch[i].ch_width,
17183 ind->ch[i].nss);
17184 }
17185
17186 for (i = 0; i < fixed_params->num_ndp_instances; i++)
17187 WMI_LOGD(FL("instance_id[%d]: %d"),
17188 i, event->ndp_instance_list[i]);
17189
17190 return QDF_STATUS_SUCCESS;
17191}
17192
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017193#endif
17194
Naveen Rawat963ee942018-04-13 16:38:36 -070017195#ifdef QCA_SUPPORT_CP_STATS
17196/**
17197 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
17198 * @wmi_handle: wma handle
17199 * @evt_buf: event buffer
17200 * @out_buff: buffer to populated after stats extraction
17201 *
17202 * Return: status of operation
17203 */
17204static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
17205 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
17206{
17207 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17208 wmi_congestion_stats *congestion_stats;
17209
17210 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
17211 congestion_stats = param_buf->congestion_stats;
17212 if (!congestion_stats) {
17213 WMI_LOGD("%s: no cca stats in event buffer", __func__);
17214 return QDF_STATUS_E_INVAL;
17215 }
17216
17217 out_buff->vdev_id = congestion_stats->vdev_id;
17218 out_buff->congestion = congestion_stats->congestion;
17219
17220 WMI_LOGD("%s: cca stats event processed", __func__);
17221 return QDF_STATUS_SUCCESS;
17222}
17223#endif /* QCA_SUPPORT_CP_STATS */
17224
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017225/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017226 * save_service_bitmap_tlv() - save service bitmap
17227 * @wmi_handle: wmi handle
17228 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017229 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017230 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017231 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017232 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017233static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017234QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017235 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017236{
17237 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017238 struct wmi_soc *soc = wmi_handle->soc;
17239
Govind Singhe7f2f342016-05-23 12:12:52 +053017240 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17241
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017242 /* If it is already allocated, use that buffer. This can happen
17243 * during target stop/start scenarios where host allocation is skipped.
17244 */
17245 if (!soc->wmi_service_bitmap) {
17246 soc->wmi_service_bitmap =
17247 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17248 if (!soc->wmi_service_bitmap) {
17249 WMI_LOGE("Failed memory allocation for service bitmap");
17250 return QDF_STATUS_E_NOMEM;
17251 }
17252 }
17253
17254 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017255 param_buf->wmi_service_bitmap,
17256 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017257
17258 if (bitmap_buf)
17259 qdf_mem_copy(bitmap_buf,
17260 param_buf->wmi_service_bitmap,
17261 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017262
17263 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017264}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017265
17266/**
17267 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17268 * @wmi_handle: wmi handle
17269 * @param evt_buf: pointer to event buffer
17270 * @param bitmap_buf: bitmap buffer, for converged legacy support
17271 *
17272 * Return: QDF_STATUS
17273 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017274static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017275QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017276 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017277{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017278 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17279 wmi_service_available_event_fixed_param *ev;
17280 struct wmi_soc *soc = wmi_handle->soc;
17281
17282 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17283
17284 ev = param_buf->fixed_param;
17285
17286 /* If it is already allocated, use that buffer. This can happen
17287 * during target stop/start scenarios where host allocation is skipped.
17288 */
17289 if (!soc->wmi_ext_service_bitmap) {
17290 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17291 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17292 if (!soc->wmi_ext_service_bitmap) {
17293 WMI_LOGE("Failed memory allocation for service bitmap");
17294 return QDF_STATUS_E_NOMEM;
17295 }
17296 }
17297
17298 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17299 ev->wmi_service_segment_bitmap,
17300 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017301
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017302 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17303 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17304 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17305
Rajeev Kumar77901472017-02-12 02:12:17 -080017306 if (bitmap_buf)
17307 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017308 soc->wmi_ext_service_bitmap,
17309 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017310
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017311 return QDF_STATUS_SUCCESS;
17312}
Govind Singhe7f2f342016-05-23 12:12:52 +053017313/**
17314 * is_service_enabled_tlv() - Check if service enabled
17315 * @param wmi_handle: wmi handle
17316 * @param service_id: service identifier
17317 *
17318 * Return: 1 enabled, 0 disabled
17319 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017320static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17321 uint32_t service_id)
17322{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017323 struct wmi_soc *soc = wmi_handle->soc;
17324
17325 if (!soc->wmi_service_bitmap) {
17326 WMI_LOGE("WMI service bit map is not saved yet\n");
17327 return false;
17328 }
17329
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017330 /* if wmi_service_enabled was received with extended bitmap,
17331 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017332 */
17333 if (soc->wmi_ext_service_bitmap)
17334 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17335 soc->wmi_ext_service_bitmap,
17336 service_id);
17337
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080017338 if (service_id >= WMI_MAX_SERVICE) {
17339 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
17340 service_id);
17341 return false;
17342 }
17343
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017344 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17345 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017346}
Govind Singhe7f2f342016-05-23 12:12:52 +053017347
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017348static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17349 struct wlan_psoc_target_capability_info *cap)
17350{
17351 /* except LDPC all flags are common betwen legacy and here
17352 * also IBFEER is not defined for TLV
17353 */
17354 cap->ht_cap_info |= ev_target_cap & (
17355 WMI_HT_CAP_ENABLED
17356 | WMI_HT_CAP_HT20_SGI
17357 | WMI_HT_CAP_DYNAMIC_SMPS
17358 | WMI_HT_CAP_TX_STBC
17359 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17360 | WMI_HT_CAP_RX_STBC
17361 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17362 | WMI_HT_CAP_LDPC
17363 | WMI_HT_CAP_L_SIG_TXOP_PROT
17364 | WMI_HT_CAP_MPDU_DENSITY
17365 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17366 | WMI_HT_CAP_HT40_SGI);
17367 if (ev_target_cap & WMI_HT_CAP_LDPC)
17368 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17369 WMI_HOST_HT_CAP_TX_LDPC;
17370}
Govind Singhe7f2f342016-05-23 12:12:52 +053017371/**
17372 * extract_service_ready_tlv() - extract service ready event
17373 * @wmi_handle: wmi handle
17374 * @param evt_buf: pointer to received event buffer
17375 * @param cap: pointer to hold target capability information extracted from even
17376 *
17377 * Return: QDF_STATUS_SUCCESS for success or error code
17378 */
17379static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017380 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017381{
17382 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17383 wmi_service_ready_event_fixed_param *ev;
17384
17385
17386 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17387
17388 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17389 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017390 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017391 return QDF_STATUS_E_FAILURE;
17392 }
17393
17394 cap->phy_capability = ev->phy_capability;
17395 cap->max_frag_entry = ev->max_frag_entry;
17396 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017397 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017398 cap->vht_cap_info = ev->vht_cap_info;
17399 cap->vht_supp_mcs = ev->vht_supp_mcs;
17400 cap->hw_min_tx_power = ev->hw_min_tx_power;
17401 cap->hw_max_tx_power = ev->hw_max_tx_power;
17402 cap->sys_cap_info = ev->sys_cap_info;
17403 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17404 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17405 cap->max_num_scan_channels = ev->max_num_scan_channels;
17406 cap->max_supported_macs = ev->max_supported_macs;
17407 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17408 cap->txrx_chainmask = ev->txrx_chainmask;
17409 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17410 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017411 cap->fw_version = ev->fw_build_vers;
17412 /* fw_version_1 is not available in TLV. */
17413 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017414
17415 return QDF_STATUS_SUCCESS;
17416}
17417
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017418/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17419 * to host internal WMI_HOST_REGDMN_MODE values.
17420 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17421 * host currently. Add this in the future if required.
17422 * 11AX (Phase II) : 11ax related values are not currently
17423 * advertised separately by FW. As part of phase II regulatory bring-up,
17424 * finalize the advertisement mechanism.
17425 * @target_wireless_mode: target wireless mode received in message
17426 *
17427 * Return: returns the host internal wireless mode.
17428 */
17429static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17430{
17431
17432 uint32_t wireless_modes = 0;
17433
17434 if (target_wireless_mode & REGDMN_MODE_11A)
17435 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17436
17437 if (target_wireless_mode & REGDMN_MODE_TURBO)
17438 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17439
17440 if (target_wireless_mode & REGDMN_MODE_11B)
17441 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17442
17443 if (target_wireless_mode & REGDMN_MODE_PUREG)
17444 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17445
17446 if (target_wireless_mode & REGDMN_MODE_11G)
17447 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
17448
17449 if (target_wireless_mode & REGDMN_MODE_108G)
17450 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
17451
17452 if (target_wireless_mode & REGDMN_MODE_108A)
17453 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
17454
17455 if (target_wireless_mode & REGDMN_MODE_XR)
17456 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
17457
17458 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
17459 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
17460
17461 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
17462 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
17463
17464 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
17465 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
17466
17467 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
17468 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
17469
17470 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
17471 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
17472
17473 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
17474 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
17475
17476 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
17477 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
17478
17479 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
17480 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
17481
17482 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
17483 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
17484
17485 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
17486 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
17487
17488 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
17489 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
17490
17491 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
17492 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
17493
17494 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
17495 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
17496
17497 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
17498 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
17499
17500 return wireless_modes;
17501}
17502
Govind Singhe7f2f342016-05-23 12:12:52 +053017503/**
17504 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
17505 * @wmi_handle: wmi handle
17506 * @param evt_buf: Pointer to event buffer
17507 * @param cap: pointer to hold HAL reg capabilities
17508 *
17509 * Return: QDF_STATUS_SUCCESS for success or error code
17510 */
17511static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017512 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017513{
17514 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17515
17516 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17517
17518 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
17519 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080017520 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053017521
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017522 cap->wireless_modes = convert_wireless_modes_tlv(
17523 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053017524
Govind Singhe7f2f342016-05-23 12:12:52 +053017525 return QDF_STATUS_SUCCESS;
17526}
17527
17528/**
17529 * extract_host_mem_req_tlv() - Extract host memory request event
17530 * @wmi_handle: wmi handle
17531 * @param evt_buf: pointer to event buffer
17532 * @param num_entries: pointer to hold number of entries requested
17533 *
17534 * Return: Number of entries requested
17535 */
17536static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
17537 void *evt_buf, uint8_t *num_entries)
17538{
17539 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17540 wmi_service_ready_event_fixed_param *ev;
17541
17542 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17543
17544 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17545 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017546 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017547 return NULL;
17548 }
17549
17550 *num_entries = ev->num_mem_reqs;
17551
17552 return (host_mem_req *)param_buf->mem_reqs;
17553}
17554
17555/**
17556 * save_fw_version_in_service_ready_tlv() - Save fw version in service
17557 * ready function
17558 * @wmi_handle: wmi handle
17559 * @param evt_buf: pointer to event buffer
17560 *
17561 * Return: QDF_STATUS_SUCCESS for success or error code
17562 */
17563static QDF_STATUS
17564save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
17565{
17566 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17567 wmi_service_ready_event_fixed_param *ev;
17568
17569
17570 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17571
17572 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17573 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017574 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017575 return QDF_STATUS_E_FAILURE;
17576 }
17577
17578 /*Save fw version from service ready message */
17579 /*This will be used while sending INIT message */
17580 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
17581 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017582
Govind Singhe7f2f342016-05-23 12:12:52 +053017583 return QDF_STATUS_SUCCESS;
17584}
17585
17586/**
17587 * ready_extract_init_status_tlv() - Extract init status from ready event
17588 * @wmi_handle: wmi handle
17589 * @param evt_buf: Pointer to event buffer
17590 *
17591 * Return: ready status
17592 */
17593static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
17594 void *evt_buf)
17595{
17596 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17597 wmi_ready_event_fixed_param *ev = NULL;
17598
Govind Singhe7f2f342016-05-23 12:12:52 +053017599 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17600 ev = param_buf->fixed_param;
17601
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017602 qdf_print("%s:%d", __func__, ev->status);
Govind Singhe7f2f342016-05-23 12:12:52 +053017603
17604 return ev->status;
17605}
17606
17607/**
17608 * ready_extract_mac_addr_tlv() - extract mac address from ready event
17609 * @wmi_handle: wmi handle
17610 * @param evt_buf: pointer to event buffer
17611 * @param macaddr: Pointer to hold MAC address
17612 *
17613 * Return: QDF_STATUS_SUCCESS for success or error code
17614 */
17615static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17616 void *evt_buf, uint8_t *macaddr)
17617{
17618 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17619 wmi_ready_event_fixed_param *ev = NULL;
17620
17621
17622 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17623 ev = param_buf->fixed_param;
17624
17625 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17626
17627 return QDF_STATUS_SUCCESS;
17628}
17629
17630/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017631 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17632 * @wmi_handle: wmi handle
17633 * @param evt_buf: pointer to event buffer
17634 * @param macaddr: Pointer to hold number of MAC addresses
17635 *
17636 * Return: Pointer to addr list
17637 */
17638static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17639 void *evt_buf, uint8_t *num_mac)
17640{
17641 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17642 wmi_ready_event_fixed_param *ev = NULL;
17643
17644 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17645 ev = param_buf->fixed_param;
17646
17647 *num_mac = ev->num_extra_mac_addr;
17648
17649 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17650}
17651
17652/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017653 * extract_ready_params_tlv() - Extract data from ready event apart from
17654 * status, macaddr and version.
17655 * @wmi_handle: Pointer to WMI handle.
17656 * @evt_buf: Pointer to Ready event buffer.
17657 * @ev_param: Pointer to host defined struct to copy the data from event.
17658 *
17659 * Return: QDF_STATUS_SUCCESS on success.
17660 */
17661static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17662 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17663{
17664 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17665 wmi_ready_event_fixed_param *ev = NULL;
17666
17667 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17668 ev = param_buf->fixed_param;
17669
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017670 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017671 ev_param->num_dscp_table = ev->num_dscp_table;
17672 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17673 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017674 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017675 /* Agile_cap in ready event is not supported in TLV target */
17676 ev_param->agile_capability = false;
17677
17678 return QDF_STATUS_SUCCESS;
17679}
17680
17681/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017682 * extract_dbglog_data_len_tlv() - extract debuglog data length
17683 * @wmi_handle: wmi handle
17684 * @param evt_buf: pointer to event buffer
17685 *
17686 * Return: length
17687 */
17688static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017689 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017690{
17691 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17692
17693 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17694
17695 *len = param_buf->num_bufp;
17696
17697 return param_buf->bufp;
17698}
17699
17700/**
17701 * extract_vdev_start_resp_tlv() - extract vdev start response
17702 * @wmi_handle: wmi handle
17703 * @param evt_buf: pointer to event buffer
17704 * @param vdev_rsp: Pointer to hold vdev response
17705 *
17706 * Return: QDF_STATUS_SUCCESS for success or error code
17707 */
17708static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
17709 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
17710{
17711 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
17712 wmi_vdev_start_response_event_fixed_param *ev;
17713
17714 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
17715 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017716 qdf_print("Invalid start response event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017717 return QDF_STATUS_E_INVAL;
17718 }
17719
17720 ev = param_buf->fixed_param;
17721 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017722 qdf_print("Invalid start response event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017723 return QDF_STATUS_E_INVAL;
17724 }
17725
17726 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
17727
17728 vdev_rsp->vdev_id = ev->vdev_id;
17729 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017730 switch (ev->resp_type) {
17731 case WMI_VDEV_START_RESP_EVENT:
17732 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
17733 break;
17734 case WMI_VDEV_RESTART_RESP_EVENT:
17735 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
17736 break;
17737 default:
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017738 qdf_print("Invalid start response event buffer");
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017739 break;
17740 };
Govind Singhe7f2f342016-05-23 12:12:52 +053017741 vdev_rsp->status = ev->status;
17742 vdev_rsp->chain_mask = ev->chain_mask;
17743 vdev_rsp->smps_mode = ev->smps_mode;
17744 vdev_rsp->mac_id = ev->mac_id;
17745 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
17746 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
17747
17748 return QDF_STATUS_SUCCESS;
17749}
17750
17751/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053017752 * extract_vdev_delete_resp_tlv() - extract vdev delete response
17753 * @wmi_handle: wmi handle
17754 * @param evt_buf: pointer to event buffer
17755 * @param delete_rsp: Pointer to hold vdev delete response
17756 *
17757 * Return: QDF_STATUS_SUCCESS for success or error code
17758 */
17759static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
17760 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
17761{
17762 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17763 wmi_vdev_delete_resp_event_fixed_param *ev;
17764
17765 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
17766 if (!param_buf) {
17767 WMI_LOGE("Invalid vdev delete response event buffer\n");
17768 return QDF_STATUS_E_INVAL;
17769 }
17770
17771 ev = param_buf->fixed_param;
17772 if (!ev) {
17773 WMI_LOGE("Invalid vdev delete response event\n");
17774 return QDF_STATUS_E_INVAL;
17775 }
17776
17777 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
17778 delete_rsp->vdev_id = ev->vdev_id;
17779
17780 return QDF_STATUS_SUCCESS;
17781}
17782
17783
17784/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017785 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053017786 * @wmi_handle: wmi handle
17787 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017788 * @param num_vdevs: Pointer to hold num vdev
17789 *
17790 * Return: QDF_STATUS_SUCCESS for success or error code
17791 */
17792static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17793 void *evt_buf, uint32_t *num_vdevs)
17794{
17795 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17796 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
17797 uint32_t vdev_map;
17798
17799 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
17800 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017801 qdf_print("Invalid tbtt update ext event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017802 return QDF_STATUS_E_INVAL;
17803 }
17804 tbtt_offset_event = param_buf->fixed_param;
17805 vdev_map = tbtt_offset_event->vdev_map;
17806 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
17807
17808 return QDF_STATUS_SUCCESS;
17809}
17810
17811/**
17812 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
17813 * @wmi_handle: wmi handle
17814 * @param evt_buf: pointer to event buffer
17815 * @param num_vdevs: Pointer to hold num vdev
17816 *
17817 * Return: QDF_STATUS_SUCCESS for success or error code
17818 */
17819static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17820 void *evt_buf, uint32_t *num_vdevs)
17821{
17822 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17823 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
17824
17825 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17826 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017827 qdf_print("Invalid tbtt update ext event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017828 return QDF_STATUS_E_INVAL;
17829 }
17830 tbtt_offset_ext_event = param_buf->fixed_param;
17831
17832 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
17833
17834 return QDF_STATUS_SUCCESS;
17835}
17836
17837/**
17838 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
17839 * @wmi_handle: wmi handle
17840 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017841 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017842 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053017843 *
17844 * Return: QDF_STATUS_SUCCESS for success or error code
17845 */
17846static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017847 void *evt_buf, uint8_t idx,
17848 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017849{
17850 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17851 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017852 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053017853
17854 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
17855 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017856 qdf_print("Invalid tbtt update event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017857 return QDF_STATUS_E_INVAL;
17858 }
Govind Singhe7f2f342016-05-23 12:12:52 +053017859
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017860 tbtt_offset_event = param_buf->fixed_param;
17861 vdev_map = tbtt_offset_event->vdev_map;
17862 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
17863 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
17864 return QDF_STATUS_E_INVAL;
17865 tbtt_param->tbttoffset =
17866 param_buf->tbttoffset_list[tbtt_param->vdev_id];
17867
17868 return QDF_STATUS_SUCCESS;
17869}
17870
17871/**
17872 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
17873 * @wmi_handle: wmi handle
17874 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017875 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017876 * @param tbtt_param: Pointer to tbttoffset event param
17877 *
17878 * Return: QDF_STATUS_SUCCESS for success or error code
17879 */
17880static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
17881 void *evt_buf, uint8_t idx,
17882 struct tbttoffset_params *tbtt_param)
17883{
17884 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17885 wmi_tbtt_offset_info *tbtt_offset_info;
17886
17887 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17888 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017889 qdf_print("Invalid tbtt update event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017890 return QDF_STATUS_E_INVAL;
17891 }
17892 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
17893
17894 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
17895 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053017896
17897 return QDF_STATUS_SUCCESS;
17898}
17899
Jinwei Chenb69924c2018-08-20 11:31:31 +080017900#ifdef CONFIG_MCL
17901#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) \
17902 ((_status) & WMI_RXERR_DECRYPT)
17903#else
17904#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) false
17905#endif
17906
Govind Singhe7f2f342016-05-23 12:12:52 +053017907/**
17908 * extract_mgmt_rx_params_tlv() - extract management rx params from event
17909 * @wmi_handle: wmi handle
17910 * @param evt_buf: pointer to event buffer
17911 * @param hdr: Pointer to hold header
17912 * @param bufp: Pointer to hold pointer to rx param buffer
17913 *
17914 * Return: QDF_STATUS_SUCCESS for success or error code
17915 */
17916static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053017917 void *evt_buf, struct mgmt_rx_event_params *hdr,
17918 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053017919{
17920 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
17921 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017922 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053017923
17924 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
17925 if (!param_tlvs) {
17926 WMI_LOGE("Get NULL point message from FW");
17927 return QDF_STATUS_E_INVAL;
17928 }
17929
17930 ev_hdr = param_tlvs->hdr;
17931 if (!hdr) {
17932 WMI_LOGE("Rx event is NULL");
17933 return QDF_STATUS_E_INVAL;
17934 }
17935
Jinwei Chenb69924c2018-08-20 11:31:31 +080017936 if (IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(ev_hdr->status)) {
17937 WMI_LOGE("%s: RX mgmt frame decrypt error, discard it",
17938 __func__);
17939 return QDF_STATUS_E_INVAL;
17940 }
17941
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017942 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17943 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017944
17945 hdr->channel = ev_hdr->channel;
17946 hdr->snr = ev_hdr->snr;
17947 hdr->rate = ev_hdr->rate;
17948 hdr->phy_mode = ev_hdr->phy_mode;
17949 hdr->buf_len = ev_hdr->buf_len;
17950 hdr->status = ev_hdr->status;
17951 hdr->flags = ev_hdr->flags;
17952 hdr->rssi = ev_hdr->rssi;
17953 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017954 for (i = 0; i < ATH_MAX_ANTENNA; i++)
17955 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053017956
17957 *bufp = param_tlvs->bufp;
17958
17959 return QDF_STATUS_SUCCESS;
17960}
17961
17962/**
17963 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
17964 * @wmi_handle: wmi handle
17965 * @param evt_buf: pointer to event buffer
17966 * @param vdev_id: Pointer to hold vdev identifier
17967 *
17968 * Return: QDF_STATUS_SUCCESS for success or error code
17969 */
17970static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
17971 void *evt_buf, uint32_t *vdev_id)
17972{
17973 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
17974 wmi_vdev_stopped_event_fixed_param *resp_event;
17975
17976 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
17977 if (!param_buf) {
17978 WMI_LOGE("Invalid event buffer");
17979 return QDF_STATUS_E_INVAL;
17980 }
17981 resp_event = param_buf->fixed_param;
17982 *vdev_id = resp_event->vdev_id;
17983
17984 return QDF_STATUS_SUCCESS;
17985}
17986
17987/**
17988 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
17989 * @wmi_handle: wmi handle
17990 * @param evt_buf: pointer to event buffer
17991 * @param param: Pointer to hold roam param
17992 *
17993 * Return: QDF_STATUS_SUCCESS for success or error code
17994 */
17995static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
17996 void *evt_buf, wmi_host_roam_event *param)
17997{
17998 WMI_ROAM_EVENTID_param_tlvs *param_buf;
17999 wmi_roam_event_fixed_param *evt;
18000
18001 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18002 if (!param_buf) {
18003 WMI_LOGE("Invalid roam event buffer");
18004 return QDF_STATUS_E_INVAL;
18005 }
18006
18007 evt = param_buf->fixed_param;
18008 qdf_mem_zero(param, sizeof(*param));
18009
18010 param->vdev_id = evt->vdev_id;
18011 param->reason = evt->reason;
18012 param->rssi = evt->rssi;
18013
18014 return QDF_STATUS_SUCCESS;
18015}
18016
18017/**
18018 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18019 * @wmi_handle: wmi handle
18020 * @param evt_buf: pointer to event buffer
18021 * @param param: Pointer to hold vdev scan param
18022 *
18023 * Return: QDF_STATUS_SUCCESS for success or error code
18024 */
18025static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018026 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018027{
18028 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18029 wmi_scan_event_fixed_param *evt = NULL;
18030
18031 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18032 evt = param_buf->fixed_param;
18033
18034 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018035
Govind Singhe7f2f342016-05-23 12:12:52 +053018036 switch (evt->event) {
18037 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018038 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018039 break;
18040 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018041 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018042 break;
18043 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018044 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018045 break;
18046 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018047 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018048 break;
18049 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018050 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018051 break;
18052 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018053 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018054 break;
18055 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018056 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018057 break;
18058 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018059 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018060 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018061 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018062 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018063 break;
18064 case WMI_SCAN_EVENT_MAX:
18065 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018066 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018067 break;
18068 };
18069
18070 switch (evt->reason) {
18071 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018072 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018073 break;
18074 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018075 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018076 break;
18077 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018078 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018079 break;
18080 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018081 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018082 break;
18083 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018084 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018085 break;
18086 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018087 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018088 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018089 case WMI_SCAN_REASON_SUSPENDED:
18090 param->reason = SCAN_REASON_SUSPENDED;
18091 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018092 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018093 param->reason = SCAN_REASON_MAX;
18094 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018095 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018096 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018097 break;
18098 };
18099
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018100 param->chan_freq = evt->channel_freq;
18101 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018102 param->scan_id = evt->scan_id;
18103 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018104 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018105
18106 return QDF_STATUS_SUCCESS;
18107}
18108
Frank Liu3d5e9992017-03-15 17:51:43 +080018109#ifdef CONVERGED_TDLS_ENABLE
18110/**
18111 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18112 * @wmi_handle: wmi handle
18113 * @param evt_buf: pointer to event buffer
18114 * @param param: Pointer to hold vdev tdls param
18115 *
18116 * Return: QDF_STATUS_SUCCESS for success or error code
18117 */
18118static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18119 void *evt_buf, struct tdls_event_info *param)
18120{
18121 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18122 wmi_tdls_peer_event_fixed_param *evt;
18123
18124 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18125 if (!param_buf) {
18126 WMI_LOGE("%s: NULL param_buf", __func__);
18127 return QDF_STATUS_E_NULL_VALUE;
18128 }
18129
18130 evt = param_buf->fixed_param;
18131
18132 qdf_mem_zero(param, sizeof(*param));
18133
18134 param->vdev_id = evt->vdev_id;
18135 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18136 param->peermac.bytes);
18137 switch (evt->peer_status) {
18138 case WMI_TDLS_SHOULD_DISCOVER:
18139 param->message_type = TDLS_SHOULD_DISCOVER;
18140 break;
18141 case WMI_TDLS_SHOULD_TEARDOWN:
18142 param->message_type = TDLS_SHOULD_TEARDOWN;
18143 break;
18144 case WMI_TDLS_PEER_DISCONNECTED:
18145 param->message_type = TDLS_PEER_DISCONNECTED;
18146 break;
18147 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18148 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18149 break;
18150 default:
18151 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18152 __func__, evt->peer_status);
18153 return QDF_STATUS_E_INVAL;
18154 };
18155
18156 switch (evt->peer_reason) {
18157 case WMI_TDLS_TEARDOWN_REASON_TX:
18158 param->peer_reason = TDLS_TEARDOWN_TX;
18159 break;
18160 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18161 param->peer_reason = TDLS_TEARDOWN_RSSI;
18162 break;
18163 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18164 param->peer_reason = TDLS_TEARDOWN_SCAN;
18165 break;
18166 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18167 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18168 break;
18169 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18170 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18171 break;
18172 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18173 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18174 break;
18175 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18176 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18177 break;
18178 case WMI_TDLS_ENTER_BUF_STA:
18179 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18180 break;
18181 case WMI_TDLS_EXIT_BUF_STA:
18182 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18183 break;
18184 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18185 param->peer_reason = TDLS_ENTER_BT_BUSY;
18186 break;
18187 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18188 param->peer_reason = TDLS_EXIT_BT_BUSY;
18189 break;
18190 case WMI_TDLS_SCAN_STARTED_EVENT:
18191 param->peer_reason = TDLS_SCAN_STARTED;
18192 break;
18193 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18194 param->peer_reason = TDLS_SCAN_COMPLETED;
18195 break;
18196
18197 default:
18198 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18199 __func__, evt->peer_reason, evt->peer_status);
18200 return QDF_STATUS_E_INVAL;
18201 };
18202
18203 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18204 __func__, param->peermac.bytes, param->message_type,
18205 param->peer_reason, param->vdev_id);
18206
18207 return QDF_STATUS_SUCCESS;
18208}
18209#endif
18210
Govind Singhe7f2f342016-05-23 12:12:52 +053018211/**
18212 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18213 * @wmi_handle: wmi handle
18214 * @param evt_buf: pointer to event buffer
18215 * @param param: Pointer to hold MGMT TX completion params
18216 *
18217 * Return: QDF_STATUS_SUCCESS for success or error code
18218 */
18219static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18220 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18221{
18222 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18223 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18224
18225 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18226 evt_buf;
18227 if (!param_buf) {
18228 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18229 return QDF_STATUS_E_INVAL;
18230 }
18231 cmpl_params = param_buf->fixed_param;
18232
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018233 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18234 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018235 param->desc_id = cmpl_params->desc_id;
18236 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018237 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018238
18239 return QDF_STATUS_SUCCESS;
18240}
18241
18242/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018243 * extract_offchan_data_tx_compl_param_tlv() -
18244 * extract Offchan data tx completion event params
18245 * @wmi_handle: wmi handle
18246 * @param evt_buf: pointer to event buffer
18247 * @param param: Pointer to hold offchan data TX completion params
18248 *
18249 * Return: QDF_STATUS_SUCCESS for success or error code
18250 */
18251static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18252 wmi_unified_t wmi_handle, void *evt_buf,
18253 struct wmi_host_offchan_data_tx_compl_event *param)
18254{
18255 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18256 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18257
18258 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18259 evt_buf;
18260 if (!param_buf) {
18261 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18262 return QDF_STATUS_E_INVAL;
18263 }
18264 cmpl_params = param_buf->fixed_param;
18265
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018266 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18267 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018268 param->desc_id = cmpl_params->desc_id;
18269 param->status = cmpl_params->status;
18270
18271 return QDF_STATUS_SUCCESS;
18272}
18273
18274/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018275 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18276 * status tlv
18277 * @wmi_handle: wmi handle
18278 * @param evt_buf: pointer to event buffer
18279 * @param param: Pointer to hold csa switch count status event param
18280 *
18281 * Return: QDF_STATUS_SUCCESS for success or error code
18282 */
18283static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18284 wmi_unified_t wmi_handle,
18285 void *evt_buf,
18286 struct pdev_csa_switch_count_status *param)
18287{
18288 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18289 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18290
18291 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18292 evt_buf;
18293 if (!param_buf) {
18294 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18295 return QDF_STATUS_E_INVAL;
18296 }
18297
18298 csa_status = param_buf->fixed_param;
18299
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018300 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18301 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018302 param->current_switch_count = csa_status->current_switch_count;
18303 param->num_vdevs = csa_status->num_vdevs;
18304 param->vdev_ids = param_buf->vdev_ids;
18305
18306 return QDF_STATUS_SUCCESS;
18307}
18308
18309/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018310 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18311 * param from event
18312 * @wmi_handle: wmi handle
18313 * @param evt_buf: pointer to event buffer
18314 * @param param: Pointer to hold tpc configuration
18315 *
18316 * Return: 0 for success or error code
18317 */
18318static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18319 void *evt_buf,
18320 wmi_host_pdev_tpc_config_event *param)
18321{
18322 wmi_pdev_tpc_config_event_fixed_param *event =
18323 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18324
18325 if (!event) {
18326 WMI_LOGE("Invalid event buffer");
18327 return QDF_STATUS_E_INVAL;
18328 }
18329
18330 param->pdev_id = event->pdev_id;
18331 param->regDomain = event->regDomain;
18332 param->chanFreq = event->chanFreq;
18333 param->phyMode = event->phyMode;
18334 param->twiceAntennaReduction = event->twiceAntennaReduction;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053018335 param->twiceAntennaGain = event->twiceAntennaGain;
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018336 param->twiceMaxRDPower = event->twiceMaxRDPower;
18337 param->powerLimit = event->powerLimit;
18338 param->rateMax = event->rateMax;
18339 param->numTxChain = event->numTxChain;
18340 param->ctl = event->ctl;
18341 param->flags = event->flags;
18342
18343 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18344 sizeof(param->maxRegAllowedPower));
18345 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18346 event->maxRegAllowedPowerAGCDD,
18347 sizeof(param->maxRegAllowedPowerAGCDD));
18348 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18349 event->maxRegAllowedPowerAGSTBC,
18350 sizeof(param->maxRegAllowedPowerAGSTBC));
18351 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18352 event->maxRegAllowedPowerAGTXBF,
18353 sizeof(param->maxRegAllowedPowerAGTXBF));
18354 WMI_LOGD("%s:extract success", __func__);
18355
18356 return QDF_STATUS_SUCCESS;
18357}
18358
18359/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018360 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018361 * @wmi_handle: wmi handle
18362 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018363 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018364 *
18365 * Return: QDF_STATUS_SUCCESS for success or error code
18366 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018367static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18368 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018369{
18370 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18371 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018372 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018373
18374 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18375 if (!param_buf) {
18376 WMI_LOGE("Invalid swba event buffer");
18377 return QDF_STATUS_E_INVAL;
18378 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018379
Govind Singhe7f2f342016-05-23 12:12:52 +053018380 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018381 *num_vdevs = swba_event->num_vdevs;
18382 if (!(*num_vdevs)) {
18383 vdev_map = swba_event->vdev_map;
18384 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18385 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018386
18387 return QDF_STATUS_SUCCESS;
18388}
18389
18390/**
18391 * extract_swba_tim_info_tlv() - extract swba tim info from event
18392 * @wmi_handle: wmi handle
18393 * @param evt_buf: pointer to event buffer
18394 * @param idx: Index to bcn info
18395 * @param tim_info: Pointer to hold tim info
18396 *
18397 * Return: QDF_STATUS_SUCCESS for success or error code
18398 */
18399static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18400 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18401{
18402 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18403 wmi_tim_info *tim_info_ev;
18404
18405 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18406 if (!param_buf) {
18407 WMI_LOGE("Invalid swba event buffer");
18408 return QDF_STATUS_E_INVAL;
18409 }
18410
18411 tim_info_ev = &param_buf->tim_info[idx];
18412
18413 tim_info->tim_len = tim_info_ev->tim_len;
18414 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18415 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18416 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18417 tim_info->tim_changed = tim_info_ev->tim_changed;
18418 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018419 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018420
18421 return QDF_STATUS_SUCCESS;
18422}
18423
18424/**
18425 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18426 * @wmi_handle: wmi handle
18427 * @param evt_buf: pointer to event buffer
18428 * @param idx: Index to bcn info
18429 * @param p2p_desc: Pointer to hold p2p NoA info
18430 *
18431 * Return: QDF_STATUS_SUCCESS for success or error code
18432 */
18433static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18434 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18435{
18436 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18437 wmi_p2p_noa_info *p2p_noa_info;
18438 uint8_t i = 0;
18439
18440 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18441 if (!param_buf) {
18442 WMI_LOGE("Invalid swba event buffer");
18443 return QDF_STATUS_E_INVAL;
18444 }
18445
18446 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18447
18448 p2p_desc->modified = false;
18449 p2p_desc->num_descriptors = 0;
18450 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18451 p2p_desc->modified = true;
18452 p2p_desc->index =
18453 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18454 p2p_desc->oppPS =
18455 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18456 p2p_desc->ctwindow =
18457 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18458 p2p_desc->num_descriptors =
18459 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18460 (p2p_noa_info);
18461 for (i = 0; i < p2p_desc->num_descriptors; i++) {
18462 p2p_desc->noa_descriptors[i].type_count =
18463 (uint8_t) p2p_noa_info->noa_descriptors[i].
18464 type_count;
18465 p2p_desc->noa_descriptors[i].duration =
18466 p2p_noa_info->noa_descriptors[i].duration;
18467 p2p_desc->noa_descriptors[i].interval =
18468 p2p_noa_info->noa_descriptors[i].interval;
18469 p2p_desc->noa_descriptors[i].start_time =
18470 p2p_noa_info->noa_descriptors[i].start_time;
18471 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018472 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018473 }
18474
18475 return QDF_STATUS_SUCCESS;
18476}
18477
Wu Gaocd3a8512017-03-13 20:17:34 +080018478#ifdef CONVERGED_P2P_ENABLE
18479/**
18480 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
18481 * @wmi_handle: wmi handle
18482 * @param evt_buf: pointer to event buffer
18483 * @param param: Pointer to hold p2p noa info
18484 *
18485 * Return: QDF_STATUS_SUCCESS for success or error code
18486 */
18487static QDF_STATUS extract_p2p_noa_ev_param_tlv(
18488 wmi_unified_t wmi_handle, void *evt_buf,
18489 struct p2p_noa_info *param)
18490{
18491 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
18492 wmi_p2p_noa_event_fixed_param *fixed_param;
18493 uint8_t i;
18494 wmi_p2p_noa_info *wmi_noa_info;
18495 uint8_t *buf_ptr;
18496 uint32_t descriptors;
18497
18498 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
18499 if (!param_tlvs) {
18500 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
18501 return QDF_STATUS_E_INVAL;
18502 }
18503
18504 if (!param) {
18505 WMI_LOGE("noa information param is null");
18506 return QDF_STATUS_E_INVAL;
18507 }
18508
18509 fixed_param = param_tlvs->fixed_param;
18510 buf_ptr = (uint8_t *) fixed_param;
18511 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
18512 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
18513
18514 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
18515 WMI_LOGE("%s: noa attr is not modified", __func__);
18516 return QDF_STATUS_E_INVAL;
18517 }
18518
18519 param->vdev_id = fixed_param->vdev_id;
18520 param->index =
18521 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
18522 param->opps_ps =
18523 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
18524 param->ct_window =
18525 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
18526 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
18527 param->num_desc = (uint8_t) descriptors;
18528
18529 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
18530 param->index, param->opps_ps, param->ct_window,
18531 param->num_desc);
18532 for (i = 0; i < param->num_desc; i++) {
18533 param->noa_desc[i].type_count =
18534 (uint8_t) wmi_noa_info->noa_descriptors[i].
18535 type_count;
18536 param->noa_desc[i].duration =
18537 wmi_noa_info->noa_descriptors[i].duration;
18538 param->noa_desc[i].interval =
18539 wmi_noa_info->noa_descriptors[i].interval;
18540 param->noa_desc[i].start_time =
18541 wmi_noa_info->noa_descriptors[i].start_time;
18542 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
18543 __func__, i, param->noa_desc[i].type_count,
18544 param->noa_desc[i].duration,
18545 param->noa_desc[i].interval,
18546 param->noa_desc[i].start_time);
18547 }
18548
18549 return QDF_STATUS_SUCCESS;
18550}
18551
Rachit Kankane9cd0c752018-07-31 16:26:38 +053018552#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +080018553/**
18554 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
18555 * information from event
18556 * @wmi_handle: wmi handle
18557 * @param evt_buf: pointer to event buffer
18558 * @param param: Pointer to hold p2p lo stop event information
18559 *
18560 * Return: QDF_STATUS_SUCCESS for success or error code
18561 */
18562static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
18563 wmi_unified_t wmi_handle, void *evt_buf,
18564 struct p2p_lo_event *param)
18565{
18566 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
18567 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
18568
18569 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
18570 evt_buf;
18571 if (!param_tlvs) {
18572 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
18573 return QDF_STATUS_E_INVAL;
18574 }
18575
18576 if (!param) {
18577 WMI_LOGE("lo stop event param is null");
18578 return QDF_STATUS_E_INVAL;
18579 }
18580
18581 lo_param = param_tlvs->fixed_param;
18582 param->vdev_id = lo_param->vdev_id;
18583 param->reason_code = lo_param->reason;
18584 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
18585 param->vdev_id, param->reason_code);
18586
18587 return QDF_STATUS_SUCCESS;
18588}
Rachit Kankane9cd0c752018-07-31 16:26:38 +053018589#endif
Wu Gaocd3a8512017-03-13 20:17:34 +080018590#endif /* End of CONVERGED_P2P_ENABLE */
18591
Govind Singhe7f2f342016-05-23 12:12:52 +053018592/**
18593 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
18594 * @wmi_handle: wmi handle
18595 * @param evt_buf: pointer to event buffer
18596 * @param ev: Pointer to hold peer param
18597 *
18598 * Return: QDF_STATUS_SUCCESS for success or error code
18599 */
18600static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
18601 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
18602{
18603 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
18604 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
18605
18606 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
18607 kickout_event = param_buf->fixed_param;
18608
18609 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
18610 ev->peer_macaddr);
18611
18612 ev->reason = kickout_event->reason;
18613 ev->rssi = kickout_event->rssi;
18614
18615 return QDF_STATUS_SUCCESS;
18616}
18617
18618/**
18619 * extract_all_stats_counts_tlv() - extract all stats count from event
18620 * @wmi_handle: wmi handle
18621 * @param evt_buf: pointer to event buffer
18622 * @param stats_param: Pointer to hold stats count
18623 *
18624 * Return: QDF_STATUS_SUCCESS for success or error code
18625 */
18626static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
18627 void *evt_buf, wmi_host_stats_event *stats_param)
18628{
Govind Singhe7f2f342016-05-23 12:12:52 +053018629 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018630 wmi_per_chain_rssi_stats *rssi_event;
18631 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018632
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018633 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053018634 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018635 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018636 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053018637 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018638 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053018639 return QDF_STATUS_E_FAILURE;
18640 }
18641
18642 switch (ev->stats_id) {
18643 case WMI_REQUEST_PEER_STAT:
18644 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
18645 break;
18646
18647 case WMI_REQUEST_AP_STAT:
18648 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
18649 break;
18650
18651 case WMI_REQUEST_PDEV_STAT:
18652 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
18653 break;
18654
18655 case WMI_REQUEST_VDEV_STAT:
18656 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
18657 break;
18658
18659 case WMI_REQUEST_BCNFLT_STAT:
18660 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
18661 break;
18662
18663 case WMI_REQUEST_VDEV_RATE_STAT:
18664 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
18665 break;
18666
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018667 case WMI_REQUEST_BCN_STAT:
18668 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
18669 break;
18670
Govind Singhe7f2f342016-05-23 12:12:52 +053018671 default:
18672 stats_param->stats_id = 0;
18673 break;
18674
18675 }
18676
18677 stats_param->num_pdev_stats = ev->num_pdev_stats;
18678 stats_param->num_pdev_ext_stats = 0;
18679 stats_param->num_vdev_stats = ev->num_vdev_stats;
18680 stats_param->num_peer_stats = ev->num_peer_stats;
18681 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18682 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018683 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018684 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18685 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018686
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018687 /* if chain_stats is not populated */
18688 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
18689 return QDF_STATUS_SUCCESS;
18690
18691 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
18692 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
18693 return QDF_STATUS_SUCCESS;
18694
18695 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -070018696 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018697 return QDF_STATUS_SUCCESS;
18698
18699 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
18700
Govind Singhe7f2f342016-05-23 12:12:52 +053018701 return QDF_STATUS_SUCCESS;
18702}
18703
18704/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018705 * extract_pdev_tx_stats() - extract pdev tx stats from event
18706 */
18707static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
18708{
18709 /* Tx Stats */
18710 tx->comp_queued = tx_stats->comp_queued;
18711 tx->comp_delivered = tx_stats->comp_delivered;
18712 tx->msdu_enqued = tx_stats->msdu_enqued;
18713 tx->mpdu_enqued = tx_stats->mpdu_enqued;
18714 tx->wmm_drop = tx_stats->wmm_drop;
18715 tx->local_enqued = tx_stats->local_enqued;
18716 tx->local_freed = tx_stats->local_freed;
18717 tx->hw_queued = tx_stats->hw_queued;
18718 tx->hw_reaped = tx_stats->hw_reaped;
18719 tx->underrun = tx_stats->underrun;
18720 tx->tx_abort = tx_stats->tx_abort;
18721 tx->mpdus_requed = tx_stats->mpdus_requed;
18722 tx->data_rc = tx_stats->data_rc;
18723 tx->self_triggers = tx_stats->self_triggers;
18724 tx->sw_retry_failure = tx_stats->sw_retry_failure;
18725 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
18726 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
18727 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
18728 tx->pdev_resets = tx_stats->pdev_resets;
18729 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
18730 tx->phy_underrun = tx_stats->phy_underrun;
18731 tx->txop_ovf = tx_stats->txop_ovf;
18732
18733 return;
18734}
18735
18736
18737/**
18738 * extract_pdev_rx_stats() - extract pdev rx stats from event
18739 */
18740static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
18741{
18742 /* Rx Stats */
18743 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
18744 rx->status_rcvd = rx_stats->status_rcvd;
18745 rx->r0_frags = rx_stats->r0_frags;
18746 rx->r1_frags = rx_stats->r1_frags;
18747 rx->r2_frags = rx_stats->r2_frags;
18748 /* Only TLV */
18749 rx->r3_frags = 0;
18750 rx->htt_msdus = rx_stats->htt_msdus;
18751 rx->htt_mpdus = rx_stats->htt_mpdus;
18752 rx->loc_msdus = rx_stats->loc_msdus;
18753 rx->loc_mpdus = rx_stats->loc_mpdus;
18754 rx->oversize_amsdu = rx_stats->oversize_amsdu;
18755 rx->phy_errs = rx_stats->phy_errs;
18756 rx->phy_err_drop = rx_stats->phy_err_drop;
18757 rx->mpdu_errs = rx_stats->mpdu_errs;
18758
18759 return;
18760}
18761
18762/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018763 * extract_pdev_stats_tlv() - extract pdev stats from event
18764 * @wmi_handle: wmi handle
18765 * @param evt_buf: pointer to event buffer
18766 * @param index: Index into pdev stats
18767 * @param pdev_stats: Pointer to hold pdev stats
18768 *
18769 * Return: QDF_STATUS_SUCCESS for success or error code
18770 */
18771static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
18772 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
18773{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018774 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18775 wmi_stats_event_fixed_param *ev_param;
18776 uint8_t *data;
18777
18778 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18779 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18780
18781 data = param_buf->data;
18782
18783 if (index < ev_param->num_pdev_stats) {
18784 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
18785 (index * sizeof(wmi_pdev_stats)));
18786
18787 pdev_stats->chan_nf = ev->chan_nf;
18788 pdev_stats->tx_frame_count = ev->tx_frame_count;
18789 pdev_stats->rx_frame_count = ev->rx_frame_count;
18790 pdev_stats->rx_clear_count = ev->rx_clear_count;
18791 pdev_stats->cycle_count = ev->cycle_count;
18792 pdev_stats->phy_err_count = ev->phy_err_count;
18793 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
18794
18795 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
18796 &(ev->pdev_stats.tx));
18797 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
18798 &(ev->pdev_stats.rx));
18799 }
18800
Govind Singhe7f2f342016-05-23 12:12:52 +053018801 return QDF_STATUS_SUCCESS;
18802}
18803
18804/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070018805 * extract_unit_test_tlv() - extract unit test data
18806 * @wmi_handle: wmi handle
18807 * @param evt_buf: pointer to event buffer
18808 * @param unit_test: pointer to hold unit test data
18809 * @param maxspace: Amount of space in evt_buf
18810 *
18811 * Return: QDF_STATUS_SUCCESS for success or error code
18812 */
18813static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
18814 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
18815{
18816 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
18817 wmi_unit_test_event_fixed_param *ev_param;
18818 uint32_t num_bufp;
18819 uint32_t copy_size;
18820 uint8_t *bufp;
18821
18822 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
18823 ev_param = param_buf->fixed_param;
18824 bufp = param_buf->bufp;
18825 num_bufp = param_buf->num_bufp;
18826 unit_test->vdev_id = ev_param->vdev_id;
18827 unit_test->module_id = ev_param->module_id;
18828 unit_test->diag_token = ev_param->diag_token;
18829 unit_test->flag = ev_param->flag;
18830 unit_test->payload_len = ev_param->payload_len;
18831 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
18832 ev_param->vdev_id,
18833 ev_param->module_id,
18834 ev_param->diag_token,
18835 ev_param->flag);
18836 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
18837 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
18838 bufp, num_bufp);
18839 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
18840 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
18841 unit_test->buffer_len = copy_size;
18842
18843 return QDF_STATUS_SUCCESS;
18844}
18845
18846/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018847 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
18848 * @wmi_handle: wmi handle
18849 * @param evt_buf: pointer to event buffer
18850 * @param index: Index into extended pdev stats
18851 * @param pdev_ext_stats: Pointer to hold extended pdev stats
18852 *
18853 * Return: QDF_STATUS_SUCCESS for success or error code
18854 */
18855static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
18856 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
18857{
18858 return QDF_STATUS_SUCCESS;
18859}
18860
18861/**
18862 * extract_vdev_stats_tlv() - extract vdev stats from event
18863 * @wmi_handle: wmi handle
18864 * @param evt_buf: pointer to event buffer
18865 * @param index: Index into vdev stats
18866 * @param vdev_stats: Pointer to hold vdev stats
18867 *
18868 * Return: QDF_STATUS_SUCCESS for success or error code
18869 */
18870static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
18871 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
18872{
18873 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18874 wmi_stats_event_fixed_param *ev_param;
18875 uint8_t *data;
18876
18877 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18878 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18879 data = (uint8_t *) param_buf->data;
18880
18881 if (index < ev_param->num_vdev_stats) {
18882 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
18883 ((ev_param->num_pdev_stats) *
18884 sizeof(wmi_pdev_stats)) +
18885 (index * sizeof(wmi_vdev_stats)));
18886
18887 vdev_stats->vdev_id = ev->vdev_id;
18888 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
18889 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
18890
18891 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
18892 sizeof(ev->tx_frm_cnt));
18893 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
18894 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
18895 ev->multiple_retry_cnt,
18896 sizeof(ev->multiple_retry_cnt));
18897 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
18898 sizeof(ev->fail_cnt));
18899 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
18900 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
18901 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
18902 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
18903 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
18904 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
18905 sizeof(ev->tx_rate_history));
18906 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
18907 sizeof(ev->bcn_rssi_history));
18908
18909 }
18910
18911 return QDF_STATUS_SUCCESS;
18912}
18913
18914/**
Naveen Rawatd2115722018-04-12 08:17:55 -070018915 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
18916 * buffer
18917 * @wmi_handle: wmi handle
18918 * @evt_buf: pointer to event buffer
18919 * @index: Index into vdev stats
18920 * @rssi_stats: Pointer to hold rssi stats
18921 *
18922 * Return: QDF_STATUS_SUCCESS for success or error code
18923 */
18924static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
18925 void *evt_buf, uint32_t index,
18926 struct wmi_host_per_chain_rssi_stats *rssi_stats)
18927{
18928 uint8_t *data;
18929 wmi_rssi_stats *fw_rssi_stats;
18930 wmi_per_chain_rssi_stats *rssi_event;
18931 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18932
18933 if (!evt_buf) {
18934 WMI_LOGE("evt_buf is null");
18935 return QDF_STATUS_E_NULL_VALUE;
18936 }
18937
18938 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18939 rssi_event = param_buf->chain_stats;
18940
18941 if (index >= rssi_event->num_per_chain_rssi_stats) {
18942 WMI_LOGE("invalid index");
18943 return QDF_STATUS_E_INVAL;
18944 }
18945
18946 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
18947 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
18948
18949 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
18950 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
18951 fw_rssi_stats->rssi_avg_beacon,
18952 sizeof(fw_rssi_stats->rssi_avg_beacon));
18953 qdf_mem_copy(rssi_stats->rssi_avg_data,
18954 fw_rssi_stats->rssi_avg_data,
18955 sizeof(fw_rssi_stats->rssi_avg_data));
18956 qdf_mem_copy(&rssi_stats->peer_macaddr,
18957 &fw_rssi_stats->peer_macaddr,
18958 sizeof(fw_rssi_stats->peer_macaddr));
18959
18960 return QDF_STATUS_SUCCESS;
18961}
18962
18963
18964
18965/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018966 * extract_bcn_stats_tlv() - extract bcn stats from event
18967 * @wmi_handle: wmi handle
18968 * @param evt_buf: pointer to event buffer
18969 * @param index: Index into vdev stats
18970 * @param bcn_stats: Pointer to hold bcn stats
18971 *
18972 * Return: QDF_STATUS_SUCCESS for success or error code
18973 */
18974static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
18975 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
18976{
18977 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18978 wmi_stats_event_fixed_param *ev_param;
18979 uint8_t *data;
18980
18981 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18982 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18983 data = (uint8_t *) param_buf->data;
18984
18985 if (index < ev_param->num_bcn_stats) {
18986 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
18987 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18988 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18989 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
18990 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
18991 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
18992 (index * sizeof(wmi_bcn_stats)));
18993
18994 bcn_stats->vdev_id = ev->vdev_id;
18995 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
18996 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
18997 }
18998
18999 return QDF_STATUS_SUCCESS;
19000}
19001
19002/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019003 * extract_peer_stats_tlv() - extract peer stats from event
19004 * @wmi_handle: wmi handle
19005 * @param evt_buf: pointer to event buffer
19006 * @param index: Index into peer stats
19007 * @param peer_stats: Pointer to hold peer stats
19008 *
19009 * Return: QDF_STATUS_SUCCESS for success or error code
19010 */
19011static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19012 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19013{
19014 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19015 wmi_stats_event_fixed_param *ev_param;
19016 uint8_t *data;
19017
19018 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19019 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19020 data = (uint8_t *) param_buf->data;
19021
19022 if (index < ev_param->num_peer_stats) {
19023 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19024 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19025 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19026 (index * sizeof(wmi_peer_stats)));
19027
19028 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19029
19030 OS_MEMCPY(&(peer_stats->peer_macaddr),
19031 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19032
19033 peer_stats->peer_rssi = ev->peer_rssi;
19034 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19035 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19036 }
19037
19038 return QDF_STATUS_SUCCESS;
19039}
19040
19041/**
19042 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19043 * @wmi_handle: wmi handle
19044 * @param evt_buf: pointer to event buffer
19045 * @param index: Index into bcn fault stats
19046 * @param bcnflt_stats: Pointer to hold bcn fault stats
19047 *
19048 * Return: QDF_STATUS_SUCCESS for success or error code
19049 */
19050static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19051 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19052{
19053 return QDF_STATUS_SUCCESS;
19054}
19055
19056/**
19057 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19058 * @wmi_handle: wmi handle
19059 * @param evt_buf: pointer to event buffer
19060 * @param index: Index into extended peer stats
19061 * @param peer_extd_stats: Pointer to hold extended peer stats
19062 *
19063 * Return: QDF_STATUS_SUCCESS for success or error code
19064 */
19065static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19066 void *evt_buf, uint32_t index,
19067 wmi_host_peer_extd_stats *peer_extd_stats)
19068{
19069 return QDF_STATUS_SUCCESS;
19070}
19071
19072/**
19073 * extract_chan_stats_tlv() - extract chan stats from event
19074 * @wmi_handle: wmi handle
19075 * @param evt_buf: pointer to event buffer
19076 * @param index: Index into chan stats
19077 * @param vdev_extd_stats: Pointer to hold chan stats
19078 *
19079 * Return: QDF_STATUS_SUCCESS for success or error code
19080 */
19081static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19082 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19083{
19084 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19085 wmi_stats_event_fixed_param *ev_param;
19086 uint8_t *data;
19087
19088 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19089 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19090 data = (uint8_t *) param_buf->data;
19091
19092 if (index < ev_param->num_chan_stats) {
19093 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19094 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19095 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19096 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19097 (index * sizeof(wmi_chan_stats)));
19098
19099
Jeff Johnson79eaacb2018-05-06 17:53:18 -070019100 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +053019101 chan_stats->chan_mhz = ev->chan_mhz;
19102 chan_stats->sampling_period_us = ev->sampling_period_us;
19103 chan_stats->rx_clear_count = ev->rx_clear_count;
19104 chan_stats->tx_duration_us = ev->tx_duration_us;
19105 chan_stats->rx_duration_us = ev->rx_duration_us;
19106 }
19107
19108 return QDF_STATUS_SUCCESS;
19109}
19110
19111/**
19112 * extract_profile_ctx_tlv() - extract profile context from event
19113 * @wmi_handle: wmi handle
19114 * @param evt_buf: pointer to event buffer
19115 * @idx: profile stats index to extract
19116 * @param profile_ctx: Pointer to hold profile context
19117 *
19118 * Return: QDF_STATUS_SUCCESS for success or error code
19119 */
19120static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19121 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19122{
19123 return QDF_STATUS_SUCCESS;
19124}
19125
19126/**
19127 * extract_profile_data_tlv() - extract profile data from event
19128 * @wmi_handle: wmi handle
19129 * @param evt_buf: pointer to event buffer
19130 * @param profile_data: Pointer to hold profile data
19131 *
19132 * Return: QDF_STATUS_SUCCESS for success or error code
19133 */
19134static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19135 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19136{
19137
19138 return QDF_STATUS_SUCCESS;
19139}
19140
19141/**
19142 * extract_chan_info_event_tlv() - extract chan information from event
19143 * @wmi_handle: wmi handle
19144 * @param evt_buf: pointer to event buffer
19145 * @param chan_info: Pointer to hold chan information
19146 *
19147 * Return: QDF_STATUS_SUCCESS for success or error code
19148 */
19149static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19150 void *evt_buf, wmi_host_chan_info_event *chan_info)
19151{
19152 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19153 wmi_chan_info_event_fixed_param *ev;
19154
19155 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19156
19157 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19158 if (!ev) {
19159 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19160 return QDF_STATUS_E_FAILURE;
19161 }
19162
19163 chan_info->err_code = ev->err_code;
19164 chan_info->freq = ev->freq;
19165 chan_info->cmd_flags = ev->cmd_flags;
19166 chan_info->noise_floor = ev->noise_floor;
19167 chan_info->rx_clear_count = ev->rx_clear_count;
19168 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019169 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19170 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019171 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19172 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19173 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019174 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19175 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19176 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19177 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19178 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19179 chan_info->rx_frame_count = ev->rx_frame_count;
19180 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19181 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019182
19183 return QDF_STATUS_SUCCESS;
19184}
19185
19186/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019187 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19188 * @wmi_handle: WMI handle
19189 * @param evt_buf: Pointer to event buffer
19190 * @param param: Pointer to hold data
19191 *
19192 * Return : QDF_STATUS_SUCCESS for success or error code
19193 */
19194static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19195 uint8_t *evt_buf,
19196 struct wmi_host_pdev_utf_event *event)
19197{
19198 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019199 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019200
19201 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19202 event->data = param_buf->data;
19203 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019204 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019205 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019206 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019207 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019208
19209 return QDF_STATUS_SUCCESS;
19210}
Govind Singhe7f2f342016-05-23 12:12:52 +053019211
Kiran Venkatappa06520822016-08-10 23:55:40 +053019212/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019213 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19214 * @wmi_handle: wmi handle
19215 * @param evt_buf: pointer to event buffer
19216 * @param param: Pointer to hold evt buf
19217 *
19218 * Return: QDF_STATUS_SUCCESS for success or error code
19219 */
19220static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19221 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19222{
19223 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19224 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19225 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19226 uint8_t i = 0, j = 0;
19227
19228 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19229 if (!param_buf)
19230 return QDF_STATUS_E_INVAL;
19231
19232 hw_caps = param_buf->soc_hw_mode_caps;
19233 if (!hw_caps)
19234 return QDF_STATUS_E_INVAL;
19235
19236 if (!hw_caps->num_chainmask_tables)
19237 return QDF_STATUS_E_INVAL;
19238
19239 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19240
19241 if (chainmask_caps == NULL)
19242 return QDF_STATUS_E_INVAL;
19243
19244 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19245
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019246 qdf_print("Dumping chain mask combo data for table : %d", i);
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019247 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19248
19249 chainmask_table[i].cap_list[j].chainmask =
19250 chainmask_caps->chainmask;
19251
19252 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19253 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19254
19255 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19256 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19257
19258 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19259 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19260
19261 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19262 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19263
19264 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19265 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19266
19267 chainmask_table[i].cap_list[j].chain_mask_2G =
19268 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19269
19270 chainmask_table[i].cap_list[j].chain_mask_5G =
19271 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19272
19273 chainmask_table[i].cap_list[j].chain_mask_tx =
19274 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19275
19276 chainmask_table[i].cap_list[j].chain_mask_rx =
19277 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19278
19279 chainmask_table[i].cap_list[j].supports_aDFS =
19280 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19281
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019282 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x",
19283 chainmask_caps->supported_flags,
19284 chainmask_caps->chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019285 );
19286 chainmask_caps++;
19287 }
19288 }
19289
19290 return QDF_STATUS_SUCCESS;
19291}
19292
19293/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019294 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19295 * from event
19296 * @wmi_handle: wmi handle
19297 * @param evt_buf: pointer to event buffer
19298 * @param param: Pointer to hold evt buf
19299 *
19300 * Return: QDF_STATUS_SUCCESS for success or error code
19301 */
19302static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019303 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019304{
19305 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19306 wmi_service_ready_ext_event_fixed_param *ev;
19307 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19308 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019309 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19310 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019311
19312 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19313 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019314 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019315
19316 ev = param_buf->fixed_param;
19317 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019318 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019319
19320 /* Move this to host based bitmap */
19321 param->default_conc_scan_config_bits =
19322 ev->default_conc_scan_config_bits;
19323 param->default_fw_config_bits = ev->default_fw_config_bits;
19324 param->he_cap_info = ev->he_cap_info;
19325 param->mpdu_density = ev->mpdu_density;
19326 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019327 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019328 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -070019329 param->max_bssid_indicator = ev->max_bssid_indicator;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019330 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19331
19332 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019333 if (hw_caps)
19334 param->num_hw_modes = hw_caps->num_hw_modes;
19335 else
19336 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019337
19338 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019339 if (reg_caps)
19340 param->num_phy = reg_caps->num_phy;
19341 else
19342 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019343
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019344 if (hw_caps) {
19345 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019346 qdf_print("Num chain mask tables: %d", hw_caps->num_chainmask_tables);
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019347 } else
19348 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019349
19350 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19351
19352 if (chain_mask_combo == NULL)
19353 return QDF_STATUS_SUCCESS;
19354
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019355 qdf_print("Dumping chain mask combo data");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019356
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019357 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019358
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019359 qdf_print("table_id : %d Num valid chainmasks: %d",
19360 chain_mask_combo->chainmask_table_id,
19361 chain_mask_combo->num_valid_chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019362 );
19363
19364 param->chainmask_table[i].table_id =
19365 chain_mask_combo->chainmask_table_id;
19366 param->chainmask_table[i].num_valid_chainmasks =
19367 chain_mask_combo->num_valid_chainmask;
19368 chain_mask_combo++;
19369 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019370 qdf_print("chain mask combo end");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019371
Kiran Venkatappa06520822016-08-10 23:55:40 +053019372 return QDF_STATUS_SUCCESS;
19373}
19374
19375/**
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019376 * extract_sar_cap_service_ready_ext_tlv() -
19377 * extract SAR cap from service ready event
19378 * @wmi_handle: wmi handle
19379 * @event: pointer to event buffer
19380 * @ext_param: extended target info
19381 *
19382 * Return: QDF_STATUS_SUCCESS for success or error code
19383 */
19384static QDF_STATUS extract_sar_cap_service_ready_ext_tlv(
19385 wmi_unified_t wmi_handle,
19386 uint8_t *event,
19387 struct wlan_psoc_host_service_ext_param *ext_param)
19388{
19389 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19390 WMI_SAR_CAPABILITIES *sar_caps;
19391
19392 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19393
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019394 if (!param_buf)
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019395 return QDF_STATUS_E_INVAL;
19396
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019397 sar_caps = param_buf->sar_caps;
19398 if (sar_caps)
19399 ext_param->sar_version = sar_caps->active_version;
19400 else
19401 ext_param->sar_version = 0;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019402
19403 return QDF_STATUS_SUCCESS;
19404}
19405
19406/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019407 * extract_hw_mode_cap_service_ready_ext_tlv() -
19408 * extract HW mode cap from service ready event
19409 * @wmi_handle: wmi handle
19410 * @param evt_buf: pointer to event buffer
19411 * @param param: Pointer to hold evt buf
19412 * @param hw_mode_idx: hw mode idx should be less than num_mode
19413 *
19414 * Return: QDF_STATUS_SUCCESS for success or error code
19415 */
19416static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19417 wmi_unified_t wmi_handle,
19418 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019419 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019420{
19421 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19422 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19423
19424 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19425 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019426 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019427
19428 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019429 if (!hw_caps)
19430 return QDF_STATUS_E_INVAL;
19431
Kiran Venkatappa06520822016-08-10 23:55:40 +053019432 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019433 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019434
19435 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19436 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19437
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019438 param->hw_mode_config_type =
19439 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19440
Kiran Venkatappa06520822016-08-10 23:55:40 +053019441 return QDF_STATUS_SUCCESS;
19442}
19443
19444/**
19445 * extract_mac_phy_cap_service_ready_ext_tlv() -
19446 * extract MAC phy cap from service ready event
19447 * @wmi_handle: wmi handle
19448 * @param evt_buf: pointer to event buffer
19449 * @param param: Pointer to hold evt buf
19450 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019451 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019452 *
19453 * Return: QDF_STATUS_SUCCESS for success or error code
19454 */
19455static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19456 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019457 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019458 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019459{
19460 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019461 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019462 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19463 uint32_t phy_map;
19464 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019465
19466 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19467 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019468 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019469
19470 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019471 if (!hw_caps)
19472 return QDF_STATUS_E_INVAL;
19473
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019474 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19475 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19476 break;
19477
19478 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19479 while (phy_map) {
19480 phy_map >>= 1;
19481 phy_idx++;
19482 }
19483 }
19484
19485 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019486 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019487
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019488 phy_idx += phy_id;
19489 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019490 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019491
19492 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019493
19494 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019495 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19496 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019497 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019498 param->supports_11b =
19499 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19500 param->supports_11g =
19501 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19502 param->supports_11a =
19503 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19504 param->supports_11n =
19505 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19506 param->supports_11ac =
19507 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19508 param->supports_11ax =
19509 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019510
19511 param->supported_bands = mac_phy_caps->supported_bands;
19512 param->ampdu_density = mac_phy_caps->ampdu_density;
19513 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19514 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19515 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19516 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19517 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19518 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19519 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19520 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19521 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19522 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19523 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19524 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19525 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19526 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19527 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19528 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019529 qdf_mem_copy(&param->he_cap_phy_info_2G,
19530 &mac_phy_caps->he_cap_phy_info_2G,
19531 sizeof(param->he_cap_phy_info_2G));
19532 qdf_mem_copy(&param->he_cap_phy_info_5G,
19533 &mac_phy_caps->he_cap_phy_info_5G,
19534 sizeof(param->he_cap_phy_info_5G));
19535 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19536 sizeof(param->he_ppet2G));
19537 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19538 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019539 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019540
19541 return QDF_STATUS_SUCCESS;
19542}
19543
19544/**
19545 * extract_reg_cap_service_ready_ext_tlv() -
19546 * extract REG cap from service ready event
19547 * @wmi_handle: wmi handle
19548 * @param evt_buf: pointer to event buffer
19549 * @param param: Pointer to hold evt buf
19550 * @param phy_idx: phy idx should be less than num_mode
19551 *
19552 * Return: QDF_STATUS_SUCCESS for success or error code
19553 */
19554static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
19555 wmi_unified_t wmi_handle,
19556 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019557 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019558{
19559 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19560 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
19561 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
19562
19563 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19564 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019565 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019566
19567 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019568 if (!reg_caps)
19569 return QDF_STATUS_E_INVAL;
19570
Kiran Venkatappa06520822016-08-10 23:55:40 +053019571 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019572 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019573
19574 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
19575
19576 param->phy_id = ext_reg_cap->phy_id;
19577 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
19578 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
19579 param->regcap1 = ext_reg_cap->regcap1;
19580 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053019581 param->wireless_modes = convert_wireless_modes_tlv(
19582 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019583 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
19584 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
19585 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
19586 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
19587
19588 return QDF_STATUS_SUCCESS;
19589}
19590
Sathish Kumarf396c722017-11-17 17:30:41 +053019591static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
19592 wmi_unified_t wmi_handle,
19593 uint8_t *event, uint8_t idx,
19594 struct wlan_psoc_host_dbr_ring_caps *param)
19595{
19596 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19597 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
19598
19599 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19600 if (!param_buf)
19601 return QDF_STATUS_E_INVAL;
19602
19603 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
19604
19605 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19606 dbr_ring_caps->pdev_id);
19607 param->mod_id = dbr_ring_caps->mod_id;
19608 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
19609 param->min_buf_size = dbr_ring_caps->min_buf_size;
19610 param->min_buf_align = dbr_ring_caps->min_buf_align;
19611
19612 return QDF_STATUS_SUCCESS;
19613}
19614
19615static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
19616 uint8_t *event, struct direct_buf_rx_rsp *param)
19617{
19618 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19619 wmi_dma_buf_release_fixed_param *ev;
19620
19621 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19622 if (!param_buf)
19623 return QDF_STATUS_E_INVAL;
19624
19625 ev = param_buf->fixed_param;
19626 if (!ev)
19627 return QDF_STATUS_E_INVAL;
19628
19629 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19630 ev->pdev_id);
19631 param->mod_id = ev->mod_id;
19632 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019633 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053019634 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
19635 param->pdev_id, param->mod_id, param->num_buf_release_entry);
19636
19637 return QDF_STATUS_SUCCESS;
19638}
19639
19640static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
19641 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
19642{
19643 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19644 wmi_dma_buf_release_entry *entry;
19645
19646 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19647 if (!param_buf)
19648 return QDF_STATUS_E_INVAL;
19649
19650 entry = &param_buf->entries[idx];
19651
19652 if (!entry) {
19653 WMI_LOGE("%s: Entry is NULL\n", __func__);
19654 return QDF_STATUS_E_FAILURE;
19655 }
19656
19657 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
19658
19659 param->paddr_lo = entry->paddr_lo;
19660 param->paddr_hi = entry->paddr_hi;
19661
19662 return QDF_STATUS_SUCCESS;
19663}
19664
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019665static QDF_STATUS extract_dbr_buf_metadata_tlv(
19666 wmi_unified_t wmi_handle, uint8_t *event,
19667 uint8_t idx, struct direct_buf_rx_metadata *param)
19668{
19669 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19670 wmi_dma_buf_release_spectral_meta_data *entry;
19671
19672 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19673 if (!param_buf)
19674 return QDF_STATUS_E_INVAL;
19675
19676 entry = &param_buf->meta_data[idx];
19677
19678 if (!entry) {
19679 WMI_LOGE("%s: Entry is NULL\n", __func__);
19680 return QDF_STATUS_E_FAILURE;
19681 }
19682
19683 qdf_mem_copy(param->noisefloor, entry->noise_floor,
19684 sizeof(entry->noise_floor));
19685 return QDF_STATUS_SUCCESS;
19686}
19687
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019688/**
19689 * extract_dcs_interference_type_tlv() - extract dcs interference type
19690 * from event
19691 * @wmi_handle: wmi handle
19692 * @param evt_buf: pointer to event buffer
19693 * @param param: Pointer to hold dcs interference param
19694 *
19695 * Return: 0 for success or error code
19696 */
19697static QDF_STATUS extract_dcs_interference_type_tlv(
19698 wmi_unified_t wmi_handle,
19699 void *evt_buf, struct wmi_host_dcs_interference_param *param)
19700{
19701 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19702
19703 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19704 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019705 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019706
19707 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019708 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19709 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019710
19711 return QDF_STATUS_SUCCESS;
19712}
19713
19714/*
19715 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
19716 * @wmi_handle: wmi handle
19717 * @param evt_buf: pointer to event buffer
19718 * @param cw_int: Pointer to hold cw interference
19719 *
19720 * Return: 0 for success or error code
19721 */
19722static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
19723 void *evt_buf,
19724 wmi_host_ath_dcs_cw_int *cw_int)
19725{
19726 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19727 wlan_dcs_cw_int *ev;
19728
19729 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19730 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019731 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019732
19733 ev = param_buf->cw_int;
19734
19735 cw_int->channel = ev->channel;
19736
19737 return QDF_STATUS_SUCCESS;
19738}
19739
19740/**
19741 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
19742 * @wmi_handle: wmi handle
19743 * @param evt_buf: pointer to event buffer
19744 * @param wlan_stat: Pointer to hold wlan stats
19745 *
19746 * Return: 0 for success or error code
19747 */
19748static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
19749 void *evt_buf,
19750 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
19751{
19752 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19753 wlan_dcs_im_tgt_stats_t *ev;
19754
19755 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19756 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019757 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019758
19759 ev = param_buf->wlan_stat;
19760 wlan_stat->reg_tsf32 = ev->reg_tsf32;
19761 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
19762 wlan_stat->tx_waste_time = ev->tx_waste_time;
19763 wlan_stat->rx_time = ev->rx_time;
19764 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
19765 wlan_stat->mib_stats.listen_time = ev->listen_time;
19766 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
19767 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
19768 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
19769 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
19770 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
19771 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
19772 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
19773 wlan_stat->chan_nf = ev->chan_nf;
19774 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19775
19776 return QDF_STATUS_SUCCESS;
19777}
19778
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019779/**
19780 * extract_thermal_stats_tlv() - extract thermal stats from event
19781 * @wmi_handle: wmi handle
19782 * @param evt_buf: Pointer to event buffer
19783 * @param temp: Pointer to hold extracted temperature
19784 * @param level: Pointer to hold extracted level
19785 *
19786 * Return: 0 for success or error code
19787 */
19788static QDF_STATUS
19789extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
19790 void *evt_buf, uint32_t *temp,
19791 uint32_t *level, uint32_t *pdev_id)
19792{
19793 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19794 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
19795
19796 param_buf =
19797 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19798 if (!param_buf)
19799 return QDF_STATUS_E_INVAL;
19800
19801 tt_stats_event = param_buf->fixed_param;
19802
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019803 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19804 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019805 *temp = tt_stats_event->temp;
19806 *level = tt_stats_event->level;
19807
19808 return QDF_STATUS_SUCCESS;
19809}
19810
19811/**
19812 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
19813 * @wmi_handle: wmi handle
19814 * @param evt_buf: pointer to event buffer
19815 * @param idx: Index to level stats
19816 * @param levelcount: Pointer to hold levelcount
19817 * @param dccount: Pointer to hold dccount
19818 *
19819 * Return: 0 for success or error code
19820 */
19821static QDF_STATUS
19822extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
19823 void *evt_buf, uint8_t idx, uint32_t *levelcount,
19824 uint32_t *dccount)
19825{
19826 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19827 wmi_therm_throt_level_stats_info *tt_level_info;
19828
19829 param_buf =
19830 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19831 if (!param_buf)
19832 return QDF_STATUS_E_INVAL;
19833
19834 tt_level_info = param_buf->therm_throt_level_stats_info;
19835
19836 if (idx < THERMAL_LEVELS) {
19837 *levelcount = tt_level_info[idx].level_count;
19838 *dccount = tt_level_info[idx].dc_count;
19839 return QDF_STATUS_SUCCESS;
19840 }
19841
19842 return QDF_STATUS_E_FAILURE;
19843}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019844#ifdef BIG_ENDIAN_HOST
19845/**
19846 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
19847 * @param data_len - data length
19848 * @param data - pointer to data
19849 *
19850 * Return: QDF_STATUS - success or error status
19851 */
19852static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19853{
19854 uint8_t *data_aligned = NULL;
19855 int c;
19856 unsigned char *data_unaligned;
19857
19858 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
19859 FIPS_ALIGN));
19860 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -070019861 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019862 if (data_unaligned == NULL)
19863 return QDF_STATUS_E_FAILURE;
19864
19865 /* Checking if space is alligned */
19866 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
19867 /* align the data space */
19868 data_aligned =
19869 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
19870 } else {
19871 data_aligned = (u_int8_t *)data_unaligned;
19872 }
19873
19874 /* memset and copy content from data to data aligned */
19875 OS_MEMSET(data_aligned, 0, data_len);
19876 OS_MEMCPY(data_aligned, data, data_len);
19877 /* Endianness to LE */
19878 for (c = 0; c < data_len/4; c++) {
19879 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019880 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019881 }
19882
19883 /* Copy content to event->data */
19884 OS_MEMCPY(data, data_aligned, data_len);
19885
19886 /* clean up allocated space */
19887 qdf_mem_free(data_unaligned);
19888 data_aligned = NULL;
19889 data_unaligned = NULL;
19890
19891 /*************************************************************/
19892
19893 return QDF_STATUS_SUCCESS;
19894}
19895#else
19896/**
19897 * fips_conv_data_be() - DUMMY for LE platform
19898 *
19899 * Return: QDF_STATUS - success
19900 */
19901static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19902{
19903 return QDF_STATUS_SUCCESS;
19904}
19905#endif
19906
19907/**
19908 * extract_fips_event_data_tlv() - extract fips event data
19909 * @wmi_handle: wmi handle
19910 * @param evt_buf: pointer to event buffer
19911 * @param param: pointer FIPS event params
19912 *
19913 * Return: 0 for success or error code
19914 */
19915static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
19916 void *evt_buf, struct wmi_host_fips_event_param *param)
19917{
19918 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
19919 wmi_pdev_fips_event_fixed_param *event;
19920
19921 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
19922 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
19923
19924 if (fips_conv_data_be(event->data_len, param_buf->data) !=
19925 QDF_STATUS_SUCCESS)
19926 return QDF_STATUS_E_FAILURE;
19927
19928 param->data = (uint32_t *)param_buf->data;
19929 param->data_len = event->data_len;
19930 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019931 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19932 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019933
19934 return QDF_STATUS_SUCCESS;
19935}
19936
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019937/*
19938 * extract_peer_delete_response_event_tlv() - extract peer delete response event
19939 * @wmi_handle: wmi handle
19940 * @param evt_buf: pointer to event buffer
19941 * @param vdev_id: Pointer to hold vdev_id
19942 * @param mac_addr: Pointer to hold peer mac address
19943 *
19944 * Return: QDF_STATUS_SUCCESS for success or error code
19945 */
19946static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
19947 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
19948{
19949 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
19950 wmi_peer_delete_resp_event_fixed_param *ev;
19951
19952 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
19953
19954 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
19955 if (!ev) {
19956 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
19957 return QDF_STATUS_E_FAILURE;
19958 }
19959
19960 param->vdev_id = ev->vdev_id;
19961 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
19962 &param->mac_address.bytes[0]);
19963
19964 return QDF_STATUS_SUCCESS;
19965}
19966
Govind Singhecf03cd2016-05-12 12:45:51 +053019967static bool is_management_record_tlv(uint32_t cmd_id)
19968{
jiad36c94d22018-01-22 15:37:03 +080019969 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
19970 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
19971 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053019972 return true;
jiad36c94d22018-01-22 15:37:03 +080019973 }
Govind Singhe7f2f342016-05-23 12:12:52 +053019974
Govind Singhecf03cd2016-05-12 12:45:51 +053019975 return false;
19976}
19977
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053019978static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19979{
19980 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
19981
19982 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
19983
19984 switch (set_cmd->param_id) {
19985 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
19986 case WMI_VDEV_PARAM_DTIM_POLICY:
19987 return HTC_TX_PACKET_TAG_AUTO_PM;
19988 default:
19989 break;
19990 }
19991
19992 return 0;
19993}
19994
19995static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19996{
19997 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
19998
19999 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20000
20001 switch (ps_cmd->param) {
20002 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20003 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20004 case WMI_STA_PS_ENABLE_QPOWER:
20005 return HTC_TX_PACKET_TAG_AUTO_PM;
20006 default:
20007 break;
20008 }
20009
20010 return 0;
20011}
20012
20013static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20014 uint32_t cmd_id)
20015{
20016 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20017 return 0;
20018
20019 switch (cmd_id) {
20020 case WMI_VDEV_SET_PARAM_CMDID:
20021 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20022 case WMI_STA_POWERSAVE_PARAM_CMDID:
20023 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20024 default:
20025 break;
20026 }
20027
20028 return 0;
20029}
20030
20031static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20032{
20033 uint16_t tag = 0;
20034
20035 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20036 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20037 __func__);
20038 return tag;
20039 }
20040
20041 if (wmi_handle->tag_crash_inject)
20042 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20043
20044 wmi_handle->tag_crash_inject = false;
20045 return tag;
20046}
20047
20048/**
20049 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20050 * @wmi_handle: WMI handle
20051 * @buf: WMI buffer
20052 * @cmd_id: WMI command Id
20053 *
20054 * Return htc_tx_tag
20055 */
20056static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20057 wmi_buf_t buf,
20058 uint32_t cmd_id)
20059{
20060 uint16_t htc_tx_tag = 0;
20061
20062 switch (cmd_id) {
20063 case WMI_WOW_ENABLE_CMDID:
20064 case WMI_PDEV_SUSPEND_CMDID:
20065 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20066 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20067 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20068 case WMI_PDEV_RESUME_CMDID:
20069 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20070 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20071#ifdef FEATURE_WLAN_D0WOW
20072 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20073#endif
20074 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20075 break;
20076 case WMI_FORCE_FW_HANG_CMDID:
20077 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20078 break;
20079 case WMI_VDEV_SET_PARAM_CMDID:
20080 case WMI_STA_POWERSAVE_PARAM_CMDID:
20081 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20082 default:
20083 break;
20084 }
20085
20086 return htc_tx_tag;
20087}
20088
Sathish Kumard3ab1002017-02-07 17:10:59 +053020089/**
20090 * extract_channel_hopping_event_tlv() - extract channel hopping param
20091 * from event
20092 * @wmi_handle: wmi handle
20093 * @param evt_buf: pointer to event buffer
20094 * @param ch_hopping: Pointer to hold channel hopping param
20095 *
20096 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20097 */
20098static QDF_STATUS extract_channel_hopping_event_tlv(
20099 wmi_unified_t wmi_handle, void *evt_buf,
20100 wmi_host_pdev_channel_hopping_event *ch_hopping)
20101{
20102 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20103 wmi_pdev_channel_hopping_event_fixed_param *event;
20104
20105 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20106 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20107 param_buf->fixed_param;
20108
20109 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20110 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020111 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20112 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020113
20114 return QDF_STATUS_SUCCESS;
20115}
20116
20117/**
20118 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20119 * @wmi_handle: wmi handle
20120 * @param evt_buf: pointer to event buffer
20121 * @param param: Pointer to hold tpc param
20122 *
20123 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20124 */
20125static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20126 void *evt_buf,
20127 wmi_host_pdev_tpc_event *param)
20128{
20129 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20130 wmi_pdev_tpc_event_fixed_param *event;
20131
20132 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20133 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20134
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020135 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20136 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020137 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20138
20139 return QDF_STATUS_SUCCESS;
20140}
20141
nobeljf74583b2018-01-25 16:35:36 -080020142/**
20143 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20144 * power param from event
20145 * @wmi_handle: wmi handle
20146 * @param evt_buf: pointer to event buffer
20147 * @param param: Pointer to hold nf cal power param
20148 *
20149 * Return: 0 for success or error code
20150 */
20151static QDF_STATUS
20152extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20153 void *evt_buf,
20154 wmi_host_pdev_nfcal_power_all_channels_event *param)
20155{
20156 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20157 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20158 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20159 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20160 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20161 uint32_t i;
20162
20163 param_buf =
20164 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20165 event = param_buf->fixed_param;
20166 ch_nfdbr = param_buf->nfdbr;
20167 ch_nfdbm = param_buf->nfdbm;
20168 ch_freqnum = param_buf->freqnum;
20169
20170 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20171 event->pdev_id, param_buf->num_nfdbr,
20172 param_buf->num_nfdbm, param_buf->num_freqnum);
20173
20174 if (param_buf->num_nfdbr >
20175 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20176 WMI_LOGE("invalid number of nfdBr");
20177 return QDF_STATUS_E_FAILURE;
20178 }
20179
20180 if (param_buf->num_nfdbm >
20181 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20182 WMI_LOGE("invalid number of nfdBm");
20183 return QDF_STATUS_E_FAILURE;
20184 }
20185
20186 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20187 WMI_LOGE("invalid number of freqNum");
20188 return QDF_STATUS_E_FAILURE;
20189 }
20190
20191 for (i = 0; i < param_buf->num_nfdbr; i++) {
20192 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20193 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20194 ch_nfdbr++;
20195 ch_nfdbm++;
20196 }
20197
20198 for (i = 0; i < param_buf->num_freqnum; i++) {
20199 param->freqnum[i] = ch_freqnum->freqNum;
20200 ch_freqnum++;
20201 }
20202
Keyur Parekh2c0bab62018-05-16 13:15:38 -070020203 param->pdev_id = wmi_handle->ops->
20204 convert_pdev_id_target_to_host(event->pdev_id);
nobeljf74583b2018-01-25 16:35:36 -080020205
20206 return QDF_STATUS_SUCCESS;
20207}
20208
Sathish Kumard3ab1002017-02-07 17:10:59 +053020209
20210#ifdef BIG_ENDIAN_HOST
20211/**
20212 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20213 * @param data_len - data length
20214 * @param data - pointer to data
20215 *
20216 * Return: QDF_STATUS - success or error status
20217 */
20218static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20219{
20220 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020221 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020222 /* Skip swapping the first word */
20223 datap += sizeof(uint32_t);
20224 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20225 i++, datap += sizeof(uint32_t)) {
20226 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20227 }
20228
20229 return QDF_STATUS_SUCCESS;
20230}
20231#else
20232/**
20233 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20234 * @param data_len - data length
20235 * @param data - pointer to data
20236 *
20237 * Return: QDF_STATUS - success or error status
20238 */
20239static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20240{
20241 return QDF_STATUS_SUCCESS;
20242}
20243#endif
20244
20245/**
20246 * extract_wds_addr_event_tlv() - extract wds address from event
20247 * @wmi_handle: wmi handle
20248 * @param evt_buf: pointer to event buffer
20249 * @param wds_ev: Pointer to hold wds address
20250 *
20251 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20252 */
20253static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20254 void *evt_buf,
20255 uint16_t len, wds_addr_event_t *wds_ev)
20256{
20257 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20258 wmi_wds_addr_event_fixed_param *ev;
20259 int i;
20260
20261 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20262 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20263
20264 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20265 return QDF_STATUS_E_FAILURE;
20266
20267 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20268 sizeof(wds_ev->event_type));
20269 for (i = 0; i < 4; i++) {
20270 wds_ev->peer_mac[i] =
20271 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20272 wds_ev->dest_mac[i] =
20273 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20274 }
20275 for (i = 0; i < 2; i++) {
20276 wds_ev->peer_mac[4+i] =
20277 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20278 wds_ev->dest_mac[4+i] =
20279 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20280 }
20281 return QDF_STATUS_SUCCESS;
20282}
20283
20284/**
20285 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20286 * from event
20287 * @wmi_handle: wmi handle
20288 * @param evt_buf: pointer to event buffer
20289 * @param ev: Pointer to hold peer param and ps state
20290 *
20291 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20292 */
20293static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20294 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20295{
20296 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20297 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20298
20299 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20300 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20301 param_buf->fixed_param;
20302
20303 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20304 ev->peer_ps_state = event->peer_ps_state;
20305
20306 return QDF_STATUS_SUCCESS;
20307}
20308
20309/**
20310 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20311 * @wmi_handle: wmi handle
20312 * @param evt_buf: pointer to event buffer
20313 * @param inst_rssi_resp: Pointer to hold inst rssi response
20314 *
20315 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20316 */
20317static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20318 wmi_unified_t wmi_handle, void *evt_buf,
20319 wmi_host_inst_stats_resp *inst_rssi_resp)
20320{
20321 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20322 wmi_inst_rssi_stats_resp_fixed_param *event;
20323
20324 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20325 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20326
20327 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20328 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20329 inst_rssi_resp->iRSSI = event->iRSSI;
20330
20331 return QDF_STATUS_SUCCESS;
20332}
20333
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020334static struct cur_reg_rule
20335*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20336 wmi_regulatory_rule_struct *wmi_reg_rule)
20337{
20338 struct cur_reg_rule *reg_rule_ptr;
20339 uint32_t count;
20340
20341 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20342
20343 if (NULL == reg_rule_ptr) {
20344 WMI_LOGE("memory allocation failure");
20345 return NULL;
20346 }
20347
20348 for (count = 0; count < num_reg_rules; count++) {
20349 reg_rule_ptr[count].start_freq =
20350 WMI_REG_RULE_START_FREQ_GET(
20351 wmi_reg_rule[count].freq_info);
20352 reg_rule_ptr[count].end_freq =
20353 WMI_REG_RULE_END_FREQ_GET(
20354 wmi_reg_rule[count].freq_info);
20355 reg_rule_ptr[count].max_bw =
20356 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020357 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020358 reg_rule_ptr[count].reg_power =
20359 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020360 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020361 reg_rule_ptr[count].ant_gain =
20362 WMI_REG_RULE_ANTENNA_GAIN_GET(
20363 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020364 reg_rule_ptr[count].flags =
20365 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020366 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020367 }
20368
20369 return reg_rule_ptr;
20370}
20371
20372static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20373 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20374 struct cur_regulatory_info *reg_info, uint32_t len)
20375{
20376 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20377 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20378 wmi_regulatory_rule_struct *wmi_reg_rule;
20379 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20380
20381 WMI_LOGD("processing regulatory channel list");
20382
20383 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20384 if (!param_buf) {
20385 WMI_LOGE("invalid channel list event buf");
20386 return QDF_STATUS_E_FAILURE;
20387 }
20388
20389 chan_list_event_hdr = param_buf->fixed_param;
20390
20391 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20392 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20393 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020394 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020395 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20396 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020397 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020398 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020399 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020400 reg_info->ctry_code = chan_list_event_hdr->country_id;
20401 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20402 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20403 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20404 else if (chan_list_event_hdr->status_code ==
20405 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20406 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20407 else if (chan_list_event_hdr->status_code ==
20408 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20409 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20410 else if (chan_list_event_hdr->status_code ==
20411 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20412 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20413 else if (chan_list_event_hdr->status_code ==
20414 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20415 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20416 else if (chan_list_event_hdr->status_code ==
20417 WMI_REG_SET_CC_STATUS_FAIL)
20418 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20419
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020420 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20421 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20422 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20423 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20424
20425 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20426 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20427
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020428 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20429 __func__, reg_info->alpha2, reg_info->dfs_region,
20430 reg_info->min_bw_2g, reg_info->max_bw_2g,
20431 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020432
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020433 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20434 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020435 wmi_reg_rule =
20436 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20437 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20438 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020439 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20440 wmi_reg_rule);
20441 wmi_reg_rule += num_2g_reg_rules;
20442
20443 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20444 wmi_reg_rule);
20445
20446 WMI_LOGD("processed regulatory channel list");
20447
20448 return QDF_STATUS_SUCCESS;
20449}
20450
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020451static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20452 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20453 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20454{
20455 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20456 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20457
20458 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20459 if (!param_buf) {
20460 WMI_LOGE("invalid 11d country event buf");
20461 return QDF_STATUS_E_FAILURE;
20462 }
20463
20464 reg_11d_country_event = param_buf->fixed_param;
20465
20466 qdf_mem_copy(reg_11d_country->alpha2,
20467 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20468
20469 WMI_LOGD("processed 11d country event, new cc %s",
20470 reg_11d_country->alpha2);
20471
20472 return QDF_STATUS_SUCCESS;
20473}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020474
20475static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20476 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20477 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20478{
20479 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20480 wmi_avoid_freq_range_desc *afr_desc;
20481 uint32_t num_freq_ranges, freq_range_idx;
20482 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20483 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20484
20485 if (!param_buf) {
20486 WMI_LOGE("Invalid channel avoid event buffer");
20487 return QDF_STATUS_E_INVAL;
20488 }
20489
20490 afr_fixed_param = param_buf->fixed_param;
20491 if (!afr_fixed_param) {
20492 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20493 return QDF_STATUS_E_INVAL;
20494 }
20495
20496 if (!ch_avoid_ind) {
20497 WMI_LOGE("Invalid channel avoid indication buffer");
20498 return QDF_STATUS_E_INVAL;
20499 }
20500 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20501 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20502 afr_fixed_param->num_freq_ranges;
20503
20504 WMI_LOGD("Channel avoid event received with %d ranges",
20505 num_freq_ranges);
20506
20507 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20508 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20509 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20510 freq_range_idx++) {
20511 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20512 afr_desc->start_freq;
20513 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20514 afr_desc->end_freq;
20515 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20516 freq_range_idx, afr_desc->tlv_header,
20517 afr_desc->start_freq, afr_desc->end_freq);
20518 afr_desc++;
20519 }
20520
20521 return QDF_STATUS_SUCCESS;
20522}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020523#ifdef DFS_COMPONENT_ENABLE
20524/**
20525 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20526 * @wmi_handle: wma handle
20527 * @evt_buf: event buffer
20528 * @vdev_id: vdev id
20529 * @len: length of buffer
20530 *
20531 * Return: 0 for success or error code
20532 */
20533static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20534 uint8_t *evt_buf,
20535 uint32_t *vdev_id,
20536 uint32_t len)
20537{
20538 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20539 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20540
20541 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20542 if (!param_tlvs) {
20543 WMI_LOGE("invalid cac complete event buf");
20544 return QDF_STATUS_E_FAILURE;
20545 }
20546
20547 cac_event = param_tlvs->fixed_param;
20548 *vdev_id = cac_event->vdev_id;
20549 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20550
20551 return QDF_STATUS_SUCCESS;
20552}
20553
20554/**
20555 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20556 * @wmi_handle: wma handle
20557 * @evt_buf: event buffer
20558 * @radar_found: radar found event info
20559 * @len: length of buffer
20560 *
20561 * Return: 0 for success or error code
20562 */
20563static QDF_STATUS extract_dfs_radar_detection_event_tlv(
20564 wmi_unified_t wmi_handle,
20565 uint8_t *evt_buf,
20566 struct radar_found_info *radar_found,
20567 uint32_t len)
20568{
20569 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
20570 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
20571
20572 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
20573 if (!param_tlv) {
20574 WMI_LOGE("invalid radar detection event buf");
20575 return QDF_STATUS_E_FAILURE;
20576 }
20577
20578 radar_event = param_tlv->fixed_param;
Arif Hussainb522ac92018-06-27 10:51:06 -070020579 radar_found->pdev_id = convert_target_pdev_id_to_host_pdev_id(
20580 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020581 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020582 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020583 radar_found->chan_width = radar_event->chan_width;
20584 radar_found->detector_id = radar_event->detector_id;
20585 radar_found->segment_id = radar_event->segment_id;
20586 radar_found->timestamp = radar_event->timestamp;
20587 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020588 radar_found->freq_offset = radar_event->freq_offset;
20589 radar_found->sidx = radar_event->sidx;
20590
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020591 WMI_LOGI("processed radar found event pdev %d,"
20592 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
20593 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
20594 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
20595 "is_chirp %d,detection mode %d\n",
Arif Hussainb522ac92018-06-27 10:51:06 -070020596 radar_event->pdev_id, radar_found->pdev_id,
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020597 radar_event->timestamp, radar_event->chan_freq,
20598 radar_event->chan_width, radar_event->detector_id,
20599 radar_event->freq_offset, radar_event->segment_id,
20600 radar_event->sidx, radar_event->is_chirp,
20601 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020602
20603 return QDF_STATUS_SUCCESS;
20604}
bings1ea12532017-12-18 16:56:53 +080020605
20606#ifdef QCA_MCL_DFS_SUPPORT
20607/**
20608 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
20609 * @wmi_handle: wma handle
20610 * @evt_buf: event buffer
20611 * @wlan_radar_event: Pointer to struct radar_event_info
20612 * @len: length of buffer
20613 *
20614 * Return: QDF_STATUS
20615 */
20616static QDF_STATUS extract_wlan_radar_event_info_tlv(
20617 wmi_unified_t wmi_handle,
20618 uint8_t *evt_buf,
20619 struct radar_event_info *wlan_radar_event,
20620 uint32_t len)
20621{
20622 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
20623 wmi_dfs_radar_event_fixed_param *radar_event;
20624
20625 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
20626 if (!param_tlv) {
20627 WMI_LOGE("invalid wlan radar event buf");
20628 return QDF_STATUS_E_FAILURE;
20629 }
20630
20631 radar_event = param_tlv->fixed_param;
20632 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
20633 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
20634 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
20635 wlan_radar_event->rssi = radar_event->rssi;
20636 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
20637 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
20638 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
20639 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080020640 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
20641 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +080020642 if (radar_event->pulse_flags &
20643 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
20644 wlan_radar_event->is_psidx_diff_valid = true;
20645 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
20646 } else {
20647 wlan_radar_event->is_psidx_diff_valid = false;
20648 }
20649
bings1ea12532017-12-18 16:56:53 +080020650 wlan_radar_event->pdev_id = radar_event->pdev_id;
20651
20652 return QDF_STATUS_SUCCESS;
20653}
20654#else
20655static QDF_STATUS extract_wlan_radar_event_info_tlv(
20656 wmi_unified_t wmi_handle,
20657 uint8_t *evt_buf,
20658 struct radar_event_info *wlan_radar_event,
20659 uint32_t len)
20660{
20661 return QDF_STATUS_SUCCESS;
20662}
20663#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020664#endif
20665
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020666/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020667 * send_get_rcpi_cmd_tlv() - send request for rcpi value
20668 * @wmi_handle: wmi handle
20669 * @get_rcpi_param: rcpi params
20670 *
20671 * Return: QDF status
20672 */
20673static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
20674 struct rcpi_req *get_rcpi_param)
20675{
20676 wmi_buf_t buf;
20677 wmi_request_rcpi_cmd_fixed_param *cmd;
20678 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
20679
20680 buf = wmi_buf_alloc(wmi_handle, len);
20681 if (!buf) {
20682 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
20683 return QDF_STATUS_E_NOMEM;
20684 }
20685
20686 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
20687 WMITLV_SET_HDR(&cmd->tlv_header,
20688 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
20689 WMITLV_GET_STRUCT_TLVLEN
20690 (wmi_request_rcpi_cmd_fixed_param));
20691
20692 cmd->vdev_id = get_rcpi_param->vdev_id;
20693 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
20694 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070020695
20696 switch (get_rcpi_param->measurement_type) {
20697
20698 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20699 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20700 break;
20701
20702 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
20703 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
20704 break;
20705
20706 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20707 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20708 break;
20709
20710 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
20711 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
20712 break;
20713
20714 default:
20715 /*
20716 * invalid rcpi measurement type, fall back to
20717 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
20718 */
20719 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20720 break;
20721 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020722 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
20723 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20724 WMI_REQUEST_RCPI_CMDID)) {
20725
20726 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
20727 __func__);
20728 wmi_buf_free(buf);
20729 return QDF_STATUS_E_FAILURE;
20730 }
20731
20732 return QDF_STATUS_SUCCESS;
20733}
20734
20735/**
20736 * extract_rcpi_response_event_tlv() - Extract RCPI event params
20737 * @wmi_handle: wmi handle
20738 * @evt_buf: pointer to event buffer
20739 * @res: pointer to hold rcpi response from firmware
20740 *
20741 * Return: QDF_STATUS_SUCCESS for successful event parse
20742 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
20743 */
20744static QDF_STATUS
20745extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
20746 void *evt_buf, struct rcpi_res *res)
20747{
20748 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
20749 wmi_update_rcpi_event_fixed_param *event;
20750
20751 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
20752 if (!param_buf) {
20753 WMI_LOGE(FL("Invalid rcpi event"));
20754 return QDF_STATUS_E_INVAL;
20755 }
20756
20757 event = param_buf->fixed_param;
20758 res->vdev_id = event->vdev_id;
20759 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
20760
20761 switch (event->measurement_type) {
20762
20763 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20764 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20765 break;
20766
20767 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
20768 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
20769 break;
20770
20771 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20772 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20773 break;
20774
20775 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
20776 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
20777 break;
20778
20779 default:
20780 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
20781 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
20782 return QDF_STATUS_E_FAILURE;
20783 }
20784
20785 if (event->status)
20786 return QDF_STATUS_E_FAILURE;
20787 else
20788 return QDF_STATUS_SUCCESS;
20789}
20790
20791/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020792 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
20793 * host to target defines. For legacy there is not conversion
20794 * required. Just return pdev_id as it is.
20795 * @param pdev_id: host pdev_id to be converted.
20796 * Return: target pdev_id after conversion.
20797 */
20798static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
20799 uint32_t pdev_id)
20800{
20801 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
20802 return WMI_PDEV_ID_SOC;
20803
20804 /*No conversion required*/
20805 return pdev_id;
20806}
20807
20808/**
20809 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
20810 * target to host defines. For legacy there is not conversion
20811 * required. Just return pdev_id as it is.
20812 * @param pdev_id: target pdev_id to be converted.
20813 * Return: host pdev_id after conversion.
20814 */
20815static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
20816 uint32_t pdev_id)
20817{
20818 /*No conversion required*/
20819 return pdev_id;
20820}
20821
20822/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020823 * send_set_country_cmd_tlv() - WMI scan channel list function
20824 * @param wmi_handle : handle to WMI.
20825 * @param param : pointer to hold scan channel list parameter
20826 *
20827 * Return: 0 on success and -ve on failure.
20828 */
20829static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
20830 struct set_country *params)
20831{
20832 wmi_buf_t buf;
20833 QDF_STATUS qdf_status;
20834 wmi_set_current_country_cmd_fixed_param *cmd;
20835 uint16_t len = sizeof(*cmd);
20836
20837 buf = wmi_buf_alloc(wmi_handle, len);
20838 if (!buf) {
20839 WMI_LOGE("Failed to allocate memory");
20840 qdf_status = QDF_STATUS_E_NOMEM;
20841 goto end;
20842 }
20843
20844 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
20845 WMITLV_SET_HDR(&cmd->tlv_header,
20846 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
20847 WMITLV_GET_STRUCT_TLVLEN
20848 (wmi_set_current_country_cmd_fixed_param));
20849
20850 WMI_LOGD("setting cuurnet country to %s", params->country);
20851
20852 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
20853
20854 cmd->pdev_id = params->pdev_id;
20855
20856 qdf_status = wmi_unified_cmd_send(wmi_handle,
20857 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
20858
20859 if (QDF_IS_STATUS_ERROR(qdf_status)) {
20860 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
20861 wmi_buf_free(buf);
20862 }
20863
20864end:
20865 return qdf_status;
20866}
20867
Abhijit Pradhand38a2692017-06-29 12:32:20 +053020868#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
20869 WMI_SET_BITS(alpha, 0, 8, val0); \
20870 WMI_SET_BITS(alpha, 8, 8, val1); \
20871 WMI_SET_BITS(alpha, 16, 8, val2); \
20872 } while (0)
20873
20874static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
20875 uint8_t pdev_id, struct cc_regdmn_s *rd)
20876{
20877 wmi_set_init_country_cmd_fixed_param *cmd;
20878 uint16_t len;
20879 wmi_buf_t buf;
20880 int ret;
20881
20882 len = sizeof(wmi_set_init_country_cmd_fixed_param);
20883 buf = wmi_buf_alloc(wmi_handle, len);
20884 if (!buf) {
20885 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
20886 return QDF_STATUS_E_NOMEM;
20887 }
20888 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
20889 WMITLV_SET_HDR(&cmd->tlv_header,
20890 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
20891 WMITLV_GET_STRUCT_TLVLEN
20892 (wmi_set_init_country_cmd_fixed_param));
20893
20894 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
20895
20896 if (rd->flags == CC_IS_SET) {
20897 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
20898 cmd->country_code.country_id = rd->cc.country_code;
20899 } else if (rd->flags == ALPHA_IS_SET) {
20900 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
20901 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
20902 rd->cc.alpha[0],
20903 rd->cc.alpha[1],
20904 rd->cc.alpha[2]);
20905 } else if (rd->flags == REGDMN_IS_SET) {
20906 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
20907 cmd->country_code.domain_code = rd->cc.regdmn_id;
20908 }
20909
20910 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
20911 WMI_SET_INIT_COUNTRY_CMDID);
20912 if (ret) {
20913 WMI_LOGE("Failed to config wow wakeup event");
20914 wmi_buf_free(buf);
20915 return QDF_STATUS_E_FAILURE;
20916 }
20917
20918 return QDF_STATUS_SUCCESS;
20919}
20920
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053020921/**
20922 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
20923 * configuration params
20924 * @wmi_handle: wmi handler
20925 * @limit_off_chan_param: pointer to wmi_off_chan_param
20926 *
20927 * Return: 0 for success and non zero for failure
20928 */
20929static
20930QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
20931 struct wmi_limit_off_chan_param *limit_off_chan_param)
20932{
20933 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
20934 wmi_buf_t buf;
20935 uint32_t len = sizeof(*cmd);
20936 int err;
20937
20938 buf = wmi_buf_alloc(wmi_handle, len);
20939 if (!buf) {
20940 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
20941 __func__);
20942 return QDF_STATUS_E_NOMEM;
20943 }
20944
20945 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
20946
20947 WMITLV_SET_HDR(&cmd->tlv_header,
20948 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
20949 WMITLV_GET_STRUCT_TLVLEN(
20950 wmi_vdev_limit_offchan_cmd_fixed_param));
20951
20952 cmd->vdev_id = limit_off_chan_param->vdev_id;
20953
20954 cmd->flags &= 0;
20955 if (limit_off_chan_param->status)
20956 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
20957 if (limit_off_chan_param->skip_dfs_chans)
20958 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
20959
20960 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
20961 cmd->rest_time = limit_off_chan_param->rest_time;
20962
20963 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
20964 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
20965 cmd->rest_time);
20966
20967 err = wmi_unified_cmd_send(wmi_handle, buf,
20968 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
20969 if (QDF_IS_STATUS_ERROR(err)) {
20970 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
20971 wmi_buf_free(buf);
20972 return QDF_STATUS_E_FAILURE;
20973 }
20974
20975 return QDF_STATUS_SUCCESS;
20976}
20977
Anurag Chouhan97f00422017-09-11 14:56:30 +053020978/**
20979 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
20980 * @wmi_handle: wmi handler
20981 * @req_buf: set arp stats request buffer
20982 *
20983 * Return: 0 for success and non zero for failure
20984 */
20985static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20986 struct set_arp_stats *req_buf)
20987{
20988 wmi_buf_t buf = NULL;
20989 QDF_STATUS status;
20990 int len;
20991 uint8_t *buf_ptr;
20992 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
20993
20994 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020995 if (req_buf->pkt_type_bitmap) {
20996 len += WMI_TLV_HDR_SIZE;
20997 len += sizeof(wmi_vdev_set_connectivity_check_stats);
20998 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053020999 buf = wmi_buf_alloc(wmi_handle, len);
21000 if (!buf) {
21001 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21002 return QDF_STATUS_E_NOMEM;
21003 }
21004
21005 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21006 wmi_set_arp =
21007 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
21008 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
21009 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
21010 WMITLV_GET_STRUCT_TLVLEN
21011 (wmi_vdev_set_arp_stats_cmd_fixed_param));
21012
21013 /* fill in per roam config values */
21014 wmi_set_arp->vdev_id = req_buf->vdev_id;
21015
21016 wmi_set_arp->set_clr = req_buf->flag;
21017 wmi_set_arp->pkt_type = req_buf->pkt_type;
21018 wmi_set_arp->ipv4 = req_buf->ip_addr;
21019
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021020 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
21021 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
21022 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
21023
21024 /*
21025 * pkt_type_bitmap should be non-zero to ensure
21026 * presence of additional stats.
21027 */
21028 if (req_buf->pkt_type_bitmap) {
21029 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
21030
21031 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21032 WMITLV_SET_HDR(buf_ptr,
21033 WMITLV_TAG_ARRAY_STRUC,
21034 sizeof(wmi_vdev_set_connectivity_check_stats));
21035 buf_ptr += WMI_TLV_HDR_SIZE;
21036 wmi_set_connect_stats =
21037 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
21038 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
21039 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
21040 WMITLV_GET_STRUCT_TLVLEN(
21041 wmi_vdev_set_connectivity_check_stats));
21042 wmi_set_connect_stats->pkt_type_bitmap =
21043 req_buf->pkt_type_bitmap;
21044 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
21045 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
21046 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
21047
21048 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
21049 wmi_set_connect_stats->pkt_type_bitmap,
21050 wmi_set_connect_stats->tcp_src_port,
21051 wmi_set_connect_stats->tcp_dst_port,
21052 wmi_set_connect_stats->icmp_ipv4);
21053 }
21054
Anurag Chouhan97f00422017-09-11 14:56:30 +053021055 /* Send per roam config parameters */
21056 status = wmi_unified_cmd_send(wmi_handle, buf,
21057 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21058 if (QDF_IS_STATUS_ERROR(status)) {
21059 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21060 status);
21061 goto error;
21062 }
21063
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +053021064 WMI_LOGD(FL("set arp stats flag=%d, vdev=%d"),
Anurag Chouhan97f00422017-09-11 14:56:30 +053021065 req_buf->flag, req_buf->vdev_id);
21066 return QDF_STATUS_SUCCESS;
21067error:
21068 wmi_buf_free(buf);
21069
21070 return status;
21071}
21072
21073/**
21074 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21075 * @wmi_handle: wmi handler
21076 * @req_buf: get arp stats request buffer
21077 *
21078 * Return: 0 for success and non zero for failure
21079 */
21080static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21081 struct get_arp_stats *req_buf)
21082{
21083 wmi_buf_t buf = NULL;
21084 QDF_STATUS status;
21085 int len;
21086 uint8_t *buf_ptr;
21087 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21088
21089 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21090 buf = wmi_buf_alloc(wmi_handle, len);
21091 if (!buf) {
21092 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21093 return QDF_STATUS_E_NOMEM;
21094 }
21095
21096 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21097 get_arp_stats =
21098 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21099 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21100 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21101 WMITLV_GET_STRUCT_TLVLEN
21102 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21103
21104 /* fill in arp stats req cmd values */
21105 get_arp_stats->vdev_id = req_buf->vdev_id;
21106
21107 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21108 /* Send per roam config parameters */
21109 status = wmi_unified_cmd_send(wmi_handle, buf,
21110 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21111 if (QDF_IS_STATUS_ERROR(status)) {
21112 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21113 status);
21114 goto error;
21115 }
21116
21117 return QDF_STATUS_SUCCESS;
21118error:
21119 wmi_buf_free(buf);
21120
21121 return status;
21122}
21123
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021124/**
21125 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21126 * @wmi_handle: wmi handler
21127 * @pmk_info: pointer to PMK cache entry
21128 * @vdev_id: vdev id
21129 *
21130 * Return: 0 for success and non zero for failure
21131 */
21132static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21133 struct wmi_unified_pmk_cache *pmk_info)
21134{
21135 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21136 wmi_buf_t buf;
21137 QDF_STATUS status;
21138 uint8_t *buf_ptr;
21139 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021140 uint32_t len = sizeof(*cmd);
21141
21142 if (pmk_info->pmk_len)
21143 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021144
21145 buf = wmi_buf_alloc(wmi_handle, len);
21146 if (!buf) {
21147 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21148 __func__);
21149 return QDF_STATUS_E_NOMEM;
21150 }
21151
21152 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21153 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21154
21155 WMITLV_SET_HDR(&cmd->tlv_header,
21156 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21157 WMITLV_GET_STRUCT_TLVLEN(
21158 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21159
21160 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021161
21162 /* If pmk_info->pmk_len is 0, this is a flush request */
21163 if (!pmk_info->pmk_len) {
21164 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21165 cmd->num_cache = 0;
21166 goto send_cmd;
21167 }
21168
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021169 cmd->num_cache = 1;
21170 buf_ptr += sizeof(*cmd);
21171
21172 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21173 sizeof(*pmksa));
21174 buf_ptr += WMI_TLV_HDR_SIZE;
21175
21176 pmksa = (wmi_pmk_cache *)buf_ptr;
21177 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21178 WMITLV_GET_STRUCT_TLVLEN
21179 (wmi_pmk_cache));
21180 pmksa->pmk_len = pmk_info->pmk_len;
21181 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21182 pmksa->pmkid_len = pmk_info->pmkid_len;
21183 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21184 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21185 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21186 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21187 pmksa->ssid.ssid_len);
21188 pmksa->cache_id = pmk_info->cache_id;
21189 pmksa->cat_flag = pmk_info->cat_flag;
21190 pmksa->action_flag = pmk_info->action_flag;
21191
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021192send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021193 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21194 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21195 if (status != QDF_STATUS_SUCCESS) {
21196 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21197 __func__, status);
21198 wmi_buf_free(buf);
21199 }
21200
21201 return status;
21202}
21203
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021204/**
21205 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21206 * @wmi_handle: wmi handle
21207 * @param: reserved param
21208 *
21209 * Return: 0 for success or error code
21210 */
21211static QDF_STATUS
21212send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21213 uint32_t param)
21214{
21215 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21216 wmi_buf_t buf;
21217 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21218
21219 buf = wmi_buf_alloc(wmi_handle, len);
21220 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053021221 qdf_print("%s:wmi_buf_alloc failed", __func__);
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021222 return QDF_STATUS_E_FAILURE;
21223 }
21224 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21225 WMITLV_SET_HDR(&cmd->tlv_header,
21226 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21227 WMITLV_GET_STRUCT_TLVLEN
21228 (wmi_pdev_check_cal_version_cmd_fixed_param));
21229 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21230 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21231 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21232 wmi_buf_free(buf);
21233 return QDF_STATUS_E_FAILURE;
21234 }
21235
21236 return QDF_STATUS_SUCCESS;
21237}
21238
21239/**
21240 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21241 * @wmi_handle: wmi handle
21242 * @param evt_buf: pointer to event buffer
21243 * @param param: Pointer to hold peer caldata version data
21244 *
21245 * Return: 0 for success or error code
21246 */
21247static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21248 wmi_unified_t wmi_handle,
21249 void *evt_buf,
21250 wmi_host_pdev_check_cal_version_event *param)
21251{
21252 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21253 wmi_pdev_check_cal_version_event_fixed_param *event;
21254
21255 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21256 if (!param_tlvs) {
21257 WMI_LOGE("invalid cal version event buf");
21258 return QDF_STATUS_E_FAILURE;
21259 }
21260 event = param_tlvs->fixed_param;
21261 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21262 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21263 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21264 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21265
21266 param->software_cal_version = event->software_cal_version;
21267 param->board_cal_version = event->board_cal_version;
21268 param->cal_ok = event->cal_status;
21269
21270 return QDF_STATUS_SUCCESS;
21271}
21272
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021273/*
21274 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21275 * @wmi_handle: wmi handle
21276 * @params: pointer to wmi_btm_config
21277 *
21278 * Return: QDF_STATUS
21279 */
21280static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21281 struct wmi_btm_config *params)
21282{
21283
21284 wmi_btm_config_fixed_param *cmd;
21285 wmi_buf_t buf;
21286 uint32_t len;
21287
21288 len = sizeof(*cmd);
21289 buf = wmi_buf_alloc(wmi_handle, len);
21290 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053021291 qdf_print("%s:wmi_buf_alloc failed", __func__);
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021292 return QDF_STATUS_E_NOMEM;
21293 }
21294
21295 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21296 WMITLV_SET_HDR(&cmd->tlv_header,
21297 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21298 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21299 cmd->vdev_id = params->vdev_id;
21300 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021301 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21302 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21303 cmd->stick_time_seconds = params->btm_sticky_time;
21304
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021305 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21306 WMI_ROAM_BTM_CONFIG_CMDID)) {
21307 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21308 __func__);
21309 wmi_buf_free(buf);
21310 return QDF_STATUS_E_FAILURE;
21311 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021312
21313 return QDF_STATUS_SUCCESS;
21314}
21315
21316/**
21317 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21318 * configurations to firmware.
21319 * @wmi_handle: wmi handle
21320 * @obss_cfg_param: obss detection configurations
21321 *
21322 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21323 *
21324 * Return: QDF_STATUS
21325 */
21326static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21327 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21328{
21329 wmi_buf_t buf;
21330 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21331 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21332
21333 buf = wmi_buf_alloc(wmi_handle, len);
21334 if (!buf) {
21335 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21336 return QDF_STATUS_E_NOMEM;
21337 }
21338
21339 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21340 WMITLV_SET_HDR(&cmd->tlv_header,
21341 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21342 WMITLV_GET_STRUCT_TLVLEN
21343 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21344
21345 cmd->vdev_id = obss_cfg_param->vdev_id;
21346 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21347 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21348 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21349 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21350 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21351 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21352 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21353 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021354
21355 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21356 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21357 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21358 wmi_buf_free(buf);
21359 return QDF_STATUS_E_FAILURE;
21360 }
21361
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021362 return QDF_STATUS_SUCCESS;
21363}
21364
Arif Hussain33d98502018-01-12 13:15:04 -080021365/**
21366 * extract_obss_detection_info_tlv() - Extract obss detection info
21367 * received from firmware.
21368 * @evt_buf: pointer to event buffer
21369 * @obss_detection: Pointer to hold obss detection info
21370 *
21371 * Return: QDF_STATUS
21372 */
21373static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21374 struct wmi_obss_detect_info
21375 *obss_detection)
21376{
21377 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21378 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21379
21380 if (!obss_detection) {
21381 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21382 return QDF_STATUS_E_INVAL;
21383 }
21384
21385 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21386 if (!param_buf) {
21387 WMI_LOGE("%s: Invalid evt_buf", __func__);
21388 return QDF_STATUS_E_INVAL;
21389 }
21390
21391 fix_param = param_buf->fixed_param;
21392 obss_detection->vdev_id = fix_param->vdev_id;
21393 obss_detection->matched_detection_masks =
21394 fix_param->matched_detection_masks;
21395 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21396 &obss_detection->matched_bssid_addr[0]);
21397 switch (fix_param->reason) {
21398 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21399 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21400 break;
21401 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21402 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21403 break;
21404 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21405 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21406 break;
21407 default:
21408 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21409 return QDF_STATUS_E_INVAL;
21410 }
21411
21412 return QDF_STATUS_SUCCESS;
21413}
21414
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021415/**
21416 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21417 * @wmi_handle: wmi handler
21418 * @params: pointer to 11k offload params
21419 *
21420 * Return: 0 for success and non zero for failure
21421 */
21422static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21423 struct wmi_11k_offload_params *params)
21424{
21425 wmi_11k_offload_report_fixed_param *cmd;
21426 wmi_buf_t buf;
21427 QDF_STATUS status;
21428 uint8_t *buf_ptr;
21429 wmi_neighbor_report_11k_offload_tlv_param
21430 *neighbor_report_offload_params;
21431 wmi_neighbor_report_offload *neighbor_report_offload;
21432
21433 uint32_t len = sizeof(*cmd);
21434
21435 if (params->offload_11k_bitmask &
21436 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21437 len += WMI_TLV_HDR_SIZE +
21438 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21439
21440 buf = wmi_buf_alloc(wmi_handle, len);
21441 if (!buf) {
21442 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21443 __func__);
21444 return QDF_STATUS_E_NOMEM;
21445 }
21446
21447 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21448 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21449
21450 WMITLV_SET_HDR(&cmd->tlv_header,
21451 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21452 WMITLV_GET_STRUCT_TLVLEN(
21453 wmi_11k_offload_report_fixed_param));
21454
21455 cmd->vdev_id = params->vdev_id;
21456 cmd->offload_11k = params->offload_11k_bitmask;
21457
21458 if (params->offload_11k_bitmask &
21459 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21460 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21461
21462 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21463 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21464 buf_ptr += WMI_TLV_HDR_SIZE;
21465
21466 neighbor_report_offload_params =
21467 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21468 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21469 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21470 WMITLV_GET_STRUCT_TLVLEN(
21471 wmi_neighbor_report_11k_offload_tlv_param));
21472
21473 neighbor_report_offload = &neighbor_report_offload_params->
21474 neighbor_rep_ofld_params;
21475
21476 neighbor_report_offload->time_offset =
21477 params->neighbor_report_params.time_offset;
21478 neighbor_report_offload->low_rssi_offset =
21479 params->neighbor_report_params.low_rssi_offset;
21480 neighbor_report_offload->bmiss_count_trigger =
21481 params->neighbor_report_params.bmiss_count_trigger;
21482 neighbor_report_offload->per_threshold_offset =
21483 params->neighbor_report_params.per_threshold_offset;
21484 neighbor_report_offload->neighbor_report_cache_timeout =
21485 params->neighbor_report_params.
21486 neighbor_report_cache_timeout;
21487 neighbor_report_offload->max_neighbor_report_req_cap =
21488 params->neighbor_report_params.
21489 max_neighbor_report_req_cap;
21490 neighbor_report_offload->ssid.ssid_len =
21491 params->neighbor_report_params.ssid.length;
21492 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21493 &params->neighbor_report_params.ssid.mac_ssid,
21494 neighbor_report_offload->ssid.ssid_len);
21495 }
21496
21497 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21498 WMI_11K_OFFLOAD_REPORT_CMDID);
21499 if (status != QDF_STATUS_SUCCESS) {
21500 WMI_LOGE("%s: failed to send 11k offload command %d",
21501 __func__, status);
21502 wmi_buf_free(buf);
21503 }
21504
21505 return status;
21506}
21507
21508/**
21509 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
21510 * command
21511 * @wmi_handle: wmi handler
21512 * @params: pointer to neighbor report invoke params
21513 *
21514 * Return: 0 for success and non zero for failure
21515 */
21516static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
21517 struct wmi_invoke_neighbor_report_params *params)
21518{
21519 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
21520 wmi_buf_t buf;
21521 QDF_STATUS status;
21522 uint8_t *buf_ptr;
21523 uint32_t len = sizeof(*cmd);
21524
21525 buf = wmi_buf_alloc(wmi_handle, len);
21526 if (!buf) {
21527 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
21528 __func__);
21529 return QDF_STATUS_E_NOMEM;
21530 }
21531
21532 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21533 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
21534
21535 WMITLV_SET_HDR(&cmd->tlv_header,
21536 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
21537 WMITLV_GET_STRUCT_TLVLEN(
21538 wmi_11k_offload_invoke_neighbor_report_fixed_param));
21539
21540 cmd->vdev_id = params->vdev_id;
21541 cmd->flags = params->send_resp_to_host;
21542
21543 cmd->ssid.ssid_len = params->ssid.length;
21544 qdf_mem_copy(cmd->ssid.ssid,
21545 &params->ssid.mac_ssid,
21546 cmd->ssid.ssid_len);
21547
21548 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21549 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
21550 if (status != QDF_STATUS_SUCCESS) {
21551 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
21552 __func__, status);
21553 wmi_buf_free(buf);
21554 }
21555
21556 return status;
21557}
21558
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021559#ifdef WLAN_SUPPORT_GREEN_AP
21560static QDF_STATUS extract_green_ap_egap_status_info_tlv(
21561 uint8_t *evt_buf,
21562 struct wlan_green_ap_egap_status_info *egap_status_info_params)
21563{
21564 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
21565 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
21566 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
21567
21568 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
21569 if (!param_buf) {
21570 WMI_LOGE("Invalid EGAP Info status event buffer");
21571 return QDF_STATUS_E_INVAL;
21572 }
21573
21574 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
21575 param_buf->fixed_param;
21576 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
21577 param_buf->chainmask_list;
21578
21579 egap_status_info_params->status = egap_info_event->status;
21580 egap_status_info_params->mac_id = chainmask_event->mac_id;
21581 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
21582 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
21583
21584 return QDF_STATUS_SUCCESS;
21585}
21586#endif
21587
Arif Hussainec5cd3c2018-01-22 01:19:36 -080021588/*
21589 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
21590 * updating bss color change within firmware when AP announces bss color change.
21591 * @wmi_handle: wmi handle
21592 * @vdev_id: vdev ID
21593 * @enable: enable bss color change within firmware
21594 *
21595 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
21596 *
21597 * Return: QDF_STATUS
21598 */
21599static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
21600 uint32_t vdev_id,
21601 bool enable)
21602{
21603 wmi_buf_t buf;
21604 wmi_bss_color_change_enable_fixed_param *cmd;
21605 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
21606
21607 buf = wmi_buf_alloc(wmi_handle, len);
21608 if (!buf) {
21609 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21610 return QDF_STATUS_E_NOMEM;
21611 }
21612
21613 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
21614 WMITLV_SET_HDR(&cmd->tlv_header,
21615 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
21616 WMITLV_GET_STRUCT_TLVLEN
21617 (wmi_bss_color_change_enable_fixed_param));
21618 cmd->vdev_id = vdev_id;
21619 cmd->enable = enable;
21620 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21621 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
21622 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
21623 wmi_buf_free(buf);
21624 return QDF_STATUS_E_FAILURE;
21625 }
21626
21627 return QDF_STATUS_SUCCESS;
21628}
21629
21630/**
21631 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
21632 * configurations to firmware.
21633 * @wmi_handle: wmi handle
21634 * @cfg_param: obss detection configurations
21635 *
21636 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
21637 *
21638 * Return: QDF_STATUS
21639 */
21640static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
21641 wmi_unified_t wmi_handle,
21642 struct wmi_obss_color_collision_cfg_param *cfg_param)
21643{
21644 wmi_buf_t buf;
21645 wmi_obss_color_collision_det_config_fixed_param *cmd;
21646 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
21647
21648 buf = wmi_buf_alloc(wmi_handle, len);
21649 if (!buf) {
21650 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21651 return QDF_STATUS_E_NOMEM;
21652 }
21653
21654 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
21655 buf);
21656 WMITLV_SET_HDR(&cmd->tlv_header,
21657 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
21658 WMITLV_GET_STRUCT_TLVLEN
21659 (wmi_obss_color_collision_det_config_fixed_param));
21660 cmd->vdev_id = cfg_param->vdev_id;
21661 cmd->flags = cfg_param->flags;
21662 cmd->current_bss_color = cfg_param->current_bss_color;
21663 cmd->detection_period_ms = cfg_param->detection_period_ms;
21664 cmd->scan_period_ms = cfg_param->scan_period_ms;
21665 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
21666
21667 switch (cfg_param->evt_type) {
21668 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
21669 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
21670 break;
21671 case OBSS_COLOR_COLLISION_DETECTION:
21672 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
21673 break;
21674 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21675 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21676 break;
21677 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
21678 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
21679 break;
21680 default:
21681 WMI_LOGE("%s: invalid event type: %d",
21682 __func__, cfg_param->evt_type);
21683 wmi_buf_free(buf);
21684 return QDF_STATUS_E_FAILURE;
21685 }
21686
21687 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21688 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
21689 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
21690 __func__, cfg_param->vdev_id);
21691 wmi_buf_free(buf);
21692 return QDF_STATUS_E_FAILURE;
21693 }
21694
21695 return QDF_STATUS_SUCCESS;
21696}
21697
21698/**
21699 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
21700 * received from firmware.
21701 * @evt_buf: pointer to event buffer
21702 * @info: Pointer to hold bss collision info
21703 *
21704 * Return: QDF_STATUS
21705 */
21706static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
21707 struct wmi_obss_color_collision_info *info)
21708{
21709 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
21710 wmi_obss_color_collision_evt_fixed_param *fix_param;
21711
21712 if (!info) {
21713 WMI_LOGE("%s: Invalid obss color buffer", __func__);
21714 return QDF_STATUS_E_INVAL;
21715 }
21716
21717 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
21718 evt_buf;
21719 if (!param_buf) {
21720 WMI_LOGE("%s: Invalid evt_buf", __func__);
21721 return QDF_STATUS_E_INVAL;
21722 }
21723
21724 fix_param = param_buf->fixed_param;
21725 info->vdev_id = fix_param->vdev_id;
21726 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
21727 info->obss_color_bitmap_bit32to63 =
21728 fix_param->bss_color_bitmap_bit32to63;
21729
21730 switch (fix_param->evt_type) {
21731 case WMI_BSS_COLOR_COLLISION_DISABLE:
21732 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
21733 break;
21734 case WMI_BSS_COLOR_COLLISION_DETECTION:
21735 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
21736 break;
21737 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21738 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21739 break;
21740 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
21741 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
21742 break;
21743 default:
21744 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
21745 __func__, fix_param->evt_type, fix_param->vdev_id);
21746 return QDF_STATUS_E_FAILURE;
21747 }
21748
21749 return QDF_STATUS_SUCCESS;
21750}
21751
Arif Hussaine0eb7302018-03-01 14:40:59 -080021752/*
21753 * extract_comb_phyerr_tlv() - extract comb phy error from event
21754 * @wmi_handle: wmi handle
21755 * @evt_buf: pointer to event buffer
21756 * @datalen: data length of event buffer
21757 * @buf_offset: Pointer to hold value of current event buffer offset
21758 * post extraction
21759 * @phyerr: Pointer to hold phyerr
21760 *
21761 * Return: QDF_STATUS
21762 */
21763static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
21764 void *evt_buf,
21765 uint16_t datalen,
21766 uint16_t *buf_offset,
21767 wmi_host_phyerr_t *phyerr)
21768{
21769 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
21770 wmi_comb_phyerr_rx_hdr *pe_hdr;
21771
21772 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
21773 if (!param_tlvs) {
21774 WMI_LOGD("%s: Received null data from FW", __func__);
21775 return QDF_STATUS_E_FAILURE;
21776 }
21777
21778 pe_hdr = param_tlvs->hdr;
21779 if (!pe_hdr) {
21780 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
21781 return QDF_STATUS_E_FAILURE;
21782 }
21783
21784 /* Ensure it's at least the size of the header */
21785 if (datalen < sizeof(*pe_hdr)) {
21786 WMI_LOGD("%s: Expected minimum size %zu, received %d",
21787 __func__, sizeof(*pe_hdr), datalen);
21788 return QDF_STATUS_E_FAILURE;
21789 }
21790
21791 phyerr->pdev_id = wmi_handle->ops->
21792 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
21793 phyerr->tsf64 = pe_hdr->tsf_l32;
21794 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
21795 phyerr->bufp = param_tlvs->bufp;
21796 phyerr->buf_len = pe_hdr->buf_len;
21797 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
21798 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
21799 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
21800
21801 return QDF_STATUS_SUCCESS;
21802}
21803
21804/**
21805 * extract_single_phyerr_tlv() - extract single phy error from event
21806 * @wmi_handle: wmi handle
21807 * @evt_buf: pointer to event buffer
21808 * @datalen: data length of event buffer
21809 * @buf_offset: Pointer to hold value of current event buffer offset
21810 * post extraction
21811 * @phyerr: Pointer to hold phyerr
21812 *
21813 * Return: QDF_STATUS
21814 */
21815static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
21816 void *evt_buf,
21817 uint16_t datalen,
21818 uint16_t *buf_offset,
21819 wmi_host_phyerr_t *phyerr)
21820{
21821 wmi_single_phyerr_rx_event *ev;
21822 uint16_t n = *buf_offset;
21823 uint8_t *data = (uint8_t *)evt_buf;
21824
21825 if (n < datalen) {
21826 if ((datalen - n) < sizeof(ev->hdr)) {
21827 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
21828 __func__, datalen, n, sizeof(ev->hdr));
21829 return QDF_STATUS_E_FAILURE;
21830 }
21831
21832 /*
21833 * Obtain a pointer to the beginning of the current event.
21834 * data[0] is the beginning of the WMI payload.
21835 */
21836 ev = (wmi_single_phyerr_rx_event *)&data[n];
21837
21838 /*
21839 * Sanity check the buffer length of the event against
21840 * what we currently have.
21841 *
21842 * Since buf_len is 32 bits, we check if it overflows
21843 * a large 32 bit value. It's not 0x7fffffff because
21844 * we increase n by (buf_len + sizeof(hdr)), which would
21845 * in itself cause n to overflow.
21846 *
21847 * If "int" is 64 bits then this becomes a moot point.
21848 */
21849 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
21850 WMI_LOGD("%s: buf_len is garbage 0x%x",
21851 __func__, ev->hdr.buf_len);
21852 return QDF_STATUS_E_FAILURE;
21853 }
21854
21855 if ((n + ev->hdr.buf_len) > datalen) {
21856 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
21857 __func__, n, ev->hdr.buf_len, datalen);
21858 return QDF_STATUS_E_FAILURE;
21859 }
21860
21861 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
21862 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
21863 phyerr->bufp = &ev->bufp[0];
21864 phyerr->buf_len = ev->hdr.buf_len;
21865 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
21866
21867 /*
21868 * Advance the buffer pointer to the next PHY error.
21869 * buflen is the length of this payload, so we need to
21870 * advance past the current header _AND_ the payload.
21871 */
21872 n += sizeof(*ev) + ev->hdr.buf_len;
21873 }
21874 *buf_offset = n;
21875
21876 return QDF_STATUS_SUCCESS;
21877}
21878
Subrat Mishraa667b1c2018-08-02 15:02:04 +053021879/**
21880 * extract_esp_estimation_ev_param_tlv() - extract air time from event
21881 * @wmi_handle: wmi handle
21882 * @evt_buf: pointer to event buffer
21883 * @param: Pointer to hold esp event
21884 *
21885 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
21886 */
21887static QDF_STATUS
21888extract_esp_estimation_ev_param_tlv(wmi_unified_t wmi_handle,
21889 void *evt_buf,
21890 struct esp_estimation_event *param)
21891{
21892 WMI_ESP_ESTIMATE_EVENTID_param_tlvs *param_buf;
21893 wmi_esp_estimate_event_fixed_param *esp_event;
21894
21895 param_buf = (WMI_ESP_ESTIMATE_EVENTID_param_tlvs *)evt_buf;
21896 if (!param_buf) {
21897 WMI_LOGE("Invalid ESP Estimate Event buffer");
21898 return QDF_STATUS_E_INVAL;
21899 }
21900 esp_event = param_buf->fixed_param;
21901 param->ac_airtime_percentage = esp_event->ac_airtime_percentage;
21902 param->pdev_id = convert_target_pdev_id_to_host_pdev_id(
21903 esp_event->pdev_id);
21904
21905 return QDF_STATUS_SUCCESS;
21906}
21907
Govind Singh5eb51532016-03-09 11:34:12 +053021908struct wmi_ops tlv_ops = {
21909 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
21910 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
21911 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053021912 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
21913 .send_hidden_ssid_vdev_restart_cmd =
21914 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021915 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
21916 .send_peer_param_cmd = send_peer_param_cmd_tlv,
21917 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021918 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021919 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021920 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070021921 .send_peer_rx_reorder_queue_setup_cmd =
21922 send_peer_rx_reorder_queue_setup_cmd_tlv,
21923 .send_peer_rx_reorder_queue_remove_cmd =
21924 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053021925 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
21926 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
21927 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021928 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
21929 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080021930 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021931 .send_suspend_cmd = send_suspend_cmd_tlv,
21932 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080021933#ifdef FEATURE_WLAN_D0WOW
21934 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
21935 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
21936#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021937 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
21938 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
21939 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
21940 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021941#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053021942 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021943#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021944 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
21945 .send_stats_request_cmd = send_stats_request_cmd_tlv,
21946 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053021947 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070021948 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021949 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021950 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021951 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
21952 .send_scan_start_cmd = send_scan_start_cmd_tlv,
21953 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
21954 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021955 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021956 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021957 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
21958 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021959 .send_set_sta_uapsd_auto_trig_cmd =
21960 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021961 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
21962 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
21963 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Rachit Kankane9cd0c752018-07-31 16:26:38 +053021964#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +080021965 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
21966 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
21967#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053021968 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
21969 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021970#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053021971 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
21972 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
21973 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
21974 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
21975 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
21976 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
21977 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021978 .send_ocb_start_timing_advert_cmd =
21979 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021980 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
21981 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
21982 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
21983 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
21984#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053021985 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
21986 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
21987 .send_set_mcc_channel_time_latency_cmd =
21988 send_set_mcc_channel_time_latency_cmd_tlv,
21989 .send_set_mcc_channel_time_quota_cmd =
21990 send_set_mcc_channel_time_quota_cmd_tlv,
21991 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
21992 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053021993 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021994 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
21995 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
21996 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021997 .send_probe_rsp_tmpl_send_cmd =
21998 send_probe_rsp_tmpl_send_cmd_tlv,
21999 .send_p2p_go_set_beacon_ie_cmd =
22000 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053022001 .send_setup_install_key_cmd =
22002 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022003 .send_set_gateway_params_cmd =
22004 send_set_gateway_params_cmd_tlv,
22005 .send_set_rssi_monitoring_cmd =
22006 send_set_rssi_monitoring_cmd_tlv,
22007 .send_scan_probe_setoui_cmd =
22008 send_scan_probe_setoui_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022009 .send_roam_scan_offload_rssi_thresh_cmd =
22010 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070022011 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022012 .send_roam_scan_filter_cmd =
22013 send_roam_scan_filter_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022014#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053022015 .send_ipa_offload_control_cmd =
22016 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022017#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053022018 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
22019 .send_plm_start_cmd = send_plm_start_cmd_tlv,
22020 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
22021 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070022022 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022023 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080022024#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053022025 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
22026 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
22027 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080022028#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053022029 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022030 .send_snr_request_cmd = send_snr_request_cmd_tlv,
22031 .send_snr_cmd = send_snr_cmd_tlv,
22032 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080022033#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022034 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
22035 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
22036 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
22037 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053022038 .send_multiple_add_clear_mcbc_filter_cmd =
22039 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070022040 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022041 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
22042 .send_process_gtk_offload_getinfo_cmd =
22043 send_process_gtk_offload_getinfo_cmd_tlv,
22044 .send_enable_enhance_multicast_offload_cmd =
22045 send_enable_enhance_multicast_offload_tlv,
22046 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
22047#ifdef FEATURE_WLAN_RA_FILTERING
22048 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
22049#endif
22050 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022051 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
22052 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022053 .send_lphb_config_tcp_pkt_filter_cmd =
22054 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022055 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22056 .send_lphb_config_udp_pkt_filter_cmd =
22057 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022058 .send_enable_disable_packet_filter_cmd =
22059 send_enable_disable_packet_filter_cmd_tlv,
22060 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080022061#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022062#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022063 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22064 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022065 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022066 .send_roam_scan_offload_mode_cmd =
22067 send_roam_scan_offload_mode_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053022068#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053022069 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053022070#endif
Govind Singh87542482016-06-08 19:40:11 +053022071 .send_roam_scan_offload_ap_profile_cmd =
22072 send_roam_scan_offload_ap_profile_cmd_tlv,
22073#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022074#ifdef WLAN_SUPPORT_GREEN_AP
22075 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22076 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022077 .extract_green_ap_egap_status_info =
22078 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022079#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022080 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22081 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022082 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022083 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022084 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022085#ifdef WLAN_FEATURE_CIF_CFR
22086 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22087#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022088 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022089 .send_dfs_phyerr_filter_offload_en_cmd =
22090 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022091 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22092 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22093 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22094 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22095 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022096 .send_process_add_periodic_tx_ptrn_cmd =
22097 send_process_add_periodic_tx_ptrn_cmd_tlv,
22098 .send_process_del_periodic_tx_ptrn_cmd =
22099 send_process_del_periodic_tx_ptrn_cmd_tlv,
22100 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22101 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22102 .send_set_app_type2_params_in_fw_cmd =
22103 send_set_app_type2_params_in_fw_cmd_tlv,
22104 .send_set_auto_shutdown_timer_cmd =
22105 send_set_auto_shutdown_timer_cmd_tlv,
22106 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22107 .send_process_dhcpserver_offload_cmd =
22108 send_process_dhcpserver_offload_cmd_tlv,
22109 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22110 .send_process_ch_avoid_update_cmd =
22111 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022112 .send_pdev_set_regdomain_cmd =
22113 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022114 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22115 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22116 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22117 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022118 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022119 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022120 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022121 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022122 .send_set_base_macaddr_indicate_cmd =
22123 send_set_base_macaddr_indicate_cmd_tlv,
22124 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22125 .send_enable_specific_fw_logs_cmd =
22126 send_enable_specific_fw_logs_cmd_tlv,
22127 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022128 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022129 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022130#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022131 .send_pdev_set_dual_mac_config_cmd =
22132 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022133#endif
Govind Singha4836fd2016-03-07 16:45:38 +053022134 .send_app_type1_params_in_fw_cmd =
22135 send_app_type1_params_in_fw_cmd_tlv,
22136 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22137 .send_process_roam_synch_complete_cmd =
22138 send_process_roam_synch_complete_cmd_tlv,
22139 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22140 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22141 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022142 .send_roam_scan_offload_scan_period_cmd =
22143 send_roam_scan_offload_scan_period_cmd_tlv,
22144 .send_roam_scan_offload_chan_list_cmd =
22145 send_roam_scan_offload_chan_list_cmd_tlv,
22146 .send_roam_scan_offload_rssi_change_cmd =
22147 send_roam_scan_offload_rssi_change_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022148#ifdef FEATURE_WLAN_APF
22149 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
22150 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
22151 .send_apf_write_work_memory_cmd =
22152 wmi_send_apf_write_work_memory_cmd_tlv,
22153 .send_apf_read_work_memory_cmd =
22154 wmi_send_apf_read_work_memory_cmd_tlv,
22155 .extract_apf_read_memory_resp_event =
22156 wmi_extract_apf_read_memory_resp_event_tlv,
22157#endif /* FEATURE_WLAN_APF */
Gupta, Kapil2e685982016-04-25 19:14:19 +053022158 .send_adapt_dwelltime_params_cmd =
22159 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022160 .send_dbs_scan_sel_params_cmd =
22161 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022162 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022163 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22164 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22165 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22166 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22167 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22168 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022169 .send_vdev_set_custom_aggr_size_cmd =
22170 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022171 .send_vdev_set_qdepth_thresh_cmd =
22172 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022173 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22174 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22175 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022176 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22177 .send_smart_ant_set_training_info_cmd =
22178 send_smart_ant_set_training_info_cmd_tlv,
22179 .send_smart_ant_set_node_config_cmd =
22180 send_smart_ant_set_node_config_cmd_tlv,
Jeffin Mammen095050b2018-07-24 14:20:08 +053022181#ifdef WLAN_ATF_ENABLE
Sathish Kumar02c3b542017-02-22 17:24:45 +053022182 .send_set_atf_cmd = send_set_atf_cmd_tlv,
Jeffin Mammen095050b2018-07-24 14:20:08 +053022183#endif
Sathish Kumar02c3b542017-02-22 17:24:45 +053022184 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22185 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022186 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22187 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22188 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22189 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022190 .send_periodic_chan_stats_config_cmd =
22191 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022192 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22193 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22194 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022195 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22196 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22197 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22198 .send_vdev_spectral_configure_cmd =
22199 send_vdev_spectral_configure_cmd_tlv,
22200 .send_vdev_spectral_enable_cmd =
22201 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022202 .send_thermal_mitigation_param_cmd =
22203 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022204 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22205 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022206 .send_process_update_edca_param_cmd =
22207 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022208 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022209 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022210 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022211 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22212 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022213 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022214 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22215 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22216 .extract_host_mem_req = extract_host_mem_req_tlv,
22217 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022218 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022219 .is_service_enabled = is_service_enabled_tlv,
22220 .save_fw_version = save_fw_version_in_service_ready_tlv,
22221 .ready_extract_init_status = ready_extract_init_status_tlv,
22222 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022223 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022224 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022225 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22226 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022227 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022228 .extract_tbttoffset_update_params =
22229 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022230 .extract_ext_tbttoffset_update_params =
22231 extract_ext_tbttoffset_update_params_tlv,
22232 .extract_tbttoffset_num_vdevs =
22233 extract_tbttoffset_num_vdevs_tlv,
22234 .extract_ext_tbttoffset_num_vdevs =
22235 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022236 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22237 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22238 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22239 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022240#ifdef CONVERGED_TDLS_ENABLE
22241 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22242#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022243 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022244 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022245 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22246 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022247#ifdef CONVERGED_P2P_ENABLE
22248 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
Rachit Kankane9cd0c752018-07-31 16:26:38 +053022249#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +080022250 .extract_p2p_lo_stop_ev_param =
22251 extract_p2p_lo_stop_ev_param_tlv,
22252#endif
Rachit Kankane9cd0c752018-07-31 16:26:38 +053022253#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022254 .extract_offchan_data_tx_compl_param =
22255 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022256 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22257 .extract_all_stats_count = extract_all_stats_counts_tlv,
22258 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022259 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022260 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22261 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070022262 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022263 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022264 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022265 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22266 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22267 .extract_chan_stats = extract_chan_stats_tlv,
22268 .extract_profile_ctx = extract_profile_ctx_tlv,
22269 .extract_profile_data = extract_profile_data_tlv,
22270 .extract_chan_info_event = extract_chan_info_event_tlv,
22271 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022272 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022273#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022274 .send_encrypt_decrypt_send_cmd =
22275 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022276 .extract_encrypt_decrypt_resp_event =
22277 extract_encrypt_decrypt_resp_event_tlv,
22278#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022279 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022280 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22281 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022282 .extract_sar2_result_event = extract_sar2_result_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022283 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022284 .send_multiple_vdev_restart_req_cmd =
22285 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022286 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22287 .extract_hw_mode_cap_service_ready_ext =
22288 extract_hw_mode_cap_service_ready_ext_tlv,
22289 .extract_mac_phy_cap_service_ready_ext =
22290 extract_mac_phy_cap_service_ready_ext_tlv,
22291 .extract_reg_cap_service_ready_ext =
22292 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022293 .extract_dbr_ring_cap_service_ready_ext =
22294 extract_dbr_ring_cap_service_ready_ext_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022295 .extract_sar_cap_service_ready_ext =
22296 extract_sar_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022297 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22298 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022299 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022300 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022301 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022302 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22303 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22304 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022305 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022306 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022307 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022308 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022309 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022310 .extract_pdev_csa_switch_count_status =
22311 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022312 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022313 .extract_pdev_tpc_config_ev_param =
22314 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022315 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022316 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22317 .extract_peer_sta_ps_statechange_ev =
22318 extract_peer_sta_ps_statechange_ev_tlv,
22319 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022320 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053022321#ifdef WLAN_FEATURE_ACTION_OUI
22322 .send_action_oui_cmd = send_action_oui_cmd_tlv,
22323#endif
Arif Hussainf00be1d2017-01-07 18:21:55 -080022324 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22325 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022326 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022327 extract_reg_chan_list_update_event_tlv,
22328 .extract_chainmask_tables =
22329 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022330 .extract_thermal_stats = extract_thermal_stats_tlv,
22331 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022332 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22333 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022334#ifdef DFS_COMPONENT_ENABLE
22335 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22336 .extract_dfs_radar_detection_event =
22337 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022338 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022339#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022340 .convert_pdev_id_host_to_target =
22341 convert_host_pdev_id_to_target_pdev_id_legacy,
22342 .convert_pdev_id_target_to_host =
22343 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022344
22345 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22346 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22347 .extract_reg_11d_new_country_event =
22348 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022349 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022350 .send_limit_off_chan_cmd =
22351 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022352 .extract_reg_ch_avoid_event =
22353 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022354 .send_pdev_caldata_version_check_cmd =
22355 send_pdev_caldata_version_check_cmd_tlv,
22356 .extract_pdev_caldata_version_check_ev_param =
22357 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022358 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22359 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022360 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22361#if defined(WLAN_FEATURE_FILS_SK)
22362 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22363#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022364 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022365#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22366 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22367 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22368 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22369 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22370 .extract_ndp_ind = extract_ndp_ind_tlv,
22371 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22372 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22373 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22374 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
Naveen Rawatd42ce382018-01-09 17:54:41 -080022375 .extract_ndp_sch_update = extract_ndp_sch_update_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022376#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022377 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022378 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022379 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022380#ifdef WLAN_SUPPORT_FILS
22381 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22382 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22383 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22384#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022385 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22386 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022387 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22388 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22389 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22390 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022391 .send_bss_color_change_enable_cmd =
22392 send_bss_color_change_enable_cmd_tlv,
22393 .send_obss_color_collision_cfg_cmd =
22394 send_obss_color_collision_cfg_cmd_tlv,
22395 .extract_obss_color_collision_info =
22396 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022397 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22398 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070022399#ifdef QCA_SUPPORT_CP_STATS
22400 .extract_cca_stats = extract_cca_stats_tlv,
22401#endif
Subrat Mishraa667b1c2018-08-02 15:02:04 +053022402 .extract_esp_estimation_ev_param =
22403 extract_esp_estimation_ev_param_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022404};
22405
Govind Singhe7f2f342016-05-23 12:12:52 +053022406/**
22407 * populate_tlv_event_id() - populates wmi event ids
22408 *
22409 * @param event_ids: Pointer to hold event ids
22410 * Return: None
22411 */
22412static void populate_tlv_events_id(uint32_t *event_ids)
22413{
22414 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22415 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22416 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22417 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22418 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22419 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22420 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22421 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22422 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22423 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22424 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22425 event_ids[wmi_service_ready_ext_event_id] =
22426 WMI_SERVICE_READY_EXT_EVENTID;
22427 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22428 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22429 event_ids[wmi_vdev_install_key_complete_event_id] =
22430 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22431 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22432 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22433
22434 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22435 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22436 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22437 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22438 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22439 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22440 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22441 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022442 event_ids[wmi_peer_delete_response_event_id] =
22443 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022444 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22445 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22446 event_ids[wmi_tbttoffset_update_event_id] =
22447 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022448 event_ids[wmi_ext_tbttoffset_update_event_id] =
22449 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022450 event_ids[wmi_offload_bcn_tx_status_event_id] =
22451 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22452 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22453 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22454 event_ids[wmi_mgmt_tx_completion_event_id] =
22455 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022456 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22457 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022458 event_ids[wmi_tx_delba_complete_event_id] =
22459 WMI_TX_DELBA_COMPLETE_EVENTID;
22460 event_ids[wmi_tx_addba_complete_event_id] =
22461 WMI_TX_ADDBA_COMPLETE_EVENTID;
22462 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22463
22464 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22465
22466 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22467 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22468
22469 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022470 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022471
22472 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22473
22474 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022475 event_ids[wmi_p2p_lo_stop_event_id] =
22476 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022477 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22478 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022479 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022480 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22481 event_ids[wmi_wow_initial_wakeup_event_id] =
22482 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22483
22484 event_ids[wmi_rtt_meas_report_event_id] =
22485 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22486 event_ids[wmi_tsf_meas_report_event_id] =
22487 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22488 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22489 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22490 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22491 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22492 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022493 event_ids[wmi_diag_event_id_log_supported_event_id] =
22494 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22495 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22496 event_ids[wmi_nlo_scan_complete_event_id] =
22497 WMI_NLO_SCAN_COMPLETE_EVENTID;
22498 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22499 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22500
22501 event_ids[wmi_gtk_offload_status_event_id] =
22502 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22503 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22504 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22505 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22506
22507 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22508
22509 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22510
22511 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22512 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22513 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22514 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22515 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22516 event_ids[wmi_wlan_profile_data_event_id] =
22517 WMI_WLAN_PROFILE_DATA_EVENTID;
22518 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22519 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22520 event_ids[wmi_vdev_get_keepalive_event_id] =
22521 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22522 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22523
22524 event_ids[wmi_diag_container_event_id] =
22525 WMI_DIAG_DATA_CONTAINER_EVENTID;
22526
22527 event_ids[wmi_host_auto_shutdown_event_id] =
22528 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22529
22530 event_ids[wmi_update_whal_mib_stats_event_id] =
22531 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22532
22533 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22534 event_ids[wmi_update_vdev_rate_stats_event_id] =
22535 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22536
22537 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022538 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022539
22540 /** Set OCB Sched Response, deprecated */
22541 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
22542
22543 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
22544 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
22545 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
22546
22547 /* GPIO Event */
22548 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
22549 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
22550
22551 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
22552 event_ids[wmi_rfkill_state_change_event_id] =
22553 WMI_RFKILL_STATE_CHANGE_EVENTID;
22554
22555 /* TDLS Event */
22556 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
22557
22558 event_ids[wmi_batch_scan_enabled_event_id] =
22559 WMI_BATCH_SCAN_ENABLED_EVENTID;
22560 event_ids[wmi_batch_scan_result_event_id] =
22561 WMI_BATCH_SCAN_RESULT_EVENTID;
22562 /* OEM Event */
22563 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
22564 event_ids[wmi_oem_meas_report_event_id] =
22565 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
22566 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
22567
22568 /* NAN Event */
22569 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
22570
22571 /* LPI Event */
22572 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
22573 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
22574 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
22575
22576 /* ExtScan events */
22577 event_ids[wmi_extscan_start_stop_event_id] =
22578 WMI_EXTSCAN_START_STOP_EVENTID;
22579 event_ids[wmi_extscan_operation_event_id] =
22580 WMI_EXTSCAN_OPERATION_EVENTID;
22581 event_ids[wmi_extscan_table_usage_event_id] =
22582 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
22583 event_ids[wmi_extscan_cached_results_event_id] =
22584 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
22585 event_ids[wmi_extscan_wlan_change_results_event_id] =
22586 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
22587 event_ids[wmi_extscan_hotlist_match_event_id] =
22588 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
22589 event_ids[wmi_extscan_capabilities_event_id] =
22590 WMI_EXTSCAN_CAPABILITIES_EVENTID;
22591 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
22592 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
22593
22594 /* mDNS offload events */
22595 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
22596
22597 /* SAP Authentication offload events */
22598 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
22599 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
22600
22601 /** Out-of-context-of-bss (OCB) events */
22602 event_ids[wmi_ocb_set_config_resp_event_id] =
22603 WMI_OCB_SET_CONFIG_RESP_EVENTID;
22604 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
22605 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
22606 event_ids[wmi_dcc_get_stats_resp_event_id] =
22607 WMI_DCC_GET_STATS_RESP_EVENTID;
22608 event_ids[wmi_dcc_update_ndl_resp_event_id] =
22609 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
22610 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
22611 /* System-On-Chip events */
22612 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
22613 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
22614 event_ids[wmi_soc_hw_mode_transition_event_id] =
22615 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
22616 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
22617 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022618 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053022619 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
22620 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022621 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053022622 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
22623 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22624 event_ids[wmi_peer_sta_ps_statechg_event_id] =
22625 WMI_PEER_STA_PS_STATECHG_EVENTID;
22626 event_ids[wmi_pdev_channel_hopping_event_id] =
22627 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022628 event_ids[wmi_offchan_data_tx_completion_event] =
22629 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022630 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
22631 event_ids[wmi_dfs_radar_detection_event_id] =
22632 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022633 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070022634 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053022635 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053022636 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022637 event_ids[wmi_service_available_event_id] =
22638 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022639 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022640 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022641 /* NDP events */
22642 event_ids[wmi_ndp_initiator_rsp_event_id] =
22643 WMI_NDP_INITIATOR_RSP_EVENTID;
22644 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
22645 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
22646 event_ids[wmi_ndp_responder_rsp_event_id] =
22647 WMI_NDP_RESPONDER_RSP_EVENTID;
22648 event_ids[wmi_ndp_end_indication_event_id] =
22649 WMI_NDP_END_INDICATION_EVENTID;
22650 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080022651 event_ids[wmi_ndl_schedule_update_event_id] =
22652 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022653
22654 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
22655 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
22656 event_ids[wmi_pdev_chip_power_stats_event_id] =
22657 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
22658 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
22659 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
22660 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022661 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022662 WMI_BPF_CAPABILIY_INFO_EVENTID;
22663 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
22664 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
22665 event_ids[wmi_report_rx_aggr_failure_event_id] =
22666 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
22667 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
22668 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
22669 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
22670 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
22671 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
22672 event_ids[wmi_pdev_hw_mode_transition_event_id] =
22673 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
22674 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
22675 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
22676 event_ids[wmi_coex_bt_activity_event_id] =
22677 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
22678 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
22679 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
22680 event_ids[wmi_radio_tx_power_level_stats_event_id] =
22681 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
22682 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053022683 event_ids[wmi_dma_buf_release_event_id] =
22684 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022685 event_ids[wmi_sap_obss_detection_report_event_id] =
22686 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022687 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080022688 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022689 event_ids[wmi_obss_color_collision_report_event_id] =
22690 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080022691 event_ids[wmi_pdev_div_rssi_antid_event_id] =
22692 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070022693 event_ids[wmi_twt_enable_complete_event_id] =
22694 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022695 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
22696 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022697 event_ids[wmi_wlan_sar2_result_event_id] = WMI_SAR2_RESULT_EVENTID;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053022698 event_ids[wmi_esp_estimate_event_id] = WMI_ESP_ESTIMATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022699}
22700
Soumya Bhat488092d2017-03-22 14:41:01 +053022701/**
22702 * populate_tlv_service() - populates wmi services
22703 *
22704 * @param wmi_service: Pointer to hold wmi_service
22705 * Return: None
22706 */
22707static void populate_tlv_service(uint32_t *wmi_service)
22708{
22709 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022710 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022711 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
22712 wmi_service[wmi_service_roam_scan_offload] =
22713 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
22714 wmi_service[wmi_service_bcn_miss_offload] =
22715 WMI_SERVICE_BCN_MISS_OFFLOAD;
22716 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
22717 wmi_service[wmi_service_sta_advanced_pwrsave] =
22718 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
22719 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
22720 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
22721 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
22722 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
22723 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
22724 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
22725 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
22726 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
22727 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
22728 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
22729 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
22730 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
22731 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
22732 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
22733 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
22734 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
22735 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
22736 wmi_service[wmi_service_packet_power_save] =
22737 WMI_SERVICE_PACKET_POWER_SAVE;
22738 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
22739 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
22740 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
22741 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
22742 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
22743 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
22744 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
22745 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
22746 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
22747 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
22748 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
22749 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
22750 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
22751 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
22752 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
22753 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
22754 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
22755 wmi_service[wmi_service_mcc_bcn_interval_change] =
22756 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
22757 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
22758 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
22759 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
22760 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
22761 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
22762 wmi_service[wmi_service_lte_ant_share_support] =
22763 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
22764 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
22765 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
22766 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
22767 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
22768 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
22769 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
22770 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
22771 wmi_service[wmi_service_bcn_txrate_override] =
22772 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
22773 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
22774 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
22775 wmi_service[wmi_service_estimate_linkspeed] =
22776 WMI_SERVICE_ESTIMATE_LINKSPEED;
22777 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
22778 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
22779 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
22780 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
22781 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
22782 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
22783 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
22784 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
22785 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
22786 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
22787 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
22788 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
22789 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
22790 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
22791 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
22792 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
22793 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
22794 wmi_service[wmi_service_sap_auth_offload] =
22795 WMI_SERVICE_SAP_AUTH_OFFLOAD;
22796 wmi_service[wmi_service_dual_band_simultaneous_support] =
22797 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
22798 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
22799 wmi_service[wmi_service_ap_arpns_offload] =
22800 WMI_SERVICE_AP_ARPNS_OFFLOAD;
22801 wmi_service[wmi_service_per_band_chainmask_support] =
22802 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
22803 wmi_service[wmi_service_packet_filter_offload] =
22804 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
22805 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
22806 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
22807 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
22808 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
22809 wmi_service[wmi_service_multiple_vdev_restart] =
22810 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
22811
22812 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
22813 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
22814 wmi_service[wmi_service_smart_antenna_sw_support] =
22815 WMI_SERVICE_UNAVAILABLE;
22816 wmi_service[wmi_service_smart_antenna_hw_support] =
22817 WMI_SERVICE_UNAVAILABLE;
22818 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053022819 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022820 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053022821 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
22822 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
22823 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
22824 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
22825 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
22826 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
22827 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
22828 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053022829 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
22830 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
22831 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022832 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022833 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
22834 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
22835 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
22836 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
22837 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
22838 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022839 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
22840 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
22841 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
22842 wmi_service[wmi_service_unified_wow_capability] =
22843 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
22844 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022845 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022846 wmi_service[wmi_service_sync_delete_cmds] =
22847 WMI_SERVICE_SYNC_DELETE_CMDS;
22848 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
22849 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
22850 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
22851 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
22852 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
22853 wmi_service[wmi_service_deprecated_replace] =
22854 WMI_SERVICE_DEPRECATED_REPLACE;
22855 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
22856 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
22857 wmi_service[wmi_service_enhanced_mcast_filter] =
22858 WMI_SERVICE_ENHANCED_MCAST_FILTER;
22859 wmi_service[wmi_service_half_rate_quarter_rate_support] =
22860 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
22861 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
22862 wmi_service[wmi_service_p2p_listen_offload_support] =
22863 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
22864 wmi_service[wmi_service_mark_first_wakeup_packet] =
22865 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
22866 wmi_service[wmi_service_multiple_mcast_filter_set] =
22867 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
22868 wmi_service[wmi_service_host_managed_rx_reorder] =
22869 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
22870 wmi_service[wmi_service_flash_rdwr_support] =
22871 WMI_SERVICE_FLASH_RDWR_SUPPORT;
22872 wmi_service[wmi_service_wlan_stats_report] =
22873 WMI_SERVICE_WLAN_STATS_REPORT;
22874 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
22875 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
22876 wmi_service[wmi_service_dfs_phyerr_offload] =
22877 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
22878 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
22879 wmi_service[wmi_service_fw_mem_dump_support] =
22880 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
22881 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
22882 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
22883 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
22884 wmi_service[wmi_service_hw_data_filtering] =
22885 WMI_SERVICE_HW_DATA_FILTERING;
22886 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
22887 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053022888 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053022889 wmi_service[wmi_service_extended_nss_support] =
22890 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053022891 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022892 wmi_service[wmi_service_bcn_offload_start_stop_support] =
22893 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053022894 wmi_service[wmi_service_offchan_data_tid_support] =
22895 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053022896 wmi_service[wmi_service_support_dma] =
22897 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022898 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
22899 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
22900 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080022901 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
22902 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053022903 wmi_service[wmi_service_11k_neighbour_report_support] =
22904 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080022905 wmi_service[wmi_service_ap_obss_detection_offload] =
22906 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
22907 wmi_service[wmi_service_bss_color_offload] =
22908 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053022909 wmi_service[wmi_service_gmac_offload_support] =
22910 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080022911 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
22912 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
22913 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
22914 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070022915 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
22916 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053022917 wmi_service[wmi_service_listen_interval_offload_support] =
22918 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022919
Soumya Bhat488092d2017-03-22 14:41:01 +053022920}
22921
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022922#ifndef CONFIG_MCL
22923
Govind Singhe7f2f342016-05-23 12:12:52 +053022924/**
22925 * populate_pdev_param_tlv() - populates pdev params
22926 *
22927 * @param pdev_param: Pointer to hold pdev params
22928 * Return: None
22929 */
22930static void populate_pdev_param_tlv(uint32_t *pdev_param)
22931{
22932 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
22933 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
22934 pdev_param[wmi_pdev_param_txpower_limit2g] =
22935 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
22936 pdev_param[wmi_pdev_param_txpower_limit5g] =
22937 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
22938 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
22939 pdev_param[wmi_pdev_param_beacon_gen_mode] =
22940 WMI_PDEV_PARAM_BEACON_GEN_MODE;
22941 pdev_param[wmi_pdev_param_beacon_tx_mode] =
22942 WMI_PDEV_PARAM_BEACON_TX_MODE;
22943 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
22944 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
22945 pdev_param[wmi_pdev_param_protection_mode] =
22946 WMI_PDEV_PARAM_PROTECTION_MODE;
22947 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
22948 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
22949 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
22950 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
22951 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
22952 pdev_param[wmi_pdev_param_sta_kickout_th] =
22953 WMI_PDEV_PARAM_STA_KICKOUT_TH;
22954 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
22955 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
22956 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
22957 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
22958 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
22959 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
22960 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
22961 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
22962 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
22963 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
22964 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
22965 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
22966 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
22967 pdev_param[wmi_pdev_param_ltr_sleep_override] =
22968 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
22969 pdev_param[wmi_pdev_param_ltr_rx_override] =
22970 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
22971 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
22972 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
22973 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
22974 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
22975 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
22976 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
22977 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
22978 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
22979 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
22980 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
22981 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
22982 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
22983 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
22984 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
22985 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
22986 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
22987 pdev_param[wmi_pdev_param_peer_stats_update_period] =
22988 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
22989 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
22990 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
22991 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
22992 pdev_param[wmi_pdev_param_arp_ac_override] =
22993 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
22994 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
22995 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
22996 pdev_param[wmi_pdev_param_ani_poll_period] =
22997 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
22998 pdev_param[wmi_pdev_param_ani_listen_period] =
22999 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
23000 pdev_param[wmi_pdev_param_ani_ofdm_level] =
23001 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
23002 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
23003 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
23004 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
23005 pdev_param[wmi_pdev_param_idle_ps_config] =
23006 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
23007 pdev_param[wmi_pdev_param_power_gating_sleep] =
23008 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
23009 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
23010 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
23011 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
23012 pdev_param[wmi_pdev_param_hw_rfkill_config] =
23013 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
23014 pdev_param[wmi_pdev_param_low_power_rf_enable] =
23015 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
23016 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
23017 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
23018 pdev_param[wmi_pdev_param_power_collapse_enable] =
23019 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
23020 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
23021 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
23022 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
23023 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
23024 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
23025 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
23026 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
23027 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
23028 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
23029 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
23030 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
23031 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
23032 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
23033 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
23034 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
23035 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
23036 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
23037 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
23038 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
23039 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
23040 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
23041 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
23042 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
23043 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
23044 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
23045 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
23046 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
23047 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
23048 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
23049 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
23050 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
23051 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
23052 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
23053 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
23054 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
23055 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
23056 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
23057 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
23058 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23059 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23060 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23061 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23062 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23063 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023064 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23065 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23066 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023067 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23068 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023069 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023070 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023071 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23072 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23073 WMI_PDEV_PARAM_PROXY_STA_MODE;
23074 pdev_param[wmi_pdev_param_mu_group_policy] =
23075 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23076 pdev_param[wmi_pdev_param_noise_detection] =
23077 WMI_PDEV_PARAM_NOISE_DETECTION;
23078 pdev_param[wmi_pdev_param_noise_threshold] =
23079 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23080 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23081 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23082 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023083 pdev_param[wmi_pdev_param_atf_strict_sch] =
23084 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23085 pdev_param[wmi_pdev_param_atf_sched_duration] =
23086 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023087 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23088 pdev_param[wmi_pdev_param_sensitivity_level] =
23089 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23090 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23091 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23092 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23093 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023094 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23095 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23096 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23097 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023098 pdev_param[wmi_pdev_param_cca_threshold] =
23099 WMI_PDEV_PARAM_CCA_THRESHOLD;
23100 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23101 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023102 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023103 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23104 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23105 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23106 pdev_param[wmi_pdev_param_arp_srcaddr] =
23107 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23108 pdev_param[wmi_pdev_param_arp_dstaddr] =
23109 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23110 pdev_param[wmi_pdev_param_txpower_decr_db] =
23111 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023112 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23113 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023114 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23115 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023116 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023117 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023118 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23119 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023120 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23121 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023122 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23123 WMI_UNAVAILABLE_PARAM;
Sathish Kumar210b4062018-07-03 17:25:11 +053023124 pdev_param[wmi_pdev_param_igmpmld_override] =
23125 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23126 pdev_param[wmi_pdev_param_igmpmld_tid] =
23127 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023128 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23129 pdev_param[wmi_pdev_param_block_interbss] =
23130 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023131 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023132 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23133 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23134 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023135 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023136 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023137 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23138 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023139 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023140 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23141 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023142 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23143 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23144 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23145 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
Sathish Kumara059f412017-03-22 19:10:28 +053023146 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23147 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23148 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23149 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23150 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23151 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23152 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23153 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23154 pdev_param[wmi_pdev_param_fast_channel_reset] =
23155 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23156 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023157 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023158 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053023159 pdev_param[wmi_pdev_param_antenna_gain_half_db] =
23160 WMI_PDEV_PARAM_ANTENNA_GAIN_HALF_DB;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053023161 pdev_param[wmi_pdev_param_esp_indication_period] =
23162 WMI_PDEV_PARAM_ESP_INDICATION_PERIOD;
Venkateswara Swamy Bandaruc9906412018-08-06 20:44:28 +053023163#ifdef WLAN_RU26_SUPPORT
23164 pdev_param[wmi_pdev_param_ru26_allowed] = WMI_PDEV_PARAM_RU26_ALLOWED;
23165#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053023166}
23167
23168/**
23169 * populate_vdev_param_tlv() - populates vdev params
23170 *
23171 * @param vdev_param: Pointer to hold vdev params
23172 * Return: None
23173 */
23174static void populate_vdev_param_tlv(uint32_t *vdev_param)
23175{
23176 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23177 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23178 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23179 vdev_param[wmi_vdev_param_beacon_interval] =
23180 WMI_VDEV_PARAM_BEACON_INTERVAL;
23181 vdev_param[wmi_vdev_param_listen_interval] =
23182 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23183 vdev_param[wmi_vdev_param_multicast_rate] =
23184 WMI_VDEV_PARAM_MULTICAST_RATE;
23185 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23186 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23187 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23188 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23189 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23190 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23191 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23192 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23193 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23194 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23195 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23196 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23197 vdev_param[wmi_vdev_param_bmiss_count_max] =
23198 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23199 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23200 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23201 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23202 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23203 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23204 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23205 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23206 vdev_param[wmi_vdev_param_disable_htprotection] =
23207 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23208 vdev_param[wmi_vdev_param_sta_quickkickout] =
23209 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23210 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23211 vdev_param[wmi_vdev_param_protection_mode] =
23212 WMI_VDEV_PARAM_PROTECTION_MODE;
23213 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23214 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23215 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23216 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23217 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23218 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23219 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23220 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23221 vdev_param[wmi_vdev_param_bcast_data_rate] =
23222 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23223 vdev_param[wmi_vdev_param_mcast_data_rate] =
23224 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23225 vdev_param[wmi_vdev_param_mcast_indicate] =
23226 WMI_VDEV_PARAM_MCAST_INDICATE;
23227 vdev_param[wmi_vdev_param_dhcp_indicate] =
23228 WMI_VDEV_PARAM_DHCP_INDICATE;
23229 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23230 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23231 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23232 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23233 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23234 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23235 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23236 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23237 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23238 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23239 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23240 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23241 vdev_param[wmi_vdev_param_packet_powersave] =
23242 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23243 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23244 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23245 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23246 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23247 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23248 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23249 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23250 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23251 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23252 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23253 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23254 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23255 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23256 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23257 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23258 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23259 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23260 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23261 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23262 vdev_param[wmi_vdev_param_roam_fw_offload] =
23263 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23264 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23265 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23266 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23267 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23268 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23269 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23270 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23271 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23272 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23273 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23274 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23275 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23276 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23277 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23278 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23279 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23280 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23281 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23282 vdev_param[wmi_vdev_param_inactivity_cnt] =
23283 WMI_VDEV_PARAM_INACTIVITY_CNT;
23284 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23285 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23286 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23287 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23288 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23289 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23290 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23291 vdev_param[wmi_vdev_param_rx_leak_window] =
23292 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23293 vdev_param[wmi_vdev_param_stats_avg_factor] =
23294 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23295 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23296 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23297 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23298 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23299 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23300 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023301 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23302 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023303 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023304 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23305 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23306 WMI_VDEV_PARAM_HE_RANGE_EXT;
23307 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23308 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarika6d1b9422018-06-22 16:44:59 -070023309 vdev_param[wmi_vdev_param_set_he_sounding_mode]
23310 = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023311 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023312 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23313 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23314 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23315 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23316 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23317 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23318 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023319 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23320 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23321 vdev_param[wmi_vdev_param_rc_num_retries] =
23322 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23323 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23324 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23325 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23326 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23327 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23328 vdev_param[wmi_vdev_param_vht80_ratemask] =
23329 WMI_VDEV_PARAM_VHT80_RATEMASK;
23330 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23331 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23332 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023333 vdev_param[wmi_vdev_param_set_he_ltf] =
23334 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053023335 vdev_param[wmi_vdev_param_disable_cabq] =
23336 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053023337 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23338 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023339 vdev_param[wmi_vdev_param_set_ba_mode] =
23340 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023341 vdev_param[wmi_vdev_param_capabilities] =
23342 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023343 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23344 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023345}
23346#endif
23347
Govind Singh5eb51532016-03-09 11:34:12 +053023348/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023349 * populate_target_defines_tlv() - Populate target defines and params
23350 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023351 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023352 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023353 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023354#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023355static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023356{
Govind Singhe7f2f342016-05-23 12:12:52 +053023357 populate_pdev_param_tlv(wmi_handle->pdev_param);
23358 populate_vdev_param_tlv(wmi_handle->vdev_param);
23359}
23360#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023361static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23362{ }
23363#endif
23364
23365/**
Zhang Qian537fca62018-01-03 16:33:24 +080023366 * wmi_ocb_ut_attach() - Attach OCB test framework
23367 * @wmi_handle: wmi handle
23368 *
23369 * Return: None
23370 */
23371#ifdef WLAN_OCB_UT
23372void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23373#else
23374static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23375{
23376 return;
23377}
23378#endif
23379
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023380/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023381 * wmi_tlv_attach() - Attach TLV APIs
23382 *
23383 * Return: None
23384 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023385void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023386{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023387 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023388 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023389 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023390#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023391 /* Skip saving WMI_CMD_HDR and TLV HDR */
23392 wmi_handle->log_info.buf_offset_command = 8;
23393 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023394 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023395#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023396 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023397 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023398 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023399 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080023400 wmi_extscan_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023401}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023402qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023403
23404/**
23405 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23406 *
23407 * Return: None
23408 */
23409void wmi_tlv_init(void)
23410{
23411 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23412}