blob: a25a69b6cb8a3abf968ecd0fd32f80b6f2ebb5b0 [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
Rachit Kankaneed139ff2018-08-01 14:23:55 +053014832#ifdef WLAN_FEATURE_PACKET_FILTERING
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053014833/**
14834 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
14835 * @wmi_handle: wmi handle
14836 * @vdev_id: vdev id
14837 * @enable: Flag to enable/disable packet filter
14838 *
14839 * Return: QDF_STATUS_SUCCESS for success or error code
14840 */
14841static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
14842 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
14843{
14844 int32_t len;
14845 int ret = 0;
14846 wmi_buf_t buf;
14847 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
14848
14849 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
14850
14851 buf = wmi_buf_alloc(wmi_handle, len);
14852 if (!buf) {
14853 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14854 return QDF_STATUS_E_NOMEM;
14855 }
14856
14857 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
14858 WMITLV_SET_HDR(&cmd->tlv_header,
14859 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
14860 WMITLV_GET_STRUCT_TLVLEN(
14861 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
14862
14863 cmd->vdev_id = vdev_id;
14864 if (enable)
14865 cmd->enable = PACKET_FILTER_SET_ENABLE;
14866 else
14867 cmd->enable = PACKET_FILTER_SET_DISABLE;
14868
14869 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
14870 __func__, cmd->enable, vdev_id);
14871
14872 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14873 WMI_PACKET_FILTER_ENABLE_CMDID);
14874 if (ret) {
14875 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
14876 wmi_buf_free(buf);
14877 }
14878
14879 return ret;
14880}
14881
14882/**
14883 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
14884 * @wmi_handle: wmi handle
14885 * @vdev_id: vdev id
14886 * @rcv_filter_param: Packet filter parameters
14887 * @filter_id: Filter id
14888 * @enable: Flag to add/delete packet filter configuration
14889 *
14890 * Return: QDF_STATUS_SUCCESS for success or error code
14891 */
14892static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
14893 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
14894 uint8_t filter_id, bool enable)
14895{
14896 int len, i;
14897 int err = 0;
14898 wmi_buf_t buf;
14899 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
14900
14901
14902 /* allocate the memory */
14903 len = sizeof(*cmd);
14904 buf = wmi_buf_alloc(wmi_handle, len);
14905 if (!buf) {
14906 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14907 return QDF_STATUS_E_NOMEM;
14908 }
14909
14910 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
14911 WMITLV_SET_HDR(&cmd->tlv_header,
14912 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
14913 WMITLV_GET_STRUCT_TLVLEN
14914 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
14915
14916 cmd->vdev_id = vdev_id;
14917 cmd->filter_id = filter_id;
14918 if (enable)
14919 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
14920 else
14921 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
14922
14923 if (enable) {
14924 cmd->num_params = QDF_MIN(
14925 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
14926 rcv_filter_param->num_params);
14927 cmd->filter_type = rcv_filter_param->filter_type;
14928 cmd->coalesce_time = rcv_filter_param->coalesce_time;
14929
14930 for (i = 0; i < cmd->num_params; i++) {
14931 cmd->paramsData[i].proto_type =
14932 rcv_filter_param->params_data[i].protocol_layer;
14933 cmd->paramsData[i].cmp_type =
14934 rcv_filter_param->params_data[i].compare_flag;
14935 cmd->paramsData[i].data_length =
14936 rcv_filter_param->params_data[i].data_length;
14937 cmd->paramsData[i].data_offset =
14938 rcv_filter_param->params_data[i].data_offset;
14939 memcpy(&cmd->paramsData[i].compareData,
14940 rcv_filter_param->params_data[i].compare_data,
14941 sizeof(cmd->paramsData[i].compareData));
14942 memcpy(&cmd->paramsData[i].dataMask,
14943 rcv_filter_param->params_data[i].data_mask,
14944 sizeof(cmd->paramsData[i].dataMask));
14945 }
14946 }
14947
14948 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
14949 cmd->filter_action, cmd->filter_id, cmd->num_params);
14950 /* send the command along with data */
14951 err = wmi_unified_cmd_send(wmi_handle, buf, len,
14952 WMI_PACKET_FILTER_CONFIG_CMDID);
14953 if (err) {
14954 WMI_LOGE("Failed to send pkt_filter cmd");
14955 wmi_buf_free(buf);
14956 return QDF_STATUS_E_FAILURE;
14957 }
14958
14959 return QDF_STATUS_SUCCESS;
14960}
Rachit Kankaneed139ff2018-08-01 14:23:55 +053014961#endif /* End of WLAN_FEATURE_PACKET_FILTERING */
Wu Gao52c0b772018-05-17 16:14:00 +080014962#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014963
Govind Singha4836fd2016-03-07 16:45:38 +053014964/**
14965 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
14966 * @wmi_handle: wmi handle
14967 * @request: SSID hotlist set request
14968 *
Govind Singhb53420c2016-03-09 14:32:57 +053014969 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053014970 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014971static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053014972send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
14973 struct ssid_hotlist_request_params *request)
14974{
14975 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
14976 wmi_buf_t wmi_buf;
14977 uint32_t len;
14978 uint32_t array_size;
14979 uint8_t *buf_ptr;
14980
14981 /* length of fixed portion */
14982 len = sizeof(*cmd);
14983
14984 /* length of variable portion */
14985 array_size =
14986 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14987 len += WMI_TLV_HDR_SIZE + array_size;
14988
14989 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14990 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014991 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14992 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014993 }
14994
14995 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14996 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14997 buf_ptr;
14998 WMITLV_SET_HDR
14999 (&cmd->tlv_header,
15000 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15001 WMITLV_GET_STRUCT_TLVLEN
15002 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15003
15004 cmd->request_id = request->request_id;
15005 cmd->requestor_id = 0;
15006 cmd->vdev_id = request->session_id;
15007 cmd->table_id = 0;
15008 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15009 cmd->total_entries = request->ssid_count;
15010 cmd->num_entries_in_page = request->ssid_count;
15011 cmd->first_entry_index = 0;
15012
15013 buf_ptr += sizeof(*cmd);
15014 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15015
15016 if (request->ssid_count) {
15017 wmi_extscan_hotlist_ssid_entry *entry;
15018 int i;
15019
15020 buf_ptr += WMI_TLV_HDR_SIZE;
15021 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15022 for (i = 0; i < request->ssid_count; i++) {
15023 WMITLV_SET_HDR
15024 (entry,
15025 WMITLV_TAG_ARRAY_STRUC,
15026 WMITLV_GET_STRUCT_TLVLEN
15027 (wmi_extscan_hotlist_ssid_entry));
15028 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015029 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015030 request->ssids[i].ssid.mac_ssid,
15031 request->ssids[i].ssid.length);
15032 entry->band = request->ssids[i].band;
15033 entry->min_rssi = request->ssids[i].rssi_low;
15034 entry->max_rssi = request->ssids[i].rssi_high;
15035 entry++;
15036 }
15037 cmd->mode = WMI_EXTSCAN_MODE_START;
15038 } else {
15039 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15040 }
15041
15042 if (wmi_unified_cmd_send
15043 (wmi_handle, wmi_buf, len,
15044 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015045 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015046 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015047 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015048 }
15049
Govind Singhb53420c2016-03-09 14:32:57 +053015050 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015051}
15052
15053/**
15054 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15055 * @wmi_handle: wmi handle
15056 * @vdev_id: vdev id
15057 *
15058 * This function sends roam synch complete event to fw.
15059 *
15060 * Return: CDF STATUS
15061 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015062static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015063 uint8_t vdev_id)
15064{
15065 wmi_roam_synch_complete_fixed_param *cmd;
15066 wmi_buf_t wmi_buf;
15067 uint8_t *buf_ptr;
15068 uint16_t len;
15069 len = sizeof(wmi_roam_synch_complete_fixed_param);
15070
15071 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15072 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015073 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15074 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015075 }
15076 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15077 buf_ptr = (uint8_t *) cmd;
15078 WMITLV_SET_HDR(&cmd->tlv_header,
15079 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15080 WMITLV_GET_STRUCT_TLVLEN
15081 (wmi_roam_synch_complete_fixed_param));
15082 cmd->vdev_id = vdev_id;
15083 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15084 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015085 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015086 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015087 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015088 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015089 }
15090
Govind Singhb53420c2016-03-09 14:32:57 +053015091 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015092}
15093
15094/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015095 * send_fw_test_cmd_tlv() - send fw test command to fw.
15096 * @wmi_handle: wmi handle
15097 * @wmi_fwtest: fw test command
15098 *
15099 * This function sends fw test command to fw.
15100 *
15101 * Return: CDF STATUS
15102 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015103static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015104QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15105 struct set_fwtest_params *wmi_fwtest)
15106{
15107 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15108 wmi_buf_t wmi_buf;
15109 uint16_t len;
15110
15111 len = sizeof(*cmd);
15112
15113 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15114 if (!wmi_buf) {
15115 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15116 return QDF_STATUS_E_NOMEM;
15117 }
15118
15119 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15120 WMITLV_SET_HDR(&cmd->tlv_header,
15121 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15122 WMITLV_GET_STRUCT_TLVLEN(
15123 wmi_fwtest_set_param_cmd_fixed_param));
15124 cmd->param_id = wmi_fwtest->arg;
15125 cmd->param_value = wmi_fwtest->value;
15126
15127 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15128 WMI_FWTEST_CMDID)) {
15129 WMI_LOGP("%s: failed to send fw test command", __func__);
15130 qdf_nbuf_free(wmi_buf);
15131 return QDF_STATUS_E_FAILURE;
15132 }
15133
15134 return QDF_STATUS_SUCCESS;
15135}
15136
15137/**
Govind Singha4836fd2016-03-07 16:45:38 +053015138 * send_unit_test_cmd_tlv() - send unit test command to fw.
15139 * @wmi_handle: wmi handle
15140 * @wmi_utest: unit test command
15141 *
15142 * This function send unit test command to fw.
15143 *
15144 * Return: CDF STATUS
15145 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015146static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015147 struct wmi_unit_test_cmd *wmi_utest)
15148{
15149 wmi_unit_test_cmd_fixed_param *cmd;
15150 wmi_buf_t wmi_buf;
15151 uint8_t *buf_ptr;
15152 int i;
15153 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015154 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015155
15156 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015157 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015158 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15159
15160 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15161 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015162 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15163 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015164 }
15165
15166 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15167 buf_ptr = (uint8_t *) cmd;
15168 WMITLV_SET_HDR(&cmd->tlv_header,
15169 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15170 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15171 cmd->vdev_id = wmi_utest->vdev_id;
15172 cmd->module_id = wmi_utest->module_id;
15173 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015174 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015175 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15176 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15177 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015178 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015179 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15180 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15181 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015182 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015183 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015184 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015185 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015186 }
15187 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15188 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015189 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015190 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015191 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015192 }
15193
Govind Singhb53420c2016-03-09 14:32:57 +053015194 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015195}
15196
15197/**
15198 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15199 * @wmi_handle: wma handle
15200 * @roaminvoke: roam invoke command
15201 *
15202 * Send roam invoke command to fw for fastreassoc.
15203 *
15204 * Return: CDF STATUS
15205 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015206static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015207 struct wmi_roam_invoke_cmd *roaminvoke,
15208 uint32_t ch_hz)
15209{
15210 wmi_roam_invoke_cmd_fixed_param *cmd;
15211 wmi_buf_t wmi_buf;
15212 u_int8_t *buf_ptr;
15213 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015214 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015215 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015216 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015217
15218 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015219 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015220 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15221 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015222 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15223 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15224 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015225 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15226 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015227 }
15228
15229 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15230 buf_ptr = (u_int8_t *) cmd;
15231 WMITLV_SET_HDR(&cmd->tlv_header,
15232 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15233 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15234 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015235 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015236 if (roaminvoke->is_same_bssid)
15237 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15238 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015239
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015240 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015241 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015242 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15243 cmd->num_buf = 1;
15244 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015245 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015246 cmd->num_buf = 0;
15247 }
Naveen Rawat77797922017-01-20 17:00:07 -080015248
Govind Singha4836fd2016-03-07 16:45:38 +053015249 cmd->roam_ap_sel_mode = 0;
15250 cmd->roam_delay = 0;
15251 cmd->num_chan = 1;
15252 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015253
Govind Singha4836fd2016-03-07 16:45:38 +053015254 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15255 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15256 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015257 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015258 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015259 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015260 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15261 (sizeof(wmi_mac_addr)));
15262 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15263 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015264
15265 /* move to next tlv i.e. bcn_prb_buf_list */
15266 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15267
15268 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15269 sizeof(wmi_tlv_buf_len_param));
15270
15271 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15272 buf_len_tlv->buf_len = roaminvoke->frame_len;
15273
15274 /* move to next tlv i.e. bcn_prb_frm */
15275 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15276 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15277 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15278
15279 /* copy frame after the header */
15280 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15281 roaminvoke->frame_buf,
15282 roaminvoke->frame_len);
15283
15284 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070015285 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat77797922017-01-20 17:00:07 -080015286 buf_ptr + WMI_TLV_HDR_SIZE,
15287 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015288 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15289 cmd->flags, cmd->roam_scan_mode,
15290 cmd->roam_ap_sel_mode, cmd->roam_delay,
15291 cmd->num_chan, cmd->num_bssid);
15292 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015293
Govind Singha4836fd2016-03-07 16:45:38 +053015294 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15295 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015296 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015297 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015298 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015299 }
15300
Govind Singhb53420c2016-03-09 14:32:57 +053015301 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015302}
15303
15304/**
15305 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15306 * @wmi_handle: wmi handle
15307 * @command: command
15308 * @vdev_id: vdev id
15309 *
15310 * This function set roam offload command to fw.
15311 *
15312 * Return: CDF status
15313 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015314static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015315 uint32_t command, uint32_t vdev_id)
15316{
Govind Singh67922e82016-04-01 16:48:57 +053015317 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015318 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15319 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015320 int len;
15321 uint8_t *buf_ptr;
15322
15323 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15324 buf = wmi_buf_alloc(wmi_handle, len);
15325 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015326 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15327 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015328 }
15329
15330 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15331
15332 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15333 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15334 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15335 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15336 cmd_fp->vdev_id = vdev_id;
15337 cmd_fp->command_arg = command;
15338
15339 status = wmi_unified_cmd_send(wmi_handle, buf,
15340 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015341 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015342 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015343 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015344 goto error;
15345 }
15346
Govind Singhb53420c2016-03-09 14:32:57 +053015347 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15348 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015349
15350error:
15351 wmi_buf_free(buf);
15352
Govind Singh67922e82016-04-01 16:48:57 +053015353 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015354}
15355
15356/**
15357 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15358 * @wmi_handle: wmi handle
15359 * @ap_profile_p: ap profile
15360 * @vdev_id: vdev id
15361 *
15362 * Send WMI_ROAM_AP_PROFILE to firmware
15363 *
15364 * Return: CDF status
15365 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015366static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015367 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015368{
Govind Singha4836fd2016-03-07 16:45:38 +053015369 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015370 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015371 int len;
15372 uint8_t *buf_ptr;
15373 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015374 wmi_roam_cnd_scoring_param *score_param;
15375 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015376
15377 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015378 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015379 buf = wmi_buf_alloc(wmi_handle, len);
15380 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015381 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15382 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015383 }
15384
15385 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15386 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15387 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15388 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15389 WMITLV_GET_STRUCT_TLVLEN
15390 (wmi_roam_ap_profile_fixed_param));
15391 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015392 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015393 roam_ap_profile_fp->id = 0;
15394 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15395
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015396 profile = (wmi_ap_profile *)buf_ptr;
15397 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015398 WMITLV_TAG_STRUC_wmi_ap_profile,
15399 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015400 profile->flags = ap_profile->profile.flags;
15401 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15402 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15403 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15404 profile->ssid.ssid_len);
15405 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15406 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15407 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15408 profile->rsn_mcastmgmtcipherset =
15409 ap_profile->profile.rsn_mcastmgmtcipherset;
15410 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15411
15412 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",
15413 profile->flags, profile->rssi_threshold,
15414 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15415 profile->rsn_authmode, profile->rsn_ucastcipherset,
15416 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15417 profile->rssi_abs_thresh);
15418
15419 buf_ptr += sizeof(wmi_ap_profile);
15420
15421 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15422 WMITLV_SET_HDR(&score_param->tlv_header,
15423 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15424 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15425 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15426 score_param->rssi_weightage_pcnt =
15427 ap_profile->param.rssi_weightage;
15428 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15429 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15430 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15431 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15432 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15433 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15434 score_param->esp_qbss_weightage_pcnt =
15435 ap_profile->param.esp_qbss_weightage;
15436 score_param->beamforming_weightage_pcnt =
15437 ap_profile->param.beamforming_weightage;
15438 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15439 score_param->oce_wan_weightage_pcnt =
15440 ap_profile->param.oce_wan_weightage;
15441
15442 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",
15443 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15444 score_param->ht_weightage_pcnt,
15445 score_param->vht_weightage_pcnt,
15446 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15447 score_param->band_weightage_pcnt,
15448 score_param->nss_weightage_pcnt,
15449 score_param->esp_qbss_weightage_pcnt,
15450 score_param->beamforming_weightage_pcnt,
15451 score_param->pcl_weightage_pcnt,
15452 score_param->oce_wan_weightage_pcnt);
15453
15454 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15455 score_param->band_scoring.score_pcnt =
15456 ap_profile->param.band_index_score;
15457 score_param->nss_scoring.score_pcnt =
15458 ap_profile->param.nss_index_score;
15459
15460 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15461 score_param->bw_scoring.score_pcnt,
15462 score_param->band_scoring.score_pcnt,
15463 score_param->nss_scoring.score_pcnt);
15464
15465 score_param->rssi_scoring.best_rssi_threshold =
15466 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15467 score_param->rssi_scoring.good_rssi_threshold =
15468 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15469 score_param->rssi_scoring.bad_rssi_threshold =
15470 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15471 score_param->rssi_scoring.good_rssi_pcnt =
15472 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15473 score_param->rssi_scoring.bad_rssi_pcnt =
15474 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15475 score_param->rssi_scoring.good_bucket_size =
15476 ap_profile->param.rssi_scoring.good_bucket_size;
15477 score_param->rssi_scoring.bad_bucket_size =
15478 ap_profile->param.rssi_scoring.bad_bucket_size;
15479 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15480 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15481
15482 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15483 score_param->rssi_scoring.best_rssi_threshold,
15484 score_param->rssi_scoring.good_rssi_threshold,
15485 score_param->rssi_scoring.bad_rssi_threshold,
15486 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15487 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15488 score_param->rssi_scoring.good_rssi_pcnt,
15489 score_param->rssi_scoring.bad_rssi_pcnt,
15490 score_param->rssi_scoring.good_bucket_size,
15491 score_param->rssi_scoring.bad_bucket_size);
15492
15493 score_param->esp_qbss_scoring.num_slot =
15494 ap_profile->param.esp_qbss_scoring.num_slot;
15495 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15496 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15497 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15498 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15499 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15500 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15501 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15502 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15503
15504 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15505 score_param->esp_qbss_scoring.num_slot,
15506 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15507 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15508 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15509 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15510
15511 score_param->oce_wan_scoring.num_slot =
15512 ap_profile->param.oce_wan_scoring.num_slot;
15513 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15514 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15515 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15516 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15517 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15518 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15519 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15520 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15521
15522 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15523 score_param->oce_wan_scoring.num_slot,
15524 score_param->oce_wan_scoring.score_pcnt3_to_0,
15525 score_param->oce_wan_scoring.score_pcnt7_to_4,
15526 score_param->oce_wan_scoring.score_pcnt11_to_8,
15527 score_param->oce_wan_scoring.score_pcnt15_to_12);
15528
Govind Singha4836fd2016-03-07 16:45:38 +053015529 status = wmi_unified_cmd_send(wmi_handle, buf,
15530 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015531 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015532 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015533 status);
Govind Singh67922e82016-04-01 16:48:57 +053015534 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015535 }
15536
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +053015537 WMI_LOGD("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015538
Govind Singh67922e82016-04-01 16:48:57 +053015539 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015540}
15541
15542/**
15543 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15544 * @wmi_handle: wmi handle
15545 * @scan_period: scan period
15546 * @scan_age: scan age
15547 * @vdev_id: vdev id
15548 *
15549 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15550 *
15551 * Return: CDF status
15552 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015553static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015554 uint32_t scan_period,
15555 uint32_t scan_age,
15556 uint32_t vdev_id)
15557{
Govind Singh67922e82016-04-01 16:48:57 +053015558 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015559 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015560 int len;
15561 uint8_t *buf_ptr;
15562 wmi_roam_scan_period_fixed_param *scan_period_fp;
15563
15564 /* Send scan period values */
15565 len = sizeof(wmi_roam_scan_period_fixed_param);
15566 buf = wmi_buf_alloc(wmi_handle, len);
15567 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015568 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15569 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015570 }
15571
15572 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15573 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15574 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15575 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15576 WMITLV_GET_STRUCT_TLVLEN
15577 (wmi_roam_scan_period_fixed_param));
15578 /* fill in scan period values */
15579 scan_period_fp->vdev_id = vdev_id;
15580 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15581 scan_period_fp->roam_scan_age = scan_age;
15582
15583 status = wmi_unified_cmd_send(wmi_handle, buf,
15584 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015585 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015586 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015587 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015588 goto error;
15589 }
15590
Govind Singhb53420c2016-03-09 14:32:57 +053015591 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015592 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015593 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015594error:
15595 wmi_buf_free(buf);
15596
Govind Singh67922e82016-04-01 16:48:57 +053015597 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015598}
15599
15600/**
15601 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15602 * @wmi_handle: wmi handle
15603 * @chan_count: channel count
15604 * @chan_list: channel list
15605 * @list_type: list type
15606 * @vdev_id: vdev id
15607 *
15608 * Set roam offload channel list.
15609 *
15610 * Return: CDF status
15611 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015612static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015613 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015614 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015615 uint8_t list_type, uint32_t vdev_id)
15616{
Govind Singha4836fd2016-03-07 16:45:38 +053015617 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015618 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015619 int len, list_tlv_len;
15620 int i;
15621 uint8_t *buf_ptr;
15622 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053015623 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053015624
15625 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053015626 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053015627 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053015628 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053015629 }
15630 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053015631 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015632 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
15633 buf = wmi_buf_alloc(wmi_handle, len);
15634 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015635 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15636 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015637 }
15638
15639 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15640 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
15641 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
15642 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
15643 WMITLV_GET_STRUCT_TLVLEN
15644 (wmi_roam_chan_list_fixed_param));
15645 chan_list_fp->vdev_id = vdev_id;
15646 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053015647 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053015648 /* external app is controlling channel list */
15649 chan_list_fp->chan_list_type =
15650 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
15651 } else {
15652 /* umac supplied occupied channel list in LFR */
15653 chan_list_fp->chan_list_type =
15654 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
15655 }
15656
15657 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
15658 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15659 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015660 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015661 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053015662 for (i = 0; ((i < chan_list_fp->num_chan) &&
15663 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
15664 roam_chan_list_array[i] = chan_list[i];
Sandeep Puligilla412b36f2018-07-02 11:43:07 -070015665 WMI_LOGD("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015666 }
15667
15668 status = wmi_unified_cmd_send(wmi_handle, buf,
15669 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053015670 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015671 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015672 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015673 goto error;
15674 }
15675
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015676 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053015677 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015678error:
15679 wmi_buf_free(buf);
15680
Govind Singh67922e82016-04-01 16:48:57 +053015681 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015682}
15683
15684/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015685 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
15686 * @wmi_handle: wmi handle
15687 * @req_buf: per roam config buffer
15688 *
15689 * Return: QDF status
15690 */
15691static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
15692 struct wmi_per_roam_config_req *req_buf)
15693{
15694 wmi_buf_t buf = NULL;
15695 QDF_STATUS status;
15696 int len;
15697 uint8_t *buf_ptr;
15698 wmi_roam_per_config_fixed_param *wmi_per_config;
15699
15700 len = sizeof(wmi_roam_per_config_fixed_param);
15701 buf = wmi_buf_alloc(wmi_handle, len);
15702 if (!buf) {
15703 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15704 return QDF_STATUS_E_NOMEM;
15705 }
15706
15707 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15708 wmi_per_config =
15709 (wmi_roam_per_config_fixed_param *) buf_ptr;
15710 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
15711 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
15712 WMITLV_GET_STRUCT_TLVLEN
15713 (wmi_roam_per_config_fixed_param));
15714
15715 /* fill in per roam config values */
15716 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015717
15718 wmi_per_config->enable = req_buf->per_config.enable;
15719 wmi_per_config->high_rate_thresh =
15720 (req_buf->per_config.tx_high_rate_thresh << 16) |
15721 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
15722 wmi_per_config->low_rate_thresh =
15723 (req_buf->per_config.tx_low_rate_thresh << 16) |
15724 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
15725 wmi_per_config->pkt_err_rate_thresh_pct =
15726 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
15727 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
15728 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053015729 wmi_per_config->pkt_err_rate_mon_time =
15730 (req_buf->per_config.tx_per_mon_time << 16) |
15731 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053015732 wmi_per_config->min_candidate_rssi =
15733 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015734
15735 /* Send per roam config parameters */
15736 status = wmi_unified_cmd_send(wmi_handle, buf,
15737 len, WMI_ROAM_PER_CONFIG_CMDID);
15738 if (QDF_IS_STATUS_ERROR(status)) {
15739 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
Sandeep Puligilla3dd74122018-08-18 12:42:41 -070015740 status);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015741 wmi_buf_free(buf);
15742 return status;
15743 }
Sandeep Puligilla3dd74122018-08-18 12:42:41 -070015744 WMI_LOGD(FL("per roam enable=%d, vdev=%d"),
15745 req_buf->per_config.enable, req_buf->vdev_id);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015746
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015747 return QDF_STATUS_SUCCESS;
15748}
15749
15750/**
Govind Singha4836fd2016-03-07 16:45:38 +053015751 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
15752 * @wmi_handle: wmi handle
15753 * @rssi_change_thresh: RSSI Change threshold
15754 * @bcn_rssi_weight: beacon RSSI weight
15755 * @vdev_id: vdev id
15756 *
15757 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
15758 *
15759 * Return: CDF status
15760 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015761static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015762 uint32_t vdev_id,
15763 int32_t rssi_change_thresh,
15764 uint32_t bcn_rssi_weight,
15765 uint32_t hirssi_delay_btw_scans)
15766{
Govind Singha4836fd2016-03-07 16:45:38 +053015767 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015768 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015769 int len;
15770 uint8_t *buf_ptr;
15771 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
15772
15773 /* Send rssi change parameters */
15774 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
15775 buf = wmi_buf_alloc(wmi_handle, len);
15776 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015777 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15778 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015779 }
15780
15781 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15782 rssi_change_fp =
15783 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
15784 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
15785 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
15786 WMITLV_GET_STRUCT_TLVLEN
15787 (wmi_roam_scan_rssi_change_threshold_fixed_param));
15788 /* fill in rssi change threshold (hysteresis) values */
15789 rssi_change_fp->vdev_id = vdev_id;
15790 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
15791 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
15792 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
15793
15794 status = wmi_unified_cmd_send(wmi_handle, buf,
15795 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053015796 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015797 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015798 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015799 goto error;
15800 }
15801
Sandeep Puligilla3dd74122018-08-18 12:42:41 -070015802 WMI_LOGD(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
15803 rssi_change_thresh, bcn_rssi_weight);
15804 WMI_LOGD(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
Govind Singhb53420c2016-03-09 14:32:57 +053015805 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015806error:
15807 wmi_buf_free(buf);
15808
Govind Singh67922e82016-04-01 16:48:57 +053015809 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015810}
15811
Govind Singhbca3b1b2016-05-02 17:59:24 +053015812/**
15813 * send_power_dbg_cmd_tlv() - send power debug commands
15814 * @wmi_handle: wmi handle
15815 * @param: wmi power debug parameter
15816 *
15817 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
15818 *
15819 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15820 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015821static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
15822 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053015823{
15824 wmi_buf_t buf = NULL;
15825 QDF_STATUS status;
15826 int len, args_tlv_len;
15827 uint8_t *buf_ptr;
15828 uint8_t i;
15829 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
15830 uint32_t *cmd_args;
15831
15832 /* Prepare and send power debug cmd parameters */
15833 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
15834 len = sizeof(*cmd) + args_tlv_len;
15835 buf = wmi_buf_alloc(wmi_handle, len);
15836 if (!buf) {
15837 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15838 return QDF_STATUS_E_NOMEM;
15839 }
15840
15841 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15842 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
15843 WMITLV_SET_HDR(&cmd->tlv_header,
15844 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
15845 WMITLV_GET_STRUCT_TLVLEN
15846 (wmi_pdev_wal_power_debug_cmd_fixed_param));
15847
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015848 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15849 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053015850 cmd->module_id = param->module_id;
15851 cmd->num_args = param->num_args;
15852 buf_ptr += sizeof(*cmd);
15853 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15854 (param->num_args * sizeof(uint32_t)));
15855 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
15856 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080015857 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053015858 cmd_args[i] = param->args[i];
15859 WMI_LOGI("%d,", param->args[i]);
15860 }
15861
15862 status = wmi_unified_cmd_send(wmi_handle, buf,
15863 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
15864 if (QDF_IS_STATUS_ERROR(status)) {
15865 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
15866 status);
15867 goto error;
15868 }
15869
15870 return QDF_STATUS_SUCCESS;
15871error:
15872 wmi_buf_free(buf);
15873
15874 return status;
15875}
15876
Govind Singhe7f2f342016-05-23 12:12:52 +053015877/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015878 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15879 * @wmi_handle: wmi handle
15880 * @param: wmi multiple vdev restart req param
15881 *
15882 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15883 *
15884 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15885 */
15886static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15887 wmi_unified_t wmi_handle,
15888 struct multiple_vdev_restart_params *param)
15889{
15890 wmi_buf_t buf;
15891 QDF_STATUS qdf_status;
15892 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15893 int i;
15894 uint8_t *buf_ptr;
15895 uint32_t *vdev_ids;
15896 wmi_channel *chan_info;
15897 struct channel_param *tchan_info;
15898 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15899
15900 len += sizeof(wmi_channel);
15901 if (param->num_vdevs)
15902 len += sizeof(uint32_t) * param->num_vdevs;
15903
15904 buf = wmi_buf_alloc(wmi_handle, len);
15905 if (!buf) {
15906 WMI_LOGE("Failed to allocate memory\n");
15907 qdf_status = QDF_STATUS_E_NOMEM;
15908 goto end;
15909 }
15910
15911 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15912 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15913 buf_ptr;
15914
15915 WMITLV_SET_HDR(&cmd->tlv_header,
15916 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15917 WMITLV_GET_STRUCT_TLVLEN
15918 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015919 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15920 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015921 cmd->requestor_id = param->requestor_id;
15922 cmd->disable_hw_ack = param->disable_hw_ack;
15923 cmd->cac_duration_ms = param->cac_duration_ms;
15924 cmd->num_vdevs = param->num_vdevs;
15925
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015926 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
15927 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
15928 " cmd->num_vdevs: %d ",
15929 __func__, cmd->pdev_id, cmd->requestor_id,
15930 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015931 buf_ptr += sizeof(*cmd);
15932
15933 WMITLV_SET_HDR(buf_ptr,
15934 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015935 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015936 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15937 for (i = 0; i < param->num_vdevs; i++) {
15938 vdev_ids[i] = param->vdev_ids[i];
15939 }
15940
Vivekc5823092018-03-22 23:27:21 +053015941 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015942
15943 WMITLV_SET_HDR(buf_ptr,
15944 WMITLV_TAG_STRUC_wmi_channel,
15945 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015946 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015947 tchan_info = &(param->ch_param);
15948 chan_info->mhz = tchan_info->mhz;
15949 chan_info->band_center_freq1 = tchan_info->cfreq1;
15950 chan_info->band_center_freq2 = tchan_info->cfreq2;
15951 if (tchan_info->is_chan_passive)
15952 WMI_SET_CHANNEL_FLAG(chan_info,
15953 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015954 if (tchan_info->dfs_set)
15955 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
15956
Sathish Kumar45e991b2017-02-27 10:35:40 +053015957 if (tchan_info->allow_vht)
15958 WMI_SET_CHANNEL_FLAG(chan_info,
15959 WMI_CHAN_FLAG_ALLOW_VHT);
15960 else if (tchan_info->allow_ht)
15961 WMI_SET_CHANNEL_FLAG(chan_info,
15962 WMI_CHAN_FLAG_ALLOW_HT);
15963 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15964 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15965 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15966 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15967 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15968 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080015969 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015970
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015971 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
15972 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
15973 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
15974 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
15975 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
15976 "tchan_info->reg_class_id: %d ,"
15977 "tchan_info->maxregpower : %d ", __func__,
15978 tchan_info->is_chan_passive, tchan_info->dfs_set,
15979 tchan_info->allow_vht, tchan_info->allow_ht,
15980 tchan_info->antennamax, tchan_info->phy_mode,
15981 tchan_info->minpower, tchan_info->maxpower,
15982 tchan_info->maxregpower, tchan_info->reg_class_id,
15983 tchan_info->maxregpower);
15984
Sathish Kumar45e991b2017-02-27 10:35:40 +053015985 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15986 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15987
15988 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15989 WMI_LOGE("%s: Failed to send\n", __func__);
15990 wmi_buf_free(buf);
15991 }
15992
15993end:
15994 return qdf_status;
15995}
15996
15997/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015998 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15999 * @wmi_handle: wmi handle
16000 * @pdev_id: pdev id
16001 *
16002 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16003 *
16004 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16005 */
16006static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16007 uint32_t pdev_id)
16008{
16009 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16010 wmi_buf_t buf;
16011 uint16_t len;
16012 QDF_STATUS ret;
16013
16014 len = sizeof(*cmd);
16015 buf = wmi_buf_alloc(wmi_handle, len);
16016
16017 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16018
16019 if (!buf) {
16020 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16021 return QDF_STATUS_E_NOMEM;
16022 }
16023
16024 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16025 wmi_buf_data(buf);
16026
16027 WMITLV_SET_HDR(&cmd->tlv_header,
16028 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16029 WMITLV_GET_STRUCT_TLVLEN(
16030 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16031
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016032 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016033 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16034 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16035 if (QDF_IS_STATUS_ERROR(ret)) {
16036 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16037 __func__, ret, pdev_id);
16038 wmi_buf_free(buf);
16039 return QDF_STATUS_E_FAILURE;
16040 }
16041
16042 return QDF_STATUS_SUCCESS;
16043}
16044
16045/**
16046 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16047 * @wmi_handle: wmi handle
16048 * @pdev_id: pdev id
16049 *
16050 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16051 *
16052 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16053 */
16054static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16055 uint32_t pdev_id)
16056{
16057 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16058 wmi_buf_t buf;
16059 uint16_t len;
16060 QDF_STATUS ret;
16061
16062 len = sizeof(*cmd);
16063 buf = wmi_buf_alloc(wmi_handle, len);
16064
16065 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16066
16067 if (!buf) {
16068 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16069 return QDF_STATUS_E_NOMEM;
16070 }
16071
16072 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16073 wmi_buf_data(buf);
16074
16075 WMITLV_SET_HDR(&cmd->tlv_header,
16076 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16077 WMITLV_GET_STRUCT_TLVLEN(
16078 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16079
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016080 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016081 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16082 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16083 if (QDF_IS_STATUS_ERROR(ret)) {
16084 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16085 __func__, ret, pdev_id);
16086 wmi_buf_free(buf);
16087 return QDF_STATUS_E_FAILURE;
16088 }
16089
16090 return QDF_STATUS_SUCCESS;
16091}
16092
16093/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016094 * init_cmd_send_tlv() - send initialization cmd to fw
16095 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016096 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016097 *
16098 * Return: QDF_STATUS_SUCCESS for success or error code
16099 */
16100static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016101 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016102{
16103 wmi_buf_t buf;
16104 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016105 uint8_t *buf_ptr;
16106 wmi_resource_config *resource_cfg;
16107 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016108 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016109 uint16_t idx;
16110 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016111 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016112
Kiran Venkatappa26117052016-12-23 19:58:54 +053016113 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16114 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016115 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016116
16117 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16118 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16119 WMI_TLV_HDR_SIZE +
16120 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16121
16122 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016123 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053016124 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053016125 return QDF_STATUS_E_FAILURE;
16126 }
16127
16128 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16129 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16130 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16131
16132 host_mem_chunks = (wlan_host_memory_chunk *)
16133 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16134 + WMI_TLV_HDR_SIZE);
16135
16136 WMITLV_SET_HDR(&cmd->tlv_header,
16137 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16138 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16139
Kiran Venkatappa26117052016-12-23 19:58:54 +053016140 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016141 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16142 WMITLV_TAG_STRUC_wmi_resource_config,
16143 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16144
Kiran Venkatappa26117052016-12-23 19:58:54 +053016145 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016146 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16147 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16148 WMITLV_GET_STRUCT_TLVLEN
16149 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016150 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16151 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16152 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016153 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16154 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016155 idx, host_mem_chunks[idx].size,
16156 host_mem_chunks[idx].ptr);
16157 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016158 cmd->num_host_mem_chunks = param->num_mem_chunks;
16159 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16160
Govind Singhe7f2f342016-05-23 12:12:52 +053016161 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16162 WMITLV_TAG_ARRAY_STRUC,
16163 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016164 param->num_mem_chunks));
16165
16166 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016167 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016168
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016169 /* Fill fw_abi_vers */
16170 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016171
Abhishek Singh716c46c2016-05-04 16:24:07 +053016172 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16173 if (QDF_IS_STATUS_ERROR(ret)) {
16174 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16175 ret);
16176 wmi_buf_free(buf);
16177 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016178
Abhishek Singh716c46c2016-05-04 16:24:07 +053016179 return ret;
16180
Govind Singhe7f2f342016-05-23 12:12:52 +053016181}
16182
16183/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016184 * send_addba_send_cmd_tlv() - send addba send command to fw
16185 * @wmi_handle: wmi handle
16186 * @param: pointer to delba send params
16187 * @macaddr: peer mac address
16188 *
16189 * Send WMI_ADDBA_SEND_CMDID command to firmware
16190 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16191 */
16192static QDF_STATUS
16193send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
16194 uint8_t macaddr[IEEE80211_ADDR_LEN],
16195 struct addba_send_params *param)
16196{
16197 wmi_addba_send_cmd_fixed_param *cmd;
16198 wmi_buf_t buf;
16199 uint16_t len;
16200 QDF_STATUS ret;
16201
16202 len = sizeof(*cmd);
16203
16204 buf = wmi_buf_alloc(wmi_handle, len);
16205 if (!buf) {
16206 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16207 return QDF_STATUS_E_NOMEM;
16208 }
16209
16210 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
16211
16212 WMITLV_SET_HDR(&cmd->tlv_header,
16213 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
16214 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
16215
16216 cmd->vdev_id = param->vdev_id;
16217 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16218 cmd->tid = param->tidno;
16219 cmd->buffersize = param->buffersize;
16220
16221 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
16222 if (QDF_IS_STATUS_ERROR(ret)) {
16223 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16224 wmi_buf_free(buf);
16225 return QDF_STATUS_E_FAILURE;
16226 }
16227
16228 return QDF_STATUS_SUCCESS;
16229}
16230
16231/**
16232 * send_delba_send_cmd_tlv() - send delba send command to fw
16233 * @wmi_handle: wmi handle
16234 * @param: pointer to delba send params
16235 * @macaddr: peer mac address
16236 *
16237 * Send WMI_DELBA_SEND_CMDID command to firmware
16238 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16239 */
16240static QDF_STATUS
16241send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
16242 uint8_t macaddr[IEEE80211_ADDR_LEN],
16243 struct delba_send_params *param)
16244{
16245 wmi_delba_send_cmd_fixed_param *cmd;
16246 wmi_buf_t buf;
16247 uint16_t len;
16248 QDF_STATUS ret;
16249
16250 len = sizeof(*cmd);
16251
16252 buf = wmi_buf_alloc(wmi_handle, len);
16253 if (!buf) {
16254 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16255 return QDF_STATUS_E_NOMEM;
16256 }
16257
16258 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
16259
16260 WMITLV_SET_HDR(&cmd->tlv_header,
16261 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
16262 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
16263
16264 cmd->vdev_id = param->vdev_id;
16265 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16266 cmd->tid = param->tidno;
16267 cmd->initiator = param->initiator;
16268 cmd->reasoncode = param->reasoncode;
16269
16270 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
16271 if (QDF_IS_STATUS_ERROR(ret)) {
16272 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16273 wmi_buf_free(buf);
16274 return QDF_STATUS_E_FAILURE;
16275 }
16276
16277 return QDF_STATUS_SUCCESS;
16278}
16279
16280/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016281 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
16282 * to fw
16283 * @wmi_handle: wmi handle
16284 * @param: pointer to addba clearresp params
16285 * @macaddr: peer mac address
16286 * Return: 0 for success or error code
16287 */
16288static QDF_STATUS
16289send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
16290 uint8_t macaddr[IEEE80211_ADDR_LEN],
16291 struct addba_clearresponse_params *param)
16292{
16293 wmi_addba_clear_resp_cmd_fixed_param *cmd;
16294 wmi_buf_t buf;
16295 uint16_t len;
16296 QDF_STATUS ret;
16297
16298 len = sizeof(*cmd);
16299
16300 buf = wmi_buf_alloc(wmi_handle, len);
16301 if (!buf) {
16302 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
16303 return QDF_STATUS_E_FAILURE;
16304 }
16305 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
16306
16307 WMITLV_SET_HDR(&cmd->tlv_header,
16308 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
16309 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
16310
16311 cmd->vdev_id = param->vdev_id;
16312 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16313
16314 ret = wmi_unified_cmd_send(wmi_handle,
16315 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
16316 if (QDF_IS_STATUS_ERROR(ret)) {
16317 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16318 wmi_buf_free(buf);
16319 return QDF_STATUS_E_FAILURE;
16320 }
16321
16322 return QDF_STATUS_SUCCESS;
16323}
16324
16325/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016326 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16327 * @wmi_handle: wmi handle
16328 * @bcn_ctrl_param: pointer to bcn_offload_control param
16329 *
16330 * Return: QDF_STATUS_SUCCESS for success or error code
16331 */
16332static
16333QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16334 struct bcn_offload_control *bcn_ctrl_param)
16335{
16336 wmi_buf_t buf;
16337 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16338 QDF_STATUS ret;
16339 uint32_t len;
16340
16341 len = sizeof(*cmd);
16342
16343 buf = wmi_buf_alloc(wmi_handle, len);
16344 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053016345 qdf_print("%s: wmi_buf_alloc failed", __func__);
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016346 return QDF_STATUS_E_FAILURE;
16347 }
16348
16349 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16350 WMITLV_SET_HDR(&cmd->tlv_header,
16351 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16352 WMITLV_GET_STRUCT_TLVLEN
16353 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16354 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016355 switch (bcn_ctrl_param->bcn_ctrl_op) {
16356 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016357 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016358 break;
16359 case BCN_OFFLD_CTRL_TX_ENABLE:
16360 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16361 break;
16362 case BCN_OFFLD_CTRL_SWBA_DISABLE:
16363 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
16364 break;
16365 case BCN_OFFLD_CTRL_SWBA_ENABLE:
16366 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
16367 break;
16368 default:
16369 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
16370 bcn_ctrl_param->bcn_ctrl_op);
16371 wmi_buf_free(buf);
16372 return QDF_STATUS_E_FAILURE;
16373 break;
16374 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016375 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16376 WMI_BCN_OFFLOAD_CTRL_CMDID);
16377
16378 if (QDF_IS_STATUS_ERROR(ret)) {
16379 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16380 ret);
16381 wmi_buf_free(buf);
16382 }
16383
16384 return ret;
16385}
16386
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016387#ifdef WLAN_FEATURE_NAN_CONVERGENCE
16388static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
16389 struct nan_datapath_initiator_req *ndp_req)
16390{
16391 uint16_t len;
16392 wmi_buf_t buf;
16393 uint8_t *tlv_ptr;
16394 QDF_STATUS status;
16395 wmi_channel *ch_tlv;
16396 wmi_ndp_initiator_req_fixed_param *cmd;
16397 uint32_t passphrase_len, service_name_len;
16398 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016399 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016400
16401 /*
16402 * WMI command expects 4 byte alligned len:
16403 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16404 */
16405 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
16406 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
16407 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
16408 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
16409 service_name_len =
16410 qdf_roundup(ndp_req->service_name.service_name_len, 4);
16411 /* allocated memory for fixed params as well as variable size data */
16412 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
16413 + ndp_cfg_len + ndp_app_info_len + pmk_len
16414 + passphrase_len + service_name_len;
16415
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016416 if (ndp_req->is_ipv6_addr_present)
16417 len += sizeof(*tcp_ip_param);
16418
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016419 buf = wmi_buf_alloc(wmi_handle, len);
16420 if (!buf) {
16421 WMI_LOGE("wmi_buf_alloc failed");
16422 return QDF_STATUS_E_NOMEM;
16423 }
16424
16425 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
16426 WMITLV_SET_HDR(&cmd->tlv_header,
16427 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
16428 WMITLV_GET_STRUCT_TLVLEN(
16429 wmi_ndp_initiator_req_fixed_param));
16430 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
16431 cmd->transaction_id = ndp_req->transaction_id;
16432 cmd->service_instance_id = ndp_req->service_instance_id;
16433 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
16434 &cmd->peer_discovery_mac_addr);
16435
16436 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
16437 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
16438 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
16439 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
16440 cmd->nan_csid = ndp_req->ncs_sk_type;
16441 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
16442 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
16443
16444 ch_tlv = (wmi_channel *)&cmd[1];
16445 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
16446 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
16447 ch_tlv->mhz = ndp_req->channel;
16448 tlv_ptr = (uint8_t *)&ch_tlv[1];
16449
16450 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16451 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16452 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16453 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16454
16455 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16456 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16457 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
16458 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16459
16460 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16461 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
16462 cmd->nan_pmk_len);
16463 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16464
16465 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16466 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
16467 cmd->nan_passphrase_len);
16468 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16469
16470 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16471 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16472 ndp_req->service_name.service_name,
16473 cmd->nan_servicename_len);
16474 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16475
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016476 if (ndp_req->is_ipv6_addr_present) {
16477 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16478 WMITLV_SET_HDR(tcp_ip_param,
16479 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16480 WMITLV_GET_STRUCT_TLVLEN(
16481 wmi_ndp_transport_ip_param));
16482 tcp_ip_param->ipv6_addr_present = true;
16483 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16484 ndp_req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16485 }
16486 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16487 ndp_req->is_ipv6_addr_present, ndp_req->ipv6_addr);
16488
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016489 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
16490 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
16491 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
16492 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16493 cmd->peer_discovery_mac_addr.mac_addr31to0,
16494 cmd->peer_discovery_mac_addr.mac_addr47to32);
16495
16496 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016497 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016498 ndp_req->ndp_config.ndp_cfg,
16499 ndp_req->ndp_config.ndp_cfg_len);
16500
16501 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016502 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016503 ndp_req->ndp_info.ndp_app_info,
16504 ndp_req->ndp_info.ndp_app_info_len);
16505
16506 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016507 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016508 ndp_req->pmk.pmk, cmd->nan_pmk_len);
16509
16510 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016511 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016512 ndp_req->passphrase.passphrase,
16513 cmd->nan_passphrase_len);
16514
16515 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016516 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016517 ndp_req->service_name.service_name,
16518 cmd->nan_servicename_len);
16519
16520 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
16521 WMI_NDP_INITIATOR_REQ_CMDID);
16522
16523 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16524 WMI_NDP_INITIATOR_REQ_CMDID);
16525 if (QDF_IS_STATUS_ERROR(status)) {
16526 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
16527 wmi_buf_free(buf);
16528 }
16529
16530 return status;
16531}
16532
16533static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
16534 struct nan_datapath_responder_req *req)
16535{
16536 uint16_t len;
16537 wmi_buf_t buf;
16538 uint8_t *tlv_ptr;
16539 QDF_STATUS status;
16540 wmi_ndp_responder_req_fixed_param *cmd;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016541 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016542 uint32_t passphrase_len, service_name_len;
16543 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
16544
16545 vdev_id = wlan_vdev_get_id(req->vdev);
16546 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
16547 vdev_id, req->transaction_id,
16548 req->ndp_rsp,
16549 req->ndp_instance_id,
16550 req->ndp_info.ndp_app_info_len);
16551
16552 /*
16553 * WMI command expects 4 byte alligned len:
16554 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16555 */
16556 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
16557 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
16558 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
16559 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
16560 service_name_len =
16561 qdf_roundup(req->service_name.service_name_len, 4);
16562
16563 /* allocated memory for fixed params as well as variable size data */
16564 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
16565 + pmk_len + passphrase_len + service_name_len;
16566
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016567 if (req->is_ipv6_addr_present || req->is_port_present ||
16568 req->is_protocol_present)
16569 len += sizeof(*tcp_ip_param);
16570
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016571 buf = wmi_buf_alloc(wmi_handle, len);
16572 if (!buf) {
16573 WMI_LOGE("wmi_buf_alloc failed");
16574 return QDF_STATUS_E_NOMEM;
16575 }
16576 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
16577 WMITLV_SET_HDR(&cmd->tlv_header,
16578 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
16579 WMITLV_GET_STRUCT_TLVLEN(
16580 wmi_ndp_responder_req_fixed_param));
16581 cmd->vdev_id = vdev_id;
16582 cmd->transaction_id = req->transaction_id;
16583 cmd->ndp_instance_id = req->ndp_instance_id;
16584 cmd->rsp_code = req->ndp_rsp;
16585 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
16586 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
16587 cmd->nan_pmk_len = req->pmk.pmk_len;
16588 cmd->nan_csid = req->ncs_sk_type;
16589 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
16590 cmd->nan_servicename_len = req->service_name.service_name_len;
16591
16592 tlv_ptr = (uint8_t *)&cmd[1];
16593 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16594 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16595 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16596
16597 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16598 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16599 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16600 req->ndp_info.ndp_app_info,
16601 req->ndp_info.ndp_app_info_len);
16602
16603 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16604 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16605 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
16606 cmd->nan_pmk_len);
16607
16608 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16609 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16610 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16611 req->passphrase.passphrase,
16612 cmd->nan_passphrase_len);
16613 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16614
16615 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16616 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16617 req->service_name.service_name,
16618 cmd->nan_servicename_len);
16619
16620 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16621
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016622 if (req->is_ipv6_addr_present || req->is_port_present ||
16623 req->is_protocol_present) {
16624 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16625 WMITLV_SET_HDR(tcp_ip_param,
16626 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16627 WMITLV_GET_STRUCT_TLVLEN(
16628 wmi_ndp_transport_ip_param));
16629 tcp_ip_param->ipv6_addr_present = req->is_ipv6_addr_present;
16630 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16631 req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16632
16633 tcp_ip_param->trans_port_present = req->is_port_present;
16634 tcp_ip_param->transport_port = req->port;
16635
16636 tcp_ip_param->trans_proto_present = req->is_protocol_present;
16637 tcp_ip_param->transport_protocol = req->protocol;
16638 }
16639 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16640 req->is_ipv6_addr_present, req->ipv6_addr);
16641 WMI_LOGD(FL("port: %d present: %d"), req->is_port_present, req->port);
16642 WMI_LOGD(FL("protocol: %d present: %d"),
16643 req->is_protocol_present, req->protocol);
16644
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016645 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
16646 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
16647
16648 WMI_LOGD("ndp_config len: %d",
16649 req->ndp_config.ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016650 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016651 req->ndp_config.ndp_cfg,
16652 req->ndp_config.ndp_cfg_len);
16653
16654 WMI_LOGD("ndp_app_info len: %d",
16655 req->ndp_info.ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016656 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016657 req->ndp_info.ndp_app_info,
16658 req->ndp_info.ndp_app_info_len);
16659
16660 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016661 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016662 req->pmk.pmk, cmd->nan_pmk_len);
16663
16664 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016665 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016666 req->passphrase.passphrase,
16667 cmd->nan_passphrase_len);
16668
16669 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016670 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016671 req->service_name.service_name,
16672 cmd->nan_servicename_len);
16673
16674 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
16675 WMI_NDP_RESPONDER_REQ_CMDID);
16676 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16677 WMI_NDP_RESPONDER_REQ_CMDID);
16678 if (QDF_IS_STATUS_ERROR(status)) {
16679 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
16680 wmi_buf_free(buf);
16681 }
16682 return status;
16683}
16684
16685static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
16686 struct nan_datapath_end_req *req)
16687{
16688 uint16_t len;
16689 wmi_buf_t buf;
16690 QDF_STATUS status;
16691 uint32_t ndp_end_req_len, i;
16692 wmi_ndp_end_req *ndp_end_req_lst;
16693 wmi_ndp_end_req_fixed_param *cmd;
16694
16695 /* len of tlv following fixed param */
16696 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
16697 /* above comes out to 4 byte alligned already, no need of padding */
16698 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
16699 buf = wmi_buf_alloc(wmi_handle, len);
16700 if (!buf) {
16701 WMI_LOGE("Malloc failed");
16702 return QDF_STATUS_E_NOMEM;
16703 }
16704
16705 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
16706 WMITLV_SET_HDR(&cmd->tlv_header,
16707 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
16708 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
16709
16710 cmd->transaction_id = req->transaction_id;
16711
16712 /* set tlv pointer to end of fixed param */
16713 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
16714 ndp_end_req_len);
16715
16716 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
16717 WMI_TLV_HDR_SIZE);
16718 for (i = 0; i < req->num_ndp_instances; i++) {
16719 WMITLV_SET_HDR(&ndp_end_req_lst[i],
16720 WMITLV_TAG_ARRAY_FIXED_STRUC,
16721 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
16722
16723 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
16724 }
16725
16726 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
16727 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16728 WMI_NDP_END_REQ_CMDID);
16729 if (QDF_IS_STATUS_ERROR(status)) {
16730 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
16731 wmi_buf_free(buf);
16732 }
16733
16734 return status;
16735}
16736
16737static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016738 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016739{
16740 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
16741 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
16742
16743 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
16744 fixed_params = event->fixed_param;
16745
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016746 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016747 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16748 fixed_params->vdev_id,
16749 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016750 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016751 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016752 return QDF_STATUS_E_INVAL;
16753 }
16754
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016755 rsp->transaction_id = fixed_params->transaction_id;
16756 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16757 rsp->status = fixed_params->rsp_status;
16758 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016759
16760 return QDF_STATUS_SUCCESS;
16761}
16762
16763static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016764 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016765{
16766 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
16767 wmi_ndp_indication_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016768 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016769
16770 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
16771 fixed_params =
16772 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
16773
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016774 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16775 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16776 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16777 return QDF_STATUS_E_INVAL;
16778 }
16779
16780 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16781 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16782 fixed_params->ndp_app_info_len,
16783 event->num_ndp_app_info);
16784 return QDF_STATUS_E_INVAL;
16785 }
16786
gaolezab037cf2018-05-23 14:40:32 +080016787 if (fixed_params->ndp_cfg_len >
16788 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16789 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16790 __func__, fixed_params->ndp_cfg_len);
16791 return QDF_STATUS_E_INVAL;
16792 }
16793
16794 total_array_len = fixed_params->ndp_cfg_len +
16795 sizeof(*fixed_params);
16796
16797 if (fixed_params->ndp_app_info_len >
16798 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16799 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16800 __func__, fixed_params->ndp_app_info_len);
16801 return QDF_STATUS_E_INVAL;
16802 }
16803 total_array_len += fixed_params->ndp_app_info_len;
16804
16805 if (fixed_params->nan_scid_len >
16806 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16807 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16808 __func__, fixed_params->nan_scid_len);
16809 return QDF_STATUS_E_INVAL;
16810 }
16811
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016812 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016813 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16814 fixed_params->vdev_id,
16815 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016816 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016817 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016818 return QDF_STATUS_E_INVAL;
16819 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016820 rsp->service_instance_id = fixed_params->service_instance_id;
16821 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16822 rsp->role = fixed_params->self_ndp_role;
16823 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016824
16825 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016826 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016827 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016828 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016829
16830 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
16831 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
16832 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
16833 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
16834 fixed_params->service_instance_id,
16835 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
16836 fixed_params->accept_policy,
16837 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016838 rsp->peer_mac_addr.bytes,
16839 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016840
16841 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016842 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016843 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16844
16845 WMI_LOGD("ndp_app_info - %d bytes",
16846 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016847 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016848 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16849
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016850 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
16851 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16852 rsp->ncs_sk_type = fixed_params->nan_csid;
16853 rsp->scid.scid_len = fixed_params->nan_scid_len;
Lihua Liue950ad12018-07-02 18:55:56 +080016854
16855 if (rsp->ndp_config.ndp_cfg_len > NDP_QOS_INFO_LEN)
16856 rsp->ndp_config.ndp_cfg_len = NDP_QOS_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016857 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
16858 rsp->ndp_config.ndp_cfg_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016859
16860 if (rsp->ndp_info.ndp_app_info_len > NDP_APP_INFO_LEN)
16861 rsp->ndp_info.ndp_app_info_len = NDP_APP_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016862 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16863 rsp->ndp_info.ndp_app_info_len);
Lihua Liue950ad12018-07-02 18:55:56 +080016864
16865 if (rsp->scid.scid_len > NDP_SCID_BUF_LEN)
16866 rsp->scid.scid_len = NDP_SCID_BUF_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016867 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016868
16869 if (event->ndp_transport_ip_param &&
16870 event->num_ndp_transport_ip_param) {
16871 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16872 rsp->is_ipv6_addr_present = true;
16873 qdf_mem_copy(rsp->ipv6_addr,
16874 event->ndp_transport_ip_param->ipv6_intf_addr,
16875 WMI_NDP_IPV6_INTF_ADDR_LEN);
16876 }
16877 }
16878 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16879 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16880
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016881 WMI_LOGD("scid hex dump:");
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016882 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016883 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016884
16885 return QDF_STATUS_SUCCESS;
16886}
16887
16888static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016889 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016890{
Naveen Rawat38b21462018-05-31 15:04:16 -070016891 uint8_t i;
16892 WMI_HOST_WLAN_PHY_MODE ch_mode;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016893 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
16894 wmi_ndp_confirm_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016895 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016896
16897 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
16898 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070016899 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 -080016900 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
16901 fixed_params->ndp_instance_id, fixed_params->rsp_code,
16902 fixed_params->reason_code,
16903 fixed_params->num_active_ndps_on_peer);
Naveen Rawat38b21462018-05-31 15:04:16 -070016904 WMI_LOGE("num_ch: %d", fixed_params->num_ndp_channels);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016905
16906 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16907 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16908 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16909 return QDF_STATUS_E_INVAL;
16910 }
16911
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016912 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016913 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016914 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16915
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016916 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16917 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16918 fixed_params->ndp_app_info_len,
16919 event->num_ndp_app_info);
16920 return QDF_STATUS_E_INVAL;
16921 }
16922
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016923 WMI_LOGD("ndp_app_info - %d bytes",
16924 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016925 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016926 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16927
gaolezab037cf2018-05-23 14:40:32 +080016928 if (fixed_params->ndp_cfg_len >
16929 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16930 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16931 __func__, fixed_params->ndp_cfg_len);
16932 return QDF_STATUS_E_INVAL;
16933 }
16934
16935 total_array_len = fixed_params->ndp_cfg_len +
16936 sizeof(*fixed_params);
16937
16938 if (fixed_params->ndp_app_info_len >
16939 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16940 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16941 __func__, fixed_params->ndp_app_info_len);
16942 return QDF_STATUS_E_INVAL;
16943 }
16944
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016945 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016946 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16947 fixed_params->vdev_id,
16948 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016949 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016950 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016951 return QDF_STATUS_E_INVAL;
16952 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016953 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16954 rsp->rsp_code = fixed_params->rsp_code;
16955 rsp->reason_code = fixed_params->reason_code;
16956 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat38b21462018-05-31 15:04:16 -070016957 rsp->num_channels = fixed_params->num_ndp_channels;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016958 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016959 rsp->peer_ndi_mac_addr.bytes);
16960 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16961 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16962 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016963
Naveen Rawat38b21462018-05-31 15:04:16 -070016964 if (rsp->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
16965 WMI_LOGE(FL("too many channels"));
16966 rsp->num_channels = NAN_CH_INFO_MAX_CHANNELS;
16967 }
16968
16969 for (i = 0; i < rsp->num_channels; i++) {
16970 rsp->ch[i].channel = event->ndp_channel_list[i].mhz;
16971 rsp->ch[i].nss = event->nss_list[i];
16972 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndp_channel_list[i]);
16973 rsp->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
16974 ch_mode);
16975 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
16976 rsp->ch[i].channel,
16977 rsp->ch[i].ch_width,
16978 rsp->ch[i].nss);
16979 }
16980
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016981 if (event->ndp_transport_ip_param &&
16982 event->num_ndp_transport_ip_param) {
16983 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16984 rsp->is_ipv6_addr_present = true;
16985 qdf_mem_copy(rsp->ipv6_addr,
16986 event->ndp_transport_ip_param->ipv6_intf_addr,
16987 WMI_NDP_IPV6_INTF_ADDR_LEN);
16988 }
16989
16990 if (event->ndp_transport_ip_param->trans_port_present) {
16991 rsp->is_port_present = true;
16992 rsp->port =
16993 event->ndp_transport_ip_param->transport_port;
16994 }
16995
16996 if (event->ndp_transport_ip_param->trans_proto_present) {
16997 rsp->is_protocol_present = true;
16998 rsp->protocol =
16999 event->ndp_transport_ip_param->transport_protocol;
17000 }
17001 }
17002 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
17003 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
17004 WMI_LOGD(FL("port: %d present: %d"), rsp->port, rsp->is_port_present);
17005 WMI_LOGD(FL("protocol: %d present: %d"),
17006 rsp->protocol, rsp->is_protocol_present);
17007
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017008 return QDF_STATUS_SUCCESS;
17009}
17010
17011static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017012 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017013{
17014 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17015 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17016
17017 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17018 fixed_params = event->fixed_param;
17019
17020 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",
17021 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017022 rsp->peer_mac_addr.bytes, rsp->transaction_id,
17023 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017024
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017025 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017026 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17027 fixed_params->vdev_id,
17028 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017029 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017030 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017031 return QDF_STATUS_E_INVAL;
17032 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017033 rsp->transaction_id = fixed_params->transaction_id;
17034 rsp->reason = fixed_params->reason_code;
17035 rsp->status = fixed_params->rsp_status;
17036 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017037 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017038 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017039
17040 return QDF_STATUS_SUCCESS;
17041}
17042
17043static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017044 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017045{
17046 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17047 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17048
17049 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17050 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017051 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 -080017052 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17053 fixed_params->rsp_status, fixed_params->reason_code);
17054
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017055 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017056 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017057 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017058 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017059 return QDF_STATUS_E_INVAL;
17060 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017061 rsp->transaction_id = fixed_params->transaction_id;
17062 rsp->reason = fixed_params->reason_code;
17063 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017064
17065 return QDF_STATUS_SUCCESS;
17066}
17067
17068static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17069 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17070{
17071 uint32_t i, buf_size;
17072 wmi_ndp_end_indication *ind;
17073 struct qdf_mac_addr peer_addr;
17074 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17075
17076 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17077 ind = event->ndp_end_indication_list;
17078
17079 if (event->num_ndp_end_indication_list == 0) {
17080 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017081 return QDF_STATUS_E_INVAL;
17082 }
17083
17084 WMI_LOGD("number of ndp instances = %d",
17085 event->num_ndp_end_indication_list);
17086
17087 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17088 sizeof((*rsp)->ndp_map[0]))) {
17089 WMI_LOGE("num_ndp_end_ind_list %d too large",
17090 event->num_ndp_end_indication_list);
17091 return QDF_STATUS_E_INVAL;
17092 }
17093
17094 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17095 sizeof((*rsp)->ndp_map[0]);
17096 *rsp = qdf_mem_malloc(buf_size);
17097 if (!(*rsp)) {
17098 WMI_LOGE("Failed to allocate memory");
17099 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017100 }
17101
17102 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17103 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17104 if (!(*rsp)->vdev) {
17105 WMI_LOGE("vdev is null");
17106 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017107 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017108 return QDF_STATUS_E_INVAL;
17109 }
17110
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017111 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17112 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17113 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17114 peer_addr.bytes);
17115 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17116 i, ind[i].type, ind[i].reason_code,
17117 ind[i].ndp_instance_id,
17118 ind[i].num_active_ndps_on_peer);
17119 /* Add each instance entry to the list */
17120 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17121 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17122 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17123 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17124 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17125 ind[i].num_active_ndps_on_peer;
17126 (*rsp)->ndp_map[i].type = ind[i].type;
17127 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17128 }
17129
17130 return QDF_STATUS_SUCCESS;
17131}
Naveen Rawatd42ce382018-01-09 17:54:41 -080017132
17133static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,
17134 uint8_t *data, struct nan_datapath_sch_update_event *ind)
17135{
17136 uint8_t i;
17137 WMI_HOST_WLAN_PHY_MODE ch_mode;
17138 WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *event;
17139 wmi_ndl_schedule_update_fixed_param *fixed_params;
17140
17141 event = (WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *)data;
17142 fixed_params = event->fixed_param;
17143
17144 WMI_LOGD(FL("flags: %d, num_ch: %d, num_ndp_instances: %d"),
17145 fixed_params->flags, fixed_params->num_channels,
17146 fixed_params->num_ndp_instances);
17147
17148 ind->vdev =
17149 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17150 fixed_params->vdev_id,
17151 WLAN_NAN_ID);
17152 if (!ind->vdev) {
17153 WMI_LOGE("vdev is null");
17154 return QDF_STATUS_E_INVAL;
17155 }
17156
17157 ind->flags = fixed_params->flags;
17158 ind->num_channels = fixed_params->num_channels;
17159 ind->num_ndp_instances = fixed_params->num_ndp_instances;
17160 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_macaddr,
17161 ind->peer_addr.bytes);
17162
17163 if (ind->num_ndp_instances > NDP_NUM_INSTANCE_ID) {
17164 WMI_LOGE(FL("uint32 overflow"));
17165 wlan_objmgr_vdev_release_ref(ind->vdev, WLAN_NAN_ID);
17166 return QDF_STATUS_E_INVAL;
17167 }
17168
17169 qdf_mem_copy(ind->ndp_instances, event->ndp_instance_list,
17170 sizeof(uint32_t) * ind->num_ndp_instances);
17171
17172 if (ind->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
17173 WMI_LOGE(FL("too many channels"));
17174 ind->num_channels = NAN_CH_INFO_MAX_CHANNELS;
17175 }
17176 for (i = 0; i < ind->num_channels; i++) {
17177 ind->ch[i].channel = event->ndl_channel_list[i].mhz;
17178 ind->ch[i].nss = event->nss_list[i];
17179 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]);
17180 ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
17181 ch_mode);
17182 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
17183 ind->ch[i].channel,
17184 ind->ch[i].ch_width,
17185 ind->ch[i].nss);
17186 }
17187
17188 for (i = 0; i < fixed_params->num_ndp_instances; i++)
17189 WMI_LOGD(FL("instance_id[%d]: %d"),
17190 i, event->ndp_instance_list[i]);
17191
17192 return QDF_STATUS_SUCCESS;
17193}
17194
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017195#endif
17196
Naveen Rawat963ee942018-04-13 16:38:36 -070017197#ifdef QCA_SUPPORT_CP_STATS
17198/**
17199 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
17200 * @wmi_handle: wma handle
17201 * @evt_buf: event buffer
17202 * @out_buff: buffer to populated after stats extraction
17203 *
17204 * Return: status of operation
17205 */
17206static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
17207 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
17208{
17209 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17210 wmi_congestion_stats *congestion_stats;
17211
17212 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
17213 congestion_stats = param_buf->congestion_stats;
17214 if (!congestion_stats) {
17215 WMI_LOGD("%s: no cca stats in event buffer", __func__);
17216 return QDF_STATUS_E_INVAL;
17217 }
17218
17219 out_buff->vdev_id = congestion_stats->vdev_id;
17220 out_buff->congestion = congestion_stats->congestion;
17221
17222 WMI_LOGD("%s: cca stats event processed", __func__);
17223 return QDF_STATUS_SUCCESS;
17224}
17225#endif /* QCA_SUPPORT_CP_STATS */
17226
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017227/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017228 * save_service_bitmap_tlv() - save service bitmap
17229 * @wmi_handle: wmi handle
17230 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017231 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017232 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017233 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017234 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017235static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017236QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017237 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017238{
17239 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017240 struct wmi_soc *soc = wmi_handle->soc;
17241
Govind Singhe7f2f342016-05-23 12:12:52 +053017242 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17243
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017244 /* If it is already allocated, use that buffer. This can happen
17245 * during target stop/start scenarios where host allocation is skipped.
17246 */
17247 if (!soc->wmi_service_bitmap) {
17248 soc->wmi_service_bitmap =
17249 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17250 if (!soc->wmi_service_bitmap) {
17251 WMI_LOGE("Failed memory allocation for service bitmap");
17252 return QDF_STATUS_E_NOMEM;
17253 }
17254 }
17255
17256 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017257 param_buf->wmi_service_bitmap,
17258 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017259
17260 if (bitmap_buf)
17261 qdf_mem_copy(bitmap_buf,
17262 param_buf->wmi_service_bitmap,
17263 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017264
17265 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017266}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017267
17268/**
17269 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17270 * @wmi_handle: wmi handle
17271 * @param evt_buf: pointer to event buffer
17272 * @param bitmap_buf: bitmap buffer, for converged legacy support
17273 *
17274 * Return: QDF_STATUS
17275 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017276static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017277QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017278 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017279{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017280 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17281 wmi_service_available_event_fixed_param *ev;
17282 struct wmi_soc *soc = wmi_handle->soc;
17283
17284 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17285
17286 ev = param_buf->fixed_param;
17287
17288 /* If it is already allocated, use that buffer. This can happen
17289 * during target stop/start scenarios where host allocation is skipped.
17290 */
17291 if (!soc->wmi_ext_service_bitmap) {
17292 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17293 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17294 if (!soc->wmi_ext_service_bitmap) {
17295 WMI_LOGE("Failed memory allocation for service bitmap");
17296 return QDF_STATUS_E_NOMEM;
17297 }
17298 }
17299
17300 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17301 ev->wmi_service_segment_bitmap,
17302 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017303
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017304 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17305 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17306 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17307
Rajeev Kumar77901472017-02-12 02:12:17 -080017308 if (bitmap_buf)
17309 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017310 soc->wmi_ext_service_bitmap,
17311 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017312
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017313 return QDF_STATUS_SUCCESS;
17314}
Govind Singhe7f2f342016-05-23 12:12:52 +053017315/**
17316 * is_service_enabled_tlv() - Check if service enabled
17317 * @param wmi_handle: wmi handle
17318 * @param service_id: service identifier
17319 *
17320 * Return: 1 enabled, 0 disabled
17321 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017322static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17323 uint32_t service_id)
17324{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017325 struct wmi_soc *soc = wmi_handle->soc;
17326
17327 if (!soc->wmi_service_bitmap) {
17328 WMI_LOGE("WMI service bit map is not saved yet\n");
17329 return false;
17330 }
17331
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017332 /* if wmi_service_enabled was received with extended bitmap,
17333 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017334 */
17335 if (soc->wmi_ext_service_bitmap)
17336 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17337 soc->wmi_ext_service_bitmap,
17338 service_id);
17339
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080017340 if (service_id >= WMI_MAX_SERVICE) {
17341 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
17342 service_id);
17343 return false;
17344 }
17345
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017346 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17347 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017348}
Govind Singhe7f2f342016-05-23 12:12:52 +053017349
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017350static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17351 struct wlan_psoc_target_capability_info *cap)
17352{
17353 /* except LDPC all flags are common betwen legacy and here
17354 * also IBFEER is not defined for TLV
17355 */
17356 cap->ht_cap_info |= ev_target_cap & (
17357 WMI_HT_CAP_ENABLED
17358 | WMI_HT_CAP_HT20_SGI
17359 | WMI_HT_CAP_DYNAMIC_SMPS
17360 | WMI_HT_CAP_TX_STBC
17361 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17362 | WMI_HT_CAP_RX_STBC
17363 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17364 | WMI_HT_CAP_LDPC
17365 | WMI_HT_CAP_L_SIG_TXOP_PROT
17366 | WMI_HT_CAP_MPDU_DENSITY
17367 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17368 | WMI_HT_CAP_HT40_SGI);
17369 if (ev_target_cap & WMI_HT_CAP_LDPC)
17370 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17371 WMI_HOST_HT_CAP_TX_LDPC;
17372}
Govind Singhe7f2f342016-05-23 12:12:52 +053017373/**
17374 * extract_service_ready_tlv() - extract service ready event
17375 * @wmi_handle: wmi handle
17376 * @param evt_buf: pointer to received event buffer
17377 * @param cap: pointer to hold target capability information extracted from even
17378 *
17379 * Return: QDF_STATUS_SUCCESS for success or error code
17380 */
17381static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017382 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017383{
17384 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17385 wmi_service_ready_event_fixed_param *ev;
17386
17387
17388 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17389
17390 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17391 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017392 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017393 return QDF_STATUS_E_FAILURE;
17394 }
17395
17396 cap->phy_capability = ev->phy_capability;
17397 cap->max_frag_entry = ev->max_frag_entry;
17398 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017399 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017400 cap->vht_cap_info = ev->vht_cap_info;
17401 cap->vht_supp_mcs = ev->vht_supp_mcs;
17402 cap->hw_min_tx_power = ev->hw_min_tx_power;
17403 cap->hw_max_tx_power = ev->hw_max_tx_power;
17404 cap->sys_cap_info = ev->sys_cap_info;
17405 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17406 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17407 cap->max_num_scan_channels = ev->max_num_scan_channels;
17408 cap->max_supported_macs = ev->max_supported_macs;
17409 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17410 cap->txrx_chainmask = ev->txrx_chainmask;
17411 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17412 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017413 cap->fw_version = ev->fw_build_vers;
17414 /* fw_version_1 is not available in TLV. */
17415 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017416
17417 return QDF_STATUS_SUCCESS;
17418}
17419
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017420/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17421 * to host internal WMI_HOST_REGDMN_MODE values.
17422 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17423 * host currently. Add this in the future if required.
17424 * 11AX (Phase II) : 11ax related values are not currently
17425 * advertised separately by FW. As part of phase II regulatory bring-up,
17426 * finalize the advertisement mechanism.
17427 * @target_wireless_mode: target wireless mode received in message
17428 *
17429 * Return: returns the host internal wireless mode.
17430 */
17431static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17432{
17433
17434 uint32_t wireless_modes = 0;
17435
17436 if (target_wireless_mode & REGDMN_MODE_11A)
17437 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17438
17439 if (target_wireless_mode & REGDMN_MODE_TURBO)
17440 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17441
17442 if (target_wireless_mode & REGDMN_MODE_11B)
17443 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17444
17445 if (target_wireless_mode & REGDMN_MODE_PUREG)
17446 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17447
17448 if (target_wireless_mode & REGDMN_MODE_11G)
17449 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
17450
17451 if (target_wireless_mode & REGDMN_MODE_108G)
17452 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
17453
17454 if (target_wireless_mode & REGDMN_MODE_108A)
17455 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
17456
17457 if (target_wireless_mode & REGDMN_MODE_XR)
17458 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
17459
17460 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
17461 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
17462
17463 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
17464 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
17465
17466 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
17467 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
17468
17469 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
17470 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
17471
17472 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
17473 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
17474
17475 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
17476 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
17477
17478 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
17479 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
17480
17481 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
17482 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
17483
17484 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
17485 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
17486
17487 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
17488 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
17489
17490 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
17491 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
17492
17493 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
17494 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
17495
17496 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
17497 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
17498
17499 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
17500 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
17501
17502 return wireless_modes;
17503}
17504
Govind Singhe7f2f342016-05-23 12:12:52 +053017505/**
17506 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
17507 * @wmi_handle: wmi handle
17508 * @param evt_buf: Pointer to event buffer
17509 * @param cap: pointer to hold HAL reg capabilities
17510 *
17511 * Return: QDF_STATUS_SUCCESS for success or error code
17512 */
17513static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017514 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017515{
17516 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17517
17518 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17519
17520 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
17521 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080017522 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053017523
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017524 cap->wireless_modes = convert_wireless_modes_tlv(
17525 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053017526
Govind Singhe7f2f342016-05-23 12:12:52 +053017527 return QDF_STATUS_SUCCESS;
17528}
17529
17530/**
17531 * extract_host_mem_req_tlv() - Extract host memory request event
17532 * @wmi_handle: wmi handle
17533 * @param evt_buf: pointer to event buffer
17534 * @param num_entries: pointer to hold number of entries requested
17535 *
17536 * Return: Number of entries requested
17537 */
17538static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
17539 void *evt_buf, uint8_t *num_entries)
17540{
17541 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17542 wmi_service_ready_event_fixed_param *ev;
17543
17544 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17545
17546 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17547 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017548 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017549 return NULL;
17550 }
17551
17552 *num_entries = ev->num_mem_reqs;
17553
17554 return (host_mem_req *)param_buf->mem_reqs;
17555}
17556
17557/**
17558 * save_fw_version_in_service_ready_tlv() - Save fw version in service
17559 * ready function
17560 * @wmi_handle: wmi handle
17561 * @param evt_buf: pointer to event buffer
17562 *
17563 * Return: QDF_STATUS_SUCCESS for success or error code
17564 */
17565static QDF_STATUS
17566save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
17567{
17568 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17569 wmi_service_ready_event_fixed_param *ev;
17570
17571
17572 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17573
17574 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17575 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017576 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017577 return QDF_STATUS_E_FAILURE;
17578 }
17579
17580 /*Save fw version from service ready message */
17581 /*This will be used while sending INIT message */
17582 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
17583 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017584
Govind Singhe7f2f342016-05-23 12:12:52 +053017585 return QDF_STATUS_SUCCESS;
17586}
17587
17588/**
17589 * ready_extract_init_status_tlv() - Extract init status from ready event
17590 * @wmi_handle: wmi handle
17591 * @param evt_buf: Pointer to event buffer
17592 *
17593 * Return: ready status
17594 */
17595static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
17596 void *evt_buf)
17597{
17598 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17599 wmi_ready_event_fixed_param *ev = NULL;
17600
Govind Singhe7f2f342016-05-23 12:12:52 +053017601 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17602 ev = param_buf->fixed_param;
17603
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017604 qdf_print("%s:%d", __func__, ev->status);
Govind Singhe7f2f342016-05-23 12:12:52 +053017605
17606 return ev->status;
17607}
17608
17609/**
17610 * ready_extract_mac_addr_tlv() - extract mac address from ready event
17611 * @wmi_handle: wmi handle
17612 * @param evt_buf: pointer to event buffer
17613 * @param macaddr: Pointer to hold MAC address
17614 *
17615 * Return: QDF_STATUS_SUCCESS for success or error code
17616 */
17617static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17618 void *evt_buf, uint8_t *macaddr)
17619{
17620 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17621 wmi_ready_event_fixed_param *ev = NULL;
17622
17623
17624 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17625 ev = param_buf->fixed_param;
17626
17627 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17628
17629 return QDF_STATUS_SUCCESS;
17630}
17631
17632/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017633 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17634 * @wmi_handle: wmi handle
17635 * @param evt_buf: pointer to event buffer
17636 * @param macaddr: Pointer to hold number of MAC addresses
17637 *
17638 * Return: Pointer to addr list
17639 */
17640static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17641 void *evt_buf, uint8_t *num_mac)
17642{
17643 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17644 wmi_ready_event_fixed_param *ev = NULL;
17645
17646 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17647 ev = param_buf->fixed_param;
17648
17649 *num_mac = ev->num_extra_mac_addr;
17650
17651 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17652}
17653
17654/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017655 * extract_ready_params_tlv() - Extract data from ready event apart from
17656 * status, macaddr and version.
17657 * @wmi_handle: Pointer to WMI handle.
17658 * @evt_buf: Pointer to Ready event buffer.
17659 * @ev_param: Pointer to host defined struct to copy the data from event.
17660 *
17661 * Return: QDF_STATUS_SUCCESS on success.
17662 */
17663static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17664 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17665{
17666 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17667 wmi_ready_event_fixed_param *ev = NULL;
17668
17669 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17670 ev = param_buf->fixed_param;
17671
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017672 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017673 ev_param->num_dscp_table = ev->num_dscp_table;
17674 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17675 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017676 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017677 /* Agile_cap in ready event is not supported in TLV target */
17678 ev_param->agile_capability = false;
17679
17680 return QDF_STATUS_SUCCESS;
17681}
17682
17683/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017684 * extract_dbglog_data_len_tlv() - extract debuglog data length
17685 * @wmi_handle: wmi handle
17686 * @param evt_buf: pointer to event buffer
17687 *
17688 * Return: length
17689 */
17690static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017691 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017692{
17693 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17694
17695 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17696
17697 *len = param_buf->num_bufp;
17698
17699 return param_buf->bufp;
17700}
17701
17702/**
17703 * extract_vdev_start_resp_tlv() - extract vdev start response
17704 * @wmi_handle: wmi handle
17705 * @param evt_buf: pointer to event buffer
17706 * @param vdev_rsp: Pointer to hold vdev response
17707 *
17708 * Return: QDF_STATUS_SUCCESS for success or error code
17709 */
17710static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
17711 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
17712{
17713 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
17714 wmi_vdev_start_response_event_fixed_param *ev;
17715
17716 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
17717 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017718 qdf_print("Invalid start response event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017719 return QDF_STATUS_E_INVAL;
17720 }
17721
17722 ev = param_buf->fixed_param;
17723 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017724 qdf_print("Invalid start response event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017725 return QDF_STATUS_E_INVAL;
17726 }
17727
17728 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
17729
17730 vdev_rsp->vdev_id = ev->vdev_id;
17731 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017732 switch (ev->resp_type) {
17733 case WMI_VDEV_START_RESP_EVENT:
17734 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
17735 break;
17736 case WMI_VDEV_RESTART_RESP_EVENT:
17737 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
17738 break;
17739 default:
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017740 qdf_print("Invalid start response event buffer");
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017741 break;
17742 };
Govind Singhe7f2f342016-05-23 12:12:52 +053017743 vdev_rsp->status = ev->status;
17744 vdev_rsp->chain_mask = ev->chain_mask;
17745 vdev_rsp->smps_mode = ev->smps_mode;
17746 vdev_rsp->mac_id = ev->mac_id;
17747 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
17748 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
17749
17750 return QDF_STATUS_SUCCESS;
17751}
17752
17753/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053017754 * extract_vdev_delete_resp_tlv() - extract vdev delete response
17755 * @wmi_handle: wmi handle
17756 * @param evt_buf: pointer to event buffer
17757 * @param delete_rsp: Pointer to hold vdev delete response
17758 *
17759 * Return: QDF_STATUS_SUCCESS for success or error code
17760 */
17761static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
17762 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
17763{
17764 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17765 wmi_vdev_delete_resp_event_fixed_param *ev;
17766
17767 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
17768 if (!param_buf) {
17769 WMI_LOGE("Invalid vdev delete response event buffer\n");
17770 return QDF_STATUS_E_INVAL;
17771 }
17772
17773 ev = param_buf->fixed_param;
17774 if (!ev) {
17775 WMI_LOGE("Invalid vdev delete response event\n");
17776 return QDF_STATUS_E_INVAL;
17777 }
17778
17779 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
17780 delete_rsp->vdev_id = ev->vdev_id;
17781
17782 return QDF_STATUS_SUCCESS;
17783}
17784
17785
17786/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017787 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053017788 * @wmi_handle: wmi handle
17789 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017790 * @param num_vdevs: Pointer to hold num vdev
17791 *
17792 * Return: QDF_STATUS_SUCCESS for success or error code
17793 */
17794static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17795 void *evt_buf, uint32_t *num_vdevs)
17796{
17797 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17798 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
17799 uint32_t vdev_map;
17800
17801 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
17802 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017803 qdf_print("Invalid tbtt update ext event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017804 return QDF_STATUS_E_INVAL;
17805 }
17806 tbtt_offset_event = param_buf->fixed_param;
17807 vdev_map = tbtt_offset_event->vdev_map;
17808 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
17809
17810 return QDF_STATUS_SUCCESS;
17811}
17812
17813/**
17814 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
17815 * @wmi_handle: wmi handle
17816 * @param evt_buf: pointer to event buffer
17817 * @param num_vdevs: Pointer to hold num vdev
17818 *
17819 * Return: QDF_STATUS_SUCCESS for success or error code
17820 */
17821static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17822 void *evt_buf, uint32_t *num_vdevs)
17823{
17824 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17825 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
17826
17827 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17828 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017829 qdf_print("Invalid tbtt update ext event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017830 return QDF_STATUS_E_INVAL;
17831 }
17832 tbtt_offset_ext_event = param_buf->fixed_param;
17833
17834 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
17835
17836 return QDF_STATUS_SUCCESS;
17837}
17838
17839/**
17840 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
17841 * @wmi_handle: wmi handle
17842 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017843 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017844 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053017845 *
17846 * Return: QDF_STATUS_SUCCESS for success or error code
17847 */
17848static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017849 void *evt_buf, uint8_t idx,
17850 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017851{
17852 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17853 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017854 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053017855
17856 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
17857 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017858 qdf_print("Invalid tbtt update event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017859 return QDF_STATUS_E_INVAL;
17860 }
Govind Singhe7f2f342016-05-23 12:12:52 +053017861
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017862 tbtt_offset_event = param_buf->fixed_param;
17863 vdev_map = tbtt_offset_event->vdev_map;
17864 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
17865 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
17866 return QDF_STATUS_E_INVAL;
17867 tbtt_param->tbttoffset =
17868 param_buf->tbttoffset_list[tbtt_param->vdev_id];
17869
17870 return QDF_STATUS_SUCCESS;
17871}
17872
17873/**
17874 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
17875 * @wmi_handle: wmi handle
17876 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017877 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017878 * @param tbtt_param: Pointer to tbttoffset event param
17879 *
17880 * Return: QDF_STATUS_SUCCESS for success or error code
17881 */
17882static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
17883 void *evt_buf, uint8_t idx,
17884 struct tbttoffset_params *tbtt_param)
17885{
17886 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17887 wmi_tbtt_offset_info *tbtt_offset_info;
17888
17889 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17890 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017891 qdf_print("Invalid tbtt update event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017892 return QDF_STATUS_E_INVAL;
17893 }
17894 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
17895
17896 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
17897 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053017898
17899 return QDF_STATUS_SUCCESS;
17900}
17901
Jinwei Chenb69924c2018-08-20 11:31:31 +080017902#ifdef CONFIG_MCL
17903#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) \
17904 ((_status) & WMI_RXERR_DECRYPT)
17905#else
17906#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) false
17907#endif
17908
Govind Singhe7f2f342016-05-23 12:12:52 +053017909/**
17910 * extract_mgmt_rx_params_tlv() - extract management rx params from event
17911 * @wmi_handle: wmi handle
17912 * @param evt_buf: pointer to event buffer
17913 * @param hdr: Pointer to hold header
17914 * @param bufp: Pointer to hold pointer to rx param buffer
17915 *
17916 * Return: QDF_STATUS_SUCCESS for success or error code
17917 */
17918static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053017919 void *evt_buf, struct mgmt_rx_event_params *hdr,
17920 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053017921{
17922 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
17923 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017924 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053017925
17926 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
17927 if (!param_tlvs) {
17928 WMI_LOGE("Get NULL point message from FW");
17929 return QDF_STATUS_E_INVAL;
17930 }
17931
17932 ev_hdr = param_tlvs->hdr;
17933 if (!hdr) {
17934 WMI_LOGE("Rx event is NULL");
17935 return QDF_STATUS_E_INVAL;
17936 }
17937
Jinwei Chenb69924c2018-08-20 11:31:31 +080017938 if (IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(ev_hdr->status)) {
17939 WMI_LOGE("%s: RX mgmt frame decrypt error, discard it",
17940 __func__);
17941 return QDF_STATUS_E_INVAL;
17942 }
17943
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017944 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17945 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017946
17947 hdr->channel = ev_hdr->channel;
17948 hdr->snr = ev_hdr->snr;
17949 hdr->rate = ev_hdr->rate;
17950 hdr->phy_mode = ev_hdr->phy_mode;
17951 hdr->buf_len = ev_hdr->buf_len;
17952 hdr->status = ev_hdr->status;
17953 hdr->flags = ev_hdr->flags;
17954 hdr->rssi = ev_hdr->rssi;
17955 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017956 for (i = 0; i < ATH_MAX_ANTENNA; i++)
17957 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053017958
17959 *bufp = param_tlvs->bufp;
17960
17961 return QDF_STATUS_SUCCESS;
17962}
17963
17964/**
17965 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
17966 * @wmi_handle: wmi handle
17967 * @param evt_buf: pointer to event buffer
17968 * @param vdev_id: Pointer to hold vdev identifier
17969 *
17970 * Return: QDF_STATUS_SUCCESS for success or error code
17971 */
17972static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
17973 void *evt_buf, uint32_t *vdev_id)
17974{
17975 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
17976 wmi_vdev_stopped_event_fixed_param *resp_event;
17977
17978 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
17979 if (!param_buf) {
17980 WMI_LOGE("Invalid event buffer");
17981 return QDF_STATUS_E_INVAL;
17982 }
17983 resp_event = param_buf->fixed_param;
17984 *vdev_id = resp_event->vdev_id;
17985
17986 return QDF_STATUS_SUCCESS;
17987}
17988
17989/**
17990 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
17991 * @wmi_handle: wmi handle
17992 * @param evt_buf: pointer to event buffer
17993 * @param param: Pointer to hold roam param
17994 *
17995 * Return: QDF_STATUS_SUCCESS for success or error code
17996 */
17997static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
17998 void *evt_buf, wmi_host_roam_event *param)
17999{
18000 WMI_ROAM_EVENTID_param_tlvs *param_buf;
18001 wmi_roam_event_fixed_param *evt;
18002
18003 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18004 if (!param_buf) {
18005 WMI_LOGE("Invalid roam event buffer");
18006 return QDF_STATUS_E_INVAL;
18007 }
18008
18009 evt = param_buf->fixed_param;
18010 qdf_mem_zero(param, sizeof(*param));
18011
18012 param->vdev_id = evt->vdev_id;
18013 param->reason = evt->reason;
18014 param->rssi = evt->rssi;
18015
18016 return QDF_STATUS_SUCCESS;
18017}
18018
18019/**
18020 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18021 * @wmi_handle: wmi handle
18022 * @param evt_buf: pointer to event buffer
18023 * @param param: Pointer to hold vdev scan param
18024 *
18025 * Return: QDF_STATUS_SUCCESS for success or error code
18026 */
18027static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018028 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018029{
18030 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18031 wmi_scan_event_fixed_param *evt = NULL;
18032
18033 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18034 evt = param_buf->fixed_param;
18035
18036 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018037
Govind Singhe7f2f342016-05-23 12:12:52 +053018038 switch (evt->event) {
18039 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018040 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018041 break;
18042 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018043 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018044 break;
18045 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018046 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018047 break;
18048 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018049 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018050 break;
18051 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018052 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018053 break;
18054 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018055 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018056 break;
18057 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018058 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018059 break;
18060 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018061 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018062 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018063 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018064 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018065 break;
18066 case WMI_SCAN_EVENT_MAX:
18067 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018068 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018069 break;
18070 };
18071
18072 switch (evt->reason) {
18073 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018074 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018075 break;
18076 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018077 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018078 break;
18079 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018080 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018081 break;
18082 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018083 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018084 break;
18085 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018086 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018087 break;
18088 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018089 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018090 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018091 case WMI_SCAN_REASON_SUSPENDED:
18092 param->reason = SCAN_REASON_SUSPENDED;
18093 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018094 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018095 param->reason = SCAN_REASON_MAX;
18096 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018097 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018098 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018099 break;
18100 };
18101
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018102 param->chan_freq = evt->channel_freq;
18103 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018104 param->scan_id = evt->scan_id;
18105 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018106 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018107
18108 return QDF_STATUS_SUCCESS;
18109}
18110
Frank Liu3d5e9992017-03-15 17:51:43 +080018111#ifdef CONVERGED_TDLS_ENABLE
18112/**
18113 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18114 * @wmi_handle: wmi handle
18115 * @param evt_buf: pointer to event buffer
18116 * @param param: Pointer to hold vdev tdls param
18117 *
18118 * Return: QDF_STATUS_SUCCESS for success or error code
18119 */
18120static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18121 void *evt_buf, struct tdls_event_info *param)
18122{
18123 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18124 wmi_tdls_peer_event_fixed_param *evt;
18125
18126 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18127 if (!param_buf) {
18128 WMI_LOGE("%s: NULL param_buf", __func__);
18129 return QDF_STATUS_E_NULL_VALUE;
18130 }
18131
18132 evt = param_buf->fixed_param;
18133
18134 qdf_mem_zero(param, sizeof(*param));
18135
18136 param->vdev_id = evt->vdev_id;
18137 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18138 param->peermac.bytes);
18139 switch (evt->peer_status) {
18140 case WMI_TDLS_SHOULD_DISCOVER:
18141 param->message_type = TDLS_SHOULD_DISCOVER;
18142 break;
18143 case WMI_TDLS_SHOULD_TEARDOWN:
18144 param->message_type = TDLS_SHOULD_TEARDOWN;
18145 break;
18146 case WMI_TDLS_PEER_DISCONNECTED:
18147 param->message_type = TDLS_PEER_DISCONNECTED;
18148 break;
18149 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18150 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18151 break;
18152 default:
18153 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18154 __func__, evt->peer_status);
18155 return QDF_STATUS_E_INVAL;
18156 };
18157
18158 switch (evt->peer_reason) {
18159 case WMI_TDLS_TEARDOWN_REASON_TX:
18160 param->peer_reason = TDLS_TEARDOWN_TX;
18161 break;
18162 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18163 param->peer_reason = TDLS_TEARDOWN_RSSI;
18164 break;
18165 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18166 param->peer_reason = TDLS_TEARDOWN_SCAN;
18167 break;
18168 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18169 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18170 break;
18171 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18172 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18173 break;
18174 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18175 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18176 break;
18177 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18178 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18179 break;
18180 case WMI_TDLS_ENTER_BUF_STA:
18181 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18182 break;
18183 case WMI_TDLS_EXIT_BUF_STA:
18184 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18185 break;
18186 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18187 param->peer_reason = TDLS_ENTER_BT_BUSY;
18188 break;
18189 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18190 param->peer_reason = TDLS_EXIT_BT_BUSY;
18191 break;
18192 case WMI_TDLS_SCAN_STARTED_EVENT:
18193 param->peer_reason = TDLS_SCAN_STARTED;
18194 break;
18195 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18196 param->peer_reason = TDLS_SCAN_COMPLETED;
18197 break;
18198
18199 default:
18200 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18201 __func__, evt->peer_reason, evt->peer_status);
18202 return QDF_STATUS_E_INVAL;
18203 };
18204
18205 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18206 __func__, param->peermac.bytes, param->message_type,
18207 param->peer_reason, param->vdev_id);
18208
18209 return QDF_STATUS_SUCCESS;
18210}
18211#endif
18212
Govind Singhe7f2f342016-05-23 12:12:52 +053018213/**
18214 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18215 * @wmi_handle: wmi handle
18216 * @param evt_buf: pointer to event buffer
18217 * @param param: Pointer to hold MGMT TX completion params
18218 *
18219 * Return: QDF_STATUS_SUCCESS for success or error code
18220 */
18221static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18222 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18223{
18224 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18225 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18226
18227 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18228 evt_buf;
18229 if (!param_buf) {
18230 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18231 return QDF_STATUS_E_INVAL;
18232 }
18233 cmpl_params = param_buf->fixed_param;
18234
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018235 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18236 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018237 param->desc_id = cmpl_params->desc_id;
18238 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018239 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018240
18241 return QDF_STATUS_SUCCESS;
18242}
18243
18244/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018245 * extract_offchan_data_tx_compl_param_tlv() -
18246 * extract Offchan data tx completion event params
18247 * @wmi_handle: wmi handle
18248 * @param evt_buf: pointer to event buffer
18249 * @param param: Pointer to hold offchan data TX completion params
18250 *
18251 * Return: QDF_STATUS_SUCCESS for success or error code
18252 */
18253static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18254 wmi_unified_t wmi_handle, void *evt_buf,
18255 struct wmi_host_offchan_data_tx_compl_event *param)
18256{
18257 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18258 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18259
18260 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18261 evt_buf;
18262 if (!param_buf) {
18263 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18264 return QDF_STATUS_E_INVAL;
18265 }
18266 cmpl_params = param_buf->fixed_param;
18267
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018268 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18269 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018270 param->desc_id = cmpl_params->desc_id;
18271 param->status = cmpl_params->status;
18272
18273 return QDF_STATUS_SUCCESS;
18274}
18275
18276/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018277 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18278 * status tlv
18279 * @wmi_handle: wmi handle
18280 * @param evt_buf: pointer to event buffer
18281 * @param param: Pointer to hold csa switch count status event param
18282 *
18283 * Return: QDF_STATUS_SUCCESS for success or error code
18284 */
18285static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18286 wmi_unified_t wmi_handle,
18287 void *evt_buf,
18288 struct pdev_csa_switch_count_status *param)
18289{
18290 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18291 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18292
18293 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18294 evt_buf;
18295 if (!param_buf) {
18296 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18297 return QDF_STATUS_E_INVAL;
18298 }
18299
18300 csa_status = param_buf->fixed_param;
18301
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018302 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18303 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018304 param->current_switch_count = csa_status->current_switch_count;
18305 param->num_vdevs = csa_status->num_vdevs;
18306 param->vdev_ids = param_buf->vdev_ids;
18307
18308 return QDF_STATUS_SUCCESS;
18309}
18310
18311/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018312 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18313 * param from event
18314 * @wmi_handle: wmi handle
18315 * @param evt_buf: pointer to event buffer
18316 * @param param: Pointer to hold tpc configuration
18317 *
18318 * Return: 0 for success or error code
18319 */
18320static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18321 void *evt_buf,
18322 wmi_host_pdev_tpc_config_event *param)
18323{
18324 wmi_pdev_tpc_config_event_fixed_param *event =
18325 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18326
18327 if (!event) {
18328 WMI_LOGE("Invalid event buffer");
18329 return QDF_STATUS_E_INVAL;
18330 }
18331
18332 param->pdev_id = event->pdev_id;
18333 param->regDomain = event->regDomain;
18334 param->chanFreq = event->chanFreq;
18335 param->phyMode = event->phyMode;
18336 param->twiceAntennaReduction = event->twiceAntennaReduction;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053018337 param->twiceAntennaGain = event->twiceAntennaGain;
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018338 param->twiceMaxRDPower = event->twiceMaxRDPower;
18339 param->powerLimit = event->powerLimit;
18340 param->rateMax = event->rateMax;
18341 param->numTxChain = event->numTxChain;
18342 param->ctl = event->ctl;
18343 param->flags = event->flags;
18344
18345 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18346 sizeof(param->maxRegAllowedPower));
18347 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18348 event->maxRegAllowedPowerAGCDD,
18349 sizeof(param->maxRegAllowedPowerAGCDD));
18350 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18351 event->maxRegAllowedPowerAGSTBC,
18352 sizeof(param->maxRegAllowedPowerAGSTBC));
18353 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18354 event->maxRegAllowedPowerAGTXBF,
18355 sizeof(param->maxRegAllowedPowerAGTXBF));
18356 WMI_LOGD("%s:extract success", __func__);
18357
18358 return QDF_STATUS_SUCCESS;
18359}
18360
18361/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018362 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018363 * @wmi_handle: wmi handle
18364 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018365 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018366 *
18367 * Return: QDF_STATUS_SUCCESS for success or error code
18368 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018369static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18370 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018371{
18372 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18373 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018374 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018375
18376 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18377 if (!param_buf) {
18378 WMI_LOGE("Invalid swba event buffer");
18379 return QDF_STATUS_E_INVAL;
18380 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018381
Govind Singhe7f2f342016-05-23 12:12:52 +053018382 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018383 *num_vdevs = swba_event->num_vdevs;
18384 if (!(*num_vdevs)) {
18385 vdev_map = swba_event->vdev_map;
18386 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18387 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018388
18389 return QDF_STATUS_SUCCESS;
18390}
18391
18392/**
18393 * extract_swba_tim_info_tlv() - extract swba tim info from event
18394 * @wmi_handle: wmi handle
18395 * @param evt_buf: pointer to event buffer
18396 * @param idx: Index to bcn info
18397 * @param tim_info: Pointer to hold tim info
18398 *
18399 * Return: QDF_STATUS_SUCCESS for success or error code
18400 */
18401static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18402 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18403{
18404 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18405 wmi_tim_info *tim_info_ev;
18406
18407 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18408 if (!param_buf) {
18409 WMI_LOGE("Invalid swba event buffer");
18410 return QDF_STATUS_E_INVAL;
18411 }
18412
18413 tim_info_ev = &param_buf->tim_info[idx];
18414
18415 tim_info->tim_len = tim_info_ev->tim_len;
18416 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18417 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18418 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18419 tim_info->tim_changed = tim_info_ev->tim_changed;
18420 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018421 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018422
18423 return QDF_STATUS_SUCCESS;
18424}
18425
18426/**
18427 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18428 * @wmi_handle: wmi handle
18429 * @param evt_buf: pointer to event buffer
18430 * @param idx: Index to bcn info
18431 * @param p2p_desc: Pointer to hold p2p NoA info
18432 *
18433 * Return: QDF_STATUS_SUCCESS for success or error code
18434 */
18435static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18436 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18437{
18438 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18439 wmi_p2p_noa_info *p2p_noa_info;
18440 uint8_t i = 0;
18441
18442 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18443 if (!param_buf) {
18444 WMI_LOGE("Invalid swba event buffer");
18445 return QDF_STATUS_E_INVAL;
18446 }
18447
18448 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18449
18450 p2p_desc->modified = false;
18451 p2p_desc->num_descriptors = 0;
18452 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18453 p2p_desc->modified = true;
18454 p2p_desc->index =
18455 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18456 p2p_desc->oppPS =
18457 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18458 p2p_desc->ctwindow =
18459 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18460 p2p_desc->num_descriptors =
18461 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18462 (p2p_noa_info);
18463 for (i = 0; i < p2p_desc->num_descriptors; i++) {
18464 p2p_desc->noa_descriptors[i].type_count =
18465 (uint8_t) p2p_noa_info->noa_descriptors[i].
18466 type_count;
18467 p2p_desc->noa_descriptors[i].duration =
18468 p2p_noa_info->noa_descriptors[i].duration;
18469 p2p_desc->noa_descriptors[i].interval =
18470 p2p_noa_info->noa_descriptors[i].interval;
18471 p2p_desc->noa_descriptors[i].start_time =
18472 p2p_noa_info->noa_descriptors[i].start_time;
18473 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018474 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018475 }
18476
18477 return QDF_STATUS_SUCCESS;
18478}
18479
Wu Gaocd3a8512017-03-13 20:17:34 +080018480#ifdef CONVERGED_P2P_ENABLE
18481/**
18482 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
18483 * @wmi_handle: wmi handle
18484 * @param evt_buf: pointer to event buffer
18485 * @param param: Pointer to hold p2p noa info
18486 *
18487 * Return: QDF_STATUS_SUCCESS for success or error code
18488 */
18489static QDF_STATUS extract_p2p_noa_ev_param_tlv(
18490 wmi_unified_t wmi_handle, void *evt_buf,
18491 struct p2p_noa_info *param)
18492{
18493 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
18494 wmi_p2p_noa_event_fixed_param *fixed_param;
18495 uint8_t i;
18496 wmi_p2p_noa_info *wmi_noa_info;
18497 uint8_t *buf_ptr;
18498 uint32_t descriptors;
18499
18500 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
18501 if (!param_tlvs) {
18502 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
18503 return QDF_STATUS_E_INVAL;
18504 }
18505
18506 if (!param) {
18507 WMI_LOGE("noa information param is null");
18508 return QDF_STATUS_E_INVAL;
18509 }
18510
18511 fixed_param = param_tlvs->fixed_param;
18512 buf_ptr = (uint8_t *) fixed_param;
18513 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
18514 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
18515
18516 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
18517 WMI_LOGE("%s: noa attr is not modified", __func__);
18518 return QDF_STATUS_E_INVAL;
18519 }
18520
18521 param->vdev_id = fixed_param->vdev_id;
18522 param->index =
18523 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
18524 param->opps_ps =
18525 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
18526 param->ct_window =
18527 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
18528 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
18529 param->num_desc = (uint8_t) descriptors;
18530
18531 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
18532 param->index, param->opps_ps, param->ct_window,
18533 param->num_desc);
18534 for (i = 0; i < param->num_desc; i++) {
18535 param->noa_desc[i].type_count =
18536 (uint8_t) wmi_noa_info->noa_descriptors[i].
18537 type_count;
18538 param->noa_desc[i].duration =
18539 wmi_noa_info->noa_descriptors[i].duration;
18540 param->noa_desc[i].interval =
18541 wmi_noa_info->noa_descriptors[i].interval;
18542 param->noa_desc[i].start_time =
18543 wmi_noa_info->noa_descriptors[i].start_time;
18544 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
18545 __func__, i, param->noa_desc[i].type_count,
18546 param->noa_desc[i].duration,
18547 param->noa_desc[i].interval,
18548 param->noa_desc[i].start_time);
18549 }
18550
18551 return QDF_STATUS_SUCCESS;
18552}
18553
Rachit Kankane9cd0c752018-07-31 16:26:38 +053018554#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +080018555/**
18556 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
18557 * information from event
18558 * @wmi_handle: wmi handle
18559 * @param evt_buf: pointer to event buffer
18560 * @param param: Pointer to hold p2p lo stop event information
18561 *
18562 * Return: QDF_STATUS_SUCCESS for success or error code
18563 */
18564static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
18565 wmi_unified_t wmi_handle, void *evt_buf,
18566 struct p2p_lo_event *param)
18567{
18568 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
18569 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
18570
18571 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
18572 evt_buf;
18573 if (!param_tlvs) {
18574 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
18575 return QDF_STATUS_E_INVAL;
18576 }
18577
18578 if (!param) {
18579 WMI_LOGE("lo stop event param is null");
18580 return QDF_STATUS_E_INVAL;
18581 }
18582
18583 lo_param = param_tlvs->fixed_param;
18584 param->vdev_id = lo_param->vdev_id;
18585 param->reason_code = lo_param->reason;
18586 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
18587 param->vdev_id, param->reason_code);
18588
18589 return QDF_STATUS_SUCCESS;
18590}
Rachit Kankane9cd0c752018-07-31 16:26:38 +053018591#endif
Wu Gaocd3a8512017-03-13 20:17:34 +080018592#endif /* End of CONVERGED_P2P_ENABLE */
18593
Govind Singhe7f2f342016-05-23 12:12:52 +053018594/**
18595 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
18596 * @wmi_handle: wmi handle
18597 * @param evt_buf: pointer to event buffer
18598 * @param ev: Pointer to hold peer param
18599 *
18600 * Return: QDF_STATUS_SUCCESS for success or error code
18601 */
18602static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
18603 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
18604{
18605 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
18606 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
18607
18608 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
18609 kickout_event = param_buf->fixed_param;
18610
18611 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
18612 ev->peer_macaddr);
18613
18614 ev->reason = kickout_event->reason;
18615 ev->rssi = kickout_event->rssi;
18616
18617 return QDF_STATUS_SUCCESS;
18618}
18619
18620/**
18621 * extract_all_stats_counts_tlv() - extract all stats count from event
18622 * @wmi_handle: wmi handle
18623 * @param evt_buf: pointer to event buffer
18624 * @param stats_param: Pointer to hold stats count
18625 *
18626 * Return: QDF_STATUS_SUCCESS for success or error code
18627 */
18628static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
18629 void *evt_buf, wmi_host_stats_event *stats_param)
18630{
Govind Singhe7f2f342016-05-23 12:12:52 +053018631 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018632 wmi_per_chain_rssi_stats *rssi_event;
18633 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018634
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018635 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053018636 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018637 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018638 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053018639 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018640 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053018641 return QDF_STATUS_E_FAILURE;
18642 }
18643
18644 switch (ev->stats_id) {
18645 case WMI_REQUEST_PEER_STAT:
18646 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
18647 break;
18648
18649 case WMI_REQUEST_AP_STAT:
18650 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
18651 break;
18652
18653 case WMI_REQUEST_PDEV_STAT:
18654 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
18655 break;
18656
18657 case WMI_REQUEST_VDEV_STAT:
18658 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
18659 break;
18660
18661 case WMI_REQUEST_BCNFLT_STAT:
18662 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
18663 break;
18664
18665 case WMI_REQUEST_VDEV_RATE_STAT:
18666 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
18667 break;
18668
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018669 case WMI_REQUEST_BCN_STAT:
18670 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
18671 break;
18672
Govind Singhe7f2f342016-05-23 12:12:52 +053018673 default:
18674 stats_param->stats_id = 0;
18675 break;
18676
18677 }
18678
18679 stats_param->num_pdev_stats = ev->num_pdev_stats;
18680 stats_param->num_pdev_ext_stats = 0;
18681 stats_param->num_vdev_stats = ev->num_vdev_stats;
18682 stats_param->num_peer_stats = ev->num_peer_stats;
18683 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18684 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018685 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018686 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18687 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018688
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018689 /* if chain_stats is not populated */
18690 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
18691 return QDF_STATUS_SUCCESS;
18692
18693 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
18694 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
18695 return QDF_STATUS_SUCCESS;
18696
18697 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -070018698 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018699 return QDF_STATUS_SUCCESS;
18700
18701 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
18702
Govind Singhe7f2f342016-05-23 12:12:52 +053018703 return QDF_STATUS_SUCCESS;
18704}
18705
18706/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018707 * extract_pdev_tx_stats() - extract pdev tx stats from event
18708 */
18709static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
18710{
18711 /* Tx Stats */
18712 tx->comp_queued = tx_stats->comp_queued;
18713 tx->comp_delivered = tx_stats->comp_delivered;
18714 tx->msdu_enqued = tx_stats->msdu_enqued;
18715 tx->mpdu_enqued = tx_stats->mpdu_enqued;
18716 tx->wmm_drop = tx_stats->wmm_drop;
18717 tx->local_enqued = tx_stats->local_enqued;
18718 tx->local_freed = tx_stats->local_freed;
18719 tx->hw_queued = tx_stats->hw_queued;
18720 tx->hw_reaped = tx_stats->hw_reaped;
18721 tx->underrun = tx_stats->underrun;
18722 tx->tx_abort = tx_stats->tx_abort;
18723 tx->mpdus_requed = tx_stats->mpdus_requed;
18724 tx->data_rc = tx_stats->data_rc;
18725 tx->self_triggers = tx_stats->self_triggers;
18726 tx->sw_retry_failure = tx_stats->sw_retry_failure;
18727 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
18728 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
18729 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
18730 tx->pdev_resets = tx_stats->pdev_resets;
18731 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
18732 tx->phy_underrun = tx_stats->phy_underrun;
18733 tx->txop_ovf = tx_stats->txop_ovf;
18734
18735 return;
18736}
18737
18738
18739/**
18740 * extract_pdev_rx_stats() - extract pdev rx stats from event
18741 */
18742static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
18743{
18744 /* Rx Stats */
18745 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
18746 rx->status_rcvd = rx_stats->status_rcvd;
18747 rx->r0_frags = rx_stats->r0_frags;
18748 rx->r1_frags = rx_stats->r1_frags;
18749 rx->r2_frags = rx_stats->r2_frags;
18750 /* Only TLV */
18751 rx->r3_frags = 0;
18752 rx->htt_msdus = rx_stats->htt_msdus;
18753 rx->htt_mpdus = rx_stats->htt_mpdus;
18754 rx->loc_msdus = rx_stats->loc_msdus;
18755 rx->loc_mpdus = rx_stats->loc_mpdus;
18756 rx->oversize_amsdu = rx_stats->oversize_amsdu;
18757 rx->phy_errs = rx_stats->phy_errs;
18758 rx->phy_err_drop = rx_stats->phy_err_drop;
18759 rx->mpdu_errs = rx_stats->mpdu_errs;
18760
18761 return;
18762}
18763
18764/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018765 * extract_pdev_stats_tlv() - extract pdev stats from event
18766 * @wmi_handle: wmi handle
18767 * @param evt_buf: pointer to event buffer
18768 * @param index: Index into pdev stats
18769 * @param pdev_stats: Pointer to hold pdev stats
18770 *
18771 * Return: QDF_STATUS_SUCCESS for success or error code
18772 */
18773static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
18774 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
18775{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018776 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18777 wmi_stats_event_fixed_param *ev_param;
18778 uint8_t *data;
18779
18780 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18781 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18782
18783 data = param_buf->data;
18784
18785 if (index < ev_param->num_pdev_stats) {
18786 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
18787 (index * sizeof(wmi_pdev_stats)));
18788
18789 pdev_stats->chan_nf = ev->chan_nf;
18790 pdev_stats->tx_frame_count = ev->tx_frame_count;
18791 pdev_stats->rx_frame_count = ev->rx_frame_count;
18792 pdev_stats->rx_clear_count = ev->rx_clear_count;
18793 pdev_stats->cycle_count = ev->cycle_count;
18794 pdev_stats->phy_err_count = ev->phy_err_count;
18795 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
18796
18797 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
18798 &(ev->pdev_stats.tx));
18799 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
18800 &(ev->pdev_stats.rx));
18801 }
18802
Govind Singhe7f2f342016-05-23 12:12:52 +053018803 return QDF_STATUS_SUCCESS;
18804}
18805
18806/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070018807 * extract_unit_test_tlv() - extract unit test data
18808 * @wmi_handle: wmi handle
18809 * @param evt_buf: pointer to event buffer
18810 * @param unit_test: pointer to hold unit test data
18811 * @param maxspace: Amount of space in evt_buf
18812 *
18813 * Return: QDF_STATUS_SUCCESS for success or error code
18814 */
18815static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
18816 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
18817{
18818 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
18819 wmi_unit_test_event_fixed_param *ev_param;
18820 uint32_t num_bufp;
18821 uint32_t copy_size;
18822 uint8_t *bufp;
18823
18824 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
18825 ev_param = param_buf->fixed_param;
18826 bufp = param_buf->bufp;
18827 num_bufp = param_buf->num_bufp;
18828 unit_test->vdev_id = ev_param->vdev_id;
18829 unit_test->module_id = ev_param->module_id;
18830 unit_test->diag_token = ev_param->diag_token;
18831 unit_test->flag = ev_param->flag;
18832 unit_test->payload_len = ev_param->payload_len;
18833 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
18834 ev_param->vdev_id,
18835 ev_param->module_id,
18836 ev_param->diag_token,
18837 ev_param->flag);
18838 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
18839 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
18840 bufp, num_bufp);
18841 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
18842 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
18843 unit_test->buffer_len = copy_size;
18844
18845 return QDF_STATUS_SUCCESS;
18846}
18847
18848/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018849 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
18850 * @wmi_handle: wmi handle
18851 * @param evt_buf: pointer to event buffer
18852 * @param index: Index into extended pdev stats
18853 * @param pdev_ext_stats: Pointer to hold extended pdev stats
18854 *
18855 * Return: QDF_STATUS_SUCCESS for success or error code
18856 */
18857static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
18858 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
18859{
18860 return QDF_STATUS_SUCCESS;
18861}
18862
18863/**
18864 * extract_vdev_stats_tlv() - extract vdev stats from event
18865 * @wmi_handle: wmi handle
18866 * @param evt_buf: pointer to event buffer
18867 * @param index: Index into vdev stats
18868 * @param vdev_stats: Pointer to hold vdev stats
18869 *
18870 * Return: QDF_STATUS_SUCCESS for success or error code
18871 */
18872static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
18873 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
18874{
18875 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18876 wmi_stats_event_fixed_param *ev_param;
18877 uint8_t *data;
18878
18879 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18880 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18881 data = (uint8_t *) param_buf->data;
18882
18883 if (index < ev_param->num_vdev_stats) {
18884 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
18885 ((ev_param->num_pdev_stats) *
18886 sizeof(wmi_pdev_stats)) +
18887 (index * sizeof(wmi_vdev_stats)));
18888
18889 vdev_stats->vdev_id = ev->vdev_id;
18890 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
18891 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
18892
18893 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
18894 sizeof(ev->tx_frm_cnt));
18895 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
18896 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
18897 ev->multiple_retry_cnt,
18898 sizeof(ev->multiple_retry_cnt));
18899 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
18900 sizeof(ev->fail_cnt));
18901 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
18902 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
18903 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
18904 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
18905 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
18906 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
18907 sizeof(ev->tx_rate_history));
18908 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
18909 sizeof(ev->bcn_rssi_history));
18910
18911 }
18912
18913 return QDF_STATUS_SUCCESS;
18914}
18915
18916/**
Naveen Rawatd2115722018-04-12 08:17:55 -070018917 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
18918 * buffer
18919 * @wmi_handle: wmi handle
18920 * @evt_buf: pointer to event buffer
18921 * @index: Index into vdev stats
18922 * @rssi_stats: Pointer to hold rssi stats
18923 *
18924 * Return: QDF_STATUS_SUCCESS for success or error code
18925 */
18926static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
18927 void *evt_buf, uint32_t index,
18928 struct wmi_host_per_chain_rssi_stats *rssi_stats)
18929{
18930 uint8_t *data;
18931 wmi_rssi_stats *fw_rssi_stats;
18932 wmi_per_chain_rssi_stats *rssi_event;
18933 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18934
18935 if (!evt_buf) {
18936 WMI_LOGE("evt_buf is null");
18937 return QDF_STATUS_E_NULL_VALUE;
18938 }
18939
18940 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18941 rssi_event = param_buf->chain_stats;
18942
18943 if (index >= rssi_event->num_per_chain_rssi_stats) {
18944 WMI_LOGE("invalid index");
18945 return QDF_STATUS_E_INVAL;
18946 }
18947
18948 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
18949 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
18950
18951 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
18952 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
18953 fw_rssi_stats->rssi_avg_beacon,
18954 sizeof(fw_rssi_stats->rssi_avg_beacon));
18955 qdf_mem_copy(rssi_stats->rssi_avg_data,
18956 fw_rssi_stats->rssi_avg_data,
18957 sizeof(fw_rssi_stats->rssi_avg_data));
18958 qdf_mem_copy(&rssi_stats->peer_macaddr,
18959 &fw_rssi_stats->peer_macaddr,
18960 sizeof(fw_rssi_stats->peer_macaddr));
18961
18962 return QDF_STATUS_SUCCESS;
18963}
18964
18965
18966
18967/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018968 * extract_bcn_stats_tlv() - extract bcn stats from event
18969 * @wmi_handle: wmi handle
18970 * @param evt_buf: pointer to event buffer
18971 * @param index: Index into vdev stats
18972 * @param bcn_stats: Pointer to hold bcn stats
18973 *
18974 * Return: QDF_STATUS_SUCCESS for success or error code
18975 */
18976static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
18977 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
18978{
18979 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18980 wmi_stats_event_fixed_param *ev_param;
18981 uint8_t *data;
18982
18983 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18984 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18985 data = (uint8_t *) param_buf->data;
18986
18987 if (index < ev_param->num_bcn_stats) {
18988 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
18989 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18990 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18991 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
18992 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
18993 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
18994 (index * sizeof(wmi_bcn_stats)));
18995
18996 bcn_stats->vdev_id = ev->vdev_id;
18997 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
18998 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
18999 }
19000
19001 return QDF_STATUS_SUCCESS;
19002}
19003
19004/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019005 * extract_peer_stats_tlv() - extract peer stats from event
19006 * @wmi_handle: wmi handle
19007 * @param evt_buf: pointer to event buffer
19008 * @param index: Index into peer stats
19009 * @param peer_stats: Pointer to hold peer stats
19010 *
19011 * Return: QDF_STATUS_SUCCESS for success or error code
19012 */
19013static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19014 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19015{
19016 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19017 wmi_stats_event_fixed_param *ev_param;
19018 uint8_t *data;
19019
19020 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19021 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19022 data = (uint8_t *) param_buf->data;
19023
19024 if (index < ev_param->num_peer_stats) {
19025 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19026 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19027 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19028 (index * sizeof(wmi_peer_stats)));
19029
19030 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19031
19032 OS_MEMCPY(&(peer_stats->peer_macaddr),
19033 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19034
19035 peer_stats->peer_rssi = ev->peer_rssi;
19036 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19037 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19038 }
19039
19040 return QDF_STATUS_SUCCESS;
19041}
19042
19043/**
19044 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19045 * @wmi_handle: wmi handle
19046 * @param evt_buf: pointer to event buffer
19047 * @param index: Index into bcn fault stats
19048 * @param bcnflt_stats: Pointer to hold bcn fault stats
19049 *
19050 * Return: QDF_STATUS_SUCCESS for success or error code
19051 */
19052static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19053 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19054{
19055 return QDF_STATUS_SUCCESS;
19056}
19057
19058/**
19059 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19060 * @wmi_handle: wmi handle
19061 * @param evt_buf: pointer to event buffer
19062 * @param index: Index into extended peer stats
19063 * @param peer_extd_stats: Pointer to hold extended peer stats
19064 *
19065 * Return: QDF_STATUS_SUCCESS for success or error code
19066 */
19067static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19068 void *evt_buf, uint32_t index,
19069 wmi_host_peer_extd_stats *peer_extd_stats)
19070{
19071 return QDF_STATUS_SUCCESS;
19072}
19073
19074/**
19075 * extract_chan_stats_tlv() - extract chan stats from event
19076 * @wmi_handle: wmi handle
19077 * @param evt_buf: pointer to event buffer
19078 * @param index: Index into chan stats
19079 * @param vdev_extd_stats: Pointer to hold chan stats
19080 *
19081 * Return: QDF_STATUS_SUCCESS for success or error code
19082 */
19083static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19084 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19085{
19086 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19087 wmi_stats_event_fixed_param *ev_param;
19088 uint8_t *data;
19089
19090 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19091 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19092 data = (uint8_t *) param_buf->data;
19093
19094 if (index < ev_param->num_chan_stats) {
19095 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19096 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19097 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19098 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19099 (index * sizeof(wmi_chan_stats)));
19100
19101
Jeff Johnson79eaacb2018-05-06 17:53:18 -070019102 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +053019103 chan_stats->chan_mhz = ev->chan_mhz;
19104 chan_stats->sampling_period_us = ev->sampling_period_us;
19105 chan_stats->rx_clear_count = ev->rx_clear_count;
19106 chan_stats->tx_duration_us = ev->tx_duration_us;
19107 chan_stats->rx_duration_us = ev->rx_duration_us;
19108 }
19109
19110 return QDF_STATUS_SUCCESS;
19111}
19112
19113/**
19114 * extract_profile_ctx_tlv() - extract profile context from event
19115 * @wmi_handle: wmi handle
19116 * @param evt_buf: pointer to event buffer
19117 * @idx: profile stats index to extract
19118 * @param profile_ctx: Pointer to hold profile context
19119 *
19120 * Return: QDF_STATUS_SUCCESS for success or error code
19121 */
19122static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19123 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19124{
19125 return QDF_STATUS_SUCCESS;
19126}
19127
19128/**
19129 * extract_profile_data_tlv() - extract profile data from event
19130 * @wmi_handle: wmi handle
19131 * @param evt_buf: pointer to event buffer
19132 * @param profile_data: Pointer to hold profile data
19133 *
19134 * Return: QDF_STATUS_SUCCESS for success or error code
19135 */
19136static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19137 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19138{
19139
19140 return QDF_STATUS_SUCCESS;
19141}
19142
19143/**
19144 * extract_chan_info_event_tlv() - extract chan information from event
19145 * @wmi_handle: wmi handle
19146 * @param evt_buf: pointer to event buffer
19147 * @param chan_info: Pointer to hold chan information
19148 *
19149 * Return: QDF_STATUS_SUCCESS for success or error code
19150 */
19151static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19152 void *evt_buf, wmi_host_chan_info_event *chan_info)
19153{
19154 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19155 wmi_chan_info_event_fixed_param *ev;
19156
19157 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19158
19159 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19160 if (!ev) {
19161 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19162 return QDF_STATUS_E_FAILURE;
19163 }
19164
19165 chan_info->err_code = ev->err_code;
19166 chan_info->freq = ev->freq;
19167 chan_info->cmd_flags = ev->cmd_flags;
19168 chan_info->noise_floor = ev->noise_floor;
19169 chan_info->rx_clear_count = ev->rx_clear_count;
19170 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019171 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19172 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019173 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19174 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19175 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019176 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19177 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19178 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19179 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19180 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19181 chan_info->rx_frame_count = ev->rx_frame_count;
19182 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19183 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019184
19185 return QDF_STATUS_SUCCESS;
19186}
19187
19188/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019189 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19190 * @wmi_handle: WMI handle
19191 * @param evt_buf: Pointer to event buffer
19192 * @param param: Pointer to hold data
19193 *
19194 * Return : QDF_STATUS_SUCCESS for success or error code
19195 */
19196static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19197 uint8_t *evt_buf,
19198 struct wmi_host_pdev_utf_event *event)
19199{
19200 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019201 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019202
19203 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19204 event->data = param_buf->data;
19205 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019206 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019207 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019208 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019209 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019210
19211 return QDF_STATUS_SUCCESS;
19212}
Govind Singhe7f2f342016-05-23 12:12:52 +053019213
Kiran Venkatappa06520822016-08-10 23:55:40 +053019214/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019215 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19216 * @wmi_handle: wmi handle
19217 * @param evt_buf: pointer to event buffer
19218 * @param param: Pointer to hold evt buf
19219 *
19220 * Return: QDF_STATUS_SUCCESS for success or error code
19221 */
19222static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19223 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19224{
19225 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19226 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19227 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19228 uint8_t i = 0, j = 0;
19229
19230 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19231 if (!param_buf)
19232 return QDF_STATUS_E_INVAL;
19233
19234 hw_caps = param_buf->soc_hw_mode_caps;
19235 if (!hw_caps)
19236 return QDF_STATUS_E_INVAL;
19237
19238 if (!hw_caps->num_chainmask_tables)
19239 return QDF_STATUS_E_INVAL;
19240
19241 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19242
19243 if (chainmask_caps == NULL)
19244 return QDF_STATUS_E_INVAL;
19245
19246 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19247
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019248 qdf_print("Dumping chain mask combo data for table : %d", i);
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019249 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19250
19251 chainmask_table[i].cap_list[j].chainmask =
19252 chainmask_caps->chainmask;
19253
19254 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19255 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19256
19257 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19258 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19259
19260 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19261 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19262
19263 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19264 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19265
19266 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19267 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19268
19269 chainmask_table[i].cap_list[j].chain_mask_2G =
19270 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19271
19272 chainmask_table[i].cap_list[j].chain_mask_5G =
19273 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19274
19275 chainmask_table[i].cap_list[j].chain_mask_tx =
19276 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19277
19278 chainmask_table[i].cap_list[j].chain_mask_rx =
19279 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19280
19281 chainmask_table[i].cap_list[j].supports_aDFS =
19282 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19283
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019284 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x",
19285 chainmask_caps->supported_flags,
19286 chainmask_caps->chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019287 );
19288 chainmask_caps++;
19289 }
19290 }
19291
19292 return QDF_STATUS_SUCCESS;
19293}
19294
19295/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019296 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19297 * from event
19298 * @wmi_handle: wmi handle
19299 * @param evt_buf: pointer to event buffer
19300 * @param param: Pointer to hold evt buf
19301 *
19302 * Return: QDF_STATUS_SUCCESS for success or error code
19303 */
19304static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019305 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019306{
19307 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19308 wmi_service_ready_ext_event_fixed_param *ev;
19309 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19310 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019311 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19312 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019313
19314 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19315 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019316 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019317
19318 ev = param_buf->fixed_param;
19319 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019320 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019321
19322 /* Move this to host based bitmap */
19323 param->default_conc_scan_config_bits =
19324 ev->default_conc_scan_config_bits;
19325 param->default_fw_config_bits = ev->default_fw_config_bits;
19326 param->he_cap_info = ev->he_cap_info;
19327 param->mpdu_density = ev->mpdu_density;
19328 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019329 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019330 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -070019331 param->max_bssid_indicator = ev->max_bssid_indicator;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019332 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19333
19334 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019335 if (hw_caps)
19336 param->num_hw_modes = hw_caps->num_hw_modes;
19337 else
19338 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019339
19340 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019341 if (reg_caps)
19342 param->num_phy = reg_caps->num_phy;
19343 else
19344 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019345
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019346 if (hw_caps) {
19347 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019348 qdf_print("Num chain mask tables: %d", hw_caps->num_chainmask_tables);
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019349 } else
19350 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019351
19352 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19353
19354 if (chain_mask_combo == NULL)
19355 return QDF_STATUS_SUCCESS;
19356
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019357 qdf_print("Dumping chain mask combo data");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019358
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019359 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019360
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019361 qdf_print("table_id : %d Num valid chainmasks: %d",
19362 chain_mask_combo->chainmask_table_id,
19363 chain_mask_combo->num_valid_chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019364 );
19365
19366 param->chainmask_table[i].table_id =
19367 chain_mask_combo->chainmask_table_id;
19368 param->chainmask_table[i].num_valid_chainmasks =
19369 chain_mask_combo->num_valid_chainmask;
19370 chain_mask_combo++;
19371 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019372 qdf_print("chain mask combo end");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019373
Kiran Venkatappa06520822016-08-10 23:55:40 +053019374 return QDF_STATUS_SUCCESS;
19375}
19376
19377/**
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019378 * extract_sar_cap_service_ready_ext_tlv() -
19379 * extract SAR cap from service ready event
19380 * @wmi_handle: wmi handle
19381 * @event: pointer to event buffer
19382 * @ext_param: extended target info
19383 *
19384 * Return: QDF_STATUS_SUCCESS for success or error code
19385 */
19386static QDF_STATUS extract_sar_cap_service_ready_ext_tlv(
19387 wmi_unified_t wmi_handle,
19388 uint8_t *event,
19389 struct wlan_psoc_host_service_ext_param *ext_param)
19390{
19391 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19392 WMI_SAR_CAPABILITIES *sar_caps;
19393
19394 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19395
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019396 if (!param_buf)
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019397 return QDF_STATUS_E_INVAL;
19398
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019399 sar_caps = param_buf->sar_caps;
19400 if (sar_caps)
19401 ext_param->sar_version = sar_caps->active_version;
19402 else
19403 ext_param->sar_version = 0;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019404
19405 return QDF_STATUS_SUCCESS;
19406}
19407
19408/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019409 * extract_hw_mode_cap_service_ready_ext_tlv() -
19410 * extract HW mode cap from service ready event
19411 * @wmi_handle: wmi handle
19412 * @param evt_buf: pointer to event buffer
19413 * @param param: Pointer to hold evt buf
19414 * @param hw_mode_idx: hw mode idx should be less than num_mode
19415 *
19416 * Return: QDF_STATUS_SUCCESS for success or error code
19417 */
19418static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19419 wmi_unified_t wmi_handle,
19420 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019421 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019422{
19423 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19424 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19425
19426 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19427 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019428 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019429
19430 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019431 if (!hw_caps)
19432 return QDF_STATUS_E_INVAL;
19433
Kiran Venkatappa06520822016-08-10 23:55:40 +053019434 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019435 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019436
19437 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19438 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19439
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019440 param->hw_mode_config_type =
19441 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19442
Kiran Venkatappa06520822016-08-10 23:55:40 +053019443 return QDF_STATUS_SUCCESS;
19444}
19445
19446/**
19447 * extract_mac_phy_cap_service_ready_ext_tlv() -
19448 * extract MAC phy cap from service ready event
19449 * @wmi_handle: wmi handle
19450 * @param evt_buf: pointer to event buffer
19451 * @param param: Pointer to hold evt buf
19452 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019453 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019454 *
19455 * Return: QDF_STATUS_SUCCESS for success or error code
19456 */
19457static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19458 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019459 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019460 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019461{
19462 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019463 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019464 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19465 uint32_t phy_map;
19466 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019467
19468 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19469 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019470 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019471
19472 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019473 if (!hw_caps)
19474 return QDF_STATUS_E_INVAL;
19475
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019476 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19477 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19478 break;
19479
19480 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19481 while (phy_map) {
19482 phy_map >>= 1;
19483 phy_idx++;
19484 }
19485 }
19486
19487 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019488 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019489
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019490 phy_idx += phy_id;
19491 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019492 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019493
19494 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019495
19496 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019497 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19498 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019499 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019500 param->supports_11b =
19501 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19502 param->supports_11g =
19503 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19504 param->supports_11a =
19505 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19506 param->supports_11n =
19507 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19508 param->supports_11ac =
19509 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19510 param->supports_11ax =
19511 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019512
19513 param->supported_bands = mac_phy_caps->supported_bands;
19514 param->ampdu_density = mac_phy_caps->ampdu_density;
19515 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19516 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19517 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19518 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19519 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19520 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19521 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19522 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19523 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19524 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19525 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19526 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19527 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19528 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19529 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19530 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019531 qdf_mem_copy(&param->he_cap_phy_info_2G,
19532 &mac_phy_caps->he_cap_phy_info_2G,
19533 sizeof(param->he_cap_phy_info_2G));
19534 qdf_mem_copy(&param->he_cap_phy_info_5G,
19535 &mac_phy_caps->he_cap_phy_info_5G,
19536 sizeof(param->he_cap_phy_info_5G));
19537 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19538 sizeof(param->he_ppet2G));
19539 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19540 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019541 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019542
19543 return QDF_STATUS_SUCCESS;
19544}
19545
19546/**
19547 * extract_reg_cap_service_ready_ext_tlv() -
19548 * extract REG cap from service ready event
19549 * @wmi_handle: wmi handle
19550 * @param evt_buf: pointer to event buffer
19551 * @param param: Pointer to hold evt buf
19552 * @param phy_idx: phy idx should be less than num_mode
19553 *
19554 * Return: QDF_STATUS_SUCCESS for success or error code
19555 */
19556static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
19557 wmi_unified_t wmi_handle,
19558 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019559 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019560{
19561 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19562 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
19563 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
19564
19565 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19566 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019567 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019568
19569 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019570 if (!reg_caps)
19571 return QDF_STATUS_E_INVAL;
19572
Kiran Venkatappa06520822016-08-10 23:55:40 +053019573 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019574 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019575
19576 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
19577
19578 param->phy_id = ext_reg_cap->phy_id;
19579 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
19580 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
19581 param->regcap1 = ext_reg_cap->regcap1;
19582 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053019583 param->wireless_modes = convert_wireless_modes_tlv(
19584 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019585 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
19586 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
19587 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
19588 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
19589
19590 return QDF_STATUS_SUCCESS;
19591}
19592
Sathish Kumarf396c722017-11-17 17:30:41 +053019593static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
19594 wmi_unified_t wmi_handle,
19595 uint8_t *event, uint8_t idx,
19596 struct wlan_psoc_host_dbr_ring_caps *param)
19597{
19598 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19599 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
19600
19601 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19602 if (!param_buf)
19603 return QDF_STATUS_E_INVAL;
19604
19605 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
19606
19607 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19608 dbr_ring_caps->pdev_id);
19609 param->mod_id = dbr_ring_caps->mod_id;
19610 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
19611 param->min_buf_size = dbr_ring_caps->min_buf_size;
19612 param->min_buf_align = dbr_ring_caps->min_buf_align;
19613
19614 return QDF_STATUS_SUCCESS;
19615}
19616
19617static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
19618 uint8_t *event, struct direct_buf_rx_rsp *param)
19619{
19620 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19621 wmi_dma_buf_release_fixed_param *ev;
19622
19623 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19624 if (!param_buf)
19625 return QDF_STATUS_E_INVAL;
19626
19627 ev = param_buf->fixed_param;
19628 if (!ev)
19629 return QDF_STATUS_E_INVAL;
19630
19631 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19632 ev->pdev_id);
19633 param->mod_id = ev->mod_id;
19634 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019635 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053019636 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
19637 param->pdev_id, param->mod_id, param->num_buf_release_entry);
19638
19639 return QDF_STATUS_SUCCESS;
19640}
19641
19642static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
19643 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
19644{
19645 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19646 wmi_dma_buf_release_entry *entry;
19647
19648 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19649 if (!param_buf)
19650 return QDF_STATUS_E_INVAL;
19651
19652 entry = &param_buf->entries[idx];
19653
19654 if (!entry) {
19655 WMI_LOGE("%s: Entry is NULL\n", __func__);
19656 return QDF_STATUS_E_FAILURE;
19657 }
19658
19659 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
19660
19661 param->paddr_lo = entry->paddr_lo;
19662 param->paddr_hi = entry->paddr_hi;
19663
19664 return QDF_STATUS_SUCCESS;
19665}
19666
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019667static QDF_STATUS extract_dbr_buf_metadata_tlv(
19668 wmi_unified_t wmi_handle, uint8_t *event,
19669 uint8_t idx, struct direct_buf_rx_metadata *param)
19670{
19671 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19672 wmi_dma_buf_release_spectral_meta_data *entry;
19673
19674 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19675 if (!param_buf)
19676 return QDF_STATUS_E_INVAL;
19677
19678 entry = &param_buf->meta_data[idx];
19679
19680 if (!entry) {
19681 WMI_LOGE("%s: Entry is NULL\n", __func__);
19682 return QDF_STATUS_E_FAILURE;
19683 }
19684
19685 qdf_mem_copy(param->noisefloor, entry->noise_floor,
19686 sizeof(entry->noise_floor));
19687 return QDF_STATUS_SUCCESS;
19688}
19689
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019690/**
19691 * extract_dcs_interference_type_tlv() - extract dcs interference type
19692 * from event
19693 * @wmi_handle: wmi handle
19694 * @param evt_buf: pointer to event buffer
19695 * @param param: Pointer to hold dcs interference param
19696 *
19697 * Return: 0 for success or error code
19698 */
19699static QDF_STATUS extract_dcs_interference_type_tlv(
19700 wmi_unified_t wmi_handle,
19701 void *evt_buf, struct wmi_host_dcs_interference_param *param)
19702{
19703 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19704
19705 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19706 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019707 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019708
19709 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019710 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19711 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019712
19713 return QDF_STATUS_SUCCESS;
19714}
19715
19716/*
19717 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
19718 * @wmi_handle: wmi handle
19719 * @param evt_buf: pointer to event buffer
19720 * @param cw_int: Pointer to hold cw interference
19721 *
19722 * Return: 0 for success or error code
19723 */
19724static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
19725 void *evt_buf,
19726 wmi_host_ath_dcs_cw_int *cw_int)
19727{
19728 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19729 wlan_dcs_cw_int *ev;
19730
19731 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19732 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019733 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019734
19735 ev = param_buf->cw_int;
19736
19737 cw_int->channel = ev->channel;
19738
19739 return QDF_STATUS_SUCCESS;
19740}
19741
19742/**
19743 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
19744 * @wmi_handle: wmi handle
19745 * @param evt_buf: pointer to event buffer
19746 * @param wlan_stat: Pointer to hold wlan stats
19747 *
19748 * Return: 0 for success or error code
19749 */
19750static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
19751 void *evt_buf,
19752 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
19753{
19754 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19755 wlan_dcs_im_tgt_stats_t *ev;
19756
19757 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19758 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019759 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019760
19761 ev = param_buf->wlan_stat;
19762 wlan_stat->reg_tsf32 = ev->reg_tsf32;
19763 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
19764 wlan_stat->tx_waste_time = ev->tx_waste_time;
19765 wlan_stat->rx_time = ev->rx_time;
19766 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
19767 wlan_stat->mib_stats.listen_time = ev->listen_time;
19768 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
19769 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
19770 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
19771 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
19772 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
19773 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
19774 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
19775 wlan_stat->chan_nf = ev->chan_nf;
19776 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19777
19778 return QDF_STATUS_SUCCESS;
19779}
19780
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019781/**
19782 * extract_thermal_stats_tlv() - extract thermal stats from event
19783 * @wmi_handle: wmi handle
19784 * @param evt_buf: Pointer to event buffer
19785 * @param temp: Pointer to hold extracted temperature
19786 * @param level: Pointer to hold extracted level
19787 *
19788 * Return: 0 for success or error code
19789 */
19790static QDF_STATUS
19791extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
19792 void *evt_buf, uint32_t *temp,
19793 uint32_t *level, uint32_t *pdev_id)
19794{
19795 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19796 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
19797
19798 param_buf =
19799 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19800 if (!param_buf)
19801 return QDF_STATUS_E_INVAL;
19802
19803 tt_stats_event = param_buf->fixed_param;
19804
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019805 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19806 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019807 *temp = tt_stats_event->temp;
19808 *level = tt_stats_event->level;
19809
19810 return QDF_STATUS_SUCCESS;
19811}
19812
19813/**
19814 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
19815 * @wmi_handle: wmi handle
19816 * @param evt_buf: pointer to event buffer
19817 * @param idx: Index to level stats
19818 * @param levelcount: Pointer to hold levelcount
19819 * @param dccount: Pointer to hold dccount
19820 *
19821 * Return: 0 for success or error code
19822 */
19823static QDF_STATUS
19824extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
19825 void *evt_buf, uint8_t idx, uint32_t *levelcount,
19826 uint32_t *dccount)
19827{
19828 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19829 wmi_therm_throt_level_stats_info *tt_level_info;
19830
19831 param_buf =
19832 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19833 if (!param_buf)
19834 return QDF_STATUS_E_INVAL;
19835
19836 tt_level_info = param_buf->therm_throt_level_stats_info;
19837
19838 if (idx < THERMAL_LEVELS) {
19839 *levelcount = tt_level_info[idx].level_count;
19840 *dccount = tt_level_info[idx].dc_count;
19841 return QDF_STATUS_SUCCESS;
19842 }
19843
19844 return QDF_STATUS_E_FAILURE;
19845}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019846#ifdef BIG_ENDIAN_HOST
19847/**
19848 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
19849 * @param data_len - data length
19850 * @param data - pointer to data
19851 *
19852 * Return: QDF_STATUS - success or error status
19853 */
19854static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19855{
19856 uint8_t *data_aligned = NULL;
19857 int c;
19858 unsigned char *data_unaligned;
19859
19860 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
19861 FIPS_ALIGN));
19862 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -070019863 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019864 if (data_unaligned == NULL)
19865 return QDF_STATUS_E_FAILURE;
19866
19867 /* Checking if space is alligned */
19868 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
19869 /* align the data space */
19870 data_aligned =
19871 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
19872 } else {
19873 data_aligned = (u_int8_t *)data_unaligned;
19874 }
19875
19876 /* memset and copy content from data to data aligned */
19877 OS_MEMSET(data_aligned, 0, data_len);
19878 OS_MEMCPY(data_aligned, data, data_len);
19879 /* Endianness to LE */
19880 for (c = 0; c < data_len/4; c++) {
19881 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019882 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019883 }
19884
19885 /* Copy content to event->data */
19886 OS_MEMCPY(data, data_aligned, data_len);
19887
19888 /* clean up allocated space */
19889 qdf_mem_free(data_unaligned);
19890 data_aligned = NULL;
19891 data_unaligned = NULL;
19892
19893 /*************************************************************/
19894
19895 return QDF_STATUS_SUCCESS;
19896}
19897#else
19898/**
19899 * fips_conv_data_be() - DUMMY for LE platform
19900 *
19901 * Return: QDF_STATUS - success
19902 */
19903static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19904{
19905 return QDF_STATUS_SUCCESS;
19906}
19907#endif
19908
19909/**
19910 * extract_fips_event_data_tlv() - extract fips event data
19911 * @wmi_handle: wmi handle
19912 * @param evt_buf: pointer to event buffer
19913 * @param param: pointer FIPS event params
19914 *
19915 * Return: 0 for success or error code
19916 */
19917static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
19918 void *evt_buf, struct wmi_host_fips_event_param *param)
19919{
19920 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
19921 wmi_pdev_fips_event_fixed_param *event;
19922
19923 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
19924 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
19925
19926 if (fips_conv_data_be(event->data_len, param_buf->data) !=
19927 QDF_STATUS_SUCCESS)
19928 return QDF_STATUS_E_FAILURE;
19929
19930 param->data = (uint32_t *)param_buf->data;
19931 param->data_len = event->data_len;
19932 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019933 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19934 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019935
19936 return QDF_STATUS_SUCCESS;
19937}
19938
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019939/*
19940 * extract_peer_delete_response_event_tlv() - extract peer delete response event
19941 * @wmi_handle: wmi handle
19942 * @param evt_buf: pointer to event buffer
19943 * @param vdev_id: Pointer to hold vdev_id
19944 * @param mac_addr: Pointer to hold peer mac address
19945 *
19946 * Return: QDF_STATUS_SUCCESS for success or error code
19947 */
19948static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
19949 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
19950{
19951 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
19952 wmi_peer_delete_resp_event_fixed_param *ev;
19953
19954 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
19955
19956 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
19957 if (!ev) {
19958 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
19959 return QDF_STATUS_E_FAILURE;
19960 }
19961
19962 param->vdev_id = ev->vdev_id;
19963 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
19964 &param->mac_address.bytes[0]);
19965
19966 return QDF_STATUS_SUCCESS;
19967}
19968
Govind Singhecf03cd2016-05-12 12:45:51 +053019969static bool is_management_record_tlv(uint32_t cmd_id)
19970{
jiad36c94d22018-01-22 15:37:03 +080019971 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
19972 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
19973 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053019974 return true;
jiad36c94d22018-01-22 15:37:03 +080019975 }
Govind Singhe7f2f342016-05-23 12:12:52 +053019976
Govind Singhecf03cd2016-05-12 12:45:51 +053019977 return false;
19978}
19979
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053019980static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19981{
19982 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
19983
19984 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
19985
19986 switch (set_cmd->param_id) {
19987 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
19988 case WMI_VDEV_PARAM_DTIM_POLICY:
19989 return HTC_TX_PACKET_TAG_AUTO_PM;
19990 default:
19991 break;
19992 }
19993
19994 return 0;
19995}
19996
19997static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19998{
19999 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
20000
20001 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20002
20003 switch (ps_cmd->param) {
20004 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20005 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20006 case WMI_STA_PS_ENABLE_QPOWER:
20007 return HTC_TX_PACKET_TAG_AUTO_PM;
20008 default:
20009 break;
20010 }
20011
20012 return 0;
20013}
20014
20015static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20016 uint32_t cmd_id)
20017{
20018 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20019 return 0;
20020
20021 switch (cmd_id) {
20022 case WMI_VDEV_SET_PARAM_CMDID:
20023 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20024 case WMI_STA_POWERSAVE_PARAM_CMDID:
20025 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20026 default:
20027 break;
20028 }
20029
20030 return 0;
20031}
20032
20033static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20034{
20035 uint16_t tag = 0;
20036
20037 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20038 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20039 __func__);
20040 return tag;
20041 }
20042
20043 if (wmi_handle->tag_crash_inject)
20044 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20045
20046 wmi_handle->tag_crash_inject = false;
20047 return tag;
20048}
20049
20050/**
20051 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20052 * @wmi_handle: WMI handle
20053 * @buf: WMI buffer
20054 * @cmd_id: WMI command Id
20055 *
20056 * Return htc_tx_tag
20057 */
20058static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20059 wmi_buf_t buf,
20060 uint32_t cmd_id)
20061{
20062 uint16_t htc_tx_tag = 0;
20063
20064 switch (cmd_id) {
20065 case WMI_WOW_ENABLE_CMDID:
20066 case WMI_PDEV_SUSPEND_CMDID:
20067 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20068 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20069 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20070 case WMI_PDEV_RESUME_CMDID:
20071 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20072 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20073#ifdef FEATURE_WLAN_D0WOW
20074 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20075#endif
20076 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20077 break;
20078 case WMI_FORCE_FW_HANG_CMDID:
20079 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20080 break;
20081 case WMI_VDEV_SET_PARAM_CMDID:
20082 case WMI_STA_POWERSAVE_PARAM_CMDID:
20083 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20084 default:
20085 break;
20086 }
20087
20088 return htc_tx_tag;
20089}
20090
Sathish Kumard3ab1002017-02-07 17:10:59 +053020091/**
20092 * extract_channel_hopping_event_tlv() - extract channel hopping param
20093 * from event
20094 * @wmi_handle: wmi handle
20095 * @param evt_buf: pointer to event buffer
20096 * @param ch_hopping: Pointer to hold channel hopping param
20097 *
20098 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20099 */
20100static QDF_STATUS extract_channel_hopping_event_tlv(
20101 wmi_unified_t wmi_handle, void *evt_buf,
20102 wmi_host_pdev_channel_hopping_event *ch_hopping)
20103{
20104 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20105 wmi_pdev_channel_hopping_event_fixed_param *event;
20106
20107 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20108 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20109 param_buf->fixed_param;
20110
20111 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20112 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020113 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20114 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020115
20116 return QDF_STATUS_SUCCESS;
20117}
20118
20119/**
20120 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20121 * @wmi_handle: wmi handle
20122 * @param evt_buf: pointer to event buffer
20123 * @param param: Pointer to hold tpc param
20124 *
20125 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20126 */
20127static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20128 void *evt_buf,
20129 wmi_host_pdev_tpc_event *param)
20130{
20131 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20132 wmi_pdev_tpc_event_fixed_param *event;
20133
20134 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20135 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20136
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020137 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20138 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020139 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20140
20141 return QDF_STATUS_SUCCESS;
20142}
20143
nobeljf74583b2018-01-25 16:35:36 -080020144/**
20145 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20146 * power param from event
20147 * @wmi_handle: wmi handle
20148 * @param evt_buf: pointer to event buffer
20149 * @param param: Pointer to hold nf cal power param
20150 *
20151 * Return: 0 for success or error code
20152 */
20153static QDF_STATUS
20154extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20155 void *evt_buf,
20156 wmi_host_pdev_nfcal_power_all_channels_event *param)
20157{
20158 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20159 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20160 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20161 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20162 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20163 uint32_t i;
20164
20165 param_buf =
20166 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20167 event = param_buf->fixed_param;
20168 ch_nfdbr = param_buf->nfdbr;
20169 ch_nfdbm = param_buf->nfdbm;
20170 ch_freqnum = param_buf->freqnum;
20171
20172 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20173 event->pdev_id, param_buf->num_nfdbr,
20174 param_buf->num_nfdbm, param_buf->num_freqnum);
20175
20176 if (param_buf->num_nfdbr >
20177 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20178 WMI_LOGE("invalid number of nfdBr");
20179 return QDF_STATUS_E_FAILURE;
20180 }
20181
20182 if (param_buf->num_nfdbm >
20183 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20184 WMI_LOGE("invalid number of nfdBm");
20185 return QDF_STATUS_E_FAILURE;
20186 }
20187
20188 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20189 WMI_LOGE("invalid number of freqNum");
20190 return QDF_STATUS_E_FAILURE;
20191 }
20192
20193 for (i = 0; i < param_buf->num_nfdbr; i++) {
20194 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20195 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20196 ch_nfdbr++;
20197 ch_nfdbm++;
20198 }
20199
20200 for (i = 0; i < param_buf->num_freqnum; i++) {
20201 param->freqnum[i] = ch_freqnum->freqNum;
20202 ch_freqnum++;
20203 }
20204
Keyur Parekh2c0bab62018-05-16 13:15:38 -070020205 param->pdev_id = wmi_handle->ops->
20206 convert_pdev_id_target_to_host(event->pdev_id);
nobeljf74583b2018-01-25 16:35:36 -080020207
20208 return QDF_STATUS_SUCCESS;
20209}
20210
Sathish Kumard3ab1002017-02-07 17:10:59 +053020211
20212#ifdef BIG_ENDIAN_HOST
20213/**
20214 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20215 * @param data_len - data length
20216 * @param data - pointer to data
20217 *
20218 * Return: QDF_STATUS - success or error status
20219 */
20220static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20221{
20222 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020223 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020224 /* Skip swapping the first word */
20225 datap += sizeof(uint32_t);
20226 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20227 i++, datap += sizeof(uint32_t)) {
20228 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20229 }
20230
20231 return QDF_STATUS_SUCCESS;
20232}
20233#else
20234/**
20235 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20236 * @param data_len - data length
20237 * @param data - pointer to data
20238 *
20239 * Return: QDF_STATUS - success or error status
20240 */
20241static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20242{
20243 return QDF_STATUS_SUCCESS;
20244}
20245#endif
20246
20247/**
20248 * extract_wds_addr_event_tlv() - extract wds address from event
20249 * @wmi_handle: wmi handle
20250 * @param evt_buf: pointer to event buffer
20251 * @param wds_ev: Pointer to hold wds address
20252 *
20253 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20254 */
20255static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20256 void *evt_buf,
20257 uint16_t len, wds_addr_event_t *wds_ev)
20258{
20259 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20260 wmi_wds_addr_event_fixed_param *ev;
20261 int i;
20262
20263 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20264 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20265
20266 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20267 return QDF_STATUS_E_FAILURE;
20268
20269 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20270 sizeof(wds_ev->event_type));
20271 for (i = 0; i < 4; i++) {
20272 wds_ev->peer_mac[i] =
20273 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20274 wds_ev->dest_mac[i] =
20275 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20276 }
20277 for (i = 0; i < 2; i++) {
20278 wds_ev->peer_mac[4+i] =
20279 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20280 wds_ev->dest_mac[4+i] =
20281 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20282 }
20283 return QDF_STATUS_SUCCESS;
20284}
20285
20286/**
20287 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20288 * from event
20289 * @wmi_handle: wmi handle
20290 * @param evt_buf: pointer to event buffer
20291 * @param ev: Pointer to hold peer param and ps state
20292 *
20293 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20294 */
20295static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20296 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20297{
20298 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20299 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20300
20301 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20302 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20303 param_buf->fixed_param;
20304
20305 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20306 ev->peer_ps_state = event->peer_ps_state;
20307
20308 return QDF_STATUS_SUCCESS;
20309}
20310
20311/**
20312 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20313 * @wmi_handle: wmi handle
20314 * @param evt_buf: pointer to event buffer
20315 * @param inst_rssi_resp: Pointer to hold inst rssi response
20316 *
20317 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20318 */
20319static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20320 wmi_unified_t wmi_handle, void *evt_buf,
20321 wmi_host_inst_stats_resp *inst_rssi_resp)
20322{
20323 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20324 wmi_inst_rssi_stats_resp_fixed_param *event;
20325
20326 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20327 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20328
20329 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20330 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20331 inst_rssi_resp->iRSSI = event->iRSSI;
20332
20333 return QDF_STATUS_SUCCESS;
20334}
20335
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020336static struct cur_reg_rule
20337*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20338 wmi_regulatory_rule_struct *wmi_reg_rule)
20339{
20340 struct cur_reg_rule *reg_rule_ptr;
20341 uint32_t count;
20342
20343 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20344
20345 if (NULL == reg_rule_ptr) {
20346 WMI_LOGE("memory allocation failure");
20347 return NULL;
20348 }
20349
20350 for (count = 0; count < num_reg_rules; count++) {
20351 reg_rule_ptr[count].start_freq =
20352 WMI_REG_RULE_START_FREQ_GET(
20353 wmi_reg_rule[count].freq_info);
20354 reg_rule_ptr[count].end_freq =
20355 WMI_REG_RULE_END_FREQ_GET(
20356 wmi_reg_rule[count].freq_info);
20357 reg_rule_ptr[count].max_bw =
20358 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020359 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020360 reg_rule_ptr[count].reg_power =
20361 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020362 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020363 reg_rule_ptr[count].ant_gain =
20364 WMI_REG_RULE_ANTENNA_GAIN_GET(
20365 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020366 reg_rule_ptr[count].flags =
20367 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020368 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020369 }
20370
20371 return reg_rule_ptr;
20372}
20373
20374static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20375 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20376 struct cur_regulatory_info *reg_info, uint32_t len)
20377{
20378 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20379 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20380 wmi_regulatory_rule_struct *wmi_reg_rule;
20381 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20382
20383 WMI_LOGD("processing regulatory channel list");
20384
20385 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20386 if (!param_buf) {
20387 WMI_LOGE("invalid channel list event buf");
20388 return QDF_STATUS_E_FAILURE;
20389 }
20390
20391 chan_list_event_hdr = param_buf->fixed_param;
20392
20393 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20394 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20395 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020396 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020397 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20398 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020399 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020400 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020401 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020402 reg_info->ctry_code = chan_list_event_hdr->country_id;
20403 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20404 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20405 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20406 else if (chan_list_event_hdr->status_code ==
20407 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20408 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20409 else if (chan_list_event_hdr->status_code ==
20410 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20411 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20412 else if (chan_list_event_hdr->status_code ==
20413 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20414 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20415 else if (chan_list_event_hdr->status_code ==
20416 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20417 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20418 else if (chan_list_event_hdr->status_code ==
20419 WMI_REG_SET_CC_STATUS_FAIL)
20420 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20421
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020422 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20423 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20424 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20425 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20426
20427 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20428 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20429
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020430 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20431 __func__, reg_info->alpha2, reg_info->dfs_region,
20432 reg_info->min_bw_2g, reg_info->max_bw_2g,
20433 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020434
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020435 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20436 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020437 wmi_reg_rule =
20438 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20439 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20440 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020441 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20442 wmi_reg_rule);
20443 wmi_reg_rule += num_2g_reg_rules;
20444
20445 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20446 wmi_reg_rule);
20447
20448 WMI_LOGD("processed regulatory channel list");
20449
20450 return QDF_STATUS_SUCCESS;
20451}
20452
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020453static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20454 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20455 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20456{
20457 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20458 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20459
20460 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20461 if (!param_buf) {
20462 WMI_LOGE("invalid 11d country event buf");
20463 return QDF_STATUS_E_FAILURE;
20464 }
20465
20466 reg_11d_country_event = param_buf->fixed_param;
20467
20468 qdf_mem_copy(reg_11d_country->alpha2,
20469 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20470
20471 WMI_LOGD("processed 11d country event, new cc %s",
20472 reg_11d_country->alpha2);
20473
20474 return QDF_STATUS_SUCCESS;
20475}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020476
20477static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20478 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20479 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20480{
20481 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20482 wmi_avoid_freq_range_desc *afr_desc;
20483 uint32_t num_freq_ranges, freq_range_idx;
20484 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20485 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20486
20487 if (!param_buf) {
20488 WMI_LOGE("Invalid channel avoid event buffer");
20489 return QDF_STATUS_E_INVAL;
20490 }
20491
20492 afr_fixed_param = param_buf->fixed_param;
20493 if (!afr_fixed_param) {
20494 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20495 return QDF_STATUS_E_INVAL;
20496 }
20497
20498 if (!ch_avoid_ind) {
20499 WMI_LOGE("Invalid channel avoid indication buffer");
20500 return QDF_STATUS_E_INVAL;
20501 }
20502 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20503 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20504 afr_fixed_param->num_freq_ranges;
20505
20506 WMI_LOGD("Channel avoid event received with %d ranges",
20507 num_freq_ranges);
20508
20509 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20510 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20511 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20512 freq_range_idx++) {
20513 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20514 afr_desc->start_freq;
20515 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20516 afr_desc->end_freq;
20517 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20518 freq_range_idx, afr_desc->tlv_header,
20519 afr_desc->start_freq, afr_desc->end_freq);
20520 afr_desc++;
20521 }
20522
20523 return QDF_STATUS_SUCCESS;
20524}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020525#ifdef DFS_COMPONENT_ENABLE
20526/**
20527 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20528 * @wmi_handle: wma handle
20529 * @evt_buf: event buffer
20530 * @vdev_id: vdev id
20531 * @len: length of buffer
20532 *
20533 * Return: 0 for success or error code
20534 */
20535static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20536 uint8_t *evt_buf,
20537 uint32_t *vdev_id,
20538 uint32_t len)
20539{
20540 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20541 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20542
20543 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20544 if (!param_tlvs) {
20545 WMI_LOGE("invalid cac complete event buf");
20546 return QDF_STATUS_E_FAILURE;
20547 }
20548
20549 cac_event = param_tlvs->fixed_param;
20550 *vdev_id = cac_event->vdev_id;
20551 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20552
20553 return QDF_STATUS_SUCCESS;
20554}
20555
20556/**
20557 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20558 * @wmi_handle: wma handle
20559 * @evt_buf: event buffer
20560 * @radar_found: radar found event info
20561 * @len: length of buffer
20562 *
20563 * Return: 0 for success or error code
20564 */
20565static QDF_STATUS extract_dfs_radar_detection_event_tlv(
20566 wmi_unified_t wmi_handle,
20567 uint8_t *evt_buf,
20568 struct radar_found_info *radar_found,
20569 uint32_t len)
20570{
20571 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
20572 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
20573
20574 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
20575 if (!param_tlv) {
20576 WMI_LOGE("invalid radar detection event buf");
20577 return QDF_STATUS_E_FAILURE;
20578 }
20579
20580 radar_event = param_tlv->fixed_param;
Arif Hussainb522ac92018-06-27 10:51:06 -070020581 radar_found->pdev_id = convert_target_pdev_id_to_host_pdev_id(
20582 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020583 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020584 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020585 radar_found->chan_width = radar_event->chan_width;
20586 radar_found->detector_id = radar_event->detector_id;
20587 radar_found->segment_id = radar_event->segment_id;
20588 radar_found->timestamp = radar_event->timestamp;
20589 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020590 radar_found->freq_offset = radar_event->freq_offset;
20591 radar_found->sidx = radar_event->sidx;
20592
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020593 WMI_LOGI("processed radar found event pdev %d,"
20594 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
20595 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
20596 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
20597 "is_chirp %d,detection mode %d\n",
Arif Hussainb522ac92018-06-27 10:51:06 -070020598 radar_event->pdev_id, radar_found->pdev_id,
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020599 radar_event->timestamp, radar_event->chan_freq,
20600 radar_event->chan_width, radar_event->detector_id,
20601 radar_event->freq_offset, radar_event->segment_id,
20602 radar_event->sidx, radar_event->is_chirp,
20603 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020604
20605 return QDF_STATUS_SUCCESS;
20606}
bings1ea12532017-12-18 16:56:53 +080020607
20608#ifdef QCA_MCL_DFS_SUPPORT
20609/**
20610 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
20611 * @wmi_handle: wma handle
20612 * @evt_buf: event buffer
20613 * @wlan_radar_event: Pointer to struct radar_event_info
20614 * @len: length of buffer
20615 *
20616 * Return: QDF_STATUS
20617 */
20618static QDF_STATUS extract_wlan_radar_event_info_tlv(
20619 wmi_unified_t wmi_handle,
20620 uint8_t *evt_buf,
20621 struct radar_event_info *wlan_radar_event,
20622 uint32_t len)
20623{
20624 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
20625 wmi_dfs_radar_event_fixed_param *radar_event;
20626
20627 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
20628 if (!param_tlv) {
20629 WMI_LOGE("invalid wlan radar event buf");
20630 return QDF_STATUS_E_FAILURE;
20631 }
20632
20633 radar_event = param_tlv->fixed_param;
20634 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
20635 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
20636 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
20637 wlan_radar_event->rssi = radar_event->rssi;
20638 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
20639 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
20640 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
20641 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080020642 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
20643 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +080020644 if (radar_event->pulse_flags &
20645 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
20646 wlan_radar_event->is_psidx_diff_valid = true;
20647 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
20648 } else {
20649 wlan_radar_event->is_psidx_diff_valid = false;
20650 }
20651
bings1ea12532017-12-18 16:56:53 +080020652 wlan_radar_event->pdev_id = radar_event->pdev_id;
20653
20654 return QDF_STATUS_SUCCESS;
20655}
20656#else
20657static QDF_STATUS extract_wlan_radar_event_info_tlv(
20658 wmi_unified_t wmi_handle,
20659 uint8_t *evt_buf,
20660 struct radar_event_info *wlan_radar_event,
20661 uint32_t len)
20662{
20663 return QDF_STATUS_SUCCESS;
20664}
20665#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020666#endif
20667
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020668/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020669 * send_get_rcpi_cmd_tlv() - send request for rcpi value
20670 * @wmi_handle: wmi handle
20671 * @get_rcpi_param: rcpi params
20672 *
20673 * Return: QDF status
20674 */
20675static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
20676 struct rcpi_req *get_rcpi_param)
20677{
20678 wmi_buf_t buf;
20679 wmi_request_rcpi_cmd_fixed_param *cmd;
20680 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
20681
20682 buf = wmi_buf_alloc(wmi_handle, len);
20683 if (!buf) {
20684 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
20685 return QDF_STATUS_E_NOMEM;
20686 }
20687
20688 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
20689 WMITLV_SET_HDR(&cmd->tlv_header,
20690 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
20691 WMITLV_GET_STRUCT_TLVLEN
20692 (wmi_request_rcpi_cmd_fixed_param));
20693
20694 cmd->vdev_id = get_rcpi_param->vdev_id;
20695 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
20696 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070020697
20698 switch (get_rcpi_param->measurement_type) {
20699
20700 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20701 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20702 break;
20703
20704 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
20705 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
20706 break;
20707
20708 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20709 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20710 break;
20711
20712 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
20713 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
20714 break;
20715
20716 default:
20717 /*
20718 * invalid rcpi measurement type, fall back to
20719 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
20720 */
20721 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20722 break;
20723 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020724 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
20725 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20726 WMI_REQUEST_RCPI_CMDID)) {
20727
20728 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
20729 __func__);
20730 wmi_buf_free(buf);
20731 return QDF_STATUS_E_FAILURE;
20732 }
20733
20734 return QDF_STATUS_SUCCESS;
20735}
20736
20737/**
20738 * extract_rcpi_response_event_tlv() - Extract RCPI event params
20739 * @wmi_handle: wmi handle
20740 * @evt_buf: pointer to event buffer
20741 * @res: pointer to hold rcpi response from firmware
20742 *
20743 * Return: QDF_STATUS_SUCCESS for successful event parse
20744 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
20745 */
20746static QDF_STATUS
20747extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
20748 void *evt_buf, struct rcpi_res *res)
20749{
20750 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
20751 wmi_update_rcpi_event_fixed_param *event;
20752
20753 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
20754 if (!param_buf) {
20755 WMI_LOGE(FL("Invalid rcpi event"));
20756 return QDF_STATUS_E_INVAL;
20757 }
20758
20759 event = param_buf->fixed_param;
20760 res->vdev_id = event->vdev_id;
20761 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
20762
20763 switch (event->measurement_type) {
20764
20765 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20766 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20767 break;
20768
20769 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
20770 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
20771 break;
20772
20773 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20774 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20775 break;
20776
20777 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
20778 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
20779 break;
20780
20781 default:
20782 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
20783 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
20784 return QDF_STATUS_E_FAILURE;
20785 }
20786
20787 if (event->status)
20788 return QDF_STATUS_E_FAILURE;
20789 else
20790 return QDF_STATUS_SUCCESS;
20791}
20792
20793/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020794 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
20795 * host to target defines. For legacy there is not conversion
20796 * required. Just return pdev_id as it is.
20797 * @param pdev_id: host pdev_id to be converted.
20798 * Return: target pdev_id after conversion.
20799 */
20800static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
20801 uint32_t pdev_id)
20802{
20803 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
20804 return WMI_PDEV_ID_SOC;
20805
20806 /*No conversion required*/
20807 return pdev_id;
20808}
20809
20810/**
20811 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
20812 * target to host defines. For legacy there is not conversion
20813 * required. Just return pdev_id as it is.
20814 * @param pdev_id: target pdev_id to be converted.
20815 * Return: host pdev_id after conversion.
20816 */
20817static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
20818 uint32_t pdev_id)
20819{
20820 /*No conversion required*/
20821 return pdev_id;
20822}
20823
20824/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020825 * send_set_country_cmd_tlv() - WMI scan channel list function
20826 * @param wmi_handle : handle to WMI.
20827 * @param param : pointer to hold scan channel list parameter
20828 *
20829 * Return: 0 on success and -ve on failure.
20830 */
20831static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
20832 struct set_country *params)
20833{
20834 wmi_buf_t buf;
20835 QDF_STATUS qdf_status;
20836 wmi_set_current_country_cmd_fixed_param *cmd;
20837 uint16_t len = sizeof(*cmd);
20838
20839 buf = wmi_buf_alloc(wmi_handle, len);
20840 if (!buf) {
20841 WMI_LOGE("Failed to allocate memory");
20842 qdf_status = QDF_STATUS_E_NOMEM;
20843 goto end;
20844 }
20845
20846 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
20847 WMITLV_SET_HDR(&cmd->tlv_header,
20848 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
20849 WMITLV_GET_STRUCT_TLVLEN
20850 (wmi_set_current_country_cmd_fixed_param));
20851
20852 WMI_LOGD("setting cuurnet country to %s", params->country);
20853
20854 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
20855
20856 cmd->pdev_id = params->pdev_id;
20857
20858 qdf_status = wmi_unified_cmd_send(wmi_handle,
20859 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
20860
20861 if (QDF_IS_STATUS_ERROR(qdf_status)) {
20862 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
20863 wmi_buf_free(buf);
20864 }
20865
20866end:
20867 return qdf_status;
20868}
20869
Abhijit Pradhand38a2692017-06-29 12:32:20 +053020870#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
20871 WMI_SET_BITS(alpha, 0, 8, val0); \
20872 WMI_SET_BITS(alpha, 8, 8, val1); \
20873 WMI_SET_BITS(alpha, 16, 8, val2); \
20874 } while (0)
20875
20876static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
20877 uint8_t pdev_id, struct cc_regdmn_s *rd)
20878{
20879 wmi_set_init_country_cmd_fixed_param *cmd;
20880 uint16_t len;
20881 wmi_buf_t buf;
20882 int ret;
20883
20884 len = sizeof(wmi_set_init_country_cmd_fixed_param);
20885 buf = wmi_buf_alloc(wmi_handle, len);
20886 if (!buf) {
20887 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
20888 return QDF_STATUS_E_NOMEM;
20889 }
20890 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
20891 WMITLV_SET_HDR(&cmd->tlv_header,
20892 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
20893 WMITLV_GET_STRUCT_TLVLEN
20894 (wmi_set_init_country_cmd_fixed_param));
20895
20896 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
20897
20898 if (rd->flags == CC_IS_SET) {
20899 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
20900 cmd->country_code.country_id = rd->cc.country_code;
20901 } else if (rd->flags == ALPHA_IS_SET) {
20902 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
20903 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
20904 rd->cc.alpha[0],
20905 rd->cc.alpha[1],
20906 rd->cc.alpha[2]);
20907 } else if (rd->flags == REGDMN_IS_SET) {
20908 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
20909 cmd->country_code.domain_code = rd->cc.regdmn_id;
20910 }
20911
20912 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
20913 WMI_SET_INIT_COUNTRY_CMDID);
20914 if (ret) {
20915 WMI_LOGE("Failed to config wow wakeup event");
20916 wmi_buf_free(buf);
20917 return QDF_STATUS_E_FAILURE;
20918 }
20919
20920 return QDF_STATUS_SUCCESS;
20921}
20922
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053020923/**
20924 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
20925 * configuration params
20926 * @wmi_handle: wmi handler
20927 * @limit_off_chan_param: pointer to wmi_off_chan_param
20928 *
20929 * Return: 0 for success and non zero for failure
20930 */
20931static
20932QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
20933 struct wmi_limit_off_chan_param *limit_off_chan_param)
20934{
20935 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
20936 wmi_buf_t buf;
20937 uint32_t len = sizeof(*cmd);
20938 int err;
20939
20940 buf = wmi_buf_alloc(wmi_handle, len);
20941 if (!buf) {
20942 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
20943 __func__);
20944 return QDF_STATUS_E_NOMEM;
20945 }
20946
20947 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
20948
20949 WMITLV_SET_HDR(&cmd->tlv_header,
20950 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
20951 WMITLV_GET_STRUCT_TLVLEN(
20952 wmi_vdev_limit_offchan_cmd_fixed_param));
20953
20954 cmd->vdev_id = limit_off_chan_param->vdev_id;
20955
20956 cmd->flags &= 0;
20957 if (limit_off_chan_param->status)
20958 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
20959 if (limit_off_chan_param->skip_dfs_chans)
20960 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
20961
20962 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
20963 cmd->rest_time = limit_off_chan_param->rest_time;
20964
20965 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
20966 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
20967 cmd->rest_time);
20968
20969 err = wmi_unified_cmd_send(wmi_handle, buf,
20970 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
20971 if (QDF_IS_STATUS_ERROR(err)) {
20972 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
20973 wmi_buf_free(buf);
20974 return QDF_STATUS_E_FAILURE;
20975 }
20976
20977 return QDF_STATUS_SUCCESS;
20978}
20979
Anurag Chouhan97f00422017-09-11 14:56:30 +053020980/**
20981 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
20982 * @wmi_handle: wmi handler
20983 * @req_buf: set arp stats request buffer
20984 *
20985 * Return: 0 for success and non zero for failure
20986 */
20987static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20988 struct set_arp_stats *req_buf)
20989{
20990 wmi_buf_t buf = NULL;
20991 QDF_STATUS status;
20992 int len;
20993 uint8_t *buf_ptr;
20994 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
20995
20996 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020997 if (req_buf->pkt_type_bitmap) {
20998 len += WMI_TLV_HDR_SIZE;
20999 len += sizeof(wmi_vdev_set_connectivity_check_stats);
21000 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053021001 buf = wmi_buf_alloc(wmi_handle, len);
21002 if (!buf) {
21003 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21004 return QDF_STATUS_E_NOMEM;
21005 }
21006
21007 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21008 wmi_set_arp =
21009 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
21010 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
21011 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
21012 WMITLV_GET_STRUCT_TLVLEN
21013 (wmi_vdev_set_arp_stats_cmd_fixed_param));
21014
21015 /* fill in per roam config values */
21016 wmi_set_arp->vdev_id = req_buf->vdev_id;
21017
21018 wmi_set_arp->set_clr = req_buf->flag;
21019 wmi_set_arp->pkt_type = req_buf->pkt_type;
21020 wmi_set_arp->ipv4 = req_buf->ip_addr;
21021
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021022 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
21023 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
21024 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
21025
21026 /*
21027 * pkt_type_bitmap should be non-zero to ensure
21028 * presence of additional stats.
21029 */
21030 if (req_buf->pkt_type_bitmap) {
21031 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
21032
21033 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21034 WMITLV_SET_HDR(buf_ptr,
21035 WMITLV_TAG_ARRAY_STRUC,
21036 sizeof(wmi_vdev_set_connectivity_check_stats));
21037 buf_ptr += WMI_TLV_HDR_SIZE;
21038 wmi_set_connect_stats =
21039 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
21040 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
21041 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
21042 WMITLV_GET_STRUCT_TLVLEN(
21043 wmi_vdev_set_connectivity_check_stats));
21044 wmi_set_connect_stats->pkt_type_bitmap =
21045 req_buf->pkt_type_bitmap;
21046 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
21047 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
21048 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
21049
21050 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
21051 wmi_set_connect_stats->pkt_type_bitmap,
21052 wmi_set_connect_stats->tcp_src_port,
21053 wmi_set_connect_stats->tcp_dst_port,
21054 wmi_set_connect_stats->icmp_ipv4);
21055 }
21056
Anurag Chouhan97f00422017-09-11 14:56:30 +053021057 /* Send per roam config parameters */
21058 status = wmi_unified_cmd_send(wmi_handle, buf,
21059 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21060 if (QDF_IS_STATUS_ERROR(status)) {
21061 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21062 status);
21063 goto error;
21064 }
21065
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +053021066 WMI_LOGD(FL("set arp stats flag=%d, vdev=%d"),
Anurag Chouhan97f00422017-09-11 14:56:30 +053021067 req_buf->flag, req_buf->vdev_id);
21068 return QDF_STATUS_SUCCESS;
21069error:
21070 wmi_buf_free(buf);
21071
21072 return status;
21073}
21074
21075/**
21076 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21077 * @wmi_handle: wmi handler
21078 * @req_buf: get arp stats request buffer
21079 *
21080 * Return: 0 for success and non zero for failure
21081 */
21082static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21083 struct get_arp_stats *req_buf)
21084{
21085 wmi_buf_t buf = NULL;
21086 QDF_STATUS status;
21087 int len;
21088 uint8_t *buf_ptr;
21089 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21090
21091 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21092 buf = wmi_buf_alloc(wmi_handle, len);
21093 if (!buf) {
21094 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21095 return QDF_STATUS_E_NOMEM;
21096 }
21097
21098 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21099 get_arp_stats =
21100 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21101 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21102 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21103 WMITLV_GET_STRUCT_TLVLEN
21104 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21105
21106 /* fill in arp stats req cmd values */
21107 get_arp_stats->vdev_id = req_buf->vdev_id;
21108
21109 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21110 /* Send per roam config parameters */
21111 status = wmi_unified_cmd_send(wmi_handle, buf,
21112 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21113 if (QDF_IS_STATUS_ERROR(status)) {
21114 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21115 status);
21116 goto error;
21117 }
21118
21119 return QDF_STATUS_SUCCESS;
21120error:
21121 wmi_buf_free(buf);
21122
21123 return status;
21124}
21125
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021126/**
21127 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21128 * @wmi_handle: wmi handler
21129 * @pmk_info: pointer to PMK cache entry
21130 * @vdev_id: vdev id
21131 *
21132 * Return: 0 for success and non zero for failure
21133 */
21134static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21135 struct wmi_unified_pmk_cache *pmk_info)
21136{
21137 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21138 wmi_buf_t buf;
21139 QDF_STATUS status;
21140 uint8_t *buf_ptr;
21141 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021142 uint32_t len = sizeof(*cmd);
21143
21144 if (pmk_info->pmk_len)
21145 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021146
21147 buf = wmi_buf_alloc(wmi_handle, len);
21148 if (!buf) {
21149 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21150 __func__);
21151 return QDF_STATUS_E_NOMEM;
21152 }
21153
21154 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21155 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21156
21157 WMITLV_SET_HDR(&cmd->tlv_header,
21158 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21159 WMITLV_GET_STRUCT_TLVLEN(
21160 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21161
21162 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021163
21164 /* If pmk_info->pmk_len is 0, this is a flush request */
21165 if (!pmk_info->pmk_len) {
21166 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21167 cmd->num_cache = 0;
21168 goto send_cmd;
21169 }
21170
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021171 cmd->num_cache = 1;
21172 buf_ptr += sizeof(*cmd);
21173
21174 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21175 sizeof(*pmksa));
21176 buf_ptr += WMI_TLV_HDR_SIZE;
21177
21178 pmksa = (wmi_pmk_cache *)buf_ptr;
21179 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21180 WMITLV_GET_STRUCT_TLVLEN
21181 (wmi_pmk_cache));
21182 pmksa->pmk_len = pmk_info->pmk_len;
21183 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21184 pmksa->pmkid_len = pmk_info->pmkid_len;
21185 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21186 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21187 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21188 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21189 pmksa->ssid.ssid_len);
21190 pmksa->cache_id = pmk_info->cache_id;
21191 pmksa->cat_flag = pmk_info->cat_flag;
21192 pmksa->action_flag = pmk_info->action_flag;
21193
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021194send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021195 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21196 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21197 if (status != QDF_STATUS_SUCCESS) {
21198 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21199 __func__, status);
21200 wmi_buf_free(buf);
21201 }
21202
21203 return status;
21204}
21205
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021206/**
21207 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21208 * @wmi_handle: wmi handle
21209 * @param: reserved param
21210 *
21211 * Return: 0 for success or error code
21212 */
21213static QDF_STATUS
21214send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21215 uint32_t param)
21216{
21217 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21218 wmi_buf_t buf;
21219 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21220
21221 buf = wmi_buf_alloc(wmi_handle, len);
21222 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053021223 qdf_print("%s:wmi_buf_alloc failed", __func__);
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021224 return QDF_STATUS_E_FAILURE;
21225 }
21226 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21227 WMITLV_SET_HDR(&cmd->tlv_header,
21228 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21229 WMITLV_GET_STRUCT_TLVLEN
21230 (wmi_pdev_check_cal_version_cmd_fixed_param));
21231 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21232 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21233 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21234 wmi_buf_free(buf);
21235 return QDF_STATUS_E_FAILURE;
21236 }
21237
21238 return QDF_STATUS_SUCCESS;
21239}
21240
21241/**
21242 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21243 * @wmi_handle: wmi handle
21244 * @param evt_buf: pointer to event buffer
21245 * @param param: Pointer to hold peer caldata version data
21246 *
21247 * Return: 0 for success or error code
21248 */
21249static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21250 wmi_unified_t wmi_handle,
21251 void *evt_buf,
21252 wmi_host_pdev_check_cal_version_event *param)
21253{
21254 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21255 wmi_pdev_check_cal_version_event_fixed_param *event;
21256
21257 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21258 if (!param_tlvs) {
21259 WMI_LOGE("invalid cal version event buf");
21260 return QDF_STATUS_E_FAILURE;
21261 }
21262 event = param_tlvs->fixed_param;
21263 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21264 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21265 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21266 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21267
21268 param->software_cal_version = event->software_cal_version;
21269 param->board_cal_version = event->board_cal_version;
21270 param->cal_ok = event->cal_status;
21271
21272 return QDF_STATUS_SUCCESS;
21273}
21274
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021275/*
21276 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21277 * @wmi_handle: wmi handle
21278 * @params: pointer to wmi_btm_config
21279 *
21280 * Return: QDF_STATUS
21281 */
21282static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21283 struct wmi_btm_config *params)
21284{
21285
21286 wmi_btm_config_fixed_param *cmd;
21287 wmi_buf_t buf;
21288 uint32_t len;
21289
21290 len = sizeof(*cmd);
21291 buf = wmi_buf_alloc(wmi_handle, len);
21292 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053021293 qdf_print("%s:wmi_buf_alloc failed", __func__);
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021294 return QDF_STATUS_E_NOMEM;
21295 }
21296
21297 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21298 WMITLV_SET_HDR(&cmd->tlv_header,
21299 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21300 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21301 cmd->vdev_id = params->vdev_id;
21302 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021303 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21304 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21305 cmd->stick_time_seconds = params->btm_sticky_time;
21306
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021307 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21308 WMI_ROAM_BTM_CONFIG_CMDID)) {
21309 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21310 __func__);
21311 wmi_buf_free(buf);
21312 return QDF_STATUS_E_FAILURE;
21313 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021314
21315 return QDF_STATUS_SUCCESS;
21316}
21317
21318/**
21319 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21320 * configurations to firmware.
21321 * @wmi_handle: wmi handle
21322 * @obss_cfg_param: obss detection configurations
21323 *
21324 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21325 *
21326 * Return: QDF_STATUS
21327 */
21328static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21329 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21330{
21331 wmi_buf_t buf;
21332 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21333 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21334
21335 buf = wmi_buf_alloc(wmi_handle, len);
21336 if (!buf) {
21337 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21338 return QDF_STATUS_E_NOMEM;
21339 }
21340
21341 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21342 WMITLV_SET_HDR(&cmd->tlv_header,
21343 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21344 WMITLV_GET_STRUCT_TLVLEN
21345 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21346
21347 cmd->vdev_id = obss_cfg_param->vdev_id;
21348 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21349 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21350 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21351 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21352 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21353 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21354 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21355 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021356
21357 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21358 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21359 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21360 wmi_buf_free(buf);
21361 return QDF_STATUS_E_FAILURE;
21362 }
21363
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021364 return QDF_STATUS_SUCCESS;
21365}
21366
Arif Hussain33d98502018-01-12 13:15:04 -080021367/**
21368 * extract_obss_detection_info_tlv() - Extract obss detection info
21369 * received from firmware.
21370 * @evt_buf: pointer to event buffer
21371 * @obss_detection: Pointer to hold obss detection info
21372 *
21373 * Return: QDF_STATUS
21374 */
21375static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21376 struct wmi_obss_detect_info
21377 *obss_detection)
21378{
21379 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21380 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21381
21382 if (!obss_detection) {
21383 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21384 return QDF_STATUS_E_INVAL;
21385 }
21386
21387 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21388 if (!param_buf) {
21389 WMI_LOGE("%s: Invalid evt_buf", __func__);
21390 return QDF_STATUS_E_INVAL;
21391 }
21392
21393 fix_param = param_buf->fixed_param;
21394 obss_detection->vdev_id = fix_param->vdev_id;
21395 obss_detection->matched_detection_masks =
21396 fix_param->matched_detection_masks;
21397 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21398 &obss_detection->matched_bssid_addr[0]);
21399 switch (fix_param->reason) {
21400 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21401 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21402 break;
21403 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21404 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21405 break;
21406 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21407 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21408 break;
21409 default:
21410 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21411 return QDF_STATUS_E_INVAL;
21412 }
21413
21414 return QDF_STATUS_SUCCESS;
21415}
21416
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021417/**
21418 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21419 * @wmi_handle: wmi handler
21420 * @params: pointer to 11k offload params
21421 *
21422 * Return: 0 for success and non zero for failure
21423 */
21424static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21425 struct wmi_11k_offload_params *params)
21426{
21427 wmi_11k_offload_report_fixed_param *cmd;
21428 wmi_buf_t buf;
21429 QDF_STATUS status;
21430 uint8_t *buf_ptr;
21431 wmi_neighbor_report_11k_offload_tlv_param
21432 *neighbor_report_offload_params;
21433 wmi_neighbor_report_offload *neighbor_report_offload;
21434
21435 uint32_t len = sizeof(*cmd);
21436
21437 if (params->offload_11k_bitmask &
21438 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21439 len += WMI_TLV_HDR_SIZE +
21440 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21441
21442 buf = wmi_buf_alloc(wmi_handle, len);
21443 if (!buf) {
21444 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21445 __func__);
21446 return QDF_STATUS_E_NOMEM;
21447 }
21448
21449 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21450 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21451
21452 WMITLV_SET_HDR(&cmd->tlv_header,
21453 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21454 WMITLV_GET_STRUCT_TLVLEN(
21455 wmi_11k_offload_report_fixed_param));
21456
21457 cmd->vdev_id = params->vdev_id;
21458 cmd->offload_11k = params->offload_11k_bitmask;
21459
21460 if (params->offload_11k_bitmask &
21461 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21462 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21463
21464 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21465 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21466 buf_ptr += WMI_TLV_HDR_SIZE;
21467
21468 neighbor_report_offload_params =
21469 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21470 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21471 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21472 WMITLV_GET_STRUCT_TLVLEN(
21473 wmi_neighbor_report_11k_offload_tlv_param));
21474
21475 neighbor_report_offload = &neighbor_report_offload_params->
21476 neighbor_rep_ofld_params;
21477
21478 neighbor_report_offload->time_offset =
21479 params->neighbor_report_params.time_offset;
21480 neighbor_report_offload->low_rssi_offset =
21481 params->neighbor_report_params.low_rssi_offset;
21482 neighbor_report_offload->bmiss_count_trigger =
21483 params->neighbor_report_params.bmiss_count_trigger;
21484 neighbor_report_offload->per_threshold_offset =
21485 params->neighbor_report_params.per_threshold_offset;
21486 neighbor_report_offload->neighbor_report_cache_timeout =
21487 params->neighbor_report_params.
21488 neighbor_report_cache_timeout;
21489 neighbor_report_offload->max_neighbor_report_req_cap =
21490 params->neighbor_report_params.
21491 max_neighbor_report_req_cap;
21492 neighbor_report_offload->ssid.ssid_len =
21493 params->neighbor_report_params.ssid.length;
21494 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21495 &params->neighbor_report_params.ssid.mac_ssid,
21496 neighbor_report_offload->ssid.ssid_len);
21497 }
21498
21499 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21500 WMI_11K_OFFLOAD_REPORT_CMDID);
21501 if (status != QDF_STATUS_SUCCESS) {
21502 WMI_LOGE("%s: failed to send 11k offload command %d",
21503 __func__, status);
21504 wmi_buf_free(buf);
21505 }
21506
21507 return status;
21508}
21509
21510/**
21511 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
21512 * command
21513 * @wmi_handle: wmi handler
21514 * @params: pointer to neighbor report invoke params
21515 *
21516 * Return: 0 for success and non zero for failure
21517 */
21518static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
21519 struct wmi_invoke_neighbor_report_params *params)
21520{
21521 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
21522 wmi_buf_t buf;
21523 QDF_STATUS status;
21524 uint8_t *buf_ptr;
21525 uint32_t len = sizeof(*cmd);
21526
21527 buf = wmi_buf_alloc(wmi_handle, len);
21528 if (!buf) {
21529 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
21530 __func__);
21531 return QDF_STATUS_E_NOMEM;
21532 }
21533
21534 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21535 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
21536
21537 WMITLV_SET_HDR(&cmd->tlv_header,
21538 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
21539 WMITLV_GET_STRUCT_TLVLEN(
21540 wmi_11k_offload_invoke_neighbor_report_fixed_param));
21541
21542 cmd->vdev_id = params->vdev_id;
21543 cmd->flags = params->send_resp_to_host;
21544
21545 cmd->ssid.ssid_len = params->ssid.length;
21546 qdf_mem_copy(cmd->ssid.ssid,
21547 &params->ssid.mac_ssid,
21548 cmd->ssid.ssid_len);
21549
21550 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21551 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
21552 if (status != QDF_STATUS_SUCCESS) {
21553 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
21554 __func__, status);
21555 wmi_buf_free(buf);
21556 }
21557
21558 return status;
21559}
21560
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021561#ifdef WLAN_SUPPORT_GREEN_AP
21562static QDF_STATUS extract_green_ap_egap_status_info_tlv(
21563 uint8_t *evt_buf,
21564 struct wlan_green_ap_egap_status_info *egap_status_info_params)
21565{
21566 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
21567 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
21568 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
21569
21570 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
21571 if (!param_buf) {
21572 WMI_LOGE("Invalid EGAP Info status event buffer");
21573 return QDF_STATUS_E_INVAL;
21574 }
21575
21576 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
21577 param_buf->fixed_param;
21578 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
21579 param_buf->chainmask_list;
21580
21581 egap_status_info_params->status = egap_info_event->status;
21582 egap_status_info_params->mac_id = chainmask_event->mac_id;
21583 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
21584 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
21585
21586 return QDF_STATUS_SUCCESS;
21587}
21588#endif
21589
Arif Hussainec5cd3c2018-01-22 01:19:36 -080021590/*
21591 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
21592 * updating bss color change within firmware when AP announces bss color change.
21593 * @wmi_handle: wmi handle
21594 * @vdev_id: vdev ID
21595 * @enable: enable bss color change within firmware
21596 *
21597 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
21598 *
21599 * Return: QDF_STATUS
21600 */
21601static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
21602 uint32_t vdev_id,
21603 bool enable)
21604{
21605 wmi_buf_t buf;
21606 wmi_bss_color_change_enable_fixed_param *cmd;
21607 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
21608
21609 buf = wmi_buf_alloc(wmi_handle, len);
21610 if (!buf) {
21611 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21612 return QDF_STATUS_E_NOMEM;
21613 }
21614
21615 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
21616 WMITLV_SET_HDR(&cmd->tlv_header,
21617 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
21618 WMITLV_GET_STRUCT_TLVLEN
21619 (wmi_bss_color_change_enable_fixed_param));
21620 cmd->vdev_id = vdev_id;
21621 cmd->enable = enable;
21622 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21623 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
21624 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
21625 wmi_buf_free(buf);
21626 return QDF_STATUS_E_FAILURE;
21627 }
21628
21629 return QDF_STATUS_SUCCESS;
21630}
21631
21632/**
21633 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
21634 * configurations to firmware.
21635 * @wmi_handle: wmi handle
21636 * @cfg_param: obss detection configurations
21637 *
21638 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
21639 *
21640 * Return: QDF_STATUS
21641 */
21642static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
21643 wmi_unified_t wmi_handle,
21644 struct wmi_obss_color_collision_cfg_param *cfg_param)
21645{
21646 wmi_buf_t buf;
21647 wmi_obss_color_collision_det_config_fixed_param *cmd;
21648 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
21649
21650 buf = wmi_buf_alloc(wmi_handle, len);
21651 if (!buf) {
21652 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21653 return QDF_STATUS_E_NOMEM;
21654 }
21655
21656 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
21657 buf);
21658 WMITLV_SET_HDR(&cmd->tlv_header,
21659 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
21660 WMITLV_GET_STRUCT_TLVLEN
21661 (wmi_obss_color_collision_det_config_fixed_param));
21662 cmd->vdev_id = cfg_param->vdev_id;
21663 cmd->flags = cfg_param->flags;
21664 cmd->current_bss_color = cfg_param->current_bss_color;
21665 cmd->detection_period_ms = cfg_param->detection_period_ms;
21666 cmd->scan_period_ms = cfg_param->scan_period_ms;
21667 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
21668
21669 switch (cfg_param->evt_type) {
21670 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
21671 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
21672 break;
21673 case OBSS_COLOR_COLLISION_DETECTION:
21674 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
21675 break;
21676 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21677 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21678 break;
21679 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
21680 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
21681 break;
21682 default:
21683 WMI_LOGE("%s: invalid event type: %d",
21684 __func__, cfg_param->evt_type);
21685 wmi_buf_free(buf);
21686 return QDF_STATUS_E_FAILURE;
21687 }
21688
21689 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21690 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
21691 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
21692 __func__, cfg_param->vdev_id);
21693 wmi_buf_free(buf);
21694 return QDF_STATUS_E_FAILURE;
21695 }
21696
21697 return QDF_STATUS_SUCCESS;
21698}
21699
21700/**
21701 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
21702 * received from firmware.
21703 * @evt_buf: pointer to event buffer
21704 * @info: Pointer to hold bss collision info
21705 *
21706 * Return: QDF_STATUS
21707 */
21708static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
21709 struct wmi_obss_color_collision_info *info)
21710{
21711 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
21712 wmi_obss_color_collision_evt_fixed_param *fix_param;
21713
21714 if (!info) {
21715 WMI_LOGE("%s: Invalid obss color buffer", __func__);
21716 return QDF_STATUS_E_INVAL;
21717 }
21718
21719 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
21720 evt_buf;
21721 if (!param_buf) {
21722 WMI_LOGE("%s: Invalid evt_buf", __func__);
21723 return QDF_STATUS_E_INVAL;
21724 }
21725
21726 fix_param = param_buf->fixed_param;
21727 info->vdev_id = fix_param->vdev_id;
21728 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
21729 info->obss_color_bitmap_bit32to63 =
21730 fix_param->bss_color_bitmap_bit32to63;
21731
21732 switch (fix_param->evt_type) {
21733 case WMI_BSS_COLOR_COLLISION_DISABLE:
21734 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
21735 break;
21736 case WMI_BSS_COLOR_COLLISION_DETECTION:
21737 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
21738 break;
21739 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21740 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21741 break;
21742 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
21743 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
21744 break;
21745 default:
21746 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
21747 __func__, fix_param->evt_type, fix_param->vdev_id);
21748 return QDF_STATUS_E_FAILURE;
21749 }
21750
21751 return QDF_STATUS_SUCCESS;
21752}
21753
Arif Hussaine0eb7302018-03-01 14:40:59 -080021754/*
21755 * extract_comb_phyerr_tlv() - extract comb phy error from event
21756 * @wmi_handle: wmi handle
21757 * @evt_buf: pointer to event buffer
21758 * @datalen: data length of event buffer
21759 * @buf_offset: Pointer to hold value of current event buffer offset
21760 * post extraction
21761 * @phyerr: Pointer to hold phyerr
21762 *
21763 * Return: QDF_STATUS
21764 */
21765static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
21766 void *evt_buf,
21767 uint16_t datalen,
21768 uint16_t *buf_offset,
21769 wmi_host_phyerr_t *phyerr)
21770{
21771 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
21772 wmi_comb_phyerr_rx_hdr *pe_hdr;
21773
21774 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
21775 if (!param_tlvs) {
21776 WMI_LOGD("%s: Received null data from FW", __func__);
21777 return QDF_STATUS_E_FAILURE;
21778 }
21779
21780 pe_hdr = param_tlvs->hdr;
21781 if (!pe_hdr) {
21782 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
21783 return QDF_STATUS_E_FAILURE;
21784 }
21785
21786 /* Ensure it's at least the size of the header */
21787 if (datalen < sizeof(*pe_hdr)) {
21788 WMI_LOGD("%s: Expected minimum size %zu, received %d",
21789 __func__, sizeof(*pe_hdr), datalen);
21790 return QDF_STATUS_E_FAILURE;
21791 }
21792
21793 phyerr->pdev_id = wmi_handle->ops->
21794 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
21795 phyerr->tsf64 = pe_hdr->tsf_l32;
21796 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
21797 phyerr->bufp = param_tlvs->bufp;
21798 phyerr->buf_len = pe_hdr->buf_len;
21799 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
21800 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
21801 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
21802
21803 return QDF_STATUS_SUCCESS;
21804}
21805
21806/**
21807 * extract_single_phyerr_tlv() - extract single phy error from event
21808 * @wmi_handle: wmi handle
21809 * @evt_buf: pointer to event buffer
21810 * @datalen: data length of event buffer
21811 * @buf_offset: Pointer to hold value of current event buffer offset
21812 * post extraction
21813 * @phyerr: Pointer to hold phyerr
21814 *
21815 * Return: QDF_STATUS
21816 */
21817static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
21818 void *evt_buf,
21819 uint16_t datalen,
21820 uint16_t *buf_offset,
21821 wmi_host_phyerr_t *phyerr)
21822{
21823 wmi_single_phyerr_rx_event *ev;
21824 uint16_t n = *buf_offset;
21825 uint8_t *data = (uint8_t *)evt_buf;
21826
21827 if (n < datalen) {
21828 if ((datalen - n) < sizeof(ev->hdr)) {
21829 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
21830 __func__, datalen, n, sizeof(ev->hdr));
21831 return QDF_STATUS_E_FAILURE;
21832 }
21833
21834 /*
21835 * Obtain a pointer to the beginning of the current event.
21836 * data[0] is the beginning of the WMI payload.
21837 */
21838 ev = (wmi_single_phyerr_rx_event *)&data[n];
21839
21840 /*
21841 * Sanity check the buffer length of the event against
21842 * what we currently have.
21843 *
21844 * Since buf_len is 32 bits, we check if it overflows
21845 * a large 32 bit value. It's not 0x7fffffff because
21846 * we increase n by (buf_len + sizeof(hdr)), which would
21847 * in itself cause n to overflow.
21848 *
21849 * If "int" is 64 bits then this becomes a moot point.
21850 */
21851 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
21852 WMI_LOGD("%s: buf_len is garbage 0x%x",
21853 __func__, ev->hdr.buf_len);
21854 return QDF_STATUS_E_FAILURE;
21855 }
21856
21857 if ((n + ev->hdr.buf_len) > datalen) {
21858 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
21859 __func__, n, ev->hdr.buf_len, datalen);
21860 return QDF_STATUS_E_FAILURE;
21861 }
21862
21863 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
21864 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
21865 phyerr->bufp = &ev->bufp[0];
21866 phyerr->buf_len = ev->hdr.buf_len;
21867 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
21868
21869 /*
21870 * Advance the buffer pointer to the next PHY error.
21871 * buflen is the length of this payload, so we need to
21872 * advance past the current header _AND_ the payload.
21873 */
21874 n += sizeof(*ev) + ev->hdr.buf_len;
21875 }
21876 *buf_offset = n;
21877
21878 return QDF_STATUS_SUCCESS;
21879}
21880
Subrat Mishraa667b1c2018-08-02 15:02:04 +053021881/**
21882 * extract_esp_estimation_ev_param_tlv() - extract air time from event
21883 * @wmi_handle: wmi handle
21884 * @evt_buf: pointer to event buffer
21885 * @param: Pointer to hold esp event
21886 *
21887 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
21888 */
21889static QDF_STATUS
21890extract_esp_estimation_ev_param_tlv(wmi_unified_t wmi_handle,
21891 void *evt_buf,
21892 struct esp_estimation_event *param)
21893{
21894 WMI_ESP_ESTIMATE_EVENTID_param_tlvs *param_buf;
21895 wmi_esp_estimate_event_fixed_param *esp_event;
21896
21897 param_buf = (WMI_ESP_ESTIMATE_EVENTID_param_tlvs *)evt_buf;
21898 if (!param_buf) {
21899 WMI_LOGE("Invalid ESP Estimate Event buffer");
21900 return QDF_STATUS_E_INVAL;
21901 }
21902 esp_event = param_buf->fixed_param;
21903 param->ac_airtime_percentage = esp_event->ac_airtime_percentage;
21904 param->pdev_id = convert_target_pdev_id_to_host_pdev_id(
21905 esp_event->pdev_id);
21906
21907 return QDF_STATUS_SUCCESS;
21908}
21909
Govind Singh5eb51532016-03-09 11:34:12 +053021910struct wmi_ops tlv_ops = {
21911 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
21912 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
21913 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053021914 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
21915 .send_hidden_ssid_vdev_restart_cmd =
21916 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021917 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
21918 .send_peer_param_cmd = send_peer_param_cmd_tlv,
21919 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021920 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021921 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021922 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070021923 .send_peer_rx_reorder_queue_setup_cmd =
21924 send_peer_rx_reorder_queue_setup_cmd_tlv,
21925 .send_peer_rx_reorder_queue_remove_cmd =
21926 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053021927 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
21928 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
21929 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021930 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
21931 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080021932 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021933 .send_suspend_cmd = send_suspend_cmd_tlv,
21934 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080021935#ifdef FEATURE_WLAN_D0WOW
21936 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
21937 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
21938#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021939 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
21940 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
21941 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
21942 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021943#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053021944 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021945#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021946 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
21947 .send_stats_request_cmd = send_stats_request_cmd_tlv,
21948 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053021949 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070021950 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021951 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021952 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021953 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
21954 .send_scan_start_cmd = send_scan_start_cmd_tlv,
21955 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
21956 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021957 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021958 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021959 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
21960 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021961 .send_set_sta_uapsd_auto_trig_cmd =
21962 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021963 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
21964 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
21965 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Rachit Kankane9cd0c752018-07-31 16:26:38 +053021966#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +080021967 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
21968 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
21969#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053021970 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
21971 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021972#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053021973 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
21974 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
21975 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
21976 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
21977 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
21978 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
21979 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021980 .send_ocb_start_timing_advert_cmd =
21981 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021982 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
21983 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
21984 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
21985 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
21986#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053021987 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
21988 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
21989 .send_set_mcc_channel_time_latency_cmd =
21990 send_set_mcc_channel_time_latency_cmd_tlv,
21991 .send_set_mcc_channel_time_quota_cmd =
21992 send_set_mcc_channel_time_quota_cmd_tlv,
21993 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
21994 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053021995 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021996 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
21997 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
21998 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021999 .send_probe_rsp_tmpl_send_cmd =
22000 send_probe_rsp_tmpl_send_cmd_tlv,
22001 .send_p2p_go_set_beacon_ie_cmd =
22002 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053022003 .send_setup_install_key_cmd =
22004 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022005 .send_set_gateway_params_cmd =
22006 send_set_gateway_params_cmd_tlv,
22007 .send_set_rssi_monitoring_cmd =
22008 send_set_rssi_monitoring_cmd_tlv,
22009 .send_scan_probe_setoui_cmd =
22010 send_scan_probe_setoui_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022011 .send_roam_scan_offload_rssi_thresh_cmd =
22012 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070022013 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022014 .send_roam_scan_filter_cmd =
22015 send_roam_scan_filter_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022016#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053022017 .send_ipa_offload_control_cmd =
22018 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022019#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053022020 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
22021 .send_plm_start_cmd = send_plm_start_cmd_tlv,
22022 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
22023 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070022024 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022025 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080022026#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053022027 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
22028 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
22029 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080022030#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053022031 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022032 .send_snr_request_cmd = send_snr_request_cmd_tlv,
22033 .send_snr_cmd = send_snr_cmd_tlv,
22034 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080022035#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022036 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
22037 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
22038 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
22039 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053022040 .send_multiple_add_clear_mcbc_filter_cmd =
22041 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070022042 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022043 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
22044 .send_process_gtk_offload_getinfo_cmd =
22045 send_process_gtk_offload_getinfo_cmd_tlv,
22046 .send_enable_enhance_multicast_offload_cmd =
22047 send_enable_enhance_multicast_offload_tlv,
22048 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
22049#ifdef FEATURE_WLAN_RA_FILTERING
22050 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
22051#endif
22052 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022053 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
22054 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022055 .send_lphb_config_tcp_pkt_filter_cmd =
22056 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022057 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22058 .send_lphb_config_udp_pkt_filter_cmd =
22059 send_lphb_config_udp_pkt_filter_cmd_tlv,
Rachit Kankaneed139ff2018-08-01 14:23:55 +053022060#ifdef WLAN_FEATURE_PACKET_FILTERING
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022061 .send_enable_disable_packet_filter_cmd =
22062 send_enable_disable_packet_filter_cmd_tlv,
22063 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Rachit Kankaneed139ff2018-08-01 14:23:55 +053022064#endif
Wu Gao52c0b772018-05-17 16:14:00 +080022065#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022066#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022067 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22068 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022069 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022070 .send_roam_scan_offload_mode_cmd =
22071 send_roam_scan_offload_mode_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053022072#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053022073 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053022074#endif
Govind Singh87542482016-06-08 19:40:11 +053022075 .send_roam_scan_offload_ap_profile_cmd =
22076 send_roam_scan_offload_ap_profile_cmd_tlv,
22077#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022078#ifdef WLAN_SUPPORT_GREEN_AP
22079 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22080 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022081 .extract_green_ap_egap_status_info =
22082 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022083#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022084 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22085 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022086 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022087 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022088 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022089#ifdef WLAN_FEATURE_CIF_CFR
22090 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22091#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022092 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022093 .send_dfs_phyerr_filter_offload_en_cmd =
22094 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022095 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22096 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22097 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22098 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22099 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022100 .send_process_add_periodic_tx_ptrn_cmd =
22101 send_process_add_periodic_tx_ptrn_cmd_tlv,
22102 .send_process_del_periodic_tx_ptrn_cmd =
22103 send_process_del_periodic_tx_ptrn_cmd_tlv,
22104 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22105 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22106 .send_set_app_type2_params_in_fw_cmd =
22107 send_set_app_type2_params_in_fw_cmd_tlv,
22108 .send_set_auto_shutdown_timer_cmd =
22109 send_set_auto_shutdown_timer_cmd_tlv,
22110 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22111 .send_process_dhcpserver_offload_cmd =
22112 send_process_dhcpserver_offload_cmd_tlv,
22113 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22114 .send_process_ch_avoid_update_cmd =
22115 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022116 .send_pdev_set_regdomain_cmd =
22117 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022118 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22119 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22120 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22121 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022122 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022123 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022124 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022125 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022126 .send_set_base_macaddr_indicate_cmd =
22127 send_set_base_macaddr_indicate_cmd_tlv,
22128 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22129 .send_enable_specific_fw_logs_cmd =
22130 send_enable_specific_fw_logs_cmd_tlv,
22131 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022132 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022133 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022134#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022135 .send_pdev_set_dual_mac_config_cmd =
22136 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022137#endif
Govind Singha4836fd2016-03-07 16:45:38 +053022138 .send_app_type1_params_in_fw_cmd =
22139 send_app_type1_params_in_fw_cmd_tlv,
22140 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22141 .send_process_roam_synch_complete_cmd =
22142 send_process_roam_synch_complete_cmd_tlv,
22143 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22144 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22145 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022146 .send_roam_scan_offload_scan_period_cmd =
22147 send_roam_scan_offload_scan_period_cmd_tlv,
22148 .send_roam_scan_offload_chan_list_cmd =
22149 send_roam_scan_offload_chan_list_cmd_tlv,
22150 .send_roam_scan_offload_rssi_change_cmd =
22151 send_roam_scan_offload_rssi_change_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022152#ifdef FEATURE_WLAN_APF
22153 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
22154 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
22155 .send_apf_write_work_memory_cmd =
22156 wmi_send_apf_write_work_memory_cmd_tlv,
22157 .send_apf_read_work_memory_cmd =
22158 wmi_send_apf_read_work_memory_cmd_tlv,
22159 .extract_apf_read_memory_resp_event =
22160 wmi_extract_apf_read_memory_resp_event_tlv,
22161#endif /* FEATURE_WLAN_APF */
Gupta, Kapil2e685982016-04-25 19:14:19 +053022162 .send_adapt_dwelltime_params_cmd =
22163 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022164 .send_dbs_scan_sel_params_cmd =
22165 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022166 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022167 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22168 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22169 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22170 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22171 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22172 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022173 .send_vdev_set_custom_aggr_size_cmd =
22174 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022175 .send_vdev_set_qdepth_thresh_cmd =
22176 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022177 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22178 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22179 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022180 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22181 .send_smart_ant_set_training_info_cmd =
22182 send_smart_ant_set_training_info_cmd_tlv,
22183 .send_smart_ant_set_node_config_cmd =
22184 send_smart_ant_set_node_config_cmd_tlv,
Jeffin Mammen095050b2018-07-24 14:20:08 +053022185#ifdef WLAN_ATF_ENABLE
Sathish Kumar02c3b542017-02-22 17:24:45 +053022186 .send_set_atf_cmd = send_set_atf_cmd_tlv,
Jeffin Mammen095050b2018-07-24 14:20:08 +053022187#endif
Sathish Kumar02c3b542017-02-22 17:24:45 +053022188 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22189 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022190 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22191 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22192 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22193 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022194 .send_periodic_chan_stats_config_cmd =
22195 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022196 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22197 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22198 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022199 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22200 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22201 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22202 .send_vdev_spectral_configure_cmd =
22203 send_vdev_spectral_configure_cmd_tlv,
22204 .send_vdev_spectral_enable_cmd =
22205 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022206 .send_thermal_mitigation_param_cmd =
22207 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022208 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22209 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022210 .send_process_update_edca_param_cmd =
22211 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022212 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022213 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022214 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022215 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22216 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022217 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022218 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22219 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22220 .extract_host_mem_req = extract_host_mem_req_tlv,
22221 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022222 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022223 .is_service_enabled = is_service_enabled_tlv,
22224 .save_fw_version = save_fw_version_in_service_ready_tlv,
22225 .ready_extract_init_status = ready_extract_init_status_tlv,
22226 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022227 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022228 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022229 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22230 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022231 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022232 .extract_tbttoffset_update_params =
22233 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022234 .extract_ext_tbttoffset_update_params =
22235 extract_ext_tbttoffset_update_params_tlv,
22236 .extract_tbttoffset_num_vdevs =
22237 extract_tbttoffset_num_vdevs_tlv,
22238 .extract_ext_tbttoffset_num_vdevs =
22239 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022240 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22241 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22242 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22243 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022244#ifdef CONVERGED_TDLS_ENABLE
22245 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22246#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022247 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022248 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022249 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22250 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022251#ifdef CONVERGED_P2P_ENABLE
22252 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
Rachit Kankane9cd0c752018-07-31 16:26:38 +053022253#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +080022254 .extract_p2p_lo_stop_ev_param =
22255 extract_p2p_lo_stop_ev_param_tlv,
22256#endif
Rachit Kankane9cd0c752018-07-31 16:26:38 +053022257#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022258 .extract_offchan_data_tx_compl_param =
22259 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022260 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22261 .extract_all_stats_count = extract_all_stats_counts_tlv,
22262 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022263 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022264 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22265 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070022266 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022267 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022268 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022269 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22270 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22271 .extract_chan_stats = extract_chan_stats_tlv,
22272 .extract_profile_ctx = extract_profile_ctx_tlv,
22273 .extract_profile_data = extract_profile_data_tlv,
22274 .extract_chan_info_event = extract_chan_info_event_tlv,
22275 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022276 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022277#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022278 .send_encrypt_decrypt_send_cmd =
22279 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022280 .extract_encrypt_decrypt_resp_event =
22281 extract_encrypt_decrypt_resp_event_tlv,
22282#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022283 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022284 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22285 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022286 .extract_sar2_result_event = extract_sar2_result_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022287 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022288 .send_multiple_vdev_restart_req_cmd =
22289 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022290 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22291 .extract_hw_mode_cap_service_ready_ext =
22292 extract_hw_mode_cap_service_ready_ext_tlv,
22293 .extract_mac_phy_cap_service_ready_ext =
22294 extract_mac_phy_cap_service_ready_ext_tlv,
22295 .extract_reg_cap_service_ready_ext =
22296 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022297 .extract_dbr_ring_cap_service_ready_ext =
22298 extract_dbr_ring_cap_service_ready_ext_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022299 .extract_sar_cap_service_ready_ext =
22300 extract_sar_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022301 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22302 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022303 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022304 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022305 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022306 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22307 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22308 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022309 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022310 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022311 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022312 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022313 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022314 .extract_pdev_csa_switch_count_status =
22315 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022316 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022317 .extract_pdev_tpc_config_ev_param =
22318 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022319 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022320 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22321 .extract_peer_sta_ps_statechange_ev =
22322 extract_peer_sta_ps_statechange_ev_tlv,
22323 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022324 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053022325#ifdef WLAN_FEATURE_ACTION_OUI
22326 .send_action_oui_cmd = send_action_oui_cmd_tlv,
22327#endif
Arif Hussainf00be1d2017-01-07 18:21:55 -080022328 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22329 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022330 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022331 extract_reg_chan_list_update_event_tlv,
22332 .extract_chainmask_tables =
22333 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022334 .extract_thermal_stats = extract_thermal_stats_tlv,
22335 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022336 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22337 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022338#ifdef DFS_COMPONENT_ENABLE
22339 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22340 .extract_dfs_radar_detection_event =
22341 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022342 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022343#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022344 .convert_pdev_id_host_to_target =
22345 convert_host_pdev_id_to_target_pdev_id_legacy,
22346 .convert_pdev_id_target_to_host =
22347 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022348
22349 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22350 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22351 .extract_reg_11d_new_country_event =
22352 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022353 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022354 .send_limit_off_chan_cmd =
22355 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022356 .extract_reg_ch_avoid_event =
22357 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022358 .send_pdev_caldata_version_check_cmd =
22359 send_pdev_caldata_version_check_cmd_tlv,
22360 .extract_pdev_caldata_version_check_ev_param =
22361 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022362 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22363 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022364 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22365#if defined(WLAN_FEATURE_FILS_SK)
22366 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22367#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022368 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022369#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22370 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22371 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22372 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22373 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22374 .extract_ndp_ind = extract_ndp_ind_tlv,
22375 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22376 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22377 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22378 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
Naveen Rawatd42ce382018-01-09 17:54:41 -080022379 .extract_ndp_sch_update = extract_ndp_sch_update_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022380#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022381 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022382 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022383 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022384#ifdef WLAN_SUPPORT_FILS
22385 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22386 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22387 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22388#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022389 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22390 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022391 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22392 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22393 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22394 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022395 .send_bss_color_change_enable_cmd =
22396 send_bss_color_change_enable_cmd_tlv,
22397 .send_obss_color_collision_cfg_cmd =
22398 send_obss_color_collision_cfg_cmd_tlv,
22399 .extract_obss_color_collision_info =
22400 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022401 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22402 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070022403#ifdef QCA_SUPPORT_CP_STATS
22404 .extract_cca_stats = extract_cca_stats_tlv,
22405#endif
Subrat Mishraa667b1c2018-08-02 15:02:04 +053022406 .extract_esp_estimation_ev_param =
22407 extract_esp_estimation_ev_param_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022408};
22409
Govind Singhe7f2f342016-05-23 12:12:52 +053022410/**
22411 * populate_tlv_event_id() - populates wmi event ids
22412 *
22413 * @param event_ids: Pointer to hold event ids
22414 * Return: None
22415 */
22416static void populate_tlv_events_id(uint32_t *event_ids)
22417{
22418 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22419 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22420 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22421 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22422 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22423 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22424 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22425 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22426 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22427 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22428 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22429 event_ids[wmi_service_ready_ext_event_id] =
22430 WMI_SERVICE_READY_EXT_EVENTID;
22431 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22432 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22433 event_ids[wmi_vdev_install_key_complete_event_id] =
22434 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22435 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22436 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22437
22438 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22439 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22440 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22441 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22442 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22443 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22444 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22445 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022446 event_ids[wmi_peer_delete_response_event_id] =
22447 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022448 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22449 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22450 event_ids[wmi_tbttoffset_update_event_id] =
22451 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022452 event_ids[wmi_ext_tbttoffset_update_event_id] =
22453 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022454 event_ids[wmi_offload_bcn_tx_status_event_id] =
22455 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22456 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22457 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22458 event_ids[wmi_mgmt_tx_completion_event_id] =
22459 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022460 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22461 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022462 event_ids[wmi_tx_delba_complete_event_id] =
22463 WMI_TX_DELBA_COMPLETE_EVENTID;
22464 event_ids[wmi_tx_addba_complete_event_id] =
22465 WMI_TX_ADDBA_COMPLETE_EVENTID;
22466 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22467
22468 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22469
22470 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22471 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22472
22473 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022474 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022475
22476 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22477
22478 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022479 event_ids[wmi_p2p_lo_stop_event_id] =
22480 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022481 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22482 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022483 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022484 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22485 event_ids[wmi_wow_initial_wakeup_event_id] =
22486 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22487
22488 event_ids[wmi_rtt_meas_report_event_id] =
22489 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22490 event_ids[wmi_tsf_meas_report_event_id] =
22491 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22492 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22493 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22494 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22495 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22496 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022497 event_ids[wmi_diag_event_id_log_supported_event_id] =
22498 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22499 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22500 event_ids[wmi_nlo_scan_complete_event_id] =
22501 WMI_NLO_SCAN_COMPLETE_EVENTID;
22502 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22503 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22504
22505 event_ids[wmi_gtk_offload_status_event_id] =
22506 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22507 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22508 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22509 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22510
22511 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22512
22513 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22514
22515 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22516 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22517 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22518 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22519 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22520 event_ids[wmi_wlan_profile_data_event_id] =
22521 WMI_WLAN_PROFILE_DATA_EVENTID;
22522 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22523 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22524 event_ids[wmi_vdev_get_keepalive_event_id] =
22525 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22526 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22527
22528 event_ids[wmi_diag_container_event_id] =
22529 WMI_DIAG_DATA_CONTAINER_EVENTID;
22530
22531 event_ids[wmi_host_auto_shutdown_event_id] =
22532 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22533
22534 event_ids[wmi_update_whal_mib_stats_event_id] =
22535 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22536
22537 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22538 event_ids[wmi_update_vdev_rate_stats_event_id] =
22539 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22540
22541 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022542 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022543
22544 /** Set OCB Sched Response, deprecated */
22545 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
22546
22547 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
22548 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
22549 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
22550
22551 /* GPIO Event */
22552 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
22553 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
22554
22555 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
22556 event_ids[wmi_rfkill_state_change_event_id] =
22557 WMI_RFKILL_STATE_CHANGE_EVENTID;
22558
22559 /* TDLS Event */
22560 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
22561
22562 event_ids[wmi_batch_scan_enabled_event_id] =
22563 WMI_BATCH_SCAN_ENABLED_EVENTID;
22564 event_ids[wmi_batch_scan_result_event_id] =
22565 WMI_BATCH_SCAN_RESULT_EVENTID;
22566 /* OEM Event */
22567 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
22568 event_ids[wmi_oem_meas_report_event_id] =
22569 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
22570 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
22571
22572 /* NAN Event */
22573 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
22574
22575 /* LPI Event */
22576 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
22577 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
22578 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
22579
22580 /* ExtScan events */
22581 event_ids[wmi_extscan_start_stop_event_id] =
22582 WMI_EXTSCAN_START_STOP_EVENTID;
22583 event_ids[wmi_extscan_operation_event_id] =
22584 WMI_EXTSCAN_OPERATION_EVENTID;
22585 event_ids[wmi_extscan_table_usage_event_id] =
22586 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
22587 event_ids[wmi_extscan_cached_results_event_id] =
22588 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
22589 event_ids[wmi_extscan_wlan_change_results_event_id] =
22590 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
22591 event_ids[wmi_extscan_hotlist_match_event_id] =
22592 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
22593 event_ids[wmi_extscan_capabilities_event_id] =
22594 WMI_EXTSCAN_CAPABILITIES_EVENTID;
22595 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
22596 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
22597
22598 /* mDNS offload events */
22599 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
22600
22601 /* SAP Authentication offload events */
22602 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
22603 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
22604
22605 /** Out-of-context-of-bss (OCB) events */
22606 event_ids[wmi_ocb_set_config_resp_event_id] =
22607 WMI_OCB_SET_CONFIG_RESP_EVENTID;
22608 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
22609 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
22610 event_ids[wmi_dcc_get_stats_resp_event_id] =
22611 WMI_DCC_GET_STATS_RESP_EVENTID;
22612 event_ids[wmi_dcc_update_ndl_resp_event_id] =
22613 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
22614 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
22615 /* System-On-Chip events */
22616 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
22617 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
22618 event_ids[wmi_soc_hw_mode_transition_event_id] =
22619 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
22620 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
22621 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022622 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053022623 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
22624 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022625 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053022626 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
22627 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22628 event_ids[wmi_peer_sta_ps_statechg_event_id] =
22629 WMI_PEER_STA_PS_STATECHG_EVENTID;
22630 event_ids[wmi_pdev_channel_hopping_event_id] =
22631 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022632 event_ids[wmi_offchan_data_tx_completion_event] =
22633 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022634 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
22635 event_ids[wmi_dfs_radar_detection_event_id] =
22636 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022637 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070022638 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053022639 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053022640 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022641 event_ids[wmi_service_available_event_id] =
22642 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022643 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022644 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022645 /* NDP events */
22646 event_ids[wmi_ndp_initiator_rsp_event_id] =
22647 WMI_NDP_INITIATOR_RSP_EVENTID;
22648 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
22649 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
22650 event_ids[wmi_ndp_responder_rsp_event_id] =
22651 WMI_NDP_RESPONDER_RSP_EVENTID;
22652 event_ids[wmi_ndp_end_indication_event_id] =
22653 WMI_NDP_END_INDICATION_EVENTID;
22654 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080022655 event_ids[wmi_ndl_schedule_update_event_id] =
22656 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022657
22658 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
22659 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
22660 event_ids[wmi_pdev_chip_power_stats_event_id] =
22661 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
22662 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
22663 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
22664 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022665 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022666 WMI_BPF_CAPABILIY_INFO_EVENTID;
22667 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
22668 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
22669 event_ids[wmi_report_rx_aggr_failure_event_id] =
22670 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
22671 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
22672 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
22673 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
22674 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
22675 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
22676 event_ids[wmi_pdev_hw_mode_transition_event_id] =
22677 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
22678 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
22679 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
22680 event_ids[wmi_coex_bt_activity_event_id] =
22681 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
22682 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
22683 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
22684 event_ids[wmi_radio_tx_power_level_stats_event_id] =
22685 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
22686 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053022687 event_ids[wmi_dma_buf_release_event_id] =
22688 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022689 event_ids[wmi_sap_obss_detection_report_event_id] =
22690 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022691 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080022692 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022693 event_ids[wmi_obss_color_collision_report_event_id] =
22694 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080022695 event_ids[wmi_pdev_div_rssi_antid_event_id] =
22696 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070022697 event_ids[wmi_twt_enable_complete_event_id] =
22698 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022699 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
22700 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022701 event_ids[wmi_wlan_sar2_result_event_id] = WMI_SAR2_RESULT_EVENTID;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053022702 event_ids[wmi_esp_estimate_event_id] = WMI_ESP_ESTIMATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022703}
22704
Soumya Bhat488092d2017-03-22 14:41:01 +053022705/**
22706 * populate_tlv_service() - populates wmi services
22707 *
22708 * @param wmi_service: Pointer to hold wmi_service
22709 * Return: None
22710 */
22711static void populate_tlv_service(uint32_t *wmi_service)
22712{
22713 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022714 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022715 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
22716 wmi_service[wmi_service_roam_scan_offload] =
22717 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
22718 wmi_service[wmi_service_bcn_miss_offload] =
22719 WMI_SERVICE_BCN_MISS_OFFLOAD;
22720 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
22721 wmi_service[wmi_service_sta_advanced_pwrsave] =
22722 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
22723 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
22724 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
22725 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
22726 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
22727 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
22728 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
22729 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
22730 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
22731 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
22732 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
22733 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
22734 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
22735 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
22736 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
22737 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
22738 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
22739 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
22740 wmi_service[wmi_service_packet_power_save] =
22741 WMI_SERVICE_PACKET_POWER_SAVE;
22742 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
22743 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
22744 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
22745 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
22746 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
22747 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
22748 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
22749 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
22750 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
22751 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
22752 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
22753 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
22754 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
22755 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
22756 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
22757 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
22758 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
22759 wmi_service[wmi_service_mcc_bcn_interval_change] =
22760 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
22761 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
22762 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
22763 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
22764 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
22765 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
22766 wmi_service[wmi_service_lte_ant_share_support] =
22767 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
22768 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
22769 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
22770 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
22771 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
22772 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
22773 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
22774 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
22775 wmi_service[wmi_service_bcn_txrate_override] =
22776 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
22777 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
22778 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
22779 wmi_service[wmi_service_estimate_linkspeed] =
22780 WMI_SERVICE_ESTIMATE_LINKSPEED;
22781 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
22782 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
22783 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
22784 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
22785 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
22786 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
22787 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
22788 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
22789 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
22790 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
22791 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
22792 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
22793 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
22794 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
22795 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
22796 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
22797 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
22798 wmi_service[wmi_service_sap_auth_offload] =
22799 WMI_SERVICE_SAP_AUTH_OFFLOAD;
22800 wmi_service[wmi_service_dual_band_simultaneous_support] =
22801 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
22802 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
22803 wmi_service[wmi_service_ap_arpns_offload] =
22804 WMI_SERVICE_AP_ARPNS_OFFLOAD;
22805 wmi_service[wmi_service_per_band_chainmask_support] =
22806 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
22807 wmi_service[wmi_service_packet_filter_offload] =
22808 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
22809 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
22810 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
22811 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
22812 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
22813 wmi_service[wmi_service_multiple_vdev_restart] =
22814 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
22815
22816 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
22817 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
22818 wmi_service[wmi_service_smart_antenna_sw_support] =
22819 WMI_SERVICE_UNAVAILABLE;
22820 wmi_service[wmi_service_smart_antenna_hw_support] =
22821 WMI_SERVICE_UNAVAILABLE;
22822 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053022823 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022824 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053022825 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
22826 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
22827 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
22828 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
22829 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
22830 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
22831 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
22832 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053022833 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
22834 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
22835 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022836 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022837 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
22838 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
22839 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
22840 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
22841 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
22842 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022843 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
22844 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
22845 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
22846 wmi_service[wmi_service_unified_wow_capability] =
22847 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
22848 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022849 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022850 wmi_service[wmi_service_sync_delete_cmds] =
22851 WMI_SERVICE_SYNC_DELETE_CMDS;
22852 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
22853 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
22854 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
22855 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
22856 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
22857 wmi_service[wmi_service_deprecated_replace] =
22858 WMI_SERVICE_DEPRECATED_REPLACE;
22859 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
22860 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
22861 wmi_service[wmi_service_enhanced_mcast_filter] =
22862 WMI_SERVICE_ENHANCED_MCAST_FILTER;
22863 wmi_service[wmi_service_half_rate_quarter_rate_support] =
22864 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
22865 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
22866 wmi_service[wmi_service_p2p_listen_offload_support] =
22867 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
22868 wmi_service[wmi_service_mark_first_wakeup_packet] =
22869 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
22870 wmi_service[wmi_service_multiple_mcast_filter_set] =
22871 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
22872 wmi_service[wmi_service_host_managed_rx_reorder] =
22873 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
22874 wmi_service[wmi_service_flash_rdwr_support] =
22875 WMI_SERVICE_FLASH_RDWR_SUPPORT;
22876 wmi_service[wmi_service_wlan_stats_report] =
22877 WMI_SERVICE_WLAN_STATS_REPORT;
22878 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
22879 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
22880 wmi_service[wmi_service_dfs_phyerr_offload] =
22881 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
22882 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
22883 wmi_service[wmi_service_fw_mem_dump_support] =
22884 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
22885 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
22886 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
22887 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
22888 wmi_service[wmi_service_hw_data_filtering] =
22889 WMI_SERVICE_HW_DATA_FILTERING;
22890 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
22891 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053022892 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053022893 wmi_service[wmi_service_extended_nss_support] =
22894 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053022895 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022896 wmi_service[wmi_service_bcn_offload_start_stop_support] =
22897 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053022898 wmi_service[wmi_service_offchan_data_tid_support] =
22899 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053022900 wmi_service[wmi_service_support_dma] =
22901 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022902 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
22903 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
22904 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080022905 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
22906 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053022907 wmi_service[wmi_service_11k_neighbour_report_support] =
22908 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080022909 wmi_service[wmi_service_ap_obss_detection_offload] =
22910 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
22911 wmi_service[wmi_service_bss_color_offload] =
22912 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053022913 wmi_service[wmi_service_gmac_offload_support] =
22914 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080022915 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
22916 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
22917 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
22918 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070022919 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
22920 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053022921 wmi_service[wmi_service_listen_interval_offload_support] =
22922 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022923
Soumya Bhat488092d2017-03-22 14:41:01 +053022924}
22925
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022926#ifndef CONFIG_MCL
22927
Govind Singhe7f2f342016-05-23 12:12:52 +053022928/**
22929 * populate_pdev_param_tlv() - populates pdev params
22930 *
22931 * @param pdev_param: Pointer to hold pdev params
22932 * Return: None
22933 */
22934static void populate_pdev_param_tlv(uint32_t *pdev_param)
22935{
22936 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
22937 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
22938 pdev_param[wmi_pdev_param_txpower_limit2g] =
22939 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
22940 pdev_param[wmi_pdev_param_txpower_limit5g] =
22941 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
22942 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
22943 pdev_param[wmi_pdev_param_beacon_gen_mode] =
22944 WMI_PDEV_PARAM_BEACON_GEN_MODE;
22945 pdev_param[wmi_pdev_param_beacon_tx_mode] =
22946 WMI_PDEV_PARAM_BEACON_TX_MODE;
22947 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
22948 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
22949 pdev_param[wmi_pdev_param_protection_mode] =
22950 WMI_PDEV_PARAM_PROTECTION_MODE;
22951 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
22952 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
22953 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
22954 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
22955 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
22956 pdev_param[wmi_pdev_param_sta_kickout_th] =
22957 WMI_PDEV_PARAM_STA_KICKOUT_TH;
22958 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
22959 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
22960 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
22961 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
22962 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
22963 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
22964 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
22965 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
22966 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
22967 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
22968 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
22969 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
22970 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
22971 pdev_param[wmi_pdev_param_ltr_sleep_override] =
22972 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
22973 pdev_param[wmi_pdev_param_ltr_rx_override] =
22974 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
22975 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
22976 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
22977 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
22978 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
22979 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
22980 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
22981 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
22982 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
22983 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
22984 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
22985 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
22986 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
22987 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
22988 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
22989 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
22990 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
22991 pdev_param[wmi_pdev_param_peer_stats_update_period] =
22992 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
22993 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
22994 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
22995 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
22996 pdev_param[wmi_pdev_param_arp_ac_override] =
22997 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
22998 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
22999 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
23000 pdev_param[wmi_pdev_param_ani_poll_period] =
23001 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
23002 pdev_param[wmi_pdev_param_ani_listen_period] =
23003 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
23004 pdev_param[wmi_pdev_param_ani_ofdm_level] =
23005 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
23006 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
23007 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
23008 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
23009 pdev_param[wmi_pdev_param_idle_ps_config] =
23010 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
23011 pdev_param[wmi_pdev_param_power_gating_sleep] =
23012 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
23013 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
23014 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
23015 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
23016 pdev_param[wmi_pdev_param_hw_rfkill_config] =
23017 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
23018 pdev_param[wmi_pdev_param_low_power_rf_enable] =
23019 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
23020 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
23021 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
23022 pdev_param[wmi_pdev_param_power_collapse_enable] =
23023 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
23024 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
23025 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
23026 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
23027 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
23028 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
23029 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
23030 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
23031 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
23032 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
23033 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
23034 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
23035 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
23036 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
23037 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
23038 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
23039 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
23040 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
23041 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
23042 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
23043 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
23044 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
23045 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
23046 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
23047 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
23048 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
23049 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
23050 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
23051 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
23052 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
23053 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
23054 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
23055 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
23056 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
23057 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
23058 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
23059 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
23060 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
23061 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
23062 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23063 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23064 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23065 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23066 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23067 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023068 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23069 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23070 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023071 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23072 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023073 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023074 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023075 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23076 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23077 WMI_PDEV_PARAM_PROXY_STA_MODE;
23078 pdev_param[wmi_pdev_param_mu_group_policy] =
23079 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23080 pdev_param[wmi_pdev_param_noise_detection] =
23081 WMI_PDEV_PARAM_NOISE_DETECTION;
23082 pdev_param[wmi_pdev_param_noise_threshold] =
23083 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23084 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23085 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23086 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023087 pdev_param[wmi_pdev_param_atf_strict_sch] =
23088 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23089 pdev_param[wmi_pdev_param_atf_sched_duration] =
23090 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023091 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23092 pdev_param[wmi_pdev_param_sensitivity_level] =
23093 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23094 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23095 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23096 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23097 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023098 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23099 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23100 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23101 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023102 pdev_param[wmi_pdev_param_cca_threshold] =
23103 WMI_PDEV_PARAM_CCA_THRESHOLD;
23104 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23105 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023106 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023107 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23108 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23109 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23110 pdev_param[wmi_pdev_param_arp_srcaddr] =
23111 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23112 pdev_param[wmi_pdev_param_arp_dstaddr] =
23113 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23114 pdev_param[wmi_pdev_param_txpower_decr_db] =
23115 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023116 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23117 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023118 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23119 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023120 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023121 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023122 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23123 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023124 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23125 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023126 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23127 WMI_UNAVAILABLE_PARAM;
Sathish Kumar210b4062018-07-03 17:25:11 +053023128 pdev_param[wmi_pdev_param_igmpmld_override] =
23129 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23130 pdev_param[wmi_pdev_param_igmpmld_tid] =
23131 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023132 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23133 pdev_param[wmi_pdev_param_block_interbss] =
23134 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023135 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023136 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23137 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23138 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023139 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023140 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023141 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23142 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023143 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023144 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23145 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023146 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23147 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23148 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23149 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
Sathish Kumara059f412017-03-22 19:10:28 +053023150 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23151 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23152 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23153 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23154 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23155 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23156 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23157 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23158 pdev_param[wmi_pdev_param_fast_channel_reset] =
23159 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23160 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023161 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023162 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053023163 pdev_param[wmi_pdev_param_antenna_gain_half_db] =
23164 WMI_PDEV_PARAM_ANTENNA_GAIN_HALF_DB;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053023165 pdev_param[wmi_pdev_param_esp_indication_period] =
23166 WMI_PDEV_PARAM_ESP_INDICATION_PERIOD;
Venkateswara Swamy Bandaruc9906412018-08-06 20:44:28 +053023167#ifdef WLAN_RU26_SUPPORT
23168 pdev_param[wmi_pdev_param_ru26_allowed] = WMI_PDEV_PARAM_RU26_ALLOWED;
23169#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053023170}
23171
23172/**
23173 * populate_vdev_param_tlv() - populates vdev params
23174 *
23175 * @param vdev_param: Pointer to hold vdev params
23176 * Return: None
23177 */
23178static void populate_vdev_param_tlv(uint32_t *vdev_param)
23179{
23180 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23181 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23182 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23183 vdev_param[wmi_vdev_param_beacon_interval] =
23184 WMI_VDEV_PARAM_BEACON_INTERVAL;
23185 vdev_param[wmi_vdev_param_listen_interval] =
23186 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23187 vdev_param[wmi_vdev_param_multicast_rate] =
23188 WMI_VDEV_PARAM_MULTICAST_RATE;
23189 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23190 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23191 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23192 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23193 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23194 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23195 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23196 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23197 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23198 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23199 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23200 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23201 vdev_param[wmi_vdev_param_bmiss_count_max] =
23202 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23203 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23204 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23205 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23206 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23207 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23208 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23209 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23210 vdev_param[wmi_vdev_param_disable_htprotection] =
23211 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23212 vdev_param[wmi_vdev_param_sta_quickkickout] =
23213 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23214 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23215 vdev_param[wmi_vdev_param_protection_mode] =
23216 WMI_VDEV_PARAM_PROTECTION_MODE;
23217 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23218 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23219 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23220 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23221 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23222 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23223 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23224 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23225 vdev_param[wmi_vdev_param_bcast_data_rate] =
23226 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23227 vdev_param[wmi_vdev_param_mcast_data_rate] =
23228 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23229 vdev_param[wmi_vdev_param_mcast_indicate] =
23230 WMI_VDEV_PARAM_MCAST_INDICATE;
23231 vdev_param[wmi_vdev_param_dhcp_indicate] =
23232 WMI_VDEV_PARAM_DHCP_INDICATE;
23233 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23234 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23235 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23236 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23237 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23238 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23239 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23240 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23241 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23242 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23243 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23244 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23245 vdev_param[wmi_vdev_param_packet_powersave] =
23246 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23247 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23248 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23249 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23250 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23251 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23252 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23253 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23254 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23255 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23256 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23257 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23258 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23259 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23260 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23261 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23262 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23263 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23264 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23265 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23266 vdev_param[wmi_vdev_param_roam_fw_offload] =
23267 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23268 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23269 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23270 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23271 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23272 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23273 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23274 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23275 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23276 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23277 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23278 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23279 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23280 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23281 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23282 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23283 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23284 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23285 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23286 vdev_param[wmi_vdev_param_inactivity_cnt] =
23287 WMI_VDEV_PARAM_INACTIVITY_CNT;
23288 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23289 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23290 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23291 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23292 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23293 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23294 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23295 vdev_param[wmi_vdev_param_rx_leak_window] =
23296 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23297 vdev_param[wmi_vdev_param_stats_avg_factor] =
23298 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23299 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23300 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23301 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23302 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23303 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23304 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023305 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23306 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023307 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023308 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23309 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23310 WMI_VDEV_PARAM_HE_RANGE_EXT;
23311 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23312 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarika6d1b9422018-06-22 16:44:59 -070023313 vdev_param[wmi_vdev_param_set_he_sounding_mode]
23314 = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023315 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023316 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23317 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23318 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23319 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23320 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23321 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23322 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023323 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23324 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23325 vdev_param[wmi_vdev_param_rc_num_retries] =
23326 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23327 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23328 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23329 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23330 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23331 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23332 vdev_param[wmi_vdev_param_vht80_ratemask] =
23333 WMI_VDEV_PARAM_VHT80_RATEMASK;
23334 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23335 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23336 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023337 vdev_param[wmi_vdev_param_set_he_ltf] =
23338 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053023339 vdev_param[wmi_vdev_param_disable_cabq] =
23340 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053023341 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23342 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023343 vdev_param[wmi_vdev_param_set_ba_mode] =
23344 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023345 vdev_param[wmi_vdev_param_capabilities] =
23346 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023347 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23348 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023349}
23350#endif
23351
Govind Singh5eb51532016-03-09 11:34:12 +053023352/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023353 * populate_target_defines_tlv() - Populate target defines and params
23354 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023355 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023356 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023357 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023358#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023359static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023360{
Govind Singhe7f2f342016-05-23 12:12:52 +053023361 populate_pdev_param_tlv(wmi_handle->pdev_param);
23362 populate_vdev_param_tlv(wmi_handle->vdev_param);
23363}
23364#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023365static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23366{ }
23367#endif
23368
23369/**
Zhang Qian537fca62018-01-03 16:33:24 +080023370 * wmi_ocb_ut_attach() - Attach OCB test framework
23371 * @wmi_handle: wmi handle
23372 *
23373 * Return: None
23374 */
23375#ifdef WLAN_OCB_UT
23376void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23377#else
23378static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23379{
23380 return;
23381}
23382#endif
23383
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023384/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023385 * wmi_tlv_attach() - Attach TLV APIs
23386 *
23387 * Return: None
23388 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023389void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023390{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023391 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023392 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023393 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023394#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023395 /* Skip saving WMI_CMD_HDR and TLV HDR */
23396 wmi_handle->log_info.buf_offset_command = 8;
23397 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023398 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023399#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023400 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023401 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023402 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023403 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080023404 wmi_extscan_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023405}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023406qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023407
23408/**
23409 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23410 *
23411 * Return: None
23412 */
23413void wmi_tlv_init(void)
23414{
23415 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23416}