blob: 1b75498508cf42d29e7922302d39dbf13f7e4638 [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/**
Ashish Kumar Dhanotiyac8b83e52018-08-02 14:26:53 +0530147 * wmi_mtrace() - Wrappper function for qdf_mtrace api
148 * @message_id: 32-Bit Wmi message ID
149 * @vdev_id: Vdev ID
150 * @data: Actual message contents
151 *
152 * This function converts the 32-bit WMI message ID in 15-bit message ID
153 * format for qdf_mtrace as in qdf_mtrace message there are only 15
154 * bits reserved for message ID.
155 * out of these 15-bits, 8-bits (From MSB) specifies the WMI_GRP_ID
156 * and remaining 7-bits specifies the actual WMI command. With this
157 * notation there can be maximum 256 groups and each group can have
158 * max 128 commands can be supported.
159 *
160 * Return: None
161 */
162static void wmi_mtrace(uint32_t message_id, uint16_t vdev_id, uint32_t data)
163{
164 uint16_t mtrace_message_id;
165
166 mtrace_message_id = QDF_WMI_MTRACE_CMD_ID(message_id) |
167 (QDF_WMI_MTRACE_GRP_ID(message_id) <<
168 QDF_WMI_MTRACE_CMD_NUM_BITS);
169 qdf_mtrace(QDF_MODULE_ID_WMI, QDF_MODULE_ID_TARGET,
170 mtrace_message_id, vdev_id, data);
171}
172
173/**
Govind Singh5eb51532016-03-09 11:34:12 +0530174 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
175 * @wmi_handle: wmi handle
176 * @param: pointer to hold vdev create parameter
177 * @macaddr: vdev mac address
178 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530179 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530180 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530181static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530182 uint8_t macaddr[IEEE80211_ADDR_LEN],
183 struct vdev_create_params *param)
184{
185 wmi_vdev_create_cmd_fixed_param *cmd;
186 wmi_buf_t buf;
187 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +0530188 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700189 int num_bands = 2;
190 uint8_t *buf_ptr;
191 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +0530192
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700193 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530194 buf = wmi_buf_alloc(wmi_handle, len);
195 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530196 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530197 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530198 }
199 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
200 WMITLV_SET_HDR(&cmd->tlv_header,
201 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
202 WMITLV_GET_STRUCT_TLVLEN
203 (wmi_vdev_create_cmd_fixed_param));
204 cmd->vdev_id = param->if_id;
205 cmd->vdev_type = param->type;
206 cmd->vdev_subtype = param->subtype;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -0700207 cmd->flags = param->mbssid_flags;
208 cmd->vdevid_trans = param->vdevid_trans;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700209 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530210 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530211 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700212 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
213 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530214 macaddr[0], macaddr[1], macaddr[2],
215 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700216 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
217 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
218 (num_bands * sizeof(wmi_vdev_txrx_streams)));
219 buf_ptr += WMI_TLV_HDR_SIZE;
220
Govind Singh224a7312016-06-21 14:33:26 +0530221 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700222 param->type, param->subtype,
223 param->nss_2g, param->nss_5g);
224 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
225 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
226 txrx_streams->supported_tx_streams = param->nss_2g;
227 txrx_streams->supported_rx_streams = param->nss_2g;
228 WMITLV_SET_HDR(&txrx_streams->tlv_header,
229 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
230 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
231
232 txrx_streams++;
233 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
234 txrx_streams->supported_tx_streams = param->nss_5g;
235 txrx_streams->supported_rx_streams = param->nss_5g;
236 WMITLV_SET_HDR(&txrx_streams->tlv_header,
237 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
238 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530239 wmi_mtrace(WMI_VDEV_CREATE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530240 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530241 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530242 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530243 wmi_buf_free(buf);
244 }
245
246 return ret;
247}
248
249/**
250 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
251 * @wmi_handle: wmi handle
252 * @if_id: vdev id
253 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530254 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530255 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530256static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530257 uint8_t if_id)
258{
259 wmi_vdev_delete_cmd_fixed_param *cmd;
260 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530261 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530262
263 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
264 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530265 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530266 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530267 }
268
269 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
270 WMITLV_SET_HDR(&cmd->tlv_header,
271 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
272 WMITLV_GET_STRUCT_TLVLEN
273 (wmi_vdev_delete_cmd_fixed_param));
274 cmd->vdev_id = if_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530275 wmi_mtrace(WMI_VDEV_DELETE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530276 ret = wmi_unified_cmd_send(wmi_handle, buf,
277 sizeof(wmi_vdev_delete_cmd_fixed_param),
278 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530279 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530280 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530281 wmi_buf_free(buf);
282 }
Govind Singhb53420c2016-03-09 14:32:57 +0530283 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530284
285 return ret;
286}
287
288/**
289 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
290 * @wmi: wmi handle
291 * @vdev_id: vdev id
292 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530293 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530294 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530295static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530296 uint8_t vdev_id)
297{
298 wmi_vdev_stop_cmd_fixed_param *cmd;
299 wmi_buf_t buf;
300 int32_t len = sizeof(*cmd);
301
302 buf = wmi_buf_alloc(wmi, len);
303 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530304 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530305 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530306 }
307 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
308 WMITLV_SET_HDR(&cmd->tlv_header,
309 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
310 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
311 cmd->vdev_id = vdev_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530312 wmi_mtrace(WMI_VDEV_STOP_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530313 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530314 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530315 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530316 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530317 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530318 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530319
320 return 0;
321}
322
323/**
324 * send_vdev_down_cmd_tlv() - send vdev down command to fw
325 * @wmi: wmi handle
326 * @vdev_id: vdev id
327 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530328 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530329 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530330static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530331{
332 wmi_vdev_down_cmd_fixed_param *cmd;
333 wmi_buf_t buf;
334 int32_t len = sizeof(*cmd);
335
336 buf = wmi_buf_alloc(wmi, len);
337 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530338 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530339 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530340 }
341 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
342 WMITLV_SET_HDR(&cmd->tlv_header,
343 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
344 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
345 cmd->vdev_id = vdev_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530346 wmi_mtrace(WMI_VDEV_DOWN_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530347 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530348 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530349 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530350 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530351 }
Govind Singhb53420c2016-03-09 14:32:57 +0530352 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530353
354 return 0;
355}
356
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530357#ifdef CONFIG_MCL
358static inline void copy_channel_info(
359 wmi_vdev_start_request_cmd_fixed_param * cmd,
360 wmi_channel *chan,
361 struct vdev_start_params *req)
362{
363 chan->mhz = req->chan_freq;
364
365 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
366
367 chan->band_center_freq1 = req->band_center_freq1;
368 chan->band_center_freq2 = req->band_center_freq2;
369
370 if (req->is_half_rate)
371 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
372 else if (req->is_quarter_rate)
373 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
374
Naveen Rawat44f2f432016-12-01 12:58:57 -0800375 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530376 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
377 cmd->disable_hw_ack = req->dis_hw_ack;
378 }
379
380 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
381 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
382
383}
384#else
385static inline void copy_channel_info(
386 wmi_vdev_start_request_cmd_fixed_param * cmd,
387 wmi_channel *chan,
388 struct vdev_start_params *req)
389{
390 chan->mhz = req->channel.mhz;
391
392 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
393
394 chan->band_center_freq1 = req->channel.cfreq1;
395 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800396 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530397
398 if (req->channel.half_rate)
399 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
400 else if (req->channel.quarter_rate)
401 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
402
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800403 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
404
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530405 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530406 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530407 cmd->disable_hw_ack = req->disable_hw_ack;
408 }
409
Krishna Rao0b952ea2017-03-20 13:30:10 +0530410 if (req->channel.dfs_set_cfreq2)
411 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
412
Kai Chen4710d462017-12-15 14:06:06 -0800413 /* According to firmware both reg power and max tx power
414 * on set channel power is used and set it to max reg
415 * power from regulatory.
416 */
417 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
418 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530419 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800420 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
421 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
422 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530423
424}
425#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530426/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530427 * send_vdev_start_cmd_tlv() - send vdev start request to fw
428 * @wmi_handle: wmi handle
429 * @req: vdev start params
430 *
431 * Return: QDF status
432 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530433static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530434 struct vdev_start_params *req)
435{
436 wmi_vdev_start_request_cmd_fixed_param *cmd;
437 wmi_buf_t buf;
438 wmi_channel *chan;
439 int32_t len, ret;
440 uint8_t *buf_ptr;
441
442 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
443 buf = wmi_buf_alloc(wmi_handle, len);
444 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530445 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530446 return QDF_STATUS_E_NOMEM;
447 }
448 buf_ptr = (uint8_t *) wmi_buf_data(buf);
449 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
450 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
451 WMITLV_SET_HDR(&cmd->tlv_header,
452 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
453 WMITLV_GET_STRUCT_TLVLEN
454 (wmi_vdev_start_request_cmd_fixed_param));
455 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
456 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
457 cmd->vdev_id = req->vdev_id;
458
459 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530460 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530461
462 cmd->beacon_interval = req->beacon_intval;
463 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530464
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800465 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
466 if (req->bcn_tx_rate_code)
467 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
468
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530469 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530470 cmd->beacon_interval = req->beacon_intval;
471 cmd->dtim_period = req->dtim_period;
472
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530473 /* Copy the SSID */
474 if (req->ssid.length) {
475 if (req->ssid.length < sizeof(cmd->ssid.ssid))
476 cmd->ssid.ssid_len = req->ssid.length;
477 else
478 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
479 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
480 cmd->ssid.ssid_len);
481 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530482
483 if (req->hidden_ssid)
484 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
485
486 if (req->pmf_enabled)
487 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530488 }
489
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700490 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530491 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530492 cmd->preferred_rx_streams = req->preferred_rx_streams;
493 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700494 cmd->cac_duration_ms = req->cac_duration_ms;
495 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700496 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530497
498 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
499 sizeof(wmi_channel));
500 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
501 cmd->num_noa_descriptors *
502 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800503 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530504 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
505 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800506 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
507 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
508 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530509 req->is_dfs, req->beacon_intval, cmd->dtim_period,
510 chan->band_center_freq1, chan->band_center_freq2,
511 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700512 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700513 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800514 req->regdomain, req->he_ops,
515 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530516
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530517 if (req->is_restart) {
518 wmi_mtrace(WMI_VDEV_RESTART_REQUEST_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530519 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
520 WMI_VDEV_RESTART_REQUEST_CMDID);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530521 } else {
522 wmi_mtrace(WMI_VDEV_START_REQUEST_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530523 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
524 WMI_VDEV_START_REQUEST_CMDID);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530525 }
526 if (ret) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530527 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530528 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530529 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530530 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530531
532 return QDF_STATUS_SUCCESS;
533}
534
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530535/**
536 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
537 * @wmi_handle: wmi handle
538 * @restart_params: vdev restart params
539 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530540 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530541 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530542static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530543 struct hidden_ssid_vdev_restart_params *restart_params)
544{
545 wmi_vdev_start_request_cmd_fixed_param *cmd;
546 wmi_buf_t buf;
547 wmi_channel *chan;
548 int32_t len;
549 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530550 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530551
552 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
553 buf = wmi_buf_alloc(wmi_handle, len);
554 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530555 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530556 return QDF_STATUS_E_NOMEM;
557 }
558 buf_ptr = (uint8_t *) wmi_buf_data(buf);
559 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
560 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
561
562 WMITLV_SET_HDR(&cmd->tlv_header,
563 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
564 WMITLV_GET_STRUCT_TLVLEN
565 (wmi_vdev_start_request_cmd_fixed_param));
566
567 WMITLV_SET_HDR(&chan->tlv_header,
568 WMITLV_TAG_STRUC_wmi_channel,
569 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
570
571 cmd->vdev_id = restart_params->session_id;
572 cmd->ssid.ssid_len = restart_params->ssid_len;
573 qdf_mem_copy(cmd->ssid.ssid,
574 restart_params->ssid,
575 cmd->ssid.ssid_len);
576 cmd->flags = restart_params->flags;
577 cmd->requestor_id = restart_params->requestor_id;
578 cmd->disable_hw_ack = restart_params->disable_hw_ack;
579
580 chan->mhz = restart_params->mhz;
581 chan->band_center_freq1 =
582 restart_params->band_center_freq1;
583 chan->band_center_freq2 =
584 restart_params->band_center_freq2;
585 chan->info = restart_params->info;
586 chan->reg_info_1 = restart_params->reg_info_1;
587 chan->reg_info_2 = restart_params->reg_info_2;
588
589 cmd->num_noa_descriptors = 0;
590 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
591 sizeof(wmi_channel));
592 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
593 cmd->num_noa_descriptors *
594 sizeof(wmi_p2p_noa_descriptor));
595
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530596 wmi_mtrace(WMI_VDEV_RESTART_REQUEST_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530597 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
598 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530599 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530600 wmi_buf_free(buf);
601 return QDF_STATUS_E_FAILURE;
602 }
603 return QDF_STATUS_SUCCESS;
604}
605
606
607/**
Govind Singh5eb51532016-03-09 11:34:12 +0530608 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
609 * @wmi: wmi handle
610 * @peer_addr: peer mac address
611 * @param: pointer to hold peer flush tid parameter
612 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -0700613 * Return: 0 for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530614 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530615static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530616 uint8_t peer_addr[IEEE80211_ADDR_LEN],
617 struct peer_flush_params *param)
618{
619 wmi_peer_flush_tids_cmd_fixed_param *cmd;
620 wmi_buf_t buf;
621 int32_t len = sizeof(*cmd);
622
623 buf = wmi_buf_alloc(wmi, len);
624 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530625 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530626 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530627 }
628 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
629 WMITLV_SET_HDR(&cmd->tlv_header,
630 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
631 WMITLV_GET_STRUCT_TLVLEN
632 (wmi_peer_flush_tids_cmd_fixed_param));
633 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
634 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
635 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530636 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530637 peer_addr, param->vdev_id,
638 param->peer_tid_bitmap);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530639 wmi_mtrace(WMI_PEER_FLUSH_TIDS_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530640 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530641 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530642 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530643 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530644 }
645
646 return 0;
647}
648
649/**
650 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
651 * @wmi: wmi handle
652 * @peer_addr: peer mac addr
653 * @vdev_id: vdev id
654 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530655 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530656 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530657static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530658 uint8_t peer_addr[IEEE80211_ADDR_LEN],
659 uint8_t vdev_id)
660{
661 wmi_peer_delete_cmd_fixed_param *cmd;
662 wmi_buf_t buf;
663 int32_t len = sizeof(*cmd);
664 buf = wmi_buf_alloc(wmi, len);
665 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530666 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530667 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530668 }
669 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
670 WMITLV_SET_HDR(&cmd->tlv_header,
671 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
672 WMITLV_GET_STRUCT_TLVLEN
673 (wmi_peer_delete_cmd_fixed_param));
674 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
675 cmd->vdev_id = vdev_id;
676
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800677 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530678 wmi_mtrace(WMI_PEER_DELETE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530679 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530680 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530681 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530682 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530683 }
Govind Singh5eb51532016-03-09 11:34:12 +0530684
685 return 0;
686}
687
688/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530689 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
690 * to target id.
691 * @targ_paramid: Target parameter id to hold the result.
692 * @peer_param_id: host param id.
693 *
694 * Return: QDF_STATUS_SUCCESS for success
695 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
696 */
697#ifdef CONFIG_MCL
698static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
699 uint32_t *targ_paramid,
700 uint32_t peer_param_id)
701{
702 *targ_paramid = peer_param_id;
703 return QDF_STATUS_SUCCESS;
704}
Mohit Khannab9e1e542018-07-24 15:28:04 -0700705
706/**
707 * crash_on_send_peer_rx_reorder_queue_remove_cmd() - crash on reorder queue cmd
708 *
709 * On MCL side, we are suspecting this cmd to trigger drop of ARP
710 * response frames from REO by the FW. This function causes a crash if this
711 * command is sent out by the host, so we can track this issue. Ideally no one
712 * should be calling this API from the MCL side
713 *
714 * Return: None
715 */
716static void crash_on_send_peer_rx_reorder_queue_remove_cmd(void)
717{
718 QDF_BUG(0);
719}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530720#else
721static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
722 uint32_t *targ_paramid,
723 uint32_t peer_param_id)
724{
725 switch (peer_param_id) {
726 case WMI_HOST_PEER_MIMO_PS_STATE:
727 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
728 break;
729 case WMI_HOST_PEER_AMPDU:
730 *targ_paramid = WMI_PEER_AMPDU;
731 break;
732 case WMI_HOST_PEER_AUTHORIZE:
733 *targ_paramid = WMI_PEER_AUTHORIZE;
734 break;
735 case WMI_HOST_PEER_CHWIDTH:
736 *targ_paramid = WMI_PEER_CHWIDTH;
737 break;
738 case WMI_HOST_PEER_NSS:
739 *targ_paramid = WMI_PEER_NSS;
740 break;
741 case WMI_HOST_PEER_USE_4ADDR:
742 *targ_paramid = WMI_PEER_USE_4ADDR;
743 break;
744 case WMI_HOST_PEER_MEMBERSHIP:
745 *targ_paramid = WMI_PEER_MEMBERSHIP;
746 break;
747 case WMI_HOST_PEER_USERPOS:
748 *targ_paramid = WMI_PEER_USERPOS;
749 break;
750 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
751 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
752 break;
753 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
754 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
755 break;
756 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
757 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
758 break;
759 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
760 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
761 break;
762 case WMI_HOST_PEER_PHYMODE:
763 *targ_paramid = WMI_PEER_PHYMODE;
764 break;
765 case WMI_HOST_PEER_USE_FIXED_PWR:
766 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
767 break;
768 case WMI_HOST_PEER_PARAM_FIXED_RATE:
769 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
770 break;
771 case WMI_HOST_PEER_SET_MU_WHITELIST:
772 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
773 break;
774 case WMI_HOST_PEER_SET_MAC_TX_RATE:
775 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
776 break;
777 case WMI_HOST_PEER_SET_MIN_TX_RATE:
778 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
779 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530780 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
781 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
782 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530783 case WMI_HOST_PEER_NSS_VHT160:
784 *targ_paramid = WMI_PEER_NSS_VHT160;
785 break;
786 case WMI_HOST_PEER_NSS_VHT80_80:
787 *targ_paramid = WMI_PEER_NSS_VHT80_80;
788 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530789 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
790 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
791 break;
792 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
793 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
794 break;
795 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
796 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
797 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530798 case WMI_HOST_PEER_PARAM_MU_ENABLE:
799 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
800 break;
801 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
802 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
803 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530804 default:
805 return QDF_STATUS_E_NOSUPPORT;
806 }
807
808 return QDF_STATUS_SUCCESS;
809}
Mohit Khannab9e1e542018-07-24 15:28:04 -0700810
811static void crash_on_send_peer_rx_reorder_queue_remove_cmd(void)
812{
813 /* No-OP */
814}
815
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530816#endif
817/**
Govind Singh5eb51532016-03-09 11:34:12 +0530818 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530819 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530820 * @peer_addr: peer mac address
821 * @param : pointer to hold peer set parameter
822 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530823 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530824 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530825static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530826 uint8_t peer_addr[IEEE80211_ADDR_LEN],
827 struct peer_set_params *param)
828{
829 wmi_peer_set_param_cmd_fixed_param *cmd;
830 wmi_buf_t buf;
831 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530832 uint32_t param_id;
833
834 if (convert_host_peer_id_to_target_id_tlv(&param_id,
835 param->param_id) != QDF_STATUS_SUCCESS)
836 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530837
838 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
839 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530840 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530841 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530842 }
843 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
844 WMITLV_SET_HDR(&cmd->tlv_header,
845 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
846 WMITLV_GET_STRUCT_TLVLEN
847 (wmi_peer_set_param_cmd_fixed_param));
848 cmd->vdev_id = param->vdev_id;
849 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530850 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530851 cmd->param_value = param->param_value;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530852 wmi_mtrace(WMI_PEER_SET_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530853 err = wmi_unified_cmd_send(wmi, buf,
854 sizeof(wmi_peer_set_param_cmd_fixed_param),
855 WMI_PEER_SET_PARAM_CMDID);
856 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530857 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530858 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530859 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530860 }
861
862 return 0;
863}
864
865/**
866 * send_vdev_up_cmd_tlv() - send vdev up command in fw
867 * @wmi: wmi handle
868 * @bssid: bssid
869 * @vdev_up_params: pointer to hold vdev up parameter
870 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530871 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530872 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530873static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530874 uint8_t bssid[IEEE80211_ADDR_LEN],
875 struct vdev_up_params *params)
876{
877 wmi_vdev_up_cmd_fixed_param *cmd;
878 wmi_buf_t buf;
879 int32_t len = sizeof(*cmd);
880
Govind Singhb53420c2016-03-09 14:32:57 +0530881 WMI_LOGD("%s: VDEV_UP", __func__);
882 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530883 params->vdev_id, params->assoc_id, bssid);
884 buf = wmi_buf_alloc(wmi, len);
885 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530886 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530887 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530888 }
889 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
890 WMITLV_SET_HDR(&cmd->tlv_header,
891 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
892 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
893 cmd->vdev_id = params->vdev_id;
894 cmd->vdev_assoc_id = params->assoc_id;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -0700895 cmd->profile_idx = params->profile_idx;
896 cmd->profile_num = params->profile_num;
897 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->trans_bssid, &cmd->trans_bssid);
Govind Singh5eb51532016-03-09 11:34:12 +0530898 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530899 wmi_mtrace(WMI_VDEV_UP_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530900 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530901 WMI_LOGP("%s: Failed to send vdev up command", __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 }
905
906 return 0;
907}
908
909/**
910 * send_peer_create_cmd_tlv() - send peer create command to fw
911 * @wmi: wmi handle
912 * @peer_addr: peer mac address
913 * @peer_type: peer type
914 * @vdev_id: vdev id
915 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530916 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530917 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530918static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530919 struct peer_create_params *param)
920{
921 wmi_peer_create_cmd_fixed_param *cmd;
922 wmi_buf_t buf;
923 int32_t len = sizeof(*cmd);
924
925 buf = wmi_buf_alloc(wmi, len);
926 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530927 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530928 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530929 }
930 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
931 WMITLV_SET_HDR(&cmd->tlv_header,
932 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
933 WMITLV_GET_STRUCT_TLVLEN
934 (wmi_peer_create_cmd_fixed_param));
935 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
936 cmd->peer_type = param->peer_type;
937 cmd->vdev_id = param->vdev_id;
938
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530939 wmi_mtrace(WMI_PEER_CREATE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530940 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530941 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530942 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530943 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530944 }
Govind Singhb53420c2016-03-09 14:32:57 +0530945 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530946 param->vdev_id);
947
948 return 0;
949}
950
951/**
Leo Changeee40872016-09-28 13:43:36 -0700952 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
953 * command to fw
954 * @wmi: wmi handle
955 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
956 *
957 * Return: 0 for success or error code
958 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700959static
Leo Changeee40872016-09-28 13:43:36 -0700960QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
961 struct rx_reorder_queue_setup_params *param)
962{
963 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
964 wmi_buf_t buf;
965 int32_t len = sizeof(*cmd);
966
967 buf = wmi_buf_alloc(wmi, len);
968 if (!buf) {
969 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
970 return QDF_STATUS_E_NOMEM;
971 }
972 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
973 WMITLV_SET_HDR(&cmd->tlv_header,
974 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
975 WMITLV_GET_STRUCT_TLVLEN
976 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
977 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
978 cmd->vdev_id = param->vdev_id;
979 cmd->tid = param->tid;
980 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
981 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
982 cmd->queue_no = param->queue_no;
Gyanranjan Hazarikad6c4d782018-07-25 23:26:16 -0700983 cmd->ba_window_size_valid = param->ba_window_size_valid;
984 cmd->ba_window_size = param->ba_window_size;
985
Leo Changeee40872016-09-28 13:43:36 -0700986
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530987 wmi_mtrace(WMI_PEER_REORDER_QUEUE_SETUP_CMDID, cmd->vdev_id, 0);
Leo Changeee40872016-09-28 13:43:36 -0700988 if (wmi_unified_cmd_send(wmi, buf, len,
989 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
990 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
991 __func__);
992 qdf_nbuf_free(buf);
993 return QDF_STATUS_E_FAILURE;
994 }
995 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
996 param->peer_macaddr, param->vdev_id, param->tid);
997
998 return QDF_STATUS_SUCCESS;
999}
1000
1001/**
1002 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
1003 * command to fw
1004 * @wmi: wmi handle
1005 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
1006 *
1007 * Return: 0 for success or error code
1008 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07001009static
Leo Changeee40872016-09-28 13:43:36 -07001010QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
1011 struct rx_reorder_queue_remove_params *param)
1012{
1013 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
1014 wmi_buf_t buf;
1015 int32_t len = sizeof(*cmd);
1016
Mohit Khannab9e1e542018-07-24 15:28:04 -07001017 crash_on_send_peer_rx_reorder_queue_remove_cmd();
1018
Leo Changeee40872016-09-28 13:43:36 -07001019 buf = wmi_buf_alloc(wmi, len);
1020 if (!buf) {
1021 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
1022 return QDF_STATUS_E_NOMEM;
1023 }
1024 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
1025 wmi_buf_data(buf);
1026 WMITLV_SET_HDR(&cmd->tlv_header,
1027 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
1028 WMITLV_GET_STRUCT_TLVLEN
1029 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
1030 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
1031 cmd->vdev_id = param->vdev_id;
1032 cmd->tid_mask = param->peer_tid_bitmap;
1033
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301034 wmi_mtrace(WMI_PEER_REORDER_QUEUE_REMOVE_CMDID, cmd->vdev_id, 0);
Leo Changeee40872016-09-28 13:43:36 -07001035 if (wmi_unified_cmd_send(wmi, buf, len,
1036 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
1037 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
1038 __func__);
1039 qdf_nbuf_free(buf);
1040 return QDF_STATUS_E_FAILURE;
1041 }
1042 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
1043 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
1044
1045 return QDF_STATUS_SUCCESS;
1046}
1047
1048/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301049 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
1050 * @wmi_handle: wmi handle
1051 * @param: pointer holding peer details
1052 *
1053 * Return: 0 for success or error code
1054 */
1055static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1056 struct peer_add_wds_entry_params *param)
1057{
1058 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
1059 wmi_buf_t buf;
1060 int len = sizeof(*cmd);
1061
1062 buf = wmi_buf_alloc(wmi_handle, len);
1063 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05301064 qdf_print("%s: wmi_buf_alloc failed", __func__);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301065 return QDF_STATUS_E_FAILURE;
1066 }
1067 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
1068 WMITLV_SET_HDR(&cmd->tlv_header,
1069 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
1070 WMITLV_GET_STRUCT_TLVLEN
1071 (wmi_peer_add_wds_entry_cmd_fixed_param));
1072 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
1073 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001074 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1075 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301076
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301077 wmi_mtrace(WMI_PEER_ADD_WDS_ENTRY_CMDID, cmd->vdev_id, 0);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301078 return wmi_unified_cmd_send(wmi_handle, buf, len,
1079 WMI_PEER_ADD_WDS_ENTRY_CMDID);
1080}
1081
1082/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +05301083 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301084 * @wmi_handle: wmi handle
1085 * @param: pointer holding peer details
1086 *
1087 * Return: 0 for success or error code
1088 */
1089static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1090 struct peer_del_wds_entry_params *param)
1091{
1092 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
1093 wmi_buf_t buf;
1094 int len = sizeof(*cmd);
1095
1096 buf = wmi_buf_alloc(wmi_handle, len);
1097 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05301098 qdf_print("%s: wmi_buf_alloc failed", __func__);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301099 return QDF_STATUS_E_NOMEM;
1100 }
1101 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1102 WMITLV_SET_HDR(&cmd->tlv_header,
1103 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
1104 WMITLV_GET_STRUCT_TLVLEN
1105 (wmi_peer_remove_wds_entry_cmd_fixed_param));
1106 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001107 cmd->vdev_id = param->vdev_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301108 wmi_mtrace(WMI_PEER_REMOVE_WDS_ENTRY_CMDID, cmd->vdev_id, 0);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301109 return wmi_unified_cmd_send(wmi_handle, buf, len,
1110 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
1111}
1112
1113/**
1114 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
1115 * @wmi_handle: wmi handle
1116 * @param: pointer holding peer details
1117 *
1118 * Return: 0 for success or error code
1119 */
1120static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
1121 struct peer_update_wds_entry_params *param)
1122{
1123 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
1124 wmi_buf_t buf;
1125 int len = sizeof(*cmd);
1126
1127 buf = wmi_buf_alloc(wmi_handle, len);
1128 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05301129 qdf_print("%s: wmi_buf_alloc failed", __func__);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301130 return QDF_STATUS_E_NOMEM;
1131 }
1132
1133 /* wmi_buf_alloc returns zeroed command buffer */
1134 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
1135 WMITLV_SET_HDR(&cmd->tlv_header,
1136 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
1137 WMITLV_GET_STRUCT_TLVLEN
1138 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001139 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1140 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301141 if (param->wds_macaddr)
1142 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
1143 &cmd->wds_macaddr);
1144 if (param->peer_macaddr)
1145 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1146 &cmd->peer_macaddr);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301147 wmi_mtrace(WMI_PEER_UPDATE_WDS_ENTRY_CMDID, cmd->vdev_id, 0);
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301148 return wmi_unified_cmd_send(wmi_handle, buf, len,
1149 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1150}
1151
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001152/**
1153 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1154 * @wmi_handle: wmi handle
1155 * @param: pointer to get tpc config params
1156 *
1157 * Return: 0 for success or error code
1158 */
1159static QDF_STATUS
1160send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1161 uint32_t param)
1162{
1163 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1164 wmi_buf_t buf;
1165 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1166
1167 buf = wmi_buf_alloc(wmi_handle, len);
1168 if (!buf) {
1169 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1170 return QDF_STATUS_E_NOMEM;
1171 }
1172 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1173 WMITLV_SET_HDR(&cmd->tlv_header,
1174 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1175 WMITLV_GET_STRUCT_TLVLEN
1176 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1177
1178 cmd->param = param;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301179 wmi_mtrace(WMI_PDEV_GET_TPC_CONFIG_CMDID, NO_SESSION, 0);
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001180 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1181 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1182 WMI_LOGE("Send pdev get tpc config cmd failed");
1183 wmi_buf_free(buf);
1184 return QDF_STATUS_E_FAILURE;
1185
1186 }
1187 WMI_LOGD("%s:send success", __func__);
1188
1189 return QDF_STATUS_SUCCESS;
1190}
1191
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301192#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301193/**
Govind Singh5eb51532016-03-09 11:34:12 +05301194 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1195 * @wmi_handle: wmi handle
1196 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301197 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301198 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301199 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301200 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301201static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301202 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301203{
1204 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1205 wmi_buf_t buf;
1206 int32_t len = sizeof(*cmd);
1207
Govind Singhb53420c2016-03-09 14:32:57 +05301208 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301209
1210 buf = wmi_buf_alloc(wmi_handle, len);
1211 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301212 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301213 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301214 }
1215
1216 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1217 WMITLV_SET_HDR(&cmd->tlv_header,
1218 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1219 WMITLV_GET_STRUCT_TLVLEN
1220 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301221 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301222 cmd->enable = value;
1223
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301224 wmi_mtrace(WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301225 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1226 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301227 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301228 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301229 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301230 }
1231
1232 return 0;
1233}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301234#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301235
1236/**
1237 * send_pdev_utf_cmd_tlv() - send utf command to fw
1238 * @wmi_handle: wmi handle
1239 * @param: pointer to pdev_utf_params
1240 * @mac_id: mac id to have radio context
1241 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301242 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301243 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301244static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301245send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1246 struct pdev_utf_params *param,
1247 uint8_t mac_id)
1248{
1249 wmi_buf_t buf;
1250 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001251 /* if param->len is 0 no data is sent, return error */
1252 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301253 static uint8_t msgref = 1;
1254 uint8_t segNumber = 0, segInfo, numSegments;
1255 uint16_t chunk_len, total_bytes;
1256 uint8_t *bufpos;
1257 struct seg_hdr_info segHdrInfo;
1258
1259 bufpos = param->utf_payload;
1260 total_bytes = param->len;
1261 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1262 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1263 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1264
1265 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1266 numSegments++;
1267
1268 while (param->len) {
1269 if (param->len > MAX_WMI_UTF_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -07001270 chunk_len = MAX_WMI_UTF_LEN; /* MAX message */
Govind Singh5eb51532016-03-09 11:34:12 +05301271 else
1272 chunk_len = param->len;
1273
1274 buf = wmi_buf_alloc(wmi_handle,
1275 (chunk_len + sizeof(segHdrInfo) +
1276 WMI_TLV_HDR_SIZE));
1277 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301278 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301279 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301280 }
1281
1282 cmd = (uint8_t *) wmi_buf_data(buf);
1283
1284 segHdrInfo.len = total_bytes;
1285 segHdrInfo.msgref = msgref;
1286 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1287 segHdrInfo.segmentInfo = segInfo;
1288 segHdrInfo.pad = 0;
1289
Govind Singhb53420c2016-03-09 14:32:57 +05301290 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301291 " segHdrInfo.segmentInfo = %d",
1292 __func__, segHdrInfo.len, segHdrInfo.msgref,
1293 segHdrInfo.segmentInfo);
1294
Govind Singhb53420c2016-03-09 14:32:57 +05301295 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301296 "chunk len %d", __func__, total_bytes, segNumber,
1297 numSegments, chunk_len);
1298
1299 segNumber++;
1300
1301 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1302 (chunk_len + sizeof(segHdrInfo)));
1303 cmd += WMI_TLV_HDR_SIZE;
1304 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1305 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1306
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301307 wmi_mtrace(WMI_PDEV_UTF_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301308 ret = wmi_unified_cmd_send(wmi_handle, buf,
1309 (chunk_len + sizeof(segHdrInfo) +
1310 WMI_TLV_HDR_SIZE),
1311 WMI_PDEV_UTF_CMDID);
1312
Govind Singh67922e82016-04-01 16:48:57 +05301313 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301314 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301315 wmi_buf_free(buf);
1316 break;
1317 }
1318
1319 param->len -= chunk_len;
1320 bufpos += chunk_len;
1321 }
1322
1323 msgref++;
1324
1325 return ret;
1326}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301327#ifdef CONFIG_MCL
1328static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1329 uint32_t host_param)
1330{
1331 return host_param;
1332}
1333#else
1334static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1335 uint32_t host_param)
1336{
1337 if (host_param < wmi_pdev_param_max)
1338 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301339
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301340 return WMI_UNAVAILABLE_PARAM;
1341}
1342#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301343/**
1344 * send_pdev_param_cmd_tlv() - set pdev parameters
1345 * @wmi_handle: wmi handle
1346 * @param: pointer to pdev parameter
1347 * @mac_id: radio context
1348 *
1349 * Return: 0 on success, errno on failure
1350 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301351static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301352send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1353 struct pdev_params *param,
1354 uint8_t mac_id)
1355{
Govind Singh67922e82016-04-01 16:48:57 +05301356 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301357 wmi_pdev_set_param_cmd_fixed_param *cmd;
1358 wmi_buf_t buf;
1359 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301360 uint32_t pdev_param;
1361
1362 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1363 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1364 WMI_LOGW("%s: Unavailable param %d\n",
1365 __func__, param->param_id);
1366 return QDF_STATUS_E_INVAL;
1367 }
Govind Singh5eb51532016-03-09 11:34:12 +05301368
1369 buf = wmi_buf_alloc(wmi_handle, len);
1370 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301371 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301372 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301373 }
1374 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1375 WMITLV_SET_HDR(&cmd->tlv_header,
1376 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1377 WMITLV_GET_STRUCT_TLVLEN
1378 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301379 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301380 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301381 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301382 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301383 param->param_value);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301384 wmi_mtrace(WMI_PDEV_SET_PARAM_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301385 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1386 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301387 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301388 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301389 wmi_buf_free(buf);
1390 }
1391 return ret;
1392}
1393
1394/**
1395 * send_suspend_cmd_tlv() - WMI suspend function
1396 * @param wmi_handle : handle to WMI.
1397 * @param param : pointer to hold suspend parameter
1398 * @mac_id: radio context
1399 *
1400 * Return 0 on success and -ve on failure.
1401 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301402static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301403 struct suspend_params *param,
1404 uint8_t mac_id)
1405{
1406 wmi_pdev_suspend_cmd_fixed_param *cmd;
1407 wmi_buf_t wmibuf;
1408 uint32_t len = sizeof(*cmd);
1409 int32_t ret;
1410
1411 /*
Jeff Johnson19a59fe2018-05-06 16:10:43 -07001412 * send the command to Target to ignore the
Govind Singh5eb51532016-03-09 11:34:12 +05301413 * PCIE reset so as to ensure that Host and target
1414 * states are in sync
1415 */
1416 wmibuf = wmi_buf_alloc(wmi_handle, len);
1417 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301418 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301419
1420 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1421 WMITLV_SET_HDR(&cmd->tlv_header,
1422 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1423 WMITLV_GET_STRUCT_TLVLEN
1424 (wmi_pdev_suspend_cmd_fixed_param));
1425 if (param->disable_target_intr)
1426 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1427 else
1428 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301429
1430 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1431
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301432 wmi_mtrace(WMI_PDEV_SUSPEND_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301433 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1434 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301435 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301436 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301437 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301438 }
1439
1440 return ret;
1441}
1442
1443/**
1444 * send_resume_cmd_tlv() - WMI resume function
1445 * @param wmi_handle : handle to WMI.
1446 * @mac_id: radio context
1447 *
1448 * Return: 0 on success and -ve on failure.
1449 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301450static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301451 uint8_t mac_id)
1452{
1453 wmi_buf_t wmibuf;
1454 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301455 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301456
1457 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1458 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301459 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301460 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1461 WMITLV_SET_HDR(&cmd->tlv_header,
1462 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1463 WMITLV_GET_STRUCT_TLVLEN
1464 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301465 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301466 wmi_mtrace(WMI_PDEV_RESUME_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301467 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1468 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301469 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301470 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301471 wmi_buf_free(wmibuf);
1472 }
1473
1474 return ret;
1475}
1476
Will Huang422ac9a2017-11-17 13:19:16 +08001477#ifdef FEATURE_WLAN_D0WOW
1478/**
1479 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1480 * @param wmi_handle: handle to WMI.
1481 * @mac_id: radio context
1482 *
1483 * Return: 0 on success and error code on failure.
1484 */
1485static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1486 uint8_t mac_id)
1487{
1488 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1489 wmi_buf_t buf;
1490 int32_t len;
1491 QDF_STATUS status;
1492
1493 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1494
1495 buf = wmi_buf_alloc(wmi_handle, len);
1496 if (!buf) {
1497 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1498 return QDF_STATUS_E_NOMEM;
1499 }
1500 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1501 WMITLV_SET_HDR(&cmd->tlv_header,
1502 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1503 WMITLV_GET_STRUCT_TLVLEN
1504 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1505
1506 cmd->enable = true;
1507
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301508 wmi_mtrace(WMI_D0_WOW_ENABLE_DISABLE_CMDID, NO_SESSION, 0);
Will Huang422ac9a2017-11-17 13:19:16 +08001509 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1510 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1511 if (QDF_IS_STATUS_ERROR(status))
1512 wmi_buf_free(buf);
1513
1514 return status;
1515}
1516
1517/**
1518 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1519 * @param wmi_handle: handle to WMI.
1520 * @mac_id: radio context
1521 *
1522 * Return: 0 on success and error code on failure.
1523 */
1524static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1525 uint8_t mac_id)
1526{
1527 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1528 wmi_buf_t buf;
1529 int32_t len;
1530 QDF_STATUS status;
1531
1532 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1533
1534 buf = wmi_buf_alloc(wmi_handle, len);
1535 if (!buf) {
1536 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1537 return QDF_STATUS_E_NOMEM;
1538 }
1539 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1540 WMITLV_SET_HDR(&cmd->tlv_header,
1541 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1542 WMITLV_GET_STRUCT_TLVLEN
1543 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1544
1545 cmd->enable = false;
1546
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301547 wmi_mtrace(WMI_D0_WOW_ENABLE_DISABLE_CMDID, NO_SESSION, 0);
Will Huang422ac9a2017-11-17 13:19:16 +08001548 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1549 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1550 if (QDF_IS_STATUS_ERROR(status))
1551 wmi_buf_free(buf);
1552
1553 return status;
1554}
1555#endif
1556
Govind Singh5eb51532016-03-09 11:34:12 +05301557/**
1558 * send_wow_enable_cmd_tlv() - WMI wow enable function
1559 * @param wmi_handle : handle to WMI.
1560 * @param param : pointer to hold wow enable parameter
1561 * @mac_id: radio context
1562 *
1563 * Return: 0 on success and -ve on failure.
1564 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301565static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301566 struct wow_cmd_params *param,
1567 uint8_t mac_id)
1568{
1569 wmi_wow_enable_cmd_fixed_param *cmd;
1570 wmi_buf_t buf;
1571 int32_t len;
1572 int32_t ret;
1573
1574 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1575
1576 buf = wmi_buf_alloc(wmi_handle, len);
1577 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301578 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1579 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301580 }
1581 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1582 WMITLV_SET_HDR(&cmd->tlv_header,
1583 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1584 WMITLV_GET_STRUCT_TLVLEN
1585 (wmi_wow_enable_cmd_fixed_param));
1586 cmd->enable = param->enable;
1587 if (param->can_suspend_link)
1588 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1589 else
1590 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001591 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301592
Govind Singhb53420c2016-03-09 14:32:57 +05301593 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301594 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1595 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1596
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301597 wmi_mtrace(WMI_WOW_ENABLE_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301598 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1599 WMI_WOW_ENABLE_CMDID);
1600 if (ret)
1601 wmi_buf_free(buf);
1602
1603 return ret;
1604}
1605
1606/**
1607 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301608 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301609 * @peer_addr: peer mac address
1610 * @param: pointer to ap_ps parameter structure
1611 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301612 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301613 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301614static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301615 uint8_t *peer_addr,
1616 struct ap_ps_params *param)
1617{
1618 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1619 wmi_buf_t buf;
1620 int32_t err;
1621
1622 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1623 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301624 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301625 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301626 }
1627 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1628 WMITLV_SET_HDR(&cmd->tlv_header,
1629 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1630 WMITLV_GET_STRUCT_TLVLEN
1631 (wmi_ap_ps_peer_cmd_fixed_param));
1632 cmd->vdev_id = param->vdev_id;
1633 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1634 cmd->param = param->param;
1635 cmd->value = param->value;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301636 wmi_mtrace(WMI_AP_PS_PEER_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301637 err = wmi_unified_cmd_send(wmi_handle, buf,
1638 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1639 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301640 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301641 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301642 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301643 }
1644
1645 return 0;
1646}
1647
1648/**
1649 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301650 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301651 * @peer_addr: peer mac address
1652 * @param: pointer to sta_ps parameter structure
1653 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301654 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301655 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301656static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301657 struct sta_ps_params *param)
1658{
1659 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1660 wmi_buf_t buf;
1661 int32_t len = sizeof(*cmd);
1662
1663 buf = wmi_buf_alloc(wmi_handle, len);
1664 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301665 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301666 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301667 }
1668
1669 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1670 WMITLV_SET_HDR(&cmd->tlv_header,
1671 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1672 WMITLV_GET_STRUCT_TLVLEN
1673 (wmi_sta_powersave_param_cmd_fixed_param));
1674 cmd->vdev_id = param->vdev_id;
1675 cmd->param = param->param;
1676 cmd->value = param->value;
1677
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301678 wmi_mtrace(WMI_STA_POWERSAVE_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301679 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1680 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301681 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301682 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301683 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301684 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301685 }
1686
1687 return 0;
1688}
1689
1690/**
1691 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301692 * @wmi_handle: wmi handle
Jeff Johnsonbbd428c2018-05-06 17:02:16 -07001693 * @param: ponirt to crash inject parameter structure
Govind Singh5eb51532016-03-09 11:34:12 +05301694 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301695 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301696 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301697static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301698 struct crash_inject *param)
1699{
1700 int32_t ret = 0;
1701 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1702 uint16_t len = sizeof(*cmd);
1703 wmi_buf_t buf;
1704
1705 buf = wmi_buf_alloc(wmi_handle, len);
1706 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301707 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301708 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301709 }
1710
1711 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1712 WMITLV_SET_HDR(&cmd->tlv_header,
1713 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1714 WMITLV_GET_STRUCT_TLVLEN
1715 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1716 cmd->type = param->type;
1717 cmd->delay_time_ms = param->delay_time_ms;
1718
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301719 wmi_mtrace(WMI_FORCE_FW_HANG_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301720 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1721 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301722 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301723 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301724 __func__, ret);
1725 wmi_buf_free(buf);
1726 }
1727
1728 return ret;
1729}
1730
Wen Gongca174012018-04-20 16:56:28 +08001731#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +05301732/**
1733 * send_dbglog_cmd_tlv() - set debug log level
1734 * @param wmi_handle : handle to WMI.
1735 * @param param : pointer to hold dbglog level parameter
1736 *
1737 * Return: 0 on success and -ve on failure.
1738 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301739 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301740send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1741 struct dbglog_params *dbglog_param)
1742{
1743 wmi_buf_t buf;
1744 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001745 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301746 int32_t i;
1747 int32_t len;
1748 int8_t *buf_ptr;
1749 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1750
Alok Kumar240afea2017-08-30 14:45:34 +05301751 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301752
1753 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1754 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1755 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1756 buf = wmi_buf_alloc(wmi_handle, len);
1757 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001758 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301759
1760 configmsg =
1761 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1762 buf_ptr = (int8_t *) configmsg;
1763 WMITLV_SET_HDR(&configmsg->tlv_header,
1764 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1765 WMITLV_GET_STRUCT_TLVLEN
1766 (wmi_debug_log_config_cmd_fixed_param));
1767 configmsg->dbg_log_param = dbglog_param->param;
1768 configmsg->value = dbglog_param->val;
1769 /* Filling in the data part of second tlv -- should
1770 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301771 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301772 sizeof
1773 (wmi_debug_log_config_cmd_fixed_param)
1774 + WMI_TLV_HDR_SIZE);
1775 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1776 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301777 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301778 if (dbglog_param->module_id_bitmap) {
1779 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1780 module_id_bitmap_array[i] =
1781 dbglog_param->module_id_bitmap[i];
1782 }
1783 }
1784
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301785 wmi_mtrace(WMI_DBGLOG_CFG_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301786 status = wmi_unified_cmd_send(wmi_handle, buf,
1787 len, WMI_DBGLOG_CFG_CMDID);
1788
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001789 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301790 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301791
1792 return status;
1793}
Wen Gongca174012018-04-20 16:56:28 +08001794#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301795
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301796#ifdef CONFIG_MCL
1797static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1798 uint32_t host_param)
1799{
1800 return host_param;
1801}
1802#else
1803static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1804 uint32_t host_param)
1805{
1806 if (host_param < wmi_vdev_param_max)
1807 return wmi_handle->vdev_param[host_param];
1808
1809 return WMI_UNAVAILABLE_PARAM;
1810}
1811#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301812/**
1813 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1814 * @param wmi_handle : handle to WMI.
1815 * @param macaddr : MAC address
1816 * @param param : pointer to hold vdev set parameter
1817 *
1818 * Return: 0 on success and -ve on failure.
1819 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301820static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301821 struct vdev_set_params *param)
1822{
Govind Singh67922e82016-04-01 16:48:57 +05301823 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301824 wmi_vdev_set_param_cmd_fixed_param *cmd;
1825 wmi_buf_t buf;
1826 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301827 uint32_t vdev_param;
1828
1829 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1830 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1831 WMI_LOGW("%s:Vdev param %d not available", __func__,
1832 param->param_id);
1833 return QDF_STATUS_E_INVAL;
1834
1835 }
Govind Singh5eb51532016-03-09 11:34:12 +05301836
1837 buf = wmi_buf_alloc(wmi_handle, len);
1838 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301839 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301840 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301841 }
1842 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1843 WMITLV_SET_HDR(&cmd->tlv_header,
1844 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1845 WMITLV_GET_STRUCT_TLVLEN
1846 (wmi_vdev_set_param_cmd_fixed_param));
1847 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301848 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301849 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301850 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001851 cmd->vdev_id, cmd->param_id, cmd->param_value);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301852 wmi_mtrace(WMI_VDEV_SET_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301853 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1854 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301855 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301856 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301857 wmi_buf_free(buf);
1858 }
1859
1860 return ret;
1861}
1862
1863/**
1864 * send_stats_request_cmd_tlv() - WMI request stats function
1865 * @param wmi_handle : handle to WMI.
1866 * @param macaddr : MAC address
1867 * @param param : pointer to hold stats request parameter
1868 *
1869 * Return: 0 on success and -ve on failure.
1870 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301871static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301872 uint8_t macaddr[IEEE80211_ADDR_LEN],
1873 struct stats_request_params *param)
1874{
Govind Singhd3156eb2016-02-26 17:50:39 +05301875 int32_t ret;
1876 wmi_request_stats_cmd_fixed_param *cmd;
1877 wmi_buf_t buf;
1878 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1879
1880 buf = wmi_buf_alloc(wmi_handle, len);
1881 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301882 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1883 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301884 }
1885
1886 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1887 WMITLV_SET_HDR(&cmd->tlv_header,
1888 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1889 WMITLV_GET_STRUCT_TLVLEN
1890 (wmi_request_stats_cmd_fixed_param));
1891 cmd->stats_id = param->stats_id;
1892 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301893 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1894 param->pdev_id);
1895 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001896
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301897 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1898 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001899
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301900 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001901 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1902 WMI_REQUEST_STATS_CMDID);
1903
Govind Singhd3156eb2016-02-26 17:50:39 +05301904 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301905 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301906 wmi_buf_free(buf);
1907 }
1908
1909 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301910}
1911
Govind Singh87542482016-06-08 19:40:11 +05301912#ifdef CONFIG_WIN
1913/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001914 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301915 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001916 * @param PKTLOG_EVENT : packet log event
1917 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301918 *
1919 * Return: 0 on success and -ve on failure.
1920 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301921static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001922 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301923{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001924 int32_t ret;
1925 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1926 wmi_buf_t buf;
1927 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1928
1929 buf = wmi_buf_alloc(wmi_handle, len);
1930 if (!buf) {
1931 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1932 return -QDF_STATUS_E_NOMEM;
1933 }
1934
1935 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1936 WMITLV_SET_HDR(&cmd->tlv_header,
1937 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1938 WMITLV_GET_STRUCT_TLVLEN
1939 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1940 cmd->evlist = PKTLOG_EVENT;
1941 cmd->pdev_id = mac_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301942 wmi_mtrace(WMI_PDEV_PKTLOG_ENABLE_CMDID, cmd->pdev_id, 0);
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001943 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1944 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1945 if (ret) {
1946 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1947 wmi_buf_free(buf);
1948 }
1949
1950 return ret;
1951}
1952
1953/**
1954 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1955 * @param wmi_handle : handle to WMI.
1956 * @mac_id: mac id to have radio context
1957 *
1958 * Return: 0 on success and -ve on failure.
1959 */
1960static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001961 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001962{
1963 int32_t ret;
1964 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1965 wmi_buf_t buf;
1966 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1967
1968 buf = wmi_buf_alloc(wmi_handle, len);
1969 if (!buf) {
1970 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1971 return -QDF_STATUS_E_NOMEM;
1972 }
1973
1974 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1975 WMITLV_SET_HDR(&cmd->tlv_header,
1976 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1977 WMITLV_GET_STRUCT_TLVLEN
1978 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1979 cmd->pdev_id = mac_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301980 wmi_mtrace(WMI_PDEV_PKTLOG_DISABLE_CMDID, cmd->pdev_id, 0);
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001981 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1982 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1983 if (ret) {
1984 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1985 wmi_buf_free(buf);
1986 }
1987
1988 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301989}
1990#else
Govind Singh5eb51532016-03-09 11:34:12 +05301991/**
Keyur Parekhde522342017-08-18 14:01:05 -07001992 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1993 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301994 * @param wmi_handle : handle to WMI.
1995 * @param macaddr : MAC address
1996 * @param param : pointer to hold stats request parameter
1997 *
1998 * Return: 0 on success and -ve on failure.
1999 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302000static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302001 uint8_t macaddr[IEEE80211_ADDR_LEN],
2002 struct packet_enable_params *param)
2003{
2004 return 0;
2005}
Keyur Parekhde522342017-08-18 14:01:05 -07002006/**
2007 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
2008 * packet-log
2009 * @param wmi_handle : handle to WMI.
2010 * @mac_id: mac id to have radio context
2011 *
2012 * Return: 0 on success and -ve on failure.
2013 */
2014static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
2015 uint8_t mac_id)
2016{
2017 return 0;
2018}
Govind Singh87542482016-06-08 19:40:11 +05302019#endif
Govind Singh5eb51532016-03-09 11:34:12 +05302020
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05302021#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
2022/**
2023 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
2024 * sync time between bwtween host and firmware
2025 * @param wmi_handle : handle to WMI.
2026 *
2027 * Return: None
2028 */
2029static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
2030{
2031 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07002032 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05302033 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
2034 int32_t len;
2035 qdf_time_t time_ms;
2036
2037 len = sizeof(*time_stamp);
2038 buf = wmi_buf_alloc(wmi_handle, len);
2039
2040 if (!buf) {
2041 WMI_LOGP(FL("wmi_buf_alloc failed"));
2042 return;
2043 }
2044 time_stamp =
2045 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
2046 (wmi_buf_data(buf));
2047 WMITLV_SET_HDR(&time_stamp->tlv_header,
2048 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
2049 WMITLV_GET_STRUCT_TLVLEN(
2050 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
2051
2052 time_ms = qdf_get_time_of_the_day_ms();
2053 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
2054 time_stamp->time_stamp_low = time_ms &
2055 WMI_FW_TIME_STAMP_LOW_MASK;
2056 /*
2057 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
2058 * wont exceed 27 bit
2059 */
2060 time_stamp->time_stamp_high = 0;
2061 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
2062 time_stamp->mode, time_stamp->time_stamp_low,
2063 time_stamp->time_stamp_high);
2064
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302065 wmi_mtrace(WMI_DBGLOG_TIME_STAMP_SYNC_CMDID, NO_SESSION, 0);
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05302066 status = wmi_unified_cmd_send(wmi_handle, buf,
2067 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
2068 if (status) {
2069 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
2070 wmi_buf_free(buf);
2071 }
2072
2073}
2074
Subrat Mishrad7c7a562017-09-27 14:41:20 +05302075#ifdef WLAN_SUPPORT_FILS
2076/**
2077 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
2078 * @wmi_handle: wmi handle
2079 * @evt_buf: pointer to event buffer
2080 * @vdev_id: pointer to hold vdev id
2081 *
2082 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
2083 */
2084static QDF_STATUS
2085extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
2086 void *evt_buf, uint32_t *vdev_id)
2087{
2088 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
2089 wmi_host_swfda_event_fixed_param *swfda_event;
2090
2091 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
2092 if (!param_buf) {
2093 WMI_LOGE("Invalid swfda event buffer");
2094 return QDF_STATUS_E_INVAL;
2095 }
2096 swfda_event = param_buf->fixed_param;
2097 *vdev_id = swfda_event->vdev_id;
2098
2099 return QDF_STATUS_SUCCESS;
2100}
2101
2102/**
2103 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
2104 * @wmi_handle: wmi handle
2105 * @param: pointer to hold FILS discovery enable param
2106 *
2107 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
2108 */
2109static QDF_STATUS
2110send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
2111 struct config_fils_params *param)
2112{
2113 wmi_enable_fils_cmd_fixed_param *cmd;
2114 wmi_buf_t buf;
2115 QDF_STATUS status;
2116 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
2117
2118 buf = wmi_buf_alloc(wmi_handle, len);
2119 if (!buf) {
2120 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2121 return QDF_STATUS_E_NOMEM;
2122 }
2123 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
2124 WMITLV_SET_HDR(&cmd->tlv_header,
2125 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
2126 WMITLV_GET_STRUCT_TLVLEN(
2127 wmi_enable_fils_cmd_fixed_param));
2128 cmd->vdev_id = param->vdev_id;
2129 cmd->fd_period = param->fd_period;
2130 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
2131 param->fd_period, param->vdev_id);
2132
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302133 wmi_mtrace(WMI_ENABLE_FILS_CMDID, cmd->vdev_id, 0);
Subrat Mishrad7c7a562017-09-27 14:41:20 +05302134 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2135 WMI_ENABLE_FILS_CMDID);
2136 if (status != QDF_STATUS_SUCCESS) {
2137 wmi_buf_free(buf);
2138 return QDF_STATUS_E_FAILURE;
2139 }
2140
2141 return QDF_STATUS_SUCCESS;
2142}
2143
2144/**
2145 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
2146 * @wmi_handle: wmi handle
2147 * @param: pointer to hold FD send cmd parameter
2148 *
2149 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
2150 */
2151static QDF_STATUS
2152send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
2153 struct fd_params *param)
2154{
2155 QDF_STATUS ret;
2156 wmi_fd_send_from_host_cmd_fixed_param *cmd;
2157 wmi_buf_t wmi_buf;
2158 qdf_dma_addr_t dma_addr;
2159
2160 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2161 if (!wmi_buf) {
2162 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2163 return QDF_STATUS_E_NOMEM;
2164 }
2165 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2166 WMITLV_SET_HDR(&cmd->tlv_header,
2167 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2168 WMITLV_GET_STRUCT_TLVLEN(
2169 wmi_fd_send_from_host_cmd_fixed_param));
2170 cmd->vdev_id = param->vdev_id;
2171 cmd->data_len = qdf_nbuf_len(param->wbuf);
2172 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2173 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2174 cmd->frame_ctrl = param->frame_ctrl;
2175
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302176 wmi_mtrace(WMI_PDEV_SEND_FD_CMDID, cmd->vdev_id, 0);
Subrat Mishrad7c7a562017-09-27 14:41:20 +05302177 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2178 WMI_PDEV_SEND_FD_CMDID);
2179 if (ret != QDF_STATUS_SUCCESS) {
2180 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2181 __func__, ret);
2182 wmi_buf_free(wmi_buf);
2183 }
2184
2185 return ret;
2186}
2187#endif /* WLAN_SUPPORT_FILS */
2188
Sathish Kumarfd347372017-02-13 12:29:09 +05302189static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302190 struct beacon_params *param)
2191{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302192 QDF_STATUS ret;
2193 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2194 wmi_buf_t wmi_buf;
2195 qdf_dma_addr_t dma_addr;
2196 uint32_t dtim_flag = 0;
2197
2198 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2199 if (!wmi_buf) {
2200 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2201 return QDF_STATUS_E_NOMEM;
2202 }
2203 if (param->is_dtim_count_zero) {
2204 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2205 if (param->is_bitctl_reqd) {
2206 /* deliver CAB traffic in next DTIM beacon */
2207 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2208 }
2209 }
2210 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2211 WMITLV_SET_HDR(&cmd->tlv_header,
2212 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2213 WMITLV_GET_STRUCT_TLVLEN
2214 (wmi_bcn_send_from_host_cmd_fixed_param));
2215 cmd->vdev_id = param->vdev_id;
2216 cmd->data_len = qdf_nbuf_len(param->wbuf);
2217 cmd->frame_ctrl = param->frame_ctrl;
2218 cmd->dtim_flag = dtim_flag;
2219 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2220 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2221#if defined(HTT_PADDR64)
2222 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2223#endif
2224 cmd->bcn_antenna = param->bcn_txant;
2225
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302226 wmi_mtrace(WMI_PDEV_SEND_BCN_CMDID, cmd->vdev_id, 0);
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302227 ret = wmi_unified_cmd_send(wmi_handle,
2228 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2229 if (ret != QDF_STATUS_SUCCESS) {
2230 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2231 wmi_buf_free(wmi_buf);
2232 }
2233
2234 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302235}
2236
2237/**
2238 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2239 * @param wmi_handle : handle to WMI.
2240 * @param param : pointer to hold beacon send cmd parameter
2241 *
2242 * Return: 0 on success and -ve on failure.
2243 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302244static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302245 struct beacon_tmpl_params *param)
2246{
2247 int32_t ret;
2248 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2249 wmi_bcn_prb_info *bcn_prb_info;
2250 wmi_buf_t wmi_buf;
2251 uint8_t *buf_ptr;
2252 uint32_t wmi_buf_len;
2253
2254 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2255 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2256 param->tmpl_len_aligned;
2257 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2258 if (!wmi_buf) {
2259 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2260 return QDF_STATUS_E_NOMEM;
2261 }
2262 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2263 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2264 WMITLV_SET_HDR(&cmd->tlv_header,
2265 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2266 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2267 cmd->vdev_id = param->vdev_id;
2268 cmd->tim_ie_offset = param->tim_ie_offset;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -07002269 cmd->mbssid_ie_offset = param->mbssid_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302270 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2271 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Subrat Mishraa667b1c2018-08-02 15:02:04 +05302272 cmd->esp_ie_offset = param->esp_ie_offset;
Govind Singh87542482016-06-08 19:40:11 +05302273 cmd->buf_len = param->tmpl_len;
2274 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2275
2276 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2277 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2278 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2279 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2280 bcn_prb_info->caps = 0;
2281 bcn_prb_info->erp = 0;
2282 buf_ptr += sizeof(wmi_bcn_prb_info);
2283
2284 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2285 buf_ptr += WMI_TLV_HDR_SIZE;
2286 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2287
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302288 wmi_mtrace(WMI_BCN_TMPL_CMDID, cmd->vdev_id, 0);
Govind Singh87542482016-06-08 19:40:11 +05302289 ret = wmi_unified_cmd_send(wmi_handle,
2290 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2291 if (ret) {
2292 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2293 wmi_buf_free(wmi_buf);
2294 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302295
Govind Singh87542482016-06-08 19:40:11 +05302296 return 0;
2297}
Govind Singh5eb51532016-03-09 11:34:12 +05302298
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302299#ifdef CONFIG_MCL
2300static inline void copy_peer_flags_tlv(
2301 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2302 struct peer_assoc_params *param)
2303{
2304 cmd->peer_flags = param->peer_flags;
2305}
2306#else
2307static inline void copy_peer_flags_tlv(
2308 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2309 struct peer_assoc_params *param)
2310{
2311 /*
2312 * The target only needs a subset of the flags maintained in the host.
2313 * Just populate those flags and send it down
2314 */
2315 cmd->peer_flags = 0;
2316
2317 /*
2318 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2319 */
2320 if (param->is_wme_set) {
2321
2322 if (param->qos_flag)
2323 cmd->peer_flags |= WMI_PEER_QOS;
2324 if (param->apsd_flag)
2325 cmd->peer_flags |= WMI_PEER_APSD;
2326 if (param->ht_flag)
2327 cmd->peer_flags |= WMI_PEER_HT;
2328 if (param->bw_40)
2329 cmd->peer_flags |= WMI_PEER_40MHZ;
2330 if (param->bw_80)
2331 cmd->peer_flags |= WMI_PEER_80MHZ;
2332 if (param->bw_160)
2333 cmd->peer_flags |= WMI_PEER_160MHZ;
2334
2335 /* Typically if STBC is enabled for VHT it should be enabled
2336 * for HT as well
2337 **/
2338 if (param->stbc_flag)
2339 cmd->peer_flags |= WMI_PEER_STBC;
2340
2341 /* Typically if LDPC is enabled for VHT it should be enabled
2342 * for HT as well
2343 **/
2344 if (param->ldpc_flag)
2345 cmd->peer_flags |= WMI_PEER_LDPC;
2346
2347 if (param->static_mimops_flag)
2348 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2349 if (param->dynamic_mimops_flag)
2350 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2351 if (param->spatial_mux_flag)
2352 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2353 if (param->vht_flag)
2354 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002355 if (param->he_flag)
2356 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302357 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002358
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302359 if (param->is_pmf_enabled)
2360 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302361 /*
2362 * Suppress authorization for all AUTH modes that need 4-way handshake
2363 * (during re-association).
2364 * Authorization will be done for these modes on key installation.
2365 */
2366 if (param->auth_flag)
2367 cmd->peer_flags |= WMI_PEER_AUTH;
2368 if (param->need_ptk_4_way)
2369 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2370 else
2371 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2372 if (param->need_gtk_2_way)
2373 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2374 /* safe mode bypass the 4-way handshake */
2375 if (param->safe_mode_enabled)
2376 cmd->peer_flags &=
2377 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2378 /* Disable AMSDU for station transmit, if user configures it */
2379 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2380 * it
2381 * if (param->amsdu_disable) Add after FW support
2382 **/
2383
2384 /* Target asserts if node is marked HT and all MCS is set to 0.
2385 * Mark the node as non-HT if all the mcs rates are disabled through
2386 * iwpriv
2387 **/
2388 if (param->peer_ht_rates.num_rates == 0)
2389 cmd->peer_flags &= ~WMI_PEER_HT;
Kiran Venkatappa54c2afd2018-07-30 12:04:42 +05302390
2391 if (param->twt_requester)
2392 cmd->peer_flags |= WMI_PEER_TWT_REQ;
2393
2394 if (param->twt_responder)
2395 cmd->peer_flags |= WMI_PEER_TWT_RESP;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302396}
2397#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302398
2399#ifdef CONFIG_MCL
2400static inline void copy_peer_mac_addr_tlv(
2401 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2402 struct peer_assoc_params *param)
2403{
2404 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2405 sizeof(param->peer_macaddr));
2406}
2407#else
2408static inline void copy_peer_mac_addr_tlv(
2409 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2410 struct peer_assoc_params *param)
2411{
2412 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2413}
2414#endif
2415
Govind Singh5eb51532016-03-09 11:34:12 +05302416/**
2417 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2418 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302419 * @param param : pointer to peer assoc parameter
2420 *
2421 * Return: 0 on success and -ve on failure.
2422 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302423static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302424 struct peer_assoc_params *param)
2425{
Govind Singhd3156eb2016-02-26 17:50:39 +05302426 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2427 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002428 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302429 wmi_buf_t buf;
2430 int32_t len;
2431 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302432 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302433 uint32_t peer_legacy_rates_align;
2434 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002435 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302436
2437
2438 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2439 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302440
2441 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002442 (peer_legacy_rates_align * sizeof(uint8_t)) +
2443 WMI_TLV_HDR_SIZE +
2444 (peer_ht_rates_align * sizeof(uint8_t)) +
2445 sizeof(wmi_vht_rate_set) +
2446 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2447 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302448
2449 buf = wmi_buf_alloc(wmi_handle, len);
2450 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302451 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302452 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302453 }
2454
2455 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2456 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2457 WMITLV_SET_HDR(&cmd->tlv_header,
2458 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2459 WMITLV_GET_STRUCT_TLVLEN
2460 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302461
Govind Singhd3156eb2016-02-26 17:50:39 +05302462 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302463
Govind Singhd3156eb2016-02-26 17:50:39 +05302464 cmd->peer_new_assoc = param->peer_new_assoc;
2465 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302466
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302467 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302468 copy_peer_mac_addr_tlv(cmd, param);
2469
Govind Singhd3156eb2016-02-26 17:50:39 +05302470 cmd->peer_rate_caps = param->peer_rate_caps;
2471 cmd->peer_caps = param->peer_caps;
2472 cmd->peer_listen_intval = param->peer_listen_intval;
2473 cmd->peer_ht_caps = param->peer_ht_caps;
2474 cmd->peer_max_mpdu = param->peer_max_mpdu;
2475 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302476 cmd->peer_vht_caps = param->peer_vht_caps;
2477 cmd->peer_phymode = param->peer_phymode;
2478
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002479 /* Update 11ax capabilities */
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07002480 cmd->peer_he_cap_info =
2481 param->peer_he_cap_macinfo[WMI_HOST_HECAP_MAC_WORD1];
2482 cmd->peer_he_cap_info_ext =
2483 param->peer_he_cap_macinfo[WMI_HOST_HECAP_MAC_WORD2];
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002484 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002485 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2486 sizeof(param->peer_he_cap_phyinfo));
2487 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2488 sizeof(param->peer_ppet));
2489
Govind Singhd3156eb2016-02-26 17:50:39 +05302490 /* Update peer legacy rate information */
2491 buf_ptr += sizeof(*cmd);
2492 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302493 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302494 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302495 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302496 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302497 param->peer_legacy_rates.num_rates);
2498
2499 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002500 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302501 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302502 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302503 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302504 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302505 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302506 param->peer_ht_rates.num_rates);
2507
2508 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002509 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302510 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2511 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2512
2513 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302514
2515 /* Update bandwidth-NSS mapping */
2516 cmd->peer_bw_rxnss_override = 0;
2517 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2518
Govind Singhd3156eb2016-02-26 17:50:39 +05302519 mcs = (wmi_vht_rate_set *) buf_ptr;
2520 if (param->vht_capable) {
2521 mcs->rx_max_rate = param->rx_max_rate;
2522 mcs->rx_mcs_set = param->rx_mcs_set;
2523 mcs->tx_max_rate = param->tx_max_rate;
2524 mcs->tx_mcs_set = param->tx_mcs_set;
2525 }
2526
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002527 /* HE Rates */
2528 cmd->peer_he_mcs = param->peer_he_mcs_count;
2529 buf_ptr += sizeof(wmi_vht_rate_set);
2530 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2531 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2532 buf_ptr += WMI_TLV_HDR_SIZE;
2533
2534 /* Loop through the HE rate set */
2535 for (i = 0; i < param->peer_he_mcs_count; i++) {
2536 he_mcs = (wmi_he_rate_set *) buf_ptr;
2537 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2538 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2539
2540 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2541 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2542 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2543 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2544 buf_ptr += sizeof(wmi_he_rate_set);
2545 }
2546
2547
Govind Singhb53420c2016-03-09 14:32:57 +05302548 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302549 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2550 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002551 "cmd->peer_vht_caps %x "
2552 "HE cap_info %x ops %x "
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07002553 "HE cap_info_ext %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302554 "HE phy %x %x %x "
2555 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302556 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2557 cmd->peer_rate_caps, cmd->peer_caps,
2558 cmd->peer_listen_intval, cmd->peer_ht_caps,
2559 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2560 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002561 cmd->peer_vht_caps, cmd->peer_he_cap_info,
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07002562 cmd->peer_he_ops, cmd->peer_he_cap_info_ext,
2563 cmd->peer_he_cap_phy[0], cmd->peer_he_cap_phy[1],
2564 cmd->peer_he_cap_phy[2],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302565 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302566
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302567 wmi_mtrace(WMI_PEER_ASSOC_CMDID, cmd->vdev_id, 0);
Govind Singhd3156eb2016-02-26 17:50:39 +05302568 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2569 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302570 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302571 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302572 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302573 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302574 }
2575
2576 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302577}
2578
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302579/* copy_scan_notify_events() - Helper routine to copy scan notify events
2580 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302581static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302582 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302583 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302584{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302585
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302586 /* Scan events subscription */
2587 if (param->scan_ev_started)
2588 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2589 if (param->scan_ev_completed)
2590 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2591 if (param->scan_ev_bss_chan)
2592 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2593 if (param->scan_ev_foreign_chan)
2594 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2595 if (param->scan_ev_dequeued)
2596 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2597 if (param->scan_ev_preempted)
2598 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2599 if (param->scan_ev_start_failed)
2600 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2601 if (param->scan_ev_restarted)
2602 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2603 if (param->scan_ev_foreign_chn_exit)
2604 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2605 if (param->scan_ev_suspended)
2606 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2607 if (param->scan_ev_resumed)
2608 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302609
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302610 /** Set scan control flags */
2611 cmd->scan_ctrl_flags = 0;
2612 if (param->scan_f_passive)
2613 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2614 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302615 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302616 if (param->scan_f_promisc_mode)
2617 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2618 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302619 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302620 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302621 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302622 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302623 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302624 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302625 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302626 if (param->scan_f_ofdm_rates)
2627 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2628 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302629 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302630 if (param->scan_f_filter_prb_req)
2631 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2632 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302633 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302634 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302635 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302636 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302637 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302638 if (param->scan_f_force_active_dfs_chn)
2639 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2640 if (param->scan_f_add_tpc_ie_in_probe)
2641 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2642 if (param->scan_f_add_ds_ie_in_probe)
2643 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2644 if (param->scan_f_add_spoofed_mac_in_probe)
2645 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2646 if (param->scan_f_add_rand_seq_in_probe)
2647 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2648 if (param->scan_f_en_ie_whitelist_in_probe)
2649 cmd->scan_ctrl_flags |=
2650 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302651
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302652 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2653 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2654 param->adaptive_dwell_time_mode);
2655}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302656
2657/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302658static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302659 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302660{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302661 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302662}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302663
Govind Singh5eb51532016-03-09 11:34:12 +05302664/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302665 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2666 * @mac: random mac addr
2667 * @mask: random mac mask
2668 * @mac_addr: wmi random mac
2669 * @mac_mask: wmi random mac mask
2670 *
2671 * Return None.
2672 */
2673static inline
2674void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2675 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2676{
2677 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2678 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2679}
2680
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302681/*
2682 * wmi_fill_vendor_oui() - fill vendor OUIs
2683 * @buf_ptr: pointer to wmi tlv buffer
2684 * @num_vendor_oui: number of vendor OUIs to be filled
2685 * @param_voui: pointer to OUI buffer
2686 *
2687 * This function populates the wmi tlv buffer when vendor specific OUIs are
2688 * present.
2689 *
2690 * Return: None
2691 */
2692static inline
2693void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2694 uint32_t *pvoui)
2695{
2696 wmi_vendor_oui *voui = NULL;
2697 uint32_t i;
2698
2699 voui = (wmi_vendor_oui *)buf_ptr;
2700
2701 for (i = 0; i < num_vendor_oui; i++) {
2702 WMITLV_SET_HDR(&voui[i].tlv_header,
2703 WMITLV_TAG_STRUC_wmi_vendor_oui,
2704 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2705 voui[i].oui_type_subtype = pvoui[i];
2706 }
2707}
2708
2709/*
2710 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2711 * @ie_bitmap: output pointer to ie bit map in cmd
2712 * @num_vendor_oui: output pointer to num vendor OUIs
2713 * @ie_whitelist: input parameter
2714 *
2715 * This function populates the IE whitelist attrs of scan, pno and
2716 * scan oui commands for ie_whitelist parameter.
2717 *
2718 * Return: None
2719 */
2720static inline
2721void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2722 uint32_t *num_vendor_oui,
2723 struct probe_req_whitelist_attr *ie_whitelist)
2724{
2725 uint32_t i = 0;
2726
2727 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2728 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2729
2730 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2731}
2732
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302733/**
Govind Singh5eb51532016-03-09 11:34:12 +05302734 * send_scan_start_cmd_tlv() - WMI scan start function
2735 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302736 * @param param : pointer to hold scan start cmd parameter
2737 *
2738 * Return: 0 on success and -ve on failure.
2739 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302740static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302741 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302742{
Govind Singhd3156eb2016-02-26 17:50:39 +05302743 int32_t ret = 0;
2744 int32_t i;
2745 wmi_buf_t wmi_buf;
2746 wmi_start_scan_cmd_fixed_param *cmd;
2747 uint8_t *buf_ptr;
2748 uint32_t *tmp_ptr;
2749 wmi_ssid *ssid = NULL;
2750 wmi_mac_addr *bssid;
2751 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302752 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302753 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302754 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302755
2756 /* Length TLV placeholder for array of uint32_t */
2757 len += WMI_TLV_HDR_SIZE;
2758 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302759 if (params->chan_list.num_chan)
2760 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302761
2762 /* Length TLV placeholder for array of wmi_ssid structures */
2763 len += WMI_TLV_HDR_SIZE;
2764 if (params->num_ssids)
2765 len += params->num_ssids * sizeof(wmi_ssid);
2766
2767 /* Length TLV placeholder for array of wmi_mac_addr structures */
2768 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302769 if (params->num_bssid)
2770 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302771
2772 /* Length TLV placeholder for array of bytes */
2773 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302774 if (params->extraie.len)
2775 extraie_len_with_pad =
2776 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002777 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302778
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302779 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2780 if (ie_whitelist->num_vendor_oui)
2781 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2782
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302783 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2784 if (params->scan_f_wide_band)
2785 phymode_roundup =
2786 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2787 sizeof(uint32_t));
2788 len += phymode_roundup;
2789
Govind Singhd3156eb2016-02-26 17:50:39 +05302790 /* Allocate the memory */
2791 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2792 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302793 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302794 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302795 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302796 }
2797 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2798 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2799 WMITLV_SET_HDR(&cmd->tlv_header,
2800 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2801 WMITLV_GET_STRUCT_TLVLEN
2802 (wmi_start_scan_cmd_fixed_param));
2803
2804 cmd->scan_id = params->scan_id;
2805 cmd->scan_req_id = params->scan_req_id;
2806 cmd->vdev_id = params->vdev_id;
2807 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302808
2809 copy_scan_event_cntrl_flags(cmd, params);
2810
Govind Singhd3156eb2016-02-26 17:50:39 +05302811 cmd->dwell_time_active = params->dwell_time_active;
Arif Hussain397f08c2018-07-23 18:10:34 -07002812 cmd->dwell_time_active_2g = params->dwell_time_active_2g;
Govind Singhd3156eb2016-02-26 17:50:39 +05302813 cmd->dwell_time_passive = params->dwell_time_passive;
2814 cmd->min_rest_time = params->min_rest_time;
2815 cmd->max_rest_time = params->max_rest_time;
2816 cmd->repeat_probe_time = params->repeat_probe_time;
2817 cmd->probe_spacing_time = params->probe_spacing_time;
2818 cmd->idle_time = params->idle_time;
2819 cmd->max_scan_time = params->max_scan_time;
2820 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302821 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302822 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302823 cmd->num_bssid = params->num_bssid;
2824 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302825 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302826 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302827 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2828
2829 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2830
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302831 if (params->scan_random.randomize)
2832 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2833 params->scan_random.mac_mask,
2834 &cmd->mac_addr,
2835 &cmd->mac_mask);
2836
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302837 if (ie_whitelist->white_list)
2838 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2839 &cmd->num_vendor_oui,
2840 ie_whitelist);
2841
Govind Singhd3156eb2016-02-26 17:50:39 +05302842 buf_ptr += sizeof(*cmd);
2843 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302844 for (i = 0; i < params->chan_list.num_chan; ++i)
2845 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302846
2847 WMITLV_SET_HDR(buf_ptr,
2848 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302849 (params->chan_list.num_chan * sizeof(uint32_t)));
2850 buf_ptr += WMI_TLV_HDR_SIZE +
2851 (params->chan_list.num_chan * sizeof(uint32_t));
2852
Govind Singh4eacd2b2016-03-07 14:24:22 +05302853 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302854 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302855 goto error;
2856 }
2857
2858 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2859 (params->num_ssids * sizeof(wmi_ssid)));
2860
2861 if (params->num_ssids) {
2862 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2863 for (i = 0; i < params->num_ssids; ++i) {
2864 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302865 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302866 params->ssid[i].length);
2867 ssid++;
2868 }
2869 }
2870 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2871
2872 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2873 (params->num_bssid * sizeof(wmi_mac_addr)));
2874 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302875
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302876 if (params->num_bssid) {
2877 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302878 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2879 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302880 bssid++;
2881 }
2882 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302883
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302884 buf_ptr += WMI_TLV_HDR_SIZE +
2885 (params->num_bssid * sizeof(wmi_mac_addr));
2886
2887 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2888 if (params->extraie.len)
2889 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2890 params);
2891
2892 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302893
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302894 /* probe req ie whitelisting */
2895 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2896 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2897
2898 buf_ptr += WMI_TLV_HDR_SIZE;
2899
2900 if (cmd->num_vendor_oui) {
2901 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2902 ie_whitelist->voui);
2903 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2904 }
2905
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302906 /* Add phy mode TLV if it's a wide band scan */
2907 if (params->scan_f_wide_band) {
2908 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2909 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2910 for (i = 0; i < params->chan_list.num_chan; ++i)
2911 buf_ptr[i] =
2912 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2913 buf_ptr += phymode_roundup;
2914 } else {
2915 /* Add ZERO legth phy mode TLV */
2916 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2917 }
2918
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302919 wmi_mtrace(WMI_START_SCAN_CMDID, cmd->vdev_id, 0);
Santosh Anbu1e11b472018-03-07 15:33:27 +05302920 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002921 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302922 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302923 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302924 wmi_buf_free(wmi_buf);
2925 }
2926 return ret;
2927error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302928 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302929 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302930}
2931
2932/**
2933 * send_scan_stop_cmd_tlv() - WMI scan start function
2934 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302935 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302936 *
2937 * Return: 0 on success and -ve on failure.
2938 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302939static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302940 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302941{
Govind Singhd3156eb2016-02-26 17:50:39 +05302942 wmi_stop_scan_cmd_fixed_param *cmd;
2943 int ret;
2944 int len = sizeof(*cmd);
2945 wmi_buf_t wmi_buf;
2946
2947 /* Allocate the memory */
2948 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2949 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302950 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302951 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302952 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302953 goto error;
2954 }
2955
2956 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2957 WMITLV_SET_HDR(&cmd->tlv_header,
2958 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2959 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2960 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302961 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302962 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302963 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2964 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302965 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302966 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2967 /* Cancelling all scans */
2968 cmd->req_type = WMI_SCAN_STOP_ALL;
2969 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2970 /* Cancelling VAP scans */
2971 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2972 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2973 /* Cancelling specific scan */
2974 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302975 } else {
2976 WMI_LOGE("%s: Invalid Command : ", __func__);
2977 wmi_buf_free(wmi_buf);
2978 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302979 }
2980
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302981 wmi_mtrace(WMI_STOP_SCAN_CMDID, cmd->vdev_id, 0);
Santosh Anbu1e11b472018-03-07 15:33:27 +05302982 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002983 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302984 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302985 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302986 wmi_buf_free(wmi_buf);
2987 }
2988
2989error:
2990 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302991}
2992
Govind Singh87542482016-06-08 19:40:11 +05302993#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302994/**
2995 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2996 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302997 * @param param : pointer to hold scan channel list parameter
2998 *
2999 * Return: 0 on success and -ve on failure.
3000 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303001static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303002 struct scan_chan_list_params *chan_list)
3003{
3004 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303005 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05303006 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303007 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05303008 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05303009 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05303010 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
3011
3012 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
3013 buf = wmi_buf_alloc(wmi_handle, len);
3014 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303015 WMI_LOGE("Failed to allocate memory");
3016 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05303017 goto end;
3018 }
3019
3020 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3021 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
3022 WMITLV_SET_HDR(&cmd->tlv_header,
3023 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
3024 WMITLV_GET_STRUCT_TLVLEN
3025 (wmi_scan_chan_list_cmd_fixed_param));
3026
Govind Singhb53420c2016-03-09 14:32:57 +05303027 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05303028
3029 cmd->num_scan_chans = chan_list->num_scan_chans;
3030 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
3031 WMITLV_TAG_ARRAY_STRUC,
3032 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05303033 chan_info = (wmi_channel_param *)
3034 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05303035 tchan_info = chan_list->chan_info;
3036
3037 for (i = 0; i < chan_list->num_scan_chans; ++i) {
3038 WMITLV_SET_HDR(&chan_info->tlv_header,
3039 WMITLV_TAG_STRUC_wmi_channel,
3040 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3041 chan_info->mhz = tchan_info->mhz;
3042 chan_info->band_center_freq1 =
3043 tchan_info->band_center_freq1;
3044 chan_info->band_center_freq2 =
3045 tchan_info->band_center_freq2;
3046 chan_info->info = tchan_info->info;
3047 chan_info->reg_info_1 = tchan_info->reg_info_1;
3048 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05303049 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05303050
3051 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
3052 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
3053 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
3054 tchan_info++;
3055 chan_info++;
3056 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303057 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3058 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05303059
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303060 wmi_mtrace(WMI_SCAN_CHAN_LIST_CMDID, NO_SESSION, 0);
Anish Natarajdd855152017-03-20 12:49:08 +05303061 qdf_status = wmi_unified_cmd_send(wmi_handle,
3062 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05303063
Govind Singh67922e82016-04-01 16:48:57 +05303064 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303065 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05303066 wmi_buf_free(buf);
3067 }
Govind Singh67922e82016-04-01 16:48:57 +05303068
Govind Singhd3156eb2016-02-26 17:50:39 +05303069end:
Govind Singhb53420c2016-03-09 14:32:57 +05303070 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05303071}
Govind Singh87542482016-06-08 19:40:11 +05303072#else
Sathish Kumarfd347372017-02-13 12:29:09 +05303073static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05303074 struct scan_chan_list_params *chan_list)
3075{
3076 wmi_buf_t buf;
3077 QDF_STATUS qdf_status;
3078 wmi_scan_chan_list_cmd_fixed_param *cmd;
3079 int i;
3080 uint8_t *buf_ptr;
3081 wmi_channel *chan_info;
3082 struct channel_param *tchan_info;
3083 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05303084
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303085 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05303086 buf = wmi_buf_alloc(wmi_handle, len);
3087 if (!buf) {
3088 WMI_LOGE("Failed to allocate memory");
3089 qdf_status = QDF_STATUS_E_NOMEM;
3090 goto end;
3091 }
3092
3093 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3094 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
3095 WMITLV_SET_HDR(&cmd->tlv_header,
3096 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
3097 WMITLV_GET_STRUCT_TLVLEN
3098 (wmi_scan_chan_list_cmd_fixed_param));
3099
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303100 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05303101
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05303102 if (chan_list->append)
3103 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
3104
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303105 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3106 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303107 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05303108 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
3109 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303110 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05303111 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
3112 tchan_info = &(chan_list->ch_param[0]);
3113
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303114 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05303115 WMITLV_SET_HDR(&chan_info->tlv_header,
3116 WMITLV_TAG_STRUC_wmi_channel,
3117 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3118 chan_info->mhz = tchan_info->mhz;
3119 chan_info->band_center_freq1 =
3120 tchan_info->cfreq1;
3121 chan_info->band_center_freq2 =
3122 tchan_info->cfreq2;
3123
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303124 if (tchan_info->is_chan_passive)
3125 WMI_SET_CHANNEL_FLAG(chan_info,
3126 WMI_CHAN_FLAG_PASSIVE);
3127
3128 if (tchan_info->allow_vht)
3129 WMI_SET_CHANNEL_FLAG(chan_info,
3130 WMI_CHAN_FLAG_ALLOW_VHT);
3131 else if (tchan_info->allow_ht)
3132 WMI_SET_CHANNEL_FLAG(chan_info,
3133 WMI_CHAN_FLAG_ALLOW_HT);
3134 WMI_SET_CHANNEL_MODE(chan_info,
3135 tchan_info->phy_mode);
3136
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05303137 if (tchan_info->half_rate)
3138 WMI_SET_CHANNEL_FLAG(chan_info,
3139 WMI_CHAN_FLAG_HALF_RATE);
3140
3141 if (tchan_info->quarter_rate)
3142 WMI_SET_CHANNEL_FLAG(chan_info,
3143 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303144
3145 /* also fill in power information */
3146 WMI_SET_CHANNEL_MIN_POWER(chan_info,
3147 tchan_info->minpower);
3148 WMI_SET_CHANNEL_MAX_POWER(chan_info,
3149 tchan_info->maxpower);
3150 WMI_SET_CHANNEL_REG_POWER(chan_info,
3151 tchan_info->maxregpower);
3152 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
3153 tchan_info->antennamax);
3154 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
3155 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08003156 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
3157 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303158
Govind Singh87542482016-06-08 19:40:11 +05303159 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
3160
Govind Singh87542482016-06-08 19:40:11 +05303161 tchan_info++;
3162 chan_info++;
3163 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303164 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3165 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05303166
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303167 wmi_mtrace(WMI_SCAN_CHAN_LIST_CMDID, cmd->pdev_id, 0);
Anish Natarajdd855152017-03-20 12:49:08 +05303168 qdf_status = wmi_unified_cmd_send(
3169 wmi_handle,
3170 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05303171
3172 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3173 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
3174 wmi_buf_free(buf);
3175 }
3176
3177end:
3178 return qdf_status;
3179}
3180#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05303181
3182/**
3183 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3184 *
3185 * @bufp: Pointer to buffer
3186 * @param: Pointer to tx param
3187 *
3188 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3189 */
3190static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3191 struct tx_send_params param)
3192{
3193 wmi_tx_send_params *tx_param;
3194 QDF_STATUS status = QDF_STATUS_SUCCESS;
3195
3196 if (!bufp) {
3197 status = QDF_STATUS_E_FAILURE;
3198 return status;
3199 }
3200 tx_param = (wmi_tx_send_params *)bufp;
3201 WMITLV_SET_HDR(&tx_param->tlv_header,
3202 WMITLV_TAG_STRUC_wmi_tx_send_params,
3203 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3204 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3205 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3206 param.mcs_mask);
3207 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3208 param.nss_mask);
3209 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3210 param.retry_limit);
3211 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3212 param.chain_mask);
3213 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3214 param.bw_mask);
3215 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3216 param.preamble_type);
3217 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3218 param.frame_type);
3219
3220 return status;
3221}
3222
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303223#ifdef CONFIG_HL_SUPPORT
3224/**
3225 * send_mgmt_cmd_tlv() - WMI scan start function
3226 * @wmi_handle : handle to WMI.
3227 * @param : pointer to hold mgmt cmd parameter
3228 *
3229 * Return: 0 on success and -ve on failure.
3230 */
3231static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
3232 struct wmi_mgmt_params *param)
3233{
3234 wmi_buf_t buf;
3235 uint8_t *bufp;
3236 int32_t cmd_len;
3237 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3238 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3239 mgmt_tx_dl_frm_len;
3240
3241 if (param->frm_len > mgmt_tx_dl_frm_len) {
3242 WMI_LOGE("%s:mgmt frame len %u exceeds %u",
3243 __func__, param->frm_len, mgmt_tx_dl_frm_len);
3244 return QDF_STATUS_E_INVAL;
3245 }
3246
3247 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
3248 WMI_TLV_HDR_SIZE +
3249 roundup(bufp_len, sizeof(uint32_t));
3250
3251 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
3252 if (!buf) {
3253 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3254 return QDF_STATUS_E_NOMEM;
3255 }
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
3266 cmd->desc_id = param->desc_id;
3267 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;
3272 qdf_mem_copy(bufp, param->pdata, bufp_len);
3273
3274 cmd->frame_len = param->frm_len;
3275 cmd->buf_len = bufp_len;
3276 cmd->tx_params_valid = param->tx_params_valid;
3277
3278 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
3279 bufp, cmd->vdev_id, cmd->chanfreq);
3280
3281 bufp += roundup(bufp_len, sizeof(uint32_t));
3282 if (param->tx_params_valid) {
3283 if (populate_tx_send_params(bufp, param->tx_param) !=
3284 QDF_STATUS_SUCCESS) {
3285 WMI_LOGE("%s: Populate TX send params failed",
3286 __func__);
3287 goto free_buf;
3288 }
3289 cmd_len += sizeof(wmi_tx_send_params);
3290 }
3291
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303292 wmi_mtrace(WMI_MGMT_TX_SEND_CMDID, cmd->vdev_id, 0);
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303293 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3294 WMI_MGMT_TX_SEND_CMDID)) {
3295 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
3296 goto free_buf;
3297 }
3298 return QDF_STATUS_SUCCESS;
3299
3300free_buf:
3301 wmi_buf_free(buf);
3302 return QDF_STATUS_E_FAILURE;
3303}
3304#else
Govind Singhd3156eb2016-02-26 17:50:39 +05303305/**
3306 * send_mgmt_cmd_tlv() - WMI scan start function
3307 * @wmi_handle : handle to WMI.
3308 * @param : pointer to hold mgmt cmd parameter
3309 *
3310 * Return: 0 on success and -ve on failure.
3311 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303312static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303313 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303314{
Govind Singh427ee5a2016-02-26 18:09:36 +05303315 wmi_buf_t buf;
3316 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3317 int32_t cmd_len;
3318 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303319 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303320 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303321 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303322 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3323 mgmt_tx_dl_frm_len;
3324
3325 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303326 WMI_TLV_HDR_SIZE +
3327 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303328
Sathish Kumar5b636932017-06-28 14:40:32 +05303329 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303330 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303331 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3332 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303333 }
3334
3335 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3336 bufp = (uint8_t *) cmd;
3337 WMITLV_SET_HDR(&cmd->tlv_header,
3338 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3339 WMITLV_GET_STRUCT_TLVLEN
3340 (wmi_mgmt_tx_send_cmd_fixed_param));
3341
3342 cmd->vdev_id = param->vdev_id;
3343
Govind Singh224a7312016-06-21 14:33:26 +05303344 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303345 cmd->chanfreq = param->chanfreq;
3346 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3347 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3348 sizeof(uint32_t)));
3349 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303350 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303351
3352 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3353 QDF_DMA_TO_DEVICE);
3354 if (status != QDF_STATUS_SUCCESS) {
3355 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303356 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303357 }
3358
Govind Singhb53420c2016-03-09 14:32:57 +05303359 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303360 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003361#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303362 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3363#endif
3364 cmd->frame_len = param->frm_len;
3365 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303366 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303367
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003368 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003369 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003370
Sathish Kumar5b636932017-06-28 14:40:32 +05303371 bufp += roundup(bufp_len, sizeof(uint32_t));
3372 if (param->tx_params_valid) {
3373 status = populate_tx_send_params(bufp, param->tx_param);
3374 if (status != QDF_STATUS_SUCCESS) {
3375 WMI_LOGE("%s: Populate TX send params failed",
3376 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303377 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303378 }
3379 cmd_len += sizeof(wmi_tx_send_params);
3380 }
3381
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303382 wmi_mtrace(WMI_MGMT_TX_SEND_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303383 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3384 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303385 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303386 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303387 }
Govind Singhb53420c2016-03-09 14:32:57 +05303388 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303389
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303390unmap_tx_frame:
3391 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3392 QDF_DMA_TO_DEVICE);
3393free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303394 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303395 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303396}
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303397#endif /* CONFIG_HL_SUPPORT */
Govind Singh427ee5a2016-02-26 18:09:36 +05303398
3399/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303400 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3401 * @wmi_handle : handle to WMI.
3402 * @param : pointer to offchan data tx cmd parameter
3403 *
3404 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3405 */
3406static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3407 struct wmi_offchan_data_tx_params *param)
3408{
3409 wmi_buf_t buf;
3410 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3411 int32_t cmd_len;
3412 uint64_t dma_addr;
3413 void *qdf_ctx = param->qdf_ctx;
3414 uint8_t *bufp;
3415 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3416 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303417 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303418
3419 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303420 WMI_TLV_HDR_SIZE +
3421 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303422
Sathish Kumar5b636932017-06-28 14:40:32 +05303423 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303424 if (!buf) {
3425 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3426 return QDF_STATUS_E_NOMEM;
3427 }
3428
3429 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3430 bufp = (uint8_t *) cmd;
3431 WMITLV_SET_HDR(&cmd->tlv_header,
3432 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3433 WMITLV_GET_STRUCT_TLVLEN
3434 (wmi_offchan_data_tx_send_cmd_fixed_param));
3435
3436 cmd->vdev_id = param->vdev_id;
3437
3438 cmd->desc_id = param->desc_id;
3439 cmd->chanfreq = param->chanfreq;
3440 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3441 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3442 sizeof(uint32_t)));
3443 bufp += WMI_TLV_HDR_SIZE;
3444 qdf_mem_copy(bufp, param->pdata, bufp_len);
3445 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3446 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3447 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3448#if defined(HTT_PADDR64)
3449 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3450#endif
3451 cmd->frame_len = param->frm_len;
3452 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303453 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303454
3455 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3456 bufp, cmd->vdev_id, cmd->chanfreq);
3457
Sathish Kumar5b636932017-06-28 14:40:32 +05303458 bufp += roundup(bufp_len, sizeof(uint32_t));
3459 if (param->tx_params_valid) {
3460 status = populate_tx_send_params(bufp, param->tx_param);
3461 if (status != QDF_STATUS_SUCCESS) {
3462 WMI_LOGE("%s: Populate TX send params failed",
3463 __func__);
3464 goto err1;
3465 }
3466 cmd_len += sizeof(wmi_tx_send_params);
3467 }
3468
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303469 wmi_mtrace(WMI_OFFCHAN_DATA_TX_SEND_CMDID, cmd->vdev_id, 0);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303470 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3471 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3472 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303473 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303474 }
3475
3476 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303477
3478err1:
3479 wmi_buf_free(buf);
3480 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303481}
3482
3483/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303484 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3485 * @wmi_handle: wmi handle
3486 * @param_value: parameter value
3487 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303488 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303489 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303490static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303491 uint32_t param_value)
3492{
Govind Singh67922e82016-04-01 16:48:57 +05303493 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303494 wmi_modem_power_state_cmd_param *cmd;
3495 wmi_buf_t buf;
3496 uint16_t len = sizeof(*cmd);
3497
3498 buf = wmi_buf_alloc(wmi_handle, len);
3499 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303500 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303501 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303502 }
3503 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3504 WMITLV_SET_HDR(&cmd->tlv_header,
3505 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3506 WMITLV_GET_STRUCT_TLVLEN
3507 (wmi_modem_power_state_cmd_param));
3508 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303509 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303510 param_value);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303511 wmi_mtrace(WMI_MODEM_POWER_STATE_CMDID, NO_SESSION, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303512 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3513 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303514 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303515 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303516 wmi_buf_free(buf);
3517 }
Govind Singh67922e82016-04-01 16:48:57 +05303518
Govind Singh427ee5a2016-02-26 18:09:36 +05303519 return ret;
3520}
3521
3522/**
3523 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3524 * @wmi_handle: wmi handle
3525 * @vdev_id: vdev id
3526 * @val: value
3527 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303528 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303529 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303530static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303531 uint32_t vdev_id, uint8_t val)
3532{
3533 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3534 wmi_buf_t buf;
3535 int32_t len = sizeof(*cmd);
3536
Govind Singhb53420c2016-03-09 14:32:57 +05303537 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303538
3539 buf = wmi_buf_alloc(wmi_handle, len);
3540 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303541 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303542 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303543 }
3544 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3545 WMITLV_SET_HDR(&cmd->tlv_header,
3546 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3547 WMITLV_GET_STRUCT_TLVLEN
3548 (wmi_sta_powersave_mode_cmd_fixed_param));
3549 cmd->vdev_id = vdev_id;
3550 if (val)
3551 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3552 else
3553 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3554
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303555 wmi_mtrace(WMI_STA_POWERSAVE_MODE_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303556 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3557 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303558 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303559 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303560 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303561 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303562 }
Govind Singh5eb51532016-03-09 11:34:12 +05303563 return 0;
3564}
3565
Govind Singh427ee5a2016-02-26 18:09:36 +05303566/**
3567 * send_set_mimops_cmd_tlv() - set MIMO powersave
3568 * @wmi_handle: wmi handle
3569 * @vdev_id: vdev id
3570 * @value: value
3571 *
Govind Singhb53420c2016-03-09 14:32:57 +05303572 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303573 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303574static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303575 uint8_t vdev_id, int value)
3576{
Govind Singh67922e82016-04-01 16:48:57 +05303577 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303578 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3579 wmi_buf_t buf;
3580 uint16_t len = sizeof(*cmd);
3581
3582 buf = wmi_buf_alloc(wmi_handle, len);
3583 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303584 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303585 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303586 }
3587 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3588 WMITLV_SET_HDR(&cmd->tlv_header,
3589 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3590 WMITLV_GET_STRUCT_TLVLEN
3591 (wmi_sta_smps_force_mode_cmd_fixed_param));
3592
3593 cmd->vdev_id = vdev_id;
3594
Houston Hoffmanb5168052016-04-14 02:18:01 -07003595 /* WMI_SMPS_FORCED_MODE values do not directly map
3596 * to SM power save values defined in the specification.
3597 * Make sure to send the right mapping.
3598 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303599 switch (value) {
3600 case 0:
3601 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3602 break;
3603 case 1:
3604 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3605 break;
3606 case 2:
3607 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3608 break;
3609 case 3:
3610 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3611 break;
3612 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303613 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303614 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303615 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303616 }
3617
Govind Singhb53420c2016-03-09 14:32:57 +05303618 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303619
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303620 wmi_mtrace(WMI_STA_SMPS_FORCE_MODE_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303621 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3622 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303623 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303624 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303625 wmi_buf_free(buf);
3626 }
3627
3628 return ret;
3629}
3630
3631/**
3632 * send_set_smps_params_cmd_tlv() - set smps params
3633 * @wmi_handle: wmi handle
3634 * @vdev_id: vdev id
3635 * @value: value
3636 *
Govind Singhb53420c2016-03-09 14:32:57 +05303637 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303638 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303639static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303640 int value)
3641{
Govind Singh67922e82016-04-01 16:48:57 +05303642 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303643 wmi_sta_smps_param_cmd_fixed_param *cmd;
3644 wmi_buf_t buf;
3645 uint16_t len = sizeof(*cmd);
3646
3647 buf = wmi_buf_alloc(wmi_handle, len);
3648 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303649 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303650 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303651 }
3652 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3653 WMITLV_SET_HDR(&cmd->tlv_header,
3654 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3655 WMITLV_GET_STRUCT_TLVLEN
3656 (wmi_sta_smps_param_cmd_fixed_param));
3657
3658 cmd->vdev_id = vdev_id;
3659 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3660 cmd->param =
3661 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3662
Govind Singhb53420c2016-03-09 14:32:57 +05303663 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303664 cmd->param);
3665
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303666 wmi_mtrace(WMI_STA_SMPS_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303667 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3668 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303669 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303670 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303671 wmi_buf_free(buf);
3672 }
3673
3674 return ret;
3675}
3676
3677/**
3678 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3679 * @wmi_handle: wmi handle
3680 * @noa: p2p power save parameters
3681 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303682 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303683 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303684static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303685 struct p2p_ps_params *noa)
3686{
3687 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3688 wmi_p2p_noa_descriptor *noa_discriptor;
3689 wmi_buf_t buf;
3690 uint8_t *buf_ptr;
3691 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303692 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303693 uint32_t duration;
3694
Govind Singhb53420c2016-03-09 14:32:57 +05303695 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303696 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3697 buf = wmi_buf_alloc(wmi_handle, len);
3698 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303699 WMI_LOGE("Failed to allocate memory");
3700 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303701 goto end;
3702 }
3703
3704 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3705 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3706 WMITLV_SET_HDR(&cmd->tlv_header,
3707 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3708 WMITLV_GET_STRUCT_TLVLEN
3709 (wmi_p2p_set_noa_cmd_fixed_param));
3710 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3711 cmd->vdev_id = noa->session_id;
3712 cmd->enable = (duration) ? true : false;
3713 cmd->num_noa = 1;
3714
3715 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3716 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3717 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3718 sizeof
3719 (wmi_p2p_set_noa_cmd_fixed_param)
3720 + WMI_TLV_HDR_SIZE);
3721 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3722 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3723 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3724 noa_discriptor->type_count = noa->count;
3725 noa_discriptor->duration = duration;
3726 noa_discriptor->interval = noa->interval;
3727 noa_discriptor->start_time = 0;
3728
Govind Singhb53420c2016-03-09 14:32:57 +05303729 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303730 cmd->vdev_id, noa->count, noa_discriptor->duration,
3731 noa->interval);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303732 wmi_mtrace(WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303733 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3734 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303735 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303736 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303737 wmi_buf_free(buf);
3738 }
3739
3740end:
Govind Singhb53420c2016-03-09 14:32:57 +05303741 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303742 return status;
3743}
3744
3745
3746/**
3747 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3748 * @wmi_handle: wmi handle
3749 * @noa: p2p opp power save parameters
3750 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303751 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303752 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303753static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303754 struct p2p_ps_params *oppps)
3755{
3756 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3757 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303758 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303759
Govind Singhb53420c2016-03-09 14:32:57 +05303760 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303761 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3762 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303763 WMI_LOGE("Failed to allocate memory");
3764 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303765 goto end;
3766 }
3767
3768 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3769 WMITLV_SET_HDR(&cmd->tlv_header,
3770 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3771 WMITLV_GET_STRUCT_TLVLEN
3772 (wmi_p2p_set_oppps_cmd_fixed_param));
3773 cmd->vdev_id = oppps->session_id;
3774 if (oppps->ctwindow)
3775 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3776
3777 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303778 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303779 cmd->vdev_id, oppps->ctwindow);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303780 wmi_mtrace(WMI_P2P_SET_OPPPS_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303781 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3782 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303783 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303784 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303785 wmi_buf_free(buf);
3786 }
3787
3788end:
Govind Singhb53420c2016-03-09 14:32:57 +05303789 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303790 return status;
3791}
3792
Rachit Kankane9cd0c752018-07-31 16:26:38 +05303793#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +08003794/**
3795 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3796 * @wmi_handle: wmi handle
3797 * @param: p2p listen offload start parameters
3798 *
3799 * Return: QDF status
3800 */
3801static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3802 struct p2p_lo_start *param)
3803{
3804 wmi_buf_t buf;
3805 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3806 int32_t len = sizeof(*cmd);
3807 uint8_t *buf_ptr;
3808 QDF_STATUS status;
3809 int device_types_len_aligned;
3810 int probe_resp_len_aligned;
3811
3812 if (!param) {
3813 WMI_LOGE("lo start param is null");
3814 return QDF_STATUS_E_INVAL;
3815 }
3816
3817 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3818
3819 device_types_len_aligned =
3820 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303821 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003822 probe_resp_len_aligned =
3823 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303824 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003825
3826 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3827 probe_resp_len_aligned;
3828
3829 buf = wmi_buf_alloc(wmi_handle, len);
3830 if (!buf) {
3831 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3832 __func__);
3833 return QDF_STATUS_E_NOMEM;
3834 }
3835
3836 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3837 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3838
3839 WMITLV_SET_HDR(&cmd->tlv_header,
3840 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3841 WMITLV_GET_STRUCT_TLVLEN(
3842 wmi_p2p_lo_start_cmd_fixed_param));
3843
3844 cmd->vdev_id = param->vdev_id;
3845 cmd->ctl_flags = param->ctl_flags;
3846 cmd->channel = param->freq;
3847 cmd->period = param->period;
3848 cmd->interval = param->interval;
3849 cmd->count = param->count;
3850 cmd->device_types_len = param->dev_types_len;
3851 cmd->prob_resp_len = param->probe_resp_len;
3852
3853 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3854 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3855 device_types_len_aligned);
3856 buf_ptr += WMI_TLV_HDR_SIZE;
3857 qdf_mem_copy(buf_ptr, param->device_types,
3858 param->dev_types_len);
3859
3860 buf_ptr += device_types_len_aligned;
3861 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3862 probe_resp_len_aligned);
3863 buf_ptr += WMI_TLV_HDR_SIZE;
3864 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3865 param->probe_resp_len);
3866
3867 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3868 cmd->channel, cmd->period, cmd->interval, cmd->count);
3869
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303870 wmi_mtrace(WMI_P2P_LISTEN_OFFLOAD_START_CMDID, cmd->vdev_id, 0);
Wu Gaocd3a8512017-03-13 20:17:34 +08003871 status = wmi_unified_cmd_send(wmi_handle,
3872 buf, len,
3873 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3874 if (status != QDF_STATUS_SUCCESS) {
3875 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3876 __func__, status);
3877 wmi_buf_free(buf);
3878 return status;
3879 }
3880
3881 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3882
3883 return QDF_STATUS_SUCCESS;
3884}
3885
3886/**
3887 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3888 * @wmi_handle: wmi handle
3889 * @param: p2p listen offload stop parameters
3890 *
3891 * Return: QDF status
3892 */
3893static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3894 uint8_t vdev_id)
3895{
3896 wmi_buf_t buf;
3897 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3898 int32_t len;
3899 QDF_STATUS status;
3900
3901 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3902
3903 len = sizeof(*cmd);
3904 buf = wmi_buf_alloc(wmi_handle, len);
3905 if (!buf) {
3906 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3907 __func__);
3908 return QDF_STATUS_E_NOMEM;
3909 }
3910 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3911
3912 WMITLV_SET_HDR(&cmd->tlv_header,
3913 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3914 WMITLV_GET_STRUCT_TLVLEN(
3915 wmi_p2p_lo_stop_cmd_fixed_param));
3916
3917 cmd->vdev_id = vdev_id;
3918
3919 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3920
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303921 wmi_mtrace(WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID, cmd->vdev_id, 0);
Wu Gaocd3a8512017-03-13 20:17:34 +08003922 status = wmi_unified_cmd_send(wmi_handle,
3923 buf, len,
3924 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3925 if (status != QDF_STATUS_SUCCESS) {
3926 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3927 __func__, status);
3928 wmi_buf_free(buf);
3929 return status;
3930 }
3931
3932 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3933
3934 return QDF_STATUS_SUCCESS;
3935}
Rachit Kankane9cd0c752018-07-31 16:26:38 +05303936#endif /* End of FEATURE_P2P_LISTEN_OFFLOAD */
Wu Gaocd3a8512017-03-13 20:17:34 +08003937
Govind Singh427ee5a2016-02-26 18:09:36 +05303938/**
3939 * send_get_temperature_cmd_tlv() - get pdev temperature req
3940 * @wmi_handle: wmi handle
3941 *
Govind Singhb53420c2016-03-09 14:32:57 +05303942 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303943 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303944static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303945{
3946 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3947 wmi_buf_t wmi_buf;
3948 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3949 uint8_t *buf_ptr;
3950
3951 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303952 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3953 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303954 }
3955
3956 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3957 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303958 WMI_LOGE(FL("wmi_buf_alloc failed"));
3959 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303960 }
3961
3962 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3963
3964 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3965 WMITLV_SET_HDR(&cmd->tlv_header,
3966 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3967 WMITLV_GET_STRUCT_TLVLEN
3968 (wmi_pdev_get_temperature_cmd_fixed_param));
3969
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303970 wmi_mtrace(WMI_PDEV_GET_TEMPERATURE_CMDID, NO_SESSION, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303971 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3972 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303973 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303974 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303975 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303976 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303977
Govind Singhb53420c2016-03-09 14:32:57 +05303978 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303979}
3980
3981/**
3982 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3983 * @wmi_handle: wmi handle
3984 * @vdevid: vdev id
3985 * @peer_addr: peer mac address
3986 * @auto_triggerparam: auto trigger parameters
3987 * @num_ac: number of access category
3988 *
3989 * This function sets the trigger
3990 * uapsd params such as service interval, delay interval
3991 * and suspend interval which will be used by the firmware
3992 * to send trigger frames periodically when there is no
3993 * traffic on the transmit side.
3994 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303995 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303996 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303997static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303998 struct sta_uapsd_trig_params *param)
3999{
4000 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05304001 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05304002 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
4003 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
4004 uint32_t i;
4005 wmi_buf_t buf;
4006 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08004007 struct sta_uapsd_params *uapsd_param;
4008 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05304009
4010 buf = wmi_buf_alloc(wmi_handle, cmd_len);
4011 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304012 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304013 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05304014 }
4015
4016 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4017 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
4018 WMITLV_SET_HDR(&cmd->tlv_header,
4019 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
4020 WMITLV_GET_STRUCT_TLVLEN
4021 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
4022 cmd->vdev_id = param->vdevid;
4023 cmd->num_ac = param->num_ac;
4024 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
4025
4026 /* TLV indicating array of structures to follow */
4027 buf_ptr += sizeof(*cmd);
4028 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
4029
4030 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05304031
4032 /*
4033 * Update tag and length for uapsd auto trigger params (this will take
4034 * care of updating tag and length if it is not pre-filled by caller).
4035 */
Frank Liu3d5e9992017-03-15 17:51:43 +08004036 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
4037 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05304038 for (i = 0; i < param->num_ac; i++) {
4039 WMITLV_SET_HDR((buf_ptr +
4040 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
4041 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
4042 WMITLV_GET_STRUCT_TLVLEN
4043 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08004044 trig_param->wmm_ac = uapsd_param->wmm_ac;
4045 trig_param->user_priority = uapsd_param->user_priority;
4046 trig_param->service_interval = uapsd_param->service_interval;
4047 trig_param->suspend_interval = uapsd_param->suspend_interval;
4048 trig_param->delay_interval = uapsd_param->delay_interval;
4049 trig_param++;
4050 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05304051 }
4052
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304053 wmi_mtrace(WMI_STA_UAPSD_AUTO_TRIG_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05304054 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
4055 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304056 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304057 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05304058 wmi_buf_free(buf);
4059 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05304060
Govind Singh427ee5a2016-02-26 18:09:36 +05304061 return ret;
4062}
4063
Zhang Qian11c0de32018-01-05 16:50:53 +08004064#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05304065/**
4066 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
4067 * @wmi_handle: pointer to the wmi handle
4068 * @utc: pointer to the UTC time struct
4069 *
4070 * Return: 0 on succes
4071 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304072static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304073 struct ocb_utc_param *utc)
4074{
Govind Singh67922e82016-04-01 16:48:57 +05304075 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304076 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
4077 uint8_t *buf_ptr;
4078 uint32_t len, i;
4079 wmi_buf_t buf;
4080
4081 len = sizeof(*cmd);
4082 buf = wmi_buf_alloc(wmi_handle, len);
4083 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304084 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304085 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304086 }
4087
4088 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4089 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
4090 WMITLV_SET_HDR(&cmd->tlv_header,
4091 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
4092 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
4093 cmd->vdev_id = utc->vdev_id;
4094
4095 for (i = 0; i < SIZE_UTC_TIME; i++)
4096 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
4097
4098 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
4099 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
4100
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304101 wmi_mtrace(WMI_OCB_SET_UTC_TIME_CMDID, cmd->vdev_id, 0);
Govind Singh2edc80f2016-03-01 15:30:53 +05304102 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4103 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304104 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304105 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304106 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304107 }
4108
Govind Singh67922e82016-04-01 16:48:57 +05304109 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304110}
4111
4112/**
4113 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
4114 * frames on a channel
4115 * @wmi_handle: pointer to the wmi handle
4116 * @timing_advert: pointer to the timing advertisement struct
4117 *
4118 * Return: 0 on succes
4119 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304120static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304121 struct ocb_timing_advert_param *timing_advert)
4122{
Govind Singh67922e82016-04-01 16:48:57 +05304123 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304124 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
4125 uint8_t *buf_ptr;
4126 uint32_t len, len_template;
4127 wmi_buf_t buf;
4128
4129 len = sizeof(*cmd) +
4130 WMI_TLV_HDR_SIZE;
4131
4132 len_template = timing_advert->template_length;
4133 /* Add padding to the template if needed */
4134 if (len_template % 4 != 0)
4135 len_template += 4 - (len_template % 4);
4136 len += len_template;
4137
4138 buf = wmi_buf_alloc(wmi_handle, len);
4139 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304140 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304141 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304142 }
4143
4144 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4145 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
4146 WMITLV_SET_HDR(&cmd->tlv_header,
4147 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
4148 WMITLV_GET_STRUCT_TLVLEN(
4149 wmi_ocb_start_timing_advert_cmd_fixed_param));
4150 cmd->vdev_id = timing_advert->vdev_id;
4151 cmd->repeat_rate = timing_advert->repeat_rate;
4152 cmd->channel_freq = timing_advert->chan_freq;
4153 cmd->timestamp_offset = timing_advert->timestamp_offset;
4154 cmd->time_value_offset = timing_advert->time_value_offset;
4155 cmd->timing_advert_template_length = timing_advert->template_length;
4156 buf_ptr += sizeof(*cmd);
4157
4158 /* Add the timing advert template */
4159 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4160 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05304161 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05304162 (uint8_t *)timing_advert->template_value,
4163 timing_advert->template_length);
4164
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304165 wmi_mtrace(WMI_OCB_START_TIMING_ADVERT_CMDID, cmd->vdev_id, 0);
Govind Singh2edc80f2016-03-01 15:30:53 +05304166 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4167 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304168 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304169 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304170 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304171 }
4172
Govind Singh67922e82016-04-01 16:48:57 +05304173 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304174}
4175
4176/**
4177 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
4178 * on a channel
4179 * @wmi_handle: pointer to the wmi handle
4180 * @timing_advert: pointer to the timing advertisement struct
4181 *
4182 * Return: 0 on succes
4183 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304184static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304185 struct ocb_timing_advert_param *timing_advert)
4186{
Govind Singh67922e82016-04-01 16:48:57 +05304187 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304188 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
4189 uint8_t *buf_ptr;
4190 uint32_t len;
4191 wmi_buf_t buf;
4192
4193 len = sizeof(*cmd);
4194 buf = wmi_buf_alloc(wmi_handle, len);
4195 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304196 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304197 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304198 }
4199
4200 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4201 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
4202 WMITLV_SET_HDR(&cmd->tlv_header,
4203 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
4204 WMITLV_GET_STRUCT_TLVLEN(
4205 wmi_ocb_stop_timing_advert_cmd_fixed_param));
4206 cmd->vdev_id = timing_advert->vdev_id;
4207 cmd->channel_freq = timing_advert->chan_freq;
4208
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304209 wmi_mtrace(WMI_OCB_STOP_TIMING_ADVERT_CMDID, cmd->vdev_id, 0);
Govind Singh2edc80f2016-03-01 15:30:53 +05304210 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4211 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304212 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304213 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304214 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304215 }
4216
Govind Singh67922e82016-04-01 16:48:57 +05304217 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304218}
4219
4220/**
4221 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
4222 * @wmi_handle: pointer to the wmi handle
4223 * @request: pointer to the request
4224 *
4225 * Return: 0 on succes
4226 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304227static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304228 uint8_t vdev_id)
4229{
Govind Singhb53420c2016-03-09 14:32:57 +05304230 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304231 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
4232 uint8_t *buf_ptr;
4233 wmi_buf_t buf;
4234 int32_t len;
4235
4236 len = sizeof(*cmd);
4237 buf = wmi_buf_alloc(wmi_handle, len);
4238 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304239 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304240 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304241 }
4242 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4243
4244 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304245 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304246 WMITLV_SET_HDR(&cmd->tlv_header,
4247 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
4248 WMITLV_GET_STRUCT_TLVLEN(
4249 wmi_ocb_get_tsf_timer_cmd_fixed_param));
4250 cmd->vdev_id = vdev_id;
4251
4252 /* Send the WMI command */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304253 wmi_mtrace(WMI_OCB_GET_TSF_TIMER_CMDID, cmd->vdev_id, 0);
Govind Singh2edc80f2016-03-01 15:30:53 +05304254 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4255 WMI_OCB_GET_TSF_TIMER_CMDID);
4256 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304257 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304258 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304259 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304260 }
4261
Govind Singh67922e82016-04-01 16:48:57 +05304262 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304263}
4264
4265/**
4266 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
4267 * @wmi_handle: pointer to the wmi handle
4268 * @get_stats_param: pointer to the dcc stats
4269 *
4270 * Return: 0 on succes
4271 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304272static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004273 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304274{
Govind Singh67922e82016-04-01 16:48:57 +05304275 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304276 wmi_dcc_get_stats_cmd_fixed_param *cmd;
4277 wmi_dcc_channel_stats_request *channel_stats_array;
4278 wmi_buf_t buf;
4279 uint8_t *buf_ptr;
4280 uint32_t len;
4281 uint32_t i;
4282
4283 /* Validate the input */
4284 if (get_stats_param->request_array_len !=
4285 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304286 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304287 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304288 }
4289
4290 /* Allocate memory for the WMI command */
4291 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4292 get_stats_param->request_array_len;
4293
4294 buf = wmi_buf_alloc(wmi_handle, len);
4295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304296 WMI_LOGE(FL("wmi_buf_alloc failed"));
4297 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304298 }
4299
4300 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304301 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304302
4303 /* Populate the WMI command */
4304 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4305 buf_ptr += sizeof(*cmd);
4306
4307 WMITLV_SET_HDR(&cmd->tlv_header,
4308 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4309 WMITLV_GET_STRUCT_TLVLEN(
4310 wmi_dcc_get_stats_cmd_fixed_param));
4311 cmd->vdev_id = get_stats_param->vdev_id;
4312 cmd->num_channels = get_stats_param->channel_count;
4313
4314 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4315 get_stats_param->request_array_len);
4316 buf_ptr += WMI_TLV_HDR_SIZE;
4317
4318 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304319 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304320 get_stats_param->request_array_len);
4321 for (i = 0; i < cmd->num_channels; i++)
4322 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4323 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4324 WMITLV_GET_STRUCT_TLVLEN(
4325 wmi_dcc_channel_stats_request));
4326
4327 /* Send the WMI command */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304328 wmi_mtrace(WMI_DCC_GET_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh2edc80f2016-03-01 15:30:53 +05304329 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4330 WMI_DCC_GET_STATS_CMDID);
4331
Govind Singh67922e82016-04-01 16:48:57 +05304332 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304333 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304334 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304335 }
4336
Govind Singh67922e82016-04-01 16:48:57 +05304337 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304338}
4339
4340/**
4341 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4342 * @wmi_handle: pointer to the wmi handle
4343 * @vdev_id: vdev id
4344 * @dcc_stats_bitmap: dcc status bitmap
4345 *
4346 * Return: 0 on succes
4347 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304348static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304349 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4350{
Govind Singh67922e82016-04-01 16:48:57 +05304351 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304352 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4353 wmi_buf_t buf;
4354 uint8_t *buf_ptr;
4355 uint32_t len;
4356
4357 /* Allocate memory for the WMI command */
4358 len = sizeof(*cmd);
4359
4360 buf = wmi_buf_alloc(wmi_handle, len);
4361 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304362 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304363 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304364 }
4365
4366 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304367 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304368
4369 /* Populate the WMI command */
4370 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4371
4372 WMITLV_SET_HDR(&cmd->tlv_header,
4373 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4374 WMITLV_GET_STRUCT_TLVLEN(
4375 wmi_dcc_clear_stats_cmd_fixed_param));
4376 cmd->vdev_id = vdev_id;
4377 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4378
4379 /* Send the WMI command */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304380 wmi_mtrace(WMI_DCC_CLEAR_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh2edc80f2016-03-01 15:30:53 +05304381 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4382 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304383 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304384 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304385 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304386 }
4387
Govind Singh67922e82016-04-01 16:48:57 +05304388 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304389}
4390
4391/**
4392 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4393 * @wmi_handle: pointer to the wmi handle
4394 * @update_ndl_param: pointer to the request parameters
4395 *
4396 * Return: 0 on success
4397 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304398static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004399 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304400{
Govind Singhb53420c2016-03-09 14:32:57 +05304401 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304402 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4403 wmi_dcc_ndl_chan *ndl_chan_array;
4404 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4405 uint32_t active_state_count;
4406 wmi_buf_t buf;
4407 uint8_t *buf_ptr;
4408 uint32_t len;
4409 uint32_t i;
4410
4411 /* validate the input */
4412 if (update_ndl_param->dcc_ndl_chan_list_len !=
4413 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304414 WMI_LOGE(FL("Invalid parameter"));
4415 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304416 }
4417 active_state_count = 0;
4418 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4419 for (i = 0; i < update_ndl_param->channel_count; i++)
4420 active_state_count +=
4421 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4422 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4423 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304424 WMI_LOGE(FL("Invalid parameter"));
4425 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304426 }
4427
4428 /* Allocate memory for the WMI command */
4429 len = sizeof(*cmd) +
4430 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4431 WMI_TLV_HDR_SIZE +
4432 update_ndl_param->dcc_ndl_active_state_list_len;
4433
4434 buf = wmi_buf_alloc(wmi_handle, len);
4435 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304436 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304437 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304438 }
4439
4440 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304441 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304442
4443 /* Populate the WMI command */
4444 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4445 buf_ptr += sizeof(*cmd);
4446
4447 WMITLV_SET_HDR(&cmd->tlv_header,
4448 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4449 WMITLV_GET_STRUCT_TLVLEN(
4450 wmi_dcc_update_ndl_cmd_fixed_param));
4451 cmd->vdev_id = update_ndl_param->vdev_id;
4452 cmd->num_channel = update_ndl_param->channel_count;
4453
4454 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4455 update_ndl_param->dcc_ndl_chan_list_len);
4456 buf_ptr += WMI_TLV_HDR_SIZE;
4457
4458 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304459 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304460 update_ndl_param->dcc_ndl_chan_list_len);
4461 for (i = 0; i < cmd->num_channel; i++)
4462 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4463 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4464 WMITLV_GET_STRUCT_TLVLEN(
4465 wmi_dcc_ndl_chan));
4466 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4467
4468 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4469 update_ndl_param->dcc_ndl_active_state_list_len);
4470 buf_ptr += WMI_TLV_HDR_SIZE;
4471
4472 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304473 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304474 update_ndl_param->dcc_ndl_active_state_list,
4475 update_ndl_param->dcc_ndl_active_state_list_len);
4476 for (i = 0; i < active_state_count; i++) {
4477 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4478 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4479 WMITLV_GET_STRUCT_TLVLEN(
4480 wmi_dcc_ndl_active_state_config));
4481 }
4482 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4483
4484 /* Send the WMI command */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304485 wmi_mtrace(WMI_DCC_UPDATE_NDL_CMDID, cmd->vdev_id, 0);
Govind Singhb53420c2016-03-09 14:32:57 +05304486 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304487 WMI_DCC_UPDATE_NDL_CMDID);
4488 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304489 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304490 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304491 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304492 }
4493
Govind Singh67922e82016-04-01 16:48:57 +05304494 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304495}
4496
4497/**
4498 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4499 * @wmi_handle: pointer to the wmi handle
4500 * @config: the OCB configuration
4501 *
4502 * Return: 0 on success
4503 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304504static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004505 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304506{
Govind Singh67922e82016-04-01 16:48:57 +05304507 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304508 wmi_ocb_set_config_cmd_fixed_param *cmd;
4509 wmi_channel *chan;
4510 wmi_ocb_channel *ocb_chan;
4511 wmi_qos_parameter *qos_param;
4512 wmi_dcc_ndl_chan *ndl_chan;
4513 wmi_dcc_ndl_active_state_config *ndl_active_config;
4514 wmi_ocb_schedule_element *sched_elem;
4515 uint8_t *buf_ptr;
4516 wmi_buf_t buf;
4517 int32_t len;
4518 int32_t i, j, active_state_count;
4519
4520 /*
4521 * Validate the dcc_ndl_chan_list_len and count the number of active
4522 * states. Validate dcc_ndl_active_state_list_len.
4523 */
4524 active_state_count = 0;
4525 if (config->dcc_ndl_chan_list_len) {
4526 if (!config->dcc_ndl_chan_list ||
4527 config->dcc_ndl_chan_list_len !=
4528 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304529 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304530 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304531 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304532 }
4533
4534 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4535 i < config->channel_count; ++i, ++ndl_chan)
4536 active_state_count +=
4537 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4538
4539 if (active_state_count) {
4540 if (!config->dcc_ndl_active_state_list ||
4541 config->dcc_ndl_active_state_list_len !=
4542 active_state_count *
4543 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304544 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304545 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304546 }
4547 }
4548 }
4549
4550 len = sizeof(*cmd) +
4551 WMI_TLV_HDR_SIZE + config->channel_count *
4552 sizeof(wmi_channel) +
4553 WMI_TLV_HDR_SIZE + config->channel_count *
4554 sizeof(wmi_ocb_channel) +
4555 WMI_TLV_HDR_SIZE + config->channel_count *
4556 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4557 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4558 WMI_TLV_HDR_SIZE + active_state_count *
4559 sizeof(wmi_dcc_ndl_active_state_config) +
4560 WMI_TLV_HDR_SIZE + config->schedule_size *
4561 sizeof(wmi_ocb_schedule_element);
4562 buf = wmi_buf_alloc(wmi_handle, len);
4563 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304564 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304565 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304566 }
4567
4568 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4569 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4570 WMITLV_SET_HDR(&cmd->tlv_header,
4571 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4572 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004573 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304574 cmd->channel_count = config->channel_count;
4575 cmd->schedule_size = config->schedule_size;
4576 cmd->flags = config->flags;
4577 buf_ptr += sizeof(*cmd);
4578
4579 /* Add the wmi_channel info */
4580 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4581 config->channel_count*sizeof(wmi_channel));
4582 buf_ptr += WMI_TLV_HDR_SIZE;
4583 for (i = 0; i < config->channel_count; i++) {
4584 chan = (wmi_channel *)buf_ptr;
4585 WMITLV_SET_HDR(&chan->tlv_header,
4586 WMITLV_TAG_STRUC_wmi_channel,
4587 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4588 chan->mhz = config->channels[i].chan_freq;
4589 chan->band_center_freq1 = config->channels[i].chan_freq;
4590 chan->band_center_freq2 = 0;
4591 chan->info = 0;
4592
Zhang Qian11c0de32018-01-05 16:50:53 +08004593 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304594 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4595 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4596 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4597 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4598 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4599 config->channels[i].antenna_max);
4600
4601 if (config->channels[i].bandwidth < 10)
4602 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4603 else if (config->channels[i].bandwidth < 20)
4604 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4605 buf_ptr += sizeof(*chan);
4606 }
4607
4608 /* Add the wmi_ocb_channel info */
4609 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4610 config->channel_count*sizeof(wmi_ocb_channel));
4611 buf_ptr += WMI_TLV_HDR_SIZE;
4612 for (i = 0; i < config->channel_count; i++) {
4613 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4614 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4615 WMITLV_TAG_STRUC_wmi_ocb_channel,
4616 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4617 ocb_chan->bandwidth = config->channels[i].bandwidth;
4618 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4619 config->channels[i].mac_address.bytes,
4620 &ocb_chan->mac_address);
4621 buf_ptr += sizeof(*ocb_chan);
4622 }
4623
4624 /* Add the wmi_qos_parameter info */
4625 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4626 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4627 buf_ptr += WMI_TLV_HDR_SIZE;
4628 /* WMI_MAX_NUM_AC parameters for each channel */
4629 for (i = 0; i < config->channel_count; i++) {
4630 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4631 qos_param = (wmi_qos_parameter *)buf_ptr;
4632 WMITLV_SET_HDR(&qos_param->tlv_header,
4633 WMITLV_TAG_STRUC_wmi_qos_parameter,
4634 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4635 qos_param->aifsn =
4636 config->channels[i].qos_params[j].aifsn;
4637 qos_param->cwmin =
4638 config->channels[i].qos_params[j].cwmin;
4639 qos_param->cwmax =
4640 config->channels[i].qos_params[j].cwmax;
4641 buf_ptr += sizeof(*qos_param);
4642 }
4643 }
4644
4645 /* Add the wmi_dcc_ndl_chan (per channel) */
4646 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4647 config->dcc_ndl_chan_list_len);
4648 buf_ptr += WMI_TLV_HDR_SIZE;
4649 if (config->dcc_ndl_chan_list_len) {
4650 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304651 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304652 config->dcc_ndl_chan_list_len);
4653 for (i = 0; i < config->channel_count; i++)
4654 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4655 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4656 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4657 buf_ptr += config->dcc_ndl_chan_list_len;
4658 }
4659
4660 /* Add the wmi_dcc_ndl_active_state_config */
4661 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4662 sizeof(wmi_dcc_ndl_active_state_config));
4663 buf_ptr += WMI_TLV_HDR_SIZE;
4664 if (active_state_count) {
4665 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304666 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304667 config->dcc_ndl_active_state_list,
4668 active_state_count * sizeof(*ndl_active_config));
4669 for (i = 0; i < active_state_count; ++i)
4670 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4671 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4672 WMITLV_GET_STRUCT_TLVLEN(
4673 wmi_dcc_ndl_active_state_config));
4674 buf_ptr += active_state_count *
4675 sizeof(*ndl_active_config);
4676 }
4677
4678 /* Add the wmi_ocb_schedule_element info */
4679 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4680 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4681 buf_ptr += WMI_TLV_HDR_SIZE;
4682 for (i = 0; i < config->schedule_size; i++) {
4683 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4684 WMITLV_SET_HDR(&sched_elem->tlv_header,
4685 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4686 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4687 sched_elem->channel_freq = config->schedule[i].chan_freq;
4688 sched_elem->total_duration = config->schedule[i].total_duration;
4689 sched_elem->guard_interval = config->schedule[i].guard_interval;
4690 buf_ptr += sizeof(*sched_elem);
4691 }
4692
4693
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304694 wmi_mtrace(WMI_OCB_SET_CONFIG_CMDID, cmd->vdev_id, 0);
Govind Singh2edc80f2016-03-01 15:30:53 +05304695 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4696 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304697 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304698 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304699 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304700 }
4701
Govind Singh67922e82016-04-01 16:48:57 +05304702 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304703}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304704
4705/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004706 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4707 * @wmi_handle: wmi handle
4708 * @evt_buf: wmi event buffer
4709 * @status: status buffer
4710 *
4711 * Return: QDF_STATUS_SUCCESS on success
4712 */
4713static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4714 void *evt_buf,
4715 uint32_t *status)
4716{
4717 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4718 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4719
4720 param_tlvs = evt_buf;
4721 fix_param = param_tlvs->fixed_param;
4722
4723 *status = fix_param->status;
4724 return QDF_STATUS_SUCCESS;
4725}
4726
4727/**
4728 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4729 * @wmi_handle: wmi handle
4730 * @evt_buf: wmi event buffer
4731 * @resp: response buffer
4732 *
4733 * Return: QDF_STATUS_SUCCESS on success
4734 */
4735static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4736 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4737{
4738 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4739 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4740
4741 param_tlvs = evt_buf;
4742 fix_param = param_tlvs->fixed_param;
4743 resp->vdev_id = fix_param->vdev_id;
4744 resp->timer_high = fix_param->tsf_timer_high;
4745 resp->timer_low = fix_param->tsf_timer_low;
4746
4747 return QDF_STATUS_SUCCESS;
4748}
4749
4750/**
4751 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4752 * @wmi_handle: wmi handle
4753 * @evt_buf: wmi event buffer
4754 * @resp: response buffer
4755 *
4756 * Return: QDF_STATUS_SUCCESS on success
4757 */
4758static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4759 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4760{
4761 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4762 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4763
4764 param_tlvs = evt_buf;
4765 fix_param = param_tlvs->fixed_param;
4766 resp->vdev_id = fix_param->vdev_id;
4767 resp->status = fix_param->status;
4768 return QDF_STATUS_SUCCESS;
4769}
4770
4771/**
4772 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4773 * @wmi_handle: wmi handle
4774 * @evt_buf: wmi event buffer
4775 * @resp: response buffer
4776 *
4777 * Since length of stats is variable, buffer for DCC stats will be allocated
4778 * in this function. The caller must free the buffer.
4779 *
4780 * Return: QDF_STATUS_SUCCESS on success
4781 */
4782static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4783 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4784{
4785 struct ocb_dcc_get_stats_response *response;
4786 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4787 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4788
4789 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4790 fix_param = param_tlvs->fixed_param;
4791
4792 /* Allocate and populate the response */
4793 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4794 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4795 WMI_LOGE("%s: too many channels:%d", __func__,
4796 fix_param->num_channels);
4797 QDF_ASSERT(0);
4798 *resp = NULL;
4799 return QDF_STATUS_E_INVAL;
4800 }
4801 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4802 sizeof(wmi_dcc_ndl_stats_per_channel));
4803 *resp = response;
4804 if (!response)
4805 return QDF_STATUS_E_NOMEM;
4806
4807 response->vdev_id = fix_param->vdev_id;
4808 response->num_channels = fix_param->num_channels;
4809 response->channel_stats_array_len =
4810 fix_param->num_channels *
4811 sizeof(wmi_dcc_ndl_stats_per_channel);
4812 response->channel_stats_array = ((uint8_t *)response) +
4813 sizeof(*response);
4814 qdf_mem_copy(response->channel_stats_array,
4815 param_tlvs->stats_per_channel_list,
4816 response->channel_stats_array_len);
4817
4818 return QDF_STATUS_SUCCESS;
4819}
4820#endif
4821
4822/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304823 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4824 * @wmi_handle: wmi handle
4825 * @mcc_adaptive_scheduler: enable/disable
4826 *
4827 * This function enable/disable mcc adaptive scheduler in fw.
4828 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -07004829 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304830 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304831static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004832 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4833 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304834{
Govind Singh67922e82016-04-01 16:48:57 +05304835 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304836 wmi_buf_t buf = 0;
4837 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4838 uint16_t len =
4839 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4840
4841 buf = wmi_buf_alloc(wmi_handle, len);
4842 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304843 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4844 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304845 }
4846 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4847 wmi_buf_data(buf);
4848
4849 WMITLV_SET_HDR(&cmd->tlv_header,
4850 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4851 WMITLV_GET_STRUCT_TLVLEN
4852 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4853 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304854 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304855
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304856 wmi_mtrace(WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID, NO_SESSION, 0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304857 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4858 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304859 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304860 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304861 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304862 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304863 }
Govind Singh67922e82016-04-01 16:48:57 +05304864
4865 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304866}
4867
4868/**
4869 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4870 * @wmi: wmi handle
4871 * @mcc_channel: mcc channel
4872 * @mcc_channel_time_latency: MCC channel time latency.
4873 *
4874 * Currently used to set time latency for an MCC vdev/adapter using operating
4875 * channel of it and channel number. The info is provided run time using
4876 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4877 *
4878 * Return: CDF status
4879 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304880static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304881 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4882{
Govind Singh67922e82016-04-01 16:48:57 +05304883 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304884 wmi_buf_t buf = 0;
4885 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4886 uint16_t len = 0;
4887 uint8_t *buf_ptr = NULL;
4888 wmi_resmgr_chan_latency chan_latency;
4889 /* Note: we only support MCC time latency for a single channel */
4890 uint32_t num_channels = 1;
4891 uint32_t chan1_freq = mcc_channel_freq;
4892 uint32_t latency_chan1 = mcc_channel_time_latency;
4893
4894
4895 /* If 0ms latency is provided, then FW will set to a default.
4896 * Otherwise, latency must be at least 30ms.
4897 */
4898 if ((latency_chan1 > 0) &&
4899 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304900 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304901 "Minimum is 30ms (or 0 to use default value by "
4902 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304903 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304904 }
4905
4906 /* Set WMI CMD for channel time latency here */
4907 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4908 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4909 num_channels * sizeof(wmi_resmgr_chan_latency);
4910 buf = wmi_buf_alloc(wmi_handle, len);
4911 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304912 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4913 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304914 }
4915 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4916 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4917 wmi_buf_data(buf);
4918 WMITLV_SET_HDR(&cmdTL->tlv_header,
4919 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4920 WMITLV_GET_STRUCT_TLVLEN
4921 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4922 cmdTL->num_chans = num_channels;
4923 /* Update channel time latency information for home channel(s) */
4924 buf_ptr += sizeof(*cmdTL);
4925 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4926 num_channels * sizeof(wmi_resmgr_chan_latency));
4927 buf_ptr += WMI_TLV_HDR_SIZE;
4928 chan_latency.chan_mhz = chan1_freq;
4929 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304930 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304931 wmi_mtrace(WMI_RESMGR_SET_CHAN_LATENCY_CMDID, NO_SESSION, 0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304932 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4933 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304934 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304935 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304936 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304937 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304938 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304939 }
Govind Singh67922e82016-04-01 16:48:57 +05304940
4941 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304942}
4943
4944/**
4945 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4946 * @wmi: wmi handle
4947 * @adapter_1_chan_number: adapter 1 channel number
4948 * @adapter_1_quota: adapter 1 quota
4949 * @adapter_2_chan_number: adapter 2 channel number
4950 *
4951 * Return: CDF status
4952 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304953static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304954 uint32_t adapter_1_chan_freq,
4955 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4956{
Govind Singh67922e82016-04-01 16:48:57 +05304957 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304958 wmi_buf_t buf = 0;
4959 uint16_t len = 0;
4960 uint8_t *buf_ptr = NULL;
4961 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4962 wmi_resmgr_chan_time_quota chan_quota;
4963 uint32_t quota_chan1 = adapter_1_quota;
4964 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4965 uint32_t quota_chan2 = 100 - quota_chan1;
4966 /* Note: setting time quota for MCC requires info for 2 channels */
4967 uint32_t num_channels = 2;
4968 uint32_t chan1_freq = adapter_1_chan_freq;
4969 uint32_t chan2_freq = adapter_2_chan_freq;
4970
Govind Singhb53420c2016-03-09 14:32:57 +05304971 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304972 "freq2:%dMHz, Quota2:%dms", __func__,
4973 chan1_freq, quota_chan1, chan2_freq,
4974 quota_chan2);
4975
4976 /*
4977 * Perform sanity check on time quota values provided.
4978 */
4979 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4980 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304981 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304982 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304983 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304984 }
4985 /* Set WMI CMD for channel time quota here */
4986 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4987 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4988 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4989 buf = wmi_buf_alloc(wmi_handle, len);
4990 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304991 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4992 QDF_ASSERT(0);
4993 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304994 }
4995 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4996 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4997 wmi_buf_data(buf);
4998 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4999 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
5000 WMITLV_GET_STRUCT_TLVLEN
5001 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
5002 cmdTQ->num_chans = num_channels;
5003
5004 /* Update channel time quota information for home channel(s) */
5005 buf_ptr += sizeof(*cmdTQ);
5006 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5007 num_channels * sizeof(wmi_resmgr_chan_time_quota));
5008 buf_ptr += WMI_TLV_HDR_SIZE;
5009 chan_quota.chan_mhz = chan1_freq;
5010 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05305011 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05305012 /* Construct channel and quota record for the 2nd MCC mode. */
5013 buf_ptr += sizeof(chan_quota);
5014 chan_quota.chan_mhz = chan2_freq;
5015 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05305016 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05305017
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305018 wmi_mtrace(WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID, NO_SESSION, 0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305019 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5020 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305021 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305022 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305023 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305024 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305025 }
Govind Singh67922e82016-04-01 16:48:57 +05305026
5027 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305028}
5029
5030/**
5031 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
5032 * @wmi_handle: Pointer to wmi handle
5033 * @thermal_info: Thermal command information
5034 *
5035 * This function sends the thermal management command
5036 * to the firmware
5037 *
Govind Singhb53420c2016-03-09 14:32:57 +05305038 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05305039 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305040static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05305041 struct thermal_cmd_params *thermal_info)
5042{
5043 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
5044 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305045 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305046 uint32_t len = 0;
5047
5048 len = sizeof(*cmd);
5049
5050 buf = wmi_buf_alloc(wmi_handle, len);
5051 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305052 WMI_LOGE("Failed to allocate buffer to send set key cmd");
5053 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305054 }
5055
5056 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
5057
5058 WMITLV_SET_HDR(&cmd->tlv_header,
5059 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
5060 WMITLV_GET_STRUCT_TLVLEN
5061 (wmi_thermal_mgmt_cmd_fixed_param));
5062
5063 cmd->lower_thresh_degreeC = thermal_info->min_temp;
5064 cmd->upper_thresh_degreeC = thermal_info->max_temp;
5065 cmd->enable = thermal_info->thermal_enable;
5066
Govind Singhb53420c2016-03-09 14:32:57 +05305067 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05305068 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
5069
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305070 wmi_mtrace(WMI_THERMAL_MGMT_CMDID, NO_SESSION, 0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305071 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5072 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305073 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305074 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305075 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305076 }
5077
Govind Singh67922e82016-04-01 16:48:57 +05305078 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305079}
5080
5081
5082/**
5083 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05305084 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05305085 * @wmi_lro_cmd: Pointer to LRO configuration parameters
5086 *
5087 * This function sends down the LRO configuration parameters to
5088 * the firmware to enable LRO, sets the TCP flags and sets the
5089 * seed values for the toeplitz hash generation
5090 *
Govind Singhb53420c2016-03-09 14:32:57 +05305091 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05305092 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305093static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05305094 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
5095{
5096 wmi_lro_info_cmd_fixed_param *cmd;
5097 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305098 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305099
5100
5101 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5102 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305103 WMI_LOGE("Failed to allocate buffer to send set key cmd");
5104 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305105 }
5106
5107 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
5108
5109 WMITLV_SET_HDR(&cmd->tlv_header,
5110 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
5111 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
5112
5113 cmd->lro_enable = wmi_lro_cmd->lro_enable;
5114 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
5115 wmi_lro_cmd->tcp_flag);
5116 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
5117 wmi_lro_cmd->tcp_flag_mask);
5118 cmd->toeplitz_hash_ipv4_0_3 =
5119 wmi_lro_cmd->toeplitz_hash_ipv4[0];
5120 cmd->toeplitz_hash_ipv4_4_7 =
5121 wmi_lro_cmd->toeplitz_hash_ipv4[1];
5122 cmd->toeplitz_hash_ipv4_8_11 =
5123 wmi_lro_cmd->toeplitz_hash_ipv4[2];
5124 cmd->toeplitz_hash_ipv4_12_15 =
5125 wmi_lro_cmd->toeplitz_hash_ipv4[3];
5126 cmd->toeplitz_hash_ipv4_16 =
5127 wmi_lro_cmd->toeplitz_hash_ipv4[4];
5128
5129 cmd->toeplitz_hash_ipv6_0_3 =
5130 wmi_lro_cmd->toeplitz_hash_ipv6[0];
5131 cmd->toeplitz_hash_ipv6_4_7 =
5132 wmi_lro_cmd->toeplitz_hash_ipv6[1];
5133 cmd->toeplitz_hash_ipv6_8_11 =
5134 wmi_lro_cmd->toeplitz_hash_ipv6[2];
5135 cmd->toeplitz_hash_ipv6_12_15 =
5136 wmi_lro_cmd->toeplitz_hash_ipv6[3];
5137 cmd->toeplitz_hash_ipv6_16_19 =
5138 wmi_lro_cmd->toeplitz_hash_ipv6[4];
5139 cmd->toeplitz_hash_ipv6_20_23 =
5140 wmi_lro_cmd->toeplitz_hash_ipv6[5];
5141 cmd->toeplitz_hash_ipv6_24_27 =
5142 wmi_lro_cmd->toeplitz_hash_ipv6[6];
5143 cmd->toeplitz_hash_ipv6_28_31 =
5144 wmi_lro_cmd->toeplitz_hash_ipv6[7];
5145 cmd->toeplitz_hash_ipv6_32_35 =
5146 wmi_lro_cmd->toeplitz_hash_ipv6[8];
5147 cmd->toeplitz_hash_ipv6_36_39 =
5148 wmi_lro_cmd->toeplitz_hash_ipv6[9];
5149 cmd->toeplitz_hash_ipv6_40 =
5150 wmi_lro_cmd->toeplitz_hash_ipv6[10];
5151
Govind Singhb53420c2016-03-09 14:32:57 +05305152 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05305153 cmd->lro_enable, cmd->tcp_flag_u32);
5154
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305155 wmi_mtrace(WMI_LRO_CONFIG_CMDID, NO_SESSION, 0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305156 status = wmi_unified_cmd_send(wmi_handle, buf,
5157 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305158 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305159 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305160 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05305161 }
5162
Govind Singh67922e82016-04-01 16:48:57 +05305163 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05305164}
5165
Govind Singh4eacd2b2016-03-07 14:24:22 +05305166/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305167 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
5168 * @wmi_handle: Pointer to wmi handle
5169 * @rate_report_params: Pointer to peer rate report parameters
5170 *
5171 *
5172 * Return: QDF_STATUS_SUCCESS for success otherwise failure
5173 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305174static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305175 struct wmi_peer_rate_report_params *rate_report_params)
5176{
5177 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
5178 wmi_buf_t buf = NULL;
5179 QDF_STATUS status = 0;
5180 uint32_t len = 0;
5181 uint32_t i, j;
5182
5183 len = sizeof(*cmd);
5184
5185 buf = wmi_buf_alloc(wmi_handle, len);
5186 if (!buf) {
5187 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
5188 return QDF_STATUS_E_FAILURE;
5189 }
5190
5191 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
5192 wmi_buf_data(buf);
5193
5194 WMITLV_SET_HDR(
5195 &cmd->tlv_header,
5196 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
5197 WMITLV_GET_STRUCT_TLVLEN(
5198 wmi_peer_set_rate_report_condition_fixed_param));
5199
5200 cmd->enable_rate_report = rate_report_params->rate_report_enable;
5201 cmd->report_backoff_time = rate_report_params->backoff_time;
5202 cmd->report_timer_period = rate_report_params->timer_period;
5203 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
5204 cmd->cond_per_phy[i].val_cond_flags =
5205 rate_report_params->report_per_phy[i].cond_flags;
5206 cmd->cond_per_phy[i].rate_delta.min_delta =
5207 rate_report_params->report_per_phy[i].delta.delta_min;
5208 cmd->cond_per_phy[i].rate_delta.percentage =
5209 rate_report_params->report_per_phy[i].delta.percent;
5210 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
5211 cmd->cond_per_phy[i].rate_threshold[j] =
5212 rate_report_params->report_per_phy[i].
5213 report_rate_threshold[j];
5214 }
5215 }
5216
5217 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
5218 cmd->enable_rate_report,
5219 cmd->report_backoff_time, cmd->report_timer_period);
5220
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305221 wmi_mtrace(WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID, NO_SESSION, 0);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305222 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5223 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
5224 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305225 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305226 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
5227 __func__);
5228 }
5229 return status;
5230}
5231
5232/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05305233 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
5234 * @wmi_handle: wmi handle
5235 * @param: bcn ll cmd parameter
5236 *
Govind Singhb53420c2016-03-09 14:32:57 +05305237 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305238 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305239static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305240 wmi_bcn_send_from_host_cmd_fixed_param *param)
5241{
5242 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
5243 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05305244 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305245
5246 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5247 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305248 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5249 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305250 }
5251
5252 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
5253 WMITLV_SET_HDR(&cmd->tlv_header,
5254 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
5255 WMITLV_GET_STRUCT_TLVLEN
5256 (wmi_bcn_send_from_host_cmd_fixed_param));
5257 cmd->vdev_id = param->vdev_id;
5258 cmd->data_len = param->data_len;
5259 cmd->frame_ctrl = param->frame_ctrl;
5260 cmd->frag_ptr = param->frag_ptr;
5261 cmd->dtim_flag = param->dtim_flag;
5262
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305263 wmi_mtrace(WMI_PDEV_SEND_BCN_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305264 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
5265 WMI_PDEV_SEND_BCN_CMDID);
5266
Govind Singh67922e82016-04-01 16:48:57 +05305267 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305268 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305269 wmi_buf_free(wmi_buf);
5270 }
5271
5272 return ret;
5273}
5274
5275/**
5276 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
5277 * @wmi_handle: wmi handle
5278 * @vdev_id: vdev id
5279 * @max_retries: max retries
5280 * @retry_interval: retry interval
5281 * This function sets sta query related parameters in fw.
5282 *
Govind Singhb53420c2016-03-09 14:32:57 +05305283 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305284 */
5285
Sathish Kumarfd347372017-02-13 12:29:09 +05305286static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305287 uint8_t vdev_id, uint32_t max_retries,
5288 uint32_t retry_interval)
5289{
5290 wmi_buf_t buf;
5291 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5292 int len;
5293
5294 len = sizeof(*cmd);
5295 buf = wmi_buf_alloc(wmi_handle, len);
5296 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305297 WMI_LOGE(FL("wmi_buf_alloc failed"));
5298 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305299 }
5300
5301 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5302 WMITLV_SET_HDR(&cmd->tlv_header,
5303 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5304 WMITLV_GET_STRUCT_TLVLEN
5305 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5306
5307
5308 cmd->vdev_id = vdev_id;
5309 cmd->sa_query_max_retry_count = max_retries;
5310 cmd->sa_query_retry_interval = retry_interval;
5311
Govind Singhb53420c2016-03-09 14:32:57 +05305312 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305313 vdev_id, retry_interval, max_retries);
5314
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305315 wmi_mtrace(WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305316 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5317 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305318 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305319 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305320 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305321 }
5322
Govind Singhb53420c2016-03-09 14:32:57 +05305323 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305324 return 0;
5325}
5326
5327/**
5328 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5329 * @wmi_handle: wmi handle
5330 * @params: sta keep alive parameter
5331 *
5332 * This function sets keep alive related parameters in fw.
5333 *
5334 * Return: CDF status
5335 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305336static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305337 struct sta_params *params)
5338{
5339 wmi_buf_t buf;
5340 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5341 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5342 uint8_t *buf_ptr;
5343 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305344 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305345
Govind Singhb53420c2016-03-09 14:32:57 +05305346 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305347
Govind Singh4eacd2b2016-03-07 14:24:22 +05305348 len = sizeof(*cmd) + sizeof(*arp_rsp);
5349 buf = wmi_buf_alloc(wmi_handle, len);
5350 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305351 WMI_LOGE("wmi_buf_alloc failed");
5352 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305353 }
5354
5355 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5356 buf_ptr = (uint8_t *) cmd;
5357 WMITLV_SET_HDR(&cmd->tlv_header,
5358 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5359 WMITLV_GET_STRUCT_TLVLEN
5360 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5361 cmd->interval = params->timeperiod;
5362 cmd->enable = (params->timeperiod) ? 1 : 0;
5363 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305364 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305365 params->timeperiod, params->method);
5366 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5367 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5368 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5369 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5370
c_manjee2772b9c2017-01-23 15:14:13 +05305371 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5372 (params->method ==
5373 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305374 if ((NULL == params->hostv4addr) ||
5375 (NULL == params->destv4addr) ||
5376 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005377 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5378 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305379 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305380 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305381 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305382 }
c_manjee2772b9c2017-01-23 15:14:13 +05305383 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305384 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305385 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305386 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305387 WMI_IPV4_ADDR_LEN);
5388 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5389 } else {
5390 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5391 }
5392
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305393 wmi_mtrace(WMI_STA_KEEPALIVE_CMDID, cmd->vdev_id, 0);
Govind Singh67922e82016-04-01 16:48:57 +05305394 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5395 WMI_STA_KEEPALIVE_CMDID);
5396 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305397 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305398 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305399 }
5400
Govind Singhb53420c2016-03-09 14:32:57 +05305401 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305402 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305403}
5404
5405/**
5406 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5407 * @wmi_handle: wmi handle
5408 * @if_id: vdev id
5409 * @gtx_info: GTX config params
5410 *
5411 * This function set GTX related params in firmware.
5412 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305413 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305414 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305415static 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 +05305416 struct wmi_gtx_config *gtx_info)
5417{
5418 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5419 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305420 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305421 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305422
Govind Singh4eacd2b2016-03-07 14:24:22 +05305423 buf = wmi_buf_alloc(wmi_handle, len);
5424 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305425 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305426 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305427 }
5428 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5429 WMITLV_SET_HDR(&cmd->tlv_header,
5430 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5431 WMITLV_GET_STRUCT_TLVLEN
5432 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5433 cmd->vdev_id = if_id;
5434
5435 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5436 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5437 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5438 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5439 cmd->gtxPERMargin = gtx_info->gtx_margin;
5440 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5441 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5442 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5443
Govind Singhb53420c2016-03-09 14:32:57 +05305444 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305445 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5446 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5447 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5448 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5449
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305450 wmi_mtrace(WMI_VDEV_SET_GTX_PARAMS_CMDID, cmd->vdev_id, 0);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305451 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305452 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305453 if (QDF_IS_STATUS_ERROR(ret)) {
5454 WMI_LOGE("Failed to set GTX PARAMS");
5455 wmi_buf_free(buf);
5456 }
5457 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305458}
5459
5460/**
5461 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5462 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305463 * @vdev_id: vdev id.
5464 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305465 *
5466 * This function updates EDCA parameters to the target
5467 *
5468 * Return: CDF Status
5469 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305470static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005471 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305472 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305473{
5474 uint8_t *buf_ptr;
5475 wmi_buf_t buf;
5476 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305477 wmi_wmm_vparams *wmm_param;
5478 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305479 int len = sizeof(*cmd);
5480 int ac;
5481
5482 buf = wmi_buf_alloc(wmi_handle, len);
5483
5484 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305485 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5486 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305487 }
5488
5489 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5490 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5491 WMITLV_SET_HDR(&cmd->tlv_header,
5492 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5493 WMITLV_GET_STRUCT_TLVLEN
5494 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5495 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005496 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305497
5498 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5499 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305500 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305501 WMITLV_SET_HDR(&wmm_param->tlv_header,
5502 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5503 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5504 wmm_param->cwmin = twmm_param->cwmin;
5505 wmm_param->cwmax = twmm_param->cwmax;
5506 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005507 if (mu_edca_param)
5508 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5509 else
5510 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305511 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305512 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305513 }
5514
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305515 wmi_mtrace(WMI_VDEV_SET_WMM_PARAMS_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305516 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5517 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5518 goto fail;
5519
Govind Singhb53420c2016-03-09 14:32:57 +05305520 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305521
5522fail:
5523 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305524 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5525 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305526}
5527
5528/**
5529 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5530 * @wmi_handle: wmi handle
5531 * @vdev_id: vdev id
5532 * @probe_rsp_info: probe response info
5533 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305534 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305535 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305536static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305537 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005538 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305539{
5540 wmi_prb_tmpl_cmd_fixed_param *cmd;
5541 wmi_bcn_prb_info *bcn_prb_info;
5542 wmi_buf_t wmi_buf;
5543 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5544 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305545 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305546
Govind Singhb53420c2016-03-09 14:32:57 +05305547 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305548
Krunal Soni89426862017-11-14 15:42:48 -08005549 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305550 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305551
5552 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5553 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5554 tmpl_len_aligned;
5555
5556 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305557 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305558 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305559 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305560 }
5561
5562 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5563 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305564 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305565 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305566 }
5567
5568 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5569
5570 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5571 WMITLV_SET_HDR(&cmd->tlv_header,
5572 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5573 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5574 cmd->vdev_id = vdev_id;
5575 cmd->buf_len = tmpl_len;
5576 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5577
5578 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5579 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5580 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5581 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5582 bcn_prb_info->caps = 0;
5583 bcn_prb_info->erp = 0;
5584 buf_ptr += sizeof(wmi_bcn_prb_info);
5585
5586 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5587 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005588 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305589
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305590 wmi_mtrace(WMI_PRB_TMPL_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305591 ret = wmi_unified_cmd_send(wmi_handle,
5592 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305593 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305594 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305595 wmi_buf_free(wmi_buf);
5596 }
5597
5598 return ret;
5599}
5600
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305601#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305602#define WPI_IV_LEN 16
5603
5604/**
5605 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5606 *
5607 * @dest_tx: destination address of tsc key counter
5608 * @src_tx: source address of tsc key counter
5609 * @dest_rx: destination address of rsc key counter
5610 * @src_rx: source address of rsc key counter
5611 *
5612 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5613 *
5614 * Return: None
5615 *
5616 */
5617static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5618 uint8_t *dest_rx, uint8_t *src_rx)
5619{
5620 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5621 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5622}
5623#else
5624static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5625 uint8_t *dest_rx, uint8_t *src_rx)
5626{
5627 return;
5628}
5629#endif
5630
5631/**
5632 * send_setup_install_key_cmd_tlv() - set key parameters
5633 * @wmi_handle: wmi handle
5634 * @key_params: key parameters
5635 *
5636 * This function fills structure from information
5637 * passed in key_params.
5638 *
5639 * Return: QDF_STATUS_SUCCESS - success
5640 * QDF_STATUS_E_FAILURE - failure
5641 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5642 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305643static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305644 struct set_key_params *key_params)
5645{
5646 wmi_vdev_install_key_cmd_fixed_param *cmd;
5647 wmi_buf_t buf;
5648 uint8_t *buf_ptr;
5649 uint32_t len;
5650 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305651 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305652
5653 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5654 WMI_TLV_HDR_SIZE;
5655
5656 buf = wmi_buf_alloc(wmi_handle, len);
5657 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305658 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305659 return QDF_STATUS_E_NOMEM;
5660 }
5661
5662 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5663 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5664 WMITLV_SET_HDR(&cmd->tlv_header,
5665 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5666 WMITLV_GET_STRUCT_TLVLEN
5667 (wmi_vdev_install_key_cmd_fixed_param));
5668 cmd->vdev_id = key_params->vdev_id;
5669 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305670
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305671
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305672 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5673 cmd->key_flags |= key_params->key_flags;
5674 cmd->key_cipher = key_params->key_cipher;
5675 if ((key_params->key_txmic_len) &&
5676 (key_params->key_rxmic_len)) {
5677 cmd->key_txmic_len = key_params->key_txmic_len;
5678 cmd->key_rxmic_len = key_params->key_rxmic_len;
5679 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305680#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305681 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5682 key_params->tx_iv,
5683 cmd->wpi_key_rsc_counter,
5684 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305685#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305686 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5687 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5688 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305689 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305690 qdf_mem_copy((void *)key_data,
5691 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005692 if (key_params->key_rsc_counter)
5693 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5694 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305695 cmd->key_len = key_params->key_len;
5696
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305697 wmi_mtrace(WMI_VDEV_INSTALL_KEY_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305698 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5699 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305700 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305701 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305702
Govind Singh67922e82016-04-01 16:48:57 +05305703 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305704}
5705
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305706/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005707 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5708 * @wmi_handle: wmi handle
5709 * @params: sar limit params
5710 *
5711 * Return: QDF_STATUS_SUCCESS for success or error code
5712 */
5713static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5714 struct sar_limit_cmd_params *sar_limit_params)
5715{
5716 wmi_buf_t buf;
5717 QDF_STATUS qdf_status;
5718 wmi_sar_limits_cmd_fixed_param *cmd;
5719 int i;
5720 uint8_t *buf_ptr;
5721 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5722 struct sar_limit_cmd_row *sar_rows_list;
5723 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5724
5725 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5726 buf = wmi_buf_alloc(wmi_handle, len);
5727 if (!buf) {
5728 WMI_LOGE("Failed to allocate memory");
5729 qdf_status = QDF_STATUS_E_NOMEM;
5730 goto end;
5731 }
5732
5733 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5734 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5735 WMITLV_SET_HDR(&cmd->tlv_header,
5736 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5737 WMITLV_GET_STRUCT_TLVLEN
5738 (wmi_sar_limits_cmd_fixed_param));
5739 cmd->sar_enable = sar_limit_params->sar_enable;
5740 cmd->commit_limits = sar_limit_params->commit_limits;
5741 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5742
5743 WMI_LOGD("no of sar rows = %d, len = %d",
5744 sar_limit_params->num_limit_rows, len);
5745 buf_ptr += sizeof(*cmd);
5746 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5747 sizeof(wmi_sar_limit_cmd_row) *
5748 sar_limit_params->num_limit_rows);
5749 if (cmd->num_limit_rows == 0)
5750 goto send_sar_limits;
5751
5752 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5753 (buf_ptr + WMI_TLV_HDR_SIZE);
5754 sar_rows_list = sar_limit_params->sar_limit_row_list;
5755
5756 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5757 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5758 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5759 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5760 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5761 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5762 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5763 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5764 wmi_sar_rows_list->validity_bitmap =
5765 sar_rows_list->validity_bitmap;
5766 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5767 i, wmi_sar_rows_list->band_id,
5768 wmi_sar_rows_list->chain_id,
5769 wmi_sar_rows_list->mod_id,
5770 wmi_sar_rows_list->limit_value,
5771 wmi_sar_rows_list->validity_bitmap);
5772 sar_rows_list++;
5773 wmi_sar_rows_list++;
5774 }
5775send_sar_limits:
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305776 wmi_mtrace(WMI_SAR_LIMITS_CMDID, NO_SESSION, 0);
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005777 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5778 WMI_SAR_LIMITS_CMDID);
5779
5780 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5781 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5782 wmi_buf_free(buf);
5783 }
5784
5785end:
5786 return qdf_status;
5787}
5788
Jeff Johnson4783f902017-12-14 15:50:16 -08005789static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5790{
5791 wmi_sar_get_limits_cmd_fixed_param *cmd;
5792 wmi_buf_t wmi_buf;
5793 uint32_t len;
5794 QDF_STATUS status;
5795
5796 WMI_LOGD(FL("Enter"));
5797
5798 len = sizeof(*cmd);
5799 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5800 if (!wmi_buf) {
5801 WMI_LOGP(FL("failed to allocate memory for msg"));
5802 return QDF_STATUS_E_NOMEM;
5803 }
5804
5805 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5806
5807 WMITLV_SET_HDR(&cmd->tlv_header,
5808 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5809 WMITLV_GET_STRUCT_TLVLEN
5810 (wmi_sar_get_limits_cmd_fixed_param));
5811
5812 cmd->reserved = 0;
5813
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305814 wmi_mtrace(WMI_SAR_GET_LIMITS_CMDID, NO_SESSION, 0);
Jeff Johnson4783f902017-12-14 15:50:16 -08005815 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5816 WMI_SAR_GET_LIMITS_CMDID);
5817 if (QDF_IS_STATUS_ERROR(status)) {
5818 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5819 wmi_buf_free(wmi_buf);
5820 }
5821
5822 WMI_LOGD(FL("Exit"));
5823
5824 return status;
5825}
5826
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07005827/**
5828 * wmi_sar2_result_string() - return string conversion of sar2 result
5829 * @result: sar2 result value
5830 *
5831 * This utility function helps log string conversion of sar2 result.
5832 *
5833 * Return: string conversion of sar 2 result, if match found;
5834 * "Unknown response" otherwise.
5835 */
5836static const char *wmi_sar2_result_string(uint32_t result)
5837{
5838 switch (result) {
5839 CASE_RETURN_STRING(WMI_SAR2_SUCCESS);
5840 CASE_RETURN_STRING(WMI_SAR2_INVALID_ANTENNA_INDEX);
5841 CASE_RETURN_STRING(WMI_SAR2_INVALID_TABLE_INDEX);
5842 CASE_RETURN_STRING(WMI_SAR2_STATE_ERROR);
5843 CASE_RETURN_STRING(WMI_SAR2_BDF_NO_TABLE);
5844 default:
5845 return "Unknown response";
5846 }
5847}
5848
5849/**
5850 * extract_sar2_result_event_tlv() - process sar response event from FW.
5851 * @handle: wma handle
5852 * @event: event buffer
5853 * @len: buffer length
5854 *
5855 * Return: 0 for success or error code
5856 */
5857static QDF_STATUS extract_sar2_result_event_tlv(void *handle,
5858 uint8_t *event,
5859 uint32_t len)
5860{
5861 wmi_sar2_result_event_fixed_param *sar2_fixed_param;
5862
5863 WMI_SAR2_RESULT_EVENTID_param_tlvs *param_buf =
5864 (WMI_SAR2_RESULT_EVENTID_param_tlvs *)event;
5865
5866 if (!param_buf) {
5867 WMI_LOGI("Invalid sar2 result event buffer");
5868 return QDF_STATUS_E_INVAL;
5869 }
5870
5871 sar2_fixed_param = param_buf->fixed_param;
5872 if (!sar2_fixed_param) {
5873 WMI_LOGI("Invalid sar2 result event fixed param buffer");
5874 return QDF_STATUS_E_INVAL;
5875 }
5876
5877 WMI_LOGI("SAR2 result: %s",
5878 wmi_sar2_result_string(sar2_fixed_param->result));
5879
5880 return QDF_STATUS_SUCCESS;
5881}
5882
Jeff Johnson4783f902017-12-14 15:50:16 -08005883static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5884 uint8_t *evt_buf,
5885 struct sar_limit_event *event)
5886{
5887 wmi_sar_get_limits_event_fixed_param *fixed_param;
5888 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5889 wmi_sar_get_limit_event_row *row_in;
5890 struct sar_limit_event_row *row_out;
5891 uint32_t row;
5892
5893 if (!evt_buf) {
5894 WMI_LOGE(FL("input event is NULL"));
5895 return QDF_STATUS_E_INVAL;
5896 }
5897 if (!event) {
5898 WMI_LOGE(FL("output event is NULL"));
5899 return QDF_STATUS_E_INVAL;
5900 }
5901
5902 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5903
5904 fixed_param = param_buf->fixed_param;
5905 if (!fixed_param) {
5906 WMI_LOGE(FL("Invalid fixed param"));
5907 return QDF_STATUS_E_INVAL;
5908 }
5909
5910 event->sar_enable = fixed_param->sar_enable;
5911 event->num_limit_rows = fixed_param->num_limit_rows;
5912
Manikandan Mohane8091862018-09-05 15:09:06 -07005913 if (event->num_limit_rows > param_buf->num_sar_get_limits) {
5914 WMI_LOGE(FL("Num rows %d exceeds sar_get_limits rows len %d"),
5915 event->num_limit_rows, param_buf->num_sar_get_limits);
5916 return QDF_STATUS_E_INVAL;
5917 }
5918
Jeff Johnson4783f902017-12-14 15:50:16 -08005919 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5920 QDF_ASSERT(0);
5921 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5922 event->num_limit_rows,
5923 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5924 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5925 }
5926
5927 row_in = param_buf->sar_get_limits;
5928 row_out = &event->sar_limit_row[0];
5929 for (row = 0; row < event->num_limit_rows; row++) {
5930 row_out->band_id = row_in->band_id;
5931 row_out->chain_id = row_in->chain_id;
5932 row_out->mod_id = row_in->mod_id;
5933 row_out->limit_value = row_in->limit_value;
5934 row_out++;
5935 row_in++;
5936 }
5937
5938 return QDF_STATUS_SUCCESS;
5939}
5940
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305941#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005942/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305943 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5944 * @wmi_handle: wmi handle
5945 * @params: encrypt/decrypt params
5946 *
5947 * Return: QDF_STATUS_SUCCESS for success or error code
5948 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005949static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305950QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305951 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305952{
5953 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5954 wmi_buf_t wmi_buf;
5955 uint8_t *buf_ptr;
5956 QDF_STATUS ret;
5957 uint32_t len;
5958
5959 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5960
5961 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305962 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305963 WMI_TLV_HDR_SIZE;
5964 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5965 if (!wmi_buf) {
5966 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5967 __func__);
5968 return QDF_STATUS_E_NOMEM;
5969 }
5970
5971 buf_ptr = wmi_buf_data(wmi_buf);
5972 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5973
5974 WMITLV_SET_HDR(&cmd->tlv_header,
5975 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5976 WMITLV_GET_STRUCT_TLVLEN(
5977 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5978
5979 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5980 cmd->key_flag = encrypt_decrypt_params->key_flag;
5981 cmd->key_idx = encrypt_decrypt_params->key_idx;
5982 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5983 cmd->key_len = encrypt_decrypt_params->key_len;
5984 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5985 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5986
5987 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5988 encrypt_decrypt_params->key_len);
5989
5990 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5991 MAX_MAC_HEADER_LEN);
5992
5993 cmd->data_len = encrypt_decrypt_params->data_len;
5994
5995 if (cmd->data_len) {
5996 buf_ptr += sizeof(*cmd);
5997 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5998 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305999 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05306000 buf_ptr += WMI_TLV_HDR_SIZE;
6001 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
6002 encrypt_decrypt_params->data_len);
6003 }
6004
6005 /* This conversion is to facilitate data to FW in little endian */
6006 cmd->pn[5] = encrypt_decrypt_params->pn[0];
6007 cmd->pn[4] = encrypt_decrypt_params->pn[1];
6008 cmd->pn[3] = encrypt_decrypt_params->pn[2];
6009 cmd->pn[2] = encrypt_decrypt_params->pn[3];
6010 cmd->pn[1] = encrypt_decrypt_params->pn[4];
6011 cmd->pn[0] = encrypt_decrypt_params->pn[5];
6012
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306013 wmi_mtrace(WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID, cmd->vdev_id, 0);
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05306014 ret = wmi_unified_cmd_send(wmi_handle,
6015 wmi_buf, len,
6016 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
6017 if (QDF_IS_STATUS_ERROR(ret)) {
6018 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
6019 wmi_buf_free(wmi_buf);
6020 }
6021
6022 return ret;
6023}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05306024
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05306025/**
6026 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
6027 * params from event
6028 * @wmi_handle: wmi handle
6029 * @evt_buf: pointer to event buffer
6030 * @resp: Pointer to hold resp parameters
6031 *
6032 * Return: QDF_STATUS_SUCCESS for success or error code
6033 */
6034static
6035QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
6036 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
6037{
6038 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
6039 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
6040
6041 param_buf = evt_buf;
6042 if (!param_buf) {
6043 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
6044 return QDF_STATUS_E_INVAL;
6045 }
6046
6047 data_event = param_buf->fixed_param;
6048
6049 resp->vdev_id = data_event->vdev_id;
6050 resp->status = data_event->status;
6051
Yeshwanth Sriram Guntukaa79e7f22018-06-22 18:25:45 +05306052 if ((data_event->data_length > param_buf->num_enc80211_frame) ||
6053 (data_event->data_length > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE -
6054 sizeof(*data_event))) {
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05306055 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
6056 data_event->data_length,
6057 param_buf->num_enc80211_frame);
6058 return QDF_STATUS_E_INVAL;
6059 }
6060
6061 resp->data_len = data_event->data_length;
6062
6063 if (resp->data_len)
6064 resp->data = (uint8_t *)param_buf->enc80211_frame;
6065
6066 return QDF_STATUS_SUCCESS;
6067}
6068#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05306069
Govind Singh4eacd2b2016-03-07 14:24:22 +05306070/**
6071 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
6072 * @wmi_handle: wmi handle
6073 * @vdev_id: vdev id
6074 * @p2p_ie: p2p IE
6075 *
Govind Singhe7f2f342016-05-23 12:12:52 +05306076 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306077 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306078static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05306079 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306080{
Govind Singh67922e82016-04-01 16:48:57 +05306081 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306082 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
6083 wmi_buf_t wmi_buf;
6084 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
6085 uint8_t *buf_ptr;
6086
6087 ie_len = (uint32_t) (p2p_ie[1] + 2);
6088
6089 /* More than one P2P IE may be included in a single frame.
6090 If multiple P2P IEs are present, the complete P2P attribute
6091 data consists of the concatenation of the P2P Attribute
6092 fields of the P2P IEs. The P2P Attributes field of each
6093 P2P IE may be any length up to the maximum (251 octets).
6094 In this case host sends one P2P IE to firmware so the length
6095 should not exceed more than 251 bytes
6096 */
6097 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05306098 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05306099 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306100 }
6101
Vivekc5823092018-03-22 23:27:21 +05306102 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05306103
6104 wmi_buf_len =
6105 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
6106 WMI_TLV_HDR_SIZE;
6107
6108 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
6109 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306110 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306111 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306112 }
6113
6114 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6115
6116 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
6117 WMITLV_SET_HDR(&cmd->tlv_header,
6118 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
6119 WMITLV_GET_STRUCT_TLVLEN
6120 (wmi_p2p_go_set_beacon_ie_fixed_param));
6121 cmd->vdev_id = vdev_id;
6122 cmd->ie_buf_len = ie_len;
6123
6124 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
6125 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
6126 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05306127 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306128
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05306129 WMI_LOGD("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306130
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306131 wmi_mtrace(WMI_P2P_GO_SET_BEACON_IE, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306132 ret = wmi_unified_cmd_send(wmi_handle,
6133 wmi_buf, wmi_buf_len,
6134 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05306135 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306136 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306137 wmi_buf_free(wmi_buf);
6138 }
6139
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05306140 WMI_LOGD("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306141 return ret;
6142}
6143
6144/**
6145 * send_set_gateway_params_cmd_tlv() - set gateway parameters
6146 * @wmi_handle: wmi handle
6147 * @req: gateway parameter update request structure
6148 *
6149 * This function reads the incoming @req and fill in the destination
6150 * WMI structure and sends down the gateway configs down to the firmware
6151 *
Govind Singhb53420c2016-03-09 14:32:57 +05306152 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05306153 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306154static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306155 struct gateway_update_req_param *req)
6156{
6157 wmi_roam_subnet_change_config_fixed_param *cmd;
6158 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05306159 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306160 int len = sizeof(*cmd);
6161
6162 buf = wmi_buf_alloc(wmi_handle, len);
6163 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306164 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6165 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306166 }
6167
6168 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
6169 WMITLV_SET_HDR(&cmd->tlv_header,
6170 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
6171 WMITLV_GET_STRUCT_TLVLEN(
6172 wmi_roam_subnet_change_config_fixed_param));
6173
6174 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05306175 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
6176 QDF_IPV4_ADDR_SIZE);
6177 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
6178 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306179 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
6180 &cmd->inet_gw_mac_addr);
6181 cmd->max_retries = req->max_retries;
6182 cmd->timeout = req->timeout;
6183 cmd->num_skip_subnet_change_detection_bssid_list = 0;
6184 cmd->flag = 0;
6185 if (req->ipv4_addr_type)
6186 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
6187
6188 if (req->ipv6_addr_type)
6189 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
6190
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306191 wmi_mtrace(WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306192 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6193 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306194 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306195 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306196 ret);
6197 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306198 }
6199
Govind Singh67922e82016-04-01 16:48:57 +05306200 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306201}
6202
6203/**
6204 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
6205 * @wmi_handle: wmi handle
6206 * @req: rssi monitoring request structure
6207 *
6208 * This function reads the incoming @req and fill in the destination
6209 * WMI structure and send down the rssi monitoring configs down to the firmware
6210 *
6211 * Return: 0 on success; error number otherwise
6212 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306213static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306214 struct rssi_monitor_param *req)
6215{
6216 wmi_rssi_breach_monitor_config_fixed_param *cmd;
6217 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05306218 QDF_STATUS ret;
6219 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306220
6221 buf = wmi_buf_alloc(wmi_handle, len);
6222 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306223 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6224 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306225 }
6226
6227 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
6228 WMITLV_SET_HDR(&cmd->tlv_header,
6229 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
6230 WMITLV_GET_STRUCT_TLVLEN(
6231 wmi_rssi_breach_monitor_config_fixed_param));
6232
6233 cmd->vdev_id = req->session_id;
6234 cmd->request_id = req->request_id;
6235 cmd->lo_rssi_reenable_hysteresis = 0;
6236 cmd->hi_rssi_reenable_histeresis = 0;
6237 cmd->min_report_interval = 0;
6238 cmd->max_num_report = 1;
6239 if (req->control) {
6240 /* enable one threshold for each min/max */
6241 cmd->enabled_bitmap = 0x09;
6242 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
6243 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
6244 } else {
6245 cmd->enabled_bitmap = 0;
6246 cmd->low_rssi_breach_threshold[0] = 0;
6247 cmd->hi_rssi_breach_threshold[0] = 0;
6248 }
6249
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306250 wmi_mtrace(WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306251 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6252 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306253 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306254 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05306255 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306256 }
6257
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07006258 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
6259
Govind Singh67922e82016-04-01 16:48:57 +05306260 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306261}
6262
6263/**
6264 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
6265 * @wmi_handle: wmi handle
6266 * @psetoui: OUI parameters
6267 *
6268 * set scan probe OUI parameters in firmware
6269 *
6270 * Return: CDF status
6271 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306272static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306273 struct scan_mac_oui *psetoui)
6274{
6275 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
6276 wmi_buf_t wmi_buf;
6277 uint32_t len;
6278 uint8_t *buf_ptr;
6279 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306280 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306281
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306282 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
6283 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
6284
Govind Singh4eacd2b2016-03-07 14:24:22 +05306285 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6286 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306287 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6288 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306289 }
6290 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6291 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
6292 WMITLV_SET_HDR(&cmd->tlv_header,
6293 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
6294 WMITLV_GET_STRUCT_TLVLEN
6295 (wmi_scan_prob_req_oui_cmd_fixed_param));
6296
6297 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05306298 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05306299 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
6300 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05306301 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306302 cmd->prob_req_oui);
6303
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05306304 cmd->vdev_id = psetoui->vdev_id;
6305 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
6306 if (psetoui->enb_probe_req_sno_randomization)
6307 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
6308
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306309 if (ie_whitelist->white_list) {
6310 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
6311 &cmd->num_vendor_oui,
6312 ie_whitelist);
6313 cmd->flags |=
6314 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
6315 }
6316
6317 buf_ptr += sizeof(*cmd);
6318 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6319 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
6320 buf_ptr += WMI_TLV_HDR_SIZE;
6321
6322 if (cmd->num_vendor_oui != 0) {
6323 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
6324 ie_whitelist->voui);
6325 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
6326 }
6327
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306328 wmi_mtrace(WMI_SCAN_PROB_REQ_OUI_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306329 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6330 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306331 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306332 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306333 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306334 }
Govind Singhb53420c2016-03-09 14:32:57 +05306335 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306336}
6337
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306338#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306339/**
6340 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6341 * @wmi_handle: wmi handle
6342 * @roam_req: Roam scan offload params
6343 * @buf_ptr: command buffer to send
6344 * @fils_tlv_len: fils tlv length
6345 *
6346 * Return: Updated buffer pointer
6347 */
6348static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6349 struct roam_offload_scan_params *roam_req,
6350 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6351{
6352 wmi_roam_fils_offload_tlv_param *fils_tlv;
6353 wmi_erp_info *erp_info;
6354 struct roam_fils_params *roam_fils_params;
6355
6356 if (!roam_req->add_fils_tlv)
6357 return buf_ptr;
6358
6359 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6360 sizeof(*fils_tlv));
6361 buf_ptr += WMI_TLV_HDR_SIZE;
6362
6363 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6364 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6365 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6366 WMITLV_GET_STRUCT_TLVLEN
6367 (wmi_roam_fils_offload_tlv_param));
6368
6369 roam_fils_params = &roam_req->roam_fils_params;
6370 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6371
6372 erp_info->username_length = roam_fils_params->username_length;
6373 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6374 erp_info->username_length);
6375
6376 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6377
6378 erp_info->rRk_length = roam_fils_params->rrk_length;
6379 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6380 erp_info->rRk_length);
6381
6382 erp_info->rIk_length = roam_fils_params->rik_length;
6383 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6384 erp_info->rIk_length);
6385
6386 erp_info->realm_len = roam_fils_params->realm_len;
6387 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6388 erp_info->realm_len);
6389
6390 buf_ptr += sizeof(*fils_tlv);
6391 return buf_ptr;
6392}
6393#else
6394static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6395 struct roam_offload_scan_params *roam_req,
6396 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6397{
6398 return buf_ptr;
6399}
6400#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306401/**
6402 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6403 * @wmi_handle: wmi handle
6404 * @scan_cmd_fp: start scan command ptr
6405 * @roam_req: roam request param
6406 *
6407 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6408 * of WMI_ROAM_SCAN_MODE.
6409 *
6410 * Return: QDF status
6411 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306412static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306413 wmi_start_scan_cmd_fixed_param *
6414 scan_cmd_fp,
6415 struct roam_offload_scan_params *roam_req)
6416{
6417 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306418 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306419 int len;
6420 uint8_t *buf_ptr;
6421 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306422
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306423#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6424 int auth_mode = roam_req->auth_mode;
6425 wmi_roam_offload_tlv_param *roam_offload_params;
6426 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6427 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6428 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306429 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306430 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306431#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6432 /* Need to create a buf with roam_scan command at
6433 * front and piggyback with scan command */
6434 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6435#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6436 (2 * WMI_TLV_HDR_SIZE) +
6437#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6438 sizeof(wmi_start_scan_cmd_fixed_param);
6439#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006440 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306441 if (roam_req->is_roam_req_valid &&
6442 roam_req->roam_offload_enabled) {
6443 len += sizeof(wmi_roam_offload_tlv_param);
6444 len += WMI_TLV_HDR_SIZE;
6445 if ((auth_mode != WMI_AUTH_NONE) &&
6446 ((auth_mode != WMI_AUTH_OPEN) ||
6447 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306448 roam_req->mdid.mdie_present &&
6449 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306450 roam_req->is_ese_assoc)) {
6451 len += WMI_TLV_HDR_SIZE;
6452 if (roam_req->is_ese_assoc)
6453 len +=
6454 sizeof(wmi_roam_ese_offload_tlv_param);
6455 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6456 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6457 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306458 roam_req->mdid.mdie_present &&
6459 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306460 len +=
6461 sizeof(wmi_roam_11r_offload_tlv_param);
6462 else
6463 len +=
6464 sizeof(wmi_roam_11i_offload_tlv_param);
6465 } else {
6466 len += WMI_TLV_HDR_SIZE;
6467 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306468
6469 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6470 + roundup(roam_req->assoc_ie_length,
6471 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306472
6473 if (roam_req->add_fils_tlv) {
6474 fils_tlv_len = sizeof(
6475 wmi_roam_fils_offload_tlv_param);
6476 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6477 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306478 } else {
6479 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306480 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306481 __func__, roam_req->roam_offload_enabled);
6482 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306483 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306484 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306485 }
6486 if (roam_req->is_roam_req_valid &&
6487 roam_req->roam_offload_enabled) {
6488 roam_req->mode = roam_req->mode |
6489 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6490 }
6491#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6492
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306493 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6494 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6495 len = sizeof(wmi_roam_scan_mode_fixed_param);
6496
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306497 buf = wmi_buf_alloc(wmi_handle, len);
6498 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306499 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306500 return QDF_STATUS_E_NOMEM;
6501 }
6502
6503 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6504 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6505 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6506 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6507 WMITLV_GET_STRUCT_TLVLEN
6508 (wmi_roam_scan_mode_fixed_param));
6509
Abhinav Kumar334355f2018-04-06 17:18:52 +05306510 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6511 roam_req->roam_trigger_reason_bitmask;
6512 roam_scan_mode_fp->min_delay_btw_scans =
6513 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306514 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6515 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306516 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6517 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6518 roam_scan_mode_fp->flags |=
6519 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306520 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306521 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306522
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306523 /* Fill in scan parameters suitable for roaming scan */
6524 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306525
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306526 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6527 sizeof(wmi_start_scan_cmd_fixed_param));
6528 /* Ensure there is no additional IEs */
6529 scan_cmd_fp->ie_len = 0;
6530 WMITLV_SET_HDR(buf_ptr,
6531 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6532 WMITLV_GET_STRUCT_TLVLEN
6533 (wmi_start_scan_cmd_fixed_param));
6534#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6535 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6536 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6537 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6538 sizeof(wmi_roam_offload_tlv_param));
6539 buf_ptr += WMI_TLV_HDR_SIZE;
6540 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6541 WMITLV_SET_HDR(buf_ptr,
6542 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6543 WMITLV_GET_STRUCT_TLVLEN
6544 (wmi_roam_offload_tlv_param));
6545 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6546 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6547 roam_offload_params->select_5g_margin =
6548 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306549 roam_offload_params->handoff_delay_for_rx =
6550 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306551 roam_offload_params->reassoc_failure_timeout =
6552 roam_req->reassoc_failure_timeout;
6553
6554 /* Fill the capabilities */
6555 roam_offload_params->capability =
6556 roam_req->roam_offload_params.capability;
6557 roam_offload_params->ht_caps_info =
6558 roam_req->roam_offload_params.ht_caps_info;
6559 roam_offload_params->ampdu_param =
6560 roam_req->roam_offload_params.ampdu_param;
6561 roam_offload_params->ht_ext_cap =
6562 roam_req->roam_offload_params.ht_ext_cap;
6563 roam_offload_params->ht_txbf =
6564 roam_req->roam_offload_params.ht_txbf;
6565 roam_offload_params->asel_cap =
6566 roam_req->roam_offload_params.asel_cap;
6567 roam_offload_params->qos_caps =
6568 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006569 roam_offload_params->qos_enabled =
6570 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306571 roam_offload_params->wmm_caps =
6572 roam_req->roam_offload_params.wmm_caps;
6573 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6574 (uint8_t *)roam_req->roam_offload_params.mcsset,
6575 ROAM_OFFLOAD_NUM_MCS_SET);
6576
6577 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6578 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6579 * they are filled in the same order.Depending on the
6580 * authentication type, the other mode TLV's are nullified
6581 * and only headers are filled.*/
6582 if ((auth_mode != WMI_AUTH_NONE) &&
6583 ((auth_mode != WMI_AUTH_OPEN) ||
6584 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306585 && roam_req->mdid.mdie_present &&
6586 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306587 roam_req->is_ese_assoc)) {
6588 if (roam_req->is_ese_assoc) {
6589 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6590 WMITLV_GET_STRUCT_TLVLEN(0));
6591 buf_ptr += WMI_TLV_HDR_SIZE;
6592 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6593 WMITLV_GET_STRUCT_TLVLEN(0));
6594 buf_ptr += WMI_TLV_HDR_SIZE;
6595 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6596 sizeof(wmi_roam_ese_offload_tlv_param));
6597 buf_ptr += WMI_TLV_HDR_SIZE;
6598 roam_offload_ese =
6599 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6600 qdf_mem_copy(roam_offload_ese->krk,
6601 roam_req->krk,
6602 sizeof(roam_req->krk));
6603 qdf_mem_copy(roam_offload_ese->btk,
6604 roam_req->btk,
6605 sizeof(roam_req->btk));
6606 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6607 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6608 WMITLV_GET_STRUCT_TLVLEN
6609 (wmi_roam_ese_offload_tlv_param));
6610 buf_ptr +=
6611 sizeof(wmi_roam_ese_offload_tlv_param);
6612 } else if (auth_mode == WMI_AUTH_FT_RSNA
6613 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6614 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306615 && roam_req->mdid.mdie_present &&
6616 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306617 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6618 0);
6619 buf_ptr += WMI_TLV_HDR_SIZE;
6620 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6621 sizeof(wmi_roam_11r_offload_tlv_param));
6622 buf_ptr += WMI_TLV_HDR_SIZE;
6623 roam_offload_11r =
6624 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6625 roam_offload_11r->r0kh_id_len =
6626 roam_req->rokh_id_length;
6627 qdf_mem_copy(roam_offload_11r->r0kh_id,
6628 roam_req->rokh_id,
6629 roam_offload_11r->r0kh_id_len);
6630 qdf_mem_copy(roam_offload_11r->psk_msk,
6631 roam_req->psk_pmk,
6632 sizeof(roam_req->psk_pmk));
6633 roam_offload_11r->psk_msk_len =
6634 roam_req->pmk_len;
6635 roam_offload_11r->mdie_present =
6636 roam_req->mdid.mdie_present;
6637 roam_offload_11r->mdid =
6638 roam_req->mdid.mobility_domain;
6639 if (auth_mode == WMI_AUTH_OPEN) {
6640 /* If FT-Open ensure pmk length
6641 and r0khid len are zero */
6642 roam_offload_11r->r0kh_id_len = 0;
6643 roam_offload_11r->psk_msk_len = 0;
6644 }
6645 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6646 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6647 WMITLV_GET_STRUCT_TLVLEN
6648 (wmi_roam_11r_offload_tlv_param));
6649 buf_ptr +=
6650 sizeof(wmi_roam_11r_offload_tlv_param);
6651 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6652 WMITLV_GET_STRUCT_TLVLEN(0));
6653 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006654 WMI_LOGD("psk_msk_len = %d",
6655 roam_offload_11r->psk_msk_len);
6656 if (roam_offload_11r->psk_msk_len)
6657 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6658 QDF_TRACE_LEVEL_DEBUG,
6659 roam_offload_11r->psk_msk,
6660 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306661 } else {
6662 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6663 sizeof(wmi_roam_11i_offload_tlv_param));
6664 buf_ptr += WMI_TLV_HDR_SIZE;
6665 roam_offload_11i =
6666 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006667
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006668 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006669 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306670 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6671 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006672 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306673 } else {
6674 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6675 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006676 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006677 }
6678 if (roam_req->roam_key_mgmt_offload_enabled &&
6679 roam_req->fw_pmksa_cache) {
6680 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6681 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006682 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006683 } else {
6684 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6685 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006686 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306687 }
6688
6689 qdf_mem_copy(roam_offload_11i->pmk,
6690 roam_req->psk_pmk,
6691 sizeof(roam_req->psk_pmk));
6692 roam_offload_11i->pmk_len = roam_req->pmk_len;
6693 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6694 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6695 WMITLV_GET_STRUCT_TLVLEN
6696 (wmi_roam_11i_offload_tlv_param));
6697 buf_ptr +=
6698 sizeof(wmi_roam_11i_offload_tlv_param);
6699 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6700 0);
6701 buf_ptr += WMI_TLV_HDR_SIZE;
6702 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6703 0);
6704 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006705 WMI_LOGD("pmk_len = %d",
6706 roam_offload_11i->pmk_len);
6707 if (roam_offload_11i->pmk_len)
6708 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6709 QDF_TRACE_LEVEL_DEBUG,
6710 roam_offload_11i->pmk,
6711 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306712 }
6713 } else {
6714 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6715 WMITLV_GET_STRUCT_TLVLEN(0));
6716 buf_ptr += WMI_TLV_HDR_SIZE;
6717 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6718 WMITLV_GET_STRUCT_TLVLEN(0));
6719 buf_ptr += WMI_TLV_HDR_SIZE;
6720 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6721 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306722 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306723 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306724
6725 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6726 sizeof(*assoc_ies));
6727 buf_ptr += WMI_TLV_HDR_SIZE;
6728
6729 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6730 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6731 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6732 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6733 assoc_ies->buf_len = roam_req->assoc_ie_length;
6734
6735 buf_ptr += sizeof(*assoc_ies);
6736
6737 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6738 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6739 buf_ptr += WMI_TLV_HDR_SIZE;
6740
6741 if (assoc_ies->buf_len != 0) {
6742 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6743 assoc_ies->buf_len);
6744 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306745 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6746 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6747 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306748 } else {
6749 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6750 WMITLV_GET_STRUCT_TLVLEN(0));
6751 buf_ptr += WMI_TLV_HDR_SIZE;
6752 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6753 WMITLV_GET_STRUCT_TLVLEN(0));
6754 buf_ptr += WMI_TLV_HDR_SIZE;
6755 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6756 WMITLV_GET_STRUCT_TLVLEN(0));
6757 buf_ptr += WMI_TLV_HDR_SIZE;
6758 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6759 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306760 buf_ptr += WMI_TLV_HDR_SIZE;
6761 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6762 WMITLV_GET_STRUCT_TLVLEN(0));
6763 buf_ptr += WMI_TLV_HDR_SIZE;
6764 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6765 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306766 }
6767#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306768
6769send_roam_scan_mode_cmd:
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306770 wmi_mtrace(WMI_ROAM_SCAN_MODE, NO_SESSION, 0);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306771 status = wmi_unified_cmd_send(wmi_handle, buf,
6772 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306773 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306774 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306775 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6776 status);
6777 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306778 }
6779
Govind Singh67922e82016-04-01 16:48:57 +05306780 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306781}
6782
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006783static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6784 struct wmi_mawc_roam_params *params)
6785{
6786 wmi_buf_t buf = NULL;
6787 QDF_STATUS status;
6788 int len;
6789 uint8_t *buf_ptr;
6790 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6791
6792 len = sizeof(*wmi_roam_mawc_params);
6793 buf = wmi_buf_alloc(wmi_handle, len);
6794 if (!buf) {
6795 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6796 return QDF_STATUS_E_NOMEM;
6797 }
6798
6799 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6800 wmi_roam_mawc_params =
6801 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6802 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6803 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6804 WMITLV_GET_STRUCT_TLVLEN
6805 (wmi_roam_configure_mawc_cmd_fixed_param));
6806 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6807 if (params->enable)
6808 wmi_roam_mawc_params->enable = 1;
6809 else
6810 wmi_roam_mawc_params->enable = 0;
6811 wmi_roam_mawc_params->traffic_load_threshold =
6812 params->traffic_load_threshold;
6813 wmi_roam_mawc_params->best_ap_rssi_threshold =
6814 params->best_ap_rssi_threshold;
6815 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6816 params->rssi_stationary_high_adjust;
6817 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6818 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006819 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6820 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6821 wmi_roam_mawc_params->traffic_load_threshold,
6822 wmi_roam_mawc_params->best_ap_rssi_threshold,
6823 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6824 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006825
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306826 wmi_mtrace(WMI_ROAM_CONFIGURE_MAWC_CMDID, NO_SESSION, 0);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006827 status = wmi_unified_cmd_send(wmi_handle, buf,
6828 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6829 if (QDF_IS_STATUS_ERROR(status)) {
6830 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6831 status);
6832 wmi_buf_free(buf);
6833 return status;
6834 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006835
6836 return QDF_STATUS_SUCCESS;
6837}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306838
6839/**
6840 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6841 * rssi threashold
6842 * @wmi_handle: wmi handle
6843 * @roam_req: Roaming request buffer
6844 *
6845 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6846 *
6847 * Return: QDF status
6848 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306849static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306850 struct roam_offload_scan_rssi_params *roam_req)
6851{
6852 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306853 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306854 int len;
6855 uint8_t *buf_ptr;
6856 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6857 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6858 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306859 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006860 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306861
6862 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6863 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6864 len += sizeof(wmi_roam_scan_extended_threshold_param);
6865 len += WMI_TLV_HDR_SIZE;
6866 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306867 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6868 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006869 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6870 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306871 buf = wmi_buf_alloc(wmi_handle, len);
6872 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306873 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306874 return QDF_STATUS_E_NOMEM;
6875 }
6876
6877 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6878 rssi_threshold_fp =
6879 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6880 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6881 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6882 WMITLV_GET_STRUCT_TLVLEN
6883 (wmi_roam_scan_rssi_threshold_fixed_param));
6884 /* fill in threshold values */
6885 rssi_threshold_fp->vdev_id = roam_req->session_id;
6886 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6887 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6888 rssi_threshold_fp->hirssi_scan_max_count =
6889 roam_req->hi_rssi_scan_max_count;
6890 rssi_threshold_fp->hirssi_scan_delta =
6891 roam_req->hi_rssi_scan_rssi_delta;
6892 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006893 rssi_threshold_fp->rssi_thresh_offset_5g =
6894 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306895
6896 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6897 WMITLV_SET_HDR(buf_ptr,
6898 WMITLV_TAG_ARRAY_STRUC,
6899 sizeof(wmi_roam_scan_extended_threshold_param));
6900 buf_ptr += WMI_TLV_HDR_SIZE;
6901 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6902
6903 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6904 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6905 ext_thresholds->boost_threshold_5g =
6906 roam_req->boost_threshold_5g;
6907
6908 ext_thresholds->boost_algorithm_5g =
6909 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6910 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6911 ext_thresholds->penalty_algorithm_5g =
6912 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6913 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6914 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6915 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6916 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6917
6918 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6919 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6920 WMITLV_GET_STRUCT_TLVLEN
6921 (wmi_roam_scan_extended_threshold_param));
6922 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6923 WMITLV_SET_HDR(buf_ptr,
6924 WMITLV_TAG_ARRAY_STRUC,
6925 sizeof(wmi_roam_earlystop_rssi_thres_param));
6926 buf_ptr += WMI_TLV_HDR_SIZE;
6927 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6928 early_stop_thresholds->roam_earlystop_thres_min =
6929 roam_req->roam_earlystop_thres_min;
6930 early_stop_thresholds->roam_earlystop_thres_max =
6931 roam_req->roam_earlystop_thres_max;
6932 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6933 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6934 WMITLV_GET_STRUCT_TLVLEN
6935 (wmi_roam_earlystop_rssi_thres_param));
6936
Gupta, Kapil7e652922016-04-12 15:02:00 +05306937 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6938 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6939 sizeof(wmi_roam_dense_thres_param));
6940 buf_ptr += WMI_TLV_HDR_SIZE;
6941 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6942 dense_thresholds->roam_dense_rssi_thres_offset =
6943 roam_req->dense_rssi_thresh_offset;
6944 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6945 dense_thresholds->roam_dense_traffic_thres =
6946 roam_req->traffic_threshold;
6947 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6948 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6949 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6950 WMITLV_GET_STRUCT_TLVLEN
6951 (wmi_roam_dense_thres_param));
6952
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006953 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6954 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6955 sizeof(wmi_roam_bg_scan_roaming_param));
6956 buf_ptr += WMI_TLV_HDR_SIZE;
6957 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6958 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6959 roam_req->bg_scan_bad_rssi_thresh;
6960 bg_scan_params->roam_bg_scan_client_bitmap =
6961 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306962 bg_scan_params->bad_rssi_thresh_offset_2g =
6963 roam_req->roam_bad_rssi_thresh_offset_2g;
6964 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006965 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6966 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6967 WMITLV_GET_STRUCT_TLVLEN
6968 (wmi_roam_bg_scan_roaming_param));
6969
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306970 wmi_mtrace(WMI_ROAM_SCAN_RSSI_THRESHOLD, NO_SESSION, 0);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306971 status = wmi_unified_cmd_send(wmi_handle, buf,
6972 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306973 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306974 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306975 status);
6976 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306977 }
6978
Govind Singh67922e82016-04-01 16:48:57 +05306979 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306980}
6981
6982/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306983 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6984 * configuration params
6985 * @wma_handle: wma handler
6986 * @dwelltime_params: pointer to dwelltime_params
6987 *
6988 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6989 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006990static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306991QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6992 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6993{
6994 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6995 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6996 wmi_buf_t buf;
6997 uint8_t *buf_ptr;
6998 int32_t err;
6999 int len;
7000
7001 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
7002 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
7003 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
7004 buf = wmi_buf_alloc(wmi_handle, len);
7005 if (!buf) {
7006 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
7007 __func__);
7008 return QDF_STATUS_E_NOMEM;
7009 }
7010 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7011 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
7012 WMITLV_SET_HDR(&dwell_param->tlv_header,
7013 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
7014 WMITLV_GET_STRUCT_TLVLEN
7015 (wmi_scan_adaptive_dwell_config_fixed_param));
7016
7017 dwell_param->enable = dwelltime_params->is_enabled;
7018 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
7019 WMITLV_SET_HDR(buf_ptr,
7020 WMITLV_TAG_ARRAY_STRUC,
7021 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
7022 buf_ptr += WMI_TLV_HDR_SIZE;
7023
7024 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
7025 WMITLV_SET_HDR(&cmd->tlv_header,
7026 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
7027 WMITLV_GET_STRUCT_TLVLEN(
7028 wmi_scan_adaptive_dwell_parameters_tlv));
7029
7030 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
7031 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
7032 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
7033 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307034 wmi_mtrace(WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID, NO_SESSION, 0);
Gupta, Kapil2e685982016-04-25 19:14:19 +05307035 err = wmi_unified_cmd_send(wmi_handle, buf,
7036 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
7037 if (err) {
7038 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
7039 wmi_buf_free(buf);
7040 return QDF_STATUS_E_FAILURE;
7041 }
7042
7043 return QDF_STATUS_SUCCESS;
7044}
7045
Nitesh Shah52323d02017-05-22 15:49:00 +05307046/**
7047 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
7048 * configuration params
7049 * @wmi_handle: wmi handler
7050 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
7051 *
7052 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
7053 */
7054static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
7055 struct wmi_dbs_scan_sel_params *dbs_scan_params)
7056{
7057 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
7058 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
7059 wmi_buf_t buf;
7060 uint8_t *buf_ptr;
7061 QDF_STATUS err;
7062 uint32_t i;
7063 int len;
7064
7065 len = sizeof(*dbs_scan_param);
7066 len += WMI_TLV_HDR_SIZE;
7067 len += dbs_scan_params->num_clients * sizeof(*cmd);
7068
7069 buf = wmi_buf_alloc(wmi_handle, len);
7070 if (!buf) {
7071 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
7072 return QDF_STATUS_E_NOMEM;
7073 }
7074
7075 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7076 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
7077 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
7078 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
7079 WMITLV_GET_STRUCT_TLVLEN
7080 (wmi_scan_dbs_duty_cycle_fixed_param));
7081
7082 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
7083 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
7084 buf_ptr += sizeof(*dbs_scan_param);
7085 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7086 (sizeof(*cmd) * dbs_scan_params->num_clients));
7087 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
7088
7089 for (i = 0; i < dbs_scan_params->num_clients; i++) {
7090 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
7091 WMITLV_SET_HDR(&cmd->tlv_header,
7092 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
7093 WMITLV_GET_STRUCT_TLVLEN(
7094 wmi_scan_dbs_duty_cycle_tlv_param));
7095 cmd->module_id = dbs_scan_params->module_id[i];
7096 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
7097 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
7098 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
7099 }
7100
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307101 wmi_mtrace(WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID, NO_SESSION, 0);
Nitesh Shah52323d02017-05-22 15:49:00 +05307102 err = wmi_unified_cmd_send(wmi_handle, buf,
7103 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
7104 if (QDF_IS_STATUS_ERROR(err)) {
7105 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
7106 wmi_buf_free(buf);
7107 return QDF_STATUS_E_FAILURE;
7108 }
7109
7110 return QDF_STATUS_SUCCESS;
7111}
Gupta, Kapil2e685982016-04-25 19:14:19 +05307112
7113/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307114 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
7115 * @wmi_handle: wmi handle
7116 * @roam_req: Request which contains the filters
7117 *
7118 * There are filters such as whitelist, blacklist and preferred
7119 * list that need to be applied to the scan results to form the
7120 * probable candidates for roaming.
7121 *
Jeff Johnsonda263992018-05-12 14:22:00 -07007122 * Return: Return success upon successfully passing the
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307123 * parameters to the firmware, otherwise failure.
7124 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307125static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307126 struct roam_scan_filter_params *roam_req)
7127{
7128 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05307129 QDF_STATUS status;
7130 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307131 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307132 uint8_t *buf_ptr;
7133 wmi_roam_filter_fixed_param *roam_filter;
7134 uint8_t *bssid_src_ptr = NULL;
7135 wmi_mac_addr *bssid_dst_ptr = NULL;
7136 wmi_ssid *ssid_ptr = NULL;
7137 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307138 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307139 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307140
7141 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05307142
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307143 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05307144 if (roam_req->num_bssid_black_list)
7145 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
7146 len += WMI_TLV_HDR_SIZE;
7147 if (roam_req->num_ssid_white_list)
7148 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
7149 len += 2 * WMI_TLV_HDR_SIZE;
7150 if (roam_req->num_bssid_preferred_list) {
7151 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05307152 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05307153 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307154 len += WMI_TLV_HDR_SIZE;
7155 if (roam_req->lca_disallow_config_present) {
7156 len += sizeof(*blist_param);
7157 blist_len = sizeof(*blist_param);
7158 }
7159
7160 len += WMI_TLV_HDR_SIZE;
7161 if (roam_req->num_rssi_rejection_ap)
7162 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307163
7164 buf = wmi_buf_alloc(wmi_handle, len);
7165 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307166 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307167 return QDF_STATUS_E_NOMEM;
7168 }
7169
7170 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
7171 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
7172 WMITLV_SET_HDR(&roam_filter->tlv_header,
7173 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
7174 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
7175 /* fill in fixed values */
7176 roam_filter->vdev_id = roam_req->session_id;
7177 roam_filter->flags = 0;
7178 roam_filter->op_bitmap = roam_req->op_bitmap;
7179 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
7180 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
7181 roam_filter->num_bssid_preferred_list =
7182 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307183 roam_filter->num_rssi_rejection_ap =
7184 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307185 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
7186
7187 WMITLV_SET_HDR((buf_ptr),
7188 WMITLV_TAG_ARRAY_FIXED_STRUC,
7189 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
7190 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
7191 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7192 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
7193 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
7194 bssid_src_ptr += ATH_MAC_LEN;
7195 bssid_dst_ptr++;
7196 }
7197 buf_ptr += WMI_TLV_HDR_SIZE +
7198 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
7199 WMITLV_SET_HDR((buf_ptr),
7200 WMITLV_TAG_ARRAY_FIXED_STRUC,
7201 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
7202 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
7203 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
7204 qdf_mem_copy(&ssid_ptr->ssid,
7205 &roam_req->ssid_allowed_list[i].mac_ssid,
7206 roam_req->ssid_allowed_list[i].length);
7207 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
7208 ssid_ptr++;
7209 }
7210 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
7211 sizeof(wmi_ssid));
7212 WMITLV_SET_HDR((buf_ptr),
7213 WMITLV_TAG_ARRAY_FIXED_STRUC,
7214 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
7215 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
7216 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
7217 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7218 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
7219 (wmi_mac_addr *)bssid_dst_ptr);
7220 bssid_src_ptr += ATH_MAC_LEN;
7221 bssid_dst_ptr++;
7222 }
7223 buf_ptr += WMI_TLV_HDR_SIZE +
7224 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
7225 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7226 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
7227 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
7228 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
7229 *bssid_preferred_factor_ptr =
7230 roam_req->bssid_favored_factor[i];
7231 bssid_preferred_factor_ptr++;
7232 }
7233 buf_ptr += WMI_TLV_HDR_SIZE +
7234 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
7235
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307236 WMITLV_SET_HDR(buf_ptr,
7237 WMITLV_TAG_ARRAY_STRUC, blist_len);
7238 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307239 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307240 blist_param =
7241 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
7242 WMITLV_SET_HDR(&blist_param->tlv_header,
7243 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
7244 WMITLV_GET_STRUCT_TLVLEN(
7245 wmi_roam_lca_disallow_config_tlv_param));
7246
7247 blist_param->disallow_duration = roam_req->disallow_duration;
7248 blist_param->rssi_channel_penalization =
7249 roam_req->rssi_channel_penalization;
7250 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05307251 blist_param->disallow_lca_enable_source_bitmap =
7252 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
7253 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307254 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
7255 }
7256
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307257 WMITLV_SET_HDR(buf_ptr,
7258 WMITLV_TAG_ARRAY_STRUC,
7259 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
7260 buf_ptr += WMI_TLV_HDR_SIZE;
7261 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
7262 rssi_rej =
7263 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7264 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7265 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7266 WMITLV_GET_STRUCT_TLVLEN(
7267 wmi_roam_rssi_rejection_oce_config_param));
7268 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7269 roam_req->rssi_rejection_ap[i].bssid.bytes,
7270 &rssi_rej->bssid);
7271 rssi_rej->remaining_disallow_duration =
7272 roam_req->rssi_rejection_ap[i].remaining_duration;
7273 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05307274 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307275 buf_ptr +=
7276 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7277 }
7278
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307279 wmi_mtrace(WMI_ROAM_FILTER_CMDID, NO_SESSION, 0);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307280 status = wmi_unified_cmd_send(wmi_handle, buf,
7281 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307282 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307283 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307284 status);
7285 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307286 }
Govind Singh67922e82016-04-01 16:48:57 +05307287
7288 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307289}
7290
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307291#if defined(WLAN_FEATURE_FILS_SK)
7292static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7293 struct hlp_params *params)
7294{
7295 uint32_t len;
7296 uint8_t *buf_ptr;
7297 wmi_buf_t buf = NULL;
7298 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7299
7300 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7301 len += WMI_TLV_HDR_SIZE;
7302 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7303
7304 buf = wmi_buf_alloc(wmi_handle, len);
7305 if (!buf) {
7306 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7307 return QDF_STATUS_E_NOMEM;
7308 }
7309
7310 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7311 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7312 WMITLV_SET_HDR(&hlp_params->tlv_header,
7313 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7314 WMITLV_GET_STRUCT_TLVLEN(
7315 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7316
7317 hlp_params->vdev_id = params->vdev_id;
7318 hlp_params->size = params->hlp_ie_len;
7319 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7320
7321 buf_ptr += sizeof(*hlp_params);
7322
7323 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7324 round_up(params->hlp_ie_len,
7325 sizeof(uint32_t)));
7326 buf_ptr += WMI_TLV_HDR_SIZE;
7327 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7328
7329 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7330 hlp_params->vdev_id, hlp_params->size);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307331 wmi_mtrace(WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID, NO_SESSION, 0);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307332 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7333 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7334 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7335 wmi_buf_free(buf);
7336 return QDF_STATUS_E_FAILURE;
7337 }
7338
7339 return QDF_STATUS_SUCCESS;
7340}
7341#endif
7342
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307343#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307344/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7345 * @wmi_handle: wmi handle
7346 * @ipa_offload: ipa offload control parameter
7347 *
7348 * Returns: 0 on success, error number otherwise
7349 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307350static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307351 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307352{
7353 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7354 wmi_buf_t wmi_buf;
7355 uint32_t len;
7356 u_int8_t *buf_ptr;
7357
7358 len = sizeof(*cmd);
7359 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7360 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307361 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7362 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307363 }
7364
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007365 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307366 ipa_offload->offload_type, ipa_offload->enable);
7367
7368 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7369
7370 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7371 WMITLV_SET_HDR(&cmd->tlv_header,
7372 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7373 WMITLV_GET_STRUCT_TLVLEN(
7374 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7375
7376 cmd->offload_type = ipa_offload->offload_type;
7377 cmd->vdev_id = ipa_offload->vdev_id;
7378 cmd->enable = ipa_offload->enable;
7379
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307380 wmi_mtrace(WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307381 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7382 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307383 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307384 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307385 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307386 }
7387
Govind Singhb53420c2016-03-09 14:32:57 +05307388 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307389}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307390#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307391
7392/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307393 * send_plm_stop_cmd_tlv() - plm stop request
7394 * @wmi_handle: wmi handle
7395 * @plm: plm request parameters
7396 *
7397 * This function request FW to stop PLM.
7398 *
7399 * Return: CDF status
7400 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307401static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307402 const struct plm_req_params *plm)
7403{
7404 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7405 int32_t len;
7406 wmi_buf_t buf;
7407 uint8_t *buf_ptr;
7408 int ret;
7409
7410 len = sizeof(*cmd);
7411 buf = wmi_buf_alloc(wmi_handle, len);
7412 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307413 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7414 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307415 }
7416
7417 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7418
7419 buf_ptr = (uint8_t *) cmd;
7420
7421 WMITLV_SET_HDR(&cmd->tlv_header,
7422 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7423 WMITLV_GET_STRUCT_TLVLEN
7424 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7425
7426 cmd->vdev_id = plm->session_id;
7427
7428 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307429 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307430
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307431 wmi_mtrace(WMI_VDEV_PLMREQ_STOP_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307432 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7433 WMI_VDEV_PLMREQ_STOP_CMDID);
7434 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307435 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307436 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307437 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307438 }
7439
Govind Singhb53420c2016-03-09 14:32:57 +05307440 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307441}
7442
7443/**
7444 * send_plm_start_cmd_tlv() - plm start request
7445 * @wmi_handle: wmi handle
7446 * @plm: plm request parameters
7447 *
7448 * This function request FW to start PLM.
7449 *
7450 * Return: CDF status
7451 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307452static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307453 const struct plm_req_params *plm,
7454 uint32_t *gchannel_list)
7455{
7456 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7457 uint32_t *channel_list;
7458 int32_t len;
7459 wmi_buf_t buf;
7460 uint8_t *buf_ptr;
7461 uint8_t count;
7462 int ret;
7463
7464 /* TLV place holder for channel_list */
7465 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7466 len += sizeof(uint32_t) * plm->plm_num_ch;
7467
7468 buf = wmi_buf_alloc(wmi_handle, len);
7469 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307470 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7471 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307472 }
7473 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7474
7475 buf_ptr = (uint8_t *) cmd;
7476
7477 WMITLV_SET_HDR(&cmd->tlv_header,
7478 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7479 WMITLV_GET_STRUCT_TLVLEN
7480 (wmi_vdev_plmreq_start_cmd_fixed_param));
7481
7482 cmd->vdev_id = plm->session_id;
7483
7484 cmd->meas_token = plm->meas_token;
7485 cmd->dialog_token = plm->diag_token;
7486 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307487 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307488 cmd->off_duration = plm->meas_duration;
7489 cmd->burst_cycle = plm->burst_len;
7490 cmd->tx_power = plm->desired_tx_pwr;
7491 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7492 cmd->num_chans = plm->plm_num_ch;
7493
7494 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7495
Govind Singhb53420c2016-03-09 14:32:57 +05307496 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7497 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7498 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7499 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7500 WMI_LOGD("off_duration: %d", cmd->off_duration);
7501 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7502 WMI_LOGD("tx_power: %d", cmd->tx_power);
7503 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307504
7505 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7506 (cmd->num_chans * sizeof(uint32_t)));
7507
7508 buf_ptr += WMI_TLV_HDR_SIZE;
7509 if (cmd->num_chans) {
7510 channel_list = (uint32_t *) buf_ptr;
7511 for (count = 0; count < cmd->num_chans; count++) {
7512 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307513 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307514 channel_list[count] =
7515 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307516 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307517 }
7518 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7519 }
7520
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307521 wmi_mtrace(WMI_VDEV_PLMREQ_START_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307522 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7523 WMI_VDEV_PLMREQ_START_CMDID);
7524 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307525 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307526 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307527 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307528 }
7529
Govind Singhb53420c2016-03-09 14:32:57 +05307530 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307531}
7532
7533/**
7534 * send_pno_stop_cmd_tlv() - PNO stop request
7535 * @wmi_handle: wmi handle
7536 * @vdev_id: vdev id
7537 *
7538 * This function request FW to stop ongoing PNO operation.
7539 *
7540 * Return: CDF status
7541 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307542static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307543{
7544 wmi_nlo_config_cmd_fixed_param *cmd;
7545 int32_t len = sizeof(*cmd);
7546 wmi_buf_t buf;
7547 uint8_t *buf_ptr;
7548 int ret;
7549
7550 /*
7551 * TLV place holder for array of structures nlo_configured_parameters
7552 * TLV place holder for array of uint32_t channel_list
7553 * TLV place holder for chnl prediction cfg
7554 */
7555 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7556 buf = wmi_buf_alloc(wmi_handle, len);
7557 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307558 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7559 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307560 }
7561
7562 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7563 buf_ptr = (uint8_t *) cmd;
7564
7565 WMITLV_SET_HDR(&cmd->tlv_header,
7566 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7567 WMITLV_GET_STRUCT_TLVLEN
7568 (wmi_nlo_config_cmd_fixed_param));
7569
7570 cmd->vdev_id = vdev_id;
7571 cmd->flags = WMI_NLO_CONFIG_STOP;
7572 buf_ptr += sizeof(*cmd);
7573
7574 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7575 buf_ptr += WMI_TLV_HDR_SIZE;
7576
7577 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7578 buf_ptr += WMI_TLV_HDR_SIZE;
7579
7580 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7581 buf_ptr += WMI_TLV_HDR_SIZE;
7582
7583
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307584 wmi_mtrace(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307585 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7586 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7587 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307588 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307589 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307590 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307591 }
7592
Govind Singhb53420c2016-03-09 14:32:57 +05307593 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307594}
7595
7596/**
Govind Singhccb0c272016-04-01 16:30:08 +05307597 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7598 * @buf_ptr: Buffer passed by upper layers
7599 * @pno: Buffer to be sent to the firmware
7600 *
7601 * Copy the PNO Channel prediction configuration parameters
7602 * passed by the upper layers to a WMI format TLV and send it
7603 * down to the firmware.
7604 *
7605 * Return: None
7606 */
7607static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7608 struct pno_scan_req_params *pno)
7609{
7610 nlo_channel_prediction_cfg *channel_prediction_cfg =
7611 (nlo_channel_prediction_cfg *) buf_ptr;
7612 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7613 WMITLV_TAG_ARRAY_BYTE,
7614 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307615#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307616 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7617 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7618 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7619 channel_prediction_cfg->full_scan_period_ms =
7620 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307621#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307622 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7623 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7624 channel_prediction_cfg->enable,
7625 channel_prediction_cfg->top_k_num,
7626 channel_prediction_cfg->stationary_threshold,
7627 channel_prediction_cfg->full_scan_period_ms);
7628}
7629
7630/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007631 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7632 * @wmi_handle: wmi handle
7633 * @params: configuration parameters
7634 *
7635 * Return: QDF_STATUS
7636 */
7637static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7638 struct nlo_mawc_params *params)
7639{
7640 wmi_buf_t buf = NULL;
7641 QDF_STATUS status;
7642 int len;
7643 uint8_t *buf_ptr;
7644 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7645
7646 len = sizeof(*wmi_nlo_mawc_params);
7647 buf = wmi_buf_alloc(wmi_handle, len);
7648 if (!buf) {
7649 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7650 return QDF_STATUS_E_NOMEM;
7651 }
7652
7653 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7654 wmi_nlo_mawc_params =
7655 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7656 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7657 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7658 WMITLV_GET_STRUCT_TLVLEN
7659 (wmi_nlo_configure_mawc_cmd_fixed_param));
7660 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7661 if (params->enable)
7662 wmi_nlo_mawc_params->enable = 1;
7663 else
7664 wmi_nlo_mawc_params->enable = 0;
7665 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7666 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7667 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07007668 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7669 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7670 wmi_nlo_mawc_params->exp_backoff_ratio,
7671 wmi_nlo_mawc_params->init_scan_interval,
7672 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007673
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307674 wmi_mtrace(WMI_NLO_CONFIGURE_MAWC_CMDID, NO_SESSION, 0);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007675 status = wmi_unified_cmd_send(wmi_handle, buf,
7676 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7677 if (QDF_IS_STATUS_ERROR(status)) {
7678 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7679 status);
7680 wmi_buf_free(buf);
7681 return QDF_STATUS_E_FAILURE;
7682 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007683
7684 return QDF_STATUS_SUCCESS;
7685}
7686
7687/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307688 * send_pno_start_cmd_tlv() - PNO start request
7689 * @wmi_handle: wmi handle
7690 * @pno: PNO request
7691 *
7692 * This function request FW to start PNO request.
7693 * Request: CDF status
7694 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307695static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307696 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307697{
7698 wmi_nlo_config_cmd_fixed_param *cmd;
7699 nlo_configured_parameters *nlo_list;
7700 uint32_t *channel_list;
7701 int32_t len;
7702 wmi_buf_t buf;
7703 uint8_t *buf_ptr;
7704 uint8_t i;
7705 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307706 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307707 connected_nlo_rssi_params *nlo_relative_rssi;
7708 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307709
7710 /*
7711 * TLV place holder for array nlo_configured_parameters(nlo_list)
7712 * TLV place holder for array of uint32_t channel_list
7713 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307714 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307715 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05307716 */
7717 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307718 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307719 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307720
Abhishek Singh5987b632017-03-03 22:09:07 +05307721 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307722 WMI_NLO_MAX_CHAN);
7723 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307724 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307725 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307726 len += sizeof(enlo_candidate_score_params);
7727 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307728 len += sizeof(connected_nlo_rssi_params);
7729 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307730
7731 buf = wmi_buf_alloc(wmi_handle, len);
7732 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307733 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7734 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307735 }
7736
7737 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7738
7739 buf_ptr = (uint8_t *) cmd;
7740 WMITLV_SET_HDR(&cmd->tlv_header,
7741 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7742 WMITLV_GET_STRUCT_TLVLEN
7743 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307744 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307745 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7746
Govind Singh87542482016-06-08 19:40:11 +05307747#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307748 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307749 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307750#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307751 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307752 cmd->active_dwell_time = pno->active_dwell_time;
7753 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307754
Manjeet Singhcd2dc062016-08-11 15:31:34 +05307755 if (pno->do_passive_scan)
7756 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307757 /* Copy scan interval */
7758 cmd->fast_scan_period = pno->fast_scan_period;
7759 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007760 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307761 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007762 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307763 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307764 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307765 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307766
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307767 /* mac randomization attributes */
7768 if (pno->scan_random.randomize) {
7769 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7770 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7771 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7772 pno->scan_random.mac_mask,
7773 &cmd->mac_addr,
7774 &cmd->mac_mask);
7775 }
7776
Govind Singh4eacd2b2016-03-07 14:24:22 +05307777 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7778
Abhishek Singh5987b632017-03-03 22:09:07 +05307779 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307780 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307781 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7782 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7783 buf_ptr += WMI_TLV_HDR_SIZE;
7784
7785 nlo_list = (nlo_configured_parameters *) buf_ptr;
7786 for (i = 0; i < cmd->no_of_ssids; i++) {
7787 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7788 WMITLV_TAG_ARRAY_BYTE,
7789 WMITLV_GET_STRUCT_TLVLEN
7790 (nlo_configured_parameters));
7791 /* Copy ssid and it's length */
7792 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307793 nlo_list[i].ssid.ssid.ssid_len =
7794 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307795 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307796 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307797 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307798 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307799 nlo_list[i].ssid.ssid.ssid_len,
7800 (char *)nlo_list[i].ssid.ssid.ssid,
7801 nlo_list[i].ssid.ssid.ssid_len);
7802
7803 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307804 if (pno->networks_list[i].rssi_thresh &&
7805 pno->networks_list[i].rssi_thresh >
7806 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307807 nlo_list[i].rssi_cond.valid = true;
7808 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307809 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307810 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307811 nlo_list[i].rssi_cond.rssi);
7812 }
7813 nlo_list[i].bcast_nw_type.valid = true;
7814 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307815 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007816 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307817 nlo_list[i].bcast_nw_type.bcast_nw_type);
7818 }
7819 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7820
7821 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307822 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307823 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307824 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307825 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7826 (cmd->num_of_channels * sizeof(uint32_t)));
7827 buf_ptr += WMI_TLV_HDR_SIZE;
7828
7829 channel_list = (uint32_t *) buf_ptr;
7830 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307831 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307832
7833 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307834 channel_list[i] =
7835 wlan_chan_to_freq(pno->
7836 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307837
Govind Singhb53420c2016-03-09 14:32:57 +05307838 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307839 }
7840 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7841 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7842 sizeof(nlo_channel_prediction_cfg));
7843 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307844 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307845 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307846 /** TODO: Discrete firmware doesn't have command/option to configure
7847 * App IE which comes from wpa_supplicant as of part PNO start request.
7848 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307849 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
7850 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7851 buf_ptr += sizeof(enlo_candidate_score_params);
7852
7853 if (ie_whitelist->white_list) {
7854 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
7855 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
7856 &cmd->num_vendor_oui,
7857 ie_whitelist);
7858 }
7859
7860 /* ie white list */
7861 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7862 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
7863 buf_ptr += WMI_TLV_HDR_SIZE;
7864 if (cmd->num_vendor_oui != 0) {
7865 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
7866 ie_whitelist->voui);
7867 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
7868 }
7869
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307870 if (pno->relative_rssi_set)
7871 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
7872
7873 /*
7874 * Firmware calculation using connected PNO params:
7875 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
7876 * deduction of rssi_pref for chosen band_pref and
7877 * addition of rssi_pref for remaining bands (other than chosen band).
7878 */
7879 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
7880 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
7881 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
7882 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
7883 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
7884 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
7885 buf_ptr += sizeof(*nlo_relative_rssi);
7886
7887 /*
7888 * As of now Kernel and Host supports one band and rssi preference.
7889 * Firmware supports array of band and rssi preferences
7890 */
7891 cmd->num_cnlo_band_pref = 1;
7892 WMITLV_SET_HDR(buf_ptr,
7893 WMITLV_TAG_ARRAY_STRUC,
7894 cmd->num_cnlo_band_pref *
7895 sizeof(connected_nlo_bss_band_rssi_pref));
7896 buf_ptr += WMI_TLV_HDR_SIZE;
7897
7898 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
7899 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
7900 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
7901 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
7902 WMITLV_GET_STRUCT_TLVLEN(
7903 connected_nlo_bss_band_rssi_pref));
7904 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
7905 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
7906 WMI_LOGI("band_pref %d, rssi_pref %d",
7907 nlo_band_rssi[i].band,
7908 nlo_band_rssi[i].rssi_pref);
7909 }
7910 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
7911
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307912 wmi_mtrace(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307913 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7914 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7915 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307916 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307917 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307918 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307919 }
7920
Govind Singhb53420c2016-03-09 14:32:57 +05307921 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307922}
7923
7924/* send_set_ric_req_cmd_tlv() - set ric request element
7925 * @wmi_handle: wmi handle
7926 * @msg: message
7927 * @is_add_ts: is addts required
7928 *
7929 * This function sets ric request element for 11r roaming.
7930 *
7931 * Return: CDF status
7932 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307933static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307934 void *msg, uint8_t is_add_ts)
7935{
7936 wmi_ric_request_fixed_param *cmd;
7937 wmi_ric_tspec *tspec_param;
7938 wmi_buf_t buf;
7939 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307940 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307941 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7942 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7943
7944 buf = wmi_buf_alloc(wmi_handle, len);
7945 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307946 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7947 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307948 }
7949
7950 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7951
7952 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7953 WMITLV_SET_HDR(&cmd->tlv_header,
7954 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7955 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7956 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007957 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307958 else
7959 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7960 cmd->num_ric_request = 1;
7961 cmd->is_add_ric = is_add_ts;
7962
7963 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7964 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7965
7966 buf_ptr += WMI_TLV_HDR_SIZE;
7967 tspec_param = (wmi_ric_tspec *) buf_ptr;
7968 WMITLV_SET_HDR(&tspec_param->tlv_header,
7969 WMITLV_TAG_STRUC_wmi_ric_tspec,
7970 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7971
7972 if (is_add_ts)
7973 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307974#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307975 else
7976 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307977#endif
7978 if (ptspecIE) {
7979 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307980#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307981 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7982 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307983#else
Govind Singh87542482016-06-08 19:40:11 +05307984 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7985 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307986#endif /* ANI_LITTLE_BIT_ENDIAN */
7987
Govind Singh87542482016-06-08 19:40:11 +05307988 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7989 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7990 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7991 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7992 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7993 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7994 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7995 tspec_param->min_data_rate = ptspecIE->minDataRate;
7996 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7997 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7998 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7999 tspec_param->delay_bound = ptspecIE->delayBound;
8000 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
8001 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
8002 tspec_param->medium_time = 0;
8003 }
Govind Singhb53420c2016-03-09 14:32:57 +05308004 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308005
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308006 wmi_mtrace(WMI_ROAM_SET_RIC_REQUEST_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308007 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8008 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308009 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308010 __func__);
8011 if (is_add_ts)
8012 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05308013 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308014 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308015 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308016 }
8017
Govind Singhb53420c2016-03-09 14:32:57 +05308018 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308019}
8020
Qiwei Cai1ccba222018-05-21 16:49:39 +08008021#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +05308022/**
8023 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
8024 * @wmi_handle: wmi handle
8025 * @clear_req: ll stats clear request command params
8026 *
Govind Singhb53420c2016-03-09 14:32:57 +05308027 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308028 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308029static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308030 const struct ll_stats_clear_params *clear_req,
8031 uint8_t addr[IEEE80211_ADDR_LEN])
8032{
8033 wmi_clear_link_stats_cmd_fixed_param *cmd;
8034 int32_t len;
8035 wmi_buf_t buf;
8036 uint8_t *buf_ptr;
8037 int ret;
8038
8039 len = sizeof(*cmd);
8040 buf = wmi_buf_alloc(wmi_handle, len);
8041
8042 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308043 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8044 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308045 }
8046
8047 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308048 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308049 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
8050
8051 WMITLV_SET_HDR(&cmd->tlv_header,
8052 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
8053 WMITLV_GET_STRUCT_TLVLEN
8054 (wmi_clear_link_stats_cmd_fixed_param));
8055
8056 cmd->stop_stats_collection_req = clear_req->stop_req;
8057 cmd->vdev_id = clear_req->sta_id;
8058 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
8059
8060 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8061 &cmd->peer_macaddr);
8062
Govind Singhb53420c2016-03-09 14:32:57 +05308063 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
8064 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
8065 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
8066 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
8067 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308068 cmd->peer_macaddr); */
8069
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308070 wmi_mtrace(WMI_CLEAR_LINK_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308071 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8072 WMI_CLEAR_LINK_STATS_CMDID);
8073 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308074 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308075 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308076 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308077 }
8078
Govind Singhb53420c2016-03-09 14:32:57 +05308079 WMI_LOGD("Clear Link Layer Stats request sent successfully");
8080 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308081}
8082
8083/**
8084 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
8085 * @wmi_handle: wmi handle
8086 * @setReq: ll stats set request command params
8087 *
Govind Singhb53420c2016-03-09 14:32:57 +05308088 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308089 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308090static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308091 const struct ll_stats_set_params *set_req)
8092{
8093 wmi_start_link_stats_cmd_fixed_param *cmd;
8094 int32_t len;
8095 wmi_buf_t buf;
8096 uint8_t *buf_ptr;
8097 int ret;
8098
8099 len = sizeof(*cmd);
8100 buf = wmi_buf_alloc(wmi_handle, len);
8101
8102 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308103 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8104 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308105 }
8106
8107 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308108 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308109 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
8110
8111 WMITLV_SET_HDR(&cmd->tlv_header,
8112 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
8113 WMITLV_GET_STRUCT_TLVLEN
8114 (wmi_start_link_stats_cmd_fixed_param));
8115
8116 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
8117 cmd->aggressive_statistics_gathering =
8118 set_req->aggressive_statistics_gathering;
8119
Govind Singhb53420c2016-03-09 14:32:57 +05308120 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
8121 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
8122 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308123
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308124 wmi_mtrace(WMI_START_LINK_STATS_CMDID, NO_SESSION, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308125 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8126 WMI_START_LINK_STATS_CMDID);
8127 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308128 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308129 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308130 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308131 }
8132
Govind Singhb53420c2016-03-09 14:32:57 +05308133 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308134}
8135
8136/**
8137 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
8138 * @wmi_handle:wmi handle
8139 * @get_req:ll stats get request command params
8140 * @addr: mac address
8141 *
Govind Singhb53420c2016-03-09 14:32:57 +05308142 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308143 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308144static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308145 const struct ll_stats_get_params *get_req,
8146 uint8_t addr[IEEE80211_ADDR_LEN])
8147{
8148 wmi_request_link_stats_cmd_fixed_param *cmd;
8149 int32_t len;
8150 wmi_buf_t buf;
8151 uint8_t *buf_ptr;
8152 int ret;
8153
8154 len = sizeof(*cmd);
8155 buf = wmi_buf_alloc(wmi_handle, len);
8156
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308157 if (!buf) {
8158 WMI_LOGE("%s: buf allocation failed", __func__);
8159 return QDF_STATUS_E_NOMEM;
8160 }
8161
Govind Singh4eacd2b2016-03-07 14:24:22 +05308162 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308163 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308164 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8165
8166 WMITLV_SET_HDR(&cmd->tlv_header,
8167 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8168 WMITLV_GET_STRUCT_TLVLEN
8169 (wmi_request_link_stats_cmd_fixed_param));
8170
8171 cmd->request_id = get_req->req_id;
8172 cmd->stats_type = get_req->param_id_mask;
8173 cmd->vdev_id = get_req->sta_id;
8174
8175 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8176 &cmd->peer_macaddr);
8177
Govind Singhb53420c2016-03-09 14:32:57 +05308178 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008179 WMI_LOGD("Request ID : %u", cmd->request_id);
8180 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308181 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8182 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308183
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308184 wmi_mtrace(WMI_REQUEST_LINK_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308185 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8186 WMI_REQUEST_LINK_STATS_CMDID);
8187 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308188 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308189 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308190 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308191 }
8192
Govind Singhb53420c2016-03-09 14:32:57 +05308193 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308194}
Qiwei Cai1ccba222018-05-21 16:49:39 +08008195#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308196
Govind Singh20c5dac2016-03-07 15:33:31 +05308197/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308198 * send_congestion_cmd_tlv() - send request to fw to get CCA
8199 * @wmi_handle: wmi handle
8200 * @vdev_id: vdev id
8201 *
8202 * Return: CDF status
8203 */
8204static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05308205 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308206{
8207 wmi_buf_t buf;
8208 wmi_request_stats_cmd_fixed_param *cmd;
8209 uint8_t len;
8210 uint8_t *buf_ptr;
8211
8212 len = sizeof(*cmd);
8213 buf = wmi_buf_alloc(wmi_handle, len);
8214 if (!buf) {
8215 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8216 return QDF_STATUS_E_FAILURE;
8217 }
8218
8219 buf_ptr = wmi_buf_data(buf);
8220 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8221 WMITLV_SET_HDR(&cmd->tlv_header,
8222 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8223 WMITLV_GET_STRUCT_TLVLEN
8224 (wmi_request_stats_cmd_fixed_param));
8225
8226 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8227 cmd->vdev_id = vdev_id;
8228 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8229 cmd->vdev_id, cmd->stats_id);
8230
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308231 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308232 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8233 WMI_REQUEST_STATS_CMDID)) {
8234 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8235 __func__);
8236 wmi_buf_free(buf);
8237 return QDF_STATUS_E_FAILURE;
8238 }
8239
8240 return QDF_STATUS_SUCCESS;
8241}
8242
8243/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308244 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8245 * @wmi_handle: wmi handle
8246 * @rssi_req: get RSSI request
8247 *
8248 * Return: CDF status
8249 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308250static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308251{
8252 wmi_buf_t buf;
8253 wmi_request_stats_cmd_fixed_param *cmd;
8254 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8255
8256 buf = wmi_buf_alloc(wmi_handle, len);
8257 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308258 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8259 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308260 }
8261
8262 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8263 WMITLV_SET_HDR(&cmd->tlv_header,
8264 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8265 WMITLV_GET_STRUCT_TLVLEN
8266 (wmi_request_stats_cmd_fixed_param));
8267 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308268 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308269 if (wmi_unified_cmd_send
8270 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308271 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308272 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308273 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308274 }
8275
Govind Singhb53420c2016-03-09 14:32:57 +05308276 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308277}
8278
8279/**
8280 * send_snr_cmd_tlv() - get RSSI from fw
8281 * @wmi_handle: wmi handle
8282 * @vdev_id: vdev id
8283 *
8284 * Return: CDF status
8285 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308286static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308287{
8288 wmi_buf_t buf;
8289 wmi_request_stats_cmd_fixed_param *cmd;
8290 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8291
8292 buf = wmi_buf_alloc(wmi_handle, len);
8293 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308294 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8295 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308296 }
8297
8298 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8299 cmd->vdev_id = vdev_id;
8300
8301 WMITLV_SET_HDR(&cmd->tlv_header,
8302 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8303 WMITLV_GET_STRUCT_TLVLEN
8304 (wmi_request_stats_cmd_fixed_param));
8305 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308306 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308307 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8308 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308309 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308310 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308311 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308312 }
8313
Govind Singhb53420c2016-03-09 14:32:57 +05308314 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308315}
8316
8317/**
8318 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8319 * @wmi_handle: wmi handle
8320 * @link_status: get link params
8321 *
8322 * Return: CDF status
8323 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308324static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308325 struct link_status_params *link_status)
8326{
8327 wmi_buf_t buf;
8328 wmi_request_stats_cmd_fixed_param *cmd;
8329 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8330
8331 buf = wmi_buf_alloc(wmi_handle, len);
8332 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308333 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8334 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308335 }
8336
8337 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8338 WMITLV_SET_HDR(&cmd->tlv_header,
8339 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8340 WMITLV_GET_STRUCT_TLVLEN
8341 (wmi_request_stats_cmd_fixed_param));
8342 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8343 cmd->vdev_id = link_status->session_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308344 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308345 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8346 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308347 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308348 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308349 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308350 }
8351
Govind Singhb53420c2016-03-09 14:32:57 +05308352 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308353}
8354
Govind Singh20c5dac2016-03-07 15:33:31 +05308355/**
8356 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8357 * @wmi_handle: wmi handle
8358 * @ta_dhcp_ind: DHCP indication parameter
8359 *
8360 * Return: CDF Status
8361 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308362static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308363 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8364{
Govind Singh67922e82016-04-01 16:48:57 +05308365 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308366 wmi_buf_t buf = NULL;
8367 uint8_t *buf_ptr;
8368 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8369 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8370
8371
8372 buf = wmi_buf_alloc(wmi_handle, len);
8373 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308374 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8375 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308376 }
8377
8378 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8379 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8380 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8381 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8382 WMITLV_GET_STRUCT_TLVLEN
8383 (wmi_peer_set_param_cmd_fixed_param));
8384
8385 /* fill in values */
8386 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8387 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8388 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308389 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308390 &ta_dhcp_ind->peer_macaddr,
8391 sizeof(ta_dhcp_ind->peer_macaddr));
8392
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308393 wmi_mtrace(WMI_PEER_SET_PARAM_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308394 status = wmi_unified_cmd_send(wmi_handle, buf,
8395 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308396 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308397 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308398 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308399 wmi_buf_free(buf);
8400 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308401
Govind Singh67922e82016-04-01 16:48:57 +05308402 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308403}
8404
8405/**
8406 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8407 * @wmi_handle: wmi handle
8408 * @pLinkSpeed: link speed info
8409 *
8410 * Return: CDF status
8411 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308412static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308413 wmi_mac_addr peer_macaddr)
8414{
8415 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8416 wmi_buf_t wmi_buf;
8417 uint32_t len;
8418 uint8_t *buf_ptr;
8419
8420 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8421 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8422 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308423 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8424 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308425 }
8426 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8427
8428 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8429 WMITLV_SET_HDR(&cmd->tlv_header,
8430 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8431 WMITLV_GET_STRUCT_TLVLEN
8432 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8433
8434 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308435 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308436 &peer_macaddr,
8437 sizeof(peer_macaddr));
8438
8439
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308440 wmi_mtrace(WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308441 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8442 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308443 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308444 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308445 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308446 }
Govind Singhb53420c2016-03-09 14:32:57 +05308447 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308448}
8449
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308450#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308451/**
8452 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8453 * @wmi_handle: wmi handler
8454 * @egap_params: pointer to egap_params
8455 *
8456 * Return: 0 for success, otherwise appropriate error code
8457 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308458static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308459 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308460{
8461 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8462 wmi_buf_t buf;
8463 int32_t err;
8464
8465 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8466 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308467 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8468 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308469 }
8470 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8471 WMITLV_SET_HDR(&cmd->tlv_header,
8472 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8473 WMITLV_GET_STRUCT_TLVLEN(
8474 wmi_ap_ps_egap_param_cmd_fixed_param));
8475
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308476 cmd->enable = egap_params->host_enable_egap;
8477 cmd->inactivity_time = egap_params->egap_inactivity_time;
8478 cmd->wait_time = egap_params->egap_wait_time;
8479 cmd->flags = egap_params->egap_feature_flags;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308480 wmi_mtrace(WMI_AP_PS_EGAP_PARAM_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308481 err = wmi_unified_cmd_send(wmi_handle, buf,
8482 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8483 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308484 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308485 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308486 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308487 }
8488
Govind Singhb53420c2016-03-09 14:32:57 +05308489 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308490}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308491#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308492
8493/**
8494 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8495 * @wmi_handl: wmi handle
8496 * @cmd: Profiling command index
8497 * @value1: parameter1 value
8498 * @value2: parameter2 value
8499 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308500 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308501 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308502static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308503 uint32_t cmd, uint32_t value1, uint32_t value2)
8504{
8505 wmi_buf_t buf;
8506 int32_t len = 0;
8507 int ret;
8508 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8509 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8510 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8511 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8512
8513 switch (cmd) {
8514 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8515 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8516 buf = wmi_buf_alloc(wmi_handle, len);
8517 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308518 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308519 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308520 }
8521 prof_trig_cmd =
8522 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8523 wmi_buf_data(buf);
8524 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8525 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8526 WMITLV_GET_STRUCT_TLVLEN
8527 (wmi_wlan_profile_trigger_cmd_fixed_param));
8528 prof_trig_cmd->enable = value1;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308529 wmi_mtrace(WMI_WLAN_PROFILE_TRIGGER_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308530 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8531 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8532 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308533 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308534 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308535 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308536 return ret;
8537 }
8538 break;
8539
8540 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8541 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8542 buf = wmi_buf_alloc(wmi_handle, len);
8543 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308544 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308545 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308546 }
8547 profile_getdata_cmd =
8548 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8549 wmi_buf_data(buf);
8550 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8551 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8552 WMITLV_GET_STRUCT_TLVLEN
8553 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308554 wmi_mtrace(WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID,
8555 NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308556 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8557 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8558 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308559 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308560 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308561 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308562 return ret;
8563 }
8564 break;
8565
8566 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8567 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8568 buf = wmi_buf_alloc(wmi_handle, len);
8569 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308570 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308571 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308572 }
8573 hist_intvl_cmd =
8574 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8575 wmi_buf_data(buf);
8576 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8577 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8578 WMITLV_GET_STRUCT_TLVLEN
8579 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8580 hist_intvl_cmd->profile_id = value1;
8581 hist_intvl_cmd->value = value2;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308582 wmi_mtrace(WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID,
8583 NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308584 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8585 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8586 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308587 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308588 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308589 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308590 return ret;
8591 }
8592 break;
8593
8594 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8595 len =
8596 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8597 buf = wmi_buf_alloc(wmi_handle, len);
8598 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308599 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308600 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308601 }
8602 profile_enable_cmd =
8603 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8604 wmi_buf_data(buf);
8605 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8606 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8607 WMITLV_GET_STRUCT_TLVLEN
8608 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8609 profile_enable_cmd->profile_id = value1;
8610 profile_enable_cmd->enable = value2;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308611 wmi_mtrace(WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID,
8612 NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308613 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8614 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8615 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308616 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308617 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308618 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308619 return ret;
8620 }
8621 break;
8622
8623 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308624 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308625 break;
8626 }
8627
8628 return 0;
8629}
8630
Paul Zhang92ab8d32017-12-08 16:08:00 +08008631static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
8632 struct wlm_latency_level_param *params)
8633{
8634 wmi_wlm_config_cmd_fixed_param *cmd;
8635 wmi_buf_t buf;
8636 uint32_t len = sizeof(*cmd);
8637 static uint32_t ll[4] = {100, 60, 40, 20};
8638
8639 buf = wmi_buf_alloc(wmi_handle, len);
8640 if (!buf) {
8641 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8642 return QDF_STATUS_E_NOMEM;
8643 }
8644 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
8645 WMITLV_SET_HDR(&cmd->tlv_header,
8646 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
8647 WMITLV_GET_STRUCT_TLVLEN
8648 (wmi_wlm_config_cmd_fixed_param));
8649 cmd->vdev_id = params->vdev_id;
8650 cmd->latency_level = params->wlm_latency_level;
8651 cmd->ul_latency = ll[params->wlm_latency_level];
8652 cmd->dl_latency = ll[params->wlm_latency_level];
8653 cmd->flags = params->wlm_latency_flags;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308654 wmi_mtrace(WMI_WLM_CONFIG_CMDID, cmd->vdev_id, 0);
Paul Zhang92ab8d32017-12-08 16:08:00 +08008655 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8656 WMI_WLM_CONFIG_CMDID)) {
8657 WMI_LOGE("%s: Failed to send setting latency config command",
8658 __func__);
8659 wmi_buf_free(buf);
8660 return QDF_STATUS_E_FAILURE;
8661 }
8662
8663 return 0;
8664}
Govind Singh20c5dac2016-03-07 15:33:31 +05308665/**
8666 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8667 * @wmi_handle: wmi handle
8668 * @vdev_id: vdev id
8669 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308670 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308671 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308672static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308673{
8674 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8675 wmi_buf_t buf;
8676 int32_t len = sizeof(*cmd);
8677
Govind Singhb53420c2016-03-09 14:32:57 +05308678 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308679 buf = wmi_buf_alloc(wmi_handle, len);
8680 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308681 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308682 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308683 }
8684 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8685 wmi_buf_data(buf);
8686 WMITLV_SET_HDR(&cmd->tlv_header,
8687 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8688 WMITLV_GET_STRUCT_TLVLEN
8689 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8690 cmd->vdev_id = vdev_id;
8691 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308692 wmi_mtrace(WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308693 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8694 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308695 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308696 __func__);
8697 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308698 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308699 }
8700
8701 return 0;
8702}
8703
8704/**
8705 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8706 * @wmi_handle: wmi handle
8707 * @vdev_id: vdev id
8708 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308709 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308710 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308711static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308712 uint8_t vdev_id)
8713{
8714 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8715 wmi_buf_t buf;
8716 int32_t len = sizeof(*cmd);
8717
Govind Singhb53420c2016-03-09 14:32:57 +05308718 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308719 buf = wmi_buf_alloc(wmi_handle, len);
8720 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308721 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308722 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308723 }
8724 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8725 WMITLV_SET_HDR(&cmd->tlv_header,
8726 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8727 WMITLV_GET_STRUCT_TLVLEN
8728 (wmi_csa_offload_enable_cmd_fixed_param));
8729 cmd->vdev_id = vdev_id;
8730 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308731 wmi_mtrace(WMI_CSA_OFFLOAD_ENABLE_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308732 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8733 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308734 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308735 __func__);
8736 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308737 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308738 }
8739
8740 return 0;
8741}
8742
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008743#ifdef WLAN_FEATURE_CIF_CFR
8744/**
8745 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8746 * @wmi_handle: wmi handle
8747 * @data_len: len of dma cfg req
8748 * @data: dma cfg req
8749 *
8750 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8751 */
8752static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8753 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8754{
8755 wmi_buf_t buf;
8756 uint8_t *cmd;
8757 QDF_STATUS ret;
8758
8759 WMITLV_SET_HDR(cfg,
8760 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8761 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8762
8763 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8764 if (!buf) {
8765 WMI_LOGE(FL("wmi_buf_alloc failed"));
8766 return QDF_STATUS_E_FAILURE;
8767 }
8768
8769 cmd = (uint8_t *) wmi_buf_data(buf);
8770 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8771 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8772 sizeof(*cfg));
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308773 wmi_mtrace(WMI_OEM_DMA_RING_CFG_REQ_CMDID, NO_SESSION, 0);
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008774 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8775 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8776 if (QDF_IS_STATUS_ERROR(ret)) {
8777 WMI_LOGE(FL(":wmi cmd send failed"));
8778 wmi_buf_free(buf);
8779 }
8780
8781 return ret;
8782}
8783#endif
8784
Govind Singh20c5dac2016-03-07 15:33:31 +05308785/**
Sathish Kumarf396c722017-11-17 17:30:41 +05308786 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
8787 * @wmi_handle: wmi handle
8788 * @data_len: len of dma cfg req
8789 * @data: dma cfg req
8790 *
8791 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8792 */
8793static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8794 struct direct_buf_rx_cfg_req *cfg)
8795{
8796 wmi_buf_t buf;
8797 wmi_dma_ring_cfg_req_fixed_param *cmd;
8798 QDF_STATUS ret;
8799 int32_t len = sizeof(*cmd);
8800
8801 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8802 if (!buf) {
8803 WMI_LOGE(FL("wmi_buf_alloc failed"));
8804 return QDF_STATUS_E_FAILURE;
8805 }
8806
8807 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
8808
8809 WMITLV_SET_HDR(&cmd->tlv_header,
8810 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
8811 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
8812
8813 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8814 cfg->pdev_id);
8815 cmd->mod_id = cfg->mod_id;
8816 cmd->base_paddr_lo = cfg->base_paddr_lo;
8817 cmd->base_paddr_hi = cfg->base_paddr_hi;
8818 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
8819 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
8820 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
8821 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
8822 cmd->num_elems = cfg->num_elems;
8823 cmd->buf_size = cfg->buf_size;
8824 cmd->num_resp_per_event = cfg->num_resp_per_event;
8825 cmd->event_timeout_ms = cfg->event_timeout_ms;
8826
8827 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
8828 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
8829 "head idx paddr hi %x tail idx paddr lo %x"
8830 "tail idx addr hi %x num elems %d buf size %d num resp %d"
8831 "event timeout %d\n", __func__, cmd->pdev_id,
8832 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
8833 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
8834 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
8835 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
8836 cmd->event_timeout_ms);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308837 wmi_mtrace(WMI_PDEV_DMA_RING_CFG_REQ_CMDID, NO_SESSION, 0);
Sathish Kumarf396c722017-11-17 17:30:41 +05308838 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8839 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
8840 if (QDF_IS_STATUS_ERROR(ret)) {
8841 WMI_LOGE(FL(":wmi cmd send failed"));
8842 wmi_buf_free(buf);
8843 }
8844
8845 return ret;
8846}
8847
8848/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008849 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8850 * @wmi_handle: wmi handle
8851 * @start_11d_scan: 11d scan start request parameters
8852 *
8853 * This function request FW to start 11d scan.
8854 *
8855 * Return: QDF status
8856 */
8857static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8858 struct reg_start_11d_scan_req *start_11d_scan)
8859{
8860 wmi_11d_scan_start_cmd_fixed_param *cmd;
8861 int32_t len;
8862 wmi_buf_t buf;
8863 int ret;
8864
8865 len = sizeof(*cmd);
8866 buf = wmi_buf_alloc(wmi_handle, len);
8867 if (!buf) {
8868 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8869 return QDF_STATUS_E_NOMEM;
8870 }
8871
8872 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8873
8874 WMITLV_SET_HDR(&cmd->tlv_header,
8875 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8876 WMITLV_GET_STRUCT_TLVLEN
8877 (wmi_11d_scan_start_cmd_fixed_param));
8878
8879 cmd->vdev_id = start_11d_scan->vdev_id;
8880 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8881 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8882
8883 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8884
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308885 wmi_mtrace(WMI_11D_SCAN_START_CMDID, cmd->vdev_id, 0);
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008886 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8887 WMI_11D_SCAN_START_CMDID);
8888 if (ret) {
8889 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8890 wmi_buf_free(buf);
8891 return QDF_STATUS_E_FAILURE;
8892 }
8893
8894 return QDF_STATUS_SUCCESS;
8895}
8896
8897/**
8898 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8899 * @wmi_handle: wmi handle
8900 * @start_11d_scan: 11d scan stop request parameters
8901 *
8902 * This function request FW to stop 11d scan.
8903 *
8904 * Return: QDF status
8905 */
8906static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8907 struct reg_stop_11d_scan_req *stop_11d_scan)
8908{
8909 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8910 int32_t len;
8911 wmi_buf_t buf;
8912 int ret;
8913
8914 len = sizeof(*cmd);
8915 buf = wmi_buf_alloc(wmi_handle, len);
8916 if (!buf) {
8917 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8918 return QDF_STATUS_E_NOMEM;
8919 }
8920
8921 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8922
8923 WMITLV_SET_HDR(&cmd->tlv_header,
8924 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8925 WMITLV_GET_STRUCT_TLVLEN
8926 (wmi_11d_scan_stop_cmd_fixed_param));
8927
8928 cmd->vdev_id = stop_11d_scan->vdev_id;
8929
8930 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8931
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308932 wmi_mtrace(WMI_11D_SCAN_STOP_CMDID, cmd->vdev_id, 0);
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008933 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8934 WMI_11D_SCAN_STOP_CMDID);
8935 if (ret) {
8936 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8937 wmi_buf_free(buf);
8938 return QDF_STATUS_E_FAILURE;
8939 }
8940
8941 return QDF_STATUS_SUCCESS;
8942}
8943
8944/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308945 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8946 * @wmi_handle: wmi handle
8947 * @startOemDataReq: start request params
8948 *
8949 * Return: CDF status
8950 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308951static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008952 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308953 uint8_t *data)
8954{
8955 wmi_buf_t buf;
8956 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308957 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308958
8959 buf = wmi_buf_alloc(wmi_handle,
8960 (data_len + WMI_TLV_HDR_SIZE));
8961 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308962 WMI_LOGE(FL("wmi_buf_alloc failed"));
8963 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308964 }
8965
8966 cmd = (uint8_t *) wmi_buf_data(buf);
8967
8968 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8969 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308970 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308971 data_len);
8972
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008973 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308974 data_len);
8975
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05308976 wmi_mtrace(WMI_OEM_REQ_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05308977 ret = wmi_unified_cmd_send(wmi_handle, buf,
8978 (data_len +
8979 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8980
Govind Singh67922e82016-04-01 16:48:57 +05308981 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308982 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308983 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308984 }
8985
Govind Singh67922e82016-04-01 16:48:57 +05308986 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308987}
8988
8989/**
8990 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8991 * @wmi_handle: wmi handle
8992 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8993 *
8994 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8995 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8996 * to firmware based on phyerr filtering
8997 * offload status.
8998 *
8999 * Return: 1 success, 0 failure
9000 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309001static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05309002send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
9003 bool dfs_phyerr_filter_offload)
9004{
9005 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
9006 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
9007 wmi_buf_t buf;
9008 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05309009 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309010
9011
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07009012 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05309013 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309014 __func__);
9015 len = sizeof(*disable_phyerr_offload_cmd);
9016 buf = wmi_buf_alloc(wmi_handle, len);
9017 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309018 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309019 return 0;
9020 }
9021 disable_phyerr_offload_cmd =
9022 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
9023 wmi_buf_data(buf);
9024
9025 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
9026 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
9027 WMITLV_GET_STRUCT_TLVLEN
9028 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
9029
9030 /*
9031 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
9032 * to the firmware to disable the phyerror
9033 * filtering offload.
9034 */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309035 wmi_mtrace(WMI_DFS_PHYERR_FILTER_DIS_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309036 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9037 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309038 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309039 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309040 __func__, ret);
9041 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309042 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309043 }
Govind Singhb53420c2016-03-09 14:32:57 +05309044 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309045 __func__);
9046 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05309047 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309048 __func__);
9049
9050 len = sizeof(*enable_phyerr_offload_cmd);
9051 buf = wmi_buf_alloc(wmi_handle, len);
9052 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309053 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9054 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309055 }
9056
9057 enable_phyerr_offload_cmd =
9058 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
9059 wmi_buf_data(buf);
9060
9061 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
9062 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
9063 WMITLV_GET_STRUCT_TLVLEN
9064 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
9065
9066 /*
9067 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
9068 * to the firmware to enable the phyerror
9069 * filtering offload.
9070 */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309071 wmi_mtrace(WMI_DFS_PHYERR_FILTER_ENA_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309072 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9073 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
9074
Govind Singh67922e82016-04-01 16:48:57 +05309075 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309076 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309077 __func__, ret);
9078 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309079 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309080 }
Govind Singhb53420c2016-03-09 14:32:57 +05309081 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309082 __func__);
9083 }
9084
Govind Singhb53420c2016-03-09 14:32:57 +05309085 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309086}
9087
Naveen Rawata5817e72017-10-26 18:50:19 -07009088/**
9089 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
9090 * will wake up host after specified time is elapsed
9091 * @wmi_handle: wmi handle
9092 * @vdev_id: vdev id
9093 * @cookie: value to identify reason why host set up wake call.
9094 * @time: time in ms
9095 *
9096 * Return: QDF status
9097 */
9098static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9099 uint8_t vdev_id, uint32_t cookie, uint32_t time)
9100{
9101 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
9102 wmi_buf_t buf;
9103 uint8_t *buf_ptr;
9104 int32_t len;
9105 int ret;
9106
9107 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
9108 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
9109 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
9110 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
9111 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05309112 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
9113 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07009114
9115 buf = wmi_buf_alloc(wmi_handle, len);
9116 if (!buf) {
9117 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9118 return QDF_STATUS_E_NOMEM;
9119 }
9120
9121 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9122 buf_ptr = (uint8_t *) cmd;
9123
9124 WMITLV_SET_HDR(&cmd->tlv_header,
9125 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
9126 WMITLV_GET_STRUCT_TLVLEN
9127 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
9128 cmd->vdev_id = vdev_id;
9129 cmd->pattern_id = cookie,
9130 cmd->pattern_type = WOW_TIMER_PATTERN;
9131 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
9132
9133 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
9134 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9135 buf_ptr += WMI_TLV_HDR_SIZE;
9136
9137 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
9138 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9139 buf_ptr += WMI_TLV_HDR_SIZE;
9140
9141 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
9142 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9143 buf_ptr += WMI_TLV_HDR_SIZE;
9144
9145 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
9146 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9147 buf_ptr += WMI_TLV_HDR_SIZE;
9148
9149 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05309150 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07009151 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05309152 *((uint32_t *) buf_ptr) = time;
9153 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07009154
9155 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05309156 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07009157 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05309158 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07009159
9160 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
9161 __func__, time, vdev_id);
9162
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309163 wmi_mtrace(WMI_WOW_ADD_WAKE_PATTERN_CMDID, cmd->vdev_id, 0);
Naveen Rawata5817e72017-10-26 18:50:19 -07009164 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9165 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9166 if (ret) {
9167 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9168 __func__);
9169 wmi_buf_free(buf);
9170 return QDF_STATUS_E_FAILURE;
9171 }
9172
9173 return QDF_STATUS_SUCCESS;
9174}
9175
Govind Singh20c5dac2016-03-07 15:33:31 +05309176#if !defined(REMOVE_PKT_LOG)
9177/**
9178 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9179 * @wmi_handle: wmi handle
9180 * @pktlog_event: pktlog event
9181 * @cmd_id: pktlog cmd id
9182 *
9183 * Return: CDF status
9184 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309185static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309186 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309187 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309188{
9189 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9190 WMI_CMD_ID CMD_ID;
9191 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9192 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9193 int len = 0;
9194 wmi_buf_t buf;
9195
9196 PKTLOG_EVENT = pktlog_event;
9197 CMD_ID = cmd_id;
9198
9199 switch (CMD_ID) {
9200 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9201 len = sizeof(*cmd);
9202 buf = wmi_buf_alloc(wmi_handle, len);
9203 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309204 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9205 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309206 }
9207 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9208 wmi_buf_data(buf);
9209 WMITLV_SET_HDR(&cmd->tlv_header,
9210 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9211 WMITLV_GET_STRUCT_TLVLEN
9212 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9213 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309214 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9215 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309216 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9217 WMI_HOST_PDEV_ID_SOC);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309218 wmi_mtrace(WMI_PDEV_PKTLOG_ENABLE_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309219 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9220 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309221 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309222 goto wmi_send_failed;
9223 }
9224 break;
9225 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9226 len = sizeof(*disable_cmd);
9227 buf = wmi_buf_alloc(wmi_handle, len);
9228 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309229 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9230 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309231 }
9232 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9233 wmi_buf_data(buf);
9234 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9235 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9236 WMITLV_GET_STRUCT_TLVLEN
9237 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309238 disable_cmd->pdev_id =
9239 wmi_handle->ops->convert_pdev_id_host_to_target(
9240 WMI_HOST_PDEV_ID_SOC);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309241 wmi_mtrace(WMI_PDEV_PKTLOG_DISABLE_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309242 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9243 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309244 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309245 goto wmi_send_failed;
9246 }
9247 break;
9248 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309249 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309250 break;
9251 }
9252
Govind Singhb53420c2016-03-09 14:32:57 +05309253 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309254
9255wmi_send_failed:
9256 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309257 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309258}
9259#endif /* REMOVE_PKT_LOG */
9260
9261/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309262 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9263 * @wmi_handle: wmi handle
9264 * @ptrn_id: pattern id
9265 * @vdev_id: vdev id
9266 *
9267 * Return: CDF status
9268 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309269static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9270 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309271{
9272 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9273 wmi_buf_t buf;
9274 int32_t len;
9275 int ret;
9276
9277 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9278
9279
9280 buf = wmi_buf_alloc(wmi_handle, len);
9281 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309282 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9283 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309284 }
9285
9286 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9287
9288 WMITLV_SET_HDR(&cmd->tlv_header,
9289 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9290 WMITLV_GET_STRUCT_TLVLEN(
9291 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9292 cmd->vdev_id = vdev_id;
9293 cmd->pattern_id = ptrn_id;
9294 cmd->pattern_type = WOW_BITMAP_PATTERN;
9295
Govind Singhb53420c2016-03-09 14:32:57 +05309296 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309297 cmd->pattern_id, vdev_id);
9298
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309299 wmi_mtrace(WMI_WOW_DEL_WAKE_PATTERN_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309300 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9301 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9302 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309303 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309304 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309305 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309306 }
9307
Govind Singhb53420c2016-03-09 14:32:57 +05309308 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309309}
9310
9311/**
9312 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9313 * @wmi_handle: wmi handle
9314 *
9315 * Sends host wakeup indication to FW. On receiving this indication,
9316 * FW will come out of WOW.
9317 *
9318 * Return: CDF status
9319 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309320static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309321{
9322 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9323 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309324 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309325 int32_t len;
9326 int ret;
9327
9328 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9329
9330 buf = wmi_buf_alloc(wmi_handle, len);
9331 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309332 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9333 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309334 }
9335
9336 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9337 wmi_buf_data(buf);
9338 WMITLV_SET_HDR(&cmd->tlv_header,
9339 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9340 WMITLV_GET_STRUCT_TLVLEN
9341 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9342
9343
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309344 wmi_mtrace(WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309345 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9346 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9347 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309348 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309349 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309350 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309351 }
9352
Govind Singhb53420c2016-03-09 14:32:57 +05309353 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309354}
9355
9356/**
9357 * send_del_ts_cmd_tlv() - send DELTS request to fw
9358 * @wmi_handle: wmi handle
9359 * @msg: delts params
9360 *
9361 * Return: CDF status
9362 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309363static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309364 uint8_t ac)
9365{
9366 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9367 wmi_buf_t buf;
9368 int32_t len = sizeof(*cmd);
9369
9370 buf = wmi_buf_alloc(wmi_handle, len);
9371 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309372 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9373 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309374 }
9375 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9376 WMITLV_SET_HDR(&cmd->tlv_header,
9377 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9378 WMITLV_GET_STRUCT_TLVLEN
9379 (wmi_vdev_wmm_delts_cmd_fixed_param));
9380 cmd->vdev_id = vdev_id;
9381 cmd->ac = ac;
9382
Govind Singhb53420c2016-03-09 14:32:57 +05309383 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309384 cmd->vdev_id, cmd->ac, __func__, __LINE__);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309385 wmi_mtrace(WMI_VDEV_WMM_DELTS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309386 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9387 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309388 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309389 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309390 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309391 }
9392
Govind Singhb53420c2016-03-09 14:32:57 +05309393 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309394}
9395
9396/**
9397 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9398 * @wmi_handle: handle to wmi
9399 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9400 *
Govind Singhb53420c2016-03-09 14:32:57 +05309401 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309402 * ADD_TS requestes to firmware in loop for all the ACs with
9403 * active flow.
9404 *
9405 * Return: CDF status
9406 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309407static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309408 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9409{
9410 int i = 0;
9411 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9412 wmi_buf_t buf;
9413 int32_t len = sizeof(*cmd);
9414
9415 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9416 /* if flow in this AC is active */
9417 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9418 /*
9419 * as per implementation of wma_add_ts_req() we
9420 * are not waiting any response from firmware so
9421 * apart from sending ADDTS to firmware just send
9422 * success to upper layers
9423 */
Govind Singhb53420c2016-03-09 14:32:57 +05309424 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309425
9426 buf = wmi_buf_alloc(wmi_handle, len);
9427 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309428 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9429 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309430 }
9431 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9432 wmi_buf_data(buf);
9433 WMITLV_SET_HDR(&cmd->tlv_header,
9434 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9435 WMITLV_GET_STRUCT_TLVLEN
9436 (wmi_vdev_wmm_addts_cmd_fixed_param));
Rajasekaran Kalidoss81f8de22018-08-04 00:17:18 +05309437 cmd->vdev_id = aggr_qos_rsp_msg->vdev_id;
Govind Singh20c5dac2016-03-07 15:33:31 +05309438 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309439 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309440 traffic.userPrio);
9441 cmd->medium_time_us =
9442 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9443 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309444 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309445 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9446 cmd->medium_time_us, cmd->downgrade_type);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309447 wmi_mtrace(WMI_VDEV_WMM_ADDTS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309448 if (wmi_unified_cmd_send
9449 (wmi_handle, buf, len,
9450 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309451 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309452 __func__);
9453 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309454 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309455 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309456 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309457 }
9458 }
9459 }
9460
Govind Singhb53420c2016-03-09 14:32:57 +05309461 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309462}
9463
9464/**
9465 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9466 * @wmi_handle: wmi handle
9467 * @msg: ADDTS params
9468 *
9469 * Return: CDF status
9470 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309471static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309472 struct add_ts_param *msg)
9473{
9474 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9475 wmi_buf_t buf;
9476 int32_t len = sizeof(*cmd);
9477
Govind Singhb53420c2016-03-09 14:32:57 +05309478 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309479
9480 buf = wmi_buf_alloc(wmi_handle, len);
9481 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309482 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9483 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309484 }
9485 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9486 WMITLV_SET_HDR(&cmd->tlv_header,
9487 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9488 WMITLV_GET_STRUCT_TLVLEN
9489 (wmi_vdev_wmm_addts_cmd_fixed_param));
9490 cmd->vdev_id = msg->sme_session_id;
9491 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9492 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9493 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309494 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309495 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9496 cmd->downgrade_type, __func__, __LINE__);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309497 wmi_mtrace(WMI_VDEV_WMM_ADDTS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309498 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9499 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309500 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9501 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309502 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309503 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309504 }
9505
Govind Singhb53420c2016-03-09 14:32:57 +05309506 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309507}
9508
9509/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309510 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9511 * @wmi_handle: wmi handle
9512 * @pAddPeriodicTxPtrnParams: tx ptrn params
9513 *
9514 * Retrun: CDF status
9515 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309516static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309517 struct periodic_tx_pattern *
9518 pAddPeriodicTxPtrnParams,
9519 uint8_t vdev_id)
9520{
9521 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9522 wmi_buf_t wmi_buf;
9523 uint32_t len;
9524 uint8_t *buf_ptr;
9525 uint32_t ptrn_len, ptrn_len_aligned;
9526 int j;
9527
9528 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9529 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9530 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9531 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9532
9533 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9534 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309535 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9536 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309537 }
9538
9539 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9540
9541 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9542 WMITLV_SET_HDR(&cmd->tlv_header,
9543 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9544 WMITLV_GET_STRUCT_TLVLEN
9545 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9546
9547 /* Pass the pattern id to delete for the corresponding vdev id */
9548 cmd->vdev_id = vdev_id;
9549 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9550 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9551 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9552
9553 /* Pattern info */
9554 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9555 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9556 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309557 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309558 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309559 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309560
Govind Singhb53420c2016-03-09 14:32:57 +05309561 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309562 __func__, cmd->pattern_id, cmd->vdev_id);
9563
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309564 wmi_mtrace(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309565 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9566 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309567 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309568 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309569 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309570 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309571 }
Govind Singhb53420c2016-03-09 14:32:57 +05309572 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309573}
9574
9575/**
9576 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9577 * @wmi_handle: wmi handle
9578 * @vdev_id: vdev id
9579 * @pattern_id: pattern id
9580 *
9581 * Retrun: CDF status
9582 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309583static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309584 uint8_t vdev_id,
9585 uint8_t pattern_id)
9586{
9587 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9588 wmi_buf_t wmi_buf;
9589 uint32_t len =
9590 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9591
9592 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9593 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309594 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9595 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309596 }
9597
9598 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9599 wmi_buf_data(wmi_buf);
9600 WMITLV_SET_HDR(&cmd->tlv_header,
9601 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9602 WMITLV_GET_STRUCT_TLVLEN
9603 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9604
9605 /* Pass the pattern id to delete for the corresponding vdev id */
9606 cmd->vdev_id = vdev_id;
9607 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309608 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309609 __func__, cmd->pattern_id, cmd->vdev_id);
9610
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309611 wmi_mtrace(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309612 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9613 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309614 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309615 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309616 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309617 }
Govind Singhb53420c2016-03-09 14:32:57 +05309618 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309619}
9620
9621/**
9622 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9623 * @wmi_handle: wmi handle
9624 * @preq: stats ext params
9625 *
9626 * Return: CDF status
9627 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309628static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309629 struct stats_ext_params *preq)
9630{
Govind Singh67922e82016-04-01 16:48:57 +05309631 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309632 wmi_req_stats_ext_cmd_fixed_param *cmd;
9633 wmi_buf_t buf;
Pragaspathi Thilagaraj5920a4b2018-05-16 18:51:32 +05309634 size_t len;
Govind Singh20c5dac2016-03-07 15:33:31 +05309635 uint8_t *buf_ptr;
9636
9637 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9638
9639 buf = wmi_buf_alloc(wmi_handle, len);
9640 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309641 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309642 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309643 }
9644
9645 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9646 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9647
9648 WMITLV_SET_HDR(&cmd->tlv_header,
9649 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9650 WMITLV_GET_STRUCT_TLVLEN
9651 (wmi_req_stats_ext_cmd_fixed_param));
9652 cmd->vdev_id = preq->vdev_id;
9653 cmd->data_len = preq->request_data_len;
9654
Govind Singhb53420c2016-03-09 14:32:57 +05309655 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309656 __func__, preq->request_data_len, preq->vdev_id);
9657
9658 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9659 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9660
9661 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309662 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309663
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309664 wmi_mtrace(WMI_REQUEST_STATS_EXT_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309665 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9666 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309667 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309668 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309669 ret);
9670 wmi_buf_free(buf);
9671 }
9672
9673 return ret;
9674}
9675
9676/**
9677 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9678 * @wmi_handle: wmi handle
9679 * @params: ext wow params
9680 *
9681 * Return:0 for success or error code
9682 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309683static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309684 struct ext_wow_params *params)
9685{
9686 wmi_extwow_enable_cmd_fixed_param *cmd;
9687 wmi_buf_t buf;
9688 int32_t len;
9689 int ret;
9690
9691 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9692 buf = wmi_buf_alloc(wmi_handle, len);
9693 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309694 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9695 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309696 }
9697
9698 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9699
9700 WMITLV_SET_HDR(&cmd->tlv_header,
9701 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9702 WMITLV_GET_STRUCT_TLVLEN
9703 (wmi_extwow_enable_cmd_fixed_param));
9704
9705 cmd->vdev_id = params->vdev_id;
9706 cmd->type = params->type;
9707 cmd->wakeup_pin_num = params->wakeup_pin_num;
9708
Govind Singhb53420c2016-03-09 14:32:57 +05309709 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309710 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9711
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309712 wmi_mtrace(WMI_EXTWOW_ENABLE_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309713 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9714 WMI_EXTWOW_ENABLE_CMDID);
9715 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309716 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309717 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309718 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309719 }
9720
Govind Singhb53420c2016-03-09 14:32:57 +05309721 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309722
9723}
9724
9725/**
9726 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9727 * @wmi_handle: wmi handle
9728 * @app_type1_params: app type1 params
9729 *
9730 * Return: CDF status
9731 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309732static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309733 struct app_type1_params *app_type1_params)
9734{
9735 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9736 wmi_buf_t buf;
9737 int32_t len;
9738 int ret;
9739
9740 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9741 buf = wmi_buf_alloc(wmi_handle, len);
9742 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309743 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9744 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309745 }
9746
9747 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9748 wmi_buf_data(buf);
9749
9750 WMITLV_SET_HDR(&cmd->tlv_header,
9751 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9752 WMITLV_GET_STRUCT_TLVLEN
9753 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9754
9755 cmd->vdev_id = app_type1_params->vdev_id;
9756 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9757 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309758 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309759 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309760 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309761 cmd->passwd_len = app_type1_params->pass_length;
9762
Govind Singhb53420c2016-03-09 14:32:57 +05309763 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309764 "identification_id %.8s id_length %u "
9765 "password %.16s pass_length %u",
9766 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9767 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9768
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309769 wmi_mtrace(WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309770 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9771 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9772 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309773 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309774 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309775 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309776 }
9777
Govind Singhb53420c2016-03-09 14:32:57 +05309778 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309779}
9780
9781/**
9782 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9783 * @wmi_handle: wmi handle
9784 * @appType2Params: app type2 params
9785 *
9786 * Return: CDF status
9787 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309788static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309789 struct app_type2_params *appType2Params)
9790{
9791 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9792 wmi_buf_t buf;
9793 int32_t len;
9794 int ret;
9795
9796 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9797 buf = wmi_buf_alloc(wmi_handle, len);
9798 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309799 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9800 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309801 }
9802
9803 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9804 wmi_buf_data(buf);
9805
9806 WMITLV_SET_HDR(&cmd->tlv_header,
9807 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9808 WMITLV_GET_STRUCT_TLVLEN
9809 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9810
9811 cmd->vdev_id = appType2Params->vdev_id;
9812
Govind Singhb53420c2016-03-09 14:32:57 +05309813 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309814 cmd->rc4_key_len = appType2Params->rc4_key_len;
9815
9816 cmd->ip_id = appType2Params->ip_id;
9817 cmd->ip_device_ip = appType2Params->ip_device_ip;
9818 cmd->ip_server_ip = appType2Params->ip_server_ip;
9819
9820 cmd->tcp_src_port = appType2Params->tcp_src_port;
9821 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9822 cmd->tcp_seq = appType2Params->tcp_seq;
9823 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9824
9825 cmd->keepalive_init = appType2Params->keepalive_init;
9826 cmd->keepalive_min = appType2Params->keepalive_min;
9827 cmd->keepalive_max = appType2Params->keepalive_max;
9828 cmd->keepalive_inc = appType2Params->keepalive_inc;
9829
9830 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9831 &cmd->gateway_mac);
9832 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9833 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9834
Govind Singhb53420c2016-03-09 14:32:57 +05309835 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309836 "rc4_key %.16s rc4_key_len %u "
9837 "ip_id %x ip_device_ip %x ip_server_ip %x "
9838 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9839 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9840 "keepalive_max %u keepalive_inc %u "
9841 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9842 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9843 cmd->rc4_key, cmd->rc4_key_len,
9844 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9845 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9846 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9847 cmd->keepalive_max, cmd->keepalive_inc,
9848 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9849
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309850 wmi_mtrace(WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309851 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9852 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9853 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309854 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309855 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309856 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309857 }
9858
Govind Singhb53420c2016-03-09 14:32:57 +05309859 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309860
9861}
9862
9863/**
9864 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9865 * @wmi_handle: wmi handle
9866 * @timer_val: auto shutdown timer value
9867 *
9868 * Return: CDF status
9869 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309870static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309871 uint32_t timer_val)
9872{
Govind Singh67922e82016-04-01 16:48:57 +05309873 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309874 wmi_buf_t buf = NULL;
9875 uint8_t *buf_ptr;
9876 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9877 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9878
Govind Singhb53420c2016-03-09 14:32:57 +05309879 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309880 __func__, timer_val);
9881
9882 buf = wmi_buf_alloc(wmi_handle, len);
9883 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309884 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9885 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309886 }
9887
9888 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9889 wmi_auto_sh_cmd =
9890 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9891 wmi_auto_sh_cmd->timer_value = timer_val;
9892
9893 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9894 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9895 WMITLV_GET_STRUCT_TLVLEN
9896 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9897
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309898 wmi_mtrace(WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309899 status = wmi_unified_cmd_send(wmi_handle, buf,
9900 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309901 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309902 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309903 __func__, status);
9904 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309905 }
9906
Govind Singh67922e82016-04-01 16:48:57 +05309907 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309908}
9909
9910/**
9911 * send_nan_req_cmd_tlv() - to send nan request to target
9912 * @wmi_handle: wmi handle
9913 * @nan_req: request data which will be non-null
9914 *
9915 * Return: CDF status
9916 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309917static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309918 struct nan_req_params *nan_req)
9919{
Govind Singh67922e82016-04-01 16:48:57 +05309920 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309921 wmi_nan_cmd_param *cmd;
9922 wmi_buf_t buf;
9923 uint16_t len = sizeof(*cmd);
9924 uint16_t nan_data_len, nan_data_len_aligned;
9925 uint8_t *buf_ptr;
9926
9927 /*
9928 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9929 * +------------+----------+-----------------------+--------------+
9930 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9931 * +------------+----------+-----------------------+--------------+
9932 */
9933 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309934 WMI_LOGE("%s:nan req is not valid", __func__);
9935 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309936 }
9937 nan_data_len = nan_req->request_data_len;
9938 nan_data_len_aligned = roundup(nan_req->request_data_len,
9939 sizeof(uint32_t));
Naveen Rawatd30dad62018-05-08 09:40:10 -07009940 if (nan_data_len_aligned < nan_req->request_data_len) {
9941 WMI_LOGE("%s: integer overflow while rounding up data_len",
9942 __func__);
9943 return QDF_STATUS_E_FAILURE;
9944 }
9945
9946 if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
9947 WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen",
9948 __func__);
9949 return QDF_STATUS_E_FAILURE;
9950 }
9951
Govind Singh20c5dac2016-03-07 15:33:31 +05309952 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9953 buf = wmi_buf_alloc(wmi_handle, len);
9954 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309955 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9956 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309957 }
9958 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9959 cmd = (wmi_nan_cmd_param *) buf_ptr;
9960 WMITLV_SET_HDR(&cmd->tlv_header,
9961 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9962 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9963 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309964 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309965 __func__, nan_req->request_data_len);
9966 buf_ptr += sizeof(wmi_nan_cmd_param);
9967 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9968 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309969 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309970
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309971 wmi_mtrace(WMI_NAN_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05309972 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9973 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309974 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309975 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309976 __func__, ret);
9977 wmi_buf_free(buf);
9978 }
9979
9980 return ret;
9981}
9982
9983/**
9984 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9985 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -07009986 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +05309987 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309988 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309989 */
Jeff Johnsona87370f2017-10-04 19:19:20 -07009990static QDF_STATUS
9991send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
9992 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +05309993{
9994 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9995 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309996 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309997
9998 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010000 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +053010001 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010002 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010003 }
10004
10005 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010006
10007 WMITLV_SET_HDR(&cmd->tlv_header,
10008 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
10009 WMITLV_GET_STRUCT_TLVLEN
10010 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -070010011 cmd->vdev_id = params->vdev_id;
10012 cmd->enable = params->dhcp_offload_enabled;
10013 cmd->num_client = params->dhcp_client_num;
10014 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +053010015 cmd->start_lsb = 0;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010016 wmi_mtrace(WMI_SET_DHCP_SERVER_OFFLOAD_CMDID, cmd->vdev_id, 0);
Govind Singh67922e82016-04-01 16:48:57 +053010017 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +053010018 sizeof(*cmd),
10019 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010020 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010021 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +053010022 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010023 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010024 }
Govind Singhb53420c2016-03-09 14:32:57 +053010025 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -070010026 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +053010027
10028 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010029}
10030
10031/**
10032 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
10033 * @wmi_handle: wmi handle
10034 * @flashing: flashing request
10035 *
10036 * Return: CDF status
10037 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010038static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010039 struct flashing_req_params *flashing)
10040{
10041 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +053010042 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010043 wmi_buf_t buf;
10044 uint8_t *buf_ptr;
10045 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
10046
10047 buf = wmi_buf_alloc(wmi_handle, len);
10048 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010049 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +053010050 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010051 }
10052 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10053 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
10054 WMITLV_SET_HDR(&cmd->tlv_header,
10055 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
10056 WMITLV_GET_STRUCT_TLVLEN
10057 (wmi_set_led_flashing_cmd_fixed_param));
10058 cmd->pattern_id = flashing->pattern_id;
10059 cmd->led_x0 = flashing->led_x0;
10060 cmd->led_x1 = flashing->led_x1;
10061
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010062 wmi_mtrace(WMI_PDEV_SET_LED_FLASHING_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +053010063 status = wmi_unified_cmd_send(wmi_handle, buf, len,
10064 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010065 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010066 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +053010067 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010068 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010069 }
Govind Singh67922e82016-04-01 16:48:57 +053010070
10071 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010072}
10073
10074/**
10075 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
10076 * @wmi_handle: wmi handle
10077 * @ch_avoid_update_req: channel avoid update params
10078 *
10079 * Return: CDF status
10080 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010081static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +053010082{
Govind Singh67922e82016-04-01 16:48:57 +053010083 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010084 wmi_buf_t buf = NULL;
10085 uint8_t *buf_ptr;
10086 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
10087 int len = sizeof(wmi_chan_avoid_update_cmd_param);
10088
10089
10090 buf = wmi_buf_alloc(wmi_handle, len);
10091 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010092 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10093 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010094 }
10095
10096 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10097 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
10098 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
10099 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
10100 WMITLV_GET_STRUCT_TLVLEN
10101 (wmi_chan_avoid_update_cmd_param));
10102
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010103 wmi_mtrace(WMI_CHAN_AVOID_UPDATE_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +053010104 status = wmi_unified_cmd_send(wmi_handle, buf,
10105 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010106 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010107 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +053010108 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
10109 " returned Error %d", status);
10110 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010111 }
10112
Govind Singh67922e82016-04-01 16:48:57 +053010113 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010114}
10115
10116/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010117 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
10118 * @wmi_handle: wmi handle
10119 * @param: pointer to pdev regdomain params
10120 *
10121 * Return: 0 for success or error code
10122 */
10123static QDF_STATUS
10124send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
10125 struct pdev_set_regdomain_params *param)
10126{
10127 wmi_buf_t buf;
10128 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10129 int32_t len = sizeof(*cmd);
10130
10131
10132 buf = wmi_buf_alloc(wmi_handle, len);
10133 if (!buf) {
10134 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10135 return QDF_STATUS_E_NOMEM;
10136 }
10137 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10138 WMITLV_SET_HDR(&cmd->tlv_header,
10139 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10140 WMITLV_GET_STRUCT_TLVLEN
10141 (wmi_pdev_set_regdomain_cmd_fixed_param));
10142
10143 cmd->reg_domain = param->currentRDinuse;
10144 cmd->reg_domain_2G = param->currentRD2G;
10145 cmd->reg_domain_5G = param->currentRD5G;
10146 cmd->conformance_test_limit_2G = param->ctl_2G;
10147 cmd->conformance_test_limit_5G = param->ctl_5G;
10148 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010149 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10150 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010151
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010152 wmi_mtrace(WMI_PDEV_SET_REGDOMAIN_CMDID, NO_SESSION, 0);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010153 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10154 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
10155 WMI_LOGE("%s: Failed to send pdev set regdomain command",
10156 __func__);
10157 wmi_buf_free(buf);
10158 return QDF_STATUS_E_FAILURE;
10159 }
10160
10161 return QDF_STATUS_SUCCESS;
10162}
10163
10164/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010165 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
10166 * @wmi_handle: wmi handle
10167 * @reg_dmn: reg domain
10168 * @regdmn2G: 2G reg domain
10169 * @regdmn5G: 5G reg domain
10170 * @ctl2G: 2G test limit
10171 * @ctl5G: 5G test limit
10172 *
10173 * Return: none
10174 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010175static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010176 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +053010177 uint16_t regdmn5G, uint8_t ctl2G,
10178 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +053010179{
10180 wmi_buf_t buf;
10181 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10182 int32_t len = sizeof(*cmd);
10183
10184
10185 buf = wmi_buf_alloc(wmi_handle, len);
10186 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010187 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10188 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010189 }
10190 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10191 WMITLV_SET_HDR(&cmd->tlv_header,
10192 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10193 WMITLV_GET_STRUCT_TLVLEN
10194 (wmi_pdev_set_regdomain_cmd_fixed_param));
10195 cmd->reg_domain = reg_dmn;
10196 cmd->reg_domain_2G = regdmn2G;
10197 cmd->reg_domain_5G = regdmn5G;
10198 cmd->conformance_test_limit_2G = ctl2G;
10199 cmd->conformance_test_limit_5G = ctl5G;
10200
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010201 wmi_mtrace(WMI_PDEV_SET_REGDOMAIN_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +053010202 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10203 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010204 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010205 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010206 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010207 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010208 }
10209
Govind Singhb53420c2016-03-09 14:32:57 +053010210 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010211}
10212
10213
10214/**
10215 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10216 * @wmi_handle: wmi handle
10217 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10218 *
10219 * This function sets tdls off channel mode
10220 *
10221 * Return: 0 on success; Negative errno otherwise
10222 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010223static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010224 struct tdls_channel_switch_params *chan_switch_params)
10225{
10226 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10227 wmi_buf_t wmi_buf;
10228 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10229
10230 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10231 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010232 WMI_LOGE(FL("wmi_buf_alloc failed"));
10233 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010234 }
10235 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10236 wmi_buf_data(wmi_buf);
10237 WMITLV_SET_HDR(&cmd->tlv_header,
10238 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10239 WMITLV_GET_STRUCT_TLVLEN(
10240 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10241
10242 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10243 &cmd->peer_macaddr);
10244 cmd->vdev_id = chan_switch_params->vdev_id;
10245 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10246 cmd->is_peer_responder = chan_switch_params->is_responder;
10247 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10248 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10249 cmd->offchan_oper_class = chan_switch_params->oper_class;
10250
Govind Singhb53420c2016-03-09 14:32:57 +053010251 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010252 cmd->peer_macaddr.mac_addr31to0,
10253 cmd->peer_macaddr.mac_addr47to32);
10254
Govind Singhb53420c2016-03-09 14:32:57 +053010255 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010256 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10257 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10258 ),
10259 cmd->vdev_id,
10260 cmd->offchan_mode,
10261 cmd->offchan_num,
10262 cmd->offchan_bw_bitmap,
10263 cmd->is_peer_responder,
10264 cmd->offchan_oper_class);
10265
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010266 wmi_mtrace(WMI_TDLS_SET_OFFCHAN_MODE_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +053010267 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10268 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010269 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010270 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010271 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010272 }
10273
10274
Govind Singhb53420c2016-03-09 14:32:57 +053010275 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010276}
10277
10278/**
10279 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10280 * @wmi_handle: wmi handle
10281 * @pwmaTdlsparams: TDLS params
10282 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -070010283 * Return: 0 for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010284 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010285static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010286 void *tdls_param, uint8_t tdls_state)
10287{
10288 wmi_tdls_set_state_cmd_fixed_param *cmd;
10289 wmi_buf_t wmi_buf;
10290
10291 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10292 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10293
10294 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10295 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010296 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10297 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010298 }
10299 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10300 WMITLV_SET_HDR(&cmd->tlv_header,
10301 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10302 WMITLV_GET_STRUCT_TLVLEN
10303 (wmi_tdls_set_state_cmd_fixed_param));
10304 cmd->vdev_id = wmi_tdls->vdev_id;
10305 cmd->state = tdls_state;
10306 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10307 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10308 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10309 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10310 cmd->rssi_delta = wmi_tdls->rssi_delta;
10311 cmd->tdls_options = wmi_tdls->tdls_options;
10312 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10313 cmd->tdls_peer_traffic_response_timeout_ms =
10314 wmi_tdls->peer_traffic_response_timeout;
10315 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10316 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10317 cmd->tdls_puapsd_rx_frame_threshold =
10318 wmi_tdls->puapsd_rx_frame_threshold;
10319 cmd->teardown_notification_ms =
10320 wmi_tdls->teardown_notification_ms;
10321 cmd->tdls_peer_kickout_threshold =
10322 wmi_tdls->tdls_peer_kickout_threshold;
10323
Govind Singhb53420c2016-03-09 14:32:57 +053010324 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010325 "notification_interval_ms: %d, "
10326 "tx_discovery_threshold: %d, "
10327 "tx_teardown_threshold: %d, "
10328 "rssi_teardown_threshold: %d, "
10329 "rssi_delta: %d, "
10330 "tdls_options: 0x%x, "
10331 "tdls_peer_traffic_ind_window: %d, "
10332 "tdls_peer_traffic_response_timeout: %d, "
10333 "tdls_puapsd_mask: 0x%x, "
10334 "tdls_puapsd_inactivity_time: %d, "
10335 "tdls_puapsd_rx_frame_threshold: %d, "
10336 "teardown_notification_ms: %d, "
10337 "tdls_peer_kickout_threshold: %d",
10338 __func__, tdls_state, cmd->state,
10339 cmd->notification_interval_ms,
10340 cmd->tx_discovery_threshold,
10341 cmd->tx_teardown_threshold,
10342 cmd->rssi_teardown_threshold,
10343 cmd->rssi_delta,
10344 cmd->tdls_options,
10345 cmd->tdls_peer_traffic_ind_window,
10346 cmd->tdls_peer_traffic_response_timeout_ms,
10347 cmd->tdls_puapsd_mask,
10348 cmd->tdls_puapsd_inactivity_time_ms,
10349 cmd->tdls_puapsd_rx_frame_threshold,
10350 cmd->teardown_notification_ms,
10351 cmd->tdls_peer_kickout_threshold);
10352
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010353 wmi_mtrace(WMI_TDLS_SET_STATE_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +053010354 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10355 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010356 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010357 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010358 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010359 }
Govind Singhb53420c2016-03-09 14:32:57 +053010360 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010361
Govind Singhb53420c2016-03-09 14:32:57 +053010362 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010363}
10364
10365/**
10366 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10367 * @wmi_handle: wmi handle
10368 * @peerStateParams: TDLS peer state params
10369 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010370 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010371 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010372static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010373 struct tdls_peer_state_params *peerStateParams,
10374 uint32_t *ch_mhz)
10375{
10376 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10377 wmi_tdls_peer_capabilities *peer_cap;
10378 wmi_channel *chan_info;
10379 wmi_buf_t wmi_buf;
10380 uint8_t *buf_ptr;
10381 uint32_t i;
10382 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10383 sizeof(wmi_tdls_peer_capabilities);
10384
10385
10386 len += WMI_TLV_HDR_SIZE +
10387 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10388
10389 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10390 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010391 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10392 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010393 }
10394
10395 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10396 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10397 WMITLV_SET_HDR(&cmd->tlv_header,
10398 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10399 WMITLV_GET_STRUCT_TLVLEN
10400 (wmi_tdls_peer_update_cmd_fixed_param));
10401
10402 cmd->vdev_id = peerStateParams->vdevId;
10403 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10404 &cmd->peer_macaddr);
10405
10406
10407 cmd->peer_state = peerStateParams->peerState;
10408
Govind Singhb53420c2016-03-09 14:32:57 +053010409 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010410 "peer_macaddr.mac_addr31to0: 0x%x, "
10411 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10412 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10413 cmd->peer_macaddr.mac_addr31to0,
10414 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10415
10416 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10417 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10418 WMITLV_SET_HDR(&peer_cap->tlv_header,
10419 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10420 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10421
10422 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10423 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10424 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10425 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10426 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10427 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10428 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10429 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10430
10431 /* Ack and More Data Ack are sent as 0, so no need to set
10432 * but fill SP
10433 */
10434 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10435 peerStateParams->peerCap.peerMaxSp);
10436
10437 peer_cap->buff_sta_support =
10438 peerStateParams->peerCap.peerBuffStaSupport;
10439 peer_cap->off_chan_support =
10440 peerStateParams->peerCap.peerOffChanSupport;
10441 peer_cap->peer_curr_operclass =
10442 peerStateParams->peerCap.peerCurrOperClass;
10443 /* self curr operclass is not being used and so pass op class for
10444 * preferred off chan in it.
10445 */
10446 peer_cap->self_curr_operclass =
10447 peerStateParams->peerCap.opClassForPrefOffChan;
10448 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10449 peer_cap->peer_operclass_len =
10450 peerStateParams->peerCap.peerOperClassLen;
10451
Govind Singhb53420c2016-03-09 14:32:57 +053010452 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010453 __func__, peer_cap->peer_operclass_len);
10454 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10455 peer_cap->peer_operclass[i] =
10456 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010457 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010458 __func__, i, peer_cap->peer_operclass[i]);
10459 }
10460
10461 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10462 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10463 peer_cap->pref_offchan_bw =
10464 peerStateParams->peerCap.prefOffChanBandwidth;
10465
Govind Singhb53420c2016-03-09 14:32:57 +053010466 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010467 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10468 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10469 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10470 " %d, pref_offchan_bw: %d",
10471 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10472 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10473 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10474 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10475 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10476
10477 /* next fill variable size array of peer chan info */
10478 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10479 WMITLV_SET_HDR(buf_ptr,
10480 WMITLV_TAG_ARRAY_STRUC,
10481 sizeof(wmi_channel) *
10482 peerStateParams->peerCap.peerChanLen);
10483 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10484
10485 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10486 WMITLV_SET_HDR(&chan_info->tlv_header,
10487 WMITLV_TAG_STRUC_wmi_channel,
10488 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10489 chan_info->mhz = ch_mhz[i];
10490 chan_info->band_center_freq1 = chan_info->mhz;
10491 chan_info->band_center_freq2 = 0;
10492
Govind Singhb53420c2016-03-09 14:32:57 +053010493 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010494
10495 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10496 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010497 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010498 peerStateParams->peerCap.peerChan[i].chanId,
10499 peerStateParams->peerCap.peerChan[i].dfsSet);
10500 }
10501
10502 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10503 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10504 else
10505 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10506
10507 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10508 peerStateParams->peerCap.
10509 peerChan[i].pwr);
10510
10511 WMI_SET_CHANNEL_REG_POWER(chan_info,
10512 peerStateParams->peerCap.peerChan[i].
10513 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010514 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010515 peerStateParams->peerCap.peerChan[i].pwr);
10516
10517 chan_info++;
10518 }
10519
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010520 wmi_mtrace(WMI_TDLS_PEER_UPDATE_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +053010521 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10522 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010523 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010524 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010525 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010526 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010527 }
10528
10529
Govind Singhb53420c2016-03-09 14:32:57 +053010530 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010531}
10532
10533/*
Govind Singh20c5dac2016-03-07 15:33:31 +053010534 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10535 * @wmi_handle: Pointer to WMi handle
10536 * @ie_data: Pointer for ie data
10537 *
10538 * This function sends IE information to firmware
10539 *
Govind Singhb53420c2016-03-09 14:32:57 +053010540 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010541 *
10542 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010543static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010544 struct vdev_ie_info_param *ie_info)
10545{
10546 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10547 wmi_buf_t buf;
10548 uint8_t *buf_ptr;
10549 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010550 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010551
10552
10553 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10554 /* Allocate memory for the WMI command */
10555 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10556
10557 buf = wmi_buf_alloc(wmi_handle, len);
10558 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010559 WMI_LOGE(FL("wmi_buf_alloc failed"));
10560 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010561 }
10562
10563 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010564 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010565
10566 /* Populate the WMI command */
10567 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10568
10569 WMITLV_SET_HDR(&cmd->tlv_header,
10570 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10571 WMITLV_GET_STRUCT_TLVLEN(
10572 wmi_vdev_set_ie_cmd_fixed_param));
10573 cmd->vdev_id = ie_info->vdev_id;
10574 cmd->ie_id = ie_info->ie_id;
10575 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010576 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010577
Govind Singhb53420c2016-03-09 14:32:57 +053010578 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010579 ie_info->length, ie_info->vdev_id);
10580
10581 buf_ptr += sizeof(*cmd);
10582 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10583 buf_ptr += WMI_TLV_HDR_SIZE;
10584
Govind Singhb53420c2016-03-09 14:32:57 +053010585 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010586
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010587 wmi_mtrace(WMI_VDEV_SET_IE_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +053010588 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10589 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010590 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010591 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010592 wmi_buf_free(buf);
10593 }
10594
10595 return ret;
10596}
10597
Sathish Kumar497bef42017-03-01 14:02:36 +053010598/**
10599 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10600 *
10601 * @param wmi_handle : handle to WMI.
10602 * @param param : pointer to antenna param
10603 *
10604 * This function sends smart antenna enable command to FW
10605 *
10606 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10607 */
10608static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10609 struct smart_ant_enable_params *param)
10610{
10611 /* Send WMI COMMAND to Enable */
10612 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10613 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10614 wmi_buf_t buf;
10615 uint8_t *buf_ptr;
10616 int len = 0;
10617 QDF_STATUS ret;
10618 int loop = 0;
10619
10620 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10621 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10622 buf = wmi_buf_alloc(wmi_handle, len);
10623
10624 if (!buf) {
10625 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10626 return QDF_STATUS_E_NOMEM;
10627 }
10628
10629 buf_ptr = wmi_buf_data(buf);
10630 qdf_mem_zero(buf_ptr, len);
10631 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10632
10633 WMITLV_SET_HDR(&cmd->tlv_header,
10634 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10635 WMITLV_GET_STRUCT_TLVLEN(
10636 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10637
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010638 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10639 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010640 cmd->enable = param->enable;
10641 cmd->mode = param->mode;
10642 cmd->rx_antenna = param->rx_antenna;
10643 cmd->tx_default_antenna = param->rx_antenna;
10644
10645 /* TLV indicating array of structures to follow */
10646 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10647 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10648 WMI_HAL_MAX_SANTENNA *
10649 sizeof(wmi_pdev_smart_ant_gpio_handle));
10650
10651 buf_ptr += WMI_TLV_HDR_SIZE;
10652 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10653
10654 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10655 WMITLV_SET_HDR(&gpio_param->tlv_header,
10656 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10657 WMITLV_GET_STRUCT_TLVLEN(
10658 wmi_pdev_smart_ant_gpio_handle));
10659 if (param->mode == SMART_ANT_MODE_SERIAL) {
10660 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10661 gpio_param->gpio_pin = param->gpio_pin[loop];
10662 gpio_param->gpio_func = param->gpio_func[loop];
10663 } else {
10664 gpio_param->gpio_pin = 0;
10665 gpio_param->gpio_func = 0;
10666 }
10667 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10668 gpio_param->gpio_pin = param->gpio_pin[loop];
10669 gpio_param->gpio_func = param->gpio_func[loop];
10670 }
10671 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010672 gpio_param->pdev_id =
10673 wmi_handle->ops->convert_pdev_id_host_to_target(
10674 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010675 gpio_param++;
10676 }
10677
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010678 wmi_mtrace(WMI_PDEV_SMART_ANT_ENABLE_CMDID, NO_SESSION, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +053010679 ret = wmi_unified_cmd_send(wmi_handle,
10680 buf,
10681 len,
10682 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10683
10684 if (ret != 0) {
10685 WMI_LOGE(" %s :WMI Failed\n", __func__);
10686 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10687 cmd->enable,
10688 cmd->mode,
10689 cmd->rx_antenna,
10690 param->gpio_pin[0], param->gpio_pin[1],
10691 param->gpio_pin[2], param->gpio_pin[3],
10692 param->gpio_func[0], param->gpio_func[1],
10693 param->gpio_func[2], param->gpio_func[3],
10694 ret);
10695 wmi_buf_free(buf);
10696 }
10697
10698 return ret;
10699}
10700
10701/**
10702 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10703 *
10704 * @param wmi_handle : handle to WMI.
10705 * @param param : pointer to rx antenna param
10706 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10707 */
10708static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10709 struct smart_ant_rx_ant_params *param)
10710{
10711 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10712 wmi_buf_t buf;
10713 uint8_t *buf_ptr;
10714 uint32_t len;
10715 QDF_STATUS ret;
10716
10717 len = sizeof(*cmd);
10718 buf = wmi_buf_alloc(wmi_handle, len);
10719 WMI_LOGD("%s:\n", __func__);
10720 if (!buf) {
10721 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10722 return QDF_STATUS_E_NOMEM;
10723 }
10724
10725 buf_ptr = wmi_buf_data(buf);
10726 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10727 WMITLV_SET_HDR(&cmd->tlv_header,
10728 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10729 WMITLV_GET_STRUCT_TLVLEN(
10730 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10731 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010732 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10733 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010734
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010735 wmi_mtrace(WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID, NO_SESSION, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +053010736 ret = wmi_unified_cmd_send(wmi_handle,
10737 buf,
10738 len,
10739 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10740
10741 if (ret != 0) {
10742 WMI_LOGE(" %s :WMI Failed\n", __func__);
10743 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10744 __func__,
10745 cmd->rx_antenna,
10746 ret);
10747 wmi_buf_free(buf);
10748 }
10749
10750 return ret;
10751}
10752
10753/**
10754 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10755 * @wmi_handle: wmi handle
10756 * @param: pointer to hold ctl table param
10757 *
10758 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10759 */
10760static QDF_STATUS
10761send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10762 struct ctl_table_params *param)
10763{
10764 uint16_t len, ctl_tlv_len;
10765 uint8_t *buf_ptr;
10766 wmi_buf_t buf;
10767 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10768 uint32_t *ctl_array;
10769
10770 if (!param->ctl_array)
10771 return QDF_STATUS_E_FAILURE;
10772
Sathish Kumar497bef42017-03-01 14:02:36 +053010773 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053010774 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053010775 len = sizeof(*cmd) + ctl_tlv_len;
10776
10777 buf = wmi_buf_alloc(wmi_handle, len);
10778 if (!buf) {
10779 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10780 return QDF_STATUS_E_FAILURE;
10781 }
10782
10783 buf_ptr = wmi_buf_data(buf);
10784 qdf_mem_zero(buf_ptr, len);
10785
10786 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10787
10788 WMITLV_SET_HDR(&cmd->tlv_header,
10789 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10790 WMITLV_GET_STRUCT_TLVLEN(
10791 wmi_pdev_set_ctl_table_cmd_fixed_param));
10792 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010793 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10794 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010795
10796 buf_ptr += sizeof(*cmd);
10797 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10798 (cmd->ctl_len));
10799 buf_ptr += WMI_TLV_HDR_SIZE;
10800 ctl_array = (uint32_t *)buf_ptr;
10801
10802 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10803 sizeof(param->ctl_band));
10804 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10805 param->ctl_cmd_len -
10806 sizeof(param->ctl_band));
10807
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010808 wmi_mtrace(WMI_PDEV_SET_CTL_TABLE_CMDID, NO_SESSION, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +053010809 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10810 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10811 WMI_LOGE("%s:Failed to send command\n", __func__);
10812 wmi_buf_free(buf);
10813 return QDF_STATUS_E_FAILURE;
10814 }
10815
10816 return QDF_STATUS_SUCCESS;
10817}
10818
10819/**
10820 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10821 * @wmi_handle: wmi handle
10822 * @param: pointer to hold mimogain table param
10823 *
10824 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10825 */
10826static QDF_STATUS
10827send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10828 struct mimogain_table_params *param)
10829{
10830 uint16_t len, table_tlv_len;
10831 wmi_buf_t buf;
10832 uint8_t *buf_ptr;
10833 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10834 uint32_t *gain_table;
10835
10836 if (!param->array_gain)
10837 return QDF_STATUS_E_FAILURE;
10838
10839 /* len must be multiple of a single array gain table */
10840 if (param->tbl_len %
10841 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10842 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10843 WMI_LOGE("Array gain table len not correct\n");
10844 return QDF_STATUS_E_FAILURE;
10845 }
10846
10847 table_tlv_len = WMI_TLV_HDR_SIZE +
10848 roundup(param->tbl_len, sizeof(uint32_t));
10849 len = sizeof(*cmd) + table_tlv_len;
10850
10851 buf = wmi_buf_alloc(wmi_handle, len);
10852 if (!buf) {
10853 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10854 return QDF_STATUS_E_FAILURE;
10855 }
10856
10857 buf_ptr = wmi_buf_data(buf);
10858 qdf_mem_zero(buf_ptr, len);
10859
10860 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10861
10862 WMITLV_SET_HDR(&cmd->tlv_header,
10863 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10864 WMITLV_GET_STRUCT_TLVLEN(
10865 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10866
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010867 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10868 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010869 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10870 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10871 param->multichain_gain_bypass);
10872
10873 buf_ptr += sizeof(*cmd);
10874 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10875 (param->tbl_len));
10876 buf_ptr += WMI_TLV_HDR_SIZE;
10877 gain_table = (uint32_t *)buf_ptr;
10878
10879 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10880 param->array_gain,
10881 param->tbl_len);
10882
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010883 wmi_mtrace(WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID, NO_SESSION, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +053010884 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10885 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10886 return QDF_STATUS_E_FAILURE;
10887 }
10888
10889 return QDF_STATUS_SUCCESS;
10890}
10891
10892/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010893 * enum packet_power_tlv_flags: target defined
10894 * packet power rate flags for TLV
10895 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
10896 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
10897 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
10898 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
10899 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
10900 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
10901 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
10902 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
10903 * @WMI_TLV_FLAG_STBC: STBC is set
10904 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
10905 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
10906 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
10907 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
10908 * @WMI_TLV_FLAG_RTSENA: RTS enabled
10909 * @WMI_TLV_FLAG_CTSENA: CTS enabled
10910 * @WMI_TLV_FLAG_LDPC: LDPC is set
10911 * @WMI_TLV_FLAG_SGI: Short gaurd interval
10912 * @WMI_TLV_FLAG_SU: SU Data
10913 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
10914 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
10915 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
10916 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
10917 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
10918 *
10919 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
10920 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
10921 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
10922 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
10923 */
10924enum packet_power_tlv_flags {
10925 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
10926 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
10927 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
10928 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
10929 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
10930 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
10931 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
10932 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
10933 WMI_TLV_FLAG_STBC = 0x00000100,
10934 WMI_TLV_FLAG_40MHZ = 0x00000200,
10935 WMI_TLV_FLAG_80MHZ = 0x00000300,
10936 WMI_TLV_FLAG_160MHZ = 0x00000400,
10937 WMI_TLV_FLAG_TXBF = 0x00000800,
10938 WMI_TLV_FLAG_RTSENA = 0x00001000,
10939 WMI_TLV_FLAG_CTSENA = 0x00002000,
10940 WMI_TLV_FLAG_LDPC = 0x00004000,
10941 WMI_TLV_FLAG_SGI = 0x00008000,
10942 WMI_TLV_FLAG_SU = 0x00100000,
10943 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
10944 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
10945 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
10946 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
10947 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
10948
10949 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
10950 WMI_TLV_FLAG_BW_MASK = 0x3,
10951 WMI_TLV_FLAG_BW_SHIFT = 9,
10952 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
10953 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
10954};
10955
10956/**
10957 * convert_to_power_info_rate_flags() - convert packet_power_info_params
10958 * to FW understandable format
10959 * @param: pointer to hold packet power info param
10960 *
10961 * @return FW understandable 32 bit rate flags
10962 */
10963static uint32_t
10964convert_to_power_info_rate_flags(struct packet_power_info_params *param)
10965{
10966 uint32_t rateflags = 0;
10967
10968 if (param->chainmask)
10969 rateflags |=
10970 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
10971 if (param->chan_width)
10972 rateflags |=
10973 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
10974 << WMI_TLV_FLAG_BW_SHIFT);
10975 if (param->su_mu_ofdma)
10976 rateflags |=
10977 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
10978 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
10979 if (param->rate_flags & WMI_HOST_FLAG_STBC)
10980 rateflags |= WMI_TLV_FLAG_STBC;
10981 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
10982 rateflags |= WMI_TLV_FLAG_LDPC;
10983 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
10984 rateflags |= WMI_TLV_FLAG_TXBF;
10985 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
10986 rateflags |= WMI_TLV_FLAG_RTSENA;
10987 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
10988 rateflags |= WMI_TLV_FLAG_CTSENA;
10989 if (param->rate_flags & WMI_HOST_FLAG_SGI)
10990 rateflags |= WMI_TLV_FLAG_SGI;
10991
10992 return rateflags;
10993}
10994
10995/**
Sathish Kumar497bef42017-03-01 14:02:36 +053010996 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10997 * info to fw
10998 * @wmi_handle: wmi handle
10999 * @param: pointer to hold packet power info param
11000 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011001 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053011002 */
11003static QDF_STATUS
11004send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
11005 struct packet_power_info_params *param)
11006{
11007 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
11008 wmi_buf_t wmibuf;
11009 uint8_t *buf_ptr;
11010 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
11011
11012 wmibuf = wmi_buf_alloc(wmi_handle, len);
11013 if (wmibuf == NULL)
11014 return QDF_STATUS_E_NOMEM;
11015
11016 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
11017
11018 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
11019 WMITLV_SET_HDR(&cmd->tlv_header,
11020 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
11021 WMITLV_GET_STRUCT_TLVLEN(
11022 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011023 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11024 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011025 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053011026 cmd->nss = param->nss;
11027 cmd->preamble = param->preamble;
11028 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011029
11030 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
11031 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
11032 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
11033 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
11034
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011035 wmi_mtrace(WMI_PDEV_GET_TPC_CMDID, NO_SESSION, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +053011036 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
11037 WMI_PDEV_GET_TPC_CMDID)) {
11038 WMI_LOGE(FL("Failed to get tpc command\n"));
11039 wmi_buf_free(wmibuf);
11040 return QDF_STATUS_E_FAILURE;
11041 }
11042
11043 return QDF_STATUS_SUCCESS;
11044}
11045
11046/**
11047 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
11048 * @wmi_handle: wmi handle
11049 * @param: pointer to hold config ratemask params
11050 *
11051 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11052 */
11053static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
11054 struct config_ratemask_params *param)
11055{
11056 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
11057 wmi_buf_t buf;
11058 int32_t len = sizeof(*cmd);
11059
11060 buf = wmi_buf_alloc(wmi_handle, len);
11061 if (!buf) {
11062 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11063 return QDF_STATUS_E_FAILURE;
11064 }
11065 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
11066 WMITLV_SET_HDR(&cmd->tlv_header,
11067 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
11068 WMITLV_GET_STRUCT_TLVLEN(
11069 wmi_vdev_config_ratemask_cmd_fixed_param));
11070 cmd->vdev_id = param->vdev_id;
11071 cmd->type = param->type;
11072 cmd->mask_lower32 = param->lower32;
11073 cmd->mask_higher32 = param->higher32;
Rhythm Patwab5ca01d2018-06-19 10:43:00 -070011074 cmd->mask_lower32_2 = param->lower32_2;
11075 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X"
11076 "mask_l32 = 0x%X mask_h32 = 0x%X mask_l32_2 = 0x%X\n",
11077 param->vdev_id, param->type, param->lower32,
11078 param->higher32, param->lower32_2);
Sathish Kumar497bef42017-03-01 14:02:36 +053011079
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011080 wmi_mtrace(WMI_VDEV_RATEMASK_CMDID, cmd->vdev_id, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +053011081 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11082 WMI_VDEV_RATEMASK_CMDID)) {
11083 WMI_LOGE("Seting vdev ratemask failed\n");
11084 wmi_buf_free(buf);
11085 return QDF_STATUS_E_FAILURE;
11086 }
11087
11088 return QDF_STATUS_SUCCESS;
11089}
11090
11091/**
Sathish Kumar6011c742017-11-08 14:49:58 +053011092 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
11093 * @param: param sent from the host side
11094 * @cmd: param to be sent to the fw side
11095 */
11096static inline void copy_custom_aggr_bitmap(
11097 struct set_custom_aggr_size_params *param,
11098 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
11099{
11100 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
11101 param->ac);
11102 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
11103 param->aggr_type);
11104 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11105 param->tx_aggr_size_disable);
11106 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11107 param->rx_aggr_size_disable);
11108 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
11109 param->tx_ac_enable);
11110}
11111
11112/**
11113 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
11114 * @wmi_handle: wmi handle
11115 * @param: pointer to hold custom aggr size params
11116 *
11117 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11118 */
11119static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
11120 wmi_unified_t wmi_handle,
11121 struct set_custom_aggr_size_params *param)
11122{
11123 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
11124 wmi_buf_t buf;
11125 int32_t len = sizeof(*cmd);
11126
11127 buf = wmi_buf_alloc(wmi_handle, len);
11128 if (!buf) {
11129 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11130 return QDF_STATUS_E_FAILURE;
11131 }
11132 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
11133 wmi_buf_data(buf);
11134 WMITLV_SET_HDR(&cmd->tlv_header,
11135 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
11136 WMITLV_GET_STRUCT_TLVLEN(
11137 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
11138 cmd->vdev_id = param->vdev_id;
11139 cmd->tx_aggr_size = param->tx_aggr_size;
11140 cmd->rx_aggr_size = param->rx_aggr_size;
11141 copy_custom_aggr_bitmap(param, cmd);
11142
11143 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
11144 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
11145 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
11146 "tx_ac_enable=0x%X\n",
11147 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
11148 param->ac, param->aggr_type, param->tx_aggr_size_disable,
11149 param->rx_aggr_size_disable, param->tx_ac_enable);
11150
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011151 wmi_mtrace(WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID, cmd->vdev_id, 0);
Sathish Kumar6011c742017-11-08 14:49:58 +053011152 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11153 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
11154 WMI_LOGE("Seting custom aggregation size failed\n");
11155 wmi_buf_free(buf);
11156 return QDF_STATUS_E_FAILURE;
11157 }
11158
11159 return QDF_STATUS_SUCCESS;
11160}
11161
11162/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011163 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
11164 * @param wmi_handle : handle to WMI.
11165 * @param param : pointer to tx antenna param
11166 *
11167 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11168 */
11169
11170static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
11171 struct set_qdepth_thresh_params *param)
11172{
11173 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
11174 wmi_msduq_qdepth_thresh_update *cmd_update;
11175 wmi_buf_t buf;
11176 int32_t len = 0;
11177 int i;
11178 uint8_t *buf_ptr;
11179 QDF_STATUS ret;
11180
11181 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
11182 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
11183 return QDF_STATUS_E_INVAL;
11184 }
11185
11186 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11187 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
11188 param->num_of_msduq_updates);
11189 buf = wmi_buf_alloc(wmi_handle, len);
11190
11191 if (!buf) {
11192 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11193 return QDF_STATUS_E_NOMEM;
11194 }
11195
11196 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11197 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11198 buf_ptr;
11199
11200 WMITLV_SET_HDR(&cmd->tlv_header,
11201 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11202 , WMITLV_GET_STRUCT_TLVLEN(
11203 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11204
11205 cmd->pdev_id =
11206 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11207 cmd->vdev_id = param->vdev_id;
11208 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11209 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11210
11211 buf_ptr += sizeof(
11212 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11213 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11214 param->num_of_msduq_updates *
11215 sizeof(wmi_msduq_qdepth_thresh_update));
11216 buf_ptr += WMI_TLV_HDR_SIZE;
11217 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11218
11219 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11220 WMITLV_SET_HDR(&cmd_update->tlv_header,
11221 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11222 WMITLV_GET_STRUCT_TLVLEN(
11223 wmi_msduq_qdepth_thresh_update));
11224 cmd_update->tid_num = param->update_params[i].tid_num;
11225 cmd_update->msduq_update_mask =
11226 param->update_params[i].msduq_update_mask;
11227 cmd_update->qdepth_thresh_value =
11228 param->update_params[i].qdepth_thresh_value;
11229 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11230 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11231 " update mask=0x%X thresh val=0x%X\n",
11232 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11233 cmd->peer_mac_address.mac_addr31to0,
11234 cmd->peer_mac_address.mac_addr47to32,
11235 cmd_update->msduq_update_mask,
11236 cmd_update->qdepth_thresh_value);
11237 cmd_update++;
11238 }
11239
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011240 wmi_mtrace(WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID,
11241 cmd->vdev_id, 0);
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011242 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11243 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11244
11245 if (ret != 0) {
11246 WMI_LOGE(" %s :WMI Failed\n", __func__);
11247 wmi_buf_free(buf);
11248 }
11249
11250 return ret;
11251}
11252
11253/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011254 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11255 * @wmi_handle: wmi handle
11256 * @param: pointer to hold vap dscp tid map param
11257 *
11258 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11259 */
11260static QDF_STATUS
11261send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11262 struct vap_dscp_tid_map_params *param)
11263{
11264 wmi_buf_t buf;
11265 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11266 int32_t len = sizeof(*cmd);
11267
11268 buf = wmi_buf_alloc(wmi_handle, len);
11269 if (!buf) {
11270 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11271 return QDF_STATUS_E_FAILURE;
11272 }
11273
11274 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11275 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053011276 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053011277
11278 cmd->vdev_id = param->vdev_id;
11279 cmd->enable_override = 0;
11280
11281 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011282 wmi_mtrace(WMI_VDEV_SET_DSCP_TID_MAP_CMDID, cmd->vdev_id, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +053011283 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11284 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11285 WMI_LOGE("Failed to set dscp cmd\n");
11286 wmi_buf_free(buf);
11287 return QDF_STATUS_E_FAILURE;
11288 }
11289
11290 return QDF_STATUS_SUCCESS;
11291}
11292
11293/**
11294 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11295 * @wmi_handle: wmi handle
11296 * @macaddr: vdev mac address
11297 * @param: pointer to hold neigbour rx param
11298 *
11299 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11300 */
11301static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11302 uint8_t macaddr[IEEE80211_ADDR_LEN],
11303 struct set_neighbour_rx_params *param)
11304{
11305 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11306 wmi_buf_t buf;
11307 int32_t len = sizeof(*cmd);
11308
11309 buf = wmi_buf_alloc(wmi_handle, len);
11310 if (!buf) {
11311 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11312 return QDF_STATUS_E_FAILURE;
11313 }
11314 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11315 WMITLV_SET_HDR(&cmd->tlv_header,
11316 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11317 WMITLV_GET_STRUCT_TLVLEN(
11318 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11319 cmd->vdev_id = param->vdev_id;
11320 cmd->bssid_idx = param->idx;
11321 cmd->action = param->action;
11322 cmd->type = param->type;
11323 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11324 cmd->flag = 0;
11325
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011326 wmi_mtrace(WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID, cmd->vdev_id, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +053011327 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11328 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11329 WMI_LOGE("Failed to set neighbour rx param\n");
11330 wmi_buf_free(buf);
11331 return QDF_STATUS_E_FAILURE;
11332 }
11333
11334 return QDF_STATUS_SUCCESS;
11335}
11336
11337/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011338 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011339 * @param wmi_handle : handle to WMI.
11340 * @param macaddr : vdev mac address
11341 * @param param : pointer to tx antenna param
11342 *
11343 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11344 */
11345static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11346 uint8_t macaddr[IEEE80211_ADDR_LEN],
11347 struct smart_ant_tx_ant_params *param)
11348{
11349 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11350 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11351 wmi_buf_t buf;
11352 int32_t len = 0;
11353 int i;
11354 uint8_t *buf_ptr;
11355 QDF_STATUS ret;
11356
11357 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11358 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11359 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11360 buf = wmi_buf_alloc(wmi_handle, len);
11361
11362 if (!buf) {
11363 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11364 return QDF_STATUS_E_NOMEM;
11365 }
11366
11367 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11368 qdf_mem_zero(buf_ptr, len);
11369 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11370
11371 WMITLV_SET_HDR(&cmd->tlv_header,
11372 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11373 WMITLV_GET_STRUCT_TLVLEN(
11374 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11375
11376 cmd->vdev_id = param->vdev_id;
11377 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11378
11379 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11380 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11381 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11382 buf_ptr += WMI_TLV_HDR_SIZE;
11383 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11384
11385 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11386 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11387 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11388 WMITLV_GET_STRUCT_TLVLEN(
11389 wmi_peer_smart_ant_set_tx_antenna_series));
11390 ant_tx_series->antenna_series = param->antenna_array[i];
11391 ant_tx_series++;
11392 }
11393
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011394 wmi_mtrace(WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID, cmd->vdev_id, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +053011395 ret = wmi_unified_cmd_send(wmi_handle,
11396 buf,
11397 len,
11398 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11399
11400 if (ret != 0) {
11401 WMI_LOGE(" %s :WMI Failed\n", __func__);
11402 wmi_buf_free(buf);
11403 }
11404
11405 return ret;
11406}
11407
Sathish Kumar02c3b542017-02-22 17:24:45 +053011408/**
11409 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11410 * @wmi_handle: wmi handle
11411 * @param: pointer to hold ant switch tbl param
11412 *
11413 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11414 */
11415static QDF_STATUS
11416send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11417 struct ant_switch_tbl_params *param)
11418{
11419 uint8_t len;
11420 wmi_buf_t buf;
11421 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11422 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11423 uint8_t *buf_ptr;
11424
11425 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11426 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11427 buf = wmi_buf_alloc(wmi_handle, len);
11428
11429 if (!buf) {
11430 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11431 return QDF_STATUS_E_NOMEM;
11432 }
11433
11434 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11435 qdf_mem_zero(buf_ptr, len);
11436 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11437
11438 WMITLV_SET_HDR(&cmd->tlv_header,
11439 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11440 WMITLV_GET_STRUCT_TLVLEN(
11441 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11442
11443 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11444 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011445 cmd->mac_id =
11446 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011447
11448 /* TLV indicating array of structures to follow */
11449 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11450 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11451 sizeof(wmi_pdev_set_ant_ctrl_chain));
11452 buf_ptr += WMI_TLV_HDR_SIZE;
11453 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11454
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011455 ctrl_chain->pdev_id =
11456 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011457 ctrl_chain->antCtrlChain = param->antCtrlChain;
11458
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011459 wmi_mtrace(WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID, NO_SESSION, 0);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011460 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11461 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11462 wmi_buf_free(buf);
11463 return QDF_STATUS_E_FAILURE;
11464 }
11465
11466 return QDF_STATUS_SUCCESS;
11467}
11468
11469/**
11470 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11471 * training information function
11472 * @param wmi_handle : handle to WMI.
11473 * @macaddr : vdev mac address
11474 * @param param : pointer to tx antenna param
11475 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11476 */
11477static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11478 wmi_unified_t wmi_handle,
11479 uint8_t macaddr[IEEE80211_ADDR_LEN],
11480 struct smart_ant_training_info_params *param)
11481{
11482 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11483 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11484 wmi_buf_t buf;
11485 uint8_t *buf_ptr;
11486 int32_t len = 0;
11487 QDF_STATUS ret;
11488 int loop;
11489
11490 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11491 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11492 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11493 buf = wmi_buf_alloc(wmi_handle, len);
11494
11495 if (!buf) {
11496 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11497 return QDF_STATUS_E_NOMEM;
11498 }
11499
11500 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11501 qdf_mem_zero(buf_ptr, len);
11502 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11503
11504 WMITLV_SET_HDR(&cmd->tlv_header,
11505 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11506 WMITLV_GET_STRUCT_TLVLEN(
11507 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11508
11509 cmd->vdev_id = param->vdev_id;
11510 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11511 cmd->num_pkts = param->numpkts;
11512
11513 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11514 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11515 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11516 WMI_SMART_ANT_MAX_RATE_SERIES);
11517
11518 buf_ptr += WMI_TLV_HDR_SIZE;
11519 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11520
11521 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11522 WMITLV_SET_HDR(&train_param->tlv_header,
11523 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11524 WMITLV_GET_STRUCT_TLVLEN(
11525 wmi_peer_smart_ant_set_train_antenna_param));
11526 train_param->train_rate_series = param->rate_array[loop];
11527 train_param->train_antenna_series = param->antenna_array[loop];
11528 train_param->rc_flags = 0;
11529 WMI_LOGI(FL("Series number:%d\n"), loop);
11530 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11531 train_param->train_rate_series,
11532 train_param->train_antenna_series);
11533 train_param++;
11534 }
11535
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011536 wmi_mtrace(WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID, cmd->vdev_id, 0);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011537 ret = wmi_unified_cmd_send(wmi_handle,
11538 buf,
11539 len,
11540 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11541
11542 if (ret != 0) {
11543 WMI_LOGE(" %s :WMI Failed\n", __func__);
11544 wmi_buf_free(buf);
11545 return QDF_STATUS_E_FAILURE;
11546 }
11547
11548 return ret;
11549}
11550
11551/**
11552 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11553 * configuration function
11554 * @param wmi_handle : handle to WMI.
11555 * @macaddr : vdev mad address
11556 * @param param : pointer to tx antenna param
11557 *
11558 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11559 */
11560static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
11561 wmi_unified_t wmi_handle,
11562 uint8_t macaddr[IEEE80211_ADDR_LEN],
11563 struct smart_ant_node_config_params *param)
11564{
11565 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
11566 wmi_buf_t buf;
11567 uint8_t *buf_ptr;
11568 int32_t len = 0, args_tlv_len;
11569 int ret;
11570 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053011571 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011572
Vivekc5823092018-03-22 23:27:21 +053011573 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011574 len = sizeof(*cmd) + args_tlv_len;
11575
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070011576 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053011577 WMI_LOGE("%s: Can't send a command with %d arguments\n",
11578 __func__, param->args_count);
11579 return QDF_STATUS_E_FAILURE;
11580 }
11581
11582 buf = wmi_buf_alloc(wmi_handle, len);
11583 if (!buf) {
11584 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11585 return QDF_STATUS_E_NOMEM;
11586 }
11587
11588 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
11589 wmi_buf_data(buf);
11590 buf_ptr = (uint8_t *)cmd;
11591 WMITLV_SET_HDR(&cmd->tlv_header,
11592 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
11593 WMITLV_GET_STRUCT_TLVLEN(
11594 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
11595 cmd->vdev_id = param->vdev_id;
11596 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11597 cmd->cmd_id = param->cmd_id;
11598 cmd->args_count = param->args_count;
11599 buf_ptr += sizeof(
11600 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
11601 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053011602 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011603 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053011604 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011605
11606 for (i = 0; i < param->args_count; i++) {
11607 node_config_args[i] = param->args_arr[i];
11608 WMI_LOGI("%d", param->args_arr[i]);
11609 }
11610
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011611 wmi_mtrace(WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID,
11612 cmd->vdev_id, 0);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011613 ret = wmi_unified_cmd_send(wmi_handle,
11614 buf,
11615 len,
11616 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
11617
11618 if (ret != 0) {
11619 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
11620 __func__, param->cmd_id, macaddr[0],
11621 macaddr[1], macaddr[2], macaddr[3],
11622 macaddr[4], macaddr[5], ret);
11623 wmi_buf_free(buf);
11624 }
11625
11626 return ret;
11627}
11628
Jeffin Mammen095050b2018-07-24 14:20:08 +053011629#ifdef WLAN_ATF_ENABLE
Sathish Kumar02c3b542017-02-22 17:24:45 +053011630/**
11631 * send_set_atf_cmd_tlv() - send set atf command to fw
11632 * @wmi_handle: wmi handle
11633 * @param: pointer to set atf param
11634 *
11635 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11636 */
11637static QDF_STATUS
11638send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
11639 struct set_atf_params *param)
11640{
11641 wmi_atf_peer_info *peer_info;
11642 wmi_peer_atf_request_fixed_param *cmd;
11643 wmi_buf_t buf;
11644 uint8_t *buf_ptr;
11645 int i;
11646 int32_t len = 0;
11647 QDF_STATUS retval;
11648
11649 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11650 len += param->num_peers * sizeof(wmi_atf_peer_info);
11651 buf = wmi_buf_alloc(wmi_handle, len);
11652 if (!buf) {
11653 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11654 return QDF_STATUS_E_FAILURE;
11655 }
11656 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11657 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
11658 WMITLV_SET_HDR(&cmd->tlv_header,
11659 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
11660 WMITLV_GET_STRUCT_TLVLEN(
11661 wmi_peer_atf_request_fixed_param));
11662 cmd->num_peers = param->num_peers;
11663
11664 buf_ptr += sizeof(*cmd);
11665 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11666 sizeof(wmi_atf_peer_info) *
11667 cmd->num_peers);
11668 buf_ptr += WMI_TLV_HDR_SIZE;
11669 peer_info = (wmi_atf_peer_info *)buf_ptr;
11670
11671 for (i = 0; i < cmd->num_peers; i++) {
11672 WMITLV_SET_HDR(&peer_info->tlv_header,
11673 WMITLV_TAG_STRUC_wmi_atf_peer_info,
11674 WMITLV_GET_STRUCT_TLVLEN(
11675 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011676 qdf_mem_copy(&(peer_info->peer_macaddr),
11677 &(param->peer_info[i].peer_macaddr),
11678 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011679 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011680 peer_info->vdev_id = param->peer_info[i].vdev_id;
11681 peer_info->pdev_id =
11682 wmi_handle->ops->convert_pdev_id_host_to_target(
11683 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011684 /*
11685 * TLV definition for peer atf request fixed param combines
11686 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11687 * stats and atf extension stats as two different
11688 * implementations.
11689 * Need to discuss with FW on this.
11690 *
11691 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11692 * peer_info->atf_units_reserved =
11693 * param->peer_ext_info[i].atf_index_reserved;
11694 */
11695 peer_info++;
11696 }
11697
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011698 wmi_mtrace(WMI_PEER_ATF_REQUEST_CMDID, NO_SESSION, 0);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011699 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11700 WMI_PEER_ATF_REQUEST_CMDID);
11701
11702 if (retval != QDF_STATUS_SUCCESS) {
11703 WMI_LOGE("%s : WMI Failed\n", __func__);
11704 wmi_buf_free(buf);
11705 }
11706
11707 return retval;
11708}
Jeffin Mammen095050b2018-07-24 14:20:08 +053011709#endif
Sathish Kumar02c3b542017-02-22 17:24:45 +053011710
11711/**
11712 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11713 * @wmi_handle: wmi handle
11714 * @param: pointer to hold fwtest param
11715 *
11716 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11717 */
11718static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11719 struct set_fwtest_params *param)
11720{
11721 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11722 wmi_buf_t buf;
11723 int32_t len = sizeof(*cmd);
11724
11725 buf = wmi_buf_alloc(wmi_handle, len);
11726
11727 if (!buf) {
11728 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11729 return QDF_STATUS_E_FAILURE;
11730 }
11731
11732 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11733 WMITLV_SET_HDR(&cmd->tlv_header,
11734 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11735 WMITLV_GET_STRUCT_TLVLEN(
11736 wmi_fwtest_set_param_cmd_fixed_param));
11737 cmd->param_id = param->arg;
11738 cmd->param_value = param->value;
11739
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011740 wmi_mtrace(WMI_FWTEST_CMDID, NO_SESSION, 0);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011741 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11742 WMI_LOGE("Setting FW test param failed\n");
11743 wmi_buf_free(buf);
11744 return QDF_STATUS_E_FAILURE;
11745 }
11746
11747 return QDF_STATUS_SUCCESS;
11748}
11749
11750/**
11751 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11752 * @wmi_handle: wmi handle
11753 * @param: pointer to qboost params
11754 * @macaddr: vdev mac address
11755 *
11756 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11757 */
11758static QDF_STATUS
11759send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11760 uint8_t macaddr[IEEE80211_ADDR_LEN],
11761 struct set_qboost_params *param)
11762{
11763 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11764 wmi_buf_t buf;
11765 int32_t len;
11766 QDF_STATUS ret;
11767
11768 len = sizeof(*cmd);
11769
11770 buf = wmi_buf_alloc(wmi_handle, len);
11771 if (!buf) {
11772 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11773 return QDF_STATUS_E_FAILURE;
11774 }
11775
11776 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11777 WMITLV_SET_HDR(&cmd->tlv_header,
11778 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11779 WMITLV_GET_STRUCT_TLVLEN(
11780 WMI_QBOOST_CFG_CMD_fixed_param));
11781 cmd->vdev_id = param->vdev_id;
11782 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11783 cmd->qb_enable = param->value;
11784
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011785 wmi_mtrace(WMI_QBOOST_CFG_CMDID, cmd->vdev_id, 0);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011786 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11787 WMI_QBOOST_CFG_CMDID);
11788
11789 if (ret != 0) {
11790 WMI_LOGE("Setting qboost cmd failed\n");
11791 wmi_buf_free(buf);
11792 }
11793
11794 return ret;
11795}
11796
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011797/**
11798 * send_gpio_config_cmd_tlv() - send gpio config to fw
11799 * @wmi_handle: wmi handle
11800 * @param: pointer to hold gpio config param
11801 *
11802 * Return: 0 for success or error code
11803 */
11804static QDF_STATUS
11805send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
11806 struct gpio_config_params *param)
11807{
11808 wmi_gpio_config_cmd_fixed_param *cmd;
11809 wmi_buf_t buf;
11810 int32_t len;
11811 QDF_STATUS ret;
11812
11813 len = sizeof(*cmd);
11814
11815 /* Sanity Checks */
11816 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
11817 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
11818 return QDF_STATUS_E_FAILURE;
11819 }
11820
11821 buf = wmi_buf_alloc(wmi_handle, len);
11822 if (!buf) {
11823 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11824 return QDF_STATUS_E_FAILURE;
11825 }
11826
11827 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
11828 WMITLV_SET_HDR(&cmd->tlv_header,
11829 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
11830 WMITLV_GET_STRUCT_TLVLEN(
11831 wmi_gpio_config_cmd_fixed_param));
11832 cmd->gpio_num = param->gpio_num;
11833 cmd->input = param->input;
11834 cmd->pull_type = param->pull_type;
11835 cmd->intr_mode = param->intr_mode;
11836
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011837 wmi_mtrace(WMI_GPIO_CONFIG_CMDID, NO_SESSION, 0);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011838 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11839 WMI_GPIO_CONFIG_CMDID);
11840
11841 if (ret != 0) {
11842 WMI_LOGE("Sending GPIO config cmd failed\n");
11843 wmi_buf_free(buf);
11844 }
11845
11846 return ret;
11847}
11848
11849/**
11850 * send_gpio_output_cmd_tlv() - send gpio output to fw
11851 * @wmi_handle: wmi handle
11852 * @param: pointer to hold gpio output param
11853 *
11854 * Return: 0 for success or error code
11855 */
11856static QDF_STATUS
11857send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
11858 struct gpio_output_params *param)
11859{
11860 wmi_gpio_output_cmd_fixed_param *cmd;
11861 wmi_buf_t buf;
11862 int32_t len;
11863 QDF_STATUS ret;
11864
11865 len = sizeof(*cmd);
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 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
11874 WMITLV_SET_HDR(&cmd->tlv_header,
11875 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
11876 WMITLV_GET_STRUCT_TLVLEN(
11877 wmi_gpio_output_cmd_fixed_param));
11878 cmd->gpio_num = param->gpio_num;
11879 cmd->set = param->set;
11880
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011881 wmi_mtrace(WMI_GPIO_OUTPUT_CMDID, NO_SESSION, 0);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011882 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11883 WMI_GPIO_OUTPUT_CMDID);
11884
11885 if (ret != 0) {
11886 WMI_LOGE("Sending GPIO output cmd failed\n");
11887 wmi_buf_free(buf);
11888 }
11889
11890 return ret;
11891
11892}
11893
11894/**
11895 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
11896 *
11897 * @param wmi_handle : handle to WMI.
11898 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11899 */
11900static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
11901{
11902 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
11903 wmi_buf_t buf;
11904 QDF_STATUS ret;
11905 int32_t len;
11906
11907 len = sizeof(*cmd);
11908
11909 buf = wmi_buf_alloc(wmi_handle, len);
11910 if (!buf) {
11911 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11912 return QDF_STATUS_E_FAILURE;
11913 }
11914
11915 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
11916 WMITLV_SET_HDR(&cmd->tlv_header,
11917 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
11918 WMITLV_GET_STRUCT_TLVLEN(
11919 wmi_pdev_dfs_disable_cmd_fixed_param));
11920 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011921 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11922 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011923
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011924 wmi_mtrace(WMI_PDEV_DFS_DISABLE_CMDID, NO_SESSION, 0);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011925 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11926 WMI_PDEV_DFS_DISABLE_CMDID);
11927
11928 if (ret != 0) {
11929 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
11930 wmi_buf_free(buf);
11931 }
11932
11933 return ret;
11934}
11935
11936/**
11937 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
11938 *
11939 * @param wmi_handle : handle to WMI.
11940 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11941 */
11942static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11943{
11944 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11945 wmi_buf_t buf;
11946 QDF_STATUS ret;
11947 int32_t len;
11948
11949 len = sizeof(*cmd);
11950
11951 buf = wmi_buf_alloc(wmi_handle, len);
11952 if (!buf) {
11953 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11954 return QDF_STATUS_E_FAILURE;
11955 }
11956
11957 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11958 WMITLV_SET_HDR(&cmd->tlv_header,
11959 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
11960 WMITLV_GET_STRUCT_TLVLEN(
11961 wmi_pdev_dfs_enable_cmd_fixed_param));
11962 /* Reserved for future use */
11963 cmd->reserved0 = 0;
11964
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053011965 wmi_mtrace(WMI_PDEV_DFS_ENABLE_CMDID, NO_SESSION, 0);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011966 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11967 WMI_PDEV_DFS_ENABLE_CMDID);
11968
11969 if (ret != 0) {
11970 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
11971 wmi_buf_free(buf);
11972 }
11973
11974 return ret;
11975}
11976
11977/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011978 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
11979 * to fw
11980 * @wmi_handle: wmi handle
11981 * @param: pointer to hold periodic chan stats param
11982 *
11983 * Return: 0 for success or error code
11984 */
11985static QDF_STATUS
11986send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
11987 struct periodic_chan_stats_params *param)
11988{
11989 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
11990 wmi_buf_t buf;
11991 QDF_STATUS ret;
11992 int32_t len;
11993
11994 len = sizeof(*cmd);
11995
11996 buf = wmi_buf_alloc(wmi_handle, len);
11997 if (!buf) {
11998 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11999 return QDF_STATUS_E_FAILURE;
12000 }
12001
12002 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
12003 wmi_buf_data(buf);
12004 WMITLV_SET_HDR(&cmd->tlv_header,
12005 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
12006 WMITLV_GET_STRUCT_TLVLEN(
12007 wmi_set_periodic_channel_stats_config_fixed_param));
12008 cmd->enable = param->enable;
12009 cmd->stats_period = param->stats_period;
12010 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12011 param->pdev_id);
12012
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012013 wmi_mtrace(WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID, NO_SESSION, 0);
Sathish Kumar0ff69e42017-11-02 10:44:39 +053012014 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12015 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
12016
12017 if (ret != 0) {
12018 WMI_LOGE("Sending periodic chan stats config failed");
12019 wmi_buf_free(buf);
12020 }
12021
12022 return ret;
12023}
12024
12025/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012026 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
12027 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080012028 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012029 *
12030 * Return: 0 for success or error code
12031 */
12032static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080012033send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012034{
12035 wmi_buf_t buf;
12036 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080012037 wmi_pdev_get_nfcal_power_fixed_param *cmd;
12038 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012039
nobeljf74583b2018-01-25 16:35:36 -080012040 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012041 if (buf == NULL)
12042 return QDF_STATUS_E_NOMEM;
12043
nobeljf74583b2018-01-25 16:35:36 -080012044 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
12045 WMITLV_SET_HDR(&cmd->tlv_header,
12046 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
12047 WMITLV_GET_STRUCT_TLVLEN
12048 (wmi_pdev_get_nfcal_power_fixed_param));
12049 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
12050
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012051 wmi_mtrace(WMI_PDEV_GET_NFCAL_POWER_CMDID, NO_SESSION, 0);
nobeljf74583b2018-01-25 16:35:36 -080012052 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012053 WMI_PDEV_GET_NFCAL_POWER_CMDID);
12054 if (ret != 0) {
12055 WMI_LOGE("Sending get nfcal power cmd failed\n");
12056 wmi_buf_free(buf);
12057 }
12058
12059 return ret;
12060}
12061
12062/**
12063 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
12064 * @wmi_handle: wmi handle
12065 * @param: pointer to ht ie param
12066 *
12067 * Return: 0 for success or error code
12068 */
12069static QDF_STATUS
12070send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12071 struct ht_ie_params *param)
12072{
12073 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
12074 wmi_buf_t buf;
12075 QDF_STATUS ret;
12076 int32_t len;
12077 uint8_t *buf_ptr;
12078
12079 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12080 roundup(param->ie_len, sizeof(uint32_t));
12081
12082 buf = wmi_buf_alloc(wmi_handle, len);
12083 if (!buf) {
12084 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12085 return QDF_STATUS_E_FAILURE;
12086 }
12087
12088 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12089 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
12090 WMITLV_SET_HDR(&cmd->tlv_header,
12091 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
12092 WMITLV_GET_STRUCT_TLVLEN(
12093 wmi_pdev_set_ht_ie_cmd_fixed_param));
12094 cmd->reserved0 = 0;
12095 cmd->ie_len = param->ie_len;
12096 cmd->tx_streams = param->tx_streams;
12097 cmd->rx_streams = param->rx_streams;
12098
12099 buf_ptr += sizeof(*cmd);
12100 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12101 buf_ptr += WMI_TLV_HDR_SIZE;
12102 if (param->ie_len)
12103 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12104 cmd->ie_len);
12105
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012106 wmi_mtrace(WMI_PDEV_SET_HT_CAP_IE_CMDID, NO_SESSION, 0);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012107 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12108 WMI_PDEV_SET_HT_CAP_IE_CMDID);
12109
12110 if (ret != 0) {
12111 WMI_LOGE("Sending set ht ie cmd failed\n");
12112 wmi_buf_free(buf);
12113 }
12114
12115 return ret;
12116}
12117
12118/**
12119 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
12120 * @wmi_handle: wmi handle
12121 * @param: pointer to vht ie param
12122 *
12123 * Return: 0 for success or error code
12124 */
12125static QDF_STATUS
12126send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12127 struct vht_ie_params *param)
12128{
12129 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
12130 wmi_buf_t buf;
12131 QDF_STATUS ret;
12132 int32_t len;
12133 uint8_t *buf_ptr;
12134
12135 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12136 roundup(param->ie_len, sizeof(uint32_t));
12137
12138 buf = wmi_buf_alloc(wmi_handle, len);
12139 if (!buf) {
12140 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12141 return QDF_STATUS_E_FAILURE;
12142 }
12143
12144 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12145 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
12146 WMITLV_SET_HDR(&cmd->tlv_header,
12147 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
12148 WMITLV_GET_STRUCT_TLVLEN(
12149 wmi_pdev_set_vht_ie_cmd_fixed_param));
12150 cmd->reserved0 = 0;
12151 cmd->ie_len = param->ie_len;
12152 cmd->tx_streams = param->tx_streams;
12153 cmd->rx_streams = param->rx_streams;
12154
12155 buf_ptr += sizeof(*cmd);
12156 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12157 buf_ptr += WMI_TLV_HDR_SIZE;
12158 if (param->ie_len)
12159 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12160 cmd->ie_len);
12161
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012162 wmi_mtrace(WMI_PDEV_SET_VHT_CAP_IE_CMDID, NO_SESSION, 0);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012163 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12164 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
12165
12166 if (ret != 0) {
12167 WMI_LOGE("Sending set vht ie cmd failed\n");
12168 wmi_buf_free(buf);
12169 }
12170
12171 return ret;
12172}
12173
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012174/**
12175 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
12176 * @wmi_handle: wmi handle
12177 * @param: pointer to quiet mode params
12178 *
12179 * Return: 0 for success or error code
12180 */
12181static QDF_STATUS
12182send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
12183 struct set_quiet_mode_params *param)
12184{
12185 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
12186 wmi_buf_t buf;
12187 QDF_STATUS ret;
12188 int32_t len;
12189
12190 len = sizeof(*quiet_cmd);
12191 buf = wmi_buf_alloc(wmi_handle, len);
12192 if (!buf) {
12193 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12194 return QDF_STATUS_E_FAILURE;
12195 }
12196
12197 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12198 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
12199 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
12200 WMITLV_GET_STRUCT_TLVLEN(
12201 wmi_pdev_set_quiet_cmd_fixed_param));
12202 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12203 quiet_cmd->enabled = param->enabled;
12204 quiet_cmd->period = (param->period)*(param->intval);
12205 quiet_cmd->duration = param->duration;
12206 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012207 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12208 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012209
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012210 wmi_mtrace(WMI_PDEV_SET_QUIET_MODE_CMDID, NO_SESSION, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012211 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12212 WMI_PDEV_SET_QUIET_MODE_CMDID);
12213
12214 if (ret != 0) {
12215 WMI_LOGE("Sending set quiet cmd failed\n");
12216 wmi_buf_free(buf);
12217 }
12218
12219 return ret;
12220}
12221
12222/**
12223 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12224 * @wmi_handle: wmi handle
12225 * @param: pointer to set bwf param
12226 *
12227 * Return: 0 for success or error code
12228 */
12229static QDF_STATUS
12230send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12231 struct set_bwf_params *param)
12232{
12233 wmi_bwf_peer_info *peer_info;
12234 wmi_peer_bwf_request_fixed_param *cmd;
12235 wmi_buf_t buf;
12236 QDF_STATUS retval;
12237 int32_t len;
12238 uint8_t *buf_ptr;
12239 int i;
12240
12241 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12242 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12243 buf = wmi_buf_alloc(wmi_handle, len);
12244 if (!buf) {
12245 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12246 return QDF_STATUS_E_FAILURE;
12247 }
12248 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12249 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12250 WMITLV_SET_HDR(&cmd->tlv_header,
12251 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12252 WMITLV_GET_STRUCT_TLVLEN(
12253 wmi_peer_bwf_request_fixed_param));
12254 cmd->num_peers = param->num_peers;
12255
12256 buf_ptr += sizeof(*cmd);
12257 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12258 sizeof(wmi_bwf_peer_info) *
12259 cmd->num_peers);
12260 buf_ptr += WMI_TLV_HDR_SIZE;
12261 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12262
12263 for (i = 0; i < cmd->num_peers; i++) {
12264 WMITLV_SET_HDR(&peer_info->tlv_header,
12265 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12266 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12267 peer_info->bwf_guaranteed_bandwidth =
12268 param->peer_info[i].throughput;
12269 peer_info->bwf_max_airtime =
12270 param->peer_info[i].max_airtime;
12271 peer_info->bwf_peer_priority =
12272 param->peer_info[i].priority;
12273 qdf_mem_copy(&peer_info->peer_macaddr,
12274 &param->peer_info[i].peer_macaddr,
12275 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012276 peer_info->vdev_id =
12277 param->peer_info[i].vdev_id;
12278 peer_info->pdev_id =
12279 wmi_handle->ops->convert_pdev_id_host_to_target(
12280 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012281 peer_info++;
12282 }
12283
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012284 wmi_mtrace(WMI_PEER_BWF_REQUEST_CMDID, NO_SESSION, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012285 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12286 WMI_PEER_BWF_REQUEST_CMDID);
12287
12288 if (retval != QDF_STATUS_SUCCESS) {
12289 WMI_LOGE("%s : WMI Failed\n", __func__);
12290 wmi_buf_free(buf);
12291 }
12292
12293 return retval;
12294}
12295
12296/**
12297 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12298 * @wmi_handle: wmi handle
12299 * @param: pointer to hold mcast update param
12300 *
12301 * Return: 0 for success or error code
12302 */
12303static QDF_STATUS
12304send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12305 struct mcast_group_update_params *param)
12306{
12307 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12308 wmi_buf_t buf;
12309 QDF_STATUS ret;
12310 int32_t len;
12311 int offset = 0;
12312 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12313
12314 len = sizeof(*cmd);
12315 buf = wmi_buf_alloc(wmi_handle, len);
12316 if (!buf) {
12317 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12318 return QDF_STATUS_E_FAILURE;
12319 }
12320 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12321 WMITLV_SET_HDR(&cmd->tlv_header,
12322 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12323 WMITLV_GET_STRUCT_TLVLEN(
12324 wmi_peer_mcast_group_cmd_fixed_param));
12325 /* confirm the buffer is 4-byte aligned */
12326 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12327 qdf_mem_zero(cmd, sizeof(*cmd));
12328
12329 cmd->vdev_id = param->vap_id;
12330 /* construct the message assuming our endianness matches the target */
12331 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12332 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12333 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12334 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12335 if (param->is_action_delete)
12336 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12337
12338 if (param->is_mcast_addr_len)
12339 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12340
12341 if (param->is_filter_mode_snoop)
12342 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12343
12344 /* unicast address spec only applies for non-wildcard cases */
12345 if (!param->wildcard && param->ucast_mac_addr) {
12346 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12347 &cmd->ucast_mac_addr);
12348 }
Amar Singhal5593c902017-10-03 13:00:29 -070012349
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012350 if (param->mcast_ip_addr) {
12351 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12352 sizeof(cmd->mcast_ip_addr));
12353 offset = sizeof(cmd->mcast_ip_addr) -
12354 param->mcast_ip_addr_bytes;
12355 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12356 param->mcast_ip_addr,
12357 param->mcast_ip_addr_bytes);
12358 }
12359 if (!param->mask)
12360 param->mask = &dummymask[0];
12361
12362 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12363 param->mask,
12364 param->mcast_ip_addr_bytes);
12365
12366 if (param->srcs && param->nsrcs) {
12367 cmd->num_filter_addr = param->nsrcs;
12368 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12369 sizeof(cmd->filter_addr));
12370
12371 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12372 param->nsrcs * param->mcast_ip_addr_bytes);
12373 }
12374
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012375 wmi_mtrace(WMI_PEER_MCAST_GROUP_CMDID, cmd->vdev_id, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012376 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12377 WMI_PEER_MCAST_GROUP_CMDID);
12378
12379 if (ret != QDF_STATUS_SUCCESS) {
12380 WMI_LOGE("%s : WMI Failed\n", __func__);
12381 wmi_buf_free(buf);
12382 }
12383
12384 return ret;
12385}
12386
12387/**
12388 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12389 * command to fw
12390 * @wmi_handle: wmi handle
12391 * @param: pointer to hold spectral config parameter
12392 *
12393 * Return: 0 for success or error code
12394 */
12395static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12396 struct vdev_spectral_configure_params *param)
12397{
12398 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12399 wmi_buf_t buf;
12400 QDF_STATUS ret;
12401 int32_t len;
12402
12403 len = sizeof(*cmd);
12404 buf = wmi_buf_alloc(wmi_handle, len);
12405 if (!buf) {
12406 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12407 return QDF_STATUS_E_FAILURE;
12408 }
12409
12410 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12411 WMITLV_SET_HDR(&cmd->tlv_header,
12412 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12413 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012414 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012415
12416 cmd->vdev_id = param->vdev_id;
12417 cmd->spectral_scan_count = param->count;
12418 cmd->spectral_scan_period = param->period;
12419 cmd->spectral_scan_priority = param->spectral_pri;
12420 cmd->spectral_scan_fft_size = param->fft_size;
12421 cmd->spectral_scan_gc_ena = param->gc_enable;
12422 cmd->spectral_scan_restart_ena = param->restart_enable;
12423 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12424 cmd->spectral_scan_init_delay = param->init_delay;
12425 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12426 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12427 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12428 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12429 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12430 cmd->spectral_scan_pwr_format = param->pwr_format;
12431 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12432 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012433 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012434 cmd->spectral_scan_chn_mask = param->chn_mask;
12435
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012436 wmi_mtrace(WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID, cmd->vdev_id, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012437 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12438 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12439
12440 if (ret != 0) {
12441 WMI_LOGE("Sending set quiet cmd failed\n");
12442 wmi_buf_free(buf);
12443 }
12444
12445 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12446 __func__);
12447
12448 WMI_LOGI("vdev_id = %u\n"
12449 "spectral_scan_count = %u\n"
12450 "spectral_scan_period = %u\n"
12451 "spectral_scan_priority = %u\n"
12452 "spectral_scan_fft_size = %u\n"
12453 "spectral_scan_gc_ena = %u\n"
12454 "spectral_scan_restart_ena = %u\n"
12455 "spectral_scan_noise_floor_ref = %u\n"
12456 "spectral_scan_init_delay = %u\n"
12457 "spectral_scan_nb_tone_thr = %u\n"
12458 "spectral_scan_str_bin_thr = %u\n"
12459 "spectral_scan_wb_rpt_mode = %u\n"
12460 "spectral_scan_rssi_rpt_mode = %u\n"
12461 "spectral_scan_rssi_thr = %u\n"
12462 "spectral_scan_pwr_format = %u\n"
12463 "spectral_scan_rpt_mode = %u\n"
12464 "spectral_scan_bin_scale = %u\n"
12465 "spectral_scan_dBm_adj = %u\n"
12466 "spectral_scan_chn_mask = %u\n",
12467 param->vdev_id,
12468 param->count,
12469 param->period,
12470 param->spectral_pri,
12471 param->fft_size,
12472 param->gc_enable,
12473 param->restart_enable,
12474 param->noise_floor_ref,
12475 param->init_delay,
12476 param->nb_tone_thr,
12477 param->str_bin_thr,
12478 param->wb_rpt_mode,
12479 param->rssi_rpt_mode,
12480 param->rssi_thr,
12481 param->pwr_format,
12482 param->rpt_mode,
12483 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012484 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012485 param->chn_mask);
12486 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12487
12488 return ret;
12489}
12490
12491/**
12492 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12493 * command to fw
12494 * @wmi_handle: wmi handle
12495 * @param: pointer to hold spectral enable parameter
12496 *
12497 * Return: 0 for success or error code
12498 */
12499static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12500 struct vdev_spectral_enable_params *param)
12501{
12502 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12503 wmi_buf_t buf;
12504 QDF_STATUS ret;
12505 int32_t len;
12506
12507 len = sizeof(*cmd);
12508 buf = wmi_buf_alloc(wmi_handle, len);
12509 if (!buf) {
12510 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12511 return QDF_STATUS_E_FAILURE;
12512 }
12513
12514 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12515 WMITLV_SET_HDR(&cmd->tlv_header,
12516 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12517 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012518 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012519
12520 cmd->vdev_id = param->vdev_id;
12521
12522 if (param->active_valid) {
12523 cmd->trigger_cmd = param->active ? 1 : 2;
12524 /* 1: Trigger, 2: Clear Trigger */
12525 } else {
12526 cmd->trigger_cmd = 0; /* 0: Ignore */
12527 }
12528
12529 if (param->enabled_valid) {
12530 cmd->enable_cmd = param->enabled ? 1 : 2;
12531 /* 1: Enable 2: Disable */
12532 } else {
12533 cmd->enable_cmd = 0; /* 0: Ignore */
12534 }
12535
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012536 wmi_mtrace(WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID, cmd->vdev_id, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012537 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12538 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12539
12540 if (ret != 0) {
12541 WMI_LOGE("Sending scan enable CMD failed\n");
12542 wmi_buf_free(buf);
12543 }
12544
12545 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12546
12547 WMI_LOGI("vdev_id = %u\n"
12548 "trigger_cmd = %u\n"
12549 "enable_cmd = %u\n",
12550 cmd->vdev_id,
12551 cmd->trigger_cmd,
12552 cmd->enable_cmd);
12553
12554 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12555
12556 return ret;
12557}
12558
12559/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012560 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12561 * @param wmi_handle : handle to WMI.
12562 * @param param : pointer to hold thermal mitigation param
12563 *
12564 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12565 */
12566static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12567 wmi_unified_t wmi_handle,
12568 struct thermal_mitigation_params *param)
12569{
12570 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12571 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12572 wmi_buf_t buf = NULL;
12573 uint8_t *buf_ptr = NULL;
12574 int error;
12575 int32_t len;
12576 int i;
12577
12578 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
12579 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
12580
12581 buf = wmi_buf_alloc(wmi_handle, len);
12582 if (!buf) {
12583 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12584 return QDF_STATUS_E_NOMEM;
12585 }
12586 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
12587
12588 /* init fixed params */
12589 WMITLV_SET_HDR(tt_conf,
12590 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
12591 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
12592
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012593 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12594 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012595 tt_conf->enable = param->enable;
12596 tt_conf->dc = param->dc;
12597 tt_conf->dc_per_event = param->dc_per_event;
12598 tt_conf->therm_throt_levels = THERMAL_LEVELS;
12599
12600 buf_ptr = (uint8_t *) ++tt_conf;
12601 /* init TLV params */
12602 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12603 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
12604
12605 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
12606 for (i = 0; i < THERMAL_LEVELS; i++) {
12607 WMITLV_SET_HDR(&lvl_conf->tlv_header,
12608 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
12609 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
12610 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
12611 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
12612 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
12613 lvl_conf->prio = param->levelconf[i].priority;
12614 lvl_conf++;
12615 }
12616
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012617 wmi_mtrace(WMI_THERM_THROT_SET_CONF_CMDID, NO_SESSION, 0);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012618 error = wmi_unified_cmd_send(wmi_handle, buf, len,
12619 WMI_THERM_THROT_SET_CONF_CMDID);
12620 if (QDF_IS_STATUS_ERROR(error)) {
12621 wmi_buf_free(buf);
12622 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
12623 }
12624
12625 return error;
12626}
12627
12628/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012629 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
12630 * @wmi_handle: wmi handle
12631 * @param: pointer to pdev_qvit_params
12632 *
12633 * Return: 0 for success or error code
12634 */
12635static QDF_STATUS
12636send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
12637 struct pdev_qvit_params *param)
12638{
12639 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012640 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012641 uint8_t *cmd;
12642 static uint8_t msgref = 1;
12643 uint8_t segnumber = 0, seginfo, numsegments;
12644 uint16_t chunk_len, total_bytes;
12645 uint8_t *bufpos;
12646 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
12647
12648 bufpos = param->utf_payload;
12649 total_bytes = param->len;
12650 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
12651 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
12652 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
12653
12654 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
12655 numsegments++;
12656
12657 while (param->len) {
12658 if (param->len > MAX_WMI_QVIT_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -070012659 chunk_len = MAX_WMI_QVIT_LEN; /* MAX message */
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012660 else
12661 chunk_len = param->len;
12662
12663 buf = wmi_buf_alloc(wmi_handle,
12664 (chunk_len + sizeof(seghdrinfo) +
12665 WMI_TLV_HDR_SIZE));
12666 if (!buf) {
12667 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12668 return QDF_STATUS_E_NOMEM;
12669 }
12670
12671 cmd = (uint8_t *) wmi_buf_data(buf);
12672
12673 seghdrinfo.len = total_bytes;
12674 seghdrinfo.msgref = msgref;
12675 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
12676 seghdrinfo.segmentInfo = seginfo;
12677
12678 segnumber++;
12679
12680 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
12681 (chunk_len + sizeof(seghdrinfo)));
12682 cmd += WMI_TLV_HDR_SIZE;
12683 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
12684 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
12685
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012686 wmi_mtrace(WMI_PDEV_QVIT_CMDID, NO_SESSION, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012687 ret = wmi_unified_cmd_send(wmi_handle, buf,
12688 (chunk_len + sizeof(seghdrinfo) +
12689 WMI_TLV_HDR_SIZE),
12690 WMI_PDEV_QVIT_CMDID);
12691
12692 if (ret != 0) {
12693 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
12694 wmi_buf_free(buf);
12695 break;
12696 }
12697
12698 param->len -= chunk_len;
12699 bufpos += chunk_len;
12700 }
12701 msgref++;
12702
12703 return ret;
12704}
12705
12706/**
12707 * send_wmm_update_cmd_tlv() - send wmm update command to fw
12708 * @wmi_handle: wmi handle
12709 * @param: pointer to wmm update param
12710 *
12711 * Return: 0 for success or error code
12712 */
12713static QDF_STATUS
12714send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
12715 struct wmm_update_params *param)
12716{
12717 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
12718 wmi_wmm_params *wmm_param;
12719 wmi_buf_t buf;
12720 QDF_STATUS ret;
12721 int32_t len;
12722 int ac = 0;
12723 struct wmi_host_wmeParams *wmep;
12724 uint8_t *buf_ptr;
12725
12726 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
12727 buf = wmi_buf_alloc(wmi_handle, len);
12728 if (!buf) {
12729 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12730 return QDF_STATUS_E_FAILURE;
12731 }
12732
12733 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12734 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
12735 WMITLV_SET_HDR(&cmd->tlv_header,
12736 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
12737 WMITLV_GET_STRUCT_TLVLEN
12738 (wmi_pdev_set_wmm_params_cmd_fixed_param));
12739
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012740 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012741
12742 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
12743
12744 for (ac = 0; ac < WME_NUM_AC; ac++) {
12745 wmep = &param->wmep_array[ac];
12746 wmm_param = (wmi_wmm_params *)buf_ptr;
12747 WMITLV_SET_HDR(&wmm_param->tlv_header,
12748 WMITLV_TAG_STRUC_wmi_wmm_params,
12749 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
12750 wmm_param->aifs = wmep->wmep_aifsn;
12751 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
12752 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
12753 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
12754 wmm_param->acm = wmep->wmep_acm;
12755 wmm_param->no_ack = wmep->wmep_noackPolicy;
12756 buf_ptr += sizeof(wmi_wmm_params);
12757 }
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012758 wmi_mtrace(WMI_PDEV_SET_WMM_PARAMS_CMDID, NO_SESSION, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012759 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12760 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12761
12762 if (ret != 0) {
12763 WMI_LOGE("Sending WMM update CMD failed\n");
12764 wmi_buf_free(buf);
12765 }
12766
12767 return ret;
12768}
12769
Sathish Kumar80f4f382017-04-24 11:36:00 +053012770/**
12771 * send_coex_config_cmd_tlv() - send coex config command to fw
12772 * @wmi_handle: wmi handle
12773 * @param: pointer to coex config param
12774 *
12775 * Return: 0 for success or error code
12776 */
12777static QDF_STATUS
12778send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12779 struct coex_config_params *param)
12780{
12781 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12782 wmi_buf_t buf;
12783 QDF_STATUS ret;
12784 int32_t len;
12785
12786 len = sizeof(*cmd);
12787 buf = wmi_buf_alloc(wmi_handle, len);
12788 if (!buf) {
12789 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12790 return QDF_STATUS_E_FAILURE;
12791 }
12792
12793 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12794 WMITLV_SET_HDR(&cmd->tlv_header,
12795 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12796 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012797 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012798
12799 cmd->vdev_id = param->vdev_id;
12800 cmd->config_type = param->config_type;
12801 cmd->config_arg1 = param->config_arg1;
12802 cmd->config_arg2 = param->config_arg2;
12803 cmd->config_arg3 = param->config_arg3;
12804 cmd->config_arg4 = param->config_arg4;
12805 cmd->config_arg5 = param->config_arg5;
12806 cmd->config_arg6 = param->config_arg6;
12807
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053012808 wmi_mtrace(WMI_COEX_CONFIG_CMDID, cmd->vdev_id, 0);
Sathish Kumar80f4f382017-04-24 11:36:00 +053012809 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12810 WMI_COEX_CONFIG_CMDID);
12811
12812 if (ret != 0) {
12813 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12814 wmi_buf_free(buf);
12815 }
12816
12817 return ret;
12818}
12819
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012820
12821#ifdef WLAN_SUPPORT_TWT
12822static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12823 target_resource_config *tgt_res_cfg)
12824{
12825 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
12826 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
12827}
12828#else
12829static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12830 target_resource_config *tgt_res_cfg)
12831{
12832 resource_cfg->twt_ap_pdev_count = 0;
12833 resource_cfg->twt_ap_sta_count = 0;
12834}
12835#endif
12836
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012837static
Govind Singh9ddd5162016-03-07 16:30:32 +053012838void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053012839 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053012840{
Govind Singhe7f2f342016-05-23 12:12:52 +053012841 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053012842 resource_cfg->num_peers = tgt_res_cfg->num_peers;
12843 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
12844 resource_cfg->num_offload_reorder_buffs =
12845 tgt_res_cfg->num_offload_reorder_buffs;
12846 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
12847 resource_cfg->num_tids = tgt_res_cfg->num_tids;
12848 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
12849 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
12850 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
12851 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
12852 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
12853 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
12854 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
12855 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
12856 resource_cfg->scan_max_pending_req =
12857 tgt_res_cfg->scan_max_pending_req;
12858 resource_cfg->bmiss_offload_max_vdev =
12859 tgt_res_cfg->bmiss_offload_max_vdev;
12860 resource_cfg->roam_offload_max_vdev =
12861 tgt_res_cfg->roam_offload_max_vdev;
12862 resource_cfg->roam_offload_max_ap_profiles =
12863 tgt_res_cfg->roam_offload_max_ap_profiles;
12864 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
12865 resource_cfg->num_mcast_table_elems =
12866 tgt_res_cfg->num_mcast_table_elems;
12867 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
12868 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
12869 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
12870 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
12871 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
12872 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
12873 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
12874 resource_cfg->vow_config = tgt_res_cfg->vow_config;
12875 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
12876 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
12877 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
12878 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
12879 resource_cfg->num_tdls_conn_table_entries =
12880 tgt_res_cfg->num_tdls_conn_table_entries;
12881 resource_cfg->beacon_tx_offload_max_vdev =
12882 tgt_res_cfg->beacon_tx_offload_max_vdev;
12883 resource_cfg->num_multicast_filter_entries =
12884 tgt_res_cfg->num_multicast_filter_entries;
12885 resource_cfg->num_wow_filters =
12886 tgt_res_cfg->num_wow_filters;
12887 resource_cfg->num_keep_alive_pattern =
12888 tgt_res_cfg->num_keep_alive_pattern;
12889 resource_cfg->keep_alive_pattern_size =
12890 tgt_res_cfg->keep_alive_pattern_size;
12891 resource_cfg->max_tdls_concurrent_sleep_sta =
12892 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
12893 resource_cfg->max_tdls_concurrent_buffer_sta =
12894 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
12895 resource_cfg->wmi_send_separate =
12896 tgt_res_cfg->wmi_send_separate;
12897 resource_cfg->num_ocb_vdevs =
12898 tgt_res_cfg->num_ocb_vdevs;
12899 resource_cfg->num_ocb_channels =
12900 tgt_res_cfg->num_ocb_channels;
12901 resource_cfg->num_ocb_schedules =
12902 tgt_res_cfg->num_ocb_schedules;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053012903 resource_cfg->bpf_instruction_size = tgt_res_cfg->apf_instruction_size;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053012904 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
12905 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012906 resource_cfg->max_num_dbs_scan_duty_cycle =
12907 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080012908 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080012909 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
12910 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -070012911 resource_cfg->max_bssid_indicator = tgt_res_cfg->max_bssid_indicator;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012912 if (tgt_res_cfg->atf_config)
12913 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
12914 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
12915 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
12916 resource_cfg->flag1, 1);
12917 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
12918 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
12919 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053012920 if (tgt_res_cfg->cce_disable)
12921 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012922
12923 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Chaithanya Garrepallibdfea2b2018-09-12 17:02:31 +053012924 resource_cfg->peer_map_unmap_v2_support =
12925 tgt_res_cfg->peer_map_unmap_v2;
Govind Singh9ddd5162016-03-07 16:30:32 +053012926}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012927
12928/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
12929 * @wmi_handle: pointer to wmi handle
12930 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -070012931 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012932 * @param: point host parameters for init command
12933 *
12934 * Return: Updated pointer of buf_ptr.
12935 */
12936static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
12937 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
12938{
12939 uint16_t idx;
12940
12941 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
12942 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
12943 wmi_pdev_band_to_mac *band_to_mac;
12944
12945 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
12946 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
12947 sizeof(wmi_resource_config) +
12948 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
12949 sizeof(wlan_host_memory_chunk)));
12950
12951 WMITLV_SET_HDR(&hw_mode->tlv_header,
12952 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12953 (WMITLV_GET_STRUCT_TLVLEN
12954 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
12955
12956 hw_mode->hw_mode_index = param->hw_mode_id;
12957 hw_mode->num_band_to_mac = param->num_band_to_mac;
12958
12959 buf_ptr = (uint8_t *) (hw_mode + 1);
12960 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
12961 WMI_TLV_HDR_SIZE);
12962 for (idx = 0; idx < param->num_band_to_mac; idx++) {
12963 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
12964 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
12965 WMITLV_GET_STRUCT_TLVLEN
12966 (wmi_pdev_band_to_mac));
12967 band_to_mac[idx].pdev_id =
12968 wmi_handle->ops->convert_pdev_id_host_to_target(
12969 param->band_to_mac[idx].pdev_id);
12970 band_to_mac[idx].start_freq =
12971 param->band_to_mac[idx].start_freq;
12972 band_to_mac[idx].end_freq =
12973 param->band_to_mac[idx].end_freq;
12974 }
12975 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
12976 (param->num_band_to_mac *
12977 sizeof(wmi_pdev_band_to_mac)) +
12978 WMI_TLV_HDR_SIZE;
12979
12980 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12981 (param->num_band_to_mac *
12982 sizeof(wmi_pdev_band_to_mac)));
12983 }
12984
12985 return buf_ptr;
12986}
12987
12988static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
12989 wmi_init_cmd_fixed_param *cmd)
12990{
12991 int num_whitelist;
12992 wmi_abi_version my_vers;
12993
12994 num_whitelist = sizeof(version_whitelist) /
12995 sizeof(wmi_whitelist_version_info);
12996 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12997 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12998 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12999 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13000 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13001 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13002
13003 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13004 &my_vers,
13005 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13006 &cmd->host_abi_vers);
13007
13008 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13009 __func__,
13010 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13011 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13012 cmd->host_abi_vers.abi_version_ns_0,
13013 cmd->host_abi_vers.abi_version_ns_1,
13014 cmd->host_abi_vers.abi_version_ns_2,
13015 cmd->host_abi_vers.abi_version_ns_3);
13016
13017 /* Save version sent from host -
13018 * Will be used to check ready event
13019 */
13020 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13021 sizeof(wmi_abi_version));
13022}
13023
Sathish Kumarfd347372017-02-13 12:29:09 +053013024static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053013025{
13026 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13027 wmi_service_ready_event_fixed_param *ev;
13028
13029
13030 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13031
13032 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13033 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053013034 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013035
13036 /*Save fw version from service ready message */
13037 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053013038 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013039 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013040
Govind Singhb53420c2016-03-09 14:32:57 +053013041 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013042}
13043
13044/**
13045 * wmi_unified_save_fw_version_cmd() - save fw version
13046 * @wmi_handle: pointer to wmi handle
13047 * @res_cfg: resource config
13048 * @num_mem_chunks: no of mem chunck
13049 * @mem_chunk: pointer to mem chunck structure
13050 *
13051 * This function sends IE information to firmware
13052 *
Govind Singhb53420c2016-03-09 14:32:57 +053013053 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053013054 *
13055 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013056static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053013057 void *evt_buf)
13058{
13059 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13060 wmi_ready_event_fixed_param *ev = NULL;
13061
13062 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13063 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013064 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
13065 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013066 &ev->fw_abi_vers)) {
13067 /*
13068 * Error: Our host version and the given firmware version
13069 * are incompatible.
13070 **/
Govind Singhb53420c2016-03-09 14:32:57 +053013071 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053013072 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
13073 __func__,
13074 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
13075 abi_version_0),
13076 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
13077 abi_version_0),
13078 wmi_handle->final_abi_vers.abi_version_ns_0,
13079 wmi_handle->final_abi_vers.abi_version_ns_1,
13080 wmi_handle->final_abi_vers.abi_version_ns_2,
13081 wmi_handle->final_abi_vers.abi_version_ns_3,
13082 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
13083 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
13084 ev->fw_abi_vers.abi_version_ns_0,
13085 ev->fw_abi_vers.abi_version_ns_1,
13086 ev->fw_abi_vers.abi_version_ns_2,
13087 ev->fw_abi_vers.abi_version_ns_3);
13088
Govind Singhb53420c2016-03-09 14:32:57 +053013089 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013090 }
Govind Singhb53420c2016-03-09 14:32:57 +053013091 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013092 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053013093 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013094 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053013095
Govind Singhb53420c2016-03-09 14:32:57 +053013096 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013097}
Govind Singha4836fd2016-03-07 16:45:38 +053013098
13099/**
13100 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
13101 * @wmi_handle: wmi handle
13102 * @custom_addr: base mac address
13103 *
Govind Singhe7f2f342016-05-23 12:12:52 +053013104 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053013105 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013106static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013107 uint8_t *custom_addr)
13108{
13109 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
13110 wmi_buf_t buf;
13111 int err;
13112
13113 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13114 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013115 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053013116 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013117 }
13118
13119 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013120 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053013121
13122 WMITLV_SET_HDR(&cmd->tlv_header,
13123 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
13124 WMITLV_GET_STRUCT_TLVLEN
13125 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
13126 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013127 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13128 WMI_HOST_PDEV_ID_SOC);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053013129 wmi_mtrace(WMI_PDEV_SET_BASE_MACADDR_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053013130 err = wmi_unified_cmd_send(wmi_handle, buf,
13131 sizeof(*cmd),
13132 WMI_PDEV_SET_BASE_MACADDR_CMDID);
13133 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053013134 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053013135 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013136 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013137 }
13138
13139 return 0;
13140}
13141
13142/**
13143 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
13144 * @handle: wmi handle
13145 * @event: Event received from FW
13146 * @len: Length of the event
13147 *
13148 * Enables the low frequency events and disables the high frequency
13149 * events. Bit 17 indicates if the event if low/high frequency.
13150 * 1 - high frequency, 0 - low frequency
13151 *
13152 * Return: 0 on successfully enabling/disabling the events
13153 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013154static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013155 uint8_t *event,
13156 uint32_t len)
13157{
13158 uint32_t num_of_diag_events_logs;
13159 wmi_diag_event_log_config_fixed_param *cmd;
13160 wmi_buf_t buf;
13161 uint8_t *buf_ptr;
13162 uint32_t *cmd_args, *evt_args;
13163 uint32_t buf_len, i;
13164
13165 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
13166 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
13167
Govind Singhb53420c2016-03-09 14:32:57 +053013168 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053013169
13170 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
13171 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013172 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053013173 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013174 }
13175 wmi_event = param_buf->fixed_param;
13176 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070013177
13178 if (num_of_diag_events_logs >
13179 param_buf->num_diag_events_logs_list) {
13180 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
13181 num_of_diag_events_logs,
13182 param_buf->num_diag_events_logs_list);
13183 return QDF_STATUS_E_INVAL;
13184 }
13185
Govind Singha4836fd2016-03-07 16:45:38 +053013186 evt_args = param_buf->diag_events_logs_list;
13187 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053013188 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013189 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053013190 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013191 }
13192
Govind Singhb53420c2016-03-09 14:32:57 +053013193 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013194 __func__, num_of_diag_events_logs);
13195
13196 /* Free any previous allocation */
13197 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053013198 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013199
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070013200 if (num_of_diag_events_logs >
13201 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
13202 WMI_LOGE("%s: excess num of logs:%d", __func__,
13203 num_of_diag_events_logs);
13204 QDF_ASSERT(0);
13205 return QDF_STATUS_E_INVAL;
13206 }
Govind Singha4836fd2016-03-07 16:45:38 +053013207 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053013208 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053013209 sizeof(uint32_t));
13210 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013211 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013212 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013213 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013214 }
13215 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
13216
13217 /* Prepare the send buffer */
13218 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13219 (num_of_diag_events_logs * sizeof(uint32_t));
13220
13221 buf = wmi_buf_alloc(wmi_handle, buf_len);
13222 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013223 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13224 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013225 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013226 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013227 }
13228
13229 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13230 buf_ptr = (uint8_t *) cmd;
13231
13232 WMITLV_SET_HDR(&cmd->tlv_header,
13233 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13234 WMITLV_GET_STRUCT_TLVLEN(
13235 wmi_diag_event_log_config_fixed_param));
13236
13237 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13238
13239 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13240
13241 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13242 (num_of_diag_events_logs * sizeof(uint32_t)));
13243
13244 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13245
13246 /* Populate the events */
13247 for (i = 0; i < num_of_diag_events_logs; i++) {
13248 /* Low freq (0) - Enable (1) the event
13249 * High freq (1) - Disable (0) the event
13250 */
13251 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13252 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13253 /* Set the event ID */
13254 WMI_DIAG_ID_SET(cmd_args[i],
13255 WMI_DIAG_ID_GET(evt_args[i]));
13256 /* Set the type */
13257 WMI_DIAG_TYPE_SET(cmd_args[i],
13258 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013259 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013260 wmi_handle->events_logs_list[i] = evt_args[i];
13261 }
13262
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053013263 wmi_mtrace(WMI_DIAG_EVENT_LOG_CONFIG_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053013264 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13265 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013266 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013267 __func__);
13268 wmi_buf_free(buf);
13269 /* Not clearing events_logs_list, though wmi cmd failed.
13270 * Host can still have this list
13271 */
Govind Singh67922e82016-04-01 16:48:57 +053013272 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013273 }
13274
13275 return 0;
13276}
13277
13278/**
13279 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13280 * @wmi_handle: wmi handle
13281 * @start_log: Start logging related parameters
13282 *
13283 * Send the command to the FW based on which specific logging of diag
13284 * event/log id can be started/stopped
13285 *
13286 * Return: None
13287 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013288static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013289 struct wmi_wifi_start_log *start_log)
13290{
13291 wmi_diag_event_log_config_fixed_param *cmd;
13292 wmi_buf_t buf;
13293 uint8_t *buf_ptr;
13294 uint32_t len, count, log_level, i;
13295 uint32_t *cmd_args;
13296 uint32_t total_len;
13297 count = 0;
13298
13299 if (!wmi_handle->events_logs_list) {
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +053013300 WMI_LOGD("%s: Not received event/log list from FW, yet",
13301 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013302 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013303 }
13304 /* total_len stores the number of events where BITS 17 and 18 are set.
13305 * i.e., events of high frequency (17) and for extended debugging (18)
13306 */
13307 total_len = 0;
13308 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13309 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13310 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13311 total_len++;
13312 }
13313
13314 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13315 (total_len * sizeof(uint32_t));
13316
13317 buf = wmi_buf_alloc(wmi_handle, len);
13318 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013319 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013320 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013321 }
13322 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13323 buf_ptr = (uint8_t *) cmd;
13324
13325 WMITLV_SET_HDR(&cmd->tlv_header,
13326 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13327 WMITLV_GET_STRUCT_TLVLEN(
13328 wmi_diag_event_log_config_fixed_param));
13329
13330 cmd->num_of_diag_events_logs = total_len;
13331
13332 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13333
13334 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13335 (total_len * sizeof(uint32_t)));
13336
13337 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13338
Govind Singh224a7312016-06-21 14:33:26 +053013339 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013340 log_level = 1;
13341 else
13342 log_level = 0;
13343
Govind Singhb53420c2016-03-09 14:32:57 +053013344 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013345 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13346 uint32_t val = wmi_handle->events_logs_list[i];
13347 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13348 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13349
13350 WMI_DIAG_ID_SET(cmd_args[count],
13351 WMI_DIAG_ID_GET(val));
13352 WMI_DIAG_TYPE_SET(cmd_args[count],
13353 WMI_DIAG_TYPE_GET(val));
13354 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13355 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013356 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013357 count++;
13358 }
13359 }
13360
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053013361 wmi_mtrace(WMI_DIAG_EVENT_LOG_CONFIG_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053013362 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13363 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013364 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013365 __func__);
13366 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013367 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013368 }
13369
Govind Singhb53420c2016-03-09 14:32:57 +053013370 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013371}
13372
13373/**
13374 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13375 * @wmi_handle: WMI handle
13376 *
13377 * This function is used to send the flush command to the FW,
13378 * that will flush the fw logs that are residue in the FW
13379 *
13380 * Return: None
13381 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013382static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013383{
13384 wmi_debug_mesg_flush_fixed_param *cmd;
13385 wmi_buf_t buf;
13386 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013387 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013388
13389 buf = wmi_buf_alloc(wmi_handle, len);
13390 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013391 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013392 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013393 }
13394
13395 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13396 WMITLV_SET_HDR(&cmd->tlv_header,
13397 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13398 WMITLV_GET_STRUCT_TLVLEN(
13399 wmi_debug_mesg_flush_fixed_param));
13400 cmd->reserved0 = 0;
13401
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053013402 wmi_mtrace(WMI_DEBUG_MESG_FLUSH_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053013403 ret = wmi_unified_cmd_send(wmi_handle,
13404 buf,
13405 len,
13406 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013407 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013408 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013409 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013410 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013411 }
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +053013412 WMI_LOGD("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013413
Govind Singh67922e82016-04-01 16:48:57 +053013414 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013415}
13416
13417/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013418 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013419 * @wmi_handle: wmi handle
13420 * @msg: PCL structure containing the PCL and the number of channels
13421 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013422 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013423 * firmware. The DBS Manager is the consumer of this information in the WLAN
13424 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13425 * to migrate to a new channel without host driver involvement. An example of
13426 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13427 * manage the channel selection without firmware involvement.
13428 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013429 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13430 * channel list. The weights corresponds to the channels sent in
13431 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13432 * weightage compared to the non PCL channels.
13433 *
Govind Singha4836fd2016-03-07 16:45:38 +053013434 * Return: Success if the cmd is sent successfully to the firmware
13435 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013436static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013437 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013438{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013439 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013440 wmi_buf_t buf;
13441 uint8_t *buf_ptr;
13442 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013443 uint32_t chan_len;
13444
13445 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013446
13447 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013448 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013449
13450 buf = wmi_buf_alloc(wmi_handle, len);
13451 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013452 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13453 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013454 }
13455
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013456 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013457 buf_ptr = (uint8_t *) cmd;
13458 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013459 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13460 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013461
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013462 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13463 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013464 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013465 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013466
13467 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013468 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013469 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013470 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013471 for (i = 0; i < chan_len ; i++) {
13472 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013473 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013474 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013475 }
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053013476 wmi_mtrace(WMI_PDEV_SET_PCL_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053013477 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013478 WMI_PDEV_SET_PCL_CMDID)) {
13479 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013480 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013481 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013482 }
Govind Singhb53420c2016-03-09 14:32:57 +053013483 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013484}
13485
13486/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013487 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013488 * @wmi_handle: wmi handle
13489 * @msg: Structure containing the following parameters
13490 *
13491 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13492 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13493 *
13494 * Provides notification to the WLAN firmware that host driver is requesting a
13495 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13496 * configurations that include the Dual Band Simultaneous (DBS) feature.
13497 *
13498 * Return: Success if the cmd is sent successfully to the firmware
13499 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013500static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013501 uint32_t hw_mode_index)
13502{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013503 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013504 wmi_buf_t buf;
13505 uint32_t len;
13506
13507 len = sizeof(*cmd);
13508
13509 buf = wmi_buf_alloc(wmi_handle, len);
13510 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013511 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13512 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013513 }
13514
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013515 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013516 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013517 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13518 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13519
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013520 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13521 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013522 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013523 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013524
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053013525 wmi_mtrace(WMI_PDEV_SET_HW_MODE_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053013526 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013527 WMI_PDEV_SET_HW_MODE_CMDID)) {
13528 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013529 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013530 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013531 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013532 }
13533
Govind Singhb53420c2016-03-09 14:32:57 +053013534 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013535}
13536
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013537#ifdef WLAN_POLICY_MGR_ENABLE
Govind Singha4836fd2016-03-07 16:45:38 +053013538/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013539 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013540 * @wmi_handle: wmi handle
13541 * @msg: Dual MAC config parameters
13542 *
13543 * Configures WLAN firmware with the dual MAC features
13544 *
Govind Singhb53420c2016-03-09 14:32:57 +053013545 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013546 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013547static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013548QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013549 struct policy_mgr_dual_mac_config *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013550{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013551 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013552 wmi_buf_t buf;
13553 uint32_t len;
13554
13555 len = sizeof(*cmd);
13556
13557 buf = wmi_buf_alloc(wmi_handle, len);
13558 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013559 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13560 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013561 }
13562
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013563 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013564 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013565 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013566 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013567 wmi_pdev_set_mac_config_cmd_fixed_param));
13568
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013569 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13570 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013571 cmd->concurrent_scan_config_bits = msg->scan_config;
13572 cmd->fw_mode_config_bits = msg->fw_mode_config;
Yeshwanth Sriram Guntuka03a37812018-08-16 15:55:25 +053013573 WMI_LOGD("%s: scan_config:%x fw_mode_config:%x",
13574 __func__, msg->scan_config, msg->fw_mode_config);
Govind Singha4836fd2016-03-07 16:45:38 +053013575
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053013576 wmi_mtrace(WMI_PDEV_SET_MAC_CONFIG_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053013577 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013578 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13579 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013580 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013581 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013582 }
Govind Singhb53420c2016-03-09 14:32:57 +053013583 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013584}
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013585#endif
Govind Singha4836fd2016-03-07 16:45:38 +053013586
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013587#ifdef BIG_ENDIAN_HOST
13588/**
13589* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13590* @param data_len - data length
13591* @param data - pointer to data
13592*
13593* Return: QDF_STATUS - success or error status
13594*/
13595static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13596 struct fips_params *param)
13597{
13598 unsigned char *key_unaligned, *data_unaligned;
13599 int c;
13600 u_int8_t *key_aligned = NULL;
13601 u_int8_t *data_aligned = NULL;
13602
13603 /* Assigning unaligned space to copy the key */
13604 key_unaligned = qdf_mem_malloc(
13605 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13606 data_unaligned = qdf_mem_malloc(
13607 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13608
Jeff Johnsonda263992018-05-12 14:22:00 -070013609 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013610 if (key_unaligned == NULL)
13611 return QDF_STATUS_SUCCESS;
13612 /* Checking if space is aligned */
13613 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
13614 /* align to 4 */
13615 key_aligned =
13616 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
13617 FIPS_ALIGN);
13618 } else {
13619 key_aligned = (u_int8_t *)key_unaligned;
13620 }
13621
13622 /* memset and copy content from key to key aligned */
13623 OS_MEMSET(key_aligned, 0, param->key_len);
13624 OS_MEMCPY(key_aligned, param->key, param->key_len);
13625
13626 /* print a hexdump for host debug */
13627 print_hex_dump(KERN_DEBUG,
13628 "\t Aligned and Copied Key:@@@@ ",
13629 DUMP_PREFIX_NONE,
13630 16, 1, key_aligned, param->key_len, true);
13631
Jeff Johnsonda263992018-05-12 14:22:00 -070013632 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013633 if (data_unaligned == NULL)
13634 return QDF_STATUS_SUCCESS;
13635 /* Checking of space is aligned */
13636 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13637 /* align to 4 */
13638 data_aligned =
13639 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
13640 FIPS_ALIGN);
13641 } else {
13642 data_aligned = (u_int8_t *)data_unaligned;
13643 }
13644
13645 /* memset and copy content from data to data aligned */
13646 OS_MEMSET(data_aligned, 0, param->data_len);
13647 OS_MEMCPY(data_aligned, param->data, param->data_len);
13648
13649 /* print a hexdump for host debug */
13650 print_hex_dump(KERN_DEBUG,
13651 "\t Properly Aligned and Copied Data:@@@@ ",
13652 DUMP_PREFIX_NONE,
13653 16, 1, data_aligned, param->data_len, true);
13654
13655 /* converting to little Endian both key_aligned and
13656 * data_aligned*/
13657 for (c = 0; c < param->key_len/4; c++) {
13658 *((u_int32_t *)key_aligned+c) =
13659 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
13660 }
13661 for (c = 0; c < param->data_len/4; c++) {
13662 *((u_int32_t *)data_aligned+c) =
13663 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
13664 }
13665
13666 /* update endian data to key and data vectors */
13667 OS_MEMCPY(param->key, key_aligned, param->key_len);
13668 OS_MEMCPY(param->data, data_aligned, param->data_len);
13669
13670 /* clean up allocated spaces */
13671 qdf_mem_free(key_unaligned);
13672 key_unaligned = NULL;
13673 key_aligned = NULL;
13674
13675 qdf_mem_free(data_unaligned);
13676 data_unaligned = NULL;
13677 data_aligned = NULL;
13678
13679 return QDF_STATUS_SUCCESS;
13680}
13681#else
13682/**
13683* fips_align_data_be() - DUMMY for LE platform
13684*
13685* Return: QDF_STATUS - success
13686*/
13687static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13688 struct fips_params *param)
13689{
13690 return QDF_STATUS_SUCCESS;
13691}
13692#endif
13693
13694
13695/**
13696 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
13697 * @wmi_handle: wmi handle
13698 * @param: pointer to hold pdev fips param
13699 *
13700 * Return: 0 for success or error code
13701 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013702static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013703send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
13704 struct fips_params *param)
13705{
13706 wmi_pdev_fips_cmd_fixed_param *cmd;
13707 wmi_buf_t buf;
13708 uint8_t *buf_ptr;
13709 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
13710 QDF_STATUS retval = QDF_STATUS_SUCCESS;
13711
13712 /* Length TLV placeholder for array of bytes */
13713 len += WMI_TLV_HDR_SIZE;
13714 if (param->data_len)
13715 len += (param->data_len*sizeof(uint8_t));
13716
13717 /*
13718 * Data length must be multiples of 16 bytes - checked against 0xF -
13719 * and must be less than WMI_SVC_MSG_SIZE - static size of
13720 * wmi_pdev_fips_cmd structure
13721 */
13722
13723 /* do sanity on the input */
13724 if (!(((param->data_len & 0xF) == 0) &&
13725 ((param->data_len > 0) &&
13726 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
13727 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
13728 return QDF_STATUS_E_INVAL;
13729 }
13730
13731 buf = wmi_buf_alloc(wmi_handle, len);
13732 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013733 qdf_print("%s:wmi_buf_alloc failed", __func__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013734 return QDF_STATUS_E_FAILURE;
13735 }
13736
13737 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13738 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
13739 WMITLV_SET_HDR(&cmd->tlv_header,
13740 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
13741 WMITLV_GET_STRUCT_TLVLEN
13742 (wmi_pdev_fips_cmd_fixed_param));
13743
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013744 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13745 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013746 if (param->key != NULL && param->data != NULL) {
13747 cmd->key_len = param->key_len;
13748 cmd->data_len = param->data_len;
13749 cmd->fips_cmd = !!(param->op);
13750
13751 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13752 return QDF_STATUS_E_FAILURE;
13753
13754 qdf_mem_copy(cmd->key, param->key, param->key_len);
13755
13756 if (param->mode == FIPS_ENGINE_AES_CTR ||
13757 param->mode == FIPS_ENGINE_AES_MIC) {
13758 cmd->mode = param->mode;
13759 } else {
13760 cmd->mode = FIPS_ENGINE_AES_CTR;
13761 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013762 qdf_print("Key len = %d, Data len = %d",
13763 cmd->key_len, cmd->data_len);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013764
13765 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13766 cmd->key, cmd->key_len, true);
13767 buf_ptr += sizeof(*cmd);
13768
13769 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13770
13771 buf_ptr += WMI_TLV_HDR_SIZE;
13772 if (param->data_len)
13773 qdf_mem_copy(buf_ptr,
13774 (uint8_t *) param->data, param->data_len);
13775
13776 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13777 16, 1, buf_ptr, cmd->data_len, true);
13778
13779 buf_ptr += param->data_len;
13780
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053013781 wmi_mtrace(WMI_PDEV_FIPS_CMDID, NO_SESSION, 0);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013782 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13783 WMI_PDEV_FIPS_CMDID);
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013784 qdf_print("%s return value %d", __func__, retval);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013785 } else {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053013786 qdf_print("\n%s:%d Key or Data is NULL", __func__, __LINE__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013787 wmi_buf_free(buf);
13788 retval = -QDF_STATUS_E_BADMSG;
13789 }
13790
13791 return retval;
13792}
13793
Wu Gao52c0b772018-05-17 16:14:00 +080013794#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013795/**
13796 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13797 * @wmi_handle: wmi handle
13798 * @vdev_id: vdev id
13799 * @bitmap: Event bitmap
13800 * @enable: enable/disable
13801 *
13802 * Return: CDF status
13803 */
13804static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13805 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013806 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013807 bool enable)
13808{
13809 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13810 uint16_t len;
13811 wmi_buf_t buf;
13812 int ret;
13813
13814 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13815 buf = wmi_buf_alloc(wmi_handle, len);
13816 if (!buf) {
13817 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13818 return QDF_STATUS_E_NOMEM;
13819 }
13820 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13821 WMITLV_SET_HDR(&cmd->tlv_header,
13822 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13823 WMITLV_GET_STRUCT_TLVLEN
13824 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13825 cmd->vdev_id = vdev_id;
13826 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013827 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13828 WMI_WOW_MAX_EVENT_BM_LEN);
13829
13830 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13831 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13832 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013833
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053013834 wmi_mtrace(WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID, cmd->vdev_id, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013835 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13836 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13837 if (ret) {
13838 WMI_LOGE("Failed to config wow wakeup event");
13839 wmi_buf_free(buf);
13840 return QDF_STATUS_E_FAILURE;
13841 }
13842
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013843 return QDF_STATUS_SUCCESS;
13844}
13845
13846/**
13847 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13848 * @wmi_handle: wmi handle
13849 * @vdev_id: vdev id
13850 * @ptrn_id: pattern id
13851 * @ptrn: pattern
13852 * @ptrn_len: pattern length
13853 * @ptrn_offset: pattern offset
13854 * @mask: mask
13855 * @mask_len: mask length
13856 * @user: true for user configured pattern and false for default pattern
13857 * @default_patterns: default patterns
13858 *
13859 * Return: CDF status
13860 */
13861static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
13862 uint8_t vdev_id, uint8_t ptrn_id,
13863 const uint8_t *ptrn, uint8_t ptrn_len,
13864 uint8_t ptrn_offset, const uint8_t *mask,
13865 uint8_t mask_len, bool user,
13866 uint8_t default_patterns)
13867{
13868 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13869 WOW_BITMAP_PATTERN_T *bitmap_pattern;
13870 wmi_buf_t buf;
13871 uint8_t *buf_ptr;
13872 int32_t len;
13873 int ret;
13874
13875 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13876 WMI_TLV_HDR_SIZE +
13877 1 * sizeof(WOW_BITMAP_PATTERN_T) +
13878 WMI_TLV_HDR_SIZE +
13879 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13880 WMI_TLV_HDR_SIZE +
13881 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13882 WMI_TLV_HDR_SIZE +
13883 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13884 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053013885 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013886
13887 buf = wmi_buf_alloc(wmi_handle, len);
13888 if (!buf) {
13889 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13890 return QDF_STATUS_E_NOMEM;
13891 }
13892
13893 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13894 buf_ptr = (uint8_t *) cmd;
13895
13896 WMITLV_SET_HDR(&cmd->tlv_header,
13897 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13898 WMITLV_GET_STRUCT_TLVLEN
13899 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13900 cmd->vdev_id = vdev_id;
13901 cmd->pattern_id = ptrn_id;
13902
13903 cmd->pattern_type = WOW_BITMAP_PATTERN;
13904 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13905
13906 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13907 sizeof(WOW_BITMAP_PATTERN_T));
13908 buf_ptr += WMI_TLV_HDR_SIZE;
13909 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
13910
13911 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
13912 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
13913 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
13914
13915 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
13916 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
13917
13918 bitmap_pattern->pattern_offset = ptrn_offset;
13919 bitmap_pattern->pattern_len = ptrn_len;
13920
13921 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
13922 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
13923
13924 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
13925 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
13926
13927 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
13928 bitmap_pattern->pattern_id = ptrn_id;
13929
Manjunathappa Prakash6cbc6632018-08-14 18:18:10 -070013930 WMI_LOGD("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013931 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
13932 bitmap_pattern->pattern_offset, user);
Manjunathappa Prakash6cbc6632018-08-14 18:18:10 -070013933 WMI_LOGD("Pattern : ");
13934 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
13935 &bitmap_pattern->patternbuf[0],
13936 bitmap_pattern->pattern_len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013937
Manjunathappa Prakash6cbc6632018-08-14 18:18:10 -070013938 WMI_LOGD("Mask : ");
13939 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
13940 &bitmap_pattern->bitmaskbuf[0],
13941 bitmap_pattern->pattern_len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013942
13943 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
13944
13945 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13946 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13947 buf_ptr += WMI_TLV_HDR_SIZE;
13948
13949 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13950 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13951 buf_ptr += WMI_TLV_HDR_SIZE;
13952
13953 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13954 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13955 buf_ptr += WMI_TLV_HDR_SIZE;
13956
13957 /* Fill TLV for pattern_info_timeout but no data. */
13958 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13959 buf_ptr += WMI_TLV_HDR_SIZE;
13960
13961 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053013962 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013963 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053013964 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013965
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053013966 wmi_mtrace(WMI_WOW_ADD_WAKE_PATTERN_CMDID, cmd->vdev_id, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013967 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13968 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13969 if (ret) {
13970 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
13971 wmi_buf_free(buf);
13972 return QDF_STATUS_E_FAILURE;
13973 }
13974
13975 return QDF_STATUS_SUCCESS;
13976}
13977
Govind Singha4836fd2016-03-07 16:45:38 +053013978/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013979 * fill_arp_offload_params_tlv() - Fill ARP offload data
13980 * @wmi_handle: wmi handle
13981 * @offload_req: offload request
13982 * @buf_ptr: buffer pointer
13983 *
13984 * To fill ARP offload data to firmware
13985 * when target goes to wow mode.
13986 *
13987 * Return: None
13988 */
13989static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013990 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013991{
13992
13993 int i;
13994 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013995 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013996
13997 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13998 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
13999 *buf_ptr += WMI_TLV_HDR_SIZE;
14000 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
14001 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
14002 WMITLV_SET_HDR(&arp_tuple->tlv_header,
14003 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
14004 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
14005
14006 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014007 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014008 /* Copy the target ip addr and flags */
14009 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
14010 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014011 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014012 WMI_IPV4_ADDR_LEN);
14013 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014014 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014015 }
14016 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
14017 }
14018}
14019
14020#ifdef WLAN_NS_OFFLOAD
14021/**
14022 * fill_ns_offload_params_tlv() - Fill NS offload data
14023 * @wmi|_handle: wmi handle
14024 * @offload_req: offload request
14025 * @buf_ptr: buffer pointer
14026 *
14027 * To fill NS offload data to firmware
14028 * when target goes to wow mode.
14029 *
14030 * Return: None
14031 */
14032static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014033 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014034{
14035
14036 int i;
14037 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014038
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014039 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14040 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14041 *buf_ptr += WMI_TLV_HDR_SIZE;
14042 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
14043 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14044 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14045 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14046 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
14047
14048 /*
14049 * Fill data only for NS offload in the first ARP tuple for LA
14050 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014051 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014052 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14053 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014054 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014055 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014056 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014057 sizeof(WMI_IPV6_ADDR));
14058 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014059 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014060 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014061 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014062 ns_tuple->flags |=
14063 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14064 }
14065 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014066 i, &ns_req->self_ipv6_addr[i],
14067 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014068
14069 /* target MAC is optional, check if it is valid,
14070 * if this is not valid, the target will use the known
14071 * local MAC address rather than the tuple
14072 */
14073 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014074 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014075 &ns_tuple->target_mac);
14076 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14077 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14078 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14079 }
14080 }
14081 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14082 }
14083}
14084
14085
14086/**
14087 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
14088 * @wmi: wmi handle
14089 * @offload_req: offload request
14090 * @buf_ptr: buffer pointer
14091 *
14092 * To fill extended NS offload extended data to firmware
14093 * when target goes to wow mode.
14094 *
14095 * Return: None
14096 */
14097static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014098 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014099{
14100 int i;
14101 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
14102 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014103
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014104 count = ns_req->num_ns_offload_count;
14105 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014106 WMI_MAX_NS_OFFLOADS;
14107
14108 /* Populate extended NS offload tuples */
14109 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14110 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14111 *buf_ptr += WMI_TLV_HDR_SIZE;
14112 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
14113 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14114 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14115 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14116 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
14117
14118 /*
14119 * Fill data only for NS offload in the first ARP tuple for LA
14120 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014121 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014122 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14123 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014124 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014125 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014126 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014127 sizeof(WMI_IPV6_ADDR));
14128 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014129 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014130 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014131 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014132 ns_tuple->flags |=
14133 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14134 }
14135 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014136 i, &ns_req->self_ipv6_addr[i],
14137 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014138
14139 /* target MAC is optional, check if it is valid,
14140 * if this is not valid, the target will use the
14141 * known local MAC address rather than the tuple
14142 */
14143 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014144 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014145 &ns_tuple->target_mac);
14146 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14147 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14148 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14149 }
14150 }
14151 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14152 }
14153}
14154#else
14155static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014156 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014157{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014158}
14159
14160static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014161 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014162{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014163}
14164#endif
14165
14166/**
Govind Singha4836fd2016-03-07 16:45:38 +053014167 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
14168 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014169 * @arp_offload_req: arp offload request
14170 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053014171 * @arp_only: flag
14172 *
14173 * To configure ARP NS off load data to firmware
14174 * when target goes to wow mode.
14175 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014176 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053014177 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014178static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014179 struct pmo_arp_offload_params *arp_offload_req,
14180 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053014181 uint8_t vdev_id)
14182{
Govind Singha4836fd2016-03-07 16:45:38 +053014183 int32_t res;
14184 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053014185 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053014186 wmi_buf_t buf;
14187 int32_t len;
14188 uint32_t count = 0, num_ns_ext_tuples = 0;
14189
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014190 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053014191
Govind Singha4836fd2016-03-07 16:45:38 +053014192 /*
14193 * TLV place holder size for array of NS tuples
14194 * TLV place holder size for array of ARP tuples
14195 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014196 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
14197 WMI_TLV_HDR_SIZE +
14198 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
14199 WMI_TLV_HDR_SIZE +
14200 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014201
14202 /*
14203 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
14204 * extra length for extended NS offload tuples which follows ARP offload
14205 * tuples. Host needs to fill this structure in following format:
14206 * 2 NS ofload tuples
14207 * 2 ARP offload tuples
14208 * N numbers of extended NS offload tuples if HDD has given more than
14209 * 2 NS offload addresses
14210 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014211 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053014212 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014213 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
14214 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014215 }
14216
14217 buf = wmi_buf_alloc(wmi_handle, len);
14218 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014219 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014220 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014221 }
14222
Vivekc5823092018-03-22 23:27:21 +053014223 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014224 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
14225 WMITLV_SET_HDR(&cmd->tlv_header,
14226 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
14227 WMITLV_GET_STRUCT_TLVLEN
14228 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
14229 cmd->flags = 0;
14230 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014231 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053014232
Govind Singhb53420c2016-03-09 14:32:57 +053014233 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053014234
Govind Singha4836fd2016-03-07 16:45:38 +053014235 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014236 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
14237 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14238 if (num_ns_ext_tuples)
14239 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014240
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014241 wmi_mtrace(WMI_SET_ARP_NS_OFFLOAD_CMDID, cmd->vdev_id, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053014242 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14243 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14244 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014245 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014246 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014247 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014248 }
14249
Govind Singhb53420c2016-03-09 14:32:57 +053014250 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014251}
14252
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014253/**
14254 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14255 * @wmi_handle: wmi handle
14256 * @vdev_id: vdev id
14257 * @action: true for enable else false
14258 *
14259 * To enable enhance multicast offload to firmware
14260 * when target goes to wow mode.
14261 *
14262 * Return: QDF Status
14263 */
14264
14265static
14266QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14267 wmi_unified_t wmi_handle,
14268 uint8_t vdev_id, bool action)
14269{
14270 QDF_STATUS status;
14271 wmi_buf_t buf;
14272 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14273
14274 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14275 if (!buf) {
14276 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14277 return QDF_STATUS_E_NOMEM;
14278 }
14279
14280 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14281 wmi_buf_data(buf);
14282
14283 WMITLV_SET_HDR(&cmd->tlv_header,
14284 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14285 WMITLV_GET_STRUCT_TLVLEN(
14286 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14287
14288 cmd->vdev_id = vdev_id;
14289 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14290 ENHANCED_MCAST_FILTER_ENABLED);
14291 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14292 __func__, action, vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014293 wmi_mtrace(WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID, cmd->vdev_id, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014294 status = wmi_unified_cmd_send(wmi_handle, buf,
14295 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14296 if (status != QDF_STATUS_SUCCESS) {
14297 qdf_nbuf_free(buf);
14298 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14299 __func__);
14300 }
14301
14302 return status;
14303}
14304
14305/**
14306 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14307 * @wmi_handle: wmi handle
14308 * @param evt_buf: pointer to event buffer
14309 * @param hdr: Pointer to hold header
14310 * @param bufp: Pointer to hold pointer to rx param buffer
14311 *
14312 * Return: QDF_STATUS_SUCCESS for success or error code
14313 */
14314static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14315 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14316{
14317 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14318 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14319
14320 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14321 if (!param_buf) {
14322 WMI_LOGE("gtk param_buf is NULL");
14323 return QDF_STATUS_E_INVAL;
14324 }
14325
14326 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14327 WMI_LOGE("Invalid length for GTK status");
14328 return QDF_STATUS_E_INVAL;
14329 }
14330
14331 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14332 param_buf->fixed_param;
14333 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14334 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14335 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14336 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14337 &fixed_param->replay_counter,
14338 GTK_REPLAY_COUNTER_BYTES);
14339
14340 return QDF_STATUS_SUCCESS;
14341
14342}
14343
14344#ifdef FEATURE_WLAN_RA_FILTERING
14345/**
14346 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14347 * @wmi_handle: wmi handle
14348 * @vdev_id: vdev id
14349 *
14350 * Return: CDF status
14351 */
14352static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14353 uint8_t vdev_id, uint8_t default_pattern,
14354 uint16_t rate_limit_interval)
14355{
14356
14357 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14358 wmi_buf_t buf;
14359 uint8_t *buf_ptr;
14360 int32_t len;
14361 int ret;
14362
14363 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14364 WMI_TLV_HDR_SIZE +
14365 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14366 WMI_TLV_HDR_SIZE +
14367 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14368 WMI_TLV_HDR_SIZE +
14369 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14370 WMI_TLV_HDR_SIZE +
14371 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14372 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014373 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014374
14375 buf = wmi_buf_alloc(wmi_handle, len);
14376 if (!buf) {
14377 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14378 return QDF_STATUS_E_NOMEM;
14379 }
14380
14381 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14382 buf_ptr = (uint8_t *) cmd;
14383
14384 WMITLV_SET_HDR(&cmd->tlv_header,
14385 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14386 WMITLV_GET_STRUCT_TLVLEN
14387 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14388 cmd->vdev_id = vdev_id;
14389 cmd->pattern_id = default_pattern,
14390 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14391 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14392
14393 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14394 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14395 buf_ptr += WMI_TLV_HDR_SIZE;
14396
14397 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14398 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14399 buf_ptr += WMI_TLV_HDR_SIZE;
14400
14401 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14402 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14403 buf_ptr += WMI_TLV_HDR_SIZE;
14404
14405 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14406 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14407 buf_ptr += WMI_TLV_HDR_SIZE;
14408
14409 /* Fill TLV for pattern_info_timeout but no data. */
14410 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14411 buf_ptr += WMI_TLV_HDR_SIZE;
14412
14413 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014414 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014415 buf_ptr += WMI_TLV_HDR_SIZE;
14416
Vivekc5823092018-03-22 23:27:21 +053014417 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014418
14419 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14420 rate_limit_interval, vdev_id);
14421
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014422 wmi_mtrace(WMI_WOW_ADD_WAKE_PATTERN_CMDID, cmd->vdev_id, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014423 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14424 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14425 if (ret) {
14426 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14427 wmi_buf_free(buf);
14428 return QDF_STATUS_E_FAILURE;
14429 }
14430
14431 return QDF_STATUS_SUCCESS;
14432
14433}
14434#endif /* FEATURE_WLAN_RA_FILTERING */
14435
14436/**
14437 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14438 * @wmi_handle: wmi handle
14439 * @vdev_id: vdev id
14440 * @multicastAddr: mcast address
14441 * @clearList: clear list flag
14442 *
14443 * Return: QDF_STATUS_SUCCESS for success or error code
14444 */
14445static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14446 uint8_t vdev_id,
14447 struct qdf_mac_addr multicast_addr,
14448 bool clearList)
14449{
14450 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14451 wmi_buf_t buf;
14452 int err;
14453
14454 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14455 if (!buf) {
14456 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14457 return QDF_STATUS_E_NOMEM;
14458 }
14459
14460 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14461 qdf_mem_zero(cmd, sizeof(*cmd));
14462
14463 WMITLV_SET_HDR(&cmd->tlv_header,
14464 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14465 WMITLV_GET_STRUCT_TLVLEN
14466 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14467 cmd->action =
14468 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14469 cmd->vdev_id = vdev_id;
14470 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14471
14472 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14473 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14474
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014475 wmi_mtrace(WMI_SET_MCASTBCAST_FILTER_CMDID, cmd->vdev_id, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014476 err = wmi_unified_cmd_send(wmi_handle, buf,
14477 sizeof(*cmd),
14478 WMI_SET_MCASTBCAST_FILTER_CMDID);
14479 if (err) {
14480 WMI_LOGE("Failed to send set_param cmd");
14481 wmi_buf_free(buf);
14482 return QDF_STATUS_E_FAILURE;
14483 }
14484
14485 return QDF_STATUS_SUCCESS;
14486}
14487
14488/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014489 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14490 * command to fw
14491 * @wmi_handle: wmi handle
14492 * @vdev_id: vdev id
14493 * @mcast_filter_params: mcast filter params
14494 *
14495 * Return: QDF_STATUS_SUCCESS for success or error code
14496 */
14497static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14498 wmi_unified_t wmi_handle,
14499 uint8_t vdev_id,
14500 struct pmo_mcast_filter_params *filter_param)
14501
14502{
14503 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14504 uint8_t *buf_ptr;
14505 wmi_buf_t buf;
14506 int err;
14507 int i;
14508 uint8_t *mac_addr_src_ptr = NULL;
14509 wmi_mac_addr *mac_addr_dst_ptr;
14510 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14511 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14512
14513 buf = wmi_buf_alloc(wmi_handle, len);
14514 if (!buf) {
14515 WMI_LOGE("Failed to allocate memory");
14516 return QDF_STATUS_E_NOMEM;
14517 }
14518
Vivekc5823092018-03-22 23:27:21 +053014519 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014520 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14521 wmi_buf_data(buf);
14522 qdf_mem_zero(cmd, sizeof(*cmd));
14523
14524 WMITLV_SET_HDR(&cmd->tlv_header,
14525 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14526 WMITLV_GET_STRUCT_TLVLEN
14527 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14528 cmd->operation =
14529 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14530 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14531 cmd->vdev_id = vdev_id;
14532 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14533
14534 buf_ptr += sizeof(*cmd);
14535 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14536 sizeof(wmi_mac_addr) *
14537 filter_param->multicast_addr_cnt);
14538
14539 if (filter_param->multicast_addr_cnt == 0)
14540 goto send_cmd;
14541
14542 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14543 mac_addr_dst_ptr = (wmi_mac_addr *)
14544 (buf_ptr + WMI_TLV_HDR_SIZE);
14545
14546 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14547 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14548 mac_addr_src_ptr += ATH_MAC_LEN;
14549 mac_addr_dst_ptr++;
14550 }
14551
14552send_cmd:
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014553 wmi_mtrace(WMI_SET_MULTIPLE_MCAST_FILTER_CMDID, cmd->vdev_id, 0);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014554 err = wmi_unified_cmd_send(wmi_handle, buf,
14555 len,
14556 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14557 if (err) {
14558 WMI_LOGE("Failed to send set_param cmd");
14559 wmi_buf_free(buf);
14560 return QDF_STATUS_E_FAILURE;
14561 }
14562
14563 return QDF_STATUS_SUCCESS;
14564}
14565
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014566static void
14567fill_fils_tlv_params(WMI_GTK_OFFLOAD_CMD_fixed_param *cmd,
14568 uint8_t vdev_id,
14569 struct pmo_gtk_req *params)
14570{
14571 uint8_t *buf_ptr;
14572 wmi_gtk_offload_fils_tlv_param *ext_param;
14573
14574 buf_ptr = (uint8_t *) cmd + sizeof(*cmd);
14575 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14576 sizeof(*ext_param));
14577 buf_ptr += WMI_TLV_HDR_SIZE;
14578
14579 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
14580 WMITLV_SET_HDR(&ext_param->tlv_header,
14581 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
14582 WMITLV_GET_STRUCT_TLVLEN(
14583 wmi_gtk_offload_fils_tlv_param));
14584 ext_param->vdev_id = vdev_id;
14585 ext_param->flags = cmd->flags;
14586 ext_param->kek_len = params->kek_len;
14587 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
14588 qdf_mem_copy(ext_param->KCK, params->kck,
14589 WMI_GTK_OFFLOAD_KCK_BYTES);
14590 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
14591 GTK_REPLAY_COUNTER_BYTES);
14592}
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014593
14594/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014595 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14596 * @wmi_handle: wmi handle
14597 * @vdev_id: vdev id
14598 * @params: GTK offload parameters
14599 *
14600 * Return: CDF status
14601 */
14602static
14603QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14604 struct pmo_gtk_req *params,
14605 bool enable_offload,
14606 uint32_t gtk_offload_opcode)
14607{
14608 int len;
14609 wmi_buf_t buf;
14610 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14611 QDF_STATUS status = QDF_STATUS_SUCCESS;
14612
14613 WMI_LOGD("%s Enter", __func__);
14614
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014615 len = sizeof(*cmd);
14616
14617 if (params->is_fils_connection)
14618 len += WMI_TLV_HDR_SIZE +
14619 sizeof(wmi_gtk_offload_fils_tlv_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014620
14621 /* alloc wmi buffer */
14622 buf = wmi_buf_alloc(wmi_handle, len);
14623 if (!buf) {
14624 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14625 status = QDF_STATUS_E_NOMEM;
14626 goto out;
14627 }
14628
14629 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14630 WMITLV_SET_HDR(&cmd->tlv_header,
14631 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14632 WMITLV_GET_STRUCT_TLVLEN
14633 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14634
14635 cmd->vdev_id = vdev_id;
14636
14637 /* Request target to enable GTK offload */
14638 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14639 cmd->flags = gtk_offload_opcode;
14640
14641 /* Copy the keys and replay counter */
14642 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014643 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014644 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14645 GTK_REPLAY_COUNTER_BYTES);
14646 } else {
14647 cmd->flags = gtk_offload_opcode;
14648 }
gaurank kathpaliaab9e9e62018-07-10 16:50:51 +053014649 if (params->is_fils_connection)
14650 fill_fils_tlv_params(cmd, vdev_id, params);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014651
14652 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 +053014653 /* send the wmi command */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014654 wmi_mtrace(WMI_GTK_OFFLOAD_CMDID, cmd->vdev_id, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014655 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14656 WMI_GTK_OFFLOAD_CMDID)) {
14657 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
14658 wmi_buf_free(buf);
14659 status = QDF_STATUS_E_FAILURE;
14660 }
14661
14662out:
14663 WMI_LOGD("%s Exit", __func__);
14664 return status;
14665}
14666
14667/**
14668 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
14669 * @wmi_handle: wmi handle
14670 * @params: GTK offload params
14671 *
14672 * Return: CDF status
14673 */
14674static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
14675 wmi_unified_t wmi_handle,
14676 uint8_t vdev_id,
14677 uint64_t offload_req_opcode)
14678{
14679 int len;
14680 wmi_buf_t buf;
14681 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14682 QDF_STATUS status = QDF_STATUS_SUCCESS;
14683
14684 len = sizeof(*cmd);
14685
14686 /* alloc wmi buffer */
14687 buf = wmi_buf_alloc(wmi_handle, len);
14688 if (!buf) {
14689 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14690 status = QDF_STATUS_E_NOMEM;
14691 goto out;
14692 }
14693
14694 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14695 WMITLV_SET_HDR(&cmd->tlv_header,
14696 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14697 WMITLV_GET_STRUCT_TLVLEN
14698 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14699
14700 /* Request for GTK offload status */
14701 cmd->flags = offload_req_opcode;
14702 cmd->vdev_id = vdev_id;
14703
14704 /* send the wmi command */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014705 wmi_mtrace(WMI_GTK_OFFLOAD_CMDID, cmd->vdev_id, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014706 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14707 WMI_GTK_OFFLOAD_CMDID)) {
14708 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
14709 wmi_buf_free(buf);
14710 status = QDF_STATUS_E_FAILURE;
14711 }
14712
14713out:
14714 return status;
14715}
14716
14717/**
14718 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
14719 * @wmi_handle: wmi handler
14720 * @action_params: pointer to action_params
14721 *
14722 * Return: 0 for success, otherwise appropriate error code
14723 */
14724static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
14725 struct pmo_action_wakeup_set_params *action_params)
14726{
14727 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
14728 wmi_buf_t buf;
14729 int i;
14730 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014731 uint32_t len = 0, *cmd_args;
14732 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014733
Vivekc5823092018-03-22 23:27:21 +053014734 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014735 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
14736 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014737 if (!buf) {
14738 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
14739 return QDF_STATUS_E_NOMEM;
14740 }
14741 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014742 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014743 WMITLV_SET_HDR(&cmd->tlv_header,
14744 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
14745 WMITLV_GET_STRUCT_TLVLEN(
14746 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
14747
14748 cmd->vdev_id = action_params->vdev_id;
14749 cmd->operation = action_params->operation;
14750
14751 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
14752 cmd->action_category_map[i] =
14753 action_params->action_category_map[i];
14754
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014755 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
14756 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053014757 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014758 buf_ptr += WMI_TLV_HDR_SIZE;
14759 cmd_args = (uint32_t *) buf_ptr;
14760 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
14761 cmd_args[i] = action_params->action_per_category[i];
14762
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014763 wmi_mtrace(WMI_WOW_SET_ACTION_WAKE_UP_CMDID, cmd->vdev_id, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014764 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014765 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014766 if (err) {
14767 WMI_LOGE("Failed to send ap_ps_egap cmd");
14768 wmi_buf_free(buf);
14769 return QDF_STATUS_E_FAILURE;
14770 }
14771
14772 return QDF_STATUS_SUCCESS;
14773}
14774
14775#ifdef FEATURE_WLAN_LPHB
14776
14777/**
14778 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
14779 * @wmi_handle: wmi handle
14780 * @lphb_conf_req: configuration info
14781 *
14782 * Return: CDF status
14783 */
14784static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
14785 wmi_hb_set_enable_cmd_fixed_param *params)
14786{
14787 QDF_STATUS status;
14788 wmi_buf_t buf = NULL;
14789 uint8_t *buf_ptr;
14790 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
14791 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
14792
14793
14794 buf = wmi_buf_alloc(wmi_handle, len);
14795 if (!buf) {
14796 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14797 return QDF_STATUS_E_NOMEM;
14798 }
14799
14800 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14801 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
14802 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
14803 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
14804 WMITLV_GET_STRUCT_TLVLEN
14805 (wmi_hb_set_enable_cmd_fixed_param));
14806
14807 /* fill in values */
14808 hb_enable_fp->vdev_id = params->session;
14809 hb_enable_fp->enable = params->enable;
14810 hb_enable_fp->item = params->item;
14811 hb_enable_fp->session = params->session;
14812
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014813 wmi_mtrace(WMI_HB_SET_ENABLE_CMDID, NO_SESSION, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014814 status = wmi_unified_cmd_send(wmi_handle, buf,
14815 len, WMI_HB_SET_ENABLE_CMDID);
14816 if (QDF_IS_STATUS_ERROR(status)) {
14817 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
14818 status);
14819 wmi_buf_free(buf);
14820 }
14821
14822 return status;
14823}
14824
14825/**
14826 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
14827 * @wmi_handle: wmi handle
14828 * @lphb_conf_req: lphb config request
14829 *
14830 * Return: CDF status
14831 */
14832static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
14833 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
14834{
14835 QDF_STATUS status;
14836 wmi_buf_t buf = NULL;
14837 uint8_t *buf_ptr;
14838 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
14839 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
14840
14841 buf = wmi_buf_alloc(wmi_handle, len);
14842 if (!buf) {
14843 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14844 return QDF_STATUS_E_NOMEM;
14845 }
14846
14847 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14848 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
14849 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
14850 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
14851 WMITLV_GET_STRUCT_TLVLEN
14852 (wmi_hb_set_tcp_params_cmd_fixed_param));
14853
14854 /* fill in values */
14855 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14856 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14857 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14858 hb_tcp_params_fp->seq = lphb_conf_req->seq;
14859 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
14860 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
14861 hb_tcp_params_fp->interval = lphb_conf_req->interval;
14862 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
14863 hb_tcp_params_fp->session = lphb_conf_req->session;
14864 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
14865 &lphb_conf_req->gateway_mac,
14866 sizeof(hb_tcp_params_fp->gateway_mac));
14867
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014868 wmi_mtrace(WMI_HB_SET_TCP_PARAMS_CMDID, NO_SESSION, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014869 status = wmi_unified_cmd_send(wmi_handle, buf,
14870 len, WMI_HB_SET_TCP_PARAMS_CMDID);
14871 if (QDF_IS_STATUS_ERROR(status)) {
14872 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
14873 status);
14874 wmi_buf_free(buf);
14875 }
14876
14877 return status;
14878}
14879
14880/**
14881 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
14882 * @wmi_handle: wmi handle
14883 * @lphb_conf_req: lphb config request
14884 *
14885 * Return: CDF status
14886 */
14887static
14888QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14889 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
14890{
14891 QDF_STATUS status;
14892 wmi_buf_t buf = NULL;
14893 uint8_t *buf_ptr;
14894 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
14895 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
14896
14897 buf = wmi_buf_alloc(wmi_handle, len);
14898 if (!buf) {
14899 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14900 return QDF_STATUS_E_NOMEM;
14901 }
14902
14903 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14904 hb_tcp_filter_fp =
14905 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
14906 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
14907 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
14908 WMITLV_GET_STRUCT_TLVLEN
14909 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
14910
14911 /* fill in values */
14912 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
14913 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
14914 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
14915 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
14916 memcpy((void *)&hb_tcp_filter_fp->filter,
14917 (void *)&g_hb_tcp_filter_fp->filter,
14918 WMI_WLAN_HB_MAX_FILTER_SIZE);
14919
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014920 wmi_mtrace(WMI_HB_SET_TCP_PKT_FILTER_CMDID, NO_SESSION, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014921 status = wmi_unified_cmd_send(wmi_handle, buf,
14922 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
14923 if (QDF_IS_STATUS_ERROR(status)) {
14924 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
14925 status);
14926 wmi_buf_free(buf);
14927 }
14928
14929 return status;
14930}
14931
14932/**
14933 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
14934 * @wmi_handle: wmi handle
14935 * @lphb_conf_req: lphb config request
14936 *
14937 * Return: CDF status
14938 */
14939static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
14940 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
14941{
14942 QDF_STATUS status;
14943 wmi_buf_t buf = NULL;
14944 uint8_t *buf_ptr;
14945 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
14946 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
14947
14948 buf = wmi_buf_alloc(wmi_handle, len);
14949 if (!buf) {
14950 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14951 return QDF_STATUS_E_NOMEM;
14952 }
14953
14954 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14955 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
14956 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
14957 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
14958 WMITLV_GET_STRUCT_TLVLEN
14959 (wmi_hb_set_udp_params_cmd_fixed_param));
14960
14961 /* fill in values */
14962 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14963 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14964 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14965 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
14966 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
14967 hb_udp_params_fp->interval = lphb_conf_req->interval;
14968 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
14969 hb_udp_params_fp->session = lphb_conf_req->session;
14970 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
14971 &lphb_conf_req->gateway_mac,
14972 sizeof(lphb_conf_req->gateway_mac));
14973
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053014974 wmi_mtrace(WMI_HB_SET_UDP_PARAMS_CMDID, NO_SESSION, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014975 status = wmi_unified_cmd_send(wmi_handle, buf,
14976 len, WMI_HB_SET_UDP_PARAMS_CMDID);
14977 if (QDF_IS_STATUS_ERROR(status)) {
14978 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
14979 status);
14980 wmi_buf_free(buf);
14981 }
14982
14983 return status;
14984}
14985
14986/**
14987 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
14988 * @wmi_handle: wmi handle
14989 * @lphb_conf_req: lphb config request
14990 *
14991 * Return: CDF status
14992 */
14993static
14994QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14995 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
14996{
14997 QDF_STATUS status;
14998 wmi_buf_t buf = NULL;
14999 uint8_t *buf_ptr;
15000 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
15001 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
15002
15003 buf = wmi_buf_alloc(wmi_handle, len);
15004 if (!buf) {
15005 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15006 return QDF_STATUS_E_NOMEM;
15007 }
15008
15009 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15010 hb_udp_filter_fp =
15011 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
15012 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
15013 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
15014 WMITLV_GET_STRUCT_TLVLEN
15015 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
15016
15017 /* fill in values */
15018 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
15019 hb_udp_filter_fp->length = lphb_conf_req->length;
15020 hb_udp_filter_fp->offset = lphb_conf_req->offset;
15021 hb_udp_filter_fp->session = lphb_conf_req->session;
15022 memcpy((void *)&hb_udp_filter_fp->filter,
15023 (void *)&lphb_conf_req->filter,
15024 WMI_WLAN_HB_MAX_FILTER_SIZE);
15025
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015026 wmi_mtrace(WMI_HB_SET_UDP_PKT_FILTER_CMDID, NO_SESSION, 0);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015027 status = wmi_unified_cmd_send(wmi_handle, buf,
15028 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
15029 if (QDF_IS_STATUS_ERROR(status)) {
15030 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
15031 status);
15032 wmi_buf_free(buf);
15033 }
15034
15035 return status;
15036}
15037#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015038
Dustin Brownf31f88b2017-05-12 14:01:44 -070015039static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
15040 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015041{
Dustin Brownf31f88b2017-05-12 14:01:44 -070015042 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015043 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070015044 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015045
Dustin Brownf31f88b2017-05-12 14:01:44 -070015046 if (!req) {
15047 WMI_LOGE("req is null");
15048 return QDF_STATUS_E_INVAL;
15049 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015050
Dustin Brownf31f88b2017-05-12 14:01:44 -070015051 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
15052 if (!wmi_buf) {
15053 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015054 return QDF_STATUS_E_NOMEM;
15055 }
15056
Dustin Brownf31f88b2017-05-12 14:01:44 -070015057 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015058 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070015059 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
15060 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
15061 cmd->vdev_id = req->vdev_id;
Nachiket Kukade200fbf72018-02-27 18:21:53 +053015062 cmd->enable = req->enable;
15063 /* Set all modes in case of disable */
15064 if (!cmd->enable)
15065 cmd->hw_filter_bitmap = ((uint32_t)~0U);
15066 else
15067 cmd->hw_filter_bitmap = req->mode_bitmap;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015068
Nachiket Kukade200fbf72018-02-27 18:21:53 +053015069 WMI_LOGD("Send %s hw filter mode: 0x%X for vdev id %d",
15070 req->enable ? "enable" : "disable", req->mode_bitmap,
15071 req->vdev_id);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015072
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015073 wmi_mtrace(WMI_HW_DATA_FILTER_CMDID, cmd->vdev_id, 0);
Dustin Brownf31f88b2017-05-12 14:01:44 -070015074 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
15075 WMI_HW_DATA_FILTER_CMDID);
15076 if (QDF_IS_STATUS_ERROR(status)) {
15077 WMI_LOGE("Failed to configure hw filter");
15078 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015079 }
15080
Dustin Brownf31f88b2017-05-12 14:01:44 -070015081 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015082}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015083
Rachit Kankaneed139ff2018-08-01 14:23:55 +053015084#ifdef WLAN_FEATURE_PACKET_FILTERING
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015085/**
15086 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
15087 * @wmi_handle: wmi handle
15088 * @vdev_id: vdev id
15089 * @enable: Flag to enable/disable packet filter
15090 *
15091 * Return: QDF_STATUS_SUCCESS for success or error code
15092 */
15093static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
15094 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
15095{
15096 int32_t len;
15097 int ret = 0;
15098 wmi_buf_t buf;
15099 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
15100
15101 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
15102
15103 buf = wmi_buf_alloc(wmi_handle, len);
15104 if (!buf) {
15105 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
15106 return QDF_STATUS_E_NOMEM;
15107 }
15108
15109 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
15110 WMITLV_SET_HDR(&cmd->tlv_header,
15111 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
15112 WMITLV_GET_STRUCT_TLVLEN(
15113 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
15114
15115 cmd->vdev_id = vdev_id;
15116 if (enable)
15117 cmd->enable = PACKET_FILTER_SET_ENABLE;
15118 else
15119 cmd->enable = PACKET_FILTER_SET_DISABLE;
15120
15121 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
15122 __func__, cmd->enable, vdev_id);
15123
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015124 wmi_mtrace(WMI_PACKET_FILTER_ENABLE_CMDID, cmd->vdev_id, 0);
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015125 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15126 WMI_PACKET_FILTER_ENABLE_CMDID);
15127 if (ret) {
15128 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
15129 wmi_buf_free(buf);
15130 }
15131
15132 return ret;
15133}
15134
15135/**
15136 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
15137 * @wmi_handle: wmi handle
15138 * @vdev_id: vdev id
15139 * @rcv_filter_param: Packet filter parameters
15140 * @filter_id: Filter id
15141 * @enable: Flag to add/delete packet filter configuration
15142 *
15143 * Return: QDF_STATUS_SUCCESS for success or error code
15144 */
15145static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
15146 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
15147 uint8_t filter_id, bool enable)
15148{
15149 int len, i;
15150 int err = 0;
15151 wmi_buf_t buf;
15152 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
15153
15154
15155 /* allocate the memory */
15156 len = sizeof(*cmd);
15157 buf = wmi_buf_alloc(wmi_handle, len);
15158 if (!buf) {
15159 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
15160 return QDF_STATUS_E_NOMEM;
15161 }
15162
15163 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
15164 WMITLV_SET_HDR(&cmd->tlv_header,
15165 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
15166 WMITLV_GET_STRUCT_TLVLEN
15167 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
15168
15169 cmd->vdev_id = vdev_id;
15170 cmd->filter_id = filter_id;
15171 if (enable)
15172 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
15173 else
15174 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
15175
15176 if (enable) {
15177 cmd->num_params = QDF_MIN(
15178 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
15179 rcv_filter_param->num_params);
15180 cmd->filter_type = rcv_filter_param->filter_type;
15181 cmd->coalesce_time = rcv_filter_param->coalesce_time;
15182
15183 for (i = 0; i < cmd->num_params; i++) {
15184 cmd->paramsData[i].proto_type =
15185 rcv_filter_param->params_data[i].protocol_layer;
15186 cmd->paramsData[i].cmp_type =
15187 rcv_filter_param->params_data[i].compare_flag;
15188 cmd->paramsData[i].data_length =
15189 rcv_filter_param->params_data[i].data_length;
15190 cmd->paramsData[i].data_offset =
15191 rcv_filter_param->params_data[i].data_offset;
15192 memcpy(&cmd->paramsData[i].compareData,
15193 rcv_filter_param->params_data[i].compare_data,
15194 sizeof(cmd->paramsData[i].compareData));
15195 memcpy(&cmd->paramsData[i].dataMask,
15196 rcv_filter_param->params_data[i].data_mask,
15197 sizeof(cmd->paramsData[i].dataMask));
15198 }
15199 }
15200
15201 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
15202 cmd->filter_action, cmd->filter_id, cmd->num_params);
15203 /* send the command along with data */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015204 wmi_mtrace(WMI_PACKET_FILTER_CONFIG_CMDID, cmd->vdev_id, 0);
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015205 err = wmi_unified_cmd_send(wmi_handle, buf, len,
15206 WMI_PACKET_FILTER_CONFIG_CMDID);
15207 if (err) {
15208 WMI_LOGE("Failed to send pkt_filter cmd");
15209 wmi_buf_free(buf);
15210 return QDF_STATUS_E_FAILURE;
15211 }
15212
15213 return QDF_STATUS_SUCCESS;
15214}
Rachit Kankaneed139ff2018-08-01 14:23:55 +053015215#endif /* End of WLAN_FEATURE_PACKET_FILTERING */
Wu Gao52c0b772018-05-17 16:14:00 +080015216#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015217
Govind Singha4836fd2016-03-07 16:45:38 +053015218/**
15219 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
15220 * @wmi_handle: wmi handle
15221 * @request: SSID hotlist set request
15222 *
Govind Singhb53420c2016-03-09 14:32:57 +053015223 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053015224 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015225static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053015226send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
15227 struct ssid_hotlist_request_params *request)
15228{
15229 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
15230 wmi_buf_t wmi_buf;
15231 uint32_t len;
15232 uint32_t array_size;
15233 uint8_t *buf_ptr;
15234
15235 /* length of fixed portion */
15236 len = sizeof(*cmd);
15237
15238 /* length of variable portion */
15239 array_size =
15240 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
15241 len += WMI_TLV_HDR_SIZE + array_size;
15242
15243 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15244 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015245 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15246 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015247 }
15248
15249 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
15250 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
15251 buf_ptr;
15252 WMITLV_SET_HDR
15253 (&cmd->tlv_header,
15254 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15255 WMITLV_GET_STRUCT_TLVLEN
15256 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15257
15258 cmd->request_id = request->request_id;
15259 cmd->requestor_id = 0;
15260 cmd->vdev_id = request->session_id;
15261 cmd->table_id = 0;
15262 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15263 cmd->total_entries = request->ssid_count;
15264 cmd->num_entries_in_page = request->ssid_count;
15265 cmd->first_entry_index = 0;
15266
15267 buf_ptr += sizeof(*cmd);
15268 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15269
15270 if (request->ssid_count) {
15271 wmi_extscan_hotlist_ssid_entry *entry;
15272 int i;
15273
15274 buf_ptr += WMI_TLV_HDR_SIZE;
15275 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15276 for (i = 0; i < request->ssid_count; i++) {
15277 WMITLV_SET_HDR
15278 (entry,
15279 WMITLV_TAG_ARRAY_STRUC,
15280 WMITLV_GET_STRUCT_TLVLEN
15281 (wmi_extscan_hotlist_ssid_entry));
15282 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015283 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015284 request->ssids[i].ssid.mac_ssid,
15285 request->ssids[i].ssid.length);
15286 entry->band = request->ssids[i].band;
15287 entry->min_rssi = request->ssids[i].rssi_low;
15288 entry->max_rssi = request->ssids[i].rssi_high;
15289 entry++;
15290 }
15291 cmd->mode = WMI_EXTSCAN_MODE_START;
15292 } else {
15293 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15294 }
15295
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015296 wmi_mtrace(WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID,
15297 cmd->vdev_id, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053015298 if (wmi_unified_cmd_send
15299 (wmi_handle, wmi_buf, len,
15300 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015301 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015302 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015303 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015304 }
15305
Govind Singhb53420c2016-03-09 14:32:57 +053015306 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015307}
15308
15309/**
15310 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15311 * @wmi_handle: wmi handle
15312 * @vdev_id: vdev id
15313 *
15314 * This function sends roam synch complete event to fw.
15315 *
15316 * Return: CDF STATUS
15317 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015318static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015319 uint8_t vdev_id)
15320{
15321 wmi_roam_synch_complete_fixed_param *cmd;
15322 wmi_buf_t wmi_buf;
15323 uint8_t *buf_ptr;
15324 uint16_t len;
15325 len = sizeof(wmi_roam_synch_complete_fixed_param);
15326
15327 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15328 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015329 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15330 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015331 }
15332 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15333 buf_ptr = (uint8_t *) cmd;
15334 WMITLV_SET_HDR(&cmd->tlv_header,
15335 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15336 WMITLV_GET_STRUCT_TLVLEN
15337 (wmi_roam_synch_complete_fixed_param));
15338 cmd->vdev_id = vdev_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015339 wmi_mtrace(WMI_ROAM_SYNCH_COMPLETE, cmd->vdev_id, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053015340 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15341 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015342 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015343 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015344 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015345 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015346 }
15347
Govind Singhb53420c2016-03-09 14:32:57 +053015348 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015349}
15350
15351/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015352 * send_fw_test_cmd_tlv() - send fw test command to fw.
15353 * @wmi_handle: wmi handle
15354 * @wmi_fwtest: fw test command
15355 *
15356 * This function sends fw test command to fw.
15357 *
15358 * Return: CDF STATUS
15359 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015360static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015361QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15362 struct set_fwtest_params *wmi_fwtest)
15363{
15364 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15365 wmi_buf_t wmi_buf;
15366 uint16_t len;
15367
15368 len = sizeof(*cmd);
15369
15370 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15371 if (!wmi_buf) {
15372 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15373 return QDF_STATUS_E_NOMEM;
15374 }
15375
15376 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15377 WMITLV_SET_HDR(&cmd->tlv_header,
15378 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15379 WMITLV_GET_STRUCT_TLVLEN(
15380 wmi_fwtest_set_param_cmd_fixed_param));
15381 cmd->param_id = wmi_fwtest->arg;
15382 cmd->param_value = wmi_fwtest->value;
15383
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015384 wmi_mtrace(WMI_FWTEST_CMDID, NO_SESSION, 0);
Anurag Chouhan459e0152016-07-22 20:19:54 +053015385 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15386 WMI_FWTEST_CMDID)) {
15387 WMI_LOGP("%s: failed to send fw test command", __func__);
15388 qdf_nbuf_free(wmi_buf);
15389 return QDF_STATUS_E_FAILURE;
15390 }
15391
15392 return QDF_STATUS_SUCCESS;
15393}
15394
15395/**
Govind Singha4836fd2016-03-07 16:45:38 +053015396 * send_unit_test_cmd_tlv() - send unit test command to fw.
15397 * @wmi_handle: wmi handle
15398 * @wmi_utest: unit test command
15399 *
15400 * This function send unit test command to fw.
15401 *
15402 * Return: CDF STATUS
15403 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015404static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015405 struct wmi_unit_test_cmd *wmi_utest)
15406{
15407 wmi_unit_test_cmd_fixed_param *cmd;
15408 wmi_buf_t wmi_buf;
15409 uint8_t *buf_ptr;
15410 int i;
15411 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015412 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015413
15414 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015415 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015416 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15417
15418 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15419 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015420 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15421 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015422 }
15423
15424 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15425 buf_ptr = (uint8_t *) cmd;
15426 WMITLV_SET_HDR(&cmd->tlv_header,
15427 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15428 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15429 cmd->vdev_id = wmi_utest->vdev_id;
15430 cmd->module_id = wmi_utest->module_id;
15431 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015432 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015433 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15434 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15435 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015436 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015437 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15438 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15439 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015440 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015441 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015442 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015443 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015444 }
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015445 wmi_mtrace(WMI_UNIT_TEST_CMDID, cmd->vdev_id, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053015446 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15447 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015448 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015449 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015450 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015451 }
15452
Govind Singhb53420c2016-03-09 14:32:57 +053015453 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015454}
15455
15456/**
15457 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15458 * @wmi_handle: wma handle
15459 * @roaminvoke: roam invoke command
15460 *
15461 * Send roam invoke command to fw for fastreassoc.
15462 *
15463 * Return: CDF STATUS
15464 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015465static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015466 struct wmi_roam_invoke_cmd *roaminvoke,
15467 uint32_t ch_hz)
15468{
15469 wmi_roam_invoke_cmd_fixed_param *cmd;
15470 wmi_buf_t wmi_buf;
15471 u_int8_t *buf_ptr;
15472 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015473 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015474 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015475 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015476
15477 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015478 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015479 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15480 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015481 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15482 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15483 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015484 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15485 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015486 }
15487
15488 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15489 buf_ptr = (u_int8_t *) cmd;
15490 WMITLV_SET_HDR(&cmd->tlv_header,
15491 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15492 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15493 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015494 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015495 if (roaminvoke->is_same_bssid)
15496 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15497 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015498
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015499 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015500 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015501 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15502 cmd->num_buf = 1;
15503 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015504 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015505 cmd->num_buf = 0;
15506 }
Naveen Rawat77797922017-01-20 17:00:07 -080015507
Govind Singha4836fd2016-03-07 16:45:38 +053015508 cmd->roam_ap_sel_mode = 0;
15509 cmd->roam_delay = 0;
15510 cmd->num_chan = 1;
15511 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015512
Govind Singha4836fd2016-03-07 16:45:38 +053015513 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15514 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15515 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015516 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015517 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015518 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015519 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15520 (sizeof(wmi_mac_addr)));
15521 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15522 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015523
15524 /* move to next tlv i.e. bcn_prb_buf_list */
15525 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15526
15527 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15528 sizeof(wmi_tlv_buf_len_param));
15529
15530 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15531 buf_len_tlv->buf_len = roaminvoke->frame_len;
15532
15533 /* move to next tlv i.e. bcn_prb_frm */
15534 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15535 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15536 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15537
15538 /* copy frame after the header */
15539 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15540 roaminvoke->frame_buf,
15541 roaminvoke->frame_len);
15542
15543 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070015544 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat77797922017-01-20 17:00:07 -080015545 buf_ptr + WMI_TLV_HDR_SIZE,
15546 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015547 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15548 cmd->flags, cmd->roam_scan_mode,
15549 cmd->roam_ap_sel_mode, cmd->roam_delay,
15550 cmd->num_chan, cmd->num_bssid);
15551 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015552
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015553 wmi_mtrace(WMI_ROAM_INVOKE_CMDID, cmd->vdev_id, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053015554 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15555 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015556 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015557 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015558 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015559 }
15560
Govind Singhb53420c2016-03-09 14:32:57 +053015561 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015562}
15563
15564/**
15565 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15566 * @wmi_handle: wmi handle
15567 * @command: command
15568 * @vdev_id: vdev id
15569 *
15570 * This function set roam offload command to fw.
15571 *
15572 * Return: CDF status
15573 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015574static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015575 uint32_t command, uint32_t vdev_id)
15576{
Govind Singh67922e82016-04-01 16:48:57 +053015577 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015578 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15579 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015580 int len;
15581 uint8_t *buf_ptr;
15582
15583 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15584 buf = wmi_buf_alloc(wmi_handle, len);
15585 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015586 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15587 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015588 }
15589
15590 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15591
15592 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15593 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15594 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15595 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15596 cmd_fp->vdev_id = vdev_id;
15597 cmd_fp->command_arg = command;
15598
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015599 wmi_mtrace(WMI_ROAM_SCAN_CMD, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053015600 status = wmi_unified_cmd_send(wmi_handle, buf,
15601 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015602 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015603 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015604 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015605 goto error;
15606 }
15607
Govind Singhb53420c2016-03-09 14:32:57 +053015608 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15609 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015610
15611error:
15612 wmi_buf_free(buf);
15613
Govind Singh67922e82016-04-01 16:48:57 +053015614 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015615}
15616
15617/**
15618 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15619 * @wmi_handle: wmi handle
15620 * @ap_profile_p: ap profile
15621 * @vdev_id: vdev id
15622 *
15623 * Send WMI_ROAM_AP_PROFILE to firmware
15624 *
15625 * Return: CDF status
15626 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015627static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015628 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015629{
Govind Singha4836fd2016-03-07 16:45:38 +053015630 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015631 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015632 int len;
15633 uint8_t *buf_ptr;
15634 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015635 wmi_roam_cnd_scoring_param *score_param;
15636 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015637
15638 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015639 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015640 buf = wmi_buf_alloc(wmi_handle, len);
15641 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015642 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15643 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015644 }
15645
15646 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15647 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15648 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15649 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15650 WMITLV_GET_STRUCT_TLVLEN
15651 (wmi_roam_ap_profile_fixed_param));
15652 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015653 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015654 roam_ap_profile_fp->id = 0;
15655 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15656
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015657 profile = (wmi_ap_profile *)buf_ptr;
15658 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015659 WMITLV_TAG_STRUC_wmi_ap_profile,
15660 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015661 profile->flags = ap_profile->profile.flags;
15662 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15663 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15664 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15665 profile->ssid.ssid_len);
15666 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15667 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15668 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15669 profile->rsn_mcastmgmtcipherset =
15670 ap_profile->profile.rsn_mcastmgmtcipherset;
15671 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15672
15673 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",
15674 profile->flags, profile->rssi_threshold,
15675 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15676 profile->rsn_authmode, profile->rsn_ucastcipherset,
15677 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15678 profile->rssi_abs_thresh);
15679
15680 buf_ptr += sizeof(wmi_ap_profile);
15681
15682 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15683 WMITLV_SET_HDR(&score_param->tlv_header,
15684 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15685 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15686 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15687 score_param->rssi_weightage_pcnt =
15688 ap_profile->param.rssi_weightage;
15689 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15690 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15691 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15692 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15693 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15694 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15695 score_param->esp_qbss_weightage_pcnt =
15696 ap_profile->param.esp_qbss_weightage;
15697 score_param->beamforming_weightage_pcnt =
15698 ap_profile->param.beamforming_weightage;
15699 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15700 score_param->oce_wan_weightage_pcnt =
15701 ap_profile->param.oce_wan_weightage;
15702
15703 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",
15704 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15705 score_param->ht_weightage_pcnt,
15706 score_param->vht_weightage_pcnt,
15707 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15708 score_param->band_weightage_pcnt,
15709 score_param->nss_weightage_pcnt,
15710 score_param->esp_qbss_weightage_pcnt,
15711 score_param->beamforming_weightage_pcnt,
15712 score_param->pcl_weightage_pcnt,
15713 score_param->oce_wan_weightage_pcnt);
15714
15715 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15716 score_param->band_scoring.score_pcnt =
15717 ap_profile->param.band_index_score;
15718 score_param->nss_scoring.score_pcnt =
15719 ap_profile->param.nss_index_score;
15720
15721 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15722 score_param->bw_scoring.score_pcnt,
15723 score_param->band_scoring.score_pcnt,
15724 score_param->nss_scoring.score_pcnt);
15725
15726 score_param->rssi_scoring.best_rssi_threshold =
15727 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15728 score_param->rssi_scoring.good_rssi_threshold =
15729 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15730 score_param->rssi_scoring.bad_rssi_threshold =
15731 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15732 score_param->rssi_scoring.good_rssi_pcnt =
15733 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15734 score_param->rssi_scoring.bad_rssi_pcnt =
15735 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15736 score_param->rssi_scoring.good_bucket_size =
15737 ap_profile->param.rssi_scoring.good_bucket_size;
15738 score_param->rssi_scoring.bad_bucket_size =
15739 ap_profile->param.rssi_scoring.bad_bucket_size;
15740 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15741 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15742
15743 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15744 score_param->rssi_scoring.best_rssi_threshold,
15745 score_param->rssi_scoring.good_rssi_threshold,
15746 score_param->rssi_scoring.bad_rssi_threshold,
15747 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15748 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15749 score_param->rssi_scoring.good_rssi_pcnt,
15750 score_param->rssi_scoring.bad_rssi_pcnt,
15751 score_param->rssi_scoring.good_bucket_size,
15752 score_param->rssi_scoring.bad_bucket_size);
15753
15754 score_param->esp_qbss_scoring.num_slot =
15755 ap_profile->param.esp_qbss_scoring.num_slot;
15756 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15757 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15758 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15759 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15760 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15761 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15762 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15763 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15764
15765 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15766 score_param->esp_qbss_scoring.num_slot,
15767 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15768 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15769 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15770 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15771
15772 score_param->oce_wan_scoring.num_slot =
15773 ap_profile->param.oce_wan_scoring.num_slot;
15774 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15775 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15776 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15777 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15778 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15779 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15780 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15781 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15782
15783 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15784 score_param->oce_wan_scoring.num_slot,
15785 score_param->oce_wan_scoring.score_pcnt3_to_0,
15786 score_param->oce_wan_scoring.score_pcnt7_to_4,
15787 score_param->oce_wan_scoring.score_pcnt11_to_8,
15788 score_param->oce_wan_scoring.score_pcnt15_to_12);
15789
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015790 wmi_mtrace(WMI_ROAM_AP_PROFILE, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053015791 status = wmi_unified_cmd_send(wmi_handle, buf,
15792 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015793 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015794 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015795 status);
Govind Singh67922e82016-04-01 16:48:57 +053015796 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015797 }
15798
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +053015799 WMI_LOGD("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015800
Govind Singh67922e82016-04-01 16:48:57 +053015801 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015802}
15803
15804/**
15805 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15806 * @wmi_handle: wmi handle
15807 * @scan_period: scan period
15808 * @scan_age: scan age
15809 * @vdev_id: vdev id
15810 *
15811 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15812 *
15813 * Return: CDF status
15814 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015815static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015816 uint32_t scan_period,
15817 uint32_t scan_age,
15818 uint32_t vdev_id)
15819{
Govind Singh67922e82016-04-01 16:48:57 +053015820 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015821 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015822 int len;
15823 uint8_t *buf_ptr;
15824 wmi_roam_scan_period_fixed_param *scan_period_fp;
15825
15826 /* Send scan period values */
15827 len = sizeof(wmi_roam_scan_period_fixed_param);
15828 buf = wmi_buf_alloc(wmi_handle, len);
15829 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015830 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15831 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015832 }
15833
15834 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15835 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15836 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15837 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15838 WMITLV_GET_STRUCT_TLVLEN
15839 (wmi_roam_scan_period_fixed_param));
15840 /* fill in scan period values */
15841 scan_period_fp->vdev_id = vdev_id;
15842 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15843 scan_period_fp->roam_scan_age = scan_age;
15844
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015845 wmi_mtrace(WMI_ROAM_SCAN_PERIOD, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053015846 status = wmi_unified_cmd_send(wmi_handle, buf,
15847 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015848 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015849 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015850 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015851 goto error;
15852 }
15853
Govind Singhb53420c2016-03-09 14:32:57 +053015854 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015855 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015856 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015857error:
15858 wmi_buf_free(buf);
15859
Govind Singh67922e82016-04-01 16:48:57 +053015860 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015861}
15862
15863/**
15864 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15865 * @wmi_handle: wmi handle
15866 * @chan_count: channel count
15867 * @chan_list: channel list
15868 * @list_type: list type
15869 * @vdev_id: vdev id
15870 *
15871 * Set roam offload channel list.
15872 *
15873 * Return: CDF status
15874 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015875static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015876 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015877 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015878 uint8_t list_type, uint32_t vdev_id)
15879{
Govind Singha4836fd2016-03-07 16:45:38 +053015880 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015881 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015882 int len, list_tlv_len;
15883 int i;
15884 uint8_t *buf_ptr;
15885 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053015886 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053015887
15888 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053015889 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053015890 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053015891 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053015892 }
15893 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053015894 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015895 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
15896 buf = wmi_buf_alloc(wmi_handle, len);
15897 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015898 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15899 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015900 }
15901
15902 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15903 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
15904 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
15905 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
15906 WMITLV_GET_STRUCT_TLVLEN
15907 (wmi_roam_chan_list_fixed_param));
15908 chan_list_fp->vdev_id = vdev_id;
15909 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053015910 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053015911 /* external app is controlling channel list */
15912 chan_list_fp->chan_list_type =
15913 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
15914 } else {
15915 /* umac supplied occupied channel list in LFR */
15916 chan_list_fp->chan_list_type =
15917 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
15918 }
15919
15920 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
15921 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15922 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015923 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015924 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053015925 for (i = 0; ((i < chan_list_fp->num_chan) &&
15926 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
15927 roam_chan_list_array[i] = chan_list[i];
Sandeep Puligilla412b36f2018-07-02 11:43:07 -070015928 WMI_LOGD("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015929 }
15930
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053015931 wmi_mtrace(WMI_ROAM_CHAN_LIST, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053015932 status = wmi_unified_cmd_send(wmi_handle, buf,
15933 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053015934 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015935 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015936 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015937 goto error;
15938 }
15939
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015940 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053015941 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015942error:
15943 wmi_buf_free(buf);
15944
Govind Singh67922e82016-04-01 16:48:57 +053015945 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015946}
15947
15948/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015949 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
15950 * @wmi_handle: wmi handle
15951 * @req_buf: per roam config buffer
15952 *
15953 * Return: QDF status
15954 */
15955static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
15956 struct wmi_per_roam_config_req *req_buf)
15957{
15958 wmi_buf_t buf = NULL;
15959 QDF_STATUS status;
15960 int len;
15961 uint8_t *buf_ptr;
15962 wmi_roam_per_config_fixed_param *wmi_per_config;
15963
15964 len = sizeof(wmi_roam_per_config_fixed_param);
15965 buf = wmi_buf_alloc(wmi_handle, len);
15966 if (!buf) {
15967 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15968 return QDF_STATUS_E_NOMEM;
15969 }
15970
15971 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15972 wmi_per_config =
15973 (wmi_roam_per_config_fixed_param *) buf_ptr;
15974 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
15975 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
15976 WMITLV_GET_STRUCT_TLVLEN
15977 (wmi_roam_per_config_fixed_param));
15978
15979 /* fill in per roam config values */
15980 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015981
15982 wmi_per_config->enable = req_buf->per_config.enable;
15983 wmi_per_config->high_rate_thresh =
15984 (req_buf->per_config.tx_high_rate_thresh << 16) |
15985 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
15986 wmi_per_config->low_rate_thresh =
15987 (req_buf->per_config.tx_low_rate_thresh << 16) |
15988 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
15989 wmi_per_config->pkt_err_rate_thresh_pct =
15990 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
15991 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
15992 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053015993 wmi_per_config->pkt_err_rate_mon_time =
15994 (req_buf->per_config.tx_per_mon_time << 16) |
15995 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053015996 wmi_per_config->min_candidate_rssi =
15997 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015998
15999 /* Send per roam config parameters */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016000 wmi_mtrace(WMI_ROAM_PER_CONFIG_CMDID, NO_SESSION, 0);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016001 status = wmi_unified_cmd_send(wmi_handle, buf,
16002 len, WMI_ROAM_PER_CONFIG_CMDID);
16003 if (QDF_IS_STATUS_ERROR(status)) {
16004 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
Sandeep Puligilla3dd74122018-08-18 12:42:41 -070016005 status);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016006 wmi_buf_free(buf);
16007 return status;
16008 }
Sandeep Puligilla3dd74122018-08-18 12:42:41 -070016009 WMI_LOGD(FL("per roam enable=%d, vdev=%d"),
16010 req_buf->per_config.enable, req_buf->vdev_id);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016011
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016012 return QDF_STATUS_SUCCESS;
16013}
16014
16015/**
Govind Singha4836fd2016-03-07 16:45:38 +053016016 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
16017 * @wmi_handle: wmi handle
16018 * @rssi_change_thresh: RSSI Change threshold
16019 * @bcn_rssi_weight: beacon RSSI weight
16020 * @vdev_id: vdev id
16021 *
16022 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
16023 *
16024 * Return: CDF status
16025 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016026static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016027 uint32_t vdev_id,
16028 int32_t rssi_change_thresh,
16029 uint32_t bcn_rssi_weight,
16030 uint32_t hirssi_delay_btw_scans)
16031{
Govind Singha4836fd2016-03-07 16:45:38 +053016032 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016033 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016034 int len;
16035 uint8_t *buf_ptr;
16036 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
16037
16038 /* Send rssi change parameters */
16039 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
16040 buf = wmi_buf_alloc(wmi_handle, len);
16041 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016042 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16043 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016044 }
16045
16046 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16047 rssi_change_fp =
16048 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
16049 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
16050 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
16051 WMITLV_GET_STRUCT_TLVLEN
16052 (wmi_roam_scan_rssi_change_threshold_fixed_param));
16053 /* fill in rssi change threshold (hysteresis) values */
16054 rssi_change_fp->vdev_id = vdev_id;
16055 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
16056 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
16057 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
16058
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016059 wmi_mtrace(WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +053016060 status = wmi_unified_cmd_send(wmi_handle, buf,
16061 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053016062 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016063 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016064 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016065 goto error;
16066 }
16067
Sandeep Puligilla3dd74122018-08-18 12:42:41 -070016068 WMI_LOGD(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
16069 rssi_change_thresh, bcn_rssi_weight);
16070 WMI_LOGD(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
Govind Singhb53420c2016-03-09 14:32:57 +053016071 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016072error:
16073 wmi_buf_free(buf);
16074
Govind Singh67922e82016-04-01 16:48:57 +053016075 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016076}
16077
Govind Singhbca3b1b2016-05-02 17:59:24 +053016078/**
16079 * send_power_dbg_cmd_tlv() - send power debug commands
16080 * @wmi_handle: wmi handle
16081 * @param: wmi power debug parameter
16082 *
16083 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
16084 *
16085 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16086 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016087static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
16088 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053016089{
16090 wmi_buf_t buf = NULL;
16091 QDF_STATUS status;
16092 int len, args_tlv_len;
16093 uint8_t *buf_ptr;
16094 uint8_t i;
16095 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
16096 uint32_t *cmd_args;
16097
16098 /* Prepare and send power debug cmd parameters */
16099 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
16100 len = sizeof(*cmd) + args_tlv_len;
16101 buf = wmi_buf_alloc(wmi_handle, len);
16102 if (!buf) {
16103 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16104 return QDF_STATUS_E_NOMEM;
16105 }
16106
16107 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16108 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
16109 WMITLV_SET_HDR(&cmd->tlv_header,
16110 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
16111 WMITLV_GET_STRUCT_TLVLEN
16112 (wmi_pdev_wal_power_debug_cmd_fixed_param));
16113
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016114 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16115 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016116 cmd->module_id = param->module_id;
16117 cmd->num_args = param->num_args;
16118 buf_ptr += sizeof(*cmd);
16119 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16120 (param->num_args * sizeof(uint32_t)));
16121 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
16122 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080016123 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053016124 cmd_args[i] = param->args[i];
16125 WMI_LOGI("%d,", param->args[i]);
16126 }
16127
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016128 wmi_mtrace(WMI_PDEV_WAL_POWER_DEBUG_CMDID, NO_SESSION, 0);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016129 status = wmi_unified_cmd_send(wmi_handle, buf,
16130 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
16131 if (QDF_IS_STATUS_ERROR(status)) {
16132 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
16133 status);
16134 goto error;
16135 }
16136
16137 return QDF_STATUS_SUCCESS;
16138error:
16139 wmi_buf_free(buf);
16140
16141 return status;
16142}
16143
Govind Singhe7f2f342016-05-23 12:12:52 +053016144/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016145 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
16146 * @wmi_handle: wmi handle
16147 * @param: wmi multiple vdev restart req param
16148 *
16149 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
16150 *
16151 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16152 */
16153static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
16154 wmi_unified_t wmi_handle,
16155 struct multiple_vdev_restart_params *param)
16156{
16157 wmi_buf_t buf;
16158 QDF_STATUS qdf_status;
16159 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
16160 int i;
16161 uint8_t *buf_ptr;
16162 uint32_t *vdev_ids;
16163 wmi_channel *chan_info;
16164 struct channel_param *tchan_info;
16165 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
16166
16167 len += sizeof(wmi_channel);
16168 if (param->num_vdevs)
16169 len += sizeof(uint32_t) * param->num_vdevs;
16170
16171 buf = wmi_buf_alloc(wmi_handle, len);
16172 if (!buf) {
16173 WMI_LOGE("Failed to allocate memory\n");
16174 qdf_status = QDF_STATUS_E_NOMEM;
16175 goto end;
16176 }
16177
16178 buf_ptr = (uint8_t *)wmi_buf_data(buf);
16179 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
16180 buf_ptr;
16181
16182 WMITLV_SET_HDR(&cmd->tlv_header,
16183 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
16184 WMITLV_GET_STRUCT_TLVLEN
16185 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016186 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16187 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016188 cmd->requestor_id = param->requestor_id;
16189 cmd->disable_hw_ack = param->disable_hw_ack;
16190 cmd->cac_duration_ms = param->cac_duration_ms;
16191 cmd->num_vdevs = param->num_vdevs;
16192
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016193 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
16194 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
16195 " cmd->num_vdevs: %d ",
16196 __func__, cmd->pdev_id, cmd->requestor_id,
16197 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016198 buf_ptr += sizeof(*cmd);
16199
16200 WMITLV_SET_HDR(buf_ptr,
16201 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053016202 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016203 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
16204 for (i = 0; i < param->num_vdevs; i++) {
16205 vdev_ids[i] = param->vdev_ids[i];
16206 }
16207
Vivekc5823092018-03-22 23:27:21 +053016208 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016209
16210 WMITLV_SET_HDR(buf_ptr,
16211 WMITLV_TAG_STRUC_wmi_channel,
16212 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053016213 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016214 tchan_info = &(param->ch_param);
16215 chan_info->mhz = tchan_info->mhz;
16216 chan_info->band_center_freq1 = tchan_info->cfreq1;
16217 chan_info->band_center_freq2 = tchan_info->cfreq2;
16218 if (tchan_info->is_chan_passive)
16219 WMI_SET_CHANNEL_FLAG(chan_info,
16220 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016221 if (tchan_info->dfs_set)
16222 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
16223
Sathish Kumar45e991b2017-02-27 10:35:40 +053016224 if (tchan_info->allow_vht)
16225 WMI_SET_CHANNEL_FLAG(chan_info,
16226 WMI_CHAN_FLAG_ALLOW_VHT);
16227 else if (tchan_info->allow_ht)
16228 WMI_SET_CHANNEL_FLAG(chan_info,
16229 WMI_CHAN_FLAG_ALLOW_HT);
16230 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
16231 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
16232 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
16233 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
16234 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
16235 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080016236 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016237
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016238 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
16239 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
16240 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
16241 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
16242 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
16243 "tchan_info->reg_class_id: %d ,"
16244 "tchan_info->maxregpower : %d ", __func__,
16245 tchan_info->is_chan_passive, tchan_info->dfs_set,
16246 tchan_info->allow_vht, tchan_info->allow_ht,
16247 tchan_info->antennamax, tchan_info->phy_mode,
16248 tchan_info->minpower, tchan_info->maxpower,
16249 tchan_info->maxregpower, tchan_info->reg_class_id,
16250 tchan_info->maxregpower);
16251
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016252 wmi_mtrace(WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID, NO_SESSION, 0);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016253 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
16254 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
16255
16256 if (QDF_IS_STATUS_ERROR(qdf_status)) {
16257 WMI_LOGE("%s: Failed to send\n", __func__);
16258 wmi_buf_free(buf);
16259 }
16260
16261end:
16262 return qdf_status;
16263}
16264
16265/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080016266 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
16267 * @wmi_handle: wmi handle
16268 * @pdev_id: pdev id
16269 *
16270 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16271 *
16272 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16273 */
16274static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16275 uint32_t pdev_id)
16276{
16277 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16278 wmi_buf_t buf;
16279 uint16_t len;
16280 QDF_STATUS ret;
16281
16282 len = sizeof(*cmd);
16283 buf = wmi_buf_alloc(wmi_handle, len);
16284
16285 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16286
16287 if (!buf) {
16288 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16289 return QDF_STATUS_E_NOMEM;
16290 }
16291
16292 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16293 wmi_buf_data(buf);
16294
16295 WMITLV_SET_HDR(&cmd->tlv_header,
16296 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16297 WMITLV_GET_STRUCT_TLVLEN(
16298 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16299
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016300 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016301 wmi_mtrace(WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID, NO_SESSION, 0);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016302 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16303 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16304 if (QDF_IS_STATUS_ERROR(ret)) {
16305 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16306 __func__, ret, pdev_id);
16307 wmi_buf_free(buf);
16308 return QDF_STATUS_E_FAILURE;
16309 }
16310
16311 return QDF_STATUS_SUCCESS;
16312}
16313
16314/**
16315 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16316 * @wmi_handle: wmi handle
16317 * @pdev_id: pdev id
16318 *
16319 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16320 *
16321 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16322 */
16323static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16324 uint32_t pdev_id)
16325{
16326 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16327 wmi_buf_t buf;
16328 uint16_t len;
16329 QDF_STATUS ret;
16330
16331 len = sizeof(*cmd);
16332 buf = wmi_buf_alloc(wmi_handle, len);
16333
16334 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16335
16336 if (!buf) {
16337 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16338 return QDF_STATUS_E_NOMEM;
16339 }
16340
16341 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16342 wmi_buf_data(buf);
16343
16344 WMITLV_SET_HDR(&cmd->tlv_header,
16345 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16346 WMITLV_GET_STRUCT_TLVLEN(
16347 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16348
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016349 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016350 wmi_mtrace(WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID, NO_SESSION, 0);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016351 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16352 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16353 if (QDF_IS_STATUS_ERROR(ret)) {
16354 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16355 __func__, ret, pdev_id);
16356 wmi_buf_free(buf);
16357 return QDF_STATUS_E_FAILURE;
16358 }
16359
16360 return QDF_STATUS_SUCCESS;
16361}
16362
16363/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016364 * init_cmd_send_tlv() - send initialization cmd to fw
16365 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016366 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016367 *
16368 * Return: QDF_STATUS_SUCCESS for success or error code
16369 */
16370static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016371 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016372{
16373 wmi_buf_t buf;
16374 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016375 uint8_t *buf_ptr;
16376 wmi_resource_config *resource_cfg;
16377 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016378 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016379 uint16_t idx;
16380 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016381 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016382
Kiran Venkatappa26117052016-12-23 19:58:54 +053016383 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16384 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016385 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016386
16387 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16388 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16389 WMI_TLV_HDR_SIZE +
16390 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16391
16392 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016393 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053016394 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053016395 return QDF_STATUS_E_FAILURE;
16396 }
16397
16398 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16399 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16400 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16401
16402 host_mem_chunks = (wlan_host_memory_chunk *)
16403 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16404 + WMI_TLV_HDR_SIZE);
16405
16406 WMITLV_SET_HDR(&cmd->tlv_header,
16407 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16408 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16409
Kiran Venkatappa26117052016-12-23 19:58:54 +053016410 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016411 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16412 WMITLV_TAG_STRUC_wmi_resource_config,
16413 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16414
Kiran Venkatappa26117052016-12-23 19:58:54 +053016415 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016416 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16417 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16418 WMITLV_GET_STRUCT_TLVLEN
16419 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016420 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16421 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16422 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016423 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16424 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016425 idx, host_mem_chunks[idx].size,
16426 host_mem_chunks[idx].ptr);
16427 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016428 cmd->num_host_mem_chunks = param->num_mem_chunks;
16429 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16430
Govind Singhe7f2f342016-05-23 12:12:52 +053016431 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16432 WMITLV_TAG_ARRAY_STRUC,
16433 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016434 param->num_mem_chunks));
16435
16436 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016437 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016438
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016439 /* Fill fw_abi_vers */
16440 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016441
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016442 wmi_mtrace(WMI_INIT_CMDID, NO_SESSION, 0);
Abhishek Singh716c46c2016-05-04 16:24:07 +053016443 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16444 if (QDF_IS_STATUS_ERROR(ret)) {
16445 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16446 ret);
16447 wmi_buf_free(buf);
16448 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016449
Abhishek Singh716c46c2016-05-04 16:24:07 +053016450 return ret;
16451
Govind Singhe7f2f342016-05-23 12:12:52 +053016452}
16453
16454/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016455 * send_addba_send_cmd_tlv() - send addba send command to fw
16456 * @wmi_handle: wmi handle
16457 * @param: pointer to delba send params
16458 * @macaddr: peer mac address
16459 *
16460 * Send WMI_ADDBA_SEND_CMDID command to firmware
16461 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16462 */
16463static QDF_STATUS
16464send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
16465 uint8_t macaddr[IEEE80211_ADDR_LEN],
16466 struct addba_send_params *param)
16467{
16468 wmi_addba_send_cmd_fixed_param *cmd;
16469 wmi_buf_t buf;
16470 uint16_t len;
16471 QDF_STATUS ret;
16472
16473 len = sizeof(*cmd);
16474
16475 buf = wmi_buf_alloc(wmi_handle, len);
16476 if (!buf) {
16477 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16478 return QDF_STATUS_E_NOMEM;
16479 }
16480
16481 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
16482
16483 WMITLV_SET_HDR(&cmd->tlv_header,
16484 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
16485 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
16486
16487 cmd->vdev_id = param->vdev_id;
16488 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16489 cmd->tid = param->tidno;
16490 cmd->buffersize = param->buffersize;
16491
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016492 wmi_mtrace(WMI_ADDBA_SEND_CMDID, cmd->vdev_id, 0);
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016493 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
16494 if (QDF_IS_STATUS_ERROR(ret)) {
16495 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16496 wmi_buf_free(buf);
16497 return QDF_STATUS_E_FAILURE;
16498 }
16499
16500 return QDF_STATUS_SUCCESS;
16501}
16502
16503/**
16504 * send_delba_send_cmd_tlv() - send delba send command to fw
16505 * @wmi_handle: wmi handle
16506 * @param: pointer to delba send params
16507 * @macaddr: peer mac address
16508 *
16509 * Send WMI_DELBA_SEND_CMDID command to firmware
16510 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16511 */
16512static QDF_STATUS
16513send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
16514 uint8_t macaddr[IEEE80211_ADDR_LEN],
16515 struct delba_send_params *param)
16516{
16517 wmi_delba_send_cmd_fixed_param *cmd;
16518 wmi_buf_t buf;
16519 uint16_t len;
16520 QDF_STATUS ret;
16521
16522 len = sizeof(*cmd);
16523
16524 buf = wmi_buf_alloc(wmi_handle, len);
16525 if (!buf) {
16526 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16527 return QDF_STATUS_E_NOMEM;
16528 }
16529
16530 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
16531
16532 WMITLV_SET_HDR(&cmd->tlv_header,
16533 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
16534 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
16535
16536 cmd->vdev_id = param->vdev_id;
16537 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16538 cmd->tid = param->tidno;
16539 cmd->initiator = param->initiator;
16540 cmd->reasoncode = param->reasoncode;
16541
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016542 wmi_mtrace(WMI_DELBA_SEND_CMDID, cmd->vdev_id, 0);
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016543 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
16544 if (QDF_IS_STATUS_ERROR(ret)) {
16545 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16546 wmi_buf_free(buf);
16547 return QDF_STATUS_E_FAILURE;
16548 }
16549
16550 return QDF_STATUS_SUCCESS;
16551}
16552
16553/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016554 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
16555 * to fw
16556 * @wmi_handle: wmi handle
16557 * @param: pointer to addba clearresp params
16558 * @macaddr: peer mac address
16559 * Return: 0 for success or error code
16560 */
16561static QDF_STATUS
16562send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
16563 uint8_t macaddr[IEEE80211_ADDR_LEN],
16564 struct addba_clearresponse_params *param)
16565{
16566 wmi_addba_clear_resp_cmd_fixed_param *cmd;
16567 wmi_buf_t buf;
16568 uint16_t len;
16569 QDF_STATUS ret;
16570
16571 len = sizeof(*cmd);
16572
16573 buf = wmi_buf_alloc(wmi_handle, len);
16574 if (!buf) {
16575 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
16576 return QDF_STATUS_E_FAILURE;
16577 }
16578 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
16579
16580 WMITLV_SET_HDR(&cmd->tlv_header,
16581 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
16582 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
16583
16584 cmd->vdev_id = param->vdev_id;
16585 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16586
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016587 wmi_mtrace(WMI_ADDBA_CLEAR_RESP_CMDID, cmd->vdev_id, 0);
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016588 ret = wmi_unified_cmd_send(wmi_handle,
16589 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
16590 if (QDF_IS_STATUS_ERROR(ret)) {
16591 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16592 wmi_buf_free(buf);
16593 return QDF_STATUS_E_FAILURE;
16594 }
16595
16596 return QDF_STATUS_SUCCESS;
16597}
16598
16599/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016600 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16601 * @wmi_handle: wmi handle
16602 * @bcn_ctrl_param: pointer to bcn_offload_control param
16603 *
16604 * Return: QDF_STATUS_SUCCESS for success or error code
16605 */
16606static
16607QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16608 struct bcn_offload_control *bcn_ctrl_param)
16609{
16610 wmi_buf_t buf;
16611 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16612 QDF_STATUS ret;
16613 uint32_t len;
16614
16615 len = sizeof(*cmd);
16616
16617 buf = wmi_buf_alloc(wmi_handle, len);
16618 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053016619 qdf_print("%s: wmi_buf_alloc failed", __func__);
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016620 return QDF_STATUS_E_FAILURE;
16621 }
16622
16623 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16624 WMITLV_SET_HDR(&cmd->tlv_header,
16625 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16626 WMITLV_GET_STRUCT_TLVLEN
16627 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16628 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016629 switch (bcn_ctrl_param->bcn_ctrl_op) {
16630 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016631 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016632 break;
16633 case BCN_OFFLD_CTRL_TX_ENABLE:
16634 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16635 break;
16636 case BCN_OFFLD_CTRL_SWBA_DISABLE:
16637 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
16638 break;
16639 case BCN_OFFLD_CTRL_SWBA_ENABLE:
16640 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
16641 break;
16642 default:
16643 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
16644 bcn_ctrl_param->bcn_ctrl_op);
16645 wmi_buf_free(buf);
16646 return QDF_STATUS_E_FAILURE;
16647 break;
16648 }
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016649 wmi_mtrace(WMI_BCN_OFFLOAD_CTRL_CMDID, cmd->vdev_id, 0);
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016650 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16651 WMI_BCN_OFFLOAD_CTRL_CMDID);
16652
16653 if (QDF_IS_STATUS_ERROR(ret)) {
16654 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16655 ret);
16656 wmi_buf_free(buf);
16657 }
16658
16659 return ret;
16660}
16661
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016662#ifdef WLAN_FEATURE_NAN_CONVERGENCE
16663static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
16664 struct nan_datapath_initiator_req *ndp_req)
16665{
16666 uint16_t len;
16667 wmi_buf_t buf;
16668 uint8_t *tlv_ptr;
16669 QDF_STATUS status;
16670 wmi_channel *ch_tlv;
16671 wmi_ndp_initiator_req_fixed_param *cmd;
16672 uint32_t passphrase_len, service_name_len;
16673 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016674 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016675
16676 /*
16677 * WMI command expects 4 byte alligned len:
16678 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16679 */
16680 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
16681 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
16682 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
16683 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
16684 service_name_len =
16685 qdf_roundup(ndp_req->service_name.service_name_len, 4);
16686 /* allocated memory for fixed params as well as variable size data */
16687 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
16688 + ndp_cfg_len + ndp_app_info_len + pmk_len
16689 + passphrase_len + service_name_len;
16690
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016691 if (ndp_req->is_ipv6_addr_present)
16692 len += sizeof(*tcp_ip_param);
16693
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016694 buf = wmi_buf_alloc(wmi_handle, len);
16695 if (!buf) {
16696 WMI_LOGE("wmi_buf_alloc failed");
16697 return QDF_STATUS_E_NOMEM;
16698 }
16699
16700 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
16701 WMITLV_SET_HDR(&cmd->tlv_header,
16702 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
16703 WMITLV_GET_STRUCT_TLVLEN(
16704 wmi_ndp_initiator_req_fixed_param));
16705 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
16706 cmd->transaction_id = ndp_req->transaction_id;
16707 cmd->service_instance_id = ndp_req->service_instance_id;
16708 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
16709 &cmd->peer_discovery_mac_addr);
16710
16711 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
16712 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
16713 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
16714 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
16715 cmd->nan_csid = ndp_req->ncs_sk_type;
16716 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
16717 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
16718
16719 ch_tlv = (wmi_channel *)&cmd[1];
16720 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
16721 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
16722 ch_tlv->mhz = ndp_req->channel;
16723 tlv_ptr = (uint8_t *)&ch_tlv[1];
16724
16725 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16726 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16727 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16728 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16729
16730 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16731 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16732 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
16733 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16734
16735 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16736 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
16737 cmd->nan_pmk_len);
16738 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16739
16740 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16741 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
16742 cmd->nan_passphrase_len);
16743 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16744
16745 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16746 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16747 ndp_req->service_name.service_name,
16748 cmd->nan_servicename_len);
16749 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16750
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016751 if (ndp_req->is_ipv6_addr_present) {
16752 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16753 WMITLV_SET_HDR(tcp_ip_param,
16754 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16755 WMITLV_GET_STRUCT_TLVLEN(
16756 wmi_ndp_transport_ip_param));
16757 tcp_ip_param->ipv6_addr_present = true;
16758 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16759 ndp_req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16760 }
16761 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16762 ndp_req->is_ipv6_addr_present, ndp_req->ipv6_addr);
16763
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016764 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
16765 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
16766 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
16767 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16768 cmd->peer_discovery_mac_addr.mac_addr31to0,
16769 cmd->peer_discovery_mac_addr.mac_addr47to32);
16770
16771 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016772 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016773 ndp_req->ndp_config.ndp_cfg,
16774 ndp_req->ndp_config.ndp_cfg_len);
16775
16776 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016777 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016778 ndp_req->ndp_info.ndp_app_info,
16779 ndp_req->ndp_info.ndp_app_info_len);
16780
16781 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016782 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016783 ndp_req->pmk.pmk, cmd->nan_pmk_len);
16784
16785 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016786 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016787 ndp_req->passphrase.passphrase,
16788 cmd->nan_passphrase_len);
16789
16790 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016791 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016792 ndp_req->service_name.service_name,
16793 cmd->nan_servicename_len);
16794
16795 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
16796 WMI_NDP_INITIATOR_REQ_CMDID);
16797
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016798 wmi_mtrace(WMI_NDP_INITIATOR_REQ_CMDID, cmd->vdev_id, 0);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016799 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16800 WMI_NDP_INITIATOR_REQ_CMDID);
16801 if (QDF_IS_STATUS_ERROR(status)) {
16802 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
16803 wmi_buf_free(buf);
16804 }
16805
16806 return status;
16807}
16808
16809static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
16810 struct nan_datapath_responder_req *req)
16811{
16812 uint16_t len;
16813 wmi_buf_t buf;
16814 uint8_t *tlv_ptr;
16815 QDF_STATUS status;
16816 wmi_ndp_responder_req_fixed_param *cmd;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016817 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016818 uint32_t passphrase_len, service_name_len;
16819 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
16820
16821 vdev_id = wlan_vdev_get_id(req->vdev);
16822 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
16823 vdev_id, req->transaction_id,
16824 req->ndp_rsp,
16825 req->ndp_instance_id,
16826 req->ndp_info.ndp_app_info_len);
16827
16828 /*
16829 * WMI command expects 4 byte alligned len:
16830 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16831 */
16832 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
16833 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
16834 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
16835 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
16836 service_name_len =
16837 qdf_roundup(req->service_name.service_name_len, 4);
16838
16839 /* allocated memory for fixed params as well as variable size data */
16840 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
16841 + pmk_len + passphrase_len + service_name_len;
16842
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016843 if (req->is_ipv6_addr_present || req->is_port_present ||
16844 req->is_protocol_present)
16845 len += sizeof(*tcp_ip_param);
16846
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016847 buf = wmi_buf_alloc(wmi_handle, len);
16848 if (!buf) {
16849 WMI_LOGE("wmi_buf_alloc failed");
16850 return QDF_STATUS_E_NOMEM;
16851 }
16852 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
16853 WMITLV_SET_HDR(&cmd->tlv_header,
16854 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
16855 WMITLV_GET_STRUCT_TLVLEN(
16856 wmi_ndp_responder_req_fixed_param));
16857 cmd->vdev_id = vdev_id;
16858 cmd->transaction_id = req->transaction_id;
16859 cmd->ndp_instance_id = req->ndp_instance_id;
16860 cmd->rsp_code = req->ndp_rsp;
16861 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
16862 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
16863 cmd->nan_pmk_len = req->pmk.pmk_len;
16864 cmd->nan_csid = req->ncs_sk_type;
16865 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
16866 cmd->nan_servicename_len = req->service_name.service_name_len;
16867
16868 tlv_ptr = (uint8_t *)&cmd[1];
16869 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16870 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16871 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16872
16873 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16874 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16875 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16876 req->ndp_info.ndp_app_info,
16877 req->ndp_info.ndp_app_info_len);
16878
16879 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16880 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16881 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
16882 cmd->nan_pmk_len);
16883
16884 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16885 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16886 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16887 req->passphrase.passphrase,
16888 cmd->nan_passphrase_len);
16889 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16890
16891 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16892 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16893 req->service_name.service_name,
16894 cmd->nan_servicename_len);
16895
16896 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16897
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016898 if (req->is_ipv6_addr_present || req->is_port_present ||
16899 req->is_protocol_present) {
16900 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16901 WMITLV_SET_HDR(tcp_ip_param,
16902 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16903 WMITLV_GET_STRUCT_TLVLEN(
16904 wmi_ndp_transport_ip_param));
16905 tcp_ip_param->ipv6_addr_present = req->is_ipv6_addr_present;
16906 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16907 req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16908
16909 tcp_ip_param->trans_port_present = req->is_port_present;
16910 tcp_ip_param->transport_port = req->port;
16911
16912 tcp_ip_param->trans_proto_present = req->is_protocol_present;
16913 tcp_ip_param->transport_protocol = req->protocol;
16914 }
16915 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16916 req->is_ipv6_addr_present, req->ipv6_addr);
16917 WMI_LOGD(FL("port: %d present: %d"), req->is_port_present, req->port);
16918 WMI_LOGD(FL("protocol: %d present: %d"),
16919 req->is_protocol_present, req->protocol);
16920
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016921 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
16922 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
16923
16924 WMI_LOGD("ndp_config len: %d",
16925 req->ndp_config.ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016926 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016927 req->ndp_config.ndp_cfg,
16928 req->ndp_config.ndp_cfg_len);
16929
16930 WMI_LOGD("ndp_app_info len: %d",
16931 req->ndp_info.ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016932 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016933 req->ndp_info.ndp_app_info,
16934 req->ndp_info.ndp_app_info_len);
16935
16936 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016937 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016938 req->pmk.pmk, cmd->nan_pmk_len);
16939
16940 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016941 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016942 req->passphrase.passphrase,
16943 cmd->nan_passphrase_len);
16944
16945 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016946 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016947 req->service_name.service_name,
16948 cmd->nan_servicename_len);
16949
16950 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
16951 WMI_NDP_RESPONDER_REQ_CMDID);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053016952 wmi_mtrace(WMI_NDP_RESPONDER_REQ_CMDID, cmd->vdev_id, 0);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016953 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16954 WMI_NDP_RESPONDER_REQ_CMDID);
16955 if (QDF_IS_STATUS_ERROR(status)) {
16956 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
16957 wmi_buf_free(buf);
16958 }
16959 return status;
16960}
16961
16962static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
16963 struct nan_datapath_end_req *req)
16964{
16965 uint16_t len;
16966 wmi_buf_t buf;
16967 QDF_STATUS status;
16968 uint32_t ndp_end_req_len, i;
16969 wmi_ndp_end_req *ndp_end_req_lst;
16970 wmi_ndp_end_req_fixed_param *cmd;
16971
16972 /* len of tlv following fixed param */
16973 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
16974 /* above comes out to 4 byte alligned already, no need of padding */
16975 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
16976 buf = wmi_buf_alloc(wmi_handle, len);
16977 if (!buf) {
16978 WMI_LOGE("Malloc failed");
16979 return QDF_STATUS_E_NOMEM;
16980 }
16981
16982 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
16983 WMITLV_SET_HDR(&cmd->tlv_header,
16984 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
16985 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
16986
16987 cmd->transaction_id = req->transaction_id;
16988
16989 /* set tlv pointer to end of fixed param */
16990 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
16991 ndp_end_req_len);
16992
16993 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
16994 WMI_TLV_HDR_SIZE);
16995 for (i = 0; i < req->num_ndp_instances; i++) {
16996 WMITLV_SET_HDR(&ndp_end_req_lst[i],
16997 WMITLV_TAG_ARRAY_FIXED_STRUC,
16998 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
16999
17000 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
17001 }
17002
17003 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053017004 wmi_mtrace(WMI_NDP_END_REQ_CMDID, NO_SESSION, 0);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017005 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17006 WMI_NDP_END_REQ_CMDID);
17007 if (QDF_IS_STATUS_ERROR(status)) {
17008 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
17009 wmi_buf_free(buf);
17010 }
17011
17012 return status;
17013}
17014
17015static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017016 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017017{
17018 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
17019 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
17020
17021 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
17022 fixed_params = event->fixed_param;
17023
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017024 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017025 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17026 fixed_params->vdev_id,
17027 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017028 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017029 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017030 return QDF_STATUS_E_INVAL;
17031 }
17032
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017033 rsp->transaction_id = fixed_params->transaction_id;
17034 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17035 rsp->status = fixed_params->rsp_status;
17036 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017037
17038 return QDF_STATUS_SUCCESS;
17039}
17040
17041static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017042 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017043{
17044 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
17045 wmi_ndp_indication_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080017046 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017047
17048 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
17049 fixed_params =
17050 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
17051
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017052 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17053 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17054 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17055 return QDF_STATUS_E_INVAL;
17056 }
17057
17058 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17059 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17060 fixed_params->ndp_app_info_len,
17061 event->num_ndp_app_info);
17062 return QDF_STATUS_E_INVAL;
17063 }
17064
gaolezab037cf2018-05-23 14:40:32 +080017065 if (fixed_params->ndp_cfg_len >
17066 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
17067 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
17068 __func__, fixed_params->ndp_cfg_len);
17069 return QDF_STATUS_E_INVAL;
17070 }
17071
17072 total_array_len = fixed_params->ndp_cfg_len +
17073 sizeof(*fixed_params);
17074
17075 if (fixed_params->ndp_app_info_len >
17076 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
17077 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
17078 __func__, fixed_params->ndp_app_info_len);
17079 return QDF_STATUS_E_INVAL;
17080 }
17081 total_array_len += fixed_params->ndp_app_info_len;
17082
17083 if (fixed_params->nan_scid_len >
17084 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
17085 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
17086 __func__, fixed_params->nan_scid_len);
17087 return QDF_STATUS_E_INVAL;
17088 }
17089
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017090 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017091 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17092 fixed_params->vdev_id,
17093 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017094 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017095 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017096 return QDF_STATUS_E_INVAL;
17097 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017098 rsp->service_instance_id = fixed_params->service_instance_id;
17099 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17100 rsp->role = fixed_params->self_ndp_role;
17101 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017102
17103 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017104 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017105 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017106 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017107
17108 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
17109 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
17110 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
17111 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
17112 fixed_params->service_instance_id,
17113 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
17114 fixed_params->accept_policy,
17115 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017116 rsp->peer_mac_addr.bytes,
17117 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017118
17119 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070017120 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017121 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17122
17123 WMI_LOGD("ndp_app_info - %d bytes",
17124 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070017125 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017126 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17127
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017128 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
17129 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17130 rsp->ncs_sk_type = fixed_params->nan_csid;
17131 rsp->scid.scid_len = fixed_params->nan_scid_len;
Lihua Liue950ad12018-07-02 18:55:56 +080017132
17133 if (rsp->ndp_config.ndp_cfg_len > NDP_QOS_INFO_LEN)
17134 rsp->ndp_config.ndp_cfg_len = NDP_QOS_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017135 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
17136 rsp->ndp_config.ndp_cfg_len);
Lihua Liue950ad12018-07-02 18:55:56 +080017137
17138 if (rsp->ndp_info.ndp_app_info_len > NDP_APP_INFO_LEN)
17139 rsp->ndp_info.ndp_app_info_len = NDP_APP_INFO_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017140 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
17141 rsp->ndp_info.ndp_app_info_len);
Lihua Liue950ad12018-07-02 18:55:56 +080017142
17143 if (rsp->scid.scid_len > NDP_SCID_BUF_LEN)
17144 rsp->scid.scid_len = NDP_SCID_BUF_LEN;
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017145 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070017146
17147 if (event->ndp_transport_ip_param &&
17148 event->num_ndp_transport_ip_param) {
17149 if (event->ndp_transport_ip_param->ipv6_addr_present) {
17150 rsp->is_ipv6_addr_present = true;
17151 qdf_mem_copy(rsp->ipv6_addr,
17152 event->ndp_transport_ip_param->ipv6_intf_addr,
17153 WMI_NDP_IPV6_INTF_ADDR_LEN);
17154 }
17155 }
17156 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
17157 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
17158
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017159 WMI_LOGD("scid hex dump:");
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070017160 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017161 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017162
17163 return QDF_STATUS_SUCCESS;
17164}
17165
17166static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017167 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017168{
Naveen Rawat38b21462018-05-31 15:04:16 -070017169 uint8_t i;
17170 WMI_HOST_WLAN_PHY_MODE ch_mode;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017171 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
17172 wmi_ndp_confirm_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080017173 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017174
17175 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
17176 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017177 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 -080017178 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
17179 fixed_params->ndp_instance_id, fixed_params->rsp_code,
17180 fixed_params->reason_code,
17181 fixed_params->num_active_ndps_on_peer);
Naveen Rawat38b21462018-05-31 15:04:16 -070017182 WMI_LOGE("num_ch: %d", fixed_params->num_ndp_channels);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017183
17184 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17185 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17186 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17187 return QDF_STATUS_E_INVAL;
17188 }
17189
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017190 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070017191 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017192 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17193
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017194 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17195 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17196 fixed_params->ndp_app_info_len,
17197 event->num_ndp_app_info);
17198 return QDF_STATUS_E_INVAL;
17199 }
17200
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017201 WMI_LOGD("ndp_app_info - %d bytes",
17202 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070017203 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017204 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17205
gaolezab037cf2018-05-23 14:40:32 +080017206 if (fixed_params->ndp_cfg_len >
17207 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
17208 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
17209 __func__, fixed_params->ndp_cfg_len);
17210 return QDF_STATUS_E_INVAL;
17211 }
17212
17213 total_array_len = fixed_params->ndp_cfg_len +
17214 sizeof(*fixed_params);
17215
17216 if (fixed_params->ndp_app_info_len >
17217 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
17218 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
17219 __func__, fixed_params->ndp_app_info_len);
17220 return QDF_STATUS_E_INVAL;
17221 }
17222
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017223 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017224 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17225 fixed_params->vdev_id,
17226 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017227 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017228 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017229 return QDF_STATUS_E_INVAL;
17230 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017231 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17232 rsp->rsp_code = fixed_params->rsp_code;
17233 rsp->reason_code = fixed_params->reason_code;
17234 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat38b21462018-05-31 15:04:16 -070017235 rsp->num_channels = fixed_params->num_ndp_channels;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017236 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017237 rsp->peer_ndi_mac_addr.bytes);
17238 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17239 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
17240 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017241
Naveen Rawat38b21462018-05-31 15:04:16 -070017242 if (rsp->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
17243 WMI_LOGE(FL("too many channels"));
17244 rsp->num_channels = NAN_CH_INFO_MAX_CHANNELS;
17245 }
17246
17247 for (i = 0; i < rsp->num_channels; i++) {
17248 rsp->ch[i].channel = event->ndp_channel_list[i].mhz;
17249 rsp->ch[i].nss = event->nss_list[i];
17250 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndp_channel_list[i]);
17251 rsp->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
17252 ch_mode);
17253 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
17254 rsp->ch[i].channel,
17255 rsp->ch[i].ch_width,
17256 rsp->ch[i].nss);
17257 }
17258
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070017259 if (event->ndp_transport_ip_param &&
17260 event->num_ndp_transport_ip_param) {
17261 if (event->ndp_transport_ip_param->ipv6_addr_present) {
17262 rsp->is_ipv6_addr_present = true;
17263 qdf_mem_copy(rsp->ipv6_addr,
17264 event->ndp_transport_ip_param->ipv6_intf_addr,
17265 WMI_NDP_IPV6_INTF_ADDR_LEN);
17266 }
17267
17268 if (event->ndp_transport_ip_param->trans_port_present) {
17269 rsp->is_port_present = true;
17270 rsp->port =
17271 event->ndp_transport_ip_param->transport_port;
17272 }
17273
17274 if (event->ndp_transport_ip_param->trans_proto_present) {
17275 rsp->is_protocol_present = true;
17276 rsp->protocol =
17277 event->ndp_transport_ip_param->transport_protocol;
17278 }
17279 }
17280 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
17281 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
17282 WMI_LOGD(FL("port: %d present: %d"), rsp->port, rsp->is_port_present);
17283 WMI_LOGD(FL("protocol: %d present: %d"),
17284 rsp->protocol, rsp->is_protocol_present);
17285
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017286 return QDF_STATUS_SUCCESS;
17287}
17288
17289static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017290 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017291{
17292 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17293 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17294
17295 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17296 fixed_params = event->fixed_param;
17297
17298 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",
17299 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017300 rsp->peer_mac_addr.bytes, rsp->transaction_id,
17301 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017302
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017303 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017304 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17305 fixed_params->vdev_id,
17306 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017307 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017308 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017309 return QDF_STATUS_E_INVAL;
17310 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017311 rsp->transaction_id = fixed_params->transaction_id;
17312 rsp->reason = fixed_params->reason_code;
17313 rsp->status = fixed_params->rsp_status;
17314 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017315 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017316 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017317
17318 return QDF_STATUS_SUCCESS;
17319}
17320
17321static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017322 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017323{
17324 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17325 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17326
17327 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17328 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070017329 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 -080017330 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17331 fixed_params->rsp_status, fixed_params->reason_code);
17332
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017333 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017334 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017335 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017336 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017337 return QDF_STATUS_E_INVAL;
17338 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017339 rsp->transaction_id = fixed_params->transaction_id;
17340 rsp->reason = fixed_params->reason_code;
17341 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017342
17343 return QDF_STATUS_SUCCESS;
17344}
17345
17346static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17347 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17348{
17349 uint32_t i, buf_size;
17350 wmi_ndp_end_indication *ind;
17351 struct qdf_mac_addr peer_addr;
17352 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17353
17354 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17355 ind = event->ndp_end_indication_list;
17356
17357 if (event->num_ndp_end_indication_list == 0) {
17358 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017359 return QDF_STATUS_E_INVAL;
17360 }
17361
17362 WMI_LOGD("number of ndp instances = %d",
17363 event->num_ndp_end_indication_list);
17364
17365 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17366 sizeof((*rsp)->ndp_map[0]))) {
17367 WMI_LOGE("num_ndp_end_ind_list %d too large",
17368 event->num_ndp_end_indication_list);
17369 return QDF_STATUS_E_INVAL;
17370 }
17371
17372 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17373 sizeof((*rsp)->ndp_map[0]);
17374 *rsp = qdf_mem_malloc(buf_size);
17375 if (!(*rsp)) {
17376 WMI_LOGE("Failed to allocate memory");
17377 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017378 }
17379
17380 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17381 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17382 if (!(*rsp)->vdev) {
17383 WMI_LOGE("vdev is null");
17384 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017385 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017386 return QDF_STATUS_E_INVAL;
17387 }
17388
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017389 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17390 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17391 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17392 peer_addr.bytes);
17393 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17394 i, ind[i].type, ind[i].reason_code,
17395 ind[i].ndp_instance_id,
17396 ind[i].num_active_ndps_on_peer);
17397 /* Add each instance entry to the list */
17398 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17399 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17400 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17401 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17402 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17403 ind[i].num_active_ndps_on_peer;
17404 (*rsp)->ndp_map[i].type = ind[i].type;
17405 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17406 }
17407
17408 return QDF_STATUS_SUCCESS;
17409}
Naveen Rawatd42ce382018-01-09 17:54:41 -080017410
17411static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,
17412 uint8_t *data, struct nan_datapath_sch_update_event *ind)
17413{
17414 uint8_t i;
17415 WMI_HOST_WLAN_PHY_MODE ch_mode;
17416 WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *event;
17417 wmi_ndl_schedule_update_fixed_param *fixed_params;
17418
17419 event = (WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *)data;
17420 fixed_params = event->fixed_param;
17421
17422 WMI_LOGD(FL("flags: %d, num_ch: %d, num_ndp_instances: %d"),
17423 fixed_params->flags, fixed_params->num_channels,
17424 fixed_params->num_ndp_instances);
17425
17426 ind->vdev =
17427 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17428 fixed_params->vdev_id,
17429 WLAN_NAN_ID);
17430 if (!ind->vdev) {
17431 WMI_LOGE("vdev is null");
17432 return QDF_STATUS_E_INVAL;
17433 }
17434
17435 ind->flags = fixed_params->flags;
17436 ind->num_channels = fixed_params->num_channels;
17437 ind->num_ndp_instances = fixed_params->num_ndp_instances;
17438 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_macaddr,
17439 ind->peer_addr.bytes);
17440
17441 if (ind->num_ndp_instances > NDP_NUM_INSTANCE_ID) {
17442 WMI_LOGE(FL("uint32 overflow"));
17443 wlan_objmgr_vdev_release_ref(ind->vdev, WLAN_NAN_ID);
17444 return QDF_STATUS_E_INVAL;
17445 }
17446
17447 qdf_mem_copy(ind->ndp_instances, event->ndp_instance_list,
17448 sizeof(uint32_t) * ind->num_ndp_instances);
17449
17450 if (ind->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
17451 WMI_LOGE(FL("too many channels"));
17452 ind->num_channels = NAN_CH_INFO_MAX_CHANNELS;
17453 }
17454 for (i = 0; i < ind->num_channels; i++) {
17455 ind->ch[i].channel = event->ndl_channel_list[i].mhz;
17456 ind->ch[i].nss = event->nss_list[i];
17457 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]);
17458 ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
17459 ch_mode);
17460 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
17461 ind->ch[i].channel,
17462 ind->ch[i].ch_width,
17463 ind->ch[i].nss);
17464 }
17465
17466 for (i = 0; i < fixed_params->num_ndp_instances; i++)
17467 WMI_LOGD(FL("instance_id[%d]: %d"),
17468 i, event->ndp_instance_list[i]);
17469
17470 return QDF_STATUS_SUCCESS;
17471}
17472
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017473#endif
17474
Naveen Rawat963ee942018-04-13 16:38:36 -070017475#ifdef QCA_SUPPORT_CP_STATS
17476/**
17477 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
17478 * @wmi_handle: wma handle
17479 * @evt_buf: event buffer
17480 * @out_buff: buffer to populated after stats extraction
17481 *
17482 * Return: status of operation
17483 */
17484static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
17485 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
17486{
17487 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17488 wmi_congestion_stats *congestion_stats;
17489
17490 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
17491 congestion_stats = param_buf->congestion_stats;
17492 if (!congestion_stats) {
17493 WMI_LOGD("%s: no cca stats in event buffer", __func__);
17494 return QDF_STATUS_E_INVAL;
17495 }
17496
17497 out_buff->vdev_id = congestion_stats->vdev_id;
17498 out_buff->congestion = congestion_stats->congestion;
17499
17500 WMI_LOGD("%s: cca stats event processed", __func__);
17501 return QDF_STATUS_SUCCESS;
17502}
17503#endif /* QCA_SUPPORT_CP_STATS */
17504
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017505/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017506 * save_service_bitmap_tlv() - save service bitmap
17507 * @wmi_handle: wmi handle
17508 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017509 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017510 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017511 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017512 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017513static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017514QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017515 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017516{
17517 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017518 struct wmi_soc *soc = wmi_handle->soc;
17519
Govind Singhe7f2f342016-05-23 12:12:52 +053017520 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17521
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017522 /* If it is already allocated, use that buffer. This can happen
17523 * during target stop/start scenarios where host allocation is skipped.
17524 */
17525 if (!soc->wmi_service_bitmap) {
17526 soc->wmi_service_bitmap =
17527 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17528 if (!soc->wmi_service_bitmap) {
17529 WMI_LOGE("Failed memory allocation for service bitmap");
17530 return QDF_STATUS_E_NOMEM;
17531 }
17532 }
17533
17534 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017535 param_buf->wmi_service_bitmap,
17536 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017537
17538 if (bitmap_buf)
17539 qdf_mem_copy(bitmap_buf,
17540 param_buf->wmi_service_bitmap,
17541 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017542
17543 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017544}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017545
17546/**
17547 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17548 * @wmi_handle: wmi handle
17549 * @param evt_buf: pointer to event buffer
17550 * @param bitmap_buf: bitmap buffer, for converged legacy support
17551 *
17552 * Return: QDF_STATUS
17553 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017554static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017555QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017556 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017557{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017558 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17559 wmi_service_available_event_fixed_param *ev;
17560 struct wmi_soc *soc = wmi_handle->soc;
17561
17562 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17563
17564 ev = param_buf->fixed_param;
17565
17566 /* If it is already allocated, use that buffer. This can happen
17567 * during target stop/start scenarios where host allocation is skipped.
17568 */
17569 if (!soc->wmi_ext_service_bitmap) {
17570 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17571 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17572 if (!soc->wmi_ext_service_bitmap) {
17573 WMI_LOGE("Failed memory allocation for service bitmap");
17574 return QDF_STATUS_E_NOMEM;
17575 }
17576 }
17577
17578 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17579 ev->wmi_service_segment_bitmap,
17580 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017581
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017582 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17583 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17584 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17585
Rajeev Kumar77901472017-02-12 02:12:17 -080017586 if (bitmap_buf)
17587 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017588 soc->wmi_ext_service_bitmap,
17589 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017590
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017591 return QDF_STATUS_SUCCESS;
17592}
Govind Singhe7f2f342016-05-23 12:12:52 +053017593/**
17594 * is_service_enabled_tlv() - Check if service enabled
17595 * @param wmi_handle: wmi handle
17596 * @param service_id: service identifier
17597 *
17598 * Return: 1 enabled, 0 disabled
17599 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017600static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17601 uint32_t service_id)
17602{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017603 struct wmi_soc *soc = wmi_handle->soc;
17604
17605 if (!soc->wmi_service_bitmap) {
17606 WMI_LOGE("WMI service bit map is not saved yet\n");
17607 return false;
17608 }
17609
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017610 /* if wmi_service_enabled was received with extended bitmap,
17611 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017612 */
17613 if (soc->wmi_ext_service_bitmap)
17614 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17615 soc->wmi_ext_service_bitmap,
17616 service_id);
17617
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080017618 if (service_id >= WMI_MAX_SERVICE) {
17619 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
17620 service_id);
17621 return false;
17622 }
17623
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017624 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17625 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017626}
Govind Singhe7f2f342016-05-23 12:12:52 +053017627
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017628static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17629 struct wlan_psoc_target_capability_info *cap)
17630{
17631 /* except LDPC all flags are common betwen legacy and here
17632 * also IBFEER is not defined for TLV
17633 */
17634 cap->ht_cap_info |= ev_target_cap & (
17635 WMI_HT_CAP_ENABLED
17636 | WMI_HT_CAP_HT20_SGI
17637 | WMI_HT_CAP_DYNAMIC_SMPS
17638 | WMI_HT_CAP_TX_STBC
17639 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17640 | WMI_HT_CAP_RX_STBC
17641 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17642 | WMI_HT_CAP_LDPC
17643 | WMI_HT_CAP_L_SIG_TXOP_PROT
17644 | WMI_HT_CAP_MPDU_DENSITY
17645 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17646 | WMI_HT_CAP_HT40_SGI);
17647 if (ev_target_cap & WMI_HT_CAP_LDPC)
17648 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17649 WMI_HOST_HT_CAP_TX_LDPC;
17650}
Govind Singhe7f2f342016-05-23 12:12:52 +053017651/**
17652 * extract_service_ready_tlv() - extract service ready event
17653 * @wmi_handle: wmi handle
17654 * @param evt_buf: pointer to received event buffer
17655 * @param cap: pointer to hold target capability information extracted from even
17656 *
17657 * Return: QDF_STATUS_SUCCESS for success or error code
17658 */
17659static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017660 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017661{
17662 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17663 wmi_service_ready_event_fixed_param *ev;
17664
17665
17666 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17667
17668 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17669 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017670 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017671 return QDF_STATUS_E_FAILURE;
17672 }
17673
17674 cap->phy_capability = ev->phy_capability;
17675 cap->max_frag_entry = ev->max_frag_entry;
17676 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017677 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017678 cap->vht_cap_info = ev->vht_cap_info;
17679 cap->vht_supp_mcs = ev->vht_supp_mcs;
17680 cap->hw_min_tx_power = ev->hw_min_tx_power;
17681 cap->hw_max_tx_power = ev->hw_max_tx_power;
17682 cap->sys_cap_info = ev->sys_cap_info;
17683 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17684 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17685 cap->max_num_scan_channels = ev->max_num_scan_channels;
17686 cap->max_supported_macs = ev->max_supported_macs;
17687 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17688 cap->txrx_chainmask = ev->txrx_chainmask;
17689 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17690 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017691 cap->fw_version = ev->fw_build_vers;
17692 /* fw_version_1 is not available in TLV. */
17693 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017694
17695 return QDF_STATUS_SUCCESS;
17696}
17697
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017698/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17699 * to host internal WMI_HOST_REGDMN_MODE values.
17700 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17701 * host currently. Add this in the future if required.
17702 * 11AX (Phase II) : 11ax related values are not currently
17703 * advertised separately by FW. As part of phase II regulatory bring-up,
17704 * finalize the advertisement mechanism.
17705 * @target_wireless_mode: target wireless mode received in message
17706 *
17707 * Return: returns the host internal wireless mode.
17708 */
17709static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17710{
17711
17712 uint32_t wireless_modes = 0;
17713
17714 if (target_wireless_mode & REGDMN_MODE_11A)
17715 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17716
17717 if (target_wireless_mode & REGDMN_MODE_TURBO)
17718 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17719
17720 if (target_wireless_mode & REGDMN_MODE_11B)
17721 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17722
17723 if (target_wireless_mode & REGDMN_MODE_PUREG)
17724 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17725
17726 if (target_wireless_mode & REGDMN_MODE_11G)
17727 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
17728
17729 if (target_wireless_mode & REGDMN_MODE_108G)
17730 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
17731
17732 if (target_wireless_mode & REGDMN_MODE_108A)
17733 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
17734
17735 if (target_wireless_mode & REGDMN_MODE_XR)
17736 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
17737
17738 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
17739 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
17740
17741 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
17742 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
17743
17744 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
17745 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
17746
17747 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
17748 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
17749
17750 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
17751 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
17752
17753 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
17754 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
17755
17756 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
17757 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
17758
17759 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
17760 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
17761
17762 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
17763 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
17764
17765 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
17766 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
17767
17768 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
17769 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
17770
17771 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
17772 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
17773
17774 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
17775 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
17776
17777 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
17778 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
17779
17780 return wireless_modes;
17781}
17782
Govind Singhe7f2f342016-05-23 12:12:52 +053017783/**
17784 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
17785 * @wmi_handle: wmi handle
17786 * @param evt_buf: Pointer to event buffer
17787 * @param cap: pointer to hold HAL reg capabilities
17788 *
17789 * Return: QDF_STATUS_SUCCESS for success or error code
17790 */
17791static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017792 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017793{
17794 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17795
17796 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17797
17798 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
17799 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080017800 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053017801
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017802 cap->wireless_modes = convert_wireless_modes_tlv(
17803 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053017804
Govind Singhe7f2f342016-05-23 12:12:52 +053017805 return QDF_STATUS_SUCCESS;
17806}
17807
17808/**
17809 * extract_host_mem_req_tlv() - Extract host memory request event
17810 * @wmi_handle: wmi handle
17811 * @param evt_buf: pointer to event buffer
17812 * @param num_entries: pointer to hold number of entries requested
17813 *
17814 * Return: Number of entries requested
17815 */
17816static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
17817 void *evt_buf, uint8_t *num_entries)
17818{
17819 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17820 wmi_service_ready_event_fixed_param *ev;
17821
17822 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17823
17824 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17825 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017826 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017827 return NULL;
17828 }
17829
17830 *num_entries = ev->num_mem_reqs;
17831
17832 return (host_mem_req *)param_buf->mem_reqs;
17833}
17834
17835/**
17836 * save_fw_version_in_service_ready_tlv() - Save fw version in service
17837 * ready function
17838 * @wmi_handle: wmi handle
17839 * @param evt_buf: pointer to event buffer
17840 *
17841 * Return: QDF_STATUS_SUCCESS for success or error code
17842 */
17843static QDF_STATUS
17844save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
17845{
17846 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17847 wmi_service_ready_event_fixed_param *ev;
17848
17849
17850 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17851
17852 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17853 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017854 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053017855 return QDF_STATUS_E_FAILURE;
17856 }
17857
17858 /*Save fw version from service ready message */
17859 /*This will be used while sending INIT message */
17860 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
17861 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017862
Govind Singhe7f2f342016-05-23 12:12:52 +053017863 return QDF_STATUS_SUCCESS;
17864}
17865
17866/**
17867 * ready_extract_init_status_tlv() - Extract init status from ready event
17868 * @wmi_handle: wmi handle
17869 * @param evt_buf: Pointer to event buffer
17870 *
17871 * Return: ready status
17872 */
17873static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
17874 void *evt_buf)
17875{
17876 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17877 wmi_ready_event_fixed_param *ev = NULL;
17878
Govind Singhe7f2f342016-05-23 12:12:52 +053017879 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17880 ev = param_buf->fixed_param;
17881
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017882 qdf_print("%s:%d", __func__, ev->status);
Govind Singhe7f2f342016-05-23 12:12:52 +053017883
17884 return ev->status;
17885}
17886
17887/**
17888 * ready_extract_mac_addr_tlv() - extract mac address from ready event
17889 * @wmi_handle: wmi handle
17890 * @param evt_buf: pointer to event buffer
17891 * @param macaddr: Pointer to hold MAC address
17892 *
17893 * Return: QDF_STATUS_SUCCESS for success or error code
17894 */
17895static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17896 void *evt_buf, uint8_t *macaddr)
17897{
17898 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17899 wmi_ready_event_fixed_param *ev = NULL;
17900
17901
17902 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17903 ev = param_buf->fixed_param;
17904
17905 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17906
17907 return QDF_STATUS_SUCCESS;
17908}
17909
17910/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017911 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17912 * @wmi_handle: wmi handle
17913 * @param evt_buf: pointer to event buffer
17914 * @param macaddr: Pointer to hold number of MAC addresses
17915 *
17916 * Return: Pointer to addr list
17917 */
17918static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17919 void *evt_buf, uint8_t *num_mac)
17920{
17921 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17922 wmi_ready_event_fixed_param *ev = NULL;
17923
17924 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17925 ev = param_buf->fixed_param;
17926
17927 *num_mac = ev->num_extra_mac_addr;
17928
17929 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17930}
17931
17932/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017933 * extract_ready_params_tlv() - Extract data from ready event apart from
17934 * status, macaddr and version.
17935 * @wmi_handle: Pointer to WMI handle.
17936 * @evt_buf: Pointer to Ready event buffer.
17937 * @ev_param: Pointer to host defined struct to copy the data from event.
17938 *
17939 * Return: QDF_STATUS_SUCCESS on success.
17940 */
17941static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17942 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17943{
17944 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17945 wmi_ready_event_fixed_param *ev = NULL;
17946
17947 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17948 ev = param_buf->fixed_param;
17949
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017950 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017951 ev_param->num_dscp_table = ev->num_dscp_table;
17952 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17953 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017954 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017955 /* Agile_cap in ready event is not supported in TLV target */
17956 ev_param->agile_capability = false;
17957
17958 return QDF_STATUS_SUCCESS;
17959}
17960
17961/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017962 * extract_dbglog_data_len_tlv() - extract debuglog data length
17963 * @wmi_handle: wmi handle
17964 * @param evt_buf: pointer to event buffer
17965 *
17966 * Return: length
17967 */
17968static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017969 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017970{
17971 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17972
17973 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17974
17975 *len = param_buf->num_bufp;
17976
17977 return param_buf->bufp;
17978}
17979
17980/**
17981 * extract_vdev_start_resp_tlv() - extract vdev start response
17982 * @wmi_handle: wmi handle
17983 * @param evt_buf: pointer to event buffer
17984 * @param vdev_rsp: Pointer to hold vdev response
17985 *
17986 * Return: QDF_STATUS_SUCCESS for success or error code
17987 */
17988static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
17989 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
17990{
17991 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
17992 wmi_vdev_start_response_event_fixed_param *ev;
17993
17994 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
17995 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053017996 qdf_print("Invalid start response event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053017997 return QDF_STATUS_E_INVAL;
17998 }
17999
18000 ev = param_buf->fixed_param;
18001 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053018002 qdf_print("Invalid start response event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053018003 return QDF_STATUS_E_INVAL;
18004 }
18005
18006 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
18007
18008 vdev_rsp->vdev_id = ev->vdev_id;
18009 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070018010 switch (ev->resp_type) {
18011 case WMI_VDEV_START_RESP_EVENT:
18012 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
18013 break;
18014 case WMI_VDEV_RESTART_RESP_EVENT:
18015 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
18016 break;
18017 default:
Aditya Sathish45d7ada2018-07-02 17:31:55 +053018018 qdf_print("Invalid start response event buffer");
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070018019 break;
18020 };
Govind Singhe7f2f342016-05-23 12:12:52 +053018021 vdev_rsp->status = ev->status;
18022 vdev_rsp->chain_mask = ev->chain_mask;
18023 vdev_rsp->smps_mode = ev->smps_mode;
18024 vdev_rsp->mac_id = ev->mac_id;
18025 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
18026 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
18027
18028 return QDF_STATUS_SUCCESS;
18029}
18030
18031/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053018032 * extract_vdev_delete_resp_tlv() - extract vdev delete response
18033 * @wmi_handle: wmi handle
18034 * @param evt_buf: pointer to event buffer
18035 * @param delete_rsp: Pointer to hold vdev delete response
18036 *
18037 * Return: QDF_STATUS_SUCCESS for success or error code
18038 */
18039static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
18040 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
18041{
18042 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
18043 wmi_vdev_delete_resp_event_fixed_param *ev;
18044
18045 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
18046 if (!param_buf) {
18047 WMI_LOGE("Invalid vdev delete response event buffer\n");
18048 return QDF_STATUS_E_INVAL;
18049 }
18050
18051 ev = param_buf->fixed_param;
18052 if (!ev) {
18053 WMI_LOGE("Invalid vdev delete response event\n");
18054 return QDF_STATUS_E_INVAL;
18055 }
18056
18057 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
18058 delete_rsp->vdev_id = ev->vdev_id;
18059
18060 return QDF_STATUS_SUCCESS;
18061}
18062
18063
18064/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018065 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053018066 * @wmi_handle: wmi handle
18067 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018068 * @param num_vdevs: Pointer to hold num vdev
18069 *
18070 * Return: QDF_STATUS_SUCCESS for success or error code
18071 */
18072static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18073 void *evt_buf, uint32_t *num_vdevs)
18074{
18075 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18076 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
18077 uint32_t vdev_map;
18078
18079 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
18080 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053018081 qdf_print("Invalid tbtt update ext event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018082 return QDF_STATUS_E_INVAL;
18083 }
18084 tbtt_offset_event = param_buf->fixed_param;
18085 vdev_map = tbtt_offset_event->vdev_map;
18086 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18087
18088 return QDF_STATUS_SUCCESS;
18089}
18090
18091/**
18092 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
18093 * @wmi_handle: wmi handle
18094 * @param evt_buf: pointer to event buffer
18095 * @param num_vdevs: Pointer to hold num vdev
18096 *
18097 * Return: QDF_STATUS_SUCCESS for success or error code
18098 */
18099static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18100 void *evt_buf, uint32_t *num_vdevs)
18101{
18102 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18103 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
18104
18105 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18106 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053018107 qdf_print("Invalid tbtt update ext event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018108 return QDF_STATUS_E_INVAL;
18109 }
18110 tbtt_offset_ext_event = param_buf->fixed_param;
18111
18112 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
18113
18114 return QDF_STATUS_SUCCESS;
18115}
18116
18117/**
18118 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
18119 * @wmi_handle: wmi handle
18120 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070018121 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018122 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053018123 *
18124 * Return: QDF_STATUS_SUCCESS for success or error code
18125 */
18126static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018127 void *evt_buf, uint8_t idx,
18128 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018129{
18130 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18131 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018132 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018133
18134 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
18135 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053018136 qdf_print("Invalid tbtt update event buffer");
Govind Singhe7f2f342016-05-23 12:12:52 +053018137 return QDF_STATUS_E_INVAL;
18138 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018139
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018140 tbtt_offset_event = param_buf->fixed_param;
18141 vdev_map = tbtt_offset_event->vdev_map;
18142 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
18143 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
18144 return QDF_STATUS_E_INVAL;
18145 tbtt_param->tbttoffset =
18146 param_buf->tbttoffset_list[tbtt_param->vdev_id];
18147
18148 return QDF_STATUS_SUCCESS;
18149}
18150
18151/**
18152 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
18153 * @wmi_handle: wmi handle
18154 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070018155 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018156 * @param tbtt_param: Pointer to tbttoffset event param
18157 *
18158 * Return: QDF_STATUS_SUCCESS for success or error code
18159 */
18160static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
18161 void *evt_buf, uint8_t idx,
18162 struct tbttoffset_params *tbtt_param)
18163{
18164 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18165 wmi_tbtt_offset_info *tbtt_offset_info;
18166
18167 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18168 if (!param_buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053018169 qdf_print("Invalid tbtt update event buffer");
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018170 return QDF_STATUS_E_INVAL;
18171 }
18172 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
18173
18174 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
18175 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053018176
18177 return QDF_STATUS_SUCCESS;
18178}
18179
Jinwei Chenb69924c2018-08-20 11:31:31 +080018180#ifdef CONFIG_MCL
18181#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) \
18182 ((_status) & WMI_RXERR_DECRYPT)
18183#else
18184#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) false
18185#endif
18186
Govind Singhe7f2f342016-05-23 12:12:52 +053018187/**
18188 * extract_mgmt_rx_params_tlv() - extract management rx params from event
18189 * @wmi_handle: wmi handle
18190 * @param evt_buf: pointer to event buffer
18191 * @param hdr: Pointer to hold header
18192 * @param bufp: Pointer to hold pointer to rx param buffer
18193 *
18194 * Return: QDF_STATUS_SUCCESS for success or error code
18195 */
18196static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053018197 void *evt_buf, struct mgmt_rx_event_params *hdr,
18198 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053018199{
18200 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
18201 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018202 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053018203
18204 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
18205 if (!param_tlvs) {
18206 WMI_LOGE("Get NULL point message from FW");
18207 return QDF_STATUS_E_INVAL;
18208 }
18209
18210 ev_hdr = param_tlvs->hdr;
18211 if (!hdr) {
18212 WMI_LOGE("Rx event is NULL");
18213 return QDF_STATUS_E_INVAL;
18214 }
18215
Jinwei Chenb69924c2018-08-20 11:31:31 +080018216 if (IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(ev_hdr->status)) {
18217 WMI_LOGE("%s: RX mgmt frame decrypt error, discard it",
18218 __func__);
18219 return QDF_STATUS_E_INVAL;
18220 }
18221
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018222 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18223 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018224
18225 hdr->channel = ev_hdr->channel;
18226 hdr->snr = ev_hdr->snr;
18227 hdr->rate = ev_hdr->rate;
18228 hdr->phy_mode = ev_hdr->phy_mode;
18229 hdr->buf_len = ev_hdr->buf_len;
18230 hdr->status = ev_hdr->status;
18231 hdr->flags = ev_hdr->flags;
18232 hdr->rssi = ev_hdr->rssi;
18233 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018234 for (i = 0; i < ATH_MAX_ANTENNA; i++)
18235 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053018236
18237 *bufp = param_tlvs->bufp;
18238
18239 return QDF_STATUS_SUCCESS;
18240}
18241
18242/**
18243 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
18244 * @wmi_handle: wmi handle
18245 * @param evt_buf: pointer to event buffer
18246 * @param vdev_id: Pointer to hold vdev identifier
18247 *
18248 * Return: QDF_STATUS_SUCCESS for success or error code
18249 */
18250static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
18251 void *evt_buf, uint32_t *vdev_id)
18252{
18253 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
18254 wmi_vdev_stopped_event_fixed_param *resp_event;
18255
18256 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
18257 if (!param_buf) {
18258 WMI_LOGE("Invalid event buffer");
18259 return QDF_STATUS_E_INVAL;
18260 }
18261 resp_event = param_buf->fixed_param;
18262 *vdev_id = resp_event->vdev_id;
18263
18264 return QDF_STATUS_SUCCESS;
18265}
18266
18267/**
18268 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
18269 * @wmi_handle: wmi handle
18270 * @param evt_buf: pointer to event buffer
18271 * @param param: Pointer to hold roam param
18272 *
18273 * Return: QDF_STATUS_SUCCESS for success or error code
18274 */
18275static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
18276 void *evt_buf, wmi_host_roam_event *param)
18277{
18278 WMI_ROAM_EVENTID_param_tlvs *param_buf;
18279 wmi_roam_event_fixed_param *evt;
18280
18281 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18282 if (!param_buf) {
18283 WMI_LOGE("Invalid roam event buffer");
18284 return QDF_STATUS_E_INVAL;
18285 }
18286
18287 evt = param_buf->fixed_param;
18288 qdf_mem_zero(param, sizeof(*param));
18289
18290 param->vdev_id = evt->vdev_id;
18291 param->reason = evt->reason;
18292 param->rssi = evt->rssi;
18293
18294 return QDF_STATUS_SUCCESS;
18295}
18296
18297/**
18298 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18299 * @wmi_handle: wmi handle
18300 * @param evt_buf: pointer to event buffer
18301 * @param param: Pointer to hold vdev scan param
18302 *
18303 * Return: QDF_STATUS_SUCCESS for success or error code
18304 */
18305static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018306 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018307{
18308 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18309 wmi_scan_event_fixed_param *evt = NULL;
18310
18311 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18312 evt = param_buf->fixed_param;
18313
18314 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018315
Govind Singhe7f2f342016-05-23 12:12:52 +053018316 switch (evt->event) {
18317 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018318 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018319 break;
18320 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018321 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018322 break;
18323 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018324 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018325 break;
18326 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018327 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018328 break;
18329 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018330 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018331 break;
18332 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018333 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018334 break;
18335 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018336 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018337 break;
18338 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018339 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018340 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018341 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018342 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018343 break;
18344 case WMI_SCAN_EVENT_MAX:
18345 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018346 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018347 break;
18348 };
18349
18350 switch (evt->reason) {
18351 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018352 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018353 break;
18354 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018355 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018356 break;
18357 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018358 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018359 break;
18360 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018361 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018362 break;
18363 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018364 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018365 break;
18366 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018367 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018368 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018369 case WMI_SCAN_REASON_SUSPENDED:
18370 param->reason = SCAN_REASON_SUSPENDED;
18371 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018372 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018373 param->reason = SCAN_REASON_MAX;
18374 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018375 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018376 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018377 break;
18378 };
18379
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018380 param->chan_freq = evt->channel_freq;
18381 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018382 param->scan_id = evt->scan_id;
18383 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018384 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018385
18386 return QDF_STATUS_SUCCESS;
18387}
18388
Frank Liu3d5e9992017-03-15 17:51:43 +080018389#ifdef CONVERGED_TDLS_ENABLE
18390/**
18391 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18392 * @wmi_handle: wmi handle
18393 * @param evt_buf: pointer to event buffer
18394 * @param param: Pointer to hold vdev tdls param
18395 *
18396 * Return: QDF_STATUS_SUCCESS for success or error code
18397 */
18398static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18399 void *evt_buf, struct tdls_event_info *param)
18400{
18401 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18402 wmi_tdls_peer_event_fixed_param *evt;
18403
18404 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18405 if (!param_buf) {
18406 WMI_LOGE("%s: NULL param_buf", __func__);
18407 return QDF_STATUS_E_NULL_VALUE;
18408 }
18409
18410 evt = param_buf->fixed_param;
18411
18412 qdf_mem_zero(param, sizeof(*param));
18413
18414 param->vdev_id = evt->vdev_id;
18415 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18416 param->peermac.bytes);
18417 switch (evt->peer_status) {
18418 case WMI_TDLS_SHOULD_DISCOVER:
18419 param->message_type = TDLS_SHOULD_DISCOVER;
18420 break;
18421 case WMI_TDLS_SHOULD_TEARDOWN:
18422 param->message_type = TDLS_SHOULD_TEARDOWN;
18423 break;
18424 case WMI_TDLS_PEER_DISCONNECTED:
18425 param->message_type = TDLS_PEER_DISCONNECTED;
18426 break;
18427 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18428 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18429 break;
18430 default:
18431 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18432 __func__, evt->peer_status);
18433 return QDF_STATUS_E_INVAL;
18434 };
18435
18436 switch (evt->peer_reason) {
18437 case WMI_TDLS_TEARDOWN_REASON_TX:
18438 param->peer_reason = TDLS_TEARDOWN_TX;
18439 break;
18440 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18441 param->peer_reason = TDLS_TEARDOWN_RSSI;
18442 break;
18443 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18444 param->peer_reason = TDLS_TEARDOWN_SCAN;
18445 break;
18446 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18447 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18448 break;
18449 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18450 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18451 break;
18452 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18453 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18454 break;
18455 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18456 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18457 break;
18458 case WMI_TDLS_ENTER_BUF_STA:
18459 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18460 break;
18461 case WMI_TDLS_EXIT_BUF_STA:
18462 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18463 break;
18464 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18465 param->peer_reason = TDLS_ENTER_BT_BUSY;
18466 break;
18467 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18468 param->peer_reason = TDLS_EXIT_BT_BUSY;
18469 break;
18470 case WMI_TDLS_SCAN_STARTED_EVENT:
18471 param->peer_reason = TDLS_SCAN_STARTED;
18472 break;
18473 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18474 param->peer_reason = TDLS_SCAN_COMPLETED;
18475 break;
18476
18477 default:
18478 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18479 __func__, evt->peer_reason, evt->peer_status);
18480 return QDF_STATUS_E_INVAL;
18481 };
18482
18483 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18484 __func__, param->peermac.bytes, param->message_type,
18485 param->peer_reason, param->vdev_id);
18486
18487 return QDF_STATUS_SUCCESS;
18488}
18489#endif
18490
Govind Singhe7f2f342016-05-23 12:12:52 +053018491/**
18492 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18493 * @wmi_handle: wmi handle
18494 * @param evt_buf: pointer to event buffer
18495 * @param param: Pointer to hold MGMT TX completion params
18496 *
18497 * Return: QDF_STATUS_SUCCESS for success or error code
18498 */
18499static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18500 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18501{
18502 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18503 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18504
18505 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18506 evt_buf;
18507 if (!param_buf) {
18508 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18509 return QDF_STATUS_E_INVAL;
18510 }
18511 cmpl_params = param_buf->fixed_param;
18512
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018513 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18514 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018515 param->desc_id = cmpl_params->desc_id;
18516 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018517 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018518
18519 return QDF_STATUS_SUCCESS;
18520}
18521
18522/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018523 * extract_offchan_data_tx_compl_param_tlv() -
18524 * extract Offchan data tx completion event params
18525 * @wmi_handle: wmi handle
18526 * @param evt_buf: pointer to event buffer
18527 * @param param: Pointer to hold offchan data TX completion params
18528 *
18529 * Return: QDF_STATUS_SUCCESS for success or error code
18530 */
18531static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18532 wmi_unified_t wmi_handle, void *evt_buf,
18533 struct wmi_host_offchan_data_tx_compl_event *param)
18534{
18535 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18536 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18537
18538 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18539 evt_buf;
18540 if (!param_buf) {
18541 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18542 return QDF_STATUS_E_INVAL;
18543 }
18544 cmpl_params = param_buf->fixed_param;
18545
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018546 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18547 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018548 param->desc_id = cmpl_params->desc_id;
18549 param->status = cmpl_params->status;
18550
18551 return QDF_STATUS_SUCCESS;
18552}
18553
18554/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018555 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18556 * status tlv
18557 * @wmi_handle: wmi handle
18558 * @param evt_buf: pointer to event buffer
18559 * @param param: Pointer to hold csa switch count status event param
18560 *
18561 * Return: QDF_STATUS_SUCCESS for success or error code
18562 */
18563static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18564 wmi_unified_t wmi_handle,
18565 void *evt_buf,
18566 struct pdev_csa_switch_count_status *param)
18567{
18568 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18569 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18570
18571 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18572 evt_buf;
18573 if (!param_buf) {
18574 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18575 return QDF_STATUS_E_INVAL;
18576 }
18577
18578 csa_status = param_buf->fixed_param;
18579
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018580 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18581 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018582 param->current_switch_count = csa_status->current_switch_count;
18583 param->num_vdevs = csa_status->num_vdevs;
18584 param->vdev_ids = param_buf->vdev_ids;
18585
18586 return QDF_STATUS_SUCCESS;
18587}
18588
18589/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018590 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18591 * param from event
18592 * @wmi_handle: wmi handle
18593 * @param evt_buf: pointer to event buffer
18594 * @param param: Pointer to hold tpc configuration
18595 *
18596 * Return: 0 for success or error code
18597 */
18598static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18599 void *evt_buf,
18600 wmi_host_pdev_tpc_config_event *param)
18601{
18602 wmi_pdev_tpc_config_event_fixed_param *event =
18603 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18604
18605 if (!event) {
18606 WMI_LOGE("Invalid event buffer");
18607 return QDF_STATUS_E_INVAL;
18608 }
18609
18610 param->pdev_id = event->pdev_id;
18611 param->regDomain = event->regDomain;
18612 param->chanFreq = event->chanFreq;
18613 param->phyMode = event->phyMode;
18614 param->twiceAntennaReduction = event->twiceAntennaReduction;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053018615 param->twiceAntennaGain = event->twiceAntennaGain;
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018616 param->twiceMaxRDPower = event->twiceMaxRDPower;
18617 param->powerLimit = event->powerLimit;
18618 param->rateMax = event->rateMax;
18619 param->numTxChain = event->numTxChain;
18620 param->ctl = event->ctl;
18621 param->flags = event->flags;
18622
18623 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18624 sizeof(param->maxRegAllowedPower));
18625 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18626 event->maxRegAllowedPowerAGCDD,
18627 sizeof(param->maxRegAllowedPowerAGCDD));
18628 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18629 event->maxRegAllowedPowerAGSTBC,
18630 sizeof(param->maxRegAllowedPowerAGSTBC));
18631 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18632 event->maxRegAllowedPowerAGTXBF,
18633 sizeof(param->maxRegAllowedPowerAGTXBF));
18634 WMI_LOGD("%s:extract success", __func__);
18635
18636 return QDF_STATUS_SUCCESS;
18637}
18638
18639/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018640 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018641 * @wmi_handle: wmi handle
18642 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018643 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018644 *
18645 * Return: QDF_STATUS_SUCCESS for success or error code
18646 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018647static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18648 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018649{
18650 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18651 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018652 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018653
18654 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18655 if (!param_buf) {
18656 WMI_LOGE("Invalid swba event buffer");
18657 return QDF_STATUS_E_INVAL;
18658 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018659
Govind Singhe7f2f342016-05-23 12:12:52 +053018660 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018661 *num_vdevs = swba_event->num_vdevs;
18662 if (!(*num_vdevs)) {
18663 vdev_map = swba_event->vdev_map;
18664 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18665 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018666
18667 return QDF_STATUS_SUCCESS;
18668}
18669
18670/**
18671 * extract_swba_tim_info_tlv() - extract swba tim info from event
18672 * @wmi_handle: wmi handle
18673 * @param evt_buf: pointer to event buffer
18674 * @param idx: Index to bcn info
18675 * @param tim_info: Pointer to hold tim info
18676 *
18677 * Return: QDF_STATUS_SUCCESS for success or error code
18678 */
18679static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18680 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18681{
18682 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18683 wmi_tim_info *tim_info_ev;
18684
18685 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18686 if (!param_buf) {
18687 WMI_LOGE("Invalid swba event buffer");
18688 return QDF_STATUS_E_INVAL;
18689 }
18690
18691 tim_info_ev = &param_buf->tim_info[idx];
18692
18693 tim_info->tim_len = tim_info_ev->tim_len;
18694 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18695 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18696 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18697 tim_info->tim_changed = tim_info_ev->tim_changed;
18698 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018699 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018700
18701 return QDF_STATUS_SUCCESS;
18702}
18703
18704/**
18705 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18706 * @wmi_handle: wmi handle
18707 * @param evt_buf: pointer to event buffer
18708 * @param idx: Index to bcn info
18709 * @param p2p_desc: Pointer to hold p2p NoA info
18710 *
18711 * Return: QDF_STATUS_SUCCESS for success or error code
18712 */
18713static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18714 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18715{
18716 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18717 wmi_p2p_noa_info *p2p_noa_info;
18718 uint8_t i = 0;
18719
18720 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18721 if (!param_buf) {
18722 WMI_LOGE("Invalid swba event buffer");
18723 return QDF_STATUS_E_INVAL;
18724 }
18725
18726 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18727
18728 p2p_desc->modified = false;
18729 p2p_desc->num_descriptors = 0;
18730 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18731 p2p_desc->modified = true;
18732 p2p_desc->index =
18733 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18734 p2p_desc->oppPS =
18735 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18736 p2p_desc->ctwindow =
18737 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18738 p2p_desc->num_descriptors =
18739 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18740 (p2p_noa_info);
18741 for (i = 0; i < p2p_desc->num_descriptors; i++) {
18742 p2p_desc->noa_descriptors[i].type_count =
18743 (uint8_t) p2p_noa_info->noa_descriptors[i].
18744 type_count;
18745 p2p_desc->noa_descriptors[i].duration =
18746 p2p_noa_info->noa_descriptors[i].duration;
18747 p2p_desc->noa_descriptors[i].interval =
18748 p2p_noa_info->noa_descriptors[i].interval;
18749 p2p_desc->noa_descriptors[i].start_time =
18750 p2p_noa_info->noa_descriptors[i].start_time;
18751 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018752 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018753 }
18754
18755 return QDF_STATUS_SUCCESS;
18756}
18757
Wu Gaocd3a8512017-03-13 20:17:34 +080018758#ifdef CONVERGED_P2P_ENABLE
18759/**
18760 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
18761 * @wmi_handle: wmi handle
18762 * @param evt_buf: pointer to event buffer
18763 * @param param: Pointer to hold p2p noa info
18764 *
18765 * Return: QDF_STATUS_SUCCESS for success or error code
18766 */
18767static QDF_STATUS extract_p2p_noa_ev_param_tlv(
18768 wmi_unified_t wmi_handle, void *evt_buf,
18769 struct p2p_noa_info *param)
18770{
18771 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
18772 wmi_p2p_noa_event_fixed_param *fixed_param;
18773 uint8_t i;
18774 wmi_p2p_noa_info *wmi_noa_info;
18775 uint8_t *buf_ptr;
18776 uint32_t descriptors;
18777
18778 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
18779 if (!param_tlvs) {
18780 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
18781 return QDF_STATUS_E_INVAL;
18782 }
18783
18784 if (!param) {
18785 WMI_LOGE("noa information param is null");
18786 return QDF_STATUS_E_INVAL;
18787 }
18788
18789 fixed_param = param_tlvs->fixed_param;
18790 buf_ptr = (uint8_t *) fixed_param;
18791 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
18792 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
18793
18794 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
18795 WMI_LOGE("%s: noa attr is not modified", __func__);
18796 return QDF_STATUS_E_INVAL;
18797 }
18798
18799 param->vdev_id = fixed_param->vdev_id;
18800 param->index =
18801 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
18802 param->opps_ps =
18803 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
18804 param->ct_window =
18805 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
18806 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
18807 param->num_desc = (uint8_t) descriptors;
Wu Gao37773042018-09-04 16:16:37 +080018808 if (param->num_desc > WMI_P2P_MAX_NOA_DESCRIPTORS) {
18809 WMI_LOGE("%s: invalid num desc:%d", __func__,
18810 param->num_desc);
18811 return QDF_STATUS_E_INVAL;
18812 }
Wu Gaocd3a8512017-03-13 20:17:34 +080018813
18814 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
18815 param->index, param->opps_ps, param->ct_window,
18816 param->num_desc);
18817 for (i = 0; i < param->num_desc; i++) {
18818 param->noa_desc[i].type_count =
18819 (uint8_t) wmi_noa_info->noa_descriptors[i].
18820 type_count;
18821 param->noa_desc[i].duration =
18822 wmi_noa_info->noa_descriptors[i].duration;
18823 param->noa_desc[i].interval =
18824 wmi_noa_info->noa_descriptors[i].interval;
18825 param->noa_desc[i].start_time =
18826 wmi_noa_info->noa_descriptors[i].start_time;
18827 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
18828 __func__, i, param->noa_desc[i].type_count,
18829 param->noa_desc[i].duration,
18830 param->noa_desc[i].interval,
18831 param->noa_desc[i].start_time);
18832 }
18833
18834 return QDF_STATUS_SUCCESS;
18835}
18836
Rachit Kankane9cd0c752018-07-31 16:26:38 +053018837#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +080018838/**
18839 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
18840 * information from event
18841 * @wmi_handle: wmi handle
18842 * @param evt_buf: pointer to event buffer
18843 * @param param: Pointer to hold p2p lo stop event information
18844 *
18845 * Return: QDF_STATUS_SUCCESS for success or error code
18846 */
18847static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
18848 wmi_unified_t wmi_handle, void *evt_buf,
18849 struct p2p_lo_event *param)
18850{
18851 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
18852 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
18853
18854 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
18855 evt_buf;
18856 if (!param_tlvs) {
18857 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
18858 return QDF_STATUS_E_INVAL;
18859 }
18860
18861 if (!param) {
18862 WMI_LOGE("lo stop event param is null");
18863 return QDF_STATUS_E_INVAL;
18864 }
18865
18866 lo_param = param_tlvs->fixed_param;
18867 param->vdev_id = lo_param->vdev_id;
18868 param->reason_code = lo_param->reason;
18869 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
18870 param->vdev_id, param->reason_code);
18871
18872 return QDF_STATUS_SUCCESS;
18873}
Rachit Kankane9cd0c752018-07-31 16:26:38 +053018874#endif
Wu Gaocd3a8512017-03-13 20:17:34 +080018875#endif /* End of CONVERGED_P2P_ENABLE */
18876
Govind Singhe7f2f342016-05-23 12:12:52 +053018877/**
18878 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
18879 * @wmi_handle: wmi handle
18880 * @param evt_buf: pointer to event buffer
18881 * @param ev: Pointer to hold peer param
18882 *
18883 * Return: QDF_STATUS_SUCCESS for success or error code
18884 */
18885static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
18886 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
18887{
18888 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
18889 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
18890
18891 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
18892 kickout_event = param_buf->fixed_param;
18893
18894 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
18895 ev->peer_macaddr);
18896
18897 ev->reason = kickout_event->reason;
18898 ev->rssi = kickout_event->rssi;
18899
18900 return QDF_STATUS_SUCCESS;
18901}
18902
18903/**
18904 * extract_all_stats_counts_tlv() - extract all stats count from event
18905 * @wmi_handle: wmi handle
18906 * @param evt_buf: pointer to event buffer
18907 * @param stats_param: Pointer to hold stats count
18908 *
18909 * Return: QDF_STATUS_SUCCESS for success or error code
18910 */
18911static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
18912 void *evt_buf, wmi_host_stats_event *stats_param)
18913{
Govind Singhe7f2f342016-05-23 12:12:52 +053018914 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018915 wmi_per_chain_rssi_stats *rssi_event;
18916 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Jianmin Zhuf1b8d512018-09-03 20:08:27 +080018917 uint64_t min_data_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053018918
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018919 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053018920 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018921 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018922 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053018923 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018924 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053018925 return QDF_STATUS_E_FAILURE;
18926 }
18927
Jianmin Zhuf1b8d512018-09-03 20:08:27 +080018928 if (param_buf->num_data > WMI_SVC_MSG_MAX_SIZE - sizeof(*ev)) {
18929 WMI_LOGE("num_data : %u is invalid", param_buf->num_data);
18930 return QDF_STATUS_E_FAULT;
18931 }
18932
Govind Singhe7f2f342016-05-23 12:12:52 +053018933 switch (ev->stats_id) {
18934 case WMI_REQUEST_PEER_STAT:
18935 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
18936 break;
18937
18938 case WMI_REQUEST_AP_STAT:
18939 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
18940 break;
18941
18942 case WMI_REQUEST_PDEV_STAT:
18943 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
18944 break;
18945
18946 case WMI_REQUEST_VDEV_STAT:
18947 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
18948 break;
18949
18950 case WMI_REQUEST_BCNFLT_STAT:
18951 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
18952 break;
18953
18954 case WMI_REQUEST_VDEV_RATE_STAT:
18955 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
18956 break;
18957
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018958 case WMI_REQUEST_BCN_STAT:
18959 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
18960 break;
18961
Govind Singhe7f2f342016-05-23 12:12:52 +053018962 default:
18963 stats_param->stats_id = 0;
18964 break;
18965
18966 }
18967
Jianmin Zhuf1b8d512018-09-03 20:08:27 +080018968 /* ev->num_*_stats may cause uint32_t overflow, so use uint64_t
18969 * to save total length calculated
18970 */
18971 min_data_len =
18972 (((uint64_t)ev->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18973 (((uint64_t)ev->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18974 (((uint64_t)ev->num_peer_stats) * sizeof(wmi_peer_stats)) +
18975 (((uint64_t)ev->num_bcnflt_stats) *
18976 sizeof(wmi_bcnfilter_stats_t)) +
18977 (((uint64_t)ev->num_chan_stats) * sizeof(wmi_chan_stats)) +
18978 (((uint64_t)ev->num_mib_stats) * sizeof(wmi_mib_stats)) +
18979 (((uint64_t)ev->num_bcn_stats) * sizeof(wmi_bcn_stats)) +
18980 (((uint64_t)ev->num_peer_extd_stats) *
18981 sizeof(wmi_peer_extd_stats));
18982 if (param_buf->num_data != min_data_len) {
18983 WMI_LOGE("data len: %u isn't same as calculated: %llu",
18984 param_buf->num_data, min_data_len);
18985 return QDF_STATUS_E_FAULT;
18986 }
18987
Govind Singhe7f2f342016-05-23 12:12:52 +053018988 stats_param->num_pdev_stats = ev->num_pdev_stats;
18989 stats_param->num_pdev_ext_stats = 0;
18990 stats_param->num_vdev_stats = ev->num_vdev_stats;
18991 stats_param->num_peer_stats = ev->num_peer_stats;
18992 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18993 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018994 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018995 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18996 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018997
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018998 /* if chain_stats is not populated */
18999 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
19000 return QDF_STATUS_SUCCESS;
19001
19002 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
19003 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
19004 return QDF_STATUS_SUCCESS;
19005
19006 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -070019007 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019008 return QDF_STATUS_SUCCESS;
19009
19010 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
19011
Govind Singhe7f2f342016-05-23 12:12:52 +053019012 return QDF_STATUS_SUCCESS;
19013}
19014
19015/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019016 * extract_pdev_tx_stats() - extract pdev tx stats from event
19017 */
19018static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
19019{
19020 /* Tx Stats */
19021 tx->comp_queued = tx_stats->comp_queued;
19022 tx->comp_delivered = tx_stats->comp_delivered;
19023 tx->msdu_enqued = tx_stats->msdu_enqued;
19024 tx->mpdu_enqued = tx_stats->mpdu_enqued;
19025 tx->wmm_drop = tx_stats->wmm_drop;
19026 tx->local_enqued = tx_stats->local_enqued;
19027 tx->local_freed = tx_stats->local_freed;
19028 tx->hw_queued = tx_stats->hw_queued;
19029 tx->hw_reaped = tx_stats->hw_reaped;
19030 tx->underrun = tx_stats->underrun;
19031 tx->tx_abort = tx_stats->tx_abort;
19032 tx->mpdus_requed = tx_stats->mpdus_requed;
19033 tx->data_rc = tx_stats->data_rc;
19034 tx->self_triggers = tx_stats->self_triggers;
19035 tx->sw_retry_failure = tx_stats->sw_retry_failure;
19036 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
19037 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
19038 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
19039 tx->pdev_resets = tx_stats->pdev_resets;
19040 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
19041 tx->phy_underrun = tx_stats->phy_underrun;
19042 tx->txop_ovf = tx_stats->txop_ovf;
19043
19044 return;
19045}
19046
19047
19048/**
19049 * extract_pdev_rx_stats() - extract pdev rx stats from event
19050 */
19051static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
19052{
19053 /* Rx Stats */
19054 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
19055 rx->status_rcvd = rx_stats->status_rcvd;
19056 rx->r0_frags = rx_stats->r0_frags;
19057 rx->r1_frags = rx_stats->r1_frags;
19058 rx->r2_frags = rx_stats->r2_frags;
19059 /* Only TLV */
19060 rx->r3_frags = 0;
19061 rx->htt_msdus = rx_stats->htt_msdus;
19062 rx->htt_mpdus = rx_stats->htt_mpdus;
19063 rx->loc_msdus = rx_stats->loc_msdus;
19064 rx->loc_mpdus = rx_stats->loc_mpdus;
19065 rx->oversize_amsdu = rx_stats->oversize_amsdu;
19066 rx->phy_errs = rx_stats->phy_errs;
19067 rx->phy_err_drop = rx_stats->phy_err_drop;
19068 rx->mpdu_errs = rx_stats->mpdu_errs;
19069
19070 return;
19071}
19072
19073/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019074 * extract_pdev_stats_tlv() - extract pdev stats from event
19075 * @wmi_handle: wmi handle
19076 * @param evt_buf: pointer to event buffer
19077 * @param index: Index into pdev stats
19078 * @param pdev_stats: Pointer to hold pdev stats
19079 *
19080 * Return: QDF_STATUS_SUCCESS for success or error code
19081 */
19082static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
19083 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
19084{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019085 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19086 wmi_stats_event_fixed_param *ev_param;
19087 uint8_t *data;
19088
19089 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19090 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19091
19092 data = param_buf->data;
19093
19094 if (index < ev_param->num_pdev_stats) {
19095 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
19096 (index * sizeof(wmi_pdev_stats)));
19097
19098 pdev_stats->chan_nf = ev->chan_nf;
19099 pdev_stats->tx_frame_count = ev->tx_frame_count;
19100 pdev_stats->rx_frame_count = ev->rx_frame_count;
19101 pdev_stats->rx_clear_count = ev->rx_clear_count;
19102 pdev_stats->cycle_count = ev->cycle_count;
19103 pdev_stats->phy_err_count = ev->phy_err_count;
19104 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
19105
19106 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
19107 &(ev->pdev_stats.tx));
19108 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
19109 &(ev->pdev_stats.rx));
19110 }
19111
Govind Singhe7f2f342016-05-23 12:12:52 +053019112 return QDF_STATUS_SUCCESS;
19113}
19114
19115/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070019116 * extract_unit_test_tlv() - extract unit test data
19117 * @wmi_handle: wmi handle
19118 * @param evt_buf: pointer to event buffer
19119 * @param unit_test: pointer to hold unit test data
19120 * @param maxspace: Amount of space in evt_buf
19121 *
19122 * Return: QDF_STATUS_SUCCESS for success or error code
19123 */
19124static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
19125 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
19126{
19127 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
19128 wmi_unit_test_event_fixed_param *ev_param;
19129 uint32_t num_bufp;
19130 uint32_t copy_size;
19131 uint8_t *bufp;
19132
19133 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
19134 ev_param = param_buf->fixed_param;
19135 bufp = param_buf->bufp;
19136 num_bufp = param_buf->num_bufp;
19137 unit_test->vdev_id = ev_param->vdev_id;
19138 unit_test->module_id = ev_param->module_id;
19139 unit_test->diag_token = ev_param->diag_token;
19140 unit_test->flag = ev_param->flag;
19141 unit_test->payload_len = ev_param->payload_len;
19142 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
19143 ev_param->vdev_id,
19144 ev_param->module_id,
19145 ev_param->diag_token,
19146 ev_param->flag);
19147 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
19148 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
19149 bufp, num_bufp);
19150 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
19151 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
19152 unit_test->buffer_len = copy_size;
19153
19154 return QDF_STATUS_SUCCESS;
19155}
19156
19157/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019158 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
19159 * @wmi_handle: wmi handle
19160 * @param evt_buf: pointer to event buffer
19161 * @param index: Index into extended pdev stats
19162 * @param pdev_ext_stats: Pointer to hold extended pdev stats
19163 *
19164 * Return: QDF_STATUS_SUCCESS for success or error code
19165 */
19166static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
19167 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
19168{
19169 return QDF_STATUS_SUCCESS;
19170}
19171
19172/**
19173 * extract_vdev_stats_tlv() - extract vdev stats from event
19174 * @wmi_handle: wmi handle
19175 * @param evt_buf: pointer to event buffer
19176 * @param index: Index into vdev stats
19177 * @param vdev_stats: Pointer to hold vdev stats
19178 *
19179 * Return: QDF_STATUS_SUCCESS for success or error code
19180 */
19181static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
19182 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
19183{
19184 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19185 wmi_stats_event_fixed_param *ev_param;
19186 uint8_t *data;
19187
19188 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19189 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19190 data = (uint8_t *) param_buf->data;
19191
19192 if (index < ev_param->num_vdev_stats) {
19193 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
19194 ((ev_param->num_pdev_stats) *
19195 sizeof(wmi_pdev_stats)) +
19196 (index * sizeof(wmi_vdev_stats)));
19197
19198 vdev_stats->vdev_id = ev->vdev_id;
19199 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
19200 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
19201
19202 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
19203 sizeof(ev->tx_frm_cnt));
19204 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
19205 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
19206 ev->multiple_retry_cnt,
19207 sizeof(ev->multiple_retry_cnt));
19208 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
19209 sizeof(ev->fail_cnt));
19210 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
19211 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
19212 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
19213 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
19214 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
19215 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
19216 sizeof(ev->tx_rate_history));
19217 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
19218 sizeof(ev->bcn_rssi_history));
19219
19220 }
19221
19222 return QDF_STATUS_SUCCESS;
19223}
19224
19225/**
Naveen Rawatd2115722018-04-12 08:17:55 -070019226 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
19227 * buffer
19228 * @wmi_handle: wmi handle
19229 * @evt_buf: pointer to event buffer
19230 * @index: Index into vdev stats
19231 * @rssi_stats: Pointer to hold rssi stats
19232 *
19233 * Return: QDF_STATUS_SUCCESS for success or error code
19234 */
19235static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
19236 void *evt_buf, uint32_t index,
19237 struct wmi_host_per_chain_rssi_stats *rssi_stats)
19238{
19239 uint8_t *data;
19240 wmi_rssi_stats *fw_rssi_stats;
19241 wmi_per_chain_rssi_stats *rssi_event;
19242 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19243
19244 if (!evt_buf) {
19245 WMI_LOGE("evt_buf is null");
19246 return QDF_STATUS_E_NULL_VALUE;
19247 }
19248
19249 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19250 rssi_event = param_buf->chain_stats;
19251
19252 if (index >= rssi_event->num_per_chain_rssi_stats) {
19253 WMI_LOGE("invalid index");
19254 return QDF_STATUS_E_INVAL;
19255 }
19256
19257 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
19258 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
19259
19260 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
19261 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
19262 fw_rssi_stats->rssi_avg_beacon,
19263 sizeof(fw_rssi_stats->rssi_avg_beacon));
19264 qdf_mem_copy(rssi_stats->rssi_avg_data,
19265 fw_rssi_stats->rssi_avg_data,
19266 sizeof(fw_rssi_stats->rssi_avg_data));
19267 qdf_mem_copy(&rssi_stats->peer_macaddr,
19268 &fw_rssi_stats->peer_macaddr,
19269 sizeof(fw_rssi_stats->peer_macaddr));
19270
19271 return QDF_STATUS_SUCCESS;
19272}
19273
19274
19275
19276/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019277 * extract_bcn_stats_tlv() - extract bcn stats from event
19278 * @wmi_handle: wmi handle
19279 * @param evt_buf: pointer to event buffer
19280 * @param index: Index into vdev stats
19281 * @param bcn_stats: Pointer to hold bcn stats
19282 *
19283 * Return: QDF_STATUS_SUCCESS for success or error code
19284 */
19285static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
19286 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
19287{
19288 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19289 wmi_stats_event_fixed_param *ev_param;
19290 uint8_t *data;
19291
19292 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19293 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19294 data = (uint8_t *) param_buf->data;
19295
19296 if (index < ev_param->num_bcn_stats) {
19297 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
19298 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19299 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19300 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19301 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
19302 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
19303 (index * sizeof(wmi_bcn_stats)));
19304
19305 bcn_stats->vdev_id = ev->vdev_id;
19306 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
19307 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
19308 }
19309
19310 return QDF_STATUS_SUCCESS;
19311}
19312
19313/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019314 * extract_peer_stats_tlv() - extract peer stats from event
19315 * @wmi_handle: wmi handle
19316 * @param evt_buf: pointer to event buffer
19317 * @param index: Index into peer stats
19318 * @param peer_stats: Pointer to hold peer stats
19319 *
19320 * Return: QDF_STATUS_SUCCESS for success or error code
19321 */
19322static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19323 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19324{
19325 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19326 wmi_stats_event_fixed_param *ev_param;
19327 uint8_t *data;
19328
19329 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19330 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19331 data = (uint8_t *) param_buf->data;
19332
19333 if (index < ev_param->num_peer_stats) {
19334 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19335 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19336 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19337 (index * sizeof(wmi_peer_stats)));
19338
19339 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19340
19341 OS_MEMCPY(&(peer_stats->peer_macaddr),
19342 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19343
19344 peer_stats->peer_rssi = ev->peer_rssi;
19345 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19346 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19347 }
19348
19349 return QDF_STATUS_SUCCESS;
19350}
19351
19352/**
19353 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19354 * @wmi_handle: wmi handle
19355 * @param evt_buf: pointer to event buffer
19356 * @param index: Index into bcn fault stats
19357 * @param bcnflt_stats: Pointer to hold bcn fault stats
19358 *
19359 * Return: QDF_STATUS_SUCCESS for success or error code
19360 */
19361static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19362 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19363{
19364 return QDF_STATUS_SUCCESS;
19365}
19366
19367/**
19368 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19369 * @wmi_handle: wmi handle
19370 * @param evt_buf: pointer to event buffer
19371 * @param index: Index into extended peer stats
19372 * @param peer_extd_stats: Pointer to hold extended peer stats
19373 *
19374 * Return: QDF_STATUS_SUCCESS for success or error code
19375 */
19376static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19377 void *evt_buf, uint32_t index,
19378 wmi_host_peer_extd_stats *peer_extd_stats)
19379{
19380 return QDF_STATUS_SUCCESS;
19381}
19382
19383/**
19384 * extract_chan_stats_tlv() - extract chan stats from event
19385 * @wmi_handle: wmi handle
19386 * @param evt_buf: pointer to event buffer
19387 * @param index: Index into chan stats
19388 * @param vdev_extd_stats: Pointer to hold chan stats
19389 *
19390 * Return: QDF_STATUS_SUCCESS for success or error code
19391 */
19392static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19393 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19394{
19395 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19396 wmi_stats_event_fixed_param *ev_param;
19397 uint8_t *data;
19398
19399 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19400 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19401 data = (uint8_t *) param_buf->data;
19402
19403 if (index < ev_param->num_chan_stats) {
19404 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19405 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19406 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19407 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19408 (index * sizeof(wmi_chan_stats)));
19409
19410
Jeff Johnson79eaacb2018-05-06 17:53:18 -070019411 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +053019412 chan_stats->chan_mhz = ev->chan_mhz;
19413 chan_stats->sampling_period_us = ev->sampling_period_us;
19414 chan_stats->rx_clear_count = ev->rx_clear_count;
19415 chan_stats->tx_duration_us = ev->tx_duration_us;
19416 chan_stats->rx_duration_us = ev->rx_duration_us;
19417 }
19418
19419 return QDF_STATUS_SUCCESS;
19420}
19421
19422/**
19423 * extract_profile_ctx_tlv() - extract profile context from event
19424 * @wmi_handle: wmi handle
19425 * @param evt_buf: pointer to event buffer
19426 * @idx: profile stats index to extract
19427 * @param profile_ctx: Pointer to hold profile context
19428 *
19429 * Return: QDF_STATUS_SUCCESS for success or error code
19430 */
19431static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19432 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19433{
19434 return QDF_STATUS_SUCCESS;
19435}
19436
19437/**
19438 * extract_profile_data_tlv() - extract profile data from event
19439 * @wmi_handle: wmi handle
19440 * @param evt_buf: pointer to event buffer
19441 * @param profile_data: Pointer to hold profile data
19442 *
19443 * Return: QDF_STATUS_SUCCESS for success or error code
19444 */
19445static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19446 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19447{
19448
19449 return QDF_STATUS_SUCCESS;
19450}
19451
19452/**
19453 * extract_chan_info_event_tlv() - extract chan information from event
19454 * @wmi_handle: wmi handle
19455 * @param evt_buf: pointer to event buffer
19456 * @param chan_info: Pointer to hold chan information
19457 *
19458 * Return: QDF_STATUS_SUCCESS for success or error code
19459 */
19460static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19461 void *evt_buf, wmi_host_chan_info_event *chan_info)
19462{
19463 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19464 wmi_chan_info_event_fixed_param *ev;
19465
19466 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19467
19468 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19469 if (!ev) {
19470 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19471 return QDF_STATUS_E_FAILURE;
19472 }
19473
19474 chan_info->err_code = ev->err_code;
19475 chan_info->freq = ev->freq;
19476 chan_info->cmd_flags = ev->cmd_flags;
19477 chan_info->noise_floor = ev->noise_floor;
19478 chan_info->rx_clear_count = ev->rx_clear_count;
19479 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019480 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19481 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019482 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19483 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19484 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019485 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19486 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19487 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19488 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19489 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19490 chan_info->rx_frame_count = ev->rx_frame_count;
19491 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19492 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019493
19494 return QDF_STATUS_SUCCESS;
19495}
19496
19497/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019498 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19499 * @wmi_handle: WMI handle
19500 * @param evt_buf: Pointer to event buffer
19501 * @param param: Pointer to hold data
19502 *
19503 * Return : QDF_STATUS_SUCCESS for success or error code
19504 */
19505static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19506 uint8_t *evt_buf,
19507 struct wmi_host_pdev_utf_event *event)
19508{
19509 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019510 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019511
19512 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19513 event->data = param_buf->data;
19514 event->datalen = param_buf->num_data;
Pragaspathi Thilagarajd8d0e152018-09-04 14:39:09 +053019515
19516 if (event->datalen < sizeof(struct wmi_host_utf_seg_header_info)) {
19517 WMI_LOGE("%s: Invalid datalen: %d ", __func__, event->datalen);
19518 return QDF_STATUS_E_INVAL;
19519 }
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019520 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019521 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019522 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019523 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019524
19525 return QDF_STATUS_SUCCESS;
19526}
Govind Singhe7f2f342016-05-23 12:12:52 +053019527
Kiran Venkatappa06520822016-08-10 23:55:40 +053019528/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019529 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19530 * @wmi_handle: wmi handle
19531 * @param evt_buf: pointer to event buffer
19532 * @param param: Pointer to hold evt buf
19533 *
19534 * Return: QDF_STATUS_SUCCESS for success or error code
19535 */
19536static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19537 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19538{
19539 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19540 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19541 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19542 uint8_t i = 0, j = 0;
19543
19544 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19545 if (!param_buf)
19546 return QDF_STATUS_E_INVAL;
19547
19548 hw_caps = param_buf->soc_hw_mode_caps;
19549 if (!hw_caps)
19550 return QDF_STATUS_E_INVAL;
19551
19552 if (!hw_caps->num_chainmask_tables)
19553 return QDF_STATUS_E_INVAL;
19554
19555 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19556
19557 if (chainmask_caps == NULL)
19558 return QDF_STATUS_E_INVAL;
19559
19560 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19561
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019562 qdf_print("Dumping chain mask combo data for table : %d", i);
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019563 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19564
19565 chainmask_table[i].cap_list[j].chainmask =
19566 chainmask_caps->chainmask;
19567
19568 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19569 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19570
19571 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19572 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19573
19574 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19575 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19576
19577 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19578 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19579
19580 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19581 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19582
19583 chainmask_table[i].cap_list[j].chain_mask_2G =
19584 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19585
19586 chainmask_table[i].cap_list[j].chain_mask_5G =
19587 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19588
19589 chainmask_table[i].cap_list[j].chain_mask_tx =
19590 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19591
19592 chainmask_table[i].cap_list[j].chain_mask_rx =
19593 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19594
19595 chainmask_table[i].cap_list[j].supports_aDFS =
19596 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19597
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019598 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x",
19599 chainmask_caps->supported_flags,
19600 chainmask_caps->chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019601 );
19602 chainmask_caps++;
19603 }
19604 }
19605
19606 return QDF_STATUS_SUCCESS;
19607}
19608
19609/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019610 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19611 * from event
19612 * @wmi_handle: wmi handle
19613 * @param evt_buf: pointer to event buffer
19614 * @param param: Pointer to hold evt buf
19615 *
19616 * Return: QDF_STATUS_SUCCESS for success or error code
19617 */
19618static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019619 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019620{
19621 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19622 wmi_service_ready_ext_event_fixed_param *ev;
19623 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19624 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019625 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19626 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019627
19628 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19629 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019630 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019631
19632 ev = param_buf->fixed_param;
19633 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019634 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019635
19636 /* Move this to host based bitmap */
19637 param->default_conc_scan_config_bits =
19638 ev->default_conc_scan_config_bits;
19639 param->default_fw_config_bits = ev->default_fw_config_bits;
19640 param->he_cap_info = ev->he_cap_info;
19641 param->mpdu_density = ev->mpdu_density;
19642 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019643 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019644 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -070019645 param->max_bssid_indicator = ev->max_bssid_indicator;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019646 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19647
19648 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019649 if (hw_caps)
19650 param->num_hw_modes = hw_caps->num_hw_modes;
19651 else
19652 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019653
19654 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019655 if (reg_caps)
19656 param->num_phy = reg_caps->num_phy;
19657 else
19658 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019659
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019660 if (hw_caps) {
19661 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019662 qdf_print("Num chain mask tables: %d", hw_caps->num_chainmask_tables);
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019663 } else
19664 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019665
19666 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19667
19668 if (chain_mask_combo == NULL)
19669 return QDF_STATUS_SUCCESS;
19670
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019671 qdf_print("Dumping chain mask combo data");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019672
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019673 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019674
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019675 qdf_print("table_id : %d Num valid chainmasks: %d",
19676 chain_mask_combo->chainmask_table_id,
19677 chain_mask_combo->num_valid_chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019678 );
19679
19680 param->chainmask_table[i].table_id =
19681 chain_mask_combo->chainmask_table_id;
19682 param->chainmask_table[i].num_valid_chainmasks =
19683 chain_mask_combo->num_valid_chainmask;
19684 chain_mask_combo++;
19685 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +053019686 qdf_print("chain mask combo end");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019687
Kiran Venkatappa06520822016-08-10 23:55:40 +053019688 return QDF_STATUS_SUCCESS;
19689}
19690
19691/**
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019692 * extract_sar_cap_service_ready_ext_tlv() -
19693 * extract SAR cap from service ready event
19694 * @wmi_handle: wmi handle
19695 * @event: pointer to event buffer
19696 * @ext_param: extended target info
19697 *
19698 * Return: QDF_STATUS_SUCCESS for success or error code
19699 */
19700static QDF_STATUS extract_sar_cap_service_ready_ext_tlv(
19701 wmi_unified_t wmi_handle,
19702 uint8_t *event,
19703 struct wlan_psoc_host_service_ext_param *ext_param)
19704{
19705 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19706 WMI_SAR_CAPABILITIES *sar_caps;
19707
19708 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19709
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019710 if (!param_buf)
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019711 return QDF_STATUS_E_INVAL;
19712
Kabilan Kannanee8d27a2018-07-06 11:52:32 -070019713 sar_caps = param_buf->sar_caps;
19714 if (sar_caps)
19715 ext_param->sar_version = sar_caps->active_version;
19716 else
19717 ext_param->sar_version = 0;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070019718
19719 return QDF_STATUS_SUCCESS;
19720}
19721
19722/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019723 * extract_hw_mode_cap_service_ready_ext_tlv() -
19724 * extract HW mode cap from service ready event
19725 * @wmi_handle: wmi handle
19726 * @param evt_buf: pointer to event buffer
19727 * @param param: Pointer to hold evt buf
19728 * @param hw_mode_idx: hw mode idx should be less than num_mode
19729 *
19730 * Return: QDF_STATUS_SUCCESS for success or error code
19731 */
19732static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19733 wmi_unified_t wmi_handle,
19734 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019735 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019736{
19737 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19738 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19739
19740 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19741 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019742 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019743
19744 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019745 if (!hw_caps)
19746 return QDF_STATUS_E_INVAL;
19747
Kiran Venkatappa06520822016-08-10 23:55:40 +053019748 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019749 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019750
19751 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19752 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19753
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019754 param->hw_mode_config_type =
19755 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19756
Kiran Venkatappa06520822016-08-10 23:55:40 +053019757 return QDF_STATUS_SUCCESS;
19758}
19759
19760/**
19761 * extract_mac_phy_cap_service_ready_ext_tlv() -
19762 * extract MAC phy cap from service ready event
19763 * @wmi_handle: wmi handle
19764 * @param evt_buf: pointer to event buffer
19765 * @param param: Pointer to hold evt buf
19766 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019767 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019768 *
19769 * Return: QDF_STATUS_SUCCESS for success or error code
19770 */
19771static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19772 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019773 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019774 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019775{
19776 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019777 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019778 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19779 uint32_t phy_map;
19780 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019781
19782 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19783 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019784 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019785
19786 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019787 if (!hw_caps)
19788 return QDF_STATUS_E_INVAL;
19789
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019790 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19791 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19792 break;
19793
19794 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19795 while (phy_map) {
19796 phy_map >>= 1;
19797 phy_idx++;
19798 }
19799 }
19800
19801 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019802 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019803
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019804 phy_idx += phy_id;
19805 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019806 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019807
19808 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019809
19810 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019811 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19812 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019813 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019814 param->supports_11b =
19815 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19816 param->supports_11g =
19817 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19818 param->supports_11a =
19819 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19820 param->supports_11n =
19821 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19822 param->supports_11ac =
19823 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19824 param->supports_11ax =
19825 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019826
19827 param->supported_bands = mac_phy_caps->supported_bands;
19828 param->ampdu_density = mac_phy_caps->ampdu_density;
19829 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19830 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19831 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19832 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -070019833 param->he_cap_info_2G[WMI_HOST_HECAP_MAC_WORD1] =
19834 mac_phy_caps->he_cap_info_2G;
19835 param->he_cap_info_2G[WMI_HOST_HECAP_MAC_WORD2] =
19836 mac_phy_caps->he_cap_info_2G_ext;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019837 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19838 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19839 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19840 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19841 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19842 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19843 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -070019844 param->he_cap_info_5G[WMI_HOST_HECAP_MAC_WORD1] =
19845 mac_phy_caps->he_cap_info_5G;
19846 param->he_cap_info_5G[WMI_HOST_HECAP_MAC_WORD2] =
19847 mac_phy_caps->he_cap_info_5G_ext;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019848 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19849 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19850 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019851 qdf_mem_copy(&param->he_cap_phy_info_2G,
19852 &mac_phy_caps->he_cap_phy_info_2G,
19853 sizeof(param->he_cap_phy_info_2G));
19854 qdf_mem_copy(&param->he_cap_phy_info_5G,
19855 &mac_phy_caps->he_cap_phy_info_5G,
19856 sizeof(param->he_cap_phy_info_5G));
19857 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19858 sizeof(param->he_ppet2G));
19859 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19860 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019861 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019862
19863 return QDF_STATUS_SUCCESS;
19864}
19865
19866/**
19867 * extract_reg_cap_service_ready_ext_tlv() -
19868 * extract REG cap from service ready event
19869 * @wmi_handle: wmi handle
19870 * @param evt_buf: pointer to event buffer
19871 * @param param: Pointer to hold evt buf
19872 * @param phy_idx: phy idx should be less than num_mode
19873 *
19874 * Return: QDF_STATUS_SUCCESS for success or error code
19875 */
19876static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
19877 wmi_unified_t wmi_handle,
19878 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019879 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019880{
19881 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19882 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
19883 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
19884
19885 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19886 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019887 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019888
19889 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019890 if (!reg_caps)
19891 return QDF_STATUS_E_INVAL;
19892
Kiran Venkatappa06520822016-08-10 23:55:40 +053019893 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019894 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019895
19896 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
19897
19898 param->phy_id = ext_reg_cap->phy_id;
19899 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
19900 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
19901 param->regcap1 = ext_reg_cap->regcap1;
19902 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053019903 param->wireless_modes = convert_wireless_modes_tlv(
19904 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019905 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
19906 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
19907 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
19908 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
19909
19910 return QDF_STATUS_SUCCESS;
19911}
19912
Sathish Kumarf396c722017-11-17 17:30:41 +053019913static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
19914 wmi_unified_t wmi_handle,
19915 uint8_t *event, uint8_t idx,
19916 struct wlan_psoc_host_dbr_ring_caps *param)
19917{
19918 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19919 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
19920
19921 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19922 if (!param_buf)
19923 return QDF_STATUS_E_INVAL;
19924
19925 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
19926
19927 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19928 dbr_ring_caps->pdev_id);
19929 param->mod_id = dbr_ring_caps->mod_id;
19930 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
19931 param->min_buf_size = dbr_ring_caps->min_buf_size;
19932 param->min_buf_align = dbr_ring_caps->min_buf_align;
19933
19934 return QDF_STATUS_SUCCESS;
19935}
19936
19937static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
19938 uint8_t *event, struct direct_buf_rx_rsp *param)
19939{
19940 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19941 wmi_dma_buf_release_fixed_param *ev;
19942
19943 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19944 if (!param_buf)
19945 return QDF_STATUS_E_INVAL;
19946
19947 ev = param_buf->fixed_param;
19948 if (!ev)
19949 return QDF_STATUS_E_INVAL;
19950
19951 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19952 ev->pdev_id);
19953 param->mod_id = ev->mod_id;
19954 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019955 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053019956 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
19957 param->pdev_id, param->mod_id, param->num_buf_release_entry);
19958
19959 return QDF_STATUS_SUCCESS;
19960}
19961
19962static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
19963 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
19964{
19965 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19966 wmi_dma_buf_release_entry *entry;
19967
19968 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19969 if (!param_buf)
19970 return QDF_STATUS_E_INVAL;
19971
19972 entry = &param_buf->entries[idx];
19973
19974 if (!entry) {
19975 WMI_LOGE("%s: Entry is NULL\n", __func__);
19976 return QDF_STATUS_E_FAILURE;
19977 }
19978
19979 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
19980
19981 param->paddr_lo = entry->paddr_lo;
19982 param->paddr_hi = entry->paddr_hi;
19983
19984 return QDF_STATUS_SUCCESS;
19985}
19986
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019987static QDF_STATUS extract_dbr_buf_metadata_tlv(
19988 wmi_unified_t wmi_handle, uint8_t *event,
19989 uint8_t idx, struct direct_buf_rx_metadata *param)
19990{
19991 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19992 wmi_dma_buf_release_spectral_meta_data *entry;
19993
19994 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19995 if (!param_buf)
19996 return QDF_STATUS_E_INVAL;
19997
19998 entry = &param_buf->meta_data[idx];
19999
20000 if (!entry) {
20001 WMI_LOGE("%s: Entry is NULL\n", __func__);
20002 return QDF_STATUS_E_FAILURE;
20003 }
20004
20005 qdf_mem_copy(param->noisefloor, entry->noise_floor,
20006 sizeof(entry->noise_floor));
20007 return QDF_STATUS_SUCCESS;
20008}
20009
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020010/**
20011 * extract_dcs_interference_type_tlv() - extract dcs interference type
20012 * from event
20013 * @wmi_handle: wmi handle
20014 * @param evt_buf: pointer to event buffer
20015 * @param param: Pointer to hold dcs interference param
20016 *
20017 * Return: 0 for success or error code
20018 */
20019static QDF_STATUS extract_dcs_interference_type_tlv(
20020 wmi_unified_t wmi_handle,
20021 void *evt_buf, struct wmi_host_dcs_interference_param *param)
20022{
20023 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20024
20025 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20026 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020027 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020028
20029 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020030 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20031 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020032
20033 return QDF_STATUS_SUCCESS;
20034}
20035
20036/*
20037 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
20038 * @wmi_handle: wmi handle
20039 * @param evt_buf: pointer to event buffer
20040 * @param cw_int: Pointer to hold cw interference
20041 *
20042 * Return: 0 for success or error code
20043 */
20044static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
20045 void *evt_buf,
20046 wmi_host_ath_dcs_cw_int *cw_int)
20047{
20048 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20049 wlan_dcs_cw_int *ev;
20050
20051 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20052 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020053 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020054
20055 ev = param_buf->cw_int;
20056
20057 cw_int->channel = ev->channel;
20058
20059 return QDF_STATUS_SUCCESS;
20060}
20061
20062/**
20063 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
20064 * @wmi_handle: wmi handle
20065 * @param evt_buf: pointer to event buffer
20066 * @param wlan_stat: Pointer to hold wlan stats
20067 *
20068 * Return: 0 for success or error code
20069 */
20070static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
20071 void *evt_buf,
20072 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
20073{
20074 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20075 wlan_dcs_im_tgt_stats_t *ev;
20076
20077 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20078 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020079 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020080
20081 ev = param_buf->wlan_stat;
20082 wlan_stat->reg_tsf32 = ev->reg_tsf32;
20083 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
20084 wlan_stat->tx_waste_time = ev->tx_waste_time;
20085 wlan_stat->rx_time = ev->rx_time;
20086 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
20087 wlan_stat->mib_stats.listen_time = ev->listen_time;
20088 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
20089 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
20090 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
20091 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
20092 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
20093 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
20094 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
20095 wlan_stat->chan_nf = ev->chan_nf;
20096 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
20097
20098 return QDF_STATUS_SUCCESS;
20099}
20100
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020101/**
20102 * extract_thermal_stats_tlv() - extract thermal stats from event
20103 * @wmi_handle: wmi handle
20104 * @param evt_buf: Pointer to event buffer
20105 * @param temp: Pointer to hold extracted temperature
20106 * @param level: Pointer to hold extracted level
20107 *
20108 * Return: 0 for success or error code
20109 */
20110static QDF_STATUS
20111extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
20112 void *evt_buf, uint32_t *temp,
20113 uint32_t *level, uint32_t *pdev_id)
20114{
20115 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20116 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
20117
20118 param_buf =
20119 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20120 if (!param_buf)
20121 return QDF_STATUS_E_INVAL;
20122
20123 tt_stats_event = param_buf->fixed_param;
20124
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020125 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20126 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020127 *temp = tt_stats_event->temp;
20128 *level = tt_stats_event->level;
20129
20130 return QDF_STATUS_SUCCESS;
20131}
20132
20133/**
20134 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
20135 * @wmi_handle: wmi handle
20136 * @param evt_buf: pointer to event buffer
20137 * @param idx: Index to level stats
20138 * @param levelcount: Pointer to hold levelcount
20139 * @param dccount: Pointer to hold dccount
20140 *
20141 * Return: 0 for success or error code
20142 */
20143static QDF_STATUS
20144extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
20145 void *evt_buf, uint8_t idx, uint32_t *levelcount,
20146 uint32_t *dccount)
20147{
20148 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20149 wmi_therm_throt_level_stats_info *tt_level_info;
20150
20151 param_buf =
20152 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20153 if (!param_buf)
20154 return QDF_STATUS_E_INVAL;
20155
20156 tt_level_info = param_buf->therm_throt_level_stats_info;
20157
20158 if (idx < THERMAL_LEVELS) {
20159 *levelcount = tt_level_info[idx].level_count;
20160 *dccount = tt_level_info[idx].dc_count;
20161 return QDF_STATUS_SUCCESS;
20162 }
20163
20164 return QDF_STATUS_E_FAILURE;
20165}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020166#ifdef BIG_ENDIAN_HOST
20167/**
20168 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
20169 * @param data_len - data length
20170 * @param data - pointer to data
20171 *
20172 * Return: QDF_STATUS - success or error status
20173 */
20174static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20175{
20176 uint8_t *data_aligned = NULL;
20177 int c;
20178 unsigned char *data_unaligned;
20179
20180 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
20181 FIPS_ALIGN));
20182 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -070020183 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020184 if (data_unaligned == NULL)
20185 return QDF_STATUS_E_FAILURE;
20186
20187 /* Checking if space is alligned */
20188 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
20189 /* align the data space */
20190 data_aligned =
20191 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
20192 } else {
20193 data_aligned = (u_int8_t *)data_unaligned;
20194 }
20195
20196 /* memset and copy content from data to data aligned */
20197 OS_MEMSET(data_aligned, 0, data_len);
20198 OS_MEMCPY(data_aligned, data, data_len);
20199 /* Endianness to LE */
20200 for (c = 0; c < data_len/4; c++) {
20201 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020202 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020203 }
20204
20205 /* Copy content to event->data */
20206 OS_MEMCPY(data, data_aligned, data_len);
20207
20208 /* clean up allocated space */
20209 qdf_mem_free(data_unaligned);
20210 data_aligned = NULL;
20211 data_unaligned = NULL;
20212
20213 /*************************************************************/
20214
20215 return QDF_STATUS_SUCCESS;
20216}
20217#else
20218/**
20219 * fips_conv_data_be() - DUMMY for LE platform
20220 *
20221 * Return: QDF_STATUS - success
20222 */
20223static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20224{
20225 return QDF_STATUS_SUCCESS;
20226}
20227#endif
20228
20229/**
20230 * extract_fips_event_data_tlv() - extract fips event data
20231 * @wmi_handle: wmi handle
20232 * @param evt_buf: pointer to event buffer
20233 * @param param: pointer FIPS event params
20234 *
20235 * Return: 0 for success or error code
20236 */
20237static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
20238 void *evt_buf, struct wmi_host_fips_event_param *param)
20239{
20240 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
20241 wmi_pdev_fips_event_fixed_param *event;
20242
20243 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
20244 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
20245
20246 if (fips_conv_data_be(event->data_len, param_buf->data) !=
20247 QDF_STATUS_SUCCESS)
20248 return QDF_STATUS_E_FAILURE;
20249
20250 param->data = (uint32_t *)param_buf->data;
20251 param->data_len = event->data_len;
20252 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020253 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20254 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020255
20256 return QDF_STATUS_SUCCESS;
20257}
20258
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020259/*
20260 * extract_peer_delete_response_event_tlv() - extract peer delete response event
20261 * @wmi_handle: wmi handle
20262 * @param evt_buf: pointer to event buffer
20263 * @param vdev_id: Pointer to hold vdev_id
20264 * @param mac_addr: Pointer to hold peer mac address
20265 *
20266 * Return: QDF_STATUS_SUCCESS for success or error code
20267 */
20268static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
20269 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
20270{
20271 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
20272 wmi_peer_delete_resp_event_fixed_param *ev;
20273
20274 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
20275
20276 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
20277 if (!ev) {
20278 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
20279 return QDF_STATUS_E_FAILURE;
20280 }
20281
20282 param->vdev_id = ev->vdev_id;
20283 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
20284 &param->mac_address.bytes[0]);
20285
20286 return QDF_STATUS_SUCCESS;
20287}
20288
Govind Singhecf03cd2016-05-12 12:45:51 +053020289static bool is_management_record_tlv(uint32_t cmd_id)
20290{
jiad36c94d22018-01-22 15:37:03 +080020291 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
20292 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
20293 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053020294 return true;
jiad36c94d22018-01-22 15:37:03 +080020295 }
Govind Singhe7f2f342016-05-23 12:12:52 +053020296
Govind Singhecf03cd2016-05-12 12:45:51 +053020297 return false;
20298}
20299
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053020300static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20301{
20302 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
20303
20304 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
20305
20306 switch (set_cmd->param_id) {
20307 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
20308 case WMI_VDEV_PARAM_DTIM_POLICY:
20309 return HTC_TX_PACKET_TAG_AUTO_PM;
20310 default:
20311 break;
20312 }
20313
20314 return 0;
20315}
20316
20317static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20318{
20319 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
20320
20321 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20322
20323 switch (ps_cmd->param) {
20324 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20325 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20326 case WMI_STA_PS_ENABLE_QPOWER:
20327 return HTC_TX_PACKET_TAG_AUTO_PM;
20328 default:
20329 break;
20330 }
20331
20332 return 0;
20333}
20334
20335static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20336 uint32_t cmd_id)
20337{
20338 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20339 return 0;
20340
20341 switch (cmd_id) {
20342 case WMI_VDEV_SET_PARAM_CMDID:
20343 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20344 case WMI_STA_POWERSAVE_PARAM_CMDID:
20345 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20346 default:
20347 break;
20348 }
20349
20350 return 0;
20351}
20352
20353static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20354{
20355 uint16_t tag = 0;
20356
20357 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20358 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20359 __func__);
20360 return tag;
20361 }
20362
20363 if (wmi_handle->tag_crash_inject)
20364 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20365
20366 wmi_handle->tag_crash_inject = false;
20367 return tag;
20368}
20369
20370/**
20371 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20372 * @wmi_handle: WMI handle
20373 * @buf: WMI buffer
20374 * @cmd_id: WMI command Id
20375 *
20376 * Return htc_tx_tag
20377 */
20378static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20379 wmi_buf_t buf,
20380 uint32_t cmd_id)
20381{
20382 uint16_t htc_tx_tag = 0;
20383
20384 switch (cmd_id) {
20385 case WMI_WOW_ENABLE_CMDID:
20386 case WMI_PDEV_SUSPEND_CMDID:
20387 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20388 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20389 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20390 case WMI_PDEV_RESUME_CMDID:
20391 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20392 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20393#ifdef FEATURE_WLAN_D0WOW
20394 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20395#endif
20396 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20397 break;
20398 case WMI_FORCE_FW_HANG_CMDID:
20399 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20400 break;
20401 case WMI_VDEV_SET_PARAM_CMDID:
20402 case WMI_STA_POWERSAVE_PARAM_CMDID:
20403 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20404 default:
20405 break;
20406 }
20407
20408 return htc_tx_tag;
20409}
20410
Sathish Kumard3ab1002017-02-07 17:10:59 +053020411/**
20412 * extract_channel_hopping_event_tlv() - extract channel hopping param
20413 * from event
20414 * @wmi_handle: wmi handle
20415 * @param evt_buf: pointer to event buffer
20416 * @param ch_hopping: Pointer to hold channel hopping param
20417 *
20418 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20419 */
20420static QDF_STATUS extract_channel_hopping_event_tlv(
20421 wmi_unified_t wmi_handle, void *evt_buf,
20422 wmi_host_pdev_channel_hopping_event *ch_hopping)
20423{
20424 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20425 wmi_pdev_channel_hopping_event_fixed_param *event;
20426
20427 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20428 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20429 param_buf->fixed_param;
20430
20431 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20432 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020433 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20434 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020435
20436 return QDF_STATUS_SUCCESS;
20437}
20438
20439/**
20440 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20441 * @wmi_handle: wmi handle
20442 * @param evt_buf: pointer to event buffer
20443 * @param param: Pointer to hold tpc param
20444 *
20445 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20446 */
20447static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20448 void *evt_buf,
20449 wmi_host_pdev_tpc_event *param)
20450{
20451 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20452 wmi_pdev_tpc_event_fixed_param *event;
20453
20454 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20455 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20456
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020457 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20458 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020459 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20460
20461 return QDF_STATUS_SUCCESS;
20462}
20463
nobeljf74583b2018-01-25 16:35:36 -080020464/**
20465 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20466 * power param from event
20467 * @wmi_handle: wmi handle
20468 * @param evt_buf: pointer to event buffer
20469 * @param param: Pointer to hold nf cal power param
20470 *
20471 * Return: 0 for success or error code
20472 */
20473static QDF_STATUS
20474extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20475 void *evt_buf,
20476 wmi_host_pdev_nfcal_power_all_channels_event *param)
20477{
20478 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20479 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20480 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20481 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20482 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20483 uint32_t i;
20484
20485 param_buf =
20486 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20487 event = param_buf->fixed_param;
20488 ch_nfdbr = param_buf->nfdbr;
20489 ch_nfdbm = param_buf->nfdbm;
20490 ch_freqnum = param_buf->freqnum;
20491
20492 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20493 event->pdev_id, param_buf->num_nfdbr,
20494 param_buf->num_nfdbm, param_buf->num_freqnum);
20495
20496 if (param_buf->num_nfdbr >
20497 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20498 WMI_LOGE("invalid number of nfdBr");
20499 return QDF_STATUS_E_FAILURE;
20500 }
20501
20502 if (param_buf->num_nfdbm >
20503 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20504 WMI_LOGE("invalid number of nfdBm");
20505 return QDF_STATUS_E_FAILURE;
20506 }
20507
20508 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20509 WMI_LOGE("invalid number of freqNum");
20510 return QDF_STATUS_E_FAILURE;
20511 }
20512
20513 for (i = 0; i < param_buf->num_nfdbr; i++) {
20514 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20515 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20516 ch_nfdbr++;
20517 ch_nfdbm++;
20518 }
20519
20520 for (i = 0; i < param_buf->num_freqnum; i++) {
20521 param->freqnum[i] = ch_freqnum->freqNum;
20522 ch_freqnum++;
20523 }
20524
Keyur Parekh2c0bab62018-05-16 13:15:38 -070020525 param->pdev_id = wmi_handle->ops->
20526 convert_pdev_id_target_to_host(event->pdev_id);
nobeljf74583b2018-01-25 16:35:36 -080020527
20528 return QDF_STATUS_SUCCESS;
20529}
20530
Sathish Kumard3ab1002017-02-07 17:10:59 +053020531
20532#ifdef BIG_ENDIAN_HOST
20533/**
20534 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20535 * @param data_len - data length
20536 * @param data - pointer to data
20537 *
20538 * Return: QDF_STATUS - success or error status
20539 */
20540static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20541{
20542 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020543 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020544 /* Skip swapping the first word */
20545 datap += sizeof(uint32_t);
20546 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20547 i++, datap += sizeof(uint32_t)) {
20548 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20549 }
20550
20551 return QDF_STATUS_SUCCESS;
20552}
20553#else
20554/**
20555 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20556 * @param data_len - data length
20557 * @param data - pointer to data
20558 *
20559 * Return: QDF_STATUS - success or error status
20560 */
20561static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20562{
20563 return QDF_STATUS_SUCCESS;
20564}
20565#endif
20566
20567/**
20568 * extract_wds_addr_event_tlv() - extract wds address from event
20569 * @wmi_handle: wmi handle
20570 * @param evt_buf: pointer to event buffer
20571 * @param wds_ev: Pointer to hold wds address
20572 *
20573 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20574 */
20575static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20576 void *evt_buf,
20577 uint16_t len, wds_addr_event_t *wds_ev)
20578{
20579 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20580 wmi_wds_addr_event_fixed_param *ev;
20581 int i;
20582
20583 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20584 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20585
20586 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20587 return QDF_STATUS_E_FAILURE;
20588
20589 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20590 sizeof(wds_ev->event_type));
20591 for (i = 0; i < 4; i++) {
20592 wds_ev->peer_mac[i] =
20593 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20594 wds_ev->dest_mac[i] =
20595 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20596 }
20597 for (i = 0; i < 2; i++) {
20598 wds_ev->peer_mac[4+i] =
20599 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20600 wds_ev->dest_mac[4+i] =
20601 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20602 }
Kiran Venkatappad73f4eb2018-07-19 22:22:29 +053020603 wds_ev->vdev_id = ev->vdev_id;
20604
Sathish Kumard3ab1002017-02-07 17:10:59 +053020605 return QDF_STATUS_SUCCESS;
20606}
20607
20608/**
20609 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20610 * from event
20611 * @wmi_handle: wmi handle
20612 * @param evt_buf: pointer to event buffer
20613 * @param ev: Pointer to hold peer param and ps state
20614 *
20615 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20616 */
20617static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20618 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20619{
20620 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20621 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20622
20623 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20624 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20625 param_buf->fixed_param;
20626
20627 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20628 ev->peer_ps_state = event->peer_ps_state;
20629
20630 return QDF_STATUS_SUCCESS;
20631}
20632
20633/**
20634 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20635 * @wmi_handle: wmi handle
20636 * @param evt_buf: pointer to event buffer
20637 * @param inst_rssi_resp: Pointer to hold inst rssi response
20638 *
20639 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20640 */
20641static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20642 wmi_unified_t wmi_handle, void *evt_buf,
20643 wmi_host_inst_stats_resp *inst_rssi_resp)
20644{
20645 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20646 wmi_inst_rssi_stats_resp_fixed_param *event;
20647
20648 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20649 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20650
20651 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20652 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20653 inst_rssi_resp->iRSSI = event->iRSSI;
20654
20655 return QDF_STATUS_SUCCESS;
20656}
20657
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020658static struct cur_reg_rule
20659*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20660 wmi_regulatory_rule_struct *wmi_reg_rule)
20661{
20662 struct cur_reg_rule *reg_rule_ptr;
20663 uint32_t count;
20664
20665 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20666
20667 if (NULL == reg_rule_ptr) {
20668 WMI_LOGE("memory allocation failure");
20669 return NULL;
20670 }
20671
20672 for (count = 0; count < num_reg_rules; count++) {
20673 reg_rule_ptr[count].start_freq =
20674 WMI_REG_RULE_START_FREQ_GET(
20675 wmi_reg_rule[count].freq_info);
20676 reg_rule_ptr[count].end_freq =
20677 WMI_REG_RULE_END_FREQ_GET(
20678 wmi_reg_rule[count].freq_info);
20679 reg_rule_ptr[count].max_bw =
20680 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020681 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020682 reg_rule_ptr[count].reg_power =
20683 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020684 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020685 reg_rule_ptr[count].ant_gain =
20686 WMI_REG_RULE_ANTENNA_GAIN_GET(
20687 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020688 reg_rule_ptr[count].flags =
20689 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020690 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020691 }
20692
20693 return reg_rule_ptr;
20694}
20695
20696static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20697 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20698 struct cur_regulatory_info *reg_info, uint32_t len)
20699{
20700 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20701 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20702 wmi_regulatory_rule_struct *wmi_reg_rule;
20703 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20704
20705 WMI_LOGD("processing regulatory channel list");
20706
20707 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20708 if (!param_buf) {
20709 WMI_LOGE("invalid channel list event buf");
20710 return QDF_STATUS_E_FAILURE;
20711 }
20712
20713 chan_list_event_hdr = param_buf->fixed_param;
20714
20715 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20716 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20717 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020718 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020719 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20720 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020721 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020722 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020723 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020724 reg_info->ctry_code = chan_list_event_hdr->country_id;
20725 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20726 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20727 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20728 else if (chan_list_event_hdr->status_code ==
20729 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20730 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20731 else if (chan_list_event_hdr->status_code ==
20732 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20733 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20734 else if (chan_list_event_hdr->status_code ==
20735 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20736 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20737 else if (chan_list_event_hdr->status_code ==
20738 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20739 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20740 else if (chan_list_event_hdr->status_code ==
20741 WMI_REG_SET_CC_STATUS_FAIL)
20742 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20743
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020744 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20745 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20746 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20747 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20748
20749 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20750 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20751
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020752 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20753 __func__, reg_info->alpha2, reg_info->dfs_region,
20754 reg_info->min_bw_2g, reg_info->max_bw_2g,
20755 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020756
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020757 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20758 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020759 wmi_reg_rule =
20760 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20761 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20762 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020763 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20764 wmi_reg_rule);
20765 wmi_reg_rule += num_2g_reg_rules;
20766
20767 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20768 wmi_reg_rule);
20769
20770 WMI_LOGD("processed regulatory channel list");
20771
20772 return QDF_STATUS_SUCCESS;
20773}
20774
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020775static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20776 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20777 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20778{
20779 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20780 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20781
20782 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20783 if (!param_buf) {
20784 WMI_LOGE("invalid 11d country event buf");
20785 return QDF_STATUS_E_FAILURE;
20786 }
20787
20788 reg_11d_country_event = param_buf->fixed_param;
20789
20790 qdf_mem_copy(reg_11d_country->alpha2,
20791 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20792
20793 WMI_LOGD("processed 11d country event, new cc %s",
20794 reg_11d_country->alpha2);
20795
20796 return QDF_STATUS_SUCCESS;
20797}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020798
20799static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20800 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20801 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20802{
20803 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20804 wmi_avoid_freq_range_desc *afr_desc;
20805 uint32_t num_freq_ranges, freq_range_idx;
20806 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20807 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20808
20809 if (!param_buf) {
20810 WMI_LOGE("Invalid channel avoid event buffer");
20811 return QDF_STATUS_E_INVAL;
20812 }
20813
20814 afr_fixed_param = param_buf->fixed_param;
20815 if (!afr_fixed_param) {
20816 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20817 return QDF_STATUS_E_INVAL;
20818 }
20819
20820 if (!ch_avoid_ind) {
20821 WMI_LOGE("Invalid channel avoid indication buffer");
20822 return QDF_STATUS_E_INVAL;
20823 }
20824 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20825 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20826 afr_fixed_param->num_freq_ranges;
20827
20828 WMI_LOGD("Channel avoid event received with %d ranges",
20829 num_freq_ranges);
20830
20831 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20832 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20833 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20834 freq_range_idx++) {
20835 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20836 afr_desc->start_freq;
20837 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20838 afr_desc->end_freq;
20839 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20840 freq_range_idx, afr_desc->tlv_header,
20841 afr_desc->start_freq, afr_desc->end_freq);
20842 afr_desc++;
20843 }
20844
20845 return QDF_STATUS_SUCCESS;
20846}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020847#ifdef DFS_COMPONENT_ENABLE
20848/**
20849 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20850 * @wmi_handle: wma handle
20851 * @evt_buf: event buffer
20852 * @vdev_id: vdev id
20853 * @len: length of buffer
20854 *
20855 * Return: 0 for success or error code
20856 */
20857static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20858 uint8_t *evt_buf,
20859 uint32_t *vdev_id,
20860 uint32_t len)
20861{
20862 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20863 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20864
20865 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20866 if (!param_tlvs) {
20867 WMI_LOGE("invalid cac complete event buf");
20868 return QDF_STATUS_E_FAILURE;
20869 }
20870
20871 cac_event = param_tlvs->fixed_param;
20872 *vdev_id = cac_event->vdev_id;
20873 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20874
20875 return QDF_STATUS_SUCCESS;
20876}
20877
20878/**
20879 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20880 * @wmi_handle: wma handle
20881 * @evt_buf: event buffer
20882 * @radar_found: radar found event info
20883 * @len: length of buffer
20884 *
20885 * Return: 0 for success or error code
20886 */
20887static QDF_STATUS extract_dfs_radar_detection_event_tlv(
20888 wmi_unified_t wmi_handle,
20889 uint8_t *evt_buf,
20890 struct radar_found_info *radar_found,
20891 uint32_t len)
20892{
20893 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
20894 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
20895
20896 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
20897 if (!param_tlv) {
20898 WMI_LOGE("invalid radar detection event buf");
20899 return QDF_STATUS_E_FAILURE;
20900 }
20901
20902 radar_event = param_tlv->fixed_param;
Arif Hussainb522ac92018-06-27 10:51:06 -070020903 radar_found->pdev_id = convert_target_pdev_id_to_host_pdev_id(
20904 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020905 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020906 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020907 radar_found->chan_width = radar_event->chan_width;
20908 radar_found->detector_id = radar_event->detector_id;
20909 radar_found->segment_id = radar_event->segment_id;
20910 radar_found->timestamp = radar_event->timestamp;
20911 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020912 radar_found->freq_offset = radar_event->freq_offset;
20913 radar_found->sidx = radar_event->sidx;
20914
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020915 WMI_LOGI("processed radar found event pdev %d,"
20916 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
20917 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
20918 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
20919 "is_chirp %d,detection mode %d\n",
Arif Hussainb522ac92018-06-27 10:51:06 -070020920 radar_event->pdev_id, radar_found->pdev_id,
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020921 radar_event->timestamp, radar_event->chan_freq,
20922 radar_event->chan_width, radar_event->detector_id,
20923 radar_event->freq_offset, radar_event->segment_id,
20924 radar_event->sidx, radar_event->is_chirp,
20925 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020926
20927 return QDF_STATUS_SUCCESS;
20928}
bings1ea12532017-12-18 16:56:53 +080020929
20930#ifdef QCA_MCL_DFS_SUPPORT
20931/**
20932 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
20933 * @wmi_handle: wma handle
20934 * @evt_buf: event buffer
20935 * @wlan_radar_event: Pointer to struct radar_event_info
20936 * @len: length of buffer
20937 *
20938 * Return: QDF_STATUS
20939 */
20940static QDF_STATUS extract_wlan_radar_event_info_tlv(
20941 wmi_unified_t wmi_handle,
20942 uint8_t *evt_buf,
20943 struct radar_event_info *wlan_radar_event,
20944 uint32_t len)
20945{
20946 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
20947 wmi_dfs_radar_event_fixed_param *radar_event;
20948
20949 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
20950 if (!param_tlv) {
20951 WMI_LOGE("invalid wlan radar event buf");
20952 return QDF_STATUS_E_FAILURE;
20953 }
20954
20955 radar_event = param_tlv->fixed_param;
20956 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
20957 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
20958 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
20959 wlan_radar_event->rssi = radar_event->rssi;
20960 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
20961 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
20962 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
20963 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080020964 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
20965 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +080020966 if (radar_event->pulse_flags &
20967 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
20968 wlan_radar_event->is_psidx_diff_valid = true;
20969 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
20970 } else {
20971 wlan_radar_event->is_psidx_diff_valid = false;
20972 }
20973
bings1ea12532017-12-18 16:56:53 +080020974 wlan_radar_event->pdev_id = radar_event->pdev_id;
20975
20976 return QDF_STATUS_SUCCESS;
20977}
20978#else
20979static QDF_STATUS extract_wlan_radar_event_info_tlv(
20980 wmi_unified_t wmi_handle,
20981 uint8_t *evt_buf,
20982 struct radar_event_info *wlan_radar_event,
20983 uint32_t len)
20984{
20985 return QDF_STATUS_SUCCESS;
20986}
20987#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020988#endif
20989
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020990/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020991 * send_get_rcpi_cmd_tlv() - send request for rcpi value
20992 * @wmi_handle: wmi handle
20993 * @get_rcpi_param: rcpi params
20994 *
20995 * Return: QDF status
20996 */
20997static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
20998 struct rcpi_req *get_rcpi_param)
20999{
21000 wmi_buf_t buf;
21001 wmi_request_rcpi_cmd_fixed_param *cmd;
21002 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
21003
21004 buf = wmi_buf_alloc(wmi_handle, len);
21005 if (!buf) {
21006 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21007 return QDF_STATUS_E_NOMEM;
21008 }
21009
21010 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
21011 WMITLV_SET_HDR(&cmd->tlv_header,
21012 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
21013 WMITLV_GET_STRUCT_TLVLEN
21014 (wmi_request_rcpi_cmd_fixed_param));
21015
21016 cmd->vdev_id = get_rcpi_param->vdev_id;
21017 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
21018 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070021019
21020 switch (get_rcpi_param->measurement_type) {
21021
21022 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21023 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21024 break;
21025
21026 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
21027 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
21028 break;
21029
21030 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21031 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21032 break;
21033
21034 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
21035 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
21036 break;
21037
21038 default:
21039 /*
21040 * invalid rcpi measurement type, fall back to
21041 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
21042 */
21043 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21044 break;
21045 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021046 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053021047 wmi_mtrace(WMI_REQUEST_RCPI_CMDID, cmd->vdev_id, 0);
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021048 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21049 WMI_REQUEST_RCPI_CMDID)) {
21050
21051 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
21052 __func__);
21053 wmi_buf_free(buf);
21054 return QDF_STATUS_E_FAILURE;
21055 }
21056
21057 return QDF_STATUS_SUCCESS;
21058}
21059
21060/**
21061 * extract_rcpi_response_event_tlv() - Extract RCPI event params
21062 * @wmi_handle: wmi handle
21063 * @evt_buf: pointer to event buffer
21064 * @res: pointer to hold rcpi response from firmware
21065 *
21066 * Return: QDF_STATUS_SUCCESS for successful event parse
21067 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
21068 */
21069static QDF_STATUS
21070extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
21071 void *evt_buf, struct rcpi_res *res)
21072{
21073 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
21074 wmi_update_rcpi_event_fixed_param *event;
21075
21076 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
21077 if (!param_buf) {
21078 WMI_LOGE(FL("Invalid rcpi event"));
21079 return QDF_STATUS_E_INVAL;
21080 }
21081
21082 event = param_buf->fixed_param;
21083 res->vdev_id = event->vdev_id;
21084 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
21085
21086 switch (event->measurement_type) {
21087
21088 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21089 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21090 break;
21091
21092 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
21093 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
21094 break;
21095
21096 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21097 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21098 break;
21099
21100 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
21101 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
21102 break;
21103
21104 default:
21105 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
21106 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
21107 return QDF_STATUS_E_FAILURE;
21108 }
21109
21110 if (event->status)
21111 return QDF_STATUS_E_FAILURE;
21112 else
21113 return QDF_STATUS_SUCCESS;
21114}
21115
21116/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053021117 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
21118 * host to target defines. For legacy there is not conversion
21119 * required. Just return pdev_id as it is.
21120 * @param pdev_id: host pdev_id to be converted.
21121 * Return: target pdev_id after conversion.
21122 */
21123static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
21124 uint32_t pdev_id)
21125{
21126 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
21127 return WMI_PDEV_ID_SOC;
21128
21129 /*No conversion required*/
21130 return pdev_id;
21131}
21132
21133/**
21134 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
21135 * target to host defines. For legacy there is not conversion
21136 * required. Just return pdev_id as it is.
21137 * @param pdev_id: target pdev_id to be converted.
21138 * Return: host pdev_id after conversion.
21139 */
21140static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
21141 uint32_t pdev_id)
21142{
21143 /*No conversion required*/
21144 return pdev_id;
21145}
21146
21147/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021148 * send_set_country_cmd_tlv() - WMI scan channel list function
21149 * @param wmi_handle : handle to WMI.
21150 * @param param : pointer to hold scan channel list parameter
21151 *
21152 * Return: 0 on success and -ve on failure.
21153 */
21154static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
21155 struct set_country *params)
21156{
21157 wmi_buf_t buf;
21158 QDF_STATUS qdf_status;
21159 wmi_set_current_country_cmd_fixed_param *cmd;
21160 uint16_t len = sizeof(*cmd);
21161
21162 buf = wmi_buf_alloc(wmi_handle, len);
21163 if (!buf) {
21164 WMI_LOGE("Failed to allocate memory");
21165 qdf_status = QDF_STATUS_E_NOMEM;
21166 goto end;
21167 }
21168
21169 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
21170 WMITLV_SET_HDR(&cmd->tlv_header,
21171 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
21172 WMITLV_GET_STRUCT_TLVLEN
21173 (wmi_set_current_country_cmd_fixed_param));
21174
21175 WMI_LOGD("setting cuurnet country to %s", params->country);
21176
21177 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
21178
21179 cmd->pdev_id = params->pdev_id;
21180
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053021181 wmi_mtrace(WMI_SET_CURRENT_COUNTRY_CMDID, NO_SESSION, 0);
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021182 qdf_status = wmi_unified_cmd_send(wmi_handle,
21183 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
21184
21185 if (QDF_IS_STATUS_ERROR(qdf_status)) {
21186 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
21187 wmi_buf_free(buf);
21188 }
21189
21190end:
21191 return qdf_status;
21192}
21193
Abhijit Pradhand38a2692017-06-29 12:32:20 +053021194#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
21195 WMI_SET_BITS(alpha, 0, 8, val0); \
21196 WMI_SET_BITS(alpha, 8, 8, val1); \
21197 WMI_SET_BITS(alpha, 16, 8, val2); \
21198 } while (0)
21199
21200static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
21201 uint8_t pdev_id, struct cc_regdmn_s *rd)
21202{
21203 wmi_set_init_country_cmd_fixed_param *cmd;
21204 uint16_t len;
21205 wmi_buf_t buf;
21206 int ret;
21207
21208 len = sizeof(wmi_set_init_country_cmd_fixed_param);
21209 buf = wmi_buf_alloc(wmi_handle, len);
21210 if (!buf) {
21211 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
21212 return QDF_STATUS_E_NOMEM;
21213 }
21214 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
21215 WMITLV_SET_HDR(&cmd->tlv_header,
21216 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
21217 WMITLV_GET_STRUCT_TLVLEN
21218 (wmi_set_init_country_cmd_fixed_param));
21219
21220 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
21221
21222 if (rd->flags == CC_IS_SET) {
21223 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
21224 cmd->country_code.country_id = rd->cc.country_code;
21225 } else if (rd->flags == ALPHA_IS_SET) {
21226 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
21227 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
21228 rd->cc.alpha[0],
21229 rd->cc.alpha[1],
21230 rd->cc.alpha[2]);
21231 } else if (rd->flags == REGDMN_IS_SET) {
21232 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
21233 cmd->country_code.domain_code = rd->cc.regdmn_id;
21234 }
21235
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053021236 wmi_mtrace(WMI_SET_INIT_COUNTRY_CMDID, NO_SESSION, 0);
Abhijit Pradhand38a2692017-06-29 12:32:20 +053021237 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
21238 WMI_SET_INIT_COUNTRY_CMDID);
21239 if (ret) {
21240 WMI_LOGE("Failed to config wow wakeup event");
21241 wmi_buf_free(buf);
21242 return QDF_STATUS_E_FAILURE;
21243 }
21244
21245 return QDF_STATUS_SUCCESS;
21246}
21247
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053021248/**
21249 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
21250 * configuration params
21251 * @wmi_handle: wmi handler
21252 * @limit_off_chan_param: pointer to wmi_off_chan_param
21253 *
21254 * Return: 0 for success and non zero for failure
21255 */
21256static
21257QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
21258 struct wmi_limit_off_chan_param *limit_off_chan_param)
21259{
21260 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
21261 wmi_buf_t buf;
21262 uint32_t len = sizeof(*cmd);
21263 int err;
21264
21265 buf = wmi_buf_alloc(wmi_handle, len);
21266 if (!buf) {
21267 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
21268 __func__);
21269 return QDF_STATUS_E_NOMEM;
21270 }
21271
21272 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
21273
21274 WMITLV_SET_HDR(&cmd->tlv_header,
21275 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
21276 WMITLV_GET_STRUCT_TLVLEN(
21277 wmi_vdev_limit_offchan_cmd_fixed_param));
21278
21279 cmd->vdev_id = limit_off_chan_param->vdev_id;
21280
21281 cmd->flags &= 0;
21282 if (limit_off_chan_param->status)
21283 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
21284 if (limit_off_chan_param->skip_dfs_chans)
21285 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
21286
21287 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
21288 cmd->rest_time = limit_off_chan_param->rest_time;
21289
21290 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
21291 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
21292 cmd->rest_time);
21293
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053021294 wmi_mtrace(WMI_VDEV_LIMIT_OFFCHAN_CMDID, cmd->vdev_id, 0);
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053021295 err = wmi_unified_cmd_send(wmi_handle, buf,
21296 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
21297 if (QDF_IS_STATUS_ERROR(err)) {
21298 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
21299 wmi_buf_free(buf);
21300 return QDF_STATUS_E_FAILURE;
21301 }
21302
21303 return QDF_STATUS_SUCCESS;
21304}
21305
Anurag Chouhan97f00422017-09-11 14:56:30 +053021306/**
21307 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
21308 * @wmi_handle: wmi handler
21309 * @req_buf: set arp stats request buffer
21310 *
21311 * Return: 0 for success and non zero for failure
21312 */
21313static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21314 struct set_arp_stats *req_buf)
21315{
21316 wmi_buf_t buf = NULL;
21317 QDF_STATUS status;
21318 int len;
21319 uint8_t *buf_ptr;
21320 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
21321
21322 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021323 if (req_buf->pkt_type_bitmap) {
21324 len += WMI_TLV_HDR_SIZE;
21325 len += sizeof(wmi_vdev_set_connectivity_check_stats);
21326 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053021327 buf = wmi_buf_alloc(wmi_handle, len);
21328 if (!buf) {
21329 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21330 return QDF_STATUS_E_NOMEM;
21331 }
21332
21333 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21334 wmi_set_arp =
21335 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
21336 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
21337 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
21338 WMITLV_GET_STRUCT_TLVLEN
21339 (wmi_vdev_set_arp_stats_cmd_fixed_param));
21340
21341 /* fill in per roam config values */
21342 wmi_set_arp->vdev_id = req_buf->vdev_id;
21343
21344 wmi_set_arp->set_clr = req_buf->flag;
21345 wmi_set_arp->pkt_type = req_buf->pkt_type;
21346 wmi_set_arp->ipv4 = req_buf->ip_addr;
21347
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021348 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
21349 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
21350 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
21351
21352 /*
21353 * pkt_type_bitmap should be non-zero to ensure
21354 * presence of additional stats.
21355 */
21356 if (req_buf->pkt_type_bitmap) {
21357 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
21358
21359 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21360 WMITLV_SET_HDR(buf_ptr,
21361 WMITLV_TAG_ARRAY_STRUC,
21362 sizeof(wmi_vdev_set_connectivity_check_stats));
21363 buf_ptr += WMI_TLV_HDR_SIZE;
21364 wmi_set_connect_stats =
21365 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
21366 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
21367 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
21368 WMITLV_GET_STRUCT_TLVLEN(
21369 wmi_vdev_set_connectivity_check_stats));
21370 wmi_set_connect_stats->pkt_type_bitmap =
21371 req_buf->pkt_type_bitmap;
21372 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
21373 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
21374 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
21375
21376 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
21377 wmi_set_connect_stats->pkt_type_bitmap,
21378 wmi_set_connect_stats->tcp_src_port,
21379 wmi_set_connect_stats->tcp_dst_port,
21380 wmi_set_connect_stats->icmp_ipv4);
21381 }
21382
Anurag Chouhan97f00422017-09-11 14:56:30 +053021383 /* Send per roam config parameters */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053021384 wmi_mtrace(WMI_VDEV_SET_ARP_STAT_CMDID, NO_SESSION, 0);
Anurag Chouhan97f00422017-09-11 14:56:30 +053021385 status = wmi_unified_cmd_send(wmi_handle, buf,
21386 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21387 if (QDF_IS_STATUS_ERROR(status)) {
21388 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21389 status);
21390 goto error;
21391 }
21392
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +053021393 WMI_LOGD(FL("set arp stats flag=%d, vdev=%d"),
Anurag Chouhan97f00422017-09-11 14:56:30 +053021394 req_buf->flag, req_buf->vdev_id);
21395 return QDF_STATUS_SUCCESS;
21396error:
21397 wmi_buf_free(buf);
21398
21399 return status;
21400}
21401
21402/**
21403 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21404 * @wmi_handle: wmi handler
21405 * @req_buf: get arp stats request buffer
21406 *
21407 * Return: 0 for success and non zero for failure
21408 */
21409static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21410 struct get_arp_stats *req_buf)
21411{
21412 wmi_buf_t buf = NULL;
21413 QDF_STATUS status;
21414 int len;
21415 uint8_t *buf_ptr;
21416 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21417
21418 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21419 buf = wmi_buf_alloc(wmi_handle, len);
21420 if (!buf) {
21421 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21422 return QDF_STATUS_E_NOMEM;
21423 }
21424
21425 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21426 get_arp_stats =
21427 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21428 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21429 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21430 WMITLV_GET_STRUCT_TLVLEN
21431 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21432
21433 /* fill in arp stats req cmd values */
21434 get_arp_stats->vdev_id = req_buf->vdev_id;
21435
21436 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21437 /* Send per roam config parameters */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053021438 wmi_mtrace(WMI_VDEV_GET_ARP_STAT_CMDID, NO_SESSION, 0);
Anurag Chouhan97f00422017-09-11 14:56:30 +053021439 status = wmi_unified_cmd_send(wmi_handle, buf,
21440 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21441 if (QDF_IS_STATUS_ERROR(status)) {
21442 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21443 status);
21444 goto error;
21445 }
21446
21447 return QDF_STATUS_SUCCESS;
21448error:
21449 wmi_buf_free(buf);
21450
21451 return status;
21452}
21453
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021454/**
21455 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21456 * @wmi_handle: wmi handler
21457 * @pmk_info: pointer to PMK cache entry
21458 * @vdev_id: vdev id
21459 *
21460 * Return: 0 for success and non zero for failure
21461 */
21462static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21463 struct wmi_unified_pmk_cache *pmk_info)
21464{
21465 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21466 wmi_buf_t buf;
21467 QDF_STATUS status;
21468 uint8_t *buf_ptr;
21469 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021470 uint32_t len = sizeof(*cmd);
21471
21472 if (pmk_info->pmk_len)
21473 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021474
21475 buf = wmi_buf_alloc(wmi_handle, len);
21476 if (!buf) {
21477 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21478 __func__);
21479 return QDF_STATUS_E_NOMEM;
21480 }
21481
21482 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21483 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21484
21485 WMITLV_SET_HDR(&cmd->tlv_header,
21486 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21487 WMITLV_GET_STRUCT_TLVLEN(
21488 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21489
21490 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021491
21492 /* If pmk_info->pmk_len is 0, this is a flush request */
21493 if (!pmk_info->pmk_len) {
21494 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21495 cmd->num_cache = 0;
21496 goto send_cmd;
21497 }
21498
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021499 cmd->num_cache = 1;
21500 buf_ptr += sizeof(*cmd);
21501
21502 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21503 sizeof(*pmksa));
21504 buf_ptr += WMI_TLV_HDR_SIZE;
21505
21506 pmksa = (wmi_pmk_cache *)buf_ptr;
21507 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21508 WMITLV_GET_STRUCT_TLVLEN
21509 (wmi_pmk_cache));
21510 pmksa->pmk_len = pmk_info->pmk_len;
21511 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21512 pmksa->pmkid_len = pmk_info->pmkid_len;
21513 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21514 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21515 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21516 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21517 pmksa->ssid.ssid_len);
21518 pmksa->cache_id = pmk_info->cache_id;
21519 pmksa->cat_flag = pmk_info->cat_flag;
21520 pmksa->action_flag = pmk_info->action_flag;
21521
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021522send_cmd:
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053021523 wmi_mtrace(WMI_PDEV_UPDATE_PMK_CACHE_CMDID, cmd->vdev_id, 0);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021524 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21525 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21526 if (status != QDF_STATUS_SUCCESS) {
21527 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21528 __func__, status);
21529 wmi_buf_free(buf);
21530 }
21531
21532 return status;
21533}
21534
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021535/**
21536 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21537 * @wmi_handle: wmi handle
21538 * @param: reserved param
21539 *
21540 * Return: 0 for success or error code
21541 */
21542static QDF_STATUS
21543send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21544 uint32_t param)
21545{
21546 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21547 wmi_buf_t buf;
21548 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21549
21550 buf = wmi_buf_alloc(wmi_handle, len);
21551 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053021552 qdf_print("%s:wmi_buf_alloc failed", __func__);
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021553 return QDF_STATUS_E_FAILURE;
21554 }
21555 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21556 WMITLV_SET_HDR(&cmd->tlv_header,
21557 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21558 WMITLV_GET_STRUCT_TLVLEN
21559 (wmi_pdev_check_cal_version_cmd_fixed_param));
21560 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053021561 wmi_mtrace(WMI_PDEV_CHECK_CAL_VERSION_CMDID, NO_SESSION, 0);
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021562 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21563 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21564 wmi_buf_free(buf);
21565 return QDF_STATUS_E_FAILURE;
21566 }
21567
21568 return QDF_STATUS_SUCCESS;
21569}
21570
21571/**
21572 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21573 * @wmi_handle: wmi handle
21574 * @param evt_buf: pointer to event buffer
21575 * @param param: Pointer to hold peer caldata version data
21576 *
21577 * Return: 0 for success or error code
21578 */
21579static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21580 wmi_unified_t wmi_handle,
21581 void *evt_buf,
21582 wmi_host_pdev_check_cal_version_event *param)
21583{
21584 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21585 wmi_pdev_check_cal_version_event_fixed_param *event;
21586
21587 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21588 if (!param_tlvs) {
21589 WMI_LOGE("invalid cal version event buf");
21590 return QDF_STATUS_E_FAILURE;
21591 }
21592 event = param_tlvs->fixed_param;
21593 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21594 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21595 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21596 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21597
21598 param->software_cal_version = event->software_cal_version;
21599 param->board_cal_version = event->board_cal_version;
21600 param->cal_ok = event->cal_status;
21601
21602 return QDF_STATUS_SUCCESS;
21603}
21604
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021605/*
21606 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21607 * @wmi_handle: wmi handle
21608 * @params: pointer to wmi_btm_config
21609 *
21610 * Return: QDF_STATUS
21611 */
21612static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21613 struct wmi_btm_config *params)
21614{
21615
21616 wmi_btm_config_fixed_param *cmd;
21617 wmi_buf_t buf;
21618 uint32_t len;
21619
21620 len = sizeof(*cmd);
21621 buf = wmi_buf_alloc(wmi_handle, len);
21622 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +053021623 qdf_print("%s:wmi_buf_alloc failed", __func__);
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021624 return QDF_STATUS_E_NOMEM;
21625 }
21626
21627 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21628 WMITLV_SET_HDR(&cmd->tlv_header,
21629 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21630 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21631 cmd->vdev_id = params->vdev_id;
21632 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021633 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21634 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21635 cmd->stick_time_seconds = params->btm_sticky_time;
21636
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053021637 wmi_mtrace(WMI_ROAM_BTM_CONFIG_CMDID, cmd->vdev_id, 0);
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021638 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21639 WMI_ROAM_BTM_CONFIG_CMDID)) {
21640 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21641 __func__);
21642 wmi_buf_free(buf);
21643 return QDF_STATUS_E_FAILURE;
21644 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021645
21646 return QDF_STATUS_SUCCESS;
21647}
21648
21649/**
21650 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21651 * configurations to firmware.
21652 * @wmi_handle: wmi handle
21653 * @obss_cfg_param: obss detection configurations
21654 *
21655 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21656 *
21657 * Return: QDF_STATUS
21658 */
21659static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21660 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21661{
21662 wmi_buf_t buf;
21663 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21664 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21665
21666 buf = wmi_buf_alloc(wmi_handle, len);
21667 if (!buf) {
21668 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21669 return QDF_STATUS_E_NOMEM;
21670 }
21671
21672 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21673 WMITLV_SET_HDR(&cmd->tlv_header,
21674 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21675 WMITLV_GET_STRUCT_TLVLEN
21676 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21677
21678 cmd->vdev_id = obss_cfg_param->vdev_id;
21679 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21680 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21681 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21682 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21683 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21684 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21685 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21686 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021687
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053021688 wmi_mtrace(WMI_SAP_OBSS_DETECTION_CFG_CMDID, cmd->vdev_id, 0);
Arif Hussainc5bfe072017-12-27 16:23:45 -080021689 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21690 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21691 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21692 wmi_buf_free(buf);
21693 return QDF_STATUS_E_FAILURE;
21694 }
21695
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021696 return QDF_STATUS_SUCCESS;
21697}
21698
Arif Hussain33d98502018-01-12 13:15:04 -080021699/**
21700 * extract_obss_detection_info_tlv() - Extract obss detection info
21701 * received from firmware.
21702 * @evt_buf: pointer to event buffer
21703 * @obss_detection: Pointer to hold obss detection info
21704 *
21705 * Return: QDF_STATUS
21706 */
21707static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21708 struct wmi_obss_detect_info
21709 *obss_detection)
21710{
21711 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21712 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21713
21714 if (!obss_detection) {
21715 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21716 return QDF_STATUS_E_INVAL;
21717 }
21718
21719 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21720 if (!param_buf) {
21721 WMI_LOGE("%s: Invalid evt_buf", __func__);
21722 return QDF_STATUS_E_INVAL;
21723 }
21724
21725 fix_param = param_buf->fixed_param;
21726 obss_detection->vdev_id = fix_param->vdev_id;
21727 obss_detection->matched_detection_masks =
21728 fix_param->matched_detection_masks;
21729 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21730 &obss_detection->matched_bssid_addr[0]);
21731 switch (fix_param->reason) {
21732 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21733 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21734 break;
21735 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21736 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21737 break;
21738 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21739 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21740 break;
21741 default:
21742 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21743 return QDF_STATUS_E_INVAL;
21744 }
21745
21746 return QDF_STATUS_SUCCESS;
21747}
21748
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021749/**
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053021750 * send_roam_scan_stats_cmd_tlv() - Send roam scan stats req command to fw
21751 * @wmi_handle: wmi handle
21752 * @params: pointer to request structure
21753 *
21754 * Return: QDF_STATUS
21755 */
21756static QDF_STATUS
21757send_roam_scan_stats_cmd_tlv(wmi_unified_t wmi_handle,
21758 struct wmi_roam_scan_stats_req *params)
21759{
21760 wmi_buf_t buf;
21761 wmi_request_roam_scan_stats_cmd_fixed_param *cmd;
21762 WMITLV_TAG_ID tag;
21763 uint32_t size;
21764 uint32_t len = sizeof(*cmd);
21765
21766 buf = wmi_buf_alloc(wmi_handle, len);
21767 if (!buf) {
21768 WMI_LOGE(FL("Failed to allocate wmi buffer"));
21769 return QDF_STATUS_E_FAILURE;
21770 }
21771
21772 cmd = (wmi_request_roam_scan_stats_cmd_fixed_param *)wmi_buf_data(buf);
21773
21774 tag = WMITLV_TAG_STRUC_wmi_request_roam_scan_stats_cmd_fixed_param;
21775 size = WMITLV_GET_STRUCT_TLVLEN(
21776 wmi_request_roam_scan_stats_cmd_fixed_param);
21777 WMITLV_SET_HDR(&cmd->tlv_header, tag, size);
21778
21779 cmd->vdev_id = params->vdev_id;
21780
21781 WMI_LOGD(FL("Roam Scan Stats Req vdev_id: %u"), cmd->vdev_id);
21782 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21783 WMI_REQUEST_ROAM_SCAN_STATS_CMDID)) {
21784 WMI_LOGE("%s: Failed to send WMI_REQUEST_ROAM_SCAN_STATS_CMDID",
21785 __func__);
21786 wmi_buf_free(buf);
21787 return QDF_STATUS_E_FAILURE;
21788 }
21789
21790 return QDF_STATUS_SUCCESS;
21791}
21792
21793/**
21794 * extract_roam_scan_stats_res_evt_tlv() - Extract roam scan stats event
21795 * @wmi_handle: wmi handle
21796 * @evt_buf: pointer to event buffer
21797 * @vdev_id: output pointer to hold vdev id
21798 * @res_param: output pointer to hold the allocated response
21799 *
21800 * Return: QDF_STATUS
21801 */
21802static QDF_STATUS
21803extract_roam_scan_stats_res_evt_tlv(wmi_unified_t wmi_handle, void *evt_buf,
21804 uint32_t *vdev_id,
21805 struct wmi_roam_scan_stats_res **res_param)
21806{
21807 WMI_ROAM_SCAN_STATS_EVENTID_param_tlvs *param_buf;
21808 wmi_roam_scan_stats_event_fixed_param *fixed_param;
21809 uint32_t *client_id = NULL;
21810 wmi_roaming_timestamp *timestamp = NULL;
21811 uint32_t *num_channels = NULL;
21812 uint32_t *chan_info = NULL;
21813 wmi_mac_addr *old_bssid = NULL;
21814 uint32_t *is_roaming_success = NULL;
21815 wmi_mac_addr *new_bssid = NULL;
21816 uint32_t *num_roam_candidates = NULL;
21817 wmi_roam_scan_trigger_reason *roam_reason = NULL;
21818 wmi_mac_addr *bssid = NULL;
21819 uint32_t *score = NULL;
21820 uint32_t *channel = NULL;
21821 uint32_t *rssi = NULL;
21822 int chan_idx = 0, cand_idx = 0;
21823 uint32_t total_len;
21824 struct wmi_roam_scan_stats_res *res;
21825 uint32_t i, j;
21826 uint32_t num_scans;
21827
21828 *res_param = NULL;
21829 *vdev_id = 0xFF; /* Initialize to invalid vdev id */
21830 param_buf = (WMI_ROAM_SCAN_STATS_EVENTID_param_tlvs *)evt_buf;
21831 if (!param_buf) {
21832 WMI_LOGE(FL("Invalid roam scan stats event"));
21833 return QDF_STATUS_E_INVAL;
21834 }
21835
21836 fixed_param = param_buf->fixed_param;
21837 total_len = sizeof(*res) + fixed_param->num_roam_scans *
21838 sizeof(struct wmi_roam_scan_stats_params);
21839
21840 *vdev_id = fixed_param->vdev_id;
21841 num_scans = fixed_param->num_roam_scans;
21842
21843 res = qdf_mem_malloc(total_len);
21844 if (!res) {
21845 WMI_LOGE("Failed to allocate roam scan stats response memory");
21846 return QDF_STATUS_E_NOMEM;
21847 }
21848
21849 if (!num_scans) {
21850 *res_param = res;
21851 return QDF_STATUS_SUCCESS;
21852 }
21853
21854 if (param_buf->client_id &&
21855 param_buf->num_client_id == num_scans)
21856 client_id = param_buf->client_id;
21857
21858 if (param_buf->timestamp &&
21859 param_buf->num_timestamp == num_scans)
21860 timestamp = param_buf->timestamp;
21861
21862 if (param_buf->old_bssid &&
21863 param_buf->num_old_bssid == num_scans)
21864 old_bssid = param_buf->old_bssid;
21865
21866 if (param_buf->new_bssid &&
21867 param_buf->num_new_bssid == num_scans)
21868 new_bssid = param_buf->new_bssid;
21869
21870 if (param_buf->is_roaming_success &&
21871 param_buf->num_is_roaming_success == num_scans)
21872 is_roaming_success = param_buf->is_roaming_success;
21873
21874 if (param_buf->roam_reason &&
21875 param_buf->num_roam_reason == num_scans)
21876 roam_reason = param_buf->roam_reason;
21877
21878 if (param_buf->num_channels &&
21879 param_buf->num_num_channels == num_scans) {
21880 uint32_t count, chan_info_sum = 0;
21881
21882 num_channels = param_buf->num_channels;
21883 for (count = 0; count < param_buf->num_num_channels; count++)
21884 chan_info_sum += param_buf->num_channels[count];
21885
21886 if (param_buf->chan_info &&
21887 param_buf->num_chan_info == chan_info_sum)
21888 chan_info = param_buf->chan_info;
21889 }
21890
21891 if (param_buf->num_roam_candidates &&
21892 param_buf->num_num_roam_candidates == num_scans) {
21893 uint32_t count, roam_cand_sum = 0;
21894
21895 num_roam_candidates = param_buf->num_roam_candidates;
21896 for (count = 0; count < param_buf->num_num_roam_candidates;
21897 count++)
21898 roam_cand_sum += param_buf->num_roam_candidates[count];
21899
21900 if (param_buf->bssid &&
21901 param_buf->num_bssid == roam_cand_sum)
21902 bssid = param_buf->bssid;
21903
21904 if (param_buf->score &&
21905 param_buf->num_score == roam_cand_sum)
21906 score = param_buf->score;
21907
21908 if (param_buf->channel &&
21909 param_buf->num_channel == roam_cand_sum)
21910 channel = param_buf->channel;
21911
21912 if (param_buf->rssi &&
21913 param_buf->num_rssi == roam_cand_sum)
21914 rssi = param_buf->rssi;
21915 }
21916
21917 res->num_roam_scans = num_scans;
21918 for (i = 0; i < num_scans; i++) {
21919 struct wmi_roam_scan_stats_params *roam = &res->roam_scan[i];
21920
21921 if (timestamp)
21922 roam->time_stamp = timestamp[i].lower32bit |
21923 (timestamp[i].upper32bit << 31);
21924
21925 if (client_id)
21926 roam->client_id = client_id[i];
21927
21928 if (num_channels) {
21929 roam->num_scan_chans = num_channels[i];
21930 if (chan_info) {
21931 for (j = 0; j < num_channels[i]; j++)
21932 roam->scan_freqs[j] =
21933 chan_info[chan_idx++];
21934 }
21935 }
21936
21937 if (is_roaming_success)
21938 roam->is_roam_successful = is_roaming_success[i];
21939
21940 if (roam_reason) {
21941 roam->trigger_id = roam_reason[i].trigger_id;
21942 roam->trigger_value = roam_reason[i].trigger_value;
21943 }
21944
21945 if (num_roam_candidates) {
21946 roam->num_roam_candidates = num_roam_candidates[i];
21947
21948 for (j = 0; j < num_roam_candidates[i]; j++) {
21949 if (score)
21950 roam->cand[j].score = score[cand_idx];
21951 if (rssi)
21952 roam->cand[j].rssi = rssi[cand_idx];
21953 if (channel)
21954 roam->cand[j].freq =
21955 channel[cand_idx];
21956
21957 if (bssid)
21958 WMI_MAC_ADDR_TO_CHAR_ARRAY(
21959 &bssid[cand_idx],
21960 roam->cand[j].bssid);
21961
21962 cand_idx++;
21963 }
21964 }
21965
21966 if (old_bssid)
21967 WMI_MAC_ADDR_TO_CHAR_ARRAY(&old_bssid[i],
21968 roam->old_bssid);
21969
21970 if (new_bssid)
21971 WMI_MAC_ADDR_TO_CHAR_ARRAY(&new_bssid[i],
21972 roam->new_bssid);
21973 }
21974
21975 *res_param = res;
21976
21977 return QDF_STATUS_SUCCESS;
21978}
21979
21980/**
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021981 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21982 * @wmi_handle: wmi handler
21983 * @params: pointer to 11k offload params
21984 *
21985 * Return: 0 for success and non zero for failure
21986 */
21987static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21988 struct wmi_11k_offload_params *params)
21989{
21990 wmi_11k_offload_report_fixed_param *cmd;
21991 wmi_buf_t buf;
21992 QDF_STATUS status;
21993 uint8_t *buf_ptr;
21994 wmi_neighbor_report_11k_offload_tlv_param
21995 *neighbor_report_offload_params;
21996 wmi_neighbor_report_offload *neighbor_report_offload;
21997
21998 uint32_t len = sizeof(*cmd);
21999
22000 if (params->offload_11k_bitmask &
22001 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
22002 len += WMI_TLV_HDR_SIZE +
22003 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
22004
22005 buf = wmi_buf_alloc(wmi_handle, len);
22006 if (!buf) {
22007 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
22008 __func__);
22009 return QDF_STATUS_E_NOMEM;
22010 }
22011
22012 buf_ptr = (uint8_t *) wmi_buf_data(buf);
22013 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
22014
22015 WMITLV_SET_HDR(&cmd->tlv_header,
22016 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
22017 WMITLV_GET_STRUCT_TLVLEN(
22018 wmi_11k_offload_report_fixed_param));
22019
22020 cmd->vdev_id = params->vdev_id;
22021 cmd->offload_11k = params->offload_11k_bitmask;
22022
22023 if (params->offload_11k_bitmask &
22024 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
22025 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
22026
22027 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
22028 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
22029 buf_ptr += WMI_TLV_HDR_SIZE;
22030
22031 neighbor_report_offload_params =
22032 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
22033 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
22034 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
22035 WMITLV_GET_STRUCT_TLVLEN(
22036 wmi_neighbor_report_11k_offload_tlv_param));
22037
22038 neighbor_report_offload = &neighbor_report_offload_params->
22039 neighbor_rep_ofld_params;
22040
22041 neighbor_report_offload->time_offset =
22042 params->neighbor_report_params.time_offset;
22043 neighbor_report_offload->low_rssi_offset =
22044 params->neighbor_report_params.low_rssi_offset;
22045 neighbor_report_offload->bmiss_count_trigger =
22046 params->neighbor_report_params.bmiss_count_trigger;
22047 neighbor_report_offload->per_threshold_offset =
22048 params->neighbor_report_params.per_threshold_offset;
22049 neighbor_report_offload->neighbor_report_cache_timeout =
22050 params->neighbor_report_params.
22051 neighbor_report_cache_timeout;
22052 neighbor_report_offload->max_neighbor_report_req_cap =
22053 params->neighbor_report_params.
22054 max_neighbor_report_req_cap;
22055 neighbor_report_offload->ssid.ssid_len =
22056 params->neighbor_report_params.ssid.length;
22057 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
22058 &params->neighbor_report_params.ssid.mac_ssid,
22059 neighbor_report_offload->ssid.ssid_len);
22060 }
22061
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053022062 wmi_mtrace(WMI_11K_OFFLOAD_REPORT_CMDID, cmd->vdev_id, 0);
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022063 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22064 WMI_11K_OFFLOAD_REPORT_CMDID);
22065 if (status != QDF_STATUS_SUCCESS) {
22066 WMI_LOGE("%s: failed to send 11k offload command %d",
22067 __func__, status);
22068 wmi_buf_free(buf);
22069 }
22070
22071 return status;
22072}
22073
22074/**
22075 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
22076 * command
22077 * @wmi_handle: wmi handler
22078 * @params: pointer to neighbor report invoke params
22079 *
22080 * Return: 0 for success and non zero for failure
22081 */
22082static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
22083 struct wmi_invoke_neighbor_report_params *params)
22084{
22085 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
22086 wmi_buf_t buf;
22087 QDF_STATUS status;
22088 uint8_t *buf_ptr;
22089 uint32_t len = sizeof(*cmd);
22090
22091 buf = wmi_buf_alloc(wmi_handle, len);
22092 if (!buf) {
22093 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
22094 __func__);
22095 return QDF_STATUS_E_NOMEM;
22096 }
22097
22098 buf_ptr = (uint8_t *) wmi_buf_data(buf);
22099 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
22100
22101 WMITLV_SET_HDR(&cmd->tlv_header,
22102 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
22103 WMITLV_GET_STRUCT_TLVLEN(
22104 wmi_11k_offload_invoke_neighbor_report_fixed_param));
22105
22106 cmd->vdev_id = params->vdev_id;
22107 cmd->flags = params->send_resp_to_host;
22108
22109 cmd->ssid.ssid_len = params->ssid.length;
22110 qdf_mem_copy(cmd->ssid.ssid,
22111 &params->ssid.mac_ssid,
22112 cmd->ssid.ssid_len);
22113
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053022114 wmi_mtrace(WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID, cmd->vdev_id, 0);
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022115 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22116 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
22117 if (status != QDF_STATUS_SUCCESS) {
22118 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
22119 __func__, status);
22120 wmi_buf_free(buf);
22121 }
22122
22123 return status;
22124}
22125
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022126#ifdef WLAN_SUPPORT_GREEN_AP
22127static QDF_STATUS extract_green_ap_egap_status_info_tlv(
22128 uint8_t *evt_buf,
22129 struct wlan_green_ap_egap_status_info *egap_status_info_params)
22130{
22131 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
22132 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
22133 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
22134
22135 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
22136 if (!param_buf) {
22137 WMI_LOGE("Invalid EGAP Info status event buffer");
22138 return QDF_STATUS_E_INVAL;
22139 }
22140
22141 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
22142 param_buf->fixed_param;
22143 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
22144 param_buf->chainmask_list;
22145
22146 egap_status_info_params->status = egap_info_event->status;
22147 egap_status_info_params->mac_id = chainmask_event->mac_id;
22148 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
22149 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
22150
22151 return QDF_STATUS_SUCCESS;
22152}
22153#endif
22154
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022155/*
22156 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
22157 * updating bss color change within firmware when AP announces bss color change.
22158 * @wmi_handle: wmi handle
22159 * @vdev_id: vdev ID
22160 * @enable: enable bss color change within firmware
22161 *
22162 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
22163 *
22164 * Return: QDF_STATUS
22165 */
22166static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
22167 uint32_t vdev_id,
22168 bool enable)
22169{
22170 wmi_buf_t buf;
22171 wmi_bss_color_change_enable_fixed_param *cmd;
22172 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
22173
22174 buf = wmi_buf_alloc(wmi_handle, len);
22175 if (!buf) {
22176 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22177 return QDF_STATUS_E_NOMEM;
22178 }
22179
22180 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
22181 WMITLV_SET_HDR(&cmd->tlv_header,
22182 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
22183 WMITLV_GET_STRUCT_TLVLEN
22184 (wmi_bss_color_change_enable_fixed_param));
22185 cmd->vdev_id = vdev_id;
22186 cmd->enable = enable;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053022187 wmi_mtrace(WMI_BSS_COLOR_CHANGE_ENABLE_CMDID, cmd->vdev_id, 0);
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022188 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22189 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
22190 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
22191 wmi_buf_free(buf);
22192 return QDF_STATUS_E_FAILURE;
22193 }
22194
22195 return QDF_STATUS_SUCCESS;
22196}
22197
22198/**
22199 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
22200 * configurations to firmware.
22201 * @wmi_handle: wmi handle
22202 * @cfg_param: obss detection configurations
22203 *
22204 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
22205 *
22206 * Return: QDF_STATUS
22207 */
22208static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
22209 wmi_unified_t wmi_handle,
22210 struct wmi_obss_color_collision_cfg_param *cfg_param)
22211{
22212 wmi_buf_t buf;
22213 wmi_obss_color_collision_det_config_fixed_param *cmd;
22214 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
22215
22216 buf = wmi_buf_alloc(wmi_handle, len);
22217 if (!buf) {
22218 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22219 return QDF_STATUS_E_NOMEM;
22220 }
22221
22222 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
22223 buf);
22224 WMITLV_SET_HDR(&cmd->tlv_header,
22225 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
22226 WMITLV_GET_STRUCT_TLVLEN
22227 (wmi_obss_color_collision_det_config_fixed_param));
22228 cmd->vdev_id = cfg_param->vdev_id;
22229 cmd->flags = cfg_param->flags;
22230 cmd->current_bss_color = cfg_param->current_bss_color;
22231 cmd->detection_period_ms = cfg_param->detection_period_ms;
22232 cmd->scan_period_ms = cfg_param->scan_period_ms;
22233 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
22234
22235 switch (cfg_param->evt_type) {
22236 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
22237 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
22238 break;
22239 case OBSS_COLOR_COLLISION_DETECTION:
22240 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
22241 break;
22242 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22243 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22244 break;
22245 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
22246 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
22247 break;
22248 default:
22249 WMI_LOGE("%s: invalid event type: %d",
22250 __func__, cfg_param->evt_type);
22251 wmi_buf_free(buf);
22252 return QDF_STATUS_E_FAILURE;
22253 }
22254
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053022255 wmi_mtrace(WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID, cmd->vdev_id, 0);
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022256 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22257 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
22258 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
22259 __func__, cfg_param->vdev_id);
22260 wmi_buf_free(buf);
22261 return QDF_STATUS_E_FAILURE;
22262 }
22263
22264 return QDF_STATUS_SUCCESS;
22265}
22266
22267/**
22268 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
22269 * received from firmware.
22270 * @evt_buf: pointer to event buffer
22271 * @info: Pointer to hold bss collision info
22272 *
22273 * Return: QDF_STATUS
22274 */
22275static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
22276 struct wmi_obss_color_collision_info *info)
22277{
22278 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
22279 wmi_obss_color_collision_evt_fixed_param *fix_param;
22280
22281 if (!info) {
22282 WMI_LOGE("%s: Invalid obss color buffer", __func__);
22283 return QDF_STATUS_E_INVAL;
22284 }
22285
22286 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
22287 evt_buf;
22288 if (!param_buf) {
22289 WMI_LOGE("%s: Invalid evt_buf", __func__);
22290 return QDF_STATUS_E_INVAL;
22291 }
22292
22293 fix_param = param_buf->fixed_param;
22294 info->vdev_id = fix_param->vdev_id;
22295 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
22296 info->obss_color_bitmap_bit32to63 =
22297 fix_param->bss_color_bitmap_bit32to63;
22298
22299 switch (fix_param->evt_type) {
22300 case WMI_BSS_COLOR_COLLISION_DISABLE:
22301 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
22302 break;
22303 case WMI_BSS_COLOR_COLLISION_DETECTION:
22304 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
22305 break;
22306 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22307 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22308 break;
22309 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
22310 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
22311 break;
22312 default:
22313 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
22314 __func__, fix_param->evt_type, fix_param->vdev_id);
22315 return QDF_STATUS_E_FAILURE;
22316 }
22317
22318 return QDF_STATUS_SUCCESS;
22319}
22320
Arif Hussaine0eb7302018-03-01 14:40:59 -080022321/*
22322 * extract_comb_phyerr_tlv() - extract comb phy error from event
22323 * @wmi_handle: wmi handle
22324 * @evt_buf: pointer to event buffer
22325 * @datalen: data length of event buffer
22326 * @buf_offset: Pointer to hold value of current event buffer offset
22327 * post extraction
22328 * @phyerr: Pointer to hold phyerr
22329 *
22330 * Return: QDF_STATUS
22331 */
22332static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
22333 void *evt_buf,
22334 uint16_t datalen,
22335 uint16_t *buf_offset,
22336 wmi_host_phyerr_t *phyerr)
22337{
22338 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
22339 wmi_comb_phyerr_rx_hdr *pe_hdr;
22340
22341 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
22342 if (!param_tlvs) {
22343 WMI_LOGD("%s: Received null data from FW", __func__);
22344 return QDF_STATUS_E_FAILURE;
22345 }
22346
22347 pe_hdr = param_tlvs->hdr;
22348 if (!pe_hdr) {
22349 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
22350 return QDF_STATUS_E_FAILURE;
22351 }
22352
22353 /* Ensure it's at least the size of the header */
22354 if (datalen < sizeof(*pe_hdr)) {
22355 WMI_LOGD("%s: Expected minimum size %zu, received %d",
22356 __func__, sizeof(*pe_hdr), datalen);
22357 return QDF_STATUS_E_FAILURE;
22358 }
22359
22360 phyerr->pdev_id = wmi_handle->ops->
22361 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
22362 phyerr->tsf64 = pe_hdr->tsf_l32;
22363 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
22364 phyerr->bufp = param_tlvs->bufp;
22365 phyerr->buf_len = pe_hdr->buf_len;
22366 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
22367 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
22368 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
22369
22370 return QDF_STATUS_SUCCESS;
22371}
22372
22373/**
22374 * extract_single_phyerr_tlv() - extract single phy error from event
22375 * @wmi_handle: wmi handle
22376 * @evt_buf: pointer to event buffer
22377 * @datalen: data length of event buffer
22378 * @buf_offset: Pointer to hold value of current event buffer offset
22379 * post extraction
22380 * @phyerr: Pointer to hold phyerr
22381 *
22382 * Return: QDF_STATUS
22383 */
22384static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
22385 void *evt_buf,
22386 uint16_t datalen,
22387 uint16_t *buf_offset,
22388 wmi_host_phyerr_t *phyerr)
22389{
22390 wmi_single_phyerr_rx_event *ev;
22391 uint16_t n = *buf_offset;
22392 uint8_t *data = (uint8_t *)evt_buf;
22393
22394 if (n < datalen) {
22395 if ((datalen - n) < sizeof(ev->hdr)) {
22396 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
22397 __func__, datalen, n, sizeof(ev->hdr));
22398 return QDF_STATUS_E_FAILURE;
22399 }
22400
22401 /*
22402 * Obtain a pointer to the beginning of the current event.
22403 * data[0] is the beginning of the WMI payload.
22404 */
22405 ev = (wmi_single_phyerr_rx_event *)&data[n];
22406
22407 /*
22408 * Sanity check the buffer length of the event against
22409 * what we currently have.
22410 *
22411 * Since buf_len is 32 bits, we check if it overflows
22412 * a large 32 bit value. It's not 0x7fffffff because
22413 * we increase n by (buf_len + sizeof(hdr)), which would
22414 * in itself cause n to overflow.
22415 *
22416 * If "int" is 64 bits then this becomes a moot point.
22417 */
22418 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
22419 WMI_LOGD("%s: buf_len is garbage 0x%x",
22420 __func__, ev->hdr.buf_len);
22421 return QDF_STATUS_E_FAILURE;
22422 }
22423
22424 if ((n + ev->hdr.buf_len) > datalen) {
22425 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
22426 __func__, n, ev->hdr.buf_len, datalen);
22427 return QDF_STATUS_E_FAILURE;
22428 }
22429
22430 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
22431 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
22432 phyerr->bufp = &ev->bufp[0];
22433 phyerr->buf_len = ev->hdr.buf_len;
22434 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
22435
22436 /*
22437 * Advance the buffer pointer to the next PHY error.
22438 * buflen is the length of this payload, so we need to
22439 * advance past the current header _AND_ the payload.
22440 */
22441 n += sizeof(*ev) + ev->hdr.buf_len;
22442 }
22443 *buf_offset = n;
22444
22445 return QDF_STATUS_SUCCESS;
22446}
22447
Subrat Mishraa667b1c2018-08-02 15:02:04 +053022448/**
22449 * extract_esp_estimation_ev_param_tlv() - extract air time from event
22450 * @wmi_handle: wmi handle
22451 * @evt_buf: pointer to event buffer
22452 * @param: Pointer to hold esp event
22453 *
22454 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
22455 */
22456static QDF_STATUS
22457extract_esp_estimation_ev_param_tlv(wmi_unified_t wmi_handle,
22458 void *evt_buf,
22459 struct esp_estimation_event *param)
22460{
22461 WMI_ESP_ESTIMATE_EVENTID_param_tlvs *param_buf;
22462 wmi_esp_estimate_event_fixed_param *esp_event;
22463
22464 param_buf = (WMI_ESP_ESTIMATE_EVENTID_param_tlvs *)evt_buf;
22465 if (!param_buf) {
22466 WMI_LOGE("Invalid ESP Estimate Event buffer");
22467 return QDF_STATUS_E_INVAL;
22468 }
22469 esp_event = param_buf->fixed_param;
22470 param->ac_airtime_percentage = esp_event->ac_airtime_percentage;
22471 param->pdev_id = convert_target_pdev_id_to_host_pdev_id(
22472 esp_event->pdev_id);
22473
22474 return QDF_STATUS_SUCCESS;
22475}
22476
Govind Singh5eb51532016-03-09 11:34:12 +053022477struct wmi_ops tlv_ops = {
22478 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
22479 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
22480 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053022481 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
22482 .send_hidden_ssid_vdev_restart_cmd =
22483 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022484 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
22485 .send_peer_param_cmd = send_peer_param_cmd_tlv,
22486 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022487 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022488 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022489 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070022490 .send_peer_rx_reorder_queue_setup_cmd =
22491 send_peer_rx_reorder_queue_setup_cmd_tlv,
22492 .send_peer_rx_reorder_queue_remove_cmd =
22493 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053022494 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
22495 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
22496 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022497 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
22498 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022499 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022500 .send_suspend_cmd = send_suspend_cmd_tlv,
22501 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080022502#ifdef FEATURE_WLAN_D0WOW
22503 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
22504 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
22505#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022506 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
22507 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
22508 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
22509 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080022510#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053022511 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080022512#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022513 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
22514 .send_stats_request_cmd = send_stats_request_cmd_tlv,
22515 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053022516 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070022517 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022518 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022519 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022520 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
22521 .send_scan_start_cmd = send_scan_start_cmd_tlv,
22522 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
22523 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022524 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022525 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022526 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
22527 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022528 .send_set_sta_uapsd_auto_trig_cmd =
22529 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022530 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
22531 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
22532 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Rachit Kankane9cd0c752018-07-31 16:26:38 +053022533#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +080022534 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
22535 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
22536#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053022537 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
22538 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022539#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053022540 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
22541 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
22542 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
22543 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
22544 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
22545 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
22546 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022547 .send_ocb_start_timing_advert_cmd =
22548 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022549 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
22550 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
22551 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
22552 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
22553#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053022554 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
22555 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
22556 .send_set_mcc_channel_time_latency_cmd =
22557 send_set_mcc_channel_time_latency_cmd_tlv,
22558 .send_set_mcc_channel_time_quota_cmd =
22559 send_set_mcc_channel_time_quota_cmd_tlv,
22560 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
22561 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053022562 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022563 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
22564 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
22565 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022566 .send_probe_rsp_tmpl_send_cmd =
22567 send_probe_rsp_tmpl_send_cmd_tlv,
22568 .send_p2p_go_set_beacon_ie_cmd =
22569 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053022570 .send_setup_install_key_cmd =
22571 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022572 .send_set_gateway_params_cmd =
22573 send_set_gateway_params_cmd_tlv,
22574 .send_set_rssi_monitoring_cmd =
22575 send_set_rssi_monitoring_cmd_tlv,
22576 .send_scan_probe_setoui_cmd =
22577 send_scan_probe_setoui_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022578 .send_roam_scan_offload_rssi_thresh_cmd =
22579 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070022580 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022581 .send_roam_scan_filter_cmd =
22582 send_roam_scan_filter_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022583#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053022584 .send_ipa_offload_control_cmd =
22585 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022586#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053022587 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
22588 .send_plm_start_cmd = send_plm_start_cmd_tlv,
22589 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
22590 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070022591 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022592 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080022593#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053022594 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
22595 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
22596 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080022597#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053022598 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022599 .send_snr_request_cmd = send_snr_request_cmd_tlv,
22600 .send_snr_cmd = send_snr_cmd_tlv,
22601 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080022602#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022603 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
22604 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
22605 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
22606 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053022607 .send_multiple_add_clear_mcbc_filter_cmd =
22608 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070022609 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022610 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
22611 .send_process_gtk_offload_getinfo_cmd =
22612 send_process_gtk_offload_getinfo_cmd_tlv,
22613 .send_enable_enhance_multicast_offload_cmd =
22614 send_enable_enhance_multicast_offload_tlv,
22615 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
22616#ifdef FEATURE_WLAN_RA_FILTERING
22617 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
22618#endif
22619 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022620 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
22621 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022622 .send_lphb_config_tcp_pkt_filter_cmd =
22623 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022624 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22625 .send_lphb_config_udp_pkt_filter_cmd =
22626 send_lphb_config_udp_pkt_filter_cmd_tlv,
Rachit Kankaneed139ff2018-08-01 14:23:55 +053022627#ifdef WLAN_FEATURE_PACKET_FILTERING
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022628 .send_enable_disable_packet_filter_cmd =
22629 send_enable_disable_packet_filter_cmd_tlv,
22630 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Rachit Kankaneed139ff2018-08-01 14:23:55 +053022631#endif
Wu Gao52c0b772018-05-17 16:14:00 +080022632#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022633#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022634 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22635 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022636 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022637 .send_roam_scan_offload_mode_cmd =
22638 send_roam_scan_offload_mode_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053022639#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053022640 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053022641#endif
Govind Singh87542482016-06-08 19:40:11 +053022642 .send_roam_scan_offload_ap_profile_cmd =
22643 send_roam_scan_offload_ap_profile_cmd_tlv,
22644#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022645#ifdef WLAN_SUPPORT_GREEN_AP
22646 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22647 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022648 .extract_green_ap_egap_status_info =
22649 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022650#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022651 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22652 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022653 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022654 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022655 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022656#ifdef WLAN_FEATURE_CIF_CFR
22657 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22658#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022659 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022660 .send_dfs_phyerr_filter_offload_en_cmd =
22661 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022662 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22663 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22664 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22665 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22666 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022667 .send_process_add_periodic_tx_ptrn_cmd =
22668 send_process_add_periodic_tx_ptrn_cmd_tlv,
22669 .send_process_del_periodic_tx_ptrn_cmd =
22670 send_process_del_periodic_tx_ptrn_cmd_tlv,
22671 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22672 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22673 .send_set_app_type2_params_in_fw_cmd =
22674 send_set_app_type2_params_in_fw_cmd_tlv,
22675 .send_set_auto_shutdown_timer_cmd =
22676 send_set_auto_shutdown_timer_cmd_tlv,
22677 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22678 .send_process_dhcpserver_offload_cmd =
22679 send_process_dhcpserver_offload_cmd_tlv,
22680 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22681 .send_process_ch_avoid_update_cmd =
22682 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022683 .send_pdev_set_regdomain_cmd =
22684 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022685 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22686 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22687 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22688 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022689 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022690 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022691 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022692 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022693 .send_set_base_macaddr_indicate_cmd =
22694 send_set_base_macaddr_indicate_cmd_tlv,
22695 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22696 .send_enable_specific_fw_logs_cmd =
22697 send_enable_specific_fw_logs_cmd_tlv,
22698 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022699 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022700 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022701#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022702 .send_pdev_set_dual_mac_config_cmd =
22703 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080022704#endif
Govind Singha4836fd2016-03-07 16:45:38 +053022705 .send_app_type1_params_in_fw_cmd =
22706 send_app_type1_params_in_fw_cmd_tlv,
22707 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22708 .send_process_roam_synch_complete_cmd =
22709 send_process_roam_synch_complete_cmd_tlv,
22710 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22711 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22712 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022713 .send_roam_scan_offload_scan_period_cmd =
22714 send_roam_scan_offload_scan_period_cmd_tlv,
22715 .send_roam_scan_offload_chan_list_cmd =
22716 send_roam_scan_offload_chan_list_cmd_tlv,
22717 .send_roam_scan_offload_rssi_change_cmd =
22718 send_roam_scan_offload_rssi_change_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022719#ifdef FEATURE_WLAN_APF
22720 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
22721 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
22722 .send_apf_write_work_memory_cmd =
22723 wmi_send_apf_write_work_memory_cmd_tlv,
22724 .send_apf_read_work_memory_cmd =
22725 wmi_send_apf_read_work_memory_cmd_tlv,
22726 .extract_apf_read_memory_resp_event =
22727 wmi_extract_apf_read_memory_resp_event_tlv,
22728#endif /* FEATURE_WLAN_APF */
Gupta, Kapil2e685982016-04-25 19:14:19 +053022729 .send_adapt_dwelltime_params_cmd =
22730 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022731 .send_dbs_scan_sel_params_cmd =
22732 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022733 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022734 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22735 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22736 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22737 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22738 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22739 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022740 .send_vdev_set_custom_aggr_size_cmd =
22741 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022742 .send_vdev_set_qdepth_thresh_cmd =
22743 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022744 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22745 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22746 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022747 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22748 .send_smart_ant_set_training_info_cmd =
22749 send_smart_ant_set_training_info_cmd_tlv,
22750 .send_smart_ant_set_node_config_cmd =
22751 send_smart_ant_set_node_config_cmd_tlv,
Jeffin Mammen095050b2018-07-24 14:20:08 +053022752#ifdef WLAN_ATF_ENABLE
Sathish Kumar02c3b542017-02-22 17:24:45 +053022753 .send_set_atf_cmd = send_set_atf_cmd_tlv,
Jeffin Mammen095050b2018-07-24 14:20:08 +053022754#endif
Sathish Kumar02c3b542017-02-22 17:24:45 +053022755 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22756 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022757 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22758 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22759 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22760 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022761 .send_periodic_chan_stats_config_cmd =
22762 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022763 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22764 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22765 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022766 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22767 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22768 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22769 .send_vdev_spectral_configure_cmd =
22770 send_vdev_spectral_configure_cmd_tlv,
22771 .send_vdev_spectral_enable_cmd =
22772 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022773 .send_thermal_mitigation_param_cmd =
22774 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022775 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22776 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022777 .send_process_update_edca_param_cmd =
22778 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022779 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022780 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022781 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022782 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22783 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022784 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022785 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22786 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22787 .extract_host_mem_req = extract_host_mem_req_tlv,
22788 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022789 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022790 .is_service_enabled = is_service_enabled_tlv,
22791 .save_fw_version = save_fw_version_in_service_ready_tlv,
22792 .ready_extract_init_status = ready_extract_init_status_tlv,
22793 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022794 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022795 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022796 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22797 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022798 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022799 .extract_tbttoffset_update_params =
22800 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022801 .extract_ext_tbttoffset_update_params =
22802 extract_ext_tbttoffset_update_params_tlv,
22803 .extract_tbttoffset_num_vdevs =
22804 extract_tbttoffset_num_vdevs_tlv,
22805 .extract_ext_tbttoffset_num_vdevs =
22806 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022807 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22808 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22809 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22810 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022811#ifdef CONVERGED_TDLS_ENABLE
22812 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22813#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022814 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022815 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022816 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22817 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022818#ifdef CONVERGED_P2P_ENABLE
22819 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
Rachit Kankane9cd0c752018-07-31 16:26:38 +053022820#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Wu Gaocd3a8512017-03-13 20:17:34 +080022821 .extract_p2p_lo_stop_ev_param =
22822 extract_p2p_lo_stop_ev_param_tlv,
22823#endif
Rachit Kankane9cd0c752018-07-31 16:26:38 +053022824#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022825 .extract_offchan_data_tx_compl_param =
22826 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022827 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22828 .extract_all_stats_count = extract_all_stats_counts_tlv,
22829 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022830 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022831 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22832 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070022833 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022834 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022835 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022836 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22837 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22838 .extract_chan_stats = extract_chan_stats_tlv,
22839 .extract_profile_ctx = extract_profile_ctx_tlv,
22840 .extract_profile_data = extract_profile_data_tlv,
22841 .extract_chan_info_event = extract_chan_info_event_tlv,
22842 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022843 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022844#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022845 .send_encrypt_decrypt_send_cmd =
22846 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022847 .extract_encrypt_decrypt_resp_event =
22848 extract_encrypt_decrypt_resp_event_tlv,
22849#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022850 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022851 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22852 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022853 .extract_sar2_result_event = extract_sar2_result_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022854 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022855 .send_multiple_vdev_restart_req_cmd =
22856 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022857 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22858 .extract_hw_mode_cap_service_ready_ext =
22859 extract_hw_mode_cap_service_ready_ext_tlv,
22860 .extract_mac_phy_cap_service_ready_ext =
22861 extract_mac_phy_cap_service_ready_ext_tlv,
22862 .extract_reg_cap_service_ready_ext =
22863 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022864 .extract_dbr_ring_cap_service_ready_ext =
22865 extract_dbr_ring_cap_service_ready_ext_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070022866 .extract_sar_cap_service_ready_ext =
22867 extract_sar_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022868 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22869 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022870 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022871 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022872 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022873 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22874 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22875 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022876 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022877 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022878 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022879 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022880 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022881 .extract_pdev_csa_switch_count_status =
22882 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022883 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022884 .extract_pdev_tpc_config_ev_param =
22885 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022886 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022887 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22888 .extract_peer_sta_ps_statechange_ev =
22889 extract_peer_sta_ps_statechange_ev_tlv,
22890 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022891 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053022892#ifdef WLAN_FEATURE_ACTION_OUI
22893 .send_action_oui_cmd = send_action_oui_cmd_tlv,
22894#endif
Arif Hussainf00be1d2017-01-07 18:21:55 -080022895 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22896 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022897 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022898 extract_reg_chan_list_update_event_tlv,
22899 .extract_chainmask_tables =
22900 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022901 .extract_thermal_stats = extract_thermal_stats_tlv,
22902 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022903 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22904 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022905#ifdef DFS_COMPONENT_ENABLE
22906 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22907 .extract_dfs_radar_detection_event =
22908 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022909 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022910#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022911 .convert_pdev_id_host_to_target =
22912 convert_host_pdev_id_to_target_pdev_id_legacy,
22913 .convert_pdev_id_target_to_host =
22914 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022915
22916 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22917 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22918 .extract_reg_11d_new_country_event =
22919 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022920 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022921 .send_limit_off_chan_cmd =
22922 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022923 .extract_reg_ch_avoid_event =
22924 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022925 .send_pdev_caldata_version_check_cmd =
22926 send_pdev_caldata_version_check_cmd_tlv,
22927 .extract_pdev_caldata_version_check_ev_param =
22928 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022929 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22930 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022931 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22932#if defined(WLAN_FEATURE_FILS_SK)
22933 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22934#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022935 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022936#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22937 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22938 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22939 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22940 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22941 .extract_ndp_ind = extract_ndp_ind_tlv,
22942 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22943 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22944 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22945 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
Naveen Rawatd42ce382018-01-09 17:54:41 -080022946 .extract_ndp_sch_update = extract_ndp_sch_update_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022947#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022948 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022949 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022950 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022951#ifdef WLAN_SUPPORT_FILS
22952 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22953 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22954 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22955#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022956 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22957 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022958 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22959 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22960 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22961 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022962 .send_bss_color_change_enable_cmd =
22963 send_bss_color_change_enable_cmd_tlv,
22964 .send_obss_color_collision_cfg_cmd =
22965 send_obss_color_collision_cfg_cmd_tlv,
22966 .extract_obss_color_collision_info =
22967 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022968 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22969 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070022970#ifdef QCA_SUPPORT_CP_STATS
22971 .extract_cca_stats = extract_cca_stats_tlv,
22972#endif
Subrat Mishraa667b1c2018-08-02 15:02:04 +053022973 .extract_esp_estimation_ev_param =
22974 extract_esp_estimation_ev_param_tlv,
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053022975 .send_roam_scan_stats_cmd = send_roam_scan_stats_cmd_tlv,
22976 .extract_roam_scan_stats_res_evt = extract_roam_scan_stats_res_evt_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022977};
22978
Govind Singhe7f2f342016-05-23 12:12:52 +053022979/**
22980 * populate_tlv_event_id() - populates wmi event ids
22981 *
22982 * @param event_ids: Pointer to hold event ids
22983 * Return: None
22984 */
22985static void populate_tlv_events_id(uint32_t *event_ids)
22986{
22987 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22988 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22989 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22990 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22991 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22992 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22993 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22994 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22995 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22996 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22997 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22998 event_ids[wmi_service_ready_ext_event_id] =
22999 WMI_SERVICE_READY_EXT_EVENTID;
23000 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
23001 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
23002 event_ids[wmi_vdev_install_key_complete_event_id] =
23003 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
23004 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
23005 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
23006
23007 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
23008 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
23009 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
23010 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
23011 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
23012 event_ids[wmi_peer_estimated_linkspeed_event_id] =
23013 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
23014 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053023015 event_ids[wmi_peer_delete_response_event_id] =
23016 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023017 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
23018 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
23019 event_ids[wmi_tbttoffset_update_event_id] =
23020 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053023021 event_ids[wmi_ext_tbttoffset_update_event_id] =
23022 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023023 event_ids[wmi_offload_bcn_tx_status_event_id] =
23024 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
23025 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
23026 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
23027 event_ids[wmi_mgmt_tx_completion_event_id] =
23028 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080023029 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
23030 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023031 event_ids[wmi_tx_delba_complete_event_id] =
23032 WMI_TX_DELBA_COMPLETE_EVENTID;
23033 event_ids[wmi_tx_addba_complete_event_id] =
23034 WMI_TX_ADDBA_COMPLETE_EVENTID;
23035 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
23036
23037 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
23038
23039 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
23040 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
23041
23042 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053023043 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023044
23045 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
23046
23047 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080023048 event_ids[wmi_p2p_lo_stop_event_id] =
23049 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023050 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
23051 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080023052 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053023053 WMI_D0_WOW_DISABLE_ACK_EVENTID;
23054 event_ids[wmi_wow_initial_wakeup_event_id] =
23055 WMI_WOW_INITIAL_WAKEUP_EVENTID;
23056
23057 event_ids[wmi_rtt_meas_report_event_id] =
23058 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
23059 event_ids[wmi_tsf_meas_report_event_id] =
23060 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
23061 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
23062 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
23063 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
23064 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
23065 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023066 event_ids[wmi_diag_event_id_log_supported_event_id] =
23067 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
23068 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
23069 event_ids[wmi_nlo_scan_complete_event_id] =
23070 WMI_NLO_SCAN_COMPLETE_EVENTID;
23071 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
23072 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
23073
23074 event_ids[wmi_gtk_offload_status_event_id] =
23075 WMI_GTK_OFFLOAD_STATUS_EVENTID;
23076 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
23077 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
23078 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
23079
23080 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
23081
23082 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
23083
23084 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
23085 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
23086 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
23087 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
23088 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
23089 event_ids[wmi_wlan_profile_data_event_id] =
23090 WMI_WLAN_PROFILE_DATA_EVENTID;
23091 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
23092 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
23093 event_ids[wmi_vdev_get_keepalive_event_id] =
23094 WMI_VDEV_GET_KEEPALIVE_EVENTID;
23095 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
23096
23097 event_ids[wmi_diag_container_event_id] =
23098 WMI_DIAG_DATA_CONTAINER_EVENTID;
23099
23100 event_ids[wmi_host_auto_shutdown_event_id] =
23101 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
23102
23103 event_ids[wmi_update_whal_mib_stats_event_id] =
23104 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
23105
23106 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
23107 event_ids[wmi_update_vdev_rate_stats_event_id] =
23108 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
23109
23110 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070023111 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023112
23113 /** Set OCB Sched Response, deprecated */
23114 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
23115
23116 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
23117 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
23118 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
23119
23120 /* GPIO Event */
23121 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
23122 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
23123
23124 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
23125 event_ids[wmi_rfkill_state_change_event_id] =
23126 WMI_RFKILL_STATE_CHANGE_EVENTID;
23127
23128 /* TDLS Event */
23129 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
23130
23131 event_ids[wmi_batch_scan_enabled_event_id] =
23132 WMI_BATCH_SCAN_ENABLED_EVENTID;
23133 event_ids[wmi_batch_scan_result_event_id] =
23134 WMI_BATCH_SCAN_RESULT_EVENTID;
23135 /* OEM Event */
23136 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
23137 event_ids[wmi_oem_meas_report_event_id] =
23138 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
23139 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
23140
23141 /* NAN Event */
23142 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
23143
23144 /* LPI Event */
23145 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
23146 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
23147 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
23148
23149 /* ExtScan events */
23150 event_ids[wmi_extscan_start_stop_event_id] =
23151 WMI_EXTSCAN_START_STOP_EVENTID;
23152 event_ids[wmi_extscan_operation_event_id] =
23153 WMI_EXTSCAN_OPERATION_EVENTID;
23154 event_ids[wmi_extscan_table_usage_event_id] =
23155 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
23156 event_ids[wmi_extscan_cached_results_event_id] =
23157 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
23158 event_ids[wmi_extscan_wlan_change_results_event_id] =
23159 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
23160 event_ids[wmi_extscan_hotlist_match_event_id] =
23161 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
23162 event_ids[wmi_extscan_capabilities_event_id] =
23163 WMI_EXTSCAN_CAPABILITIES_EVENTID;
23164 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
23165 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
23166
23167 /* mDNS offload events */
23168 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
23169
23170 /* SAP Authentication offload events */
23171 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
23172 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
23173
23174 /** Out-of-context-of-bss (OCB) events */
23175 event_ids[wmi_ocb_set_config_resp_event_id] =
23176 WMI_OCB_SET_CONFIG_RESP_EVENTID;
23177 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
23178 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
23179 event_ids[wmi_dcc_get_stats_resp_event_id] =
23180 WMI_DCC_GET_STATS_RESP_EVENTID;
23181 event_ids[wmi_dcc_update_ndl_resp_event_id] =
23182 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
23183 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
23184 /* System-On-Chip events */
23185 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
23186 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
23187 event_ids[wmi_soc_hw_mode_transition_event_id] =
23188 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
23189 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
23190 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053023191 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053023192 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
23193 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053023194 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053023195 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
23196 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
23197 event_ids[wmi_peer_sta_ps_statechg_event_id] =
23198 WMI_PEER_STA_PS_STATECHG_EVENTID;
23199 event_ids[wmi_pdev_channel_hopping_event_id] =
23200 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053023201 event_ids[wmi_offchan_data_tx_completion_event] =
23202 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070023203 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
23204 event_ids[wmi_dfs_radar_detection_event_id] =
23205 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053023206 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070023207 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053023208 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053023209 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053023210 event_ids[wmi_service_available_event_id] =
23211 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053023212 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053023213 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053023214 /* NDP events */
23215 event_ids[wmi_ndp_initiator_rsp_event_id] =
23216 WMI_NDP_INITIATOR_RSP_EVENTID;
23217 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
23218 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
23219 event_ids[wmi_ndp_responder_rsp_event_id] =
23220 WMI_NDP_RESPONDER_RSP_EVENTID;
23221 event_ids[wmi_ndp_end_indication_event_id] =
23222 WMI_NDP_END_INDICATION_EVENTID;
23223 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080023224 event_ids[wmi_ndl_schedule_update_event_id] =
23225 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053023226
23227 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
23228 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
23229 event_ids[wmi_pdev_chip_power_stats_event_id] =
23230 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
23231 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
23232 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
23233 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053023234 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053023235 WMI_BPF_CAPABILIY_INFO_EVENTID;
23236 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
23237 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
23238 event_ids[wmi_report_rx_aggr_failure_event_id] =
23239 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
23240 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
23241 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
23242 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
23243 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
23244 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
23245 event_ids[wmi_pdev_hw_mode_transition_event_id] =
23246 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
23247 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
23248 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
23249 event_ids[wmi_coex_bt_activity_event_id] =
23250 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
23251 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
23252 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
23253 event_ids[wmi_radio_tx_power_level_stats_event_id] =
23254 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
23255 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053023256 event_ids[wmi_dma_buf_release_event_id] =
23257 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080023258 event_ids[wmi_sap_obss_detection_report_event_id] =
23259 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053023260 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080023261 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080023262 event_ids[wmi_obss_color_collision_report_event_id] =
23263 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080023264 event_ids[wmi_pdev_div_rssi_antid_event_id] =
23265 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070023266 event_ids[wmi_twt_enable_complete_event_id] =
23267 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053023268 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
23269 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070023270 event_ids[wmi_wlan_sar2_result_event_id] = WMI_SAR2_RESULT_EVENTID;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053023271 event_ids[wmi_esp_estimate_event_id] = WMI_ESP_ESTIMATE_EVENTID;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053023272 event_ids[wmi_roam_scan_stats_event_id] = WMI_ROAM_SCAN_STATS_EVENTID;
Kiran Venkatappad73f4eb2018-07-19 22:22:29 +053023273#ifdef AST_HKV1_WORKAROUND
23274 event_ids[wmi_wds_peer_event_id] = WMI_WDS_PEER_EVENTID;
23275#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053023276}
23277
Soumya Bhat488092d2017-03-22 14:41:01 +053023278/**
23279 * populate_tlv_service() - populates wmi services
23280 *
23281 * @param wmi_service: Pointer to hold wmi_service
23282 * Return: None
23283 */
23284static void populate_tlv_service(uint32_t *wmi_service)
23285{
23286 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023287 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023288 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
23289 wmi_service[wmi_service_roam_scan_offload] =
23290 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
23291 wmi_service[wmi_service_bcn_miss_offload] =
23292 WMI_SERVICE_BCN_MISS_OFFLOAD;
23293 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
23294 wmi_service[wmi_service_sta_advanced_pwrsave] =
23295 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
23296 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
23297 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
23298 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
23299 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
23300 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
23301 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
23302 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
23303 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
23304 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
23305 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
23306 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
23307 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
23308 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
23309 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
23310 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
23311 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
23312 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
23313 wmi_service[wmi_service_packet_power_save] =
23314 WMI_SERVICE_PACKET_POWER_SAVE;
23315 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
23316 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
23317 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
23318 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
23319 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
23320 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
23321 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
23322 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
23323 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
23324 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
23325 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
23326 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
23327 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
23328 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
23329 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
23330 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
23331 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
23332 wmi_service[wmi_service_mcc_bcn_interval_change] =
23333 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
23334 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
23335 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
23336 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
23337 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
23338 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
23339 wmi_service[wmi_service_lte_ant_share_support] =
23340 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
23341 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
23342 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
23343 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
23344 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
23345 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
23346 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
23347 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
23348 wmi_service[wmi_service_bcn_txrate_override] =
23349 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
23350 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
23351 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
23352 wmi_service[wmi_service_estimate_linkspeed] =
23353 WMI_SERVICE_ESTIMATE_LINKSPEED;
23354 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
23355 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
23356 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
23357 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
23358 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
23359 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
23360 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
23361 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
23362 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
23363 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
23364 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
23365 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
23366 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
23367 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
23368 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
23369 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
23370 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
23371 wmi_service[wmi_service_sap_auth_offload] =
23372 WMI_SERVICE_SAP_AUTH_OFFLOAD;
23373 wmi_service[wmi_service_dual_band_simultaneous_support] =
23374 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
23375 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
23376 wmi_service[wmi_service_ap_arpns_offload] =
23377 WMI_SERVICE_AP_ARPNS_OFFLOAD;
23378 wmi_service[wmi_service_per_band_chainmask_support] =
23379 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
23380 wmi_service[wmi_service_packet_filter_offload] =
23381 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
23382 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
23383 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
23384 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
23385 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
23386 wmi_service[wmi_service_multiple_vdev_restart] =
23387 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
23388
23389 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
23390 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
23391 wmi_service[wmi_service_smart_antenna_sw_support] =
23392 WMI_SERVICE_UNAVAILABLE;
23393 wmi_service[wmi_service_smart_antenna_hw_support] =
23394 WMI_SERVICE_UNAVAILABLE;
23395 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053023396 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023397 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053023398 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
23399 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
23400 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
23401 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
23402 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
23403 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
23404 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
23405 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053023406 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
23407 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
23408 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053023409 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023410 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
23411 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
23412 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
23413 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
23414 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
23415 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053023416 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
23417 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
23418 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
23419 wmi_service[wmi_service_unified_wow_capability] =
23420 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
23421 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053023422 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053023423 wmi_service[wmi_service_sync_delete_cmds] =
23424 WMI_SERVICE_SYNC_DELETE_CMDS;
23425 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
23426 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
23427 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
23428 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
23429 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
23430 wmi_service[wmi_service_deprecated_replace] =
23431 WMI_SERVICE_DEPRECATED_REPLACE;
23432 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
23433 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
23434 wmi_service[wmi_service_enhanced_mcast_filter] =
23435 WMI_SERVICE_ENHANCED_MCAST_FILTER;
23436 wmi_service[wmi_service_half_rate_quarter_rate_support] =
23437 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
23438 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
23439 wmi_service[wmi_service_p2p_listen_offload_support] =
23440 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
23441 wmi_service[wmi_service_mark_first_wakeup_packet] =
23442 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
23443 wmi_service[wmi_service_multiple_mcast_filter_set] =
23444 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
23445 wmi_service[wmi_service_host_managed_rx_reorder] =
23446 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
23447 wmi_service[wmi_service_flash_rdwr_support] =
23448 WMI_SERVICE_FLASH_RDWR_SUPPORT;
23449 wmi_service[wmi_service_wlan_stats_report] =
23450 WMI_SERVICE_WLAN_STATS_REPORT;
23451 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
23452 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
23453 wmi_service[wmi_service_dfs_phyerr_offload] =
23454 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
23455 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
23456 wmi_service[wmi_service_fw_mem_dump_support] =
23457 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
23458 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
23459 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
23460 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
23461 wmi_service[wmi_service_hw_data_filtering] =
23462 WMI_SERVICE_HW_DATA_FILTERING;
23463 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
23464 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053023465 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053023466 wmi_service[wmi_service_extended_nss_support] =
23467 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053023468 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053023469 wmi_service[wmi_service_bcn_offload_start_stop_support] =
23470 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053023471 wmi_service[wmi_service_offchan_data_tid_support] =
23472 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053023473 wmi_service[wmi_service_support_dma] =
23474 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023475 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
23476 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
23477 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080023478 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
23479 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053023480 wmi_service[wmi_service_11k_neighbour_report_support] =
23481 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080023482 wmi_service[wmi_service_ap_obss_detection_offload] =
23483 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
23484 wmi_service[wmi_service_bss_color_offload] =
23485 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053023486 wmi_service[wmi_service_gmac_offload_support] =
23487 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080023488 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
23489 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
23490 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
23491 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070023492 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
23493 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053023494 wmi_service[wmi_service_listen_interval_offload_support] =
23495 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023496
Soumya Bhat488092d2017-03-22 14:41:01 +053023497}
23498
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023499#ifndef CONFIG_MCL
23500
Govind Singhe7f2f342016-05-23 12:12:52 +053023501/**
23502 * populate_pdev_param_tlv() - populates pdev params
23503 *
23504 * @param pdev_param: Pointer to hold pdev params
23505 * Return: None
23506 */
23507static void populate_pdev_param_tlv(uint32_t *pdev_param)
23508{
23509 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
23510 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
23511 pdev_param[wmi_pdev_param_txpower_limit2g] =
23512 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
23513 pdev_param[wmi_pdev_param_txpower_limit5g] =
23514 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
23515 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
23516 pdev_param[wmi_pdev_param_beacon_gen_mode] =
23517 WMI_PDEV_PARAM_BEACON_GEN_MODE;
23518 pdev_param[wmi_pdev_param_beacon_tx_mode] =
23519 WMI_PDEV_PARAM_BEACON_TX_MODE;
23520 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
23521 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
23522 pdev_param[wmi_pdev_param_protection_mode] =
23523 WMI_PDEV_PARAM_PROTECTION_MODE;
23524 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
23525 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
23526 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
23527 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
23528 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
23529 pdev_param[wmi_pdev_param_sta_kickout_th] =
23530 WMI_PDEV_PARAM_STA_KICKOUT_TH;
23531 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
23532 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
23533 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
23534 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
23535 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
23536 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
23537 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
23538 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
23539 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
23540 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
23541 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
23542 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
23543 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
23544 pdev_param[wmi_pdev_param_ltr_sleep_override] =
23545 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
23546 pdev_param[wmi_pdev_param_ltr_rx_override] =
23547 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
23548 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
23549 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
23550 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
23551 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
23552 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
23553 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
23554 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
23555 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
23556 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
23557 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
23558 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
23559 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
23560 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
23561 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
23562 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
23563 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
23564 pdev_param[wmi_pdev_param_peer_stats_update_period] =
23565 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
23566 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
23567 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
23568 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
23569 pdev_param[wmi_pdev_param_arp_ac_override] =
23570 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
23571 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
23572 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
23573 pdev_param[wmi_pdev_param_ani_poll_period] =
23574 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
23575 pdev_param[wmi_pdev_param_ani_listen_period] =
23576 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
23577 pdev_param[wmi_pdev_param_ani_ofdm_level] =
23578 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
23579 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
23580 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
23581 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
23582 pdev_param[wmi_pdev_param_idle_ps_config] =
23583 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
23584 pdev_param[wmi_pdev_param_power_gating_sleep] =
23585 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
23586 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
23587 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
23588 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
23589 pdev_param[wmi_pdev_param_hw_rfkill_config] =
23590 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
23591 pdev_param[wmi_pdev_param_low_power_rf_enable] =
23592 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
23593 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
23594 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
23595 pdev_param[wmi_pdev_param_power_collapse_enable] =
23596 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
23597 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
23598 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
23599 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
23600 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
23601 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
23602 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
23603 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
23604 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
23605 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
23606 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
23607 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
23608 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
23609 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
23610 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
23611 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
23612 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
23613 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
23614 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
23615 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
23616 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
23617 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
23618 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
23619 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
23620 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
23621 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
23622 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
23623 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
23624 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
23625 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
23626 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
23627 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
23628 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
23629 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
23630 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
23631 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
23632 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
23633 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
23634 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
23635 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23636 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23637 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23638 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23639 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23640 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023641 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23642 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23643 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023644 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23645 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023646 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023647 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023648 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23649 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23650 WMI_PDEV_PARAM_PROXY_STA_MODE;
23651 pdev_param[wmi_pdev_param_mu_group_policy] =
23652 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23653 pdev_param[wmi_pdev_param_noise_detection] =
23654 WMI_PDEV_PARAM_NOISE_DETECTION;
23655 pdev_param[wmi_pdev_param_noise_threshold] =
23656 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23657 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23658 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23659 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023660 pdev_param[wmi_pdev_param_atf_strict_sch] =
23661 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23662 pdev_param[wmi_pdev_param_atf_sched_duration] =
23663 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023664 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23665 pdev_param[wmi_pdev_param_sensitivity_level] =
23666 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23667 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23668 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23669 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23670 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023671 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23672 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23673 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23674 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023675 pdev_param[wmi_pdev_param_cca_threshold] =
23676 WMI_PDEV_PARAM_CCA_THRESHOLD;
23677 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23678 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023679 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023680 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23681 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23682 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23683 pdev_param[wmi_pdev_param_arp_srcaddr] =
23684 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23685 pdev_param[wmi_pdev_param_arp_dstaddr] =
23686 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23687 pdev_param[wmi_pdev_param_txpower_decr_db] =
23688 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023689 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23690 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023691 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23692 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023693 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023694 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023695 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23696 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023697 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23698 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023699 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23700 WMI_UNAVAILABLE_PARAM;
Sathish Kumar210b4062018-07-03 17:25:11 +053023701 pdev_param[wmi_pdev_param_igmpmld_override] =
23702 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23703 pdev_param[wmi_pdev_param_igmpmld_tid] =
23704 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023705 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23706 pdev_param[wmi_pdev_param_block_interbss] =
23707 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023708 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023709 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23710 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23711 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023712 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023713 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023714 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23715 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023716 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023717 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23718 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023719 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23720 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23721 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23722 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
Sathish Kumara059f412017-03-22 19:10:28 +053023723 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23724 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23725 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23726 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23727 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23728 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23729 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23730 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23731 pdev_param[wmi_pdev_param_fast_channel_reset] =
23732 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23733 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023734 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023735 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053023736 pdev_param[wmi_pdev_param_antenna_gain_half_db] =
23737 WMI_PDEV_PARAM_ANTENNA_GAIN_HALF_DB;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053023738 pdev_param[wmi_pdev_param_esp_indication_period] =
23739 WMI_PDEV_PARAM_ESP_INDICATION_PERIOD;
Venkateswara Swamy Bandaruc9906412018-08-06 20:44:28 +053023740#ifdef WLAN_RU26_SUPPORT
23741 pdev_param[wmi_pdev_param_ru26_allowed] = WMI_PDEV_PARAM_RU26_ALLOWED;
23742#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053023743}
23744
23745/**
23746 * populate_vdev_param_tlv() - populates vdev params
23747 *
23748 * @param vdev_param: Pointer to hold vdev params
23749 * Return: None
23750 */
23751static void populate_vdev_param_tlv(uint32_t *vdev_param)
23752{
23753 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23754 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23755 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23756 vdev_param[wmi_vdev_param_beacon_interval] =
23757 WMI_VDEV_PARAM_BEACON_INTERVAL;
23758 vdev_param[wmi_vdev_param_listen_interval] =
23759 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23760 vdev_param[wmi_vdev_param_multicast_rate] =
23761 WMI_VDEV_PARAM_MULTICAST_RATE;
23762 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23763 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23764 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23765 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23766 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23767 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23768 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23769 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23770 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23771 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23772 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23773 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23774 vdev_param[wmi_vdev_param_bmiss_count_max] =
23775 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23776 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23777 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23778 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23779 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23780 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23781 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23782 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23783 vdev_param[wmi_vdev_param_disable_htprotection] =
23784 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23785 vdev_param[wmi_vdev_param_sta_quickkickout] =
23786 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23787 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23788 vdev_param[wmi_vdev_param_protection_mode] =
23789 WMI_VDEV_PARAM_PROTECTION_MODE;
23790 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23791 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23792 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23793 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23794 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23795 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23796 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23797 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23798 vdev_param[wmi_vdev_param_bcast_data_rate] =
23799 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23800 vdev_param[wmi_vdev_param_mcast_data_rate] =
23801 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23802 vdev_param[wmi_vdev_param_mcast_indicate] =
23803 WMI_VDEV_PARAM_MCAST_INDICATE;
23804 vdev_param[wmi_vdev_param_dhcp_indicate] =
23805 WMI_VDEV_PARAM_DHCP_INDICATE;
23806 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23807 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23808 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23809 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23810 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23811 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23812 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23813 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23814 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23815 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23816 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23817 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23818 vdev_param[wmi_vdev_param_packet_powersave] =
23819 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23820 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23821 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23822 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23823 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23824 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23825 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23826 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23827 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23828 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23829 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23830 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23831 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23832 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23833 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23834 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23835 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23836 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23837 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23838 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23839 vdev_param[wmi_vdev_param_roam_fw_offload] =
23840 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23841 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23842 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23843 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23844 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23845 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23846 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23847 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23848 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23849 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23850 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23851 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23852 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23853 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23854 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23855 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23856 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23857 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23858 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23859 vdev_param[wmi_vdev_param_inactivity_cnt] =
23860 WMI_VDEV_PARAM_INACTIVITY_CNT;
23861 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23862 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23863 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23864 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23865 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23866 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23867 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23868 vdev_param[wmi_vdev_param_rx_leak_window] =
23869 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23870 vdev_param[wmi_vdev_param_stats_avg_factor] =
23871 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23872 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23873 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23874 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23875 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23876 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23877 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023878 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23879 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023880 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023881 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23882 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23883 WMI_VDEV_PARAM_HE_RANGE_EXT;
23884 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23885 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarika6d1b9422018-06-22 16:44:59 -070023886 vdev_param[wmi_vdev_param_set_he_sounding_mode]
23887 = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023888 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023889 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23890 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23891 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23892 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23893 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23894 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23895 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023896 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23897 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23898 vdev_param[wmi_vdev_param_rc_num_retries] =
23899 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23900 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23901 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23902 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23903 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23904 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23905 vdev_param[wmi_vdev_param_vht80_ratemask] =
23906 WMI_VDEV_PARAM_VHT80_RATEMASK;
23907 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23908 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23909 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023910 vdev_param[wmi_vdev_param_set_he_ltf] =
23911 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053023912 vdev_param[wmi_vdev_param_disable_cabq] =
23913 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053023914 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23915 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023916 vdev_param[wmi_vdev_param_set_ba_mode] =
23917 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023918 vdev_param[wmi_vdev_param_capabilities] =
23919 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023920 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23921 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023922}
23923#endif
23924
Govind Singh5eb51532016-03-09 11:34:12 +053023925/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023926 * populate_target_defines_tlv() - Populate target defines and params
23927 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023928 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023929 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023930 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023931#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023932static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023933{
Govind Singhe7f2f342016-05-23 12:12:52 +053023934 populate_pdev_param_tlv(wmi_handle->pdev_param);
23935 populate_vdev_param_tlv(wmi_handle->vdev_param);
23936}
23937#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023938static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23939{ }
23940#endif
23941
23942/**
Zhang Qian537fca62018-01-03 16:33:24 +080023943 * wmi_ocb_ut_attach() - Attach OCB test framework
23944 * @wmi_handle: wmi handle
23945 *
23946 * Return: None
23947 */
23948#ifdef WLAN_OCB_UT
23949void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23950#else
23951static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23952{
23953 return;
23954}
23955#endif
23956
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023957/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023958 * wmi_tlv_attach() - Attach TLV APIs
23959 *
23960 * Return: None
23961 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023962void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023963{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023964 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023965 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023966 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023967#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023968 /* Skip saving WMI_CMD_HDR and TLV HDR */
23969 wmi_handle->log_info.buf_offset_command = 8;
23970 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023971 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023972#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023973 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023974 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023975 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023976 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080023977 wmi_extscan_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023978}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023979qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023980
23981/**
23982 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23983 *
23984 * Return: None
23985 */
23986void wmi_tlv_init(void)
23987{
23988 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23989}