blob: 2f4b9df5cfa935c95268e86451d9abd9b439c3d5 [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 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Govind Singh5eb51532016-03-09 11:34:12 +053028#include "wmi_unified_api.h"
29#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053030#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053031#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053032#include "wmi_version_whitelist.h"
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053033#include <wlan_defs.h>
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053034#include <htc_services.h>
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053035
Wu Gaocd3a8512017-03-13 20:17:34 +080036#ifdef CONVERGED_P2P_ENABLE
37#include "wlan_p2p_public_struct.h"
38#endif
Dustin Brownf31f88b2017-05-12 14:01:44 -070039#ifdef WLAN_PMO_ENABLE
40#include "wlan_pmo_hw_filter_public_struct.h"
41#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053042#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053043#ifdef WLAN_SUPPORT_GREEN_AP
44#include "wlan_green_ap_api.h"
45#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053046
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080047#ifdef WLAN_FEATURE_NAN_CONVERGENCE
48#include "nan_public_structs.h"
49#endif
50
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053051/* HTC service ids for WMI for multi-radio */
52static const uint32_t multi_svc_ids[] = {WMI_CONTROL_SVC,
53 WMI_CONTROL_SVC_WMAC1,
54 WMI_CONTROL_SVC_WMAC2};
55
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053056/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
57 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053058 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053059 * @cmd: pointer target vdev create command buffer
60 * @param: pointer host params for vdev create
61 *
62 * Return: None
63 */
64#ifdef CONFIG_MCL
65static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053066 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053067 wmi_vdev_create_cmd_fixed_param * cmd,
68 struct vdev_create_params *param)
69{
70 cmd->pdev_id = WMI_PDEV_ID_SOC;
71}
72#else
73static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053074 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053075 wmi_vdev_create_cmd_fixed_param * cmd,
76 struct vdev_create_params *param)
77{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053078 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
79 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053080}
81#endif
82
Govind Singh5eb51532016-03-09 11:34:12 +053083/**
84 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
85 * @wmi_handle: wmi handle
86 * @param: pointer to hold vdev create parameter
87 * @macaddr: vdev mac address
88 *
Govind Singhe7f2f342016-05-23 12:12:52 +053089 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053090 */
Sathish Kumarfd347372017-02-13 12:29:09 +053091static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053092 uint8_t macaddr[IEEE80211_ADDR_LEN],
93 struct vdev_create_params *param)
94{
95 wmi_vdev_create_cmd_fixed_param *cmd;
96 wmi_buf_t buf;
97 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053098 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070099 int num_bands = 2;
100 uint8_t *buf_ptr;
101 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +0530102
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700103 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530104 buf = wmi_buf_alloc(wmi_handle, len);
105 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530106 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530107 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530108 }
109 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
110 WMITLV_SET_HDR(&cmd->tlv_header,
111 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
112 WMITLV_GET_STRUCT_TLVLEN
113 (wmi_vdev_create_cmd_fixed_param));
114 cmd->vdev_id = param->if_id;
115 cmd->vdev_type = param->type;
116 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700117 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530118 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530119 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700120 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
121 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530122 macaddr[0], macaddr[1], macaddr[2],
123 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700124 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
125 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
126 (num_bands * sizeof(wmi_vdev_txrx_streams)));
127 buf_ptr += WMI_TLV_HDR_SIZE;
128
Govind Singh224a7312016-06-21 14:33:26 +0530129 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700130 param->type, param->subtype,
131 param->nss_2g, param->nss_5g);
132 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
133 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
134 txrx_streams->supported_tx_streams = param->nss_2g;
135 txrx_streams->supported_rx_streams = param->nss_2g;
136 WMITLV_SET_HDR(&txrx_streams->tlv_header,
137 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
138 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
139
140 txrx_streams++;
141 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
142 txrx_streams->supported_tx_streams = param->nss_5g;
143 txrx_streams->supported_rx_streams = param->nss_5g;
144 WMITLV_SET_HDR(&txrx_streams->tlv_header,
145 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
146 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530147 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530148 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530149 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530150 wmi_buf_free(buf);
151 }
152
153 return ret;
154}
155
156/**
157 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
158 * @wmi_handle: wmi handle
159 * @if_id: vdev id
160 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530161 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530162 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530163static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530164 uint8_t if_id)
165{
166 wmi_vdev_delete_cmd_fixed_param *cmd;
167 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530168 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530169
170 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
171 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530172 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530173 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530174 }
175
176 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
177 WMITLV_SET_HDR(&cmd->tlv_header,
178 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
179 WMITLV_GET_STRUCT_TLVLEN
180 (wmi_vdev_delete_cmd_fixed_param));
181 cmd->vdev_id = if_id;
182 ret = wmi_unified_cmd_send(wmi_handle, buf,
183 sizeof(wmi_vdev_delete_cmd_fixed_param),
184 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530185 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530186 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530187 wmi_buf_free(buf);
188 }
Govind Singhb53420c2016-03-09 14:32:57 +0530189 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530190
191 return ret;
192}
193
194/**
195 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
196 * @wmi: wmi handle
197 * @vdev_id: vdev id
198 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530199 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530200 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530201static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530202 uint8_t vdev_id)
203{
204 wmi_vdev_stop_cmd_fixed_param *cmd;
205 wmi_buf_t buf;
206 int32_t len = sizeof(*cmd);
207
208 buf = wmi_buf_alloc(wmi, len);
209 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530210 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530211 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530212 }
213 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
214 WMITLV_SET_HDR(&cmd->tlv_header,
215 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
216 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
217 cmd->vdev_id = vdev_id;
218 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530219 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530220 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530221 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530222 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530223 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530224
225 return 0;
226}
227
228/**
229 * send_vdev_down_cmd_tlv() - send vdev down command to fw
230 * @wmi: wmi handle
231 * @vdev_id: vdev id
232 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530233 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530234 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530235static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530236{
237 wmi_vdev_down_cmd_fixed_param *cmd;
238 wmi_buf_t buf;
239 int32_t len = sizeof(*cmd);
240
241 buf = wmi_buf_alloc(wmi, len);
242 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530243 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530244 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530245 }
246 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
247 WMITLV_SET_HDR(&cmd->tlv_header,
248 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
249 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
250 cmd->vdev_id = vdev_id;
251 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530252 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530253 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530254 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530255 }
Govind Singhb53420c2016-03-09 14:32:57 +0530256 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530257
258 return 0;
259}
260
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530261#ifdef CONFIG_MCL
262static inline void copy_channel_info(
263 wmi_vdev_start_request_cmd_fixed_param * cmd,
264 wmi_channel *chan,
265 struct vdev_start_params *req)
266{
267 chan->mhz = req->chan_freq;
268
269 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
270
271 chan->band_center_freq1 = req->band_center_freq1;
272 chan->band_center_freq2 = req->band_center_freq2;
273
274 if (req->is_half_rate)
275 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
276 else if (req->is_quarter_rate)
277 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
278
Naveen Rawat44f2f432016-12-01 12:58:57 -0800279 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530280 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
281 cmd->disable_hw_ack = req->dis_hw_ack;
282 }
283
284 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
285 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
286
287}
288#else
289static inline void copy_channel_info(
290 wmi_vdev_start_request_cmd_fixed_param * cmd,
291 wmi_channel *chan,
292 struct vdev_start_params *req)
293{
294 chan->mhz = req->channel.mhz;
295
296 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
297
298 chan->band_center_freq1 = req->channel.cfreq1;
299 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800300 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530301
302 if (req->channel.half_rate)
303 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
304 else if (req->channel.quarter_rate)
305 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
306
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800307 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
308
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530309 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530310 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530311 cmd->disable_hw_ack = req->disable_hw_ack;
312 }
313
Krishna Rao0b952ea2017-03-20 13:30:10 +0530314 if (req->channel.dfs_set_cfreq2)
315 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
316
Kai Chen4710d462017-12-15 14:06:06 -0800317 /* According to firmware both reg power and max tx power
318 * on set channel power is used and set it to max reg
319 * power from regulatory.
320 */
321 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
322 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530323 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800324 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
325 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
326 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530327
328}
329#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530330/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530331 * send_vdev_start_cmd_tlv() - send vdev start request to fw
332 * @wmi_handle: wmi handle
333 * @req: vdev start params
334 *
335 * Return: QDF status
336 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530337static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530338 struct vdev_start_params *req)
339{
340 wmi_vdev_start_request_cmd_fixed_param *cmd;
341 wmi_buf_t buf;
342 wmi_channel *chan;
343 int32_t len, ret;
344 uint8_t *buf_ptr;
345
346 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
347 buf = wmi_buf_alloc(wmi_handle, len);
348 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530349 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530350 return QDF_STATUS_E_NOMEM;
351 }
352 buf_ptr = (uint8_t *) wmi_buf_data(buf);
353 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
354 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
355 WMITLV_SET_HDR(&cmd->tlv_header,
356 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
357 WMITLV_GET_STRUCT_TLVLEN
358 (wmi_vdev_start_request_cmd_fixed_param));
359 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
360 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
361 cmd->vdev_id = req->vdev_id;
362
363 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530364 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530365
366 cmd->beacon_interval = req->beacon_intval;
367 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530368
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800369 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
370 if (req->bcn_tx_rate_code)
371 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
372
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530373 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530374 cmd->beacon_interval = req->beacon_intval;
375 cmd->dtim_period = req->dtim_period;
376
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530377 /* Copy the SSID */
378 if (req->ssid.length) {
379 if (req->ssid.length < sizeof(cmd->ssid.ssid))
380 cmd->ssid.ssid_len = req->ssid.length;
381 else
382 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
383 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
384 cmd->ssid.ssid_len);
385 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530386
387 if (req->hidden_ssid)
388 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
389
390 if (req->pmf_enabled)
391 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530392 }
393
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700394 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530395 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530396 cmd->preferred_rx_streams = req->preferred_rx_streams;
397 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700398 cmd->cac_duration_ms = req->cac_duration_ms;
399 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700400 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530401
402 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
403 sizeof(wmi_channel));
404 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
405 cmd->num_noa_descriptors *
406 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800407 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530408 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
409 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800410 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
411 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
412 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530413 req->is_dfs, req->beacon_intval, cmd->dtim_period,
414 chan->band_center_freq1, chan->band_center_freq2,
415 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700416 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700417 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800418 req->regdomain, req->he_ops,
419 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530420
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530421 if (req->is_restart)
422 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
423 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530424 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530425 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
426 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530427 if (ret) {
428 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530429 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530430 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530431 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530432
433 return QDF_STATUS_SUCCESS;
434}
435
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530436/**
437 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
438 * @wmi_handle: wmi handle
439 * @restart_params: vdev restart params
440 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530441 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530442 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530443static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530444 struct hidden_ssid_vdev_restart_params *restart_params)
445{
446 wmi_vdev_start_request_cmd_fixed_param *cmd;
447 wmi_buf_t buf;
448 wmi_channel *chan;
449 int32_t len;
450 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530451 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530452
453 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
454 buf = wmi_buf_alloc(wmi_handle, len);
455 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530456 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530457 return QDF_STATUS_E_NOMEM;
458 }
459 buf_ptr = (uint8_t *) wmi_buf_data(buf);
460 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
461 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
462
463 WMITLV_SET_HDR(&cmd->tlv_header,
464 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
465 WMITLV_GET_STRUCT_TLVLEN
466 (wmi_vdev_start_request_cmd_fixed_param));
467
468 WMITLV_SET_HDR(&chan->tlv_header,
469 WMITLV_TAG_STRUC_wmi_channel,
470 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
471
472 cmd->vdev_id = restart_params->session_id;
473 cmd->ssid.ssid_len = restart_params->ssid_len;
474 qdf_mem_copy(cmd->ssid.ssid,
475 restart_params->ssid,
476 cmd->ssid.ssid_len);
477 cmd->flags = restart_params->flags;
478 cmd->requestor_id = restart_params->requestor_id;
479 cmd->disable_hw_ack = restart_params->disable_hw_ack;
480
481 chan->mhz = restart_params->mhz;
482 chan->band_center_freq1 =
483 restart_params->band_center_freq1;
484 chan->band_center_freq2 =
485 restart_params->band_center_freq2;
486 chan->info = restart_params->info;
487 chan->reg_info_1 = restart_params->reg_info_1;
488 chan->reg_info_2 = restart_params->reg_info_2;
489
490 cmd->num_noa_descriptors = 0;
491 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
492 sizeof(wmi_channel));
493 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
494 cmd->num_noa_descriptors *
495 sizeof(wmi_p2p_noa_descriptor));
496
497 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
498 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530499 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530500 wmi_buf_free(buf);
501 return QDF_STATUS_E_FAILURE;
502 }
503 return QDF_STATUS_SUCCESS;
504}
505
506
507/**
Govind Singh5eb51532016-03-09 11:34:12 +0530508 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
509 * @wmi: wmi handle
510 * @peer_addr: peer mac address
511 * @param: pointer to hold peer flush tid parameter
512 *
513 * Return: 0 for sucess or error code
514 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530515static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530516 uint8_t peer_addr[IEEE80211_ADDR_LEN],
517 struct peer_flush_params *param)
518{
519 wmi_peer_flush_tids_cmd_fixed_param *cmd;
520 wmi_buf_t buf;
521 int32_t len = sizeof(*cmd);
522
523 buf = wmi_buf_alloc(wmi, len);
524 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530525 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530526 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530527 }
528 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
529 WMITLV_SET_HDR(&cmd->tlv_header,
530 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
531 WMITLV_GET_STRUCT_TLVLEN
532 (wmi_peer_flush_tids_cmd_fixed_param));
533 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
534 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
535 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530536 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530537 peer_addr, param->vdev_id,
538 param->peer_tid_bitmap);
539 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530540 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530541 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530542 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530543 }
544
545 return 0;
546}
547
548/**
549 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
550 * @wmi: wmi handle
551 * @peer_addr: peer mac addr
552 * @vdev_id: vdev id
553 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530554 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530555 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530556static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530557 uint8_t peer_addr[IEEE80211_ADDR_LEN],
558 uint8_t vdev_id)
559{
560 wmi_peer_delete_cmd_fixed_param *cmd;
561 wmi_buf_t buf;
562 int32_t len = sizeof(*cmd);
563 buf = wmi_buf_alloc(wmi, len);
564 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530565 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530566 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530567 }
568 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
569 WMITLV_SET_HDR(&cmd->tlv_header,
570 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
571 WMITLV_GET_STRUCT_TLVLEN
572 (wmi_peer_delete_cmd_fixed_param));
573 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
574 cmd->vdev_id = vdev_id;
575
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800576 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530577 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530578 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530579 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530580 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530581 }
Govind Singh5eb51532016-03-09 11:34:12 +0530582
583 return 0;
584}
585
586/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530587 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
588 * to target id.
589 * @targ_paramid: Target parameter id to hold the result.
590 * @peer_param_id: host param id.
591 *
592 * Return: QDF_STATUS_SUCCESS for success
593 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
594 */
595#ifdef CONFIG_MCL
596static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
597 uint32_t *targ_paramid,
598 uint32_t peer_param_id)
599{
600 *targ_paramid = peer_param_id;
601 return QDF_STATUS_SUCCESS;
602}
603#else
604static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
605 uint32_t *targ_paramid,
606 uint32_t peer_param_id)
607{
608 switch (peer_param_id) {
609 case WMI_HOST_PEER_MIMO_PS_STATE:
610 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
611 break;
612 case WMI_HOST_PEER_AMPDU:
613 *targ_paramid = WMI_PEER_AMPDU;
614 break;
615 case WMI_HOST_PEER_AUTHORIZE:
616 *targ_paramid = WMI_PEER_AUTHORIZE;
617 break;
618 case WMI_HOST_PEER_CHWIDTH:
619 *targ_paramid = WMI_PEER_CHWIDTH;
620 break;
621 case WMI_HOST_PEER_NSS:
622 *targ_paramid = WMI_PEER_NSS;
623 break;
624 case WMI_HOST_PEER_USE_4ADDR:
625 *targ_paramid = WMI_PEER_USE_4ADDR;
626 break;
627 case WMI_HOST_PEER_MEMBERSHIP:
628 *targ_paramid = WMI_PEER_MEMBERSHIP;
629 break;
630 case WMI_HOST_PEER_USERPOS:
631 *targ_paramid = WMI_PEER_USERPOS;
632 break;
633 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
634 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
635 break;
636 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
637 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
638 break;
639 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
640 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
641 break;
642 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
643 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
644 break;
645 case WMI_HOST_PEER_PHYMODE:
646 *targ_paramid = WMI_PEER_PHYMODE;
647 break;
648 case WMI_HOST_PEER_USE_FIXED_PWR:
649 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
650 break;
651 case WMI_HOST_PEER_PARAM_FIXED_RATE:
652 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
653 break;
654 case WMI_HOST_PEER_SET_MU_WHITELIST:
655 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
656 break;
657 case WMI_HOST_PEER_SET_MAC_TX_RATE:
658 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
659 break;
660 case WMI_HOST_PEER_SET_MIN_TX_RATE:
661 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
662 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530663 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
664 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
665 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530666 case WMI_HOST_PEER_NSS_VHT160:
667 *targ_paramid = WMI_PEER_NSS_VHT160;
668 break;
669 case WMI_HOST_PEER_NSS_VHT80_80:
670 *targ_paramid = WMI_PEER_NSS_VHT80_80;
671 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530672 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
673 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
674 break;
675 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
676 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
677 break;
678 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
679 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
680 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530681 case WMI_HOST_PEER_PARAM_MU_ENABLE:
682 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
683 break;
684 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
685 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
686 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530687 default:
688 return QDF_STATUS_E_NOSUPPORT;
689 }
690
691 return QDF_STATUS_SUCCESS;
692}
693#endif
694/**
Govind Singh5eb51532016-03-09 11:34:12 +0530695 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530696 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530697 * @peer_addr: peer mac address
698 * @param : pointer to hold peer set parameter
699 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530700 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530701 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530702static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530703 uint8_t peer_addr[IEEE80211_ADDR_LEN],
704 struct peer_set_params *param)
705{
706 wmi_peer_set_param_cmd_fixed_param *cmd;
707 wmi_buf_t buf;
708 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530709 uint32_t param_id;
710
711 if (convert_host_peer_id_to_target_id_tlv(&param_id,
712 param->param_id) != QDF_STATUS_SUCCESS)
713 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530714
715 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
716 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530717 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530718 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530719 }
720 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
721 WMITLV_SET_HDR(&cmd->tlv_header,
722 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
723 WMITLV_GET_STRUCT_TLVLEN
724 (wmi_peer_set_param_cmd_fixed_param));
725 cmd->vdev_id = param->vdev_id;
726 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530727 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530728 cmd->param_value = param->param_value;
729 err = wmi_unified_cmd_send(wmi, buf,
730 sizeof(wmi_peer_set_param_cmd_fixed_param),
731 WMI_PEER_SET_PARAM_CMDID);
732 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530733 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530734 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530735 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530736 }
737
738 return 0;
739}
740
741/**
742 * send_vdev_up_cmd_tlv() - send vdev up command in fw
743 * @wmi: wmi handle
744 * @bssid: bssid
745 * @vdev_up_params: pointer to hold vdev up parameter
746 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530747 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530748 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530749static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530750 uint8_t bssid[IEEE80211_ADDR_LEN],
751 struct vdev_up_params *params)
752{
753 wmi_vdev_up_cmd_fixed_param *cmd;
754 wmi_buf_t buf;
755 int32_t len = sizeof(*cmd);
756
Govind Singhb53420c2016-03-09 14:32:57 +0530757 WMI_LOGD("%s: VDEV_UP", __func__);
758 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530759 params->vdev_id, params->assoc_id, bssid);
760 buf = wmi_buf_alloc(wmi, len);
761 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530762 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530763 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530764 }
765 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
766 WMITLV_SET_HDR(&cmd->tlv_header,
767 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
768 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
769 cmd->vdev_id = params->vdev_id;
770 cmd->vdev_assoc_id = params->assoc_id;
771 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
772 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530773 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530774 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530775 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530776 }
777
778 return 0;
779}
780
781/**
782 * send_peer_create_cmd_tlv() - send peer create command to fw
783 * @wmi: wmi handle
784 * @peer_addr: peer mac address
785 * @peer_type: peer type
786 * @vdev_id: vdev id
787 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530788 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530789 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530790static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530791 struct peer_create_params *param)
792{
793 wmi_peer_create_cmd_fixed_param *cmd;
794 wmi_buf_t buf;
795 int32_t len = sizeof(*cmd);
796
797 buf = wmi_buf_alloc(wmi, len);
798 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530799 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530800 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530801 }
802 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
803 WMITLV_SET_HDR(&cmd->tlv_header,
804 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
805 WMITLV_GET_STRUCT_TLVLEN
806 (wmi_peer_create_cmd_fixed_param));
807 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
808 cmd->peer_type = param->peer_type;
809 cmd->vdev_id = param->vdev_id;
810
811 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530812 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530813 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530814 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530815 }
Govind Singhb53420c2016-03-09 14:32:57 +0530816 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530817 param->vdev_id);
818
819 return 0;
820}
821
822/**
Leo Changeee40872016-09-28 13:43:36 -0700823 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
824 * command to fw
825 * @wmi: wmi handle
826 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
827 *
828 * Return: 0 for success or error code
829 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700830static
Leo Changeee40872016-09-28 13:43:36 -0700831QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
832 struct rx_reorder_queue_setup_params *param)
833{
834 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
835 wmi_buf_t buf;
836 int32_t len = sizeof(*cmd);
837
838 buf = wmi_buf_alloc(wmi, len);
839 if (!buf) {
840 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
841 return QDF_STATUS_E_NOMEM;
842 }
843 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
844 WMITLV_SET_HDR(&cmd->tlv_header,
845 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
846 WMITLV_GET_STRUCT_TLVLEN
847 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
848 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
849 cmd->vdev_id = param->vdev_id;
850 cmd->tid = param->tid;
851 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
852 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
853 cmd->queue_no = param->queue_no;
854
855 if (wmi_unified_cmd_send(wmi, buf, len,
856 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
857 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
858 __func__);
859 qdf_nbuf_free(buf);
860 return QDF_STATUS_E_FAILURE;
861 }
862 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
863 param->peer_macaddr, param->vdev_id, param->tid);
864
865 return QDF_STATUS_SUCCESS;
866}
867
868/**
869 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
870 * command to fw
871 * @wmi: wmi handle
872 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
873 *
874 * Return: 0 for success or error code
875 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700876static
Leo Changeee40872016-09-28 13:43:36 -0700877QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
878 struct rx_reorder_queue_remove_params *param)
879{
880 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
881 wmi_buf_t buf;
882 int32_t len = sizeof(*cmd);
883
884 buf = wmi_buf_alloc(wmi, len);
885 if (!buf) {
886 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
887 return QDF_STATUS_E_NOMEM;
888 }
889 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
890 wmi_buf_data(buf);
891 WMITLV_SET_HDR(&cmd->tlv_header,
892 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
893 WMITLV_GET_STRUCT_TLVLEN
894 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
895 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
896 cmd->vdev_id = param->vdev_id;
897 cmd->tid_mask = param->peer_tid_bitmap;
898
899 if (wmi_unified_cmd_send(wmi, buf, len,
900 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
901 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
902 __func__);
903 qdf_nbuf_free(buf);
904 return QDF_STATUS_E_FAILURE;
905 }
906 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
907 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
908
909 return QDF_STATUS_SUCCESS;
910}
911
912/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530913 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
914 * @wmi_handle: wmi handle
915 * @param: pointer holding peer details
916 *
917 * Return: 0 for success or error code
918 */
919static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
920 struct peer_add_wds_entry_params *param)
921{
922 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
923 wmi_buf_t buf;
924 int len = sizeof(*cmd);
925
926 buf = wmi_buf_alloc(wmi_handle, len);
927 if (!buf) {
928 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
929 return QDF_STATUS_E_FAILURE;
930 }
931 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
932 WMITLV_SET_HDR(&cmd->tlv_header,
933 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
934 WMITLV_GET_STRUCT_TLVLEN
935 (wmi_peer_add_wds_entry_cmd_fixed_param));
936 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
937 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800938 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
939 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530940
941 return wmi_unified_cmd_send(wmi_handle, buf, len,
942 WMI_PEER_ADD_WDS_ENTRY_CMDID);
943}
944
945/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530946 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530947 * @wmi_handle: wmi handle
948 * @param: pointer holding peer details
949 *
950 * Return: 0 for success or error code
951 */
952static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
953 struct peer_del_wds_entry_params *param)
954{
955 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
956 wmi_buf_t buf;
957 int len = sizeof(*cmd);
958
959 buf = wmi_buf_alloc(wmi_handle, len);
960 if (!buf) {
961 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
962 return QDF_STATUS_E_NOMEM;
963 }
964 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
965 WMITLV_SET_HDR(&cmd->tlv_header,
966 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
967 WMITLV_GET_STRUCT_TLVLEN
968 (wmi_peer_remove_wds_entry_cmd_fixed_param));
969 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800970 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530971 return wmi_unified_cmd_send(wmi_handle, buf, len,
972 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
973}
974
975/**
976 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
977 * @wmi_handle: wmi handle
978 * @param: pointer holding peer details
979 *
980 * Return: 0 for success or error code
981 */
982static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
983 struct peer_update_wds_entry_params *param)
984{
985 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
986 wmi_buf_t buf;
987 int len = sizeof(*cmd);
988
989 buf = wmi_buf_alloc(wmi_handle, len);
990 if (!buf) {
991 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
992 return QDF_STATUS_E_NOMEM;
993 }
994
995 /* wmi_buf_alloc returns zeroed command buffer */
996 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
997 WMITLV_SET_HDR(&cmd->tlv_header,
998 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
999 WMITLV_GET_STRUCT_TLVLEN
1000 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001001 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1002 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301003 if (param->wds_macaddr)
1004 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
1005 &cmd->wds_macaddr);
1006 if (param->peer_macaddr)
1007 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1008 &cmd->peer_macaddr);
1009 return wmi_unified_cmd_send(wmi_handle, buf, len,
1010 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1011}
1012
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001013/**
1014 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1015 * @wmi_handle: wmi handle
1016 * @param: pointer to get tpc config params
1017 *
1018 * Return: 0 for success or error code
1019 */
1020static QDF_STATUS
1021send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1022 uint32_t param)
1023{
1024 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1025 wmi_buf_t buf;
1026 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1027
1028 buf = wmi_buf_alloc(wmi_handle, len);
1029 if (!buf) {
1030 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1031 return QDF_STATUS_E_NOMEM;
1032 }
1033 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1034 WMITLV_SET_HDR(&cmd->tlv_header,
1035 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1036 WMITLV_GET_STRUCT_TLVLEN
1037 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1038
1039 cmd->param = param;
1040 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1041 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1042 WMI_LOGE("Send pdev get tpc config cmd failed");
1043 wmi_buf_free(buf);
1044 return QDF_STATUS_E_FAILURE;
1045
1046 }
1047 WMI_LOGD("%s:send success", __func__);
1048
1049 return QDF_STATUS_SUCCESS;
1050}
1051
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301052#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301053/**
Govind Singh5eb51532016-03-09 11:34:12 +05301054 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1055 * @wmi_handle: wmi handle
1056 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301057 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301058 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301059 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301060 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301061static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301062 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301063{
1064 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1065 wmi_buf_t buf;
1066 int32_t len = sizeof(*cmd);
1067
Govind Singhb53420c2016-03-09 14:32:57 +05301068 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301069
1070 buf = wmi_buf_alloc(wmi_handle, len);
1071 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301072 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301073 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301074 }
1075
1076 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1077 WMITLV_SET_HDR(&cmd->tlv_header,
1078 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1079 WMITLV_GET_STRUCT_TLVLEN
1080 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301081 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301082 cmd->enable = value;
1083
1084 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1085 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301086 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301087 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301088 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301089 }
1090
1091 return 0;
1092}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301093#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301094
1095/**
1096 * send_pdev_utf_cmd_tlv() - send utf command to fw
1097 * @wmi_handle: wmi handle
1098 * @param: pointer to pdev_utf_params
1099 * @mac_id: mac id to have radio context
1100 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301101 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301102 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301103static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301104send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1105 struct pdev_utf_params *param,
1106 uint8_t mac_id)
1107{
1108 wmi_buf_t buf;
1109 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001110 /* if param->len is 0 no data is sent, return error */
1111 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301112 static uint8_t msgref = 1;
1113 uint8_t segNumber = 0, segInfo, numSegments;
1114 uint16_t chunk_len, total_bytes;
1115 uint8_t *bufpos;
1116 struct seg_hdr_info segHdrInfo;
1117
1118 bufpos = param->utf_payload;
1119 total_bytes = param->len;
1120 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1121 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1122 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1123
1124 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1125 numSegments++;
1126
1127 while (param->len) {
1128 if (param->len > MAX_WMI_UTF_LEN)
1129 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1130 else
1131 chunk_len = param->len;
1132
1133 buf = wmi_buf_alloc(wmi_handle,
1134 (chunk_len + sizeof(segHdrInfo) +
1135 WMI_TLV_HDR_SIZE));
1136 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301137 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301138 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301139 }
1140
1141 cmd = (uint8_t *) wmi_buf_data(buf);
1142
1143 segHdrInfo.len = total_bytes;
1144 segHdrInfo.msgref = msgref;
1145 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1146 segHdrInfo.segmentInfo = segInfo;
1147 segHdrInfo.pad = 0;
1148
Govind Singhb53420c2016-03-09 14:32:57 +05301149 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301150 " segHdrInfo.segmentInfo = %d",
1151 __func__, segHdrInfo.len, segHdrInfo.msgref,
1152 segHdrInfo.segmentInfo);
1153
Govind Singhb53420c2016-03-09 14:32:57 +05301154 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301155 "chunk len %d", __func__, total_bytes, segNumber,
1156 numSegments, chunk_len);
1157
1158 segNumber++;
1159
1160 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1161 (chunk_len + sizeof(segHdrInfo)));
1162 cmd += WMI_TLV_HDR_SIZE;
1163 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1164 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1165
1166 ret = wmi_unified_cmd_send(wmi_handle, buf,
1167 (chunk_len + sizeof(segHdrInfo) +
1168 WMI_TLV_HDR_SIZE),
1169 WMI_PDEV_UTF_CMDID);
1170
Govind Singh67922e82016-04-01 16:48:57 +05301171 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301172 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301173 wmi_buf_free(buf);
1174 break;
1175 }
1176
1177 param->len -= chunk_len;
1178 bufpos += chunk_len;
1179 }
1180
1181 msgref++;
1182
1183 return ret;
1184}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301185#ifdef CONFIG_MCL
1186static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1187 uint32_t host_param)
1188{
1189 return host_param;
1190}
1191#else
1192static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1193 uint32_t host_param)
1194{
1195 if (host_param < wmi_pdev_param_max)
1196 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301197
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301198 return WMI_UNAVAILABLE_PARAM;
1199}
1200#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301201/**
1202 * send_pdev_param_cmd_tlv() - set pdev parameters
1203 * @wmi_handle: wmi handle
1204 * @param: pointer to pdev parameter
1205 * @mac_id: radio context
1206 *
1207 * Return: 0 on success, errno on failure
1208 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301209static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301210send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1211 struct pdev_params *param,
1212 uint8_t mac_id)
1213{
Govind Singh67922e82016-04-01 16:48:57 +05301214 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301215 wmi_pdev_set_param_cmd_fixed_param *cmd;
1216 wmi_buf_t buf;
1217 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301218 uint32_t pdev_param;
1219
1220 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1221 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1222 WMI_LOGW("%s: Unavailable param %d\n",
1223 __func__, param->param_id);
1224 return QDF_STATUS_E_INVAL;
1225 }
Govind Singh5eb51532016-03-09 11:34:12 +05301226
1227 buf = wmi_buf_alloc(wmi_handle, len);
1228 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301229 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301230 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301231 }
1232 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1233 WMITLV_SET_HDR(&cmd->tlv_header,
1234 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1235 WMITLV_GET_STRUCT_TLVLEN
1236 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301237 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301238 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301239 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301240 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301241 param->param_value);
1242 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1243 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301244 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301245 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301246 wmi_buf_free(buf);
1247 }
1248 return ret;
1249}
1250
1251/**
1252 * send_suspend_cmd_tlv() - WMI suspend function
1253 * @param wmi_handle : handle to WMI.
1254 * @param param : pointer to hold suspend parameter
1255 * @mac_id: radio context
1256 *
1257 * Return 0 on success and -ve on failure.
1258 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301259static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301260 struct suspend_params *param,
1261 uint8_t mac_id)
1262{
1263 wmi_pdev_suspend_cmd_fixed_param *cmd;
1264 wmi_buf_t wmibuf;
1265 uint32_t len = sizeof(*cmd);
1266 int32_t ret;
1267
1268 /*
1269 * send the comand to Target to ignore the
1270 * PCIE reset so as to ensure that Host and target
1271 * states are in sync
1272 */
1273 wmibuf = wmi_buf_alloc(wmi_handle, len);
1274 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301275 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301276
1277 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1278 WMITLV_SET_HDR(&cmd->tlv_header,
1279 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1280 WMITLV_GET_STRUCT_TLVLEN
1281 (wmi_pdev_suspend_cmd_fixed_param));
1282 if (param->disable_target_intr)
1283 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1284 else
1285 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301286
1287 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1288
Govind Singh5eb51532016-03-09 11:34:12 +05301289 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1290 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301291 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301292 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301293 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301294 }
1295
1296 return ret;
1297}
1298
1299/**
1300 * send_resume_cmd_tlv() - WMI resume function
1301 * @param wmi_handle : handle to WMI.
1302 * @mac_id: radio context
1303 *
1304 * Return: 0 on success and -ve on failure.
1305 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301306static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301307 uint8_t mac_id)
1308{
1309 wmi_buf_t wmibuf;
1310 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301311 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301312
1313 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1314 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301315 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301316 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1317 WMITLV_SET_HDR(&cmd->tlv_header,
1318 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1319 WMITLV_GET_STRUCT_TLVLEN
1320 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301321 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301322 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1323 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301324 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301325 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301326 wmi_buf_free(wmibuf);
1327 }
1328
1329 return ret;
1330}
1331
Will Huang422ac9a2017-11-17 13:19:16 +08001332#ifdef FEATURE_WLAN_D0WOW
1333/**
1334 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1335 * @param wmi_handle: handle to WMI.
1336 * @mac_id: radio context
1337 *
1338 * Return: 0 on success and error code on failure.
1339 */
1340static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1341 uint8_t mac_id)
1342{
1343 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1344 wmi_buf_t buf;
1345 int32_t len;
1346 QDF_STATUS status;
1347
1348 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1349
1350 buf = wmi_buf_alloc(wmi_handle, len);
1351 if (!buf) {
1352 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1353 return QDF_STATUS_E_NOMEM;
1354 }
1355 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1356 WMITLV_SET_HDR(&cmd->tlv_header,
1357 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1358 WMITLV_GET_STRUCT_TLVLEN
1359 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1360
1361 cmd->enable = true;
1362
1363 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1364 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1365 if (QDF_IS_STATUS_ERROR(status))
1366 wmi_buf_free(buf);
1367
1368 return status;
1369}
1370
1371/**
1372 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1373 * @param wmi_handle: handle to WMI.
1374 * @mac_id: radio context
1375 *
1376 * Return: 0 on success and error code on failure.
1377 */
1378static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1379 uint8_t mac_id)
1380{
1381 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1382 wmi_buf_t buf;
1383 int32_t len;
1384 QDF_STATUS status;
1385
1386 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1387
1388 buf = wmi_buf_alloc(wmi_handle, len);
1389 if (!buf) {
1390 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1391 return QDF_STATUS_E_NOMEM;
1392 }
1393 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1394 WMITLV_SET_HDR(&cmd->tlv_header,
1395 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1396 WMITLV_GET_STRUCT_TLVLEN
1397 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1398
1399 cmd->enable = false;
1400
1401 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1402 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1403 if (QDF_IS_STATUS_ERROR(status))
1404 wmi_buf_free(buf);
1405
1406 return status;
1407}
1408#endif
1409
Govind Singh5eb51532016-03-09 11:34:12 +05301410/**
1411 * send_wow_enable_cmd_tlv() - WMI wow enable function
1412 * @param wmi_handle : handle to WMI.
1413 * @param param : pointer to hold wow enable parameter
1414 * @mac_id: radio context
1415 *
1416 * Return: 0 on success and -ve on failure.
1417 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301418static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301419 struct wow_cmd_params *param,
1420 uint8_t mac_id)
1421{
1422 wmi_wow_enable_cmd_fixed_param *cmd;
1423 wmi_buf_t buf;
1424 int32_t len;
1425 int32_t ret;
1426
1427 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1428
1429 buf = wmi_buf_alloc(wmi_handle, len);
1430 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301431 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1432 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301433 }
1434 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1435 WMITLV_SET_HDR(&cmd->tlv_header,
1436 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1437 WMITLV_GET_STRUCT_TLVLEN
1438 (wmi_wow_enable_cmd_fixed_param));
1439 cmd->enable = param->enable;
1440 if (param->can_suspend_link)
1441 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1442 else
1443 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001444 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301445
Govind Singhb53420c2016-03-09 14:32:57 +05301446 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301447 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1448 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1449
1450 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1451 WMI_WOW_ENABLE_CMDID);
1452 if (ret)
1453 wmi_buf_free(buf);
1454
1455 return ret;
1456}
1457
1458/**
1459 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301460 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301461 * @peer_addr: peer mac address
1462 * @param: pointer to ap_ps parameter structure
1463 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301464 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301465 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301466static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301467 uint8_t *peer_addr,
1468 struct ap_ps_params *param)
1469{
1470 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1471 wmi_buf_t buf;
1472 int32_t err;
1473
1474 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1475 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301476 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301477 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301478 }
1479 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1480 WMITLV_SET_HDR(&cmd->tlv_header,
1481 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1482 WMITLV_GET_STRUCT_TLVLEN
1483 (wmi_ap_ps_peer_cmd_fixed_param));
1484 cmd->vdev_id = param->vdev_id;
1485 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1486 cmd->param = param->param;
1487 cmd->value = param->value;
1488 err = wmi_unified_cmd_send(wmi_handle, buf,
1489 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1490 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301491 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301492 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301493 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301494 }
1495
1496 return 0;
1497}
1498
1499/**
1500 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301501 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301502 * @peer_addr: peer mac address
1503 * @param: pointer to sta_ps parameter structure
1504 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301505 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301506 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301507static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301508 struct sta_ps_params *param)
1509{
1510 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1511 wmi_buf_t buf;
1512 int32_t len = sizeof(*cmd);
1513
1514 buf = wmi_buf_alloc(wmi_handle, len);
1515 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301516 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301517 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301518 }
1519
1520 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1521 WMITLV_SET_HDR(&cmd->tlv_header,
1522 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1523 WMITLV_GET_STRUCT_TLVLEN
1524 (wmi_sta_powersave_param_cmd_fixed_param));
1525 cmd->vdev_id = param->vdev_id;
1526 cmd->param = param->param;
1527 cmd->value = param->value;
1528
1529 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1530 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301531 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301532 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301533 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301534 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301535 }
1536
1537 return 0;
1538}
1539
1540/**
1541 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301542 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301543 * @param: ponirt to crash inject paramter structure
1544 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301545 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301546 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301547static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301548 struct crash_inject *param)
1549{
1550 int32_t ret = 0;
1551 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1552 uint16_t len = sizeof(*cmd);
1553 wmi_buf_t buf;
1554
1555 buf = wmi_buf_alloc(wmi_handle, len);
1556 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301557 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301558 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301559 }
1560
1561 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1562 WMITLV_SET_HDR(&cmd->tlv_header,
1563 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1564 WMITLV_GET_STRUCT_TLVLEN
1565 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1566 cmd->type = param->type;
1567 cmd->delay_time_ms = param->delay_time_ms;
1568
1569 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1570 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301571 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301572 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301573 __func__, ret);
1574 wmi_buf_free(buf);
1575 }
1576
1577 return ret;
1578}
1579
1580/**
1581 * send_dbglog_cmd_tlv() - set debug log level
1582 * @param wmi_handle : handle to WMI.
1583 * @param param : pointer to hold dbglog level parameter
1584 *
1585 * Return: 0 on success and -ve on failure.
1586 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301587 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301588send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1589 struct dbglog_params *dbglog_param)
1590{
1591 wmi_buf_t buf;
1592 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001593 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301594 int32_t i;
1595 int32_t len;
1596 int8_t *buf_ptr;
1597 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1598
Alok Kumar240afea2017-08-30 14:45:34 +05301599 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301600
1601 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1602 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1603 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1604 buf = wmi_buf_alloc(wmi_handle, len);
1605 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001606 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301607
1608 configmsg =
1609 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1610 buf_ptr = (int8_t *) configmsg;
1611 WMITLV_SET_HDR(&configmsg->tlv_header,
1612 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1613 WMITLV_GET_STRUCT_TLVLEN
1614 (wmi_debug_log_config_cmd_fixed_param));
1615 configmsg->dbg_log_param = dbglog_param->param;
1616 configmsg->value = dbglog_param->val;
1617 /* Filling in the data part of second tlv -- should
1618 * follow first tlv _ WMI_TLV_HDR_SIZE */
1619 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1620 sizeof
1621 (wmi_debug_log_config_cmd_fixed_param)
1622 + WMI_TLV_HDR_SIZE);
1623 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1624 WMITLV_TAG_ARRAY_UINT32,
1625 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1626 if (dbglog_param->module_id_bitmap) {
1627 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1628 module_id_bitmap_array[i] =
1629 dbglog_param->module_id_bitmap[i];
1630 }
1631 }
1632
1633 status = wmi_unified_cmd_send(wmi_handle, buf,
1634 len, WMI_DBGLOG_CFG_CMDID);
1635
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001636 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301637 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301638
1639 return status;
1640}
1641
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301642#ifdef CONFIG_MCL
1643static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1644 uint32_t host_param)
1645{
1646 return host_param;
1647}
1648#else
1649static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1650 uint32_t host_param)
1651{
1652 if (host_param < wmi_vdev_param_max)
1653 return wmi_handle->vdev_param[host_param];
1654
1655 return WMI_UNAVAILABLE_PARAM;
1656}
1657#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301658/**
1659 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1660 * @param wmi_handle : handle to WMI.
1661 * @param macaddr : MAC address
1662 * @param param : pointer to hold vdev set parameter
1663 *
1664 * Return: 0 on success and -ve on failure.
1665 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301666static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301667 struct vdev_set_params *param)
1668{
Govind Singh67922e82016-04-01 16:48:57 +05301669 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301670 wmi_vdev_set_param_cmd_fixed_param *cmd;
1671 wmi_buf_t buf;
1672 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301673 uint32_t vdev_param;
1674
1675 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1676 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1677 WMI_LOGW("%s:Vdev param %d not available", __func__,
1678 param->param_id);
1679 return QDF_STATUS_E_INVAL;
1680
1681 }
Govind Singh5eb51532016-03-09 11:34:12 +05301682
1683 buf = wmi_buf_alloc(wmi_handle, len);
1684 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301685 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301686 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301687 }
1688 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1689 WMITLV_SET_HDR(&cmd->tlv_header,
1690 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1691 WMITLV_GET_STRUCT_TLVLEN
1692 (wmi_vdev_set_param_cmd_fixed_param));
1693 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301694 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301695 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301696 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301697 param->if_id, param->param_id, param->param_value);
1698 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1699 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301700 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301701 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301702 wmi_buf_free(buf);
1703 }
1704
1705 return ret;
1706}
1707
1708/**
1709 * send_stats_request_cmd_tlv() - WMI request stats function
1710 * @param wmi_handle : handle to WMI.
1711 * @param macaddr : MAC address
1712 * @param param : pointer to hold stats request parameter
1713 *
1714 * Return: 0 on success and -ve on failure.
1715 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301716static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301717 uint8_t macaddr[IEEE80211_ADDR_LEN],
1718 struct stats_request_params *param)
1719{
Govind Singhd3156eb2016-02-26 17:50:39 +05301720 int32_t ret;
1721 wmi_request_stats_cmd_fixed_param *cmd;
1722 wmi_buf_t buf;
1723 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1724
1725 buf = wmi_buf_alloc(wmi_handle, len);
1726 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301727 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1728 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301729 }
1730
1731 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1732 WMITLV_SET_HDR(&cmd->tlv_header,
1733 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1734 WMITLV_GET_STRUCT_TLVLEN
1735 (wmi_request_stats_cmd_fixed_param));
1736 cmd->stats_id = param->stats_id;
1737 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301738 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1739 param->pdev_id);
1740 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001741
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301742 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1743 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001744
1745 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1746 WMI_REQUEST_STATS_CMDID);
1747
Govind Singhd3156eb2016-02-26 17:50:39 +05301748 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301749 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301750 wmi_buf_free(buf);
1751 }
1752
1753 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301754}
1755
Govind Singh87542482016-06-08 19:40:11 +05301756#ifdef CONFIG_WIN
1757/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001758 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301759 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001760 * @param PKTLOG_EVENT : packet log event
1761 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301762 *
1763 * Return: 0 on success and -ve on failure.
1764 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301765static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001766 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301767{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001768 int32_t ret;
1769 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1770 wmi_buf_t buf;
1771 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1772
1773 buf = wmi_buf_alloc(wmi_handle, len);
1774 if (!buf) {
1775 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1776 return -QDF_STATUS_E_NOMEM;
1777 }
1778
1779 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1780 WMITLV_SET_HDR(&cmd->tlv_header,
1781 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1782 WMITLV_GET_STRUCT_TLVLEN
1783 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1784 cmd->evlist = PKTLOG_EVENT;
1785 cmd->pdev_id = mac_id;
1786 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1787 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1788 if (ret) {
1789 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1790 wmi_buf_free(buf);
1791 }
1792
1793 return ret;
1794}
1795
1796/**
1797 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1798 * @param wmi_handle : handle to WMI.
1799 * @mac_id: mac id to have radio context
1800 *
1801 * Return: 0 on success and -ve on failure.
1802 */
1803static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001804 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001805{
1806 int32_t ret;
1807 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1808 wmi_buf_t buf;
1809 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1810
1811 buf = wmi_buf_alloc(wmi_handle, len);
1812 if (!buf) {
1813 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1814 return -QDF_STATUS_E_NOMEM;
1815 }
1816
1817 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1818 WMITLV_SET_HDR(&cmd->tlv_header,
1819 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1820 WMITLV_GET_STRUCT_TLVLEN
1821 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1822 cmd->pdev_id = mac_id;
1823 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1824 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1825 if (ret) {
1826 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1827 wmi_buf_free(buf);
1828 }
1829
1830 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301831}
1832#else
Govind Singh5eb51532016-03-09 11:34:12 +05301833/**
Keyur Parekhde522342017-08-18 14:01:05 -07001834 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1835 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301836 * @param wmi_handle : handle to WMI.
1837 * @param macaddr : MAC address
1838 * @param param : pointer to hold stats request parameter
1839 *
1840 * Return: 0 on success and -ve on failure.
1841 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301842static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301843 uint8_t macaddr[IEEE80211_ADDR_LEN],
1844 struct packet_enable_params *param)
1845{
1846 return 0;
1847}
Keyur Parekhde522342017-08-18 14:01:05 -07001848/**
1849 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1850 * packet-log
1851 * @param wmi_handle : handle to WMI.
1852 * @mac_id: mac id to have radio context
1853 *
1854 * Return: 0 on success and -ve on failure.
1855 */
1856static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1857 uint8_t mac_id)
1858{
1859 return 0;
1860}
Govind Singh87542482016-06-08 19:40:11 +05301861#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301862
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301863#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1864/**
1865 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1866 * sync time between bwtween host and firmware
1867 * @param wmi_handle : handle to WMI.
1868 *
1869 * Return: None
1870 */
1871static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1872{
1873 wmi_buf_t buf;
1874 A_STATUS status = A_OK;
1875 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1876 int32_t len;
1877 qdf_time_t time_ms;
1878
1879 len = sizeof(*time_stamp);
1880 buf = wmi_buf_alloc(wmi_handle, len);
1881
1882 if (!buf) {
1883 WMI_LOGP(FL("wmi_buf_alloc failed"));
1884 return;
1885 }
1886 time_stamp =
1887 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1888 (wmi_buf_data(buf));
1889 WMITLV_SET_HDR(&time_stamp->tlv_header,
1890 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1891 WMITLV_GET_STRUCT_TLVLEN(
1892 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1893
1894 time_ms = qdf_get_time_of_the_day_ms();
1895 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1896 time_stamp->time_stamp_low = time_ms &
1897 WMI_FW_TIME_STAMP_LOW_MASK;
1898 /*
1899 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1900 * wont exceed 27 bit
1901 */
1902 time_stamp->time_stamp_high = 0;
1903 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1904 time_stamp->mode, time_stamp->time_stamp_low,
1905 time_stamp->time_stamp_high);
1906
1907 status = wmi_unified_cmd_send(wmi_handle, buf,
1908 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
1909 if (status) {
1910 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
1911 wmi_buf_free(buf);
1912 }
1913
1914}
1915
Subrat Mishrad7c7a562017-09-27 14:41:20 +05301916#ifdef WLAN_SUPPORT_FILS
1917/**
1918 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
1919 * @wmi_handle: wmi handle
1920 * @evt_buf: pointer to event buffer
1921 * @vdev_id: pointer to hold vdev id
1922 *
1923 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
1924 */
1925static QDF_STATUS
1926extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
1927 void *evt_buf, uint32_t *vdev_id)
1928{
1929 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
1930 wmi_host_swfda_event_fixed_param *swfda_event;
1931
1932 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
1933 if (!param_buf) {
1934 WMI_LOGE("Invalid swfda event buffer");
1935 return QDF_STATUS_E_INVAL;
1936 }
1937 swfda_event = param_buf->fixed_param;
1938 *vdev_id = swfda_event->vdev_id;
1939
1940 return QDF_STATUS_SUCCESS;
1941}
1942
1943/**
1944 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
1945 * @wmi_handle: wmi handle
1946 * @param: pointer to hold FILS discovery enable param
1947 *
1948 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
1949 */
1950static QDF_STATUS
1951send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
1952 struct config_fils_params *param)
1953{
1954 wmi_enable_fils_cmd_fixed_param *cmd;
1955 wmi_buf_t buf;
1956 QDF_STATUS status;
1957 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
1958
1959 buf = wmi_buf_alloc(wmi_handle, len);
1960 if (!buf) {
1961 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1962 return QDF_STATUS_E_NOMEM;
1963 }
1964 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
1965 WMITLV_SET_HDR(&cmd->tlv_header,
1966 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
1967 WMITLV_GET_STRUCT_TLVLEN(
1968 wmi_enable_fils_cmd_fixed_param));
1969 cmd->vdev_id = param->vdev_id;
1970 cmd->fd_period = param->fd_period;
1971 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
1972 param->fd_period, param->vdev_id);
1973
1974 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1975 WMI_ENABLE_FILS_CMDID);
1976 if (status != QDF_STATUS_SUCCESS) {
1977 wmi_buf_free(buf);
1978 return QDF_STATUS_E_FAILURE;
1979 }
1980
1981 return QDF_STATUS_SUCCESS;
1982}
1983
1984/**
1985 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
1986 * @wmi_handle: wmi handle
1987 * @param: pointer to hold FD send cmd parameter
1988 *
1989 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
1990 */
1991static QDF_STATUS
1992send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
1993 struct fd_params *param)
1994{
1995 QDF_STATUS ret;
1996 wmi_fd_send_from_host_cmd_fixed_param *cmd;
1997 wmi_buf_t wmi_buf;
1998 qdf_dma_addr_t dma_addr;
1999
2000 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2001 if (!wmi_buf) {
2002 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2003 return QDF_STATUS_E_NOMEM;
2004 }
2005 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2006 WMITLV_SET_HDR(&cmd->tlv_header,
2007 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2008 WMITLV_GET_STRUCT_TLVLEN(
2009 wmi_fd_send_from_host_cmd_fixed_param));
2010 cmd->vdev_id = param->vdev_id;
2011 cmd->data_len = qdf_nbuf_len(param->wbuf);
2012 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2013 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2014 cmd->frame_ctrl = param->frame_ctrl;
2015
2016 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2017 WMI_PDEV_SEND_FD_CMDID);
2018 if (ret != QDF_STATUS_SUCCESS) {
2019 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2020 __func__, ret);
2021 wmi_buf_free(wmi_buf);
2022 }
2023
2024 return ret;
2025}
2026#endif /* WLAN_SUPPORT_FILS */
2027
Sathish Kumarfd347372017-02-13 12:29:09 +05302028static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302029 struct beacon_params *param)
2030{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302031 QDF_STATUS ret;
2032 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2033 wmi_buf_t wmi_buf;
2034 qdf_dma_addr_t dma_addr;
2035 uint32_t dtim_flag = 0;
2036
2037 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2038 if (!wmi_buf) {
2039 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2040 return QDF_STATUS_E_NOMEM;
2041 }
2042 if (param->is_dtim_count_zero) {
2043 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2044 if (param->is_bitctl_reqd) {
2045 /* deliver CAB traffic in next DTIM beacon */
2046 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2047 }
2048 }
2049 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2050 WMITLV_SET_HDR(&cmd->tlv_header,
2051 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2052 WMITLV_GET_STRUCT_TLVLEN
2053 (wmi_bcn_send_from_host_cmd_fixed_param));
2054 cmd->vdev_id = param->vdev_id;
2055 cmd->data_len = qdf_nbuf_len(param->wbuf);
2056 cmd->frame_ctrl = param->frame_ctrl;
2057 cmd->dtim_flag = dtim_flag;
2058 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2059 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2060#if defined(HTT_PADDR64)
2061 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2062#endif
2063 cmd->bcn_antenna = param->bcn_txant;
2064
2065 ret = wmi_unified_cmd_send(wmi_handle,
2066 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2067 if (ret != QDF_STATUS_SUCCESS) {
2068 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2069 wmi_buf_free(wmi_buf);
2070 }
2071
2072 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302073}
2074
2075/**
2076 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2077 * @param wmi_handle : handle to WMI.
2078 * @param param : pointer to hold beacon send cmd parameter
2079 *
2080 * Return: 0 on success and -ve on failure.
2081 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302082static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302083 struct beacon_tmpl_params *param)
2084{
2085 int32_t ret;
2086 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2087 wmi_bcn_prb_info *bcn_prb_info;
2088 wmi_buf_t wmi_buf;
2089 uint8_t *buf_ptr;
2090 uint32_t wmi_buf_len;
2091
2092 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2093 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2094 param->tmpl_len_aligned;
2095 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2096 if (!wmi_buf) {
2097 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2098 return QDF_STATUS_E_NOMEM;
2099 }
2100 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2101 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2102 WMITLV_SET_HDR(&cmd->tlv_header,
2103 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2104 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2105 cmd->vdev_id = param->vdev_id;
2106 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302107 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2108 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05302109 cmd->buf_len = param->tmpl_len;
2110 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2111
2112 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2113 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2114 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2115 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2116 bcn_prb_info->caps = 0;
2117 bcn_prb_info->erp = 0;
2118 buf_ptr += sizeof(wmi_bcn_prb_info);
2119
2120 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2121 buf_ptr += WMI_TLV_HDR_SIZE;
2122 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2123
2124 ret = wmi_unified_cmd_send(wmi_handle,
2125 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2126 if (ret) {
2127 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2128 wmi_buf_free(wmi_buf);
2129 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302130
Govind Singh87542482016-06-08 19:40:11 +05302131 return 0;
2132}
Govind Singh5eb51532016-03-09 11:34:12 +05302133
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302134#ifdef CONFIG_MCL
2135static inline void copy_peer_flags_tlv(
2136 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2137 struct peer_assoc_params *param)
2138{
2139 cmd->peer_flags = param->peer_flags;
2140}
2141#else
2142static inline void copy_peer_flags_tlv(
2143 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2144 struct peer_assoc_params *param)
2145{
2146 /*
2147 * The target only needs a subset of the flags maintained in the host.
2148 * Just populate those flags and send it down
2149 */
2150 cmd->peer_flags = 0;
2151
2152 /*
2153 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2154 */
2155 if (param->is_wme_set) {
2156
2157 if (param->qos_flag)
2158 cmd->peer_flags |= WMI_PEER_QOS;
2159 if (param->apsd_flag)
2160 cmd->peer_flags |= WMI_PEER_APSD;
2161 if (param->ht_flag)
2162 cmd->peer_flags |= WMI_PEER_HT;
2163 if (param->bw_40)
2164 cmd->peer_flags |= WMI_PEER_40MHZ;
2165 if (param->bw_80)
2166 cmd->peer_flags |= WMI_PEER_80MHZ;
2167 if (param->bw_160)
2168 cmd->peer_flags |= WMI_PEER_160MHZ;
2169
2170 /* Typically if STBC is enabled for VHT it should be enabled
2171 * for HT as well
2172 **/
2173 if (param->stbc_flag)
2174 cmd->peer_flags |= WMI_PEER_STBC;
2175
2176 /* Typically if LDPC is enabled for VHT it should be enabled
2177 * for HT as well
2178 **/
2179 if (param->ldpc_flag)
2180 cmd->peer_flags |= WMI_PEER_LDPC;
2181
2182 if (param->static_mimops_flag)
2183 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2184 if (param->dynamic_mimops_flag)
2185 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2186 if (param->spatial_mux_flag)
2187 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2188 if (param->vht_flag)
2189 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002190 if (param->he_flag)
2191 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302192 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002193
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302194 if (param->is_pmf_enabled)
2195 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302196 /*
2197 * Suppress authorization for all AUTH modes that need 4-way handshake
2198 * (during re-association).
2199 * Authorization will be done for these modes on key installation.
2200 */
2201 if (param->auth_flag)
2202 cmd->peer_flags |= WMI_PEER_AUTH;
2203 if (param->need_ptk_4_way)
2204 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2205 else
2206 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2207 if (param->need_gtk_2_way)
2208 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2209 /* safe mode bypass the 4-way handshake */
2210 if (param->safe_mode_enabled)
2211 cmd->peer_flags &=
2212 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2213 /* Disable AMSDU for station transmit, if user configures it */
2214 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2215 * it
2216 * if (param->amsdu_disable) Add after FW support
2217 **/
2218
2219 /* Target asserts if node is marked HT and all MCS is set to 0.
2220 * Mark the node as non-HT if all the mcs rates are disabled through
2221 * iwpriv
2222 **/
2223 if (param->peer_ht_rates.num_rates == 0)
2224 cmd->peer_flags &= ~WMI_PEER_HT;
2225}
2226#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302227
2228#ifdef CONFIG_MCL
2229static inline void copy_peer_mac_addr_tlv(
2230 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2231 struct peer_assoc_params *param)
2232{
2233 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2234 sizeof(param->peer_macaddr));
2235}
2236#else
2237static inline void copy_peer_mac_addr_tlv(
2238 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2239 struct peer_assoc_params *param)
2240{
2241 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2242}
2243#endif
2244
Govind Singh5eb51532016-03-09 11:34:12 +05302245/**
2246 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2247 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302248 * @param param : pointer to peer assoc parameter
2249 *
2250 * Return: 0 on success and -ve on failure.
2251 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302252static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302253 struct peer_assoc_params *param)
2254{
Govind Singhd3156eb2016-02-26 17:50:39 +05302255 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2256 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002257 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302258 wmi_buf_t buf;
2259 int32_t len;
2260 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302261 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302262 uint32_t peer_legacy_rates_align;
2263 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002264 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302265
2266
2267 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2268 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302269
2270 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002271 (peer_legacy_rates_align * sizeof(uint8_t)) +
2272 WMI_TLV_HDR_SIZE +
2273 (peer_ht_rates_align * sizeof(uint8_t)) +
2274 sizeof(wmi_vht_rate_set) +
2275 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2276 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302277
2278 buf = wmi_buf_alloc(wmi_handle, len);
2279 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302280 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302281 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302282 }
2283
2284 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2285 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2286 WMITLV_SET_HDR(&cmd->tlv_header,
2287 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2288 WMITLV_GET_STRUCT_TLVLEN
2289 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302290
Govind Singhd3156eb2016-02-26 17:50:39 +05302291 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302292
Govind Singhd3156eb2016-02-26 17:50:39 +05302293 cmd->peer_new_assoc = param->peer_new_assoc;
2294 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302295
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302296 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302297 copy_peer_mac_addr_tlv(cmd, param);
2298
Govind Singhd3156eb2016-02-26 17:50:39 +05302299 cmd->peer_rate_caps = param->peer_rate_caps;
2300 cmd->peer_caps = param->peer_caps;
2301 cmd->peer_listen_intval = param->peer_listen_intval;
2302 cmd->peer_ht_caps = param->peer_ht_caps;
2303 cmd->peer_max_mpdu = param->peer_max_mpdu;
2304 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302305 cmd->peer_vht_caps = param->peer_vht_caps;
2306 cmd->peer_phymode = param->peer_phymode;
2307
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002308 /* Update 11ax capabilities */
2309 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2310 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002311 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2312 sizeof(param->peer_he_cap_phyinfo));
2313 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2314 sizeof(param->peer_ppet));
2315
Govind Singhd3156eb2016-02-26 17:50:39 +05302316 /* Update peer legacy rate information */
2317 buf_ptr += sizeof(*cmd);
2318 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302319 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302320 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302321 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302322 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302323 param->peer_legacy_rates.num_rates);
2324
2325 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002326 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302327 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302328 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302329 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302330 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302331 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302332 param->peer_ht_rates.num_rates);
2333
2334 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002335 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302336 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2337 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2338
2339 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302340
2341 /* Update bandwidth-NSS mapping */
2342 cmd->peer_bw_rxnss_override = 0;
2343 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2344
Govind Singhd3156eb2016-02-26 17:50:39 +05302345 mcs = (wmi_vht_rate_set *) buf_ptr;
2346 if (param->vht_capable) {
2347 mcs->rx_max_rate = param->rx_max_rate;
2348 mcs->rx_mcs_set = param->rx_mcs_set;
2349 mcs->tx_max_rate = param->tx_max_rate;
2350 mcs->tx_mcs_set = param->tx_mcs_set;
2351 }
2352
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002353 /* HE Rates */
2354 cmd->peer_he_mcs = param->peer_he_mcs_count;
2355 buf_ptr += sizeof(wmi_vht_rate_set);
2356 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2357 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2358 buf_ptr += WMI_TLV_HDR_SIZE;
2359
2360 /* Loop through the HE rate set */
2361 for (i = 0; i < param->peer_he_mcs_count; i++) {
2362 he_mcs = (wmi_he_rate_set *) buf_ptr;
2363 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2364 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2365
2366 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2367 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2368 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2369 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2370 buf_ptr += sizeof(wmi_he_rate_set);
2371 }
2372
2373
Govind Singhb53420c2016-03-09 14:32:57 +05302374 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302375 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2376 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002377 "cmd->peer_vht_caps %x "
2378 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302379 "HE phy %x %x %x "
2380 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302381 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2382 cmd->peer_rate_caps, cmd->peer_caps,
2383 cmd->peer_listen_intval, cmd->peer_ht_caps,
2384 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2385 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002386 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2387 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302388 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2389 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302390
2391 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2392 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302393 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302394 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302395 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302396 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302397 }
2398
2399 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302400}
2401
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302402/* copy_scan_notify_events() - Helper routine to copy scan notify events
2403 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302404static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302405 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302406 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302407{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302408
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302409 /* Scan events subscription */
2410 if (param->scan_ev_started)
2411 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2412 if (param->scan_ev_completed)
2413 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2414 if (param->scan_ev_bss_chan)
2415 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2416 if (param->scan_ev_foreign_chan)
2417 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2418 if (param->scan_ev_dequeued)
2419 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2420 if (param->scan_ev_preempted)
2421 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2422 if (param->scan_ev_start_failed)
2423 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2424 if (param->scan_ev_restarted)
2425 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2426 if (param->scan_ev_foreign_chn_exit)
2427 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2428 if (param->scan_ev_suspended)
2429 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2430 if (param->scan_ev_resumed)
2431 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302432
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302433 /** Set scan control flags */
2434 cmd->scan_ctrl_flags = 0;
2435 if (param->scan_f_passive)
2436 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2437 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302438 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302439 if (param->scan_f_promisc_mode)
2440 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2441 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302442 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302443 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302444 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302445 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302446 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302447 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302448 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302449 if (param->scan_f_ofdm_rates)
2450 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2451 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302452 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302453 if (param->scan_f_filter_prb_req)
2454 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2455 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302456 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302457 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302458 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302459 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302460 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302461 if (param->scan_f_force_active_dfs_chn)
2462 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2463 if (param->scan_f_add_tpc_ie_in_probe)
2464 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2465 if (param->scan_f_add_ds_ie_in_probe)
2466 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2467 if (param->scan_f_add_spoofed_mac_in_probe)
2468 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2469 if (param->scan_f_add_rand_seq_in_probe)
2470 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2471 if (param->scan_f_en_ie_whitelist_in_probe)
2472 cmd->scan_ctrl_flags |=
2473 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302474
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302475 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2476 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2477 param->adaptive_dwell_time_mode);
2478}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302479
2480/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302481static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302482 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302483{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302484 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302485}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302486
Anish Natarajdd855152017-03-20 12:49:08 +05302487/*
2488 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2489 * @param wmi_handle : Handle to WMI
2490 * @param vdev_id : vdev identifier
2491 *
2492 * Return : void *
2493 */
2494static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2495{
2496 struct wlan_objmgr_vdev *vdev = NULL;
2497 struct wlan_objmgr_pdev *pdev = NULL;
2498 uint8_t pdev_id = 0;
2499
2500 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2501 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2502 vdev_id, WLAN_SCAN_ID);
2503 if (vdev) {
2504 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2505 pdev = wlan_vdev_get_pdev(vdev);
2506 if (pdev)
2507 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2508 else {
2509 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2510 }
2511 } else {
2512 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2513 }
2514
2515 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2516}
2517
Govind Singh5eb51532016-03-09 11:34:12 +05302518/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302519 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2520 * @mac: random mac addr
2521 * @mask: random mac mask
2522 * @mac_addr: wmi random mac
2523 * @mac_mask: wmi random mac mask
2524 *
2525 * Return None.
2526 */
2527static inline
2528void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2529 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2530{
2531 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2532 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2533}
2534
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302535/*
2536 * wmi_fill_vendor_oui() - fill vendor OUIs
2537 * @buf_ptr: pointer to wmi tlv buffer
2538 * @num_vendor_oui: number of vendor OUIs to be filled
2539 * @param_voui: pointer to OUI buffer
2540 *
2541 * This function populates the wmi tlv buffer when vendor specific OUIs are
2542 * present.
2543 *
2544 * Return: None
2545 */
2546static inline
2547void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2548 uint32_t *pvoui)
2549{
2550 wmi_vendor_oui *voui = NULL;
2551 uint32_t i;
2552
2553 voui = (wmi_vendor_oui *)buf_ptr;
2554
2555 for (i = 0; i < num_vendor_oui; i++) {
2556 WMITLV_SET_HDR(&voui[i].tlv_header,
2557 WMITLV_TAG_STRUC_wmi_vendor_oui,
2558 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2559 voui[i].oui_type_subtype = pvoui[i];
2560 }
2561}
2562
2563/*
2564 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2565 * @ie_bitmap: output pointer to ie bit map in cmd
2566 * @num_vendor_oui: output pointer to num vendor OUIs
2567 * @ie_whitelist: input parameter
2568 *
2569 * This function populates the IE whitelist attrs of scan, pno and
2570 * scan oui commands for ie_whitelist parameter.
2571 *
2572 * Return: None
2573 */
2574static inline
2575void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2576 uint32_t *num_vendor_oui,
2577 struct probe_req_whitelist_attr *ie_whitelist)
2578{
2579 uint32_t i = 0;
2580
2581 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2582 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2583
2584 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2585}
2586
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302587/**
Govind Singh5eb51532016-03-09 11:34:12 +05302588 * send_scan_start_cmd_tlv() - WMI scan start function
2589 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302590 * @param param : pointer to hold scan start cmd parameter
2591 *
2592 * Return: 0 on success and -ve on failure.
2593 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302594static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302595 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302596{
Govind Singhd3156eb2016-02-26 17:50:39 +05302597 int32_t ret = 0;
2598 int32_t i;
2599 wmi_buf_t wmi_buf;
2600 wmi_start_scan_cmd_fixed_param *cmd;
2601 uint8_t *buf_ptr;
2602 uint32_t *tmp_ptr;
2603 wmi_ssid *ssid = NULL;
2604 wmi_mac_addr *bssid;
2605 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302606 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302607 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302608 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002609 wmi_unified_t pdev_wmi_handle;
Govind Singhd3156eb2016-02-26 17:50:39 +05302610
2611 /* Length TLV placeholder for array of uint32_t */
2612 len += WMI_TLV_HDR_SIZE;
2613 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302614 if (params->chan_list.num_chan)
2615 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302616
2617 /* Length TLV placeholder for array of wmi_ssid structures */
2618 len += WMI_TLV_HDR_SIZE;
2619 if (params->num_ssids)
2620 len += params->num_ssids * sizeof(wmi_ssid);
2621
2622 /* Length TLV placeholder for array of wmi_mac_addr structures */
2623 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302624 if (params->num_bssid)
2625 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302626
2627 /* Length TLV placeholder for array of bytes */
2628 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302629 if (params->extraie.len)
2630 extraie_len_with_pad =
2631 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002632 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302633
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302634 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2635 if (ie_whitelist->num_vendor_oui)
2636 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2637
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302638 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2639 if (params->scan_f_wide_band)
2640 phymode_roundup =
2641 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2642 sizeof(uint32_t));
2643 len += phymode_roundup;
2644
Govind Singhd3156eb2016-02-26 17:50:39 +05302645 /* Allocate the memory */
2646 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2647 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302648 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302649 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302650 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302651 }
2652 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2653 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2654 WMITLV_SET_HDR(&cmd->tlv_header,
2655 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2656 WMITLV_GET_STRUCT_TLVLEN
2657 (wmi_start_scan_cmd_fixed_param));
2658
2659 cmd->scan_id = params->scan_id;
2660 cmd->scan_req_id = params->scan_req_id;
2661 cmd->vdev_id = params->vdev_id;
2662 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302663
2664 copy_scan_event_cntrl_flags(cmd, params);
2665
Govind Singhd3156eb2016-02-26 17:50:39 +05302666 cmd->dwell_time_active = params->dwell_time_active;
2667 cmd->dwell_time_passive = params->dwell_time_passive;
2668 cmd->min_rest_time = params->min_rest_time;
2669 cmd->max_rest_time = params->max_rest_time;
2670 cmd->repeat_probe_time = params->repeat_probe_time;
2671 cmd->probe_spacing_time = params->probe_spacing_time;
2672 cmd->idle_time = params->idle_time;
2673 cmd->max_scan_time = params->max_scan_time;
2674 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302675 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302676 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302677 cmd->num_bssid = params->num_bssid;
2678 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302679 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302680 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302681 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2682
2683 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2684
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302685 if (params->scan_random.randomize)
2686 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2687 params->scan_random.mac_mask,
2688 &cmd->mac_addr,
2689 &cmd->mac_mask);
2690
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302691 if (ie_whitelist->white_list)
2692 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2693 &cmd->num_vendor_oui,
2694 ie_whitelist);
2695
Govind Singhd3156eb2016-02-26 17:50:39 +05302696 buf_ptr += sizeof(*cmd);
2697 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302698 for (i = 0; i < params->chan_list.num_chan; ++i)
2699 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302700
2701 WMITLV_SET_HDR(buf_ptr,
2702 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302703 (params->chan_list.num_chan * sizeof(uint32_t)));
2704 buf_ptr += WMI_TLV_HDR_SIZE +
2705 (params->chan_list.num_chan * sizeof(uint32_t));
2706
Govind Singh4eacd2b2016-03-07 14:24:22 +05302707 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302708 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302709 goto error;
2710 }
2711
2712 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2713 (params->num_ssids * sizeof(wmi_ssid)));
2714
2715 if (params->num_ssids) {
2716 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2717 for (i = 0; i < params->num_ssids; ++i) {
2718 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302719 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302720 params->ssid[i].length);
2721 ssid++;
2722 }
2723 }
2724 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2725
2726 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2727 (params->num_bssid * sizeof(wmi_mac_addr)));
2728 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302729
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302730 if (params->num_bssid) {
2731 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302732 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2733 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302734 bssid++;
2735 }
2736 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302737
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302738 buf_ptr += WMI_TLV_HDR_SIZE +
2739 (params->num_bssid * sizeof(wmi_mac_addr));
2740
2741 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2742 if (params->extraie.len)
2743 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2744 params);
2745
2746 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302747
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302748 /* probe req ie whitelisting */
2749 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2750 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2751
2752 buf_ptr += WMI_TLV_HDR_SIZE;
2753
2754 if (cmd->num_vendor_oui) {
2755 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2756 ie_whitelist->voui);
2757 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2758 }
2759
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302760 /* Add phy mode TLV if it's a wide band scan */
2761 if (params->scan_f_wide_band) {
2762 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2763 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2764 for (i = 0; i < params->chan_list.num_chan; ++i)
2765 buf_ptr[i] =
2766 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2767 buf_ptr += phymode_roundup;
2768 } else {
2769 /* Add ZERO legth phy mode TLV */
2770 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2771 }
2772
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002773 pdev_wmi_handle = get_pdev_wmi_handle(wmi_handle, cmd->vdev_id);
2774 if (pdev_wmi_handle == NULL) {
2775 WMI_LOGE("%s: Invalid PDEV WMI handle", __func__);
2776 goto error;
2777 }
2778
2779 ret = wmi_unified_cmd_send(pdev_wmi_handle, wmi_buf,
2780 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302781 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302782 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302783 wmi_buf_free(wmi_buf);
2784 }
2785 return ret;
2786error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302787 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302788 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302789}
2790
2791/**
2792 * send_scan_stop_cmd_tlv() - WMI scan start function
2793 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302794 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302795 *
2796 * Return: 0 on success and -ve on failure.
2797 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302798static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302799 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302800{
Govind Singhd3156eb2016-02-26 17:50:39 +05302801 wmi_stop_scan_cmd_fixed_param *cmd;
2802 int ret;
2803 int len = sizeof(*cmd);
2804 wmi_buf_t wmi_buf;
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002805 wmi_unified_t pdev_wmi_handle;
Govind Singhd3156eb2016-02-26 17:50:39 +05302806
2807 /* Allocate the memory */
2808 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2809 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302810 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302811 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302812 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302813 goto error;
2814 }
2815
2816 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2817 WMITLV_SET_HDR(&cmd->tlv_header,
2818 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2819 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2820 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302821 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302822 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302823 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2824 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302825 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302826 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2827 /* Cancelling all scans */
2828 cmd->req_type = WMI_SCAN_STOP_ALL;
2829 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2830 /* Cancelling VAP scans */
2831 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2832 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2833 /* Cancelling specific scan */
2834 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302835 } else {
2836 WMI_LOGE("%s: Invalid Command : ", __func__);
2837 wmi_buf_free(wmi_buf);
2838 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302839 }
2840
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002841 pdev_wmi_handle = get_pdev_wmi_handle(wmi_handle, cmd->vdev_id);
2842 if (pdev_wmi_handle == NULL) {
2843 WMI_LOGE("%s: Invalid PDEV WMI handle", __func__);
2844 wmi_buf_free(wmi_buf);
2845 return QDF_STATUS_E_NULL_VALUE;
2846 }
2847
2848 ret = wmi_unified_cmd_send(pdev_wmi_handle, wmi_buf,
2849 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302850 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302851 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302852 wmi_buf_free(wmi_buf);
2853 }
2854
2855error:
2856 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302857}
2858
Govind Singh87542482016-06-08 19:40:11 +05302859#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302860/**
2861 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2862 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302863 * @param param : pointer to hold scan channel list parameter
2864 *
2865 * Return: 0 on success and -ve on failure.
2866 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302867static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302868 struct scan_chan_list_params *chan_list)
2869{
2870 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302871 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302872 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302873 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302874 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302875 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302876 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2877
2878 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2879 buf = wmi_buf_alloc(wmi_handle, len);
2880 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302881 WMI_LOGE("Failed to allocate memory");
2882 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302883 goto end;
2884 }
2885
2886 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2887 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2888 WMITLV_SET_HDR(&cmd->tlv_header,
2889 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2890 WMITLV_GET_STRUCT_TLVLEN
2891 (wmi_scan_chan_list_cmd_fixed_param));
2892
Govind Singhb53420c2016-03-09 14:32:57 +05302893 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302894
2895 cmd->num_scan_chans = chan_list->num_scan_chans;
2896 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2897 WMITLV_TAG_ARRAY_STRUC,
2898 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302899 chan_info = (wmi_channel_param *)
2900 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302901 tchan_info = chan_list->chan_info;
2902
2903 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2904 WMITLV_SET_HDR(&chan_info->tlv_header,
2905 WMITLV_TAG_STRUC_wmi_channel,
2906 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2907 chan_info->mhz = tchan_info->mhz;
2908 chan_info->band_center_freq1 =
2909 tchan_info->band_center_freq1;
2910 chan_info->band_center_freq2 =
2911 tchan_info->band_center_freq2;
2912 chan_info->info = tchan_info->info;
2913 chan_info->reg_info_1 = tchan_info->reg_info_1;
2914 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302915 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302916
2917 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2918 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2919 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2920 tchan_info++;
2921 chan_info++;
2922 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302923 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2924 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302925
Anish Natarajdd855152017-03-20 12:49:08 +05302926 qdf_status = wmi_unified_cmd_send(wmi_handle,
2927 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302928
Govind Singh67922e82016-04-01 16:48:57 +05302929 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302930 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302931 wmi_buf_free(buf);
2932 }
Govind Singh67922e82016-04-01 16:48:57 +05302933
Govind Singhd3156eb2016-02-26 17:50:39 +05302934end:
Govind Singhb53420c2016-03-09 14:32:57 +05302935 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302936}
Govind Singh87542482016-06-08 19:40:11 +05302937#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302938static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302939 struct scan_chan_list_params *chan_list)
2940{
2941 wmi_buf_t buf;
2942 QDF_STATUS qdf_status;
2943 wmi_scan_chan_list_cmd_fixed_param *cmd;
2944 int i;
2945 uint8_t *buf_ptr;
2946 wmi_channel *chan_info;
2947 struct channel_param *tchan_info;
2948 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302949
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302950 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302951 buf = wmi_buf_alloc(wmi_handle, len);
2952 if (!buf) {
2953 WMI_LOGE("Failed to allocate memory");
2954 qdf_status = QDF_STATUS_E_NOMEM;
2955 goto end;
2956 }
2957
2958 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2959 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2960 WMITLV_SET_HDR(&cmd->tlv_header,
2961 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2962 WMITLV_GET_STRUCT_TLVLEN
2963 (wmi_scan_chan_list_cmd_fixed_param));
2964
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302965 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302966
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302967 if (chan_list->append)
2968 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2969
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302970 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2971 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302972 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302973 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2974 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302975 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302976 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2977 tchan_info = &(chan_list->ch_param[0]);
2978
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302979 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302980 WMITLV_SET_HDR(&chan_info->tlv_header,
2981 WMITLV_TAG_STRUC_wmi_channel,
2982 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2983 chan_info->mhz = tchan_info->mhz;
2984 chan_info->band_center_freq1 =
2985 tchan_info->cfreq1;
2986 chan_info->band_center_freq2 =
2987 tchan_info->cfreq2;
2988
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302989 if (tchan_info->is_chan_passive)
2990 WMI_SET_CHANNEL_FLAG(chan_info,
2991 WMI_CHAN_FLAG_PASSIVE);
2992
2993 if (tchan_info->allow_vht)
2994 WMI_SET_CHANNEL_FLAG(chan_info,
2995 WMI_CHAN_FLAG_ALLOW_VHT);
2996 else if (tchan_info->allow_ht)
2997 WMI_SET_CHANNEL_FLAG(chan_info,
2998 WMI_CHAN_FLAG_ALLOW_HT);
2999 WMI_SET_CHANNEL_MODE(chan_info,
3000 tchan_info->phy_mode);
3001
3002 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
3003 * after FW support
3004 */
3005
3006 /* also fill in power information */
3007 WMI_SET_CHANNEL_MIN_POWER(chan_info,
3008 tchan_info->minpower);
3009 WMI_SET_CHANNEL_MAX_POWER(chan_info,
3010 tchan_info->maxpower);
3011 WMI_SET_CHANNEL_REG_POWER(chan_info,
3012 tchan_info->maxregpower);
3013 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
3014 tchan_info->antennamax);
3015 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
3016 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08003017 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
3018 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05303019
Govind Singh87542482016-06-08 19:40:11 +05303020 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
3021
Govind Singh87542482016-06-08 19:40:11 +05303022 tchan_info++;
3023 chan_info++;
3024 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303025 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
3026 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05303027
Anish Natarajdd855152017-03-20 12:49:08 +05303028 qdf_status = wmi_unified_cmd_send(
3029 wmi_handle,
3030 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05303031
3032 if (QDF_IS_STATUS_ERROR(qdf_status)) {
3033 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
3034 wmi_buf_free(buf);
3035 }
3036
3037end:
3038 return qdf_status;
3039}
3040#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05303041
3042/**
3043 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3044 *
3045 * @bufp: Pointer to buffer
3046 * @param: Pointer to tx param
3047 *
3048 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3049 */
3050static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3051 struct tx_send_params param)
3052{
3053 wmi_tx_send_params *tx_param;
3054 QDF_STATUS status = QDF_STATUS_SUCCESS;
3055
3056 if (!bufp) {
3057 status = QDF_STATUS_E_FAILURE;
3058 return status;
3059 }
3060 tx_param = (wmi_tx_send_params *)bufp;
3061 WMITLV_SET_HDR(&tx_param->tlv_header,
3062 WMITLV_TAG_STRUC_wmi_tx_send_params,
3063 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3064 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3065 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3066 param.mcs_mask);
3067 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3068 param.nss_mask);
3069 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3070 param.retry_limit);
3071 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3072 param.chain_mask);
3073 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3074 param.bw_mask);
3075 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3076 param.preamble_type);
3077 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3078 param.frame_type);
3079
3080 return status;
3081}
3082
Govind Singhd3156eb2016-02-26 17:50:39 +05303083/**
3084 * send_mgmt_cmd_tlv() - WMI scan start function
3085 * @wmi_handle : handle to WMI.
3086 * @param : pointer to hold mgmt cmd parameter
3087 *
3088 * Return: 0 on success and -ve on failure.
3089 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303090static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303091 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303092{
Govind Singh427ee5a2016-02-26 18:09:36 +05303093 wmi_buf_t buf;
3094 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3095 int32_t cmd_len;
3096 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303097 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303098 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303099 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303100 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3101 mgmt_tx_dl_frm_len;
3102
3103 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303104 WMI_TLV_HDR_SIZE +
3105 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303106
Sathish Kumar5b636932017-06-28 14:40:32 +05303107 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303108 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303109 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3110 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303111 }
3112
3113 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3114 bufp = (uint8_t *) cmd;
3115 WMITLV_SET_HDR(&cmd->tlv_header,
3116 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3117 WMITLV_GET_STRUCT_TLVLEN
3118 (wmi_mgmt_tx_send_cmd_fixed_param));
3119
3120 cmd->vdev_id = param->vdev_id;
3121
Govind Singh224a7312016-06-21 14:33:26 +05303122 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303123 cmd->chanfreq = param->chanfreq;
3124 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3125 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3126 sizeof(uint32_t)));
3127 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303128 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303129
3130 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3131 QDF_DMA_TO_DEVICE);
3132 if (status != QDF_STATUS_SUCCESS) {
3133 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303134 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303135 }
3136
Govind Singhb53420c2016-03-09 14:32:57 +05303137 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303138 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003139#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303140 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3141#endif
3142 cmd->frame_len = param->frm_len;
3143 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303144 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303145
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003146 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003147 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003148
Sathish Kumar5b636932017-06-28 14:40:32 +05303149 bufp += roundup(bufp_len, sizeof(uint32_t));
3150 if (param->tx_params_valid) {
3151 status = populate_tx_send_params(bufp, param->tx_param);
3152 if (status != QDF_STATUS_SUCCESS) {
3153 WMI_LOGE("%s: Populate TX send params failed",
3154 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303155 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303156 }
3157 cmd_len += sizeof(wmi_tx_send_params);
3158 }
3159
Govind Singh427ee5a2016-02-26 18:09:36 +05303160 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3161 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303162 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303163 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303164 }
Govind Singhb53420c2016-03-09 14:32:57 +05303165 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303166
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303167unmap_tx_frame:
3168 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3169 QDF_DMA_TO_DEVICE);
3170free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303171 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303172 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303173}
3174
3175/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303176 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3177 * @wmi_handle : handle to WMI.
3178 * @param : pointer to offchan data tx cmd parameter
3179 *
3180 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3181 */
3182static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3183 struct wmi_offchan_data_tx_params *param)
3184{
3185 wmi_buf_t buf;
3186 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3187 int32_t cmd_len;
3188 uint64_t dma_addr;
3189 void *qdf_ctx = param->qdf_ctx;
3190 uint8_t *bufp;
3191 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3192 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303193 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303194
3195 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303196 WMI_TLV_HDR_SIZE +
3197 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303198
Sathish Kumar5b636932017-06-28 14:40:32 +05303199 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303200 if (!buf) {
3201 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3202 return QDF_STATUS_E_NOMEM;
3203 }
3204
3205 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3206 bufp = (uint8_t *) cmd;
3207 WMITLV_SET_HDR(&cmd->tlv_header,
3208 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3209 WMITLV_GET_STRUCT_TLVLEN
3210 (wmi_offchan_data_tx_send_cmd_fixed_param));
3211
3212 cmd->vdev_id = param->vdev_id;
3213
3214 cmd->desc_id = param->desc_id;
3215 cmd->chanfreq = param->chanfreq;
3216 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3217 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3218 sizeof(uint32_t)));
3219 bufp += WMI_TLV_HDR_SIZE;
3220 qdf_mem_copy(bufp, param->pdata, bufp_len);
3221 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3222 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3223 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3224#if defined(HTT_PADDR64)
3225 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3226#endif
3227 cmd->frame_len = param->frm_len;
3228 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303229 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303230
3231 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3232 bufp, cmd->vdev_id, cmd->chanfreq);
3233
Sathish Kumar5b636932017-06-28 14:40:32 +05303234 bufp += roundup(bufp_len, sizeof(uint32_t));
3235 if (param->tx_params_valid) {
3236 status = populate_tx_send_params(bufp, param->tx_param);
3237 if (status != QDF_STATUS_SUCCESS) {
3238 WMI_LOGE("%s: Populate TX send params failed",
3239 __func__);
3240 goto err1;
3241 }
3242 cmd_len += sizeof(wmi_tx_send_params);
3243 }
3244
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303245 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3246 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3247 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303248 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303249 }
3250
3251 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303252
3253err1:
3254 wmi_buf_free(buf);
3255 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303256}
3257
3258/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303259 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3260 * @wmi_handle: wmi handle
3261 * @param_value: parameter value
3262 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303263 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303264 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303265static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303266 uint32_t param_value)
3267{
Govind Singh67922e82016-04-01 16:48:57 +05303268 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303269 wmi_modem_power_state_cmd_param *cmd;
3270 wmi_buf_t buf;
3271 uint16_t len = sizeof(*cmd);
3272
3273 buf = wmi_buf_alloc(wmi_handle, len);
3274 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303275 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303276 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303277 }
3278 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3279 WMITLV_SET_HDR(&cmd->tlv_header,
3280 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3281 WMITLV_GET_STRUCT_TLVLEN
3282 (wmi_modem_power_state_cmd_param));
3283 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303284 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303285 param_value);
3286 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3287 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303288 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303289 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303290 wmi_buf_free(buf);
3291 }
Govind Singh67922e82016-04-01 16:48:57 +05303292
Govind Singh427ee5a2016-02-26 18:09:36 +05303293 return ret;
3294}
3295
3296/**
3297 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3298 * @wmi_handle: wmi handle
3299 * @vdev_id: vdev id
3300 * @val: value
3301 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303302 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303303 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303304static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303305 uint32_t vdev_id, uint8_t val)
3306{
3307 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3308 wmi_buf_t buf;
3309 int32_t len = sizeof(*cmd);
3310
Govind Singhb53420c2016-03-09 14:32:57 +05303311 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303312
3313 buf = wmi_buf_alloc(wmi_handle, len);
3314 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303315 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303316 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303317 }
3318 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3319 WMITLV_SET_HDR(&cmd->tlv_header,
3320 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3321 WMITLV_GET_STRUCT_TLVLEN
3322 (wmi_sta_powersave_mode_cmd_fixed_param));
3323 cmd->vdev_id = vdev_id;
3324 if (val)
3325 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3326 else
3327 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3328
3329 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3330 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303331 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303332 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303333 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303334 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303335 }
Govind Singh5eb51532016-03-09 11:34:12 +05303336 return 0;
3337}
3338
Govind Singh427ee5a2016-02-26 18:09:36 +05303339/**
3340 * send_set_mimops_cmd_tlv() - set MIMO powersave
3341 * @wmi_handle: wmi handle
3342 * @vdev_id: vdev id
3343 * @value: value
3344 *
Govind Singhb53420c2016-03-09 14:32:57 +05303345 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303346 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303347static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303348 uint8_t vdev_id, int value)
3349{
Govind Singh67922e82016-04-01 16:48:57 +05303350 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303351 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3352 wmi_buf_t buf;
3353 uint16_t len = sizeof(*cmd);
3354
3355 buf = wmi_buf_alloc(wmi_handle, len);
3356 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303357 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303358 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303359 }
3360 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3361 WMITLV_SET_HDR(&cmd->tlv_header,
3362 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3363 WMITLV_GET_STRUCT_TLVLEN
3364 (wmi_sta_smps_force_mode_cmd_fixed_param));
3365
3366 cmd->vdev_id = vdev_id;
3367
Houston Hoffmanb5168052016-04-14 02:18:01 -07003368 /* WMI_SMPS_FORCED_MODE values do not directly map
3369 * to SM power save values defined in the specification.
3370 * Make sure to send the right mapping.
3371 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303372 switch (value) {
3373 case 0:
3374 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3375 break;
3376 case 1:
3377 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3378 break;
3379 case 2:
3380 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3381 break;
3382 case 3:
3383 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3384 break;
3385 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303386 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
3387 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303388 }
3389
Govind Singhb53420c2016-03-09 14:32:57 +05303390 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303391
3392 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3393 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303394 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303395 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303396 wmi_buf_free(buf);
3397 }
3398
3399 return ret;
3400}
3401
3402/**
3403 * send_set_smps_params_cmd_tlv() - set smps params
3404 * @wmi_handle: wmi handle
3405 * @vdev_id: vdev id
3406 * @value: value
3407 *
Govind Singhb53420c2016-03-09 14:32:57 +05303408 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303409 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303410static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303411 int value)
3412{
Govind Singh67922e82016-04-01 16:48:57 +05303413 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303414 wmi_sta_smps_param_cmd_fixed_param *cmd;
3415 wmi_buf_t buf;
3416 uint16_t len = sizeof(*cmd);
3417
3418 buf = wmi_buf_alloc(wmi_handle, len);
3419 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303420 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303421 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303422 }
3423 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3424 WMITLV_SET_HDR(&cmd->tlv_header,
3425 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3426 WMITLV_GET_STRUCT_TLVLEN
3427 (wmi_sta_smps_param_cmd_fixed_param));
3428
3429 cmd->vdev_id = vdev_id;
3430 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3431 cmd->param =
3432 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3433
Govind Singhb53420c2016-03-09 14:32:57 +05303434 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303435 cmd->param);
3436
3437 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3438 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303439 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303440 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303441 wmi_buf_free(buf);
3442 }
3443
3444 return ret;
3445}
3446
3447/**
3448 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3449 * @wmi_handle: wmi handle
3450 * @noa: p2p power save parameters
3451 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303452 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303453 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303454static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303455 struct p2p_ps_params *noa)
3456{
3457 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3458 wmi_p2p_noa_descriptor *noa_discriptor;
3459 wmi_buf_t buf;
3460 uint8_t *buf_ptr;
3461 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303462 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303463 uint32_t duration;
3464
Govind Singhb53420c2016-03-09 14:32:57 +05303465 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303466 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3467 buf = wmi_buf_alloc(wmi_handle, len);
3468 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303469 WMI_LOGE("Failed to allocate memory");
3470 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303471 goto end;
3472 }
3473
3474 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3475 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3476 WMITLV_SET_HDR(&cmd->tlv_header,
3477 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3478 WMITLV_GET_STRUCT_TLVLEN
3479 (wmi_p2p_set_noa_cmd_fixed_param));
3480 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3481 cmd->vdev_id = noa->session_id;
3482 cmd->enable = (duration) ? true : false;
3483 cmd->num_noa = 1;
3484
3485 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3486 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3487 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3488 sizeof
3489 (wmi_p2p_set_noa_cmd_fixed_param)
3490 + WMI_TLV_HDR_SIZE);
3491 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3492 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3493 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3494 noa_discriptor->type_count = noa->count;
3495 noa_discriptor->duration = duration;
3496 noa_discriptor->interval = noa->interval;
3497 noa_discriptor->start_time = 0;
3498
Govind Singhb53420c2016-03-09 14:32:57 +05303499 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303500 cmd->vdev_id, noa->count, noa_discriptor->duration,
3501 noa->interval);
3502 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3503 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303504 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303505 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303506 wmi_buf_free(buf);
3507 }
3508
3509end:
Govind Singhb53420c2016-03-09 14:32:57 +05303510 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303511 return status;
3512}
3513
3514
3515/**
3516 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3517 * @wmi_handle: wmi handle
3518 * @noa: p2p opp power save parameters
3519 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303520 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303521 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303522static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303523 struct p2p_ps_params *oppps)
3524{
3525 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3526 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303527 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303528
Govind Singhb53420c2016-03-09 14:32:57 +05303529 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303530 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3531 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303532 WMI_LOGE("Failed to allocate memory");
3533 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303534 goto end;
3535 }
3536
3537 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3538 WMITLV_SET_HDR(&cmd->tlv_header,
3539 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3540 WMITLV_GET_STRUCT_TLVLEN
3541 (wmi_p2p_set_oppps_cmd_fixed_param));
3542 cmd->vdev_id = oppps->session_id;
3543 if (oppps->ctwindow)
3544 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3545
3546 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303547 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303548 cmd->vdev_id, oppps->ctwindow);
3549 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3550 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303551 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303552 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303553 wmi_buf_free(buf);
3554 }
3555
3556end:
Govind Singhb53420c2016-03-09 14:32:57 +05303557 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303558 return status;
3559}
3560
Wu Gaocd3a8512017-03-13 20:17:34 +08003561#ifdef CONVERGED_P2P_ENABLE
3562/**
3563 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3564 * @wmi_handle: wmi handle
3565 * @param: p2p listen offload start parameters
3566 *
3567 * Return: QDF status
3568 */
3569static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3570 struct p2p_lo_start *param)
3571{
3572 wmi_buf_t buf;
3573 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3574 int32_t len = sizeof(*cmd);
3575 uint8_t *buf_ptr;
3576 QDF_STATUS status;
3577 int device_types_len_aligned;
3578 int probe_resp_len_aligned;
3579
3580 if (!param) {
3581 WMI_LOGE("lo start param is null");
3582 return QDF_STATUS_E_INVAL;
3583 }
3584
3585 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3586
3587 device_types_len_aligned =
3588 qdf_roundup(param->dev_types_len,
3589 sizeof(A_UINT32));
3590 probe_resp_len_aligned =
3591 qdf_roundup(param->probe_resp_len,
3592 sizeof(A_UINT32));
3593
3594 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3595 probe_resp_len_aligned;
3596
3597 buf = wmi_buf_alloc(wmi_handle, len);
3598 if (!buf) {
3599 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3600 __func__);
3601 return QDF_STATUS_E_NOMEM;
3602 }
3603
3604 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3605 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3606
3607 WMITLV_SET_HDR(&cmd->tlv_header,
3608 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3609 WMITLV_GET_STRUCT_TLVLEN(
3610 wmi_p2p_lo_start_cmd_fixed_param));
3611
3612 cmd->vdev_id = param->vdev_id;
3613 cmd->ctl_flags = param->ctl_flags;
3614 cmd->channel = param->freq;
3615 cmd->period = param->period;
3616 cmd->interval = param->interval;
3617 cmd->count = param->count;
3618 cmd->device_types_len = param->dev_types_len;
3619 cmd->prob_resp_len = param->probe_resp_len;
3620
3621 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3622 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3623 device_types_len_aligned);
3624 buf_ptr += WMI_TLV_HDR_SIZE;
3625 qdf_mem_copy(buf_ptr, param->device_types,
3626 param->dev_types_len);
3627
3628 buf_ptr += device_types_len_aligned;
3629 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3630 probe_resp_len_aligned);
3631 buf_ptr += WMI_TLV_HDR_SIZE;
3632 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3633 param->probe_resp_len);
3634
3635 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3636 cmd->channel, cmd->period, cmd->interval, cmd->count);
3637
3638 status = wmi_unified_cmd_send(wmi_handle,
3639 buf, len,
3640 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3641 if (status != QDF_STATUS_SUCCESS) {
3642 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3643 __func__, status);
3644 wmi_buf_free(buf);
3645 return status;
3646 }
3647
3648 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3649
3650 return QDF_STATUS_SUCCESS;
3651}
3652
3653/**
3654 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3655 * @wmi_handle: wmi handle
3656 * @param: p2p listen offload stop parameters
3657 *
3658 * Return: QDF status
3659 */
3660static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3661 uint8_t vdev_id)
3662{
3663 wmi_buf_t buf;
3664 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3665 int32_t len;
3666 QDF_STATUS status;
3667
3668 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3669
3670 len = sizeof(*cmd);
3671 buf = wmi_buf_alloc(wmi_handle, len);
3672 if (!buf) {
3673 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3674 __func__);
3675 return QDF_STATUS_E_NOMEM;
3676 }
3677 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3678
3679 WMITLV_SET_HDR(&cmd->tlv_header,
3680 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3681 WMITLV_GET_STRUCT_TLVLEN(
3682 wmi_p2p_lo_stop_cmd_fixed_param));
3683
3684 cmd->vdev_id = vdev_id;
3685
3686 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3687
3688 status = wmi_unified_cmd_send(wmi_handle,
3689 buf, len,
3690 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3691 if (status != QDF_STATUS_SUCCESS) {
3692 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3693 __func__, status);
3694 wmi_buf_free(buf);
3695 return status;
3696 }
3697
3698 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3699
3700 return QDF_STATUS_SUCCESS;
3701}
3702#endif /* End of CONVERGED_P2P_ENABLE */
3703
Govind Singh427ee5a2016-02-26 18:09:36 +05303704/**
3705 * send_get_temperature_cmd_tlv() - get pdev temperature req
3706 * @wmi_handle: wmi handle
3707 *
Govind Singhb53420c2016-03-09 14:32:57 +05303708 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303709 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303710static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303711{
3712 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3713 wmi_buf_t wmi_buf;
3714 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3715 uint8_t *buf_ptr;
3716
3717 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303718 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3719 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303720 }
3721
3722 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3723 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303724 WMI_LOGE(FL("wmi_buf_alloc failed"));
3725 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303726 }
3727
3728 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3729
3730 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3731 WMITLV_SET_HDR(&cmd->tlv_header,
3732 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3733 WMITLV_GET_STRUCT_TLVLEN
3734 (wmi_pdev_get_temperature_cmd_fixed_param));
3735
3736 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3737 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303738 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303739 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303740 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303741 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303742
Govind Singhb53420c2016-03-09 14:32:57 +05303743 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303744}
3745
3746/**
3747 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3748 * @wmi_handle: wmi handle
3749 * @vdevid: vdev id
3750 * @peer_addr: peer mac address
3751 * @auto_triggerparam: auto trigger parameters
3752 * @num_ac: number of access category
3753 *
3754 * This function sets the trigger
3755 * uapsd params such as service interval, delay interval
3756 * and suspend interval which will be used by the firmware
3757 * to send trigger frames periodically when there is no
3758 * traffic on the transmit side.
3759 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303760 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303761 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303762static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303763 struct sta_uapsd_trig_params *param)
3764{
3765 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303766 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303767 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3768 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3769 uint32_t i;
3770 wmi_buf_t buf;
3771 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003772 struct sta_uapsd_params *uapsd_param;
3773 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303774
3775 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3776 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303777 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303778 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303779 }
3780
3781 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3782 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3783 WMITLV_SET_HDR(&cmd->tlv_header,
3784 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3785 WMITLV_GET_STRUCT_TLVLEN
3786 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3787 cmd->vdev_id = param->vdevid;
3788 cmd->num_ac = param->num_ac;
3789 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3790
3791 /* TLV indicating array of structures to follow */
3792 buf_ptr += sizeof(*cmd);
3793 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3794
3795 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303796
3797 /*
3798 * Update tag and length for uapsd auto trigger params (this will take
3799 * care of updating tag and length if it is not pre-filled by caller).
3800 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003801 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3802 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303803 for (i = 0; i < param->num_ac; i++) {
3804 WMITLV_SET_HDR((buf_ptr +
3805 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3806 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3807 WMITLV_GET_STRUCT_TLVLEN
3808 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003809 trig_param->wmm_ac = uapsd_param->wmm_ac;
3810 trig_param->user_priority = uapsd_param->user_priority;
3811 trig_param->service_interval = uapsd_param->service_interval;
3812 trig_param->suspend_interval = uapsd_param->suspend_interval;
3813 trig_param->delay_interval = uapsd_param->delay_interval;
3814 trig_param++;
3815 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303816 }
3817
3818 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3819 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303820 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303821 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303822 wmi_buf_free(buf);
3823 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303824
Govind Singh427ee5a2016-02-26 18:09:36 +05303825 return ret;
3826}
3827
Zhang Qian11c0de32018-01-05 16:50:53 +08003828#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303829/**
3830 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3831 * @wmi_handle: pointer to the wmi handle
3832 * @utc: pointer to the UTC time struct
3833 *
3834 * Return: 0 on succes
3835 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303836static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303837 struct ocb_utc_param *utc)
3838{
Govind Singh67922e82016-04-01 16:48:57 +05303839 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303840 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3841 uint8_t *buf_ptr;
3842 uint32_t len, i;
3843 wmi_buf_t buf;
3844
3845 len = sizeof(*cmd);
3846 buf = wmi_buf_alloc(wmi_handle, len);
3847 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303848 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303849 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303850 }
3851
3852 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3853 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3854 WMITLV_SET_HDR(&cmd->tlv_header,
3855 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3856 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3857 cmd->vdev_id = utc->vdev_id;
3858
3859 for (i = 0; i < SIZE_UTC_TIME; i++)
3860 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3861
3862 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3863 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3864
3865 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3866 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303867 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303868 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303869 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303870 }
3871
Govind Singh67922e82016-04-01 16:48:57 +05303872 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303873}
3874
3875/**
3876 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3877 * frames on a channel
3878 * @wmi_handle: pointer to the wmi handle
3879 * @timing_advert: pointer to the timing advertisement struct
3880 *
3881 * Return: 0 on succes
3882 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303883static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303884 struct ocb_timing_advert_param *timing_advert)
3885{
Govind Singh67922e82016-04-01 16:48:57 +05303886 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303887 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3888 uint8_t *buf_ptr;
3889 uint32_t len, len_template;
3890 wmi_buf_t buf;
3891
3892 len = sizeof(*cmd) +
3893 WMI_TLV_HDR_SIZE;
3894
3895 len_template = timing_advert->template_length;
3896 /* Add padding to the template if needed */
3897 if (len_template % 4 != 0)
3898 len_template += 4 - (len_template % 4);
3899 len += len_template;
3900
3901 buf = wmi_buf_alloc(wmi_handle, len);
3902 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303903 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303904 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303905 }
3906
3907 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3908 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3909 WMITLV_SET_HDR(&cmd->tlv_header,
3910 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3911 WMITLV_GET_STRUCT_TLVLEN(
3912 wmi_ocb_start_timing_advert_cmd_fixed_param));
3913 cmd->vdev_id = timing_advert->vdev_id;
3914 cmd->repeat_rate = timing_advert->repeat_rate;
3915 cmd->channel_freq = timing_advert->chan_freq;
3916 cmd->timestamp_offset = timing_advert->timestamp_offset;
3917 cmd->time_value_offset = timing_advert->time_value_offset;
3918 cmd->timing_advert_template_length = timing_advert->template_length;
3919 buf_ptr += sizeof(*cmd);
3920
3921 /* Add the timing advert template */
3922 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3923 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303924 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303925 (uint8_t *)timing_advert->template_value,
3926 timing_advert->template_length);
3927
3928 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3929 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303930 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303931 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303932 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303933 }
3934
Govind Singh67922e82016-04-01 16:48:57 +05303935 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303936}
3937
3938/**
3939 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3940 * on a channel
3941 * @wmi_handle: pointer to the wmi handle
3942 * @timing_advert: pointer to the timing advertisement struct
3943 *
3944 * Return: 0 on succes
3945 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303946static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303947 struct ocb_timing_advert_param *timing_advert)
3948{
Govind Singh67922e82016-04-01 16:48:57 +05303949 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303950 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3951 uint8_t *buf_ptr;
3952 uint32_t len;
3953 wmi_buf_t buf;
3954
3955 len = sizeof(*cmd);
3956 buf = wmi_buf_alloc(wmi_handle, len);
3957 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303958 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303959 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303960 }
3961
3962 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3963 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3964 WMITLV_SET_HDR(&cmd->tlv_header,
3965 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3966 WMITLV_GET_STRUCT_TLVLEN(
3967 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3968 cmd->vdev_id = timing_advert->vdev_id;
3969 cmd->channel_freq = timing_advert->chan_freq;
3970
3971 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3972 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303973 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303974 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303975 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303976 }
3977
Govind Singh67922e82016-04-01 16:48:57 +05303978 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303979}
3980
3981/**
3982 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3983 * @wmi_handle: pointer to the wmi handle
3984 * @request: pointer to the request
3985 *
3986 * Return: 0 on succes
3987 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303988static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303989 uint8_t vdev_id)
3990{
Govind Singhb53420c2016-03-09 14:32:57 +05303991 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303992 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3993 uint8_t *buf_ptr;
3994 wmi_buf_t buf;
3995 int32_t len;
3996
3997 len = sizeof(*cmd);
3998 buf = wmi_buf_alloc(wmi_handle, len);
3999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304000 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304001 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304002 }
4003 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4004
4005 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304006 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304007 WMITLV_SET_HDR(&cmd->tlv_header,
4008 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
4009 WMITLV_GET_STRUCT_TLVLEN(
4010 wmi_ocb_get_tsf_timer_cmd_fixed_param));
4011 cmd->vdev_id = vdev_id;
4012
4013 /* Send the WMI command */
4014 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4015 WMI_OCB_GET_TSF_TIMER_CMDID);
4016 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304017 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304018 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304019 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304020 }
4021
Govind Singh67922e82016-04-01 16:48:57 +05304022 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304023}
4024
4025/**
4026 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
4027 * @wmi_handle: pointer to the wmi handle
4028 * @get_stats_param: pointer to the dcc stats
4029 *
4030 * Return: 0 on succes
4031 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304032static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004033 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304034{
Govind Singh67922e82016-04-01 16:48:57 +05304035 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304036 wmi_dcc_get_stats_cmd_fixed_param *cmd;
4037 wmi_dcc_channel_stats_request *channel_stats_array;
4038 wmi_buf_t buf;
4039 uint8_t *buf_ptr;
4040 uint32_t len;
4041 uint32_t i;
4042
4043 /* Validate the input */
4044 if (get_stats_param->request_array_len !=
4045 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304046 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304047 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304048 }
4049
4050 /* Allocate memory for the WMI command */
4051 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4052 get_stats_param->request_array_len;
4053
4054 buf = wmi_buf_alloc(wmi_handle, len);
4055 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304056 WMI_LOGE(FL("wmi_buf_alloc failed"));
4057 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304058 }
4059
4060 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304061 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304062
4063 /* Populate the WMI command */
4064 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4065 buf_ptr += sizeof(*cmd);
4066
4067 WMITLV_SET_HDR(&cmd->tlv_header,
4068 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4069 WMITLV_GET_STRUCT_TLVLEN(
4070 wmi_dcc_get_stats_cmd_fixed_param));
4071 cmd->vdev_id = get_stats_param->vdev_id;
4072 cmd->num_channels = get_stats_param->channel_count;
4073
4074 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4075 get_stats_param->request_array_len);
4076 buf_ptr += WMI_TLV_HDR_SIZE;
4077
4078 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304079 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304080 get_stats_param->request_array_len);
4081 for (i = 0; i < cmd->num_channels; i++)
4082 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4083 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4084 WMITLV_GET_STRUCT_TLVLEN(
4085 wmi_dcc_channel_stats_request));
4086
4087 /* Send the WMI command */
4088 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4089 WMI_DCC_GET_STATS_CMDID);
4090
Govind Singh67922e82016-04-01 16:48:57 +05304091 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304092 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304093 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304094 }
4095
Govind Singh67922e82016-04-01 16:48:57 +05304096 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304097}
4098
4099/**
4100 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4101 * @wmi_handle: pointer to the wmi handle
4102 * @vdev_id: vdev id
4103 * @dcc_stats_bitmap: dcc status bitmap
4104 *
4105 * Return: 0 on succes
4106 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304107static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304108 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4109{
Govind Singh67922e82016-04-01 16:48:57 +05304110 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304111 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4112 wmi_buf_t buf;
4113 uint8_t *buf_ptr;
4114 uint32_t len;
4115
4116 /* Allocate memory for the WMI command */
4117 len = sizeof(*cmd);
4118
4119 buf = wmi_buf_alloc(wmi_handle, len);
4120 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304121 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304122 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304123 }
4124
4125 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304126 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304127
4128 /* Populate the WMI command */
4129 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4130
4131 WMITLV_SET_HDR(&cmd->tlv_header,
4132 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4133 WMITLV_GET_STRUCT_TLVLEN(
4134 wmi_dcc_clear_stats_cmd_fixed_param));
4135 cmd->vdev_id = vdev_id;
4136 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4137
4138 /* Send the WMI command */
4139 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4140 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304141 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304142 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304143 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304144 }
4145
Govind Singh67922e82016-04-01 16:48:57 +05304146 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304147}
4148
4149/**
4150 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4151 * @wmi_handle: pointer to the wmi handle
4152 * @update_ndl_param: pointer to the request parameters
4153 *
4154 * Return: 0 on success
4155 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304156static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004157 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304158{
Govind Singhb53420c2016-03-09 14:32:57 +05304159 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304160 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4161 wmi_dcc_ndl_chan *ndl_chan_array;
4162 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4163 uint32_t active_state_count;
4164 wmi_buf_t buf;
4165 uint8_t *buf_ptr;
4166 uint32_t len;
4167 uint32_t i;
4168
4169 /* validate the input */
4170 if (update_ndl_param->dcc_ndl_chan_list_len !=
4171 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304172 WMI_LOGE(FL("Invalid parameter"));
4173 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304174 }
4175 active_state_count = 0;
4176 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4177 for (i = 0; i < update_ndl_param->channel_count; i++)
4178 active_state_count +=
4179 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4180 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4181 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304182 WMI_LOGE(FL("Invalid parameter"));
4183 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304184 }
4185
4186 /* Allocate memory for the WMI command */
4187 len = sizeof(*cmd) +
4188 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4189 WMI_TLV_HDR_SIZE +
4190 update_ndl_param->dcc_ndl_active_state_list_len;
4191
4192 buf = wmi_buf_alloc(wmi_handle, len);
4193 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304194 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304195 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304196 }
4197
4198 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304199 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304200
4201 /* Populate the WMI command */
4202 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4203 buf_ptr += sizeof(*cmd);
4204
4205 WMITLV_SET_HDR(&cmd->tlv_header,
4206 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4207 WMITLV_GET_STRUCT_TLVLEN(
4208 wmi_dcc_update_ndl_cmd_fixed_param));
4209 cmd->vdev_id = update_ndl_param->vdev_id;
4210 cmd->num_channel = update_ndl_param->channel_count;
4211
4212 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4213 update_ndl_param->dcc_ndl_chan_list_len);
4214 buf_ptr += WMI_TLV_HDR_SIZE;
4215
4216 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304217 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304218 update_ndl_param->dcc_ndl_chan_list_len);
4219 for (i = 0; i < cmd->num_channel; i++)
4220 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4221 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4222 WMITLV_GET_STRUCT_TLVLEN(
4223 wmi_dcc_ndl_chan));
4224 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4225
4226 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4227 update_ndl_param->dcc_ndl_active_state_list_len);
4228 buf_ptr += WMI_TLV_HDR_SIZE;
4229
4230 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304231 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304232 update_ndl_param->dcc_ndl_active_state_list,
4233 update_ndl_param->dcc_ndl_active_state_list_len);
4234 for (i = 0; i < active_state_count; i++) {
4235 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4236 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4237 WMITLV_GET_STRUCT_TLVLEN(
4238 wmi_dcc_ndl_active_state_config));
4239 }
4240 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4241
4242 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304243 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304244 WMI_DCC_UPDATE_NDL_CMDID);
4245 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304246 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304247 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304248 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304249 }
4250
Govind Singh67922e82016-04-01 16:48:57 +05304251 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304252}
4253
4254/**
4255 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4256 * @wmi_handle: pointer to the wmi handle
4257 * @config: the OCB configuration
4258 *
4259 * Return: 0 on success
4260 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304261static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004262 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304263{
Govind Singh67922e82016-04-01 16:48:57 +05304264 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304265 wmi_ocb_set_config_cmd_fixed_param *cmd;
4266 wmi_channel *chan;
4267 wmi_ocb_channel *ocb_chan;
4268 wmi_qos_parameter *qos_param;
4269 wmi_dcc_ndl_chan *ndl_chan;
4270 wmi_dcc_ndl_active_state_config *ndl_active_config;
4271 wmi_ocb_schedule_element *sched_elem;
4272 uint8_t *buf_ptr;
4273 wmi_buf_t buf;
4274 int32_t len;
4275 int32_t i, j, active_state_count;
4276
4277 /*
4278 * Validate the dcc_ndl_chan_list_len and count the number of active
4279 * states. Validate dcc_ndl_active_state_list_len.
4280 */
4281 active_state_count = 0;
4282 if (config->dcc_ndl_chan_list_len) {
4283 if (!config->dcc_ndl_chan_list ||
4284 config->dcc_ndl_chan_list_len !=
4285 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304286 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304287 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304288 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304289 }
4290
4291 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4292 i < config->channel_count; ++i, ++ndl_chan)
4293 active_state_count +=
4294 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4295
4296 if (active_state_count) {
4297 if (!config->dcc_ndl_active_state_list ||
4298 config->dcc_ndl_active_state_list_len !=
4299 active_state_count *
4300 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304301 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304302 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304303 }
4304 }
4305 }
4306
4307 len = sizeof(*cmd) +
4308 WMI_TLV_HDR_SIZE + config->channel_count *
4309 sizeof(wmi_channel) +
4310 WMI_TLV_HDR_SIZE + config->channel_count *
4311 sizeof(wmi_ocb_channel) +
4312 WMI_TLV_HDR_SIZE + config->channel_count *
4313 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4314 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4315 WMI_TLV_HDR_SIZE + active_state_count *
4316 sizeof(wmi_dcc_ndl_active_state_config) +
4317 WMI_TLV_HDR_SIZE + config->schedule_size *
4318 sizeof(wmi_ocb_schedule_element);
4319 buf = wmi_buf_alloc(wmi_handle, len);
4320 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304321 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304322 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304323 }
4324
4325 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4326 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4327 WMITLV_SET_HDR(&cmd->tlv_header,
4328 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4329 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004330 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304331 cmd->channel_count = config->channel_count;
4332 cmd->schedule_size = config->schedule_size;
4333 cmd->flags = config->flags;
4334 buf_ptr += sizeof(*cmd);
4335
4336 /* Add the wmi_channel info */
4337 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4338 config->channel_count*sizeof(wmi_channel));
4339 buf_ptr += WMI_TLV_HDR_SIZE;
4340 for (i = 0; i < config->channel_count; i++) {
4341 chan = (wmi_channel *)buf_ptr;
4342 WMITLV_SET_HDR(&chan->tlv_header,
4343 WMITLV_TAG_STRUC_wmi_channel,
4344 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4345 chan->mhz = config->channels[i].chan_freq;
4346 chan->band_center_freq1 = config->channels[i].chan_freq;
4347 chan->band_center_freq2 = 0;
4348 chan->info = 0;
4349
Zhang Qian11c0de32018-01-05 16:50:53 +08004350 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304351 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4352 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4353 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4354 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4355 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4356 config->channels[i].antenna_max);
4357
4358 if (config->channels[i].bandwidth < 10)
4359 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4360 else if (config->channels[i].bandwidth < 20)
4361 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4362 buf_ptr += sizeof(*chan);
4363 }
4364
4365 /* Add the wmi_ocb_channel info */
4366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4367 config->channel_count*sizeof(wmi_ocb_channel));
4368 buf_ptr += WMI_TLV_HDR_SIZE;
4369 for (i = 0; i < config->channel_count; i++) {
4370 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4371 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4372 WMITLV_TAG_STRUC_wmi_ocb_channel,
4373 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4374 ocb_chan->bandwidth = config->channels[i].bandwidth;
4375 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4376 config->channels[i].mac_address.bytes,
4377 &ocb_chan->mac_address);
4378 buf_ptr += sizeof(*ocb_chan);
4379 }
4380
4381 /* Add the wmi_qos_parameter info */
4382 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4383 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4384 buf_ptr += WMI_TLV_HDR_SIZE;
4385 /* WMI_MAX_NUM_AC parameters for each channel */
4386 for (i = 0; i < config->channel_count; i++) {
4387 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4388 qos_param = (wmi_qos_parameter *)buf_ptr;
4389 WMITLV_SET_HDR(&qos_param->tlv_header,
4390 WMITLV_TAG_STRUC_wmi_qos_parameter,
4391 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4392 qos_param->aifsn =
4393 config->channels[i].qos_params[j].aifsn;
4394 qos_param->cwmin =
4395 config->channels[i].qos_params[j].cwmin;
4396 qos_param->cwmax =
4397 config->channels[i].qos_params[j].cwmax;
4398 buf_ptr += sizeof(*qos_param);
4399 }
4400 }
4401
4402 /* Add the wmi_dcc_ndl_chan (per channel) */
4403 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4404 config->dcc_ndl_chan_list_len);
4405 buf_ptr += WMI_TLV_HDR_SIZE;
4406 if (config->dcc_ndl_chan_list_len) {
4407 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304408 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304409 config->dcc_ndl_chan_list_len);
4410 for (i = 0; i < config->channel_count; i++)
4411 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4412 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4413 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4414 buf_ptr += config->dcc_ndl_chan_list_len;
4415 }
4416
4417 /* Add the wmi_dcc_ndl_active_state_config */
4418 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4419 sizeof(wmi_dcc_ndl_active_state_config));
4420 buf_ptr += WMI_TLV_HDR_SIZE;
4421 if (active_state_count) {
4422 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304423 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304424 config->dcc_ndl_active_state_list,
4425 active_state_count * sizeof(*ndl_active_config));
4426 for (i = 0; i < active_state_count; ++i)
4427 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4428 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4429 WMITLV_GET_STRUCT_TLVLEN(
4430 wmi_dcc_ndl_active_state_config));
4431 buf_ptr += active_state_count *
4432 sizeof(*ndl_active_config);
4433 }
4434
4435 /* Add the wmi_ocb_schedule_element info */
4436 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4437 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4438 buf_ptr += WMI_TLV_HDR_SIZE;
4439 for (i = 0; i < config->schedule_size; i++) {
4440 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4441 WMITLV_SET_HDR(&sched_elem->tlv_header,
4442 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4443 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4444 sched_elem->channel_freq = config->schedule[i].chan_freq;
4445 sched_elem->total_duration = config->schedule[i].total_duration;
4446 sched_elem->guard_interval = config->schedule[i].guard_interval;
4447 buf_ptr += sizeof(*sched_elem);
4448 }
4449
4450
4451 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4452 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304453 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304454 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304455 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304456 }
4457
Govind Singh67922e82016-04-01 16:48:57 +05304458 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304459}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304460
4461/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004462 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4463 * @wmi_handle: wmi handle
4464 * @evt_buf: wmi event buffer
4465 * @status: status buffer
4466 *
4467 * Return: QDF_STATUS_SUCCESS on success
4468 */
4469static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4470 void *evt_buf,
4471 uint32_t *status)
4472{
4473 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4474 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4475
4476 param_tlvs = evt_buf;
4477 fix_param = param_tlvs->fixed_param;
4478
4479 *status = fix_param->status;
4480 return QDF_STATUS_SUCCESS;
4481}
4482
4483/**
4484 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4485 * @wmi_handle: wmi handle
4486 * @evt_buf: wmi event buffer
4487 * @resp: response buffer
4488 *
4489 * Return: QDF_STATUS_SUCCESS on success
4490 */
4491static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4492 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4493{
4494 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4495 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4496
4497 param_tlvs = evt_buf;
4498 fix_param = param_tlvs->fixed_param;
4499 resp->vdev_id = fix_param->vdev_id;
4500 resp->timer_high = fix_param->tsf_timer_high;
4501 resp->timer_low = fix_param->tsf_timer_low;
4502
4503 return QDF_STATUS_SUCCESS;
4504}
4505
4506/**
4507 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4508 * @wmi_handle: wmi handle
4509 * @evt_buf: wmi event buffer
4510 * @resp: response buffer
4511 *
4512 * Return: QDF_STATUS_SUCCESS on success
4513 */
4514static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4515 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4516{
4517 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4518 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4519
4520 param_tlvs = evt_buf;
4521 fix_param = param_tlvs->fixed_param;
4522 resp->vdev_id = fix_param->vdev_id;
4523 resp->status = fix_param->status;
4524 return QDF_STATUS_SUCCESS;
4525}
4526
4527/**
4528 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4529 * @wmi_handle: wmi handle
4530 * @evt_buf: wmi event buffer
4531 * @resp: response buffer
4532 *
4533 * Since length of stats is variable, buffer for DCC stats will be allocated
4534 * in this function. The caller must free the buffer.
4535 *
4536 * Return: QDF_STATUS_SUCCESS on success
4537 */
4538static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4539 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4540{
4541 struct ocb_dcc_get_stats_response *response;
4542 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4543 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4544
4545 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4546 fix_param = param_tlvs->fixed_param;
4547
4548 /* Allocate and populate the response */
4549 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4550 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4551 WMI_LOGE("%s: too many channels:%d", __func__,
4552 fix_param->num_channels);
4553 QDF_ASSERT(0);
4554 *resp = NULL;
4555 return QDF_STATUS_E_INVAL;
4556 }
4557 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4558 sizeof(wmi_dcc_ndl_stats_per_channel));
4559 *resp = response;
4560 if (!response)
4561 return QDF_STATUS_E_NOMEM;
4562
4563 response->vdev_id = fix_param->vdev_id;
4564 response->num_channels = fix_param->num_channels;
4565 response->channel_stats_array_len =
4566 fix_param->num_channels *
4567 sizeof(wmi_dcc_ndl_stats_per_channel);
4568 response->channel_stats_array = ((uint8_t *)response) +
4569 sizeof(*response);
4570 qdf_mem_copy(response->channel_stats_array,
4571 param_tlvs->stats_per_channel_list,
4572 response->channel_stats_array_len);
4573
4574 return QDF_STATUS_SUCCESS;
4575}
4576#endif
4577
4578/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304579 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4580 * @wmi_handle: wmi handle
4581 * @mcc_adaptive_scheduler: enable/disable
4582 *
4583 * This function enable/disable mcc adaptive scheduler in fw.
4584 *
Govind Singhb53420c2016-03-09 14:32:57 +05304585 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304586 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304587static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004588 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4589 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304590{
Govind Singh67922e82016-04-01 16:48:57 +05304591 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304592 wmi_buf_t buf = 0;
4593 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4594 uint16_t len =
4595 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4596
4597 buf = wmi_buf_alloc(wmi_handle, len);
4598 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304599 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4600 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304601 }
4602 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4603 wmi_buf_data(buf);
4604
4605 WMITLV_SET_HDR(&cmd->tlv_header,
4606 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4607 WMITLV_GET_STRUCT_TLVLEN
4608 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4609 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304610 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304611
4612 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4613 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304614 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304615 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304616 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304617 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304618 }
Govind Singh67922e82016-04-01 16:48:57 +05304619
4620 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304621}
4622
4623/**
4624 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4625 * @wmi: wmi handle
4626 * @mcc_channel: mcc channel
4627 * @mcc_channel_time_latency: MCC channel time latency.
4628 *
4629 * Currently used to set time latency for an MCC vdev/adapter using operating
4630 * channel of it and channel number. The info is provided run time using
4631 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4632 *
4633 * Return: CDF status
4634 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304635static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304636 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4637{
Govind Singh67922e82016-04-01 16:48:57 +05304638 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304639 wmi_buf_t buf = 0;
4640 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4641 uint16_t len = 0;
4642 uint8_t *buf_ptr = NULL;
4643 wmi_resmgr_chan_latency chan_latency;
4644 /* Note: we only support MCC time latency for a single channel */
4645 uint32_t num_channels = 1;
4646 uint32_t chan1_freq = mcc_channel_freq;
4647 uint32_t latency_chan1 = mcc_channel_time_latency;
4648
4649
4650 /* If 0ms latency is provided, then FW will set to a default.
4651 * Otherwise, latency must be at least 30ms.
4652 */
4653 if ((latency_chan1 > 0) &&
4654 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304655 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304656 "Minimum is 30ms (or 0 to use default value by "
4657 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304658 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304659 }
4660
4661 /* Set WMI CMD for channel time latency here */
4662 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4663 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4664 num_channels * sizeof(wmi_resmgr_chan_latency);
4665 buf = wmi_buf_alloc(wmi_handle, len);
4666 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304667 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4668 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304669 }
4670 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4671 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4672 wmi_buf_data(buf);
4673 WMITLV_SET_HDR(&cmdTL->tlv_header,
4674 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4675 WMITLV_GET_STRUCT_TLVLEN
4676 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4677 cmdTL->num_chans = num_channels;
4678 /* Update channel time latency information for home channel(s) */
4679 buf_ptr += sizeof(*cmdTL);
4680 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4681 num_channels * sizeof(wmi_resmgr_chan_latency));
4682 buf_ptr += WMI_TLV_HDR_SIZE;
4683 chan_latency.chan_mhz = chan1_freq;
4684 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304685 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304686 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4687 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304688 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304689 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304690 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304691 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304692 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304693 }
Govind Singh67922e82016-04-01 16:48:57 +05304694
4695 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304696}
4697
4698/**
4699 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4700 * @wmi: wmi handle
4701 * @adapter_1_chan_number: adapter 1 channel number
4702 * @adapter_1_quota: adapter 1 quota
4703 * @adapter_2_chan_number: adapter 2 channel number
4704 *
4705 * Return: CDF status
4706 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304707static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304708 uint32_t adapter_1_chan_freq,
4709 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4710{
Govind Singh67922e82016-04-01 16:48:57 +05304711 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304712 wmi_buf_t buf = 0;
4713 uint16_t len = 0;
4714 uint8_t *buf_ptr = NULL;
4715 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4716 wmi_resmgr_chan_time_quota chan_quota;
4717 uint32_t quota_chan1 = adapter_1_quota;
4718 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4719 uint32_t quota_chan2 = 100 - quota_chan1;
4720 /* Note: setting time quota for MCC requires info for 2 channels */
4721 uint32_t num_channels = 2;
4722 uint32_t chan1_freq = adapter_1_chan_freq;
4723 uint32_t chan2_freq = adapter_2_chan_freq;
4724
Govind Singhb53420c2016-03-09 14:32:57 +05304725 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304726 "freq2:%dMHz, Quota2:%dms", __func__,
4727 chan1_freq, quota_chan1, chan2_freq,
4728 quota_chan2);
4729
4730 /*
4731 * Perform sanity check on time quota values provided.
4732 */
4733 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4734 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304735 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304736 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304737 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304738 }
4739 /* Set WMI CMD for channel time quota here */
4740 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4741 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4742 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4743 buf = wmi_buf_alloc(wmi_handle, len);
4744 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304745 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4746 QDF_ASSERT(0);
4747 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304748 }
4749 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4750 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4751 wmi_buf_data(buf);
4752 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4753 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4754 WMITLV_GET_STRUCT_TLVLEN
4755 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4756 cmdTQ->num_chans = num_channels;
4757
4758 /* Update channel time quota information for home channel(s) */
4759 buf_ptr += sizeof(*cmdTQ);
4760 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4761 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4762 buf_ptr += WMI_TLV_HDR_SIZE;
4763 chan_quota.chan_mhz = chan1_freq;
4764 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304765 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304766 /* Construct channel and quota record for the 2nd MCC mode. */
4767 buf_ptr += sizeof(chan_quota);
4768 chan_quota.chan_mhz = chan2_freq;
4769 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304770 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304771
4772 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4773 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304774 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304775 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304776 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304777 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304778 }
Govind Singh67922e82016-04-01 16:48:57 +05304779
4780 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304781}
4782
4783/**
4784 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4785 * @wmi_handle: Pointer to wmi handle
4786 * @thermal_info: Thermal command information
4787 *
4788 * This function sends the thermal management command
4789 * to the firmware
4790 *
Govind Singhb53420c2016-03-09 14:32:57 +05304791 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304792 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304793static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304794 struct thermal_cmd_params *thermal_info)
4795{
4796 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4797 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304798 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304799 uint32_t len = 0;
4800
4801 len = sizeof(*cmd);
4802
4803 buf = wmi_buf_alloc(wmi_handle, len);
4804 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304805 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4806 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304807 }
4808
4809 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4810
4811 WMITLV_SET_HDR(&cmd->tlv_header,
4812 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4813 WMITLV_GET_STRUCT_TLVLEN
4814 (wmi_thermal_mgmt_cmd_fixed_param));
4815
4816 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4817 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4818 cmd->enable = thermal_info->thermal_enable;
4819
Govind Singhb53420c2016-03-09 14:32:57 +05304820 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304821 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4822
4823 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4824 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304825 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304826 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304827 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304828 }
4829
Govind Singh67922e82016-04-01 16:48:57 +05304830 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304831}
4832
4833
4834/**
4835 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304836 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304837 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4838 *
4839 * This function sends down the LRO configuration parameters to
4840 * the firmware to enable LRO, sets the TCP flags and sets the
4841 * seed values for the toeplitz hash generation
4842 *
Govind Singhb53420c2016-03-09 14:32:57 +05304843 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304844 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304845static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304846 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4847{
4848 wmi_lro_info_cmd_fixed_param *cmd;
4849 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304850 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304851
4852
4853 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4854 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304855 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4856 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304857 }
4858
4859 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4860
4861 WMITLV_SET_HDR(&cmd->tlv_header,
4862 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4863 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4864
4865 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4866 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4867 wmi_lro_cmd->tcp_flag);
4868 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4869 wmi_lro_cmd->tcp_flag_mask);
4870 cmd->toeplitz_hash_ipv4_0_3 =
4871 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4872 cmd->toeplitz_hash_ipv4_4_7 =
4873 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4874 cmd->toeplitz_hash_ipv4_8_11 =
4875 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4876 cmd->toeplitz_hash_ipv4_12_15 =
4877 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4878 cmd->toeplitz_hash_ipv4_16 =
4879 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4880
4881 cmd->toeplitz_hash_ipv6_0_3 =
4882 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4883 cmd->toeplitz_hash_ipv6_4_7 =
4884 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4885 cmd->toeplitz_hash_ipv6_8_11 =
4886 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4887 cmd->toeplitz_hash_ipv6_12_15 =
4888 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4889 cmd->toeplitz_hash_ipv6_16_19 =
4890 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4891 cmd->toeplitz_hash_ipv6_20_23 =
4892 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4893 cmd->toeplitz_hash_ipv6_24_27 =
4894 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4895 cmd->toeplitz_hash_ipv6_28_31 =
4896 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4897 cmd->toeplitz_hash_ipv6_32_35 =
4898 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4899 cmd->toeplitz_hash_ipv6_36_39 =
4900 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4901 cmd->toeplitz_hash_ipv6_40 =
4902 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4903
Govind Singhb53420c2016-03-09 14:32:57 +05304904 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304905 cmd->lro_enable, cmd->tcp_flag_u32);
4906
4907 status = wmi_unified_cmd_send(wmi_handle, buf,
4908 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304909 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304910 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304911 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304912 }
4913
Govind Singh67922e82016-04-01 16:48:57 +05304914 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304915}
4916
Govind Singh4eacd2b2016-03-07 14:24:22 +05304917/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304918 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4919 * @wmi_handle: Pointer to wmi handle
4920 * @rate_report_params: Pointer to peer rate report parameters
4921 *
4922 *
4923 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4924 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304925static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304926 struct wmi_peer_rate_report_params *rate_report_params)
4927{
4928 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4929 wmi_buf_t buf = NULL;
4930 QDF_STATUS status = 0;
4931 uint32_t len = 0;
4932 uint32_t i, j;
4933
4934 len = sizeof(*cmd);
4935
4936 buf = wmi_buf_alloc(wmi_handle, len);
4937 if (!buf) {
4938 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4939 return QDF_STATUS_E_FAILURE;
4940 }
4941
4942 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4943 wmi_buf_data(buf);
4944
4945 WMITLV_SET_HDR(
4946 &cmd->tlv_header,
4947 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4948 WMITLV_GET_STRUCT_TLVLEN(
4949 wmi_peer_set_rate_report_condition_fixed_param));
4950
4951 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4952 cmd->report_backoff_time = rate_report_params->backoff_time;
4953 cmd->report_timer_period = rate_report_params->timer_period;
4954 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4955 cmd->cond_per_phy[i].val_cond_flags =
4956 rate_report_params->report_per_phy[i].cond_flags;
4957 cmd->cond_per_phy[i].rate_delta.min_delta =
4958 rate_report_params->report_per_phy[i].delta.delta_min;
4959 cmd->cond_per_phy[i].rate_delta.percentage =
4960 rate_report_params->report_per_phy[i].delta.percent;
4961 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4962 cmd->cond_per_phy[i].rate_threshold[j] =
4963 rate_report_params->report_per_phy[i].
4964 report_rate_threshold[j];
4965 }
4966 }
4967
4968 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4969 cmd->enable_rate_report,
4970 cmd->report_backoff_time, cmd->report_timer_period);
4971
4972 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4973 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4974 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304975 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304976 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4977 __func__);
4978 }
4979 return status;
4980}
4981
4982/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304983 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4984 * @wmi_handle: wmi handle
4985 * @param: bcn ll cmd parameter
4986 *
Govind Singhb53420c2016-03-09 14:32:57 +05304987 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304988 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304989static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304990 wmi_bcn_send_from_host_cmd_fixed_param *param)
4991{
4992 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4993 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304994 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304995
4996 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4997 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304998 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4999 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305000 }
5001
5002 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
5003 WMITLV_SET_HDR(&cmd->tlv_header,
5004 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
5005 WMITLV_GET_STRUCT_TLVLEN
5006 (wmi_bcn_send_from_host_cmd_fixed_param));
5007 cmd->vdev_id = param->vdev_id;
5008 cmd->data_len = param->data_len;
5009 cmd->frame_ctrl = param->frame_ctrl;
5010 cmd->frag_ptr = param->frag_ptr;
5011 cmd->dtim_flag = param->dtim_flag;
5012
5013 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
5014 WMI_PDEV_SEND_BCN_CMDID);
5015
Govind Singh67922e82016-04-01 16:48:57 +05305016 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305017 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305018 wmi_buf_free(wmi_buf);
5019 }
5020
5021 return ret;
5022}
5023
5024/**
5025 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
5026 * @wmi_handle: wmi handle
5027 * @vdev_id: vdev id
5028 * @max_retries: max retries
5029 * @retry_interval: retry interval
5030 * This function sets sta query related parameters in fw.
5031 *
Govind Singhb53420c2016-03-09 14:32:57 +05305032 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305033 */
5034
Sathish Kumarfd347372017-02-13 12:29:09 +05305035static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305036 uint8_t vdev_id, uint32_t max_retries,
5037 uint32_t retry_interval)
5038{
5039 wmi_buf_t buf;
5040 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5041 int len;
5042
5043 len = sizeof(*cmd);
5044 buf = wmi_buf_alloc(wmi_handle, len);
5045 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305046 WMI_LOGE(FL("wmi_buf_alloc failed"));
5047 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305048 }
5049
5050 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5051 WMITLV_SET_HDR(&cmd->tlv_header,
5052 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5053 WMITLV_GET_STRUCT_TLVLEN
5054 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5055
5056
5057 cmd->vdev_id = vdev_id;
5058 cmd->sa_query_max_retry_count = max_retries;
5059 cmd->sa_query_retry_interval = retry_interval;
5060
Govind Singhb53420c2016-03-09 14:32:57 +05305061 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305062 vdev_id, retry_interval, max_retries);
5063
5064 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5065 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305066 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305067 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305068 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305069 }
5070
Govind Singhb53420c2016-03-09 14:32:57 +05305071 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305072 return 0;
5073}
5074
5075/**
5076 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5077 * @wmi_handle: wmi handle
5078 * @params: sta keep alive parameter
5079 *
5080 * This function sets keep alive related parameters in fw.
5081 *
5082 * Return: CDF status
5083 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305084static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305085 struct sta_params *params)
5086{
5087 wmi_buf_t buf;
5088 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5089 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5090 uint8_t *buf_ptr;
5091 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305092 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305093
Govind Singhb53420c2016-03-09 14:32:57 +05305094 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305095
Govind Singh4eacd2b2016-03-07 14:24:22 +05305096 len = sizeof(*cmd) + sizeof(*arp_rsp);
5097 buf = wmi_buf_alloc(wmi_handle, len);
5098 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305099 WMI_LOGE("wmi_buf_alloc failed");
5100 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305101 }
5102
5103 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5104 buf_ptr = (uint8_t *) cmd;
5105 WMITLV_SET_HDR(&cmd->tlv_header,
5106 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5107 WMITLV_GET_STRUCT_TLVLEN
5108 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5109 cmd->interval = params->timeperiod;
5110 cmd->enable = (params->timeperiod) ? 1 : 0;
5111 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305112 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305113 params->timeperiod, params->method);
5114 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5115 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5116 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5117 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5118
c_manjee2772b9c2017-01-23 15:14:13 +05305119 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5120 (params->method ==
5121 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305122 if ((NULL == params->hostv4addr) ||
5123 (NULL == params->destv4addr) ||
5124 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005125 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5126 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305127 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305128 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305129 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305130 }
c_manjee2772b9c2017-01-23 15:14:13 +05305131 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305132 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305133 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305134 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305135 WMI_IPV4_ADDR_LEN);
5136 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5137 } else {
5138 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5139 }
5140
Govind Singh67922e82016-04-01 16:48:57 +05305141 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5142 WMI_STA_KEEPALIVE_CMDID);
5143 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305144 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305145 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305146 }
5147
Govind Singhb53420c2016-03-09 14:32:57 +05305148 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305149 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305150}
5151
5152/**
5153 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5154 * @wmi_handle: wmi handle
5155 * @if_id: vdev id
5156 * @gtx_info: GTX config params
5157 *
5158 * This function set GTX related params in firmware.
5159 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305160 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305161 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305162static 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 +05305163 struct wmi_gtx_config *gtx_info)
5164{
5165 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5166 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305167 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305168 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305169
Govind Singh4eacd2b2016-03-07 14:24:22 +05305170 buf = wmi_buf_alloc(wmi_handle, len);
5171 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305172 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305173 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305174 }
5175 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5176 WMITLV_SET_HDR(&cmd->tlv_header,
5177 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5178 WMITLV_GET_STRUCT_TLVLEN
5179 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5180 cmd->vdev_id = if_id;
5181
5182 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5183 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5184 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5185 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5186 cmd->gtxPERMargin = gtx_info->gtx_margin;
5187 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5188 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5189 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5190
Govind Singhb53420c2016-03-09 14:32:57 +05305191 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305192 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5193 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5194 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5195 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5196
Abhishek Singh716c46c2016-05-04 16:24:07 +05305197 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305198 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305199 if (QDF_IS_STATUS_ERROR(ret)) {
5200 WMI_LOGE("Failed to set GTX PARAMS");
5201 wmi_buf_free(buf);
5202 }
5203 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305204}
5205
5206/**
5207 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5208 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305209 * @vdev_id: vdev id.
5210 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305211 *
5212 * This function updates EDCA parameters to the target
5213 *
5214 * Return: CDF Status
5215 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305216static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305217 uint8_t vdev_id,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305218 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305219{
5220 uint8_t *buf_ptr;
5221 wmi_buf_t buf;
5222 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305223 wmi_wmm_vparams *wmm_param;
5224 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305225 int len = sizeof(*cmd);
5226 int ac;
5227
5228 buf = wmi_buf_alloc(wmi_handle, len);
5229
5230 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305231 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5232 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305233 }
5234
5235 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5236 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5237 WMITLV_SET_HDR(&cmd->tlv_header,
5238 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5239 WMITLV_GET_STRUCT_TLVLEN
5240 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5241 cmd->vdev_id = vdev_id;
5242
5243 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5244 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305245 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305246 WMITLV_SET_HDR(&wmm_param->tlv_header,
5247 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5248 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5249 wmm_param->cwmin = twmm_param->cwmin;
5250 wmm_param->cwmax = twmm_param->cwmax;
5251 wmm_param->aifs = twmm_param->aifs;
5252 wmm_param->txoplimit = twmm_param->txoplimit;
5253 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305254 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305255 }
5256
5257 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5258 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5259 goto fail;
5260
Govind Singhb53420c2016-03-09 14:32:57 +05305261 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305262
5263fail:
5264 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305265 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5266 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305267}
5268
5269/**
5270 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5271 * @wmi_handle: wmi handle
5272 * @vdev_id: vdev id
5273 * @probe_rsp_info: probe response info
5274 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305275 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305276 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305277static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305278 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005279 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305280{
5281 wmi_prb_tmpl_cmd_fixed_param *cmd;
5282 wmi_bcn_prb_info *bcn_prb_info;
5283 wmi_buf_t wmi_buf;
5284 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5285 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305286 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305287
Govind Singhb53420c2016-03-09 14:32:57 +05305288 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305289
Krunal Soni89426862017-11-14 15:42:48 -08005290 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305291 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
5292
5293 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5294 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5295 tmpl_len_aligned;
5296
5297 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305298 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305299 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305300 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305301 }
5302
5303 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5304 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305305 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305306 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305307 }
5308
5309 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5310
5311 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5312 WMITLV_SET_HDR(&cmd->tlv_header,
5313 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5314 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5315 cmd->vdev_id = vdev_id;
5316 cmd->buf_len = tmpl_len;
5317 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5318
5319 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5320 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5321 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5322 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5323 bcn_prb_info->caps = 0;
5324 bcn_prb_info->erp = 0;
5325 buf_ptr += sizeof(wmi_bcn_prb_info);
5326
5327 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5328 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005329 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305330
5331 ret = wmi_unified_cmd_send(wmi_handle,
5332 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305333 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305334 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305335 wmi_buf_free(wmi_buf);
5336 }
5337
5338 return ret;
5339}
5340
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305341#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305342#define WPI_IV_LEN 16
5343
5344/**
5345 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5346 *
5347 * @dest_tx: destination address of tsc key counter
5348 * @src_tx: source address of tsc key counter
5349 * @dest_rx: destination address of rsc key counter
5350 * @src_rx: source address of rsc key counter
5351 *
5352 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5353 *
5354 * Return: None
5355 *
5356 */
5357static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5358 uint8_t *dest_rx, uint8_t *src_rx)
5359{
5360 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5361 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5362}
5363#else
5364static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5365 uint8_t *dest_rx, uint8_t *src_rx)
5366{
5367 return;
5368}
5369#endif
5370
5371/**
5372 * send_setup_install_key_cmd_tlv() - set key parameters
5373 * @wmi_handle: wmi handle
5374 * @key_params: key parameters
5375 *
5376 * This function fills structure from information
5377 * passed in key_params.
5378 *
5379 * Return: QDF_STATUS_SUCCESS - success
5380 * QDF_STATUS_E_FAILURE - failure
5381 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5382 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305383static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305384 struct set_key_params *key_params)
5385{
5386 wmi_vdev_install_key_cmd_fixed_param *cmd;
5387 wmi_buf_t buf;
5388 uint8_t *buf_ptr;
5389 uint32_t len;
5390 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305391 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305392
5393 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5394 WMI_TLV_HDR_SIZE;
5395
5396 buf = wmi_buf_alloc(wmi_handle, len);
5397 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305398 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305399 return QDF_STATUS_E_NOMEM;
5400 }
5401
5402 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5403 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5404 WMITLV_SET_HDR(&cmd->tlv_header,
5405 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5406 WMITLV_GET_STRUCT_TLVLEN
5407 (wmi_vdev_install_key_cmd_fixed_param));
5408 cmd->vdev_id = key_params->vdev_id;
5409 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305410
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305411
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305412 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5413 cmd->key_flags |= key_params->key_flags;
5414 cmd->key_cipher = key_params->key_cipher;
5415 if ((key_params->key_txmic_len) &&
5416 (key_params->key_rxmic_len)) {
5417 cmd->key_txmic_len = key_params->key_txmic_len;
5418 cmd->key_rxmic_len = key_params->key_rxmic_len;
5419 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305420#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305421 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5422 key_params->tx_iv,
5423 cmd->wpi_key_rsc_counter,
5424 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305425#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305426 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5427 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5428 roundup(key_params->key_len, sizeof(uint32_t)));
5429 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
5430 qdf_mem_copy((void *)key_data,
5431 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005432 if (key_params->key_rsc_counter)
5433 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5434 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305435 cmd->key_len = key_params->key_len;
5436
5437 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5438 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305439 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305440 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305441
Govind Singh67922e82016-04-01 16:48:57 +05305442 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305443}
5444
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305445/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005446 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5447 * @wmi_handle: wmi handle
5448 * @params: sar limit params
5449 *
5450 * Return: QDF_STATUS_SUCCESS for success or error code
5451 */
5452static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5453 struct sar_limit_cmd_params *sar_limit_params)
5454{
5455 wmi_buf_t buf;
5456 QDF_STATUS qdf_status;
5457 wmi_sar_limits_cmd_fixed_param *cmd;
5458 int i;
5459 uint8_t *buf_ptr;
5460 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5461 struct sar_limit_cmd_row *sar_rows_list;
5462 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5463
5464 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5465 buf = wmi_buf_alloc(wmi_handle, len);
5466 if (!buf) {
5467 WMI_LOGE("Failed to allocate memory");
5468 qdf_status = QDF_STATUS_E_NOMEM;
5469 goto end;
5470 }
5471
5472 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5473 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5474 WMITLV_SET_HDR(&cmd->tlv_header,
5475 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5476 WMITLV_GET_STRUCT_TLVLEN
5477 (wmi_sar_limits_cmd_fixed_param));
5478 cmd->sar_enable = sar_limit_params->sar_enable;
5479 cmd->commit_limits = sar_limit_params->commit_limits;
5480 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5481
5482 WMI_LOGD("no of sar rows = %d, len = %d",
5483 sar_limit_params->num_limit_rows, len);
5484 buf_ptr += sizeof(*cmd);
5485 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5486 sizeof(wmi_sar_limit_cmd_row) *
5487 sar_limit_params->num_limit_rows);
5488 if (cmd->num_limit_rows == 0)
5489 goto send_sar_limits;
5490
5491 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5492 (buf_ptr + WMI_TLV_HDR_SIZE);
5493 sar_rows_list = sar_limit_params->sar_limit_row_list;
5494
5495 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5496 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5497 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5498 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5499 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5500 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5501 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5502 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5503 wmi_sar_rows_list->validity_bitmap =
5504 sar_rows_list->validity_bitmap;
5505 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5506 i, wmi_sar_rows_list->band_id,
5507 wmi_sar_rows_list->chain_id,
5508 wmi_sar_rows_list->mod_id,
5509 wmi_sar_rows_list->limit_value,
5510 wmi_sar_rows_list->validity_bitmap);
5511 sar_rows_list++;
5512 wmi_sar_rows_list++;
5513 }
5514send_sar_limits:
5515 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5516 WMI_SAR_LIMITS_CMDID);
5517
5518 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5519 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5520 wmi_buf_free(buf);
5521 }
5522
5523end:
5524 return qdf_status;
5525}
5526
Jeff Johnson4783f902017-12-14 15:50:16 -08005527static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5528{
5529 wmi_sar_get_limits_cmd_fixed_param *cmd;
5530 wmi_buf_t wmi_buf;
5531 uint32_t len;
5532 QDF_STATUS status;
5533
5534 WMI_LOGD(FL("Enter"));
5535
5536 len = sizeof(*cmd);
5537 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5538 if (!wmi_buf) {
5539 WMI_LOGP(FL("failed to allocate memory for msg"));
5540 return QDF_STATUS_E_NOMEM;
5541 }
5542
5543 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5544
5545 WMITLV_SET_HDR(&cmd->tlv_header,
5546 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5547 WMITLV_GET_STRUCT_TLVLEN
5548 (wmi_sar_get_limits_cmd_fixed_param));
5549
5550 cmd->reserved = 0;
5551
5552 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5553 WMI_SAR_GET_LIMITS_CMDID);
5554 if (QDF_IS_STATUS_ERROR(status)) {
5555 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5556 wmi_buf_free(wmi_buf);
5557 }
5558
5559 WMI_LOGD(FL("Exit"));
5560
5561 return status;
5562}
5563
5564static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5565 uint8_t *evt_buf,
5566 struct sar_limit_event *event)
5567{
5568 wmi_sar_get_limits_event_fixed_param *fixed_param;
5569 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5570 wmi_sar_get_limit_event_row *row_in;
5571 struct sar_limit_event_row *row_out;
5572 uint32_t row;
5573
5574 if (!evt_buf) {
5575 WMI_LOGE(FL("input event is NULL"));
5576 return QDF_STATUS_E_INVAL;
5577 }
5578 if (!event) {
5579 WMI_LOGE(FL("output event is NULL"));
5580 return QDF_STATUS_E_INVAL;
5581 }
5582
5583 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5584
5585 fixed_param = param_buf->fixed_param;
5586 if (!fixed_param) {
5587 WMI_LOGE(FL("Invalid fixed param"));
5588 return QDF_STATUS_E_INVAL;
5589 }
5590
5591 event->sar_enable = fixed_param->sar_enable;
5592 event->num_limit_rows = fixed_param->num_limit_rows;
5593
5594 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5595 QDF_ASSERT(0);
5596 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5597 event->num_limit_rows,
5598 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5599 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5600 }
5601
5602 row_in = param_buf->sar_get_limits;
5603 row_out = &event->sar_limit_row[0];
5604 for (row = 0; row < event->num_limit_rows; row++) {
5605 row_out->band_id = row_in->band_id;
5606 row_out->chain_id = row_in->chain_id;
5607 row_out->mod_id = row_in->mod_id;
5608 row_out->limit_value = row_in->limit_value;
5609 row_out++;
5610 row_in++;
5611 }
5612
5613 return QDF_STATUS_SUCCESS;
5614}
5615
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305616#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005617/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305618 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5619 * @wmi_handle: wmi handle
5620 * @params: encrypt/decrypt params
5621 *
5622 * Return: QDF_STATUS_SUCCESS for success or error code
5623 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005624static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305625QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305626 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305627{
5628 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5629 wmi_buf_t wmi_buf;
5630 uint8_t *buf_ptr;
5631 QDF_STATUS ret;
5632 uint32_t len;
5633
5634 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5635
5636 len = sizeof(*cmd) +
5637 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
5638 WMI_TLV_HDR_SIZE;
5639 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5640 if (!wmi_buf) {
5641 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5642 __func__);
5643 return QDF_STATUS_E_NOMEM;
5644 }
5645
5646 buf_ptr = wmi_buf_data(wmi_buf);
5647 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5648
5649 WMITLV_SET_HDR(&cmd->tlv_header,
5650 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5651 WMITLV_GET_STRUCT_TLVLEN(
5652 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5653
5654 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5655 cmd->key_flag = encrypt_decrypt_params->key_flag;
5656 cmd->key_idx = encrypt_decrypt_params->key_idx;
5657 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5658 cmd->key_len = encrypt_decrypt_params->key_len;
5659 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5660 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5661
5662 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5663 encrypt_decrypt_params->key_len);
5664
5665 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5666 MAX_MAC_HEADER_LEN);
5667
5668 cmd->data_len = encrypt_decrypt_params->data_len;
5669
5670 if (cmd->data_len) {
5671 buf_ptr += sizeof(*cmd);
5672 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5673 roundup(encrypt_decrypt_params->data_len,
5674 sizeof(A_UINT32)));
5675 buf_ptr += WMI_TLV_HDR_SIZE;
5676 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5677 encrypt_decrypt_params->data_len);
5678 }
5679
5680 /* This conversion is to facilitate data to FW in little endian */
5681 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5682 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5683 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5684 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5685 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5686 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5687
5688 ret = wmi_unified_cmd_send(wmi_handle,
5689 wmi_buf, len,
5690 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5691 if (QDF_IS_STATUS_ERROR(ret)) {
5692 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5693 wmi_buf_free(wmi_buf);
5694 }
5695
5696 return ret;
5697}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305698
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305699/**
5700 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5701 * params from event
5702 * @wmi_handle: wmi handle
5703 * @evt_buf: pointer to event buffer
5704 * @resp: Pointer to hold resp parameters
5705 *
5706 * Return: QDF_STATUS_SUCCESS for success or error code
5707 */
5708static
5709QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5710 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5711{
5712 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5713 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5714
5715 param_buf = evt_buf;
5716 if (!param_buf) {
5717 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5718 return QDF_STATUS_E_INVAL;
5719 }
5720
5721 data_event = param_buf->fixed_param;
5722
5723 resp->vdev_id = data_event->vdev_id;
5724 resp->status = data_event->status;
5725
5726 if (data_event->data_length > param_buf->num_enc80211_frame) {
5727 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5728 data_event->data_length,
5729 param_buf->num_enc80211_frame);
5730 return QDF_STATUS_E_INVAL;
5731 }
5732
5733 resp->data_len = data_event->data_length;
5734
5735 if (resp->data_len)
5736 resp->data = (uint8_t *)param_buf->enc80211_frame;
5737
5738 return QDF_STATUS_SUCCESS;
5739}
5740#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305741
Govind Singh4eacd2b2016-03-07 14:24:22 +05305742/**
5743 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5744 * @wmi_handle: wmi handle
5745 * @vdev_id: vdev id
5746 * @p2p_ie: p2p IE
5747 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305748 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305749 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305750static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305751 A_UINT32 vdev_id, uint8_t *p2p_ie)
5752{
Govind Singh67922e82016-04-01 16:48:57 +05305753 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305754 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5755 wmi_buf_t wmi_buf;
5756 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5757 uint8_t *buf_ptr;
5758
5759 ie_len = (uint32_t) (p2p_ie[1] + 2);
5760
5761 /* More than one P2P IE may be included in a single frame.
5762 If multiple P2P IEs are present, the complete P2P attribute
5763 data consists of the concatenation of the P2P Attribute
5764 fields of the P2P IEs. The P2P Attributes field of each
5765 P2P IE may be any length up to the maximum (251 octets).
5766 In this case host sends one P2P IE to firmware so the length
5767 should not exceed more than 251 bytes
5768 */
5769 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305770 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305771 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305772 }
5773
5774 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
5775
5776 wmi_buf_len =
5777 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5778 WMI_TLV_HDR_SIZE;
5779
5780 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5781 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305782 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305783 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305784 }
5785
5786 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5787
5788 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5789 WMITLV_SET_HDR(&cmd->tlv_header,
5790 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5791 WMITLV_GET_STRUCT_TLVLEN
5792 (wmi_p2p_go_set_beacon_ie_fixed_param));
5793 cmd->vdev_id = vdev_id;
5794 cmd->ie_buf_len = ie_len;
5795
5796 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5797 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5798 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305799 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305800
Govind Singhb53420c2016-03-09 14:32:57 +05305801 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305802
5803 ret = wmi_unified_cmd_send(wmi_handle,
5804 wmi_buf, wmi_buf_len,
5805 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305806 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305807 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305808 wmi_buf_free(wmi_buf);
5809 }
5810
Govind Singhb53420c2016-03-09 14:32:57 +05305811 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305812 return ret;
5813}
5814
5815/**
5816 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5817 * @wmi_handle: wmi handle
5818 * @req: gateway parameter update request structure
5819 *
5820 * This function reads the incoming @req and fill in the destination
5821 * WMI structure and sends down the gateway configs down to the firmware
5822 *
Govind Singhb53420c2016-03-09 14:32:57 +05305823 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305824 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305825static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305826 struct gateway_update_req_param *req)
5827{
5828 wmi_roam_subnet_change_config_fixed_param *cmd;
5829 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305830 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305831 int len = sizeof(*cmd);
5832
5833 buf = wmi_buf_alloc(wmi_handle, len);
5834 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305835 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5836 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305837 }
5838
5839 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5840 WMITLV_SET_HDR(&cmd->tlv_header,
5841 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5842 WMITLV_GET_STRUCT_TLVLEN(
5843 wmi_roam_subnet_change_config_fixed_param));
5844
5845 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305846 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5847 QDF_IPV4_ADDR_SIZE);
5848 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5849 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305850 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5851 &cmd->inet_gw_mac_addr);
5852 cmd->max_retries = req->max_retries;
5853 cmd->timeout = req->timeout;
5854 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5855 cmd->flag = 0;
5856 if (req->ipv4_addr_type)
5857 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5858
5859 if (req->ipv6_addr_type)
5860 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5861
5862 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5863 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305864 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305865 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305866 ret);
5867 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305868 }
5869
Govind Singh67922e82016-04-01 16:48:57 +05305870 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305871}
5872
5873/**
5874 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5875 * @wmi_handle: wmi handle
5876 * @req: rssi monitoring request structure
5877 *
5878 * This function reads the incoming @req and fill in the destination
5879 * WMI structure and send down the rssi monitoring configs down to the firmware
5880 *
5881 * Return: 0 on success; error number otherwise
5882 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305883static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305884 struct rssi_monitor_param *req)
5885{
5886 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5887 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305888 QDF_STATUS ret;
5889 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305890
5891 buf = wmi_buf_alloc(wmi_handle, len);
5892 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305893 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5894 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305895 }
5896
5897 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5898 WMITLV_SET_HDR(&cmd->tlv_header,
5899 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5900 WMITLV_GET_STRUCT_TLVLEN(
5901 wmi_rssi_breach_monitor_config_fixed_param));
5902
5903 cmd->vdev_id = req->session_id;
5904 cmd->request_id = req->request_id;
5905 cmd->lo_rssi_reenable_hysteresis = 0;
5906 cmd->hi_rssi_reenable_histeresis = 0;
5907 cmd->min_report_interval = 0;
5908 cmd->max_num_report = 1;
5909 if (req->control) {
5910 /* enable one threshold for each min/max */
5911 cmd->enabled_bitmap = 0x09;
5912 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5913 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5914 } else {
5915 cmd->enabled_bitmap = 0;
5916 cmd->low_rssi_breach_threshold[0] = 0;
5917 cmd->hi_rssi_breach_threshold[0] = 0;
5918 }
5919
5920 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5921 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305922 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305923 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305924 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305925 }
5926
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005927 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5928
Govind Singh67922e82016-04-01 16:48:57 +05305929 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305930}
5931
5932/**
5933 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5934 * @wmi_handle: wmi handle
5935 * @psetoui: OUI parameters
5936 *
5937 * set scan probe OUI parameters in firmware
5938 *
5939 * Return: CDF status
5940 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305941static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305942 struct scan_mac_oui *psetoui)
5943{
5944 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5945 wmi_buf_t wmi_buf;
5946 uint32_t len;
5947 uint8_t *buf_ptr;
5948 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305949 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305950
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305951 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5952 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5953
Govind Singh4eacd2b2016-03-07 14:24:22 +05305954 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5955 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305956 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5957 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305958 }
5959 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5960 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5961 WMITLV_SET_HDR(&cmd->tlv_header,
5962 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5963 WMITLV_GET_STRUCT_TLVLEN
5964 (wmi_scan_prob_req_oui_cmd_fixed_param));
5965
5966 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305967 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305968 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5969 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305970 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305971 cmd->prob_req_oui);
5972
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305973 cmd->vdev_id = psetoui->vdev_id;
5974 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5975 if (psetoui->enb_probe_req_sno_randomization)
5976 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5977
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305978 if (ie_whitelist->white_list) {
5979 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5980 &cmd->num_vendor_oui,
5981 ie_whitelist);
5982 cmd->flags |=
5983 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5984 }
5985
5986 buf_ptr += sizeof(*cmd);
5987 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5988 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5989 buf_ptr += WMI_TLV_HDR_SIZE;
5990
5991 if (cmd->num_vendor_oui != 0) {
5992 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5993 ie_whitelist->voui);
5994 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5995 }
5996
Govind Singh4eacd2b2016-03-07 14:24:22 +05305997 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5998 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305999 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306000 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306001 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306002 }
Govind Singhb53420c2016-03-09 14:32:57 +05306003 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306004}
6005
6006/**
6007 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
6008 * @wmi_handle: wmi handle
6009 * @req: passpoint network request structure
6010 *
6011 * This function sends down WMI command with network id set to wildcard id.
6012 * firmware shall clear all the config entries
6013 *
Govind Singhb53420c2016-03-09 14:32:57 +05306014 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05306015 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306016static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306017 struct wifi_passpoint_req_param *req)
6018{
6019 wmi_passpoint_config_cmd_fixed_param *cmd;
6020 wmi_buf_t buf;
6021 uint32_t len;
6022 int ret;
6023
6024 len = sizeof(*cmd);
6025 buf = wmi_buf_alloc(wmi_handle, len);
6026 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306027 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6028 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306029 }
6030
6031 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
6032
6033 WMITLV_SET_HDR(&cmd->tlv_header,
6034 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
6035 WMITLV_GET_STRUCT_TLVLEN(
6036 wmi_passpoint_config_cmd_fixed_param));
6037 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
6038
6039 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6040 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6041 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306042 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306043 __func__);
6044 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306045 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306046 }
6047
Govind Singhb53420c2016-03-09 14:32:57 +05306048 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306049}
6050
6051/**
6052 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
6053 * @wmi_handle: wmi handle
6054 * @req: passpoint network request structure
6055 *
6056 * This function reads the incoming @req and fill in the destination
6057 * WMI structure and send down the passpoint configs down to the firmware
6058 *
Govind Singhb53420c2016-03-09 14:32:57 +05306059 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05306060 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306061static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306062 struct wifi_passpoint_req_param *req)
6063{
6064 wmi_passpoint_config_cmd_fixed_param *cmd;
6065 u_int8_t i, j, *bytes;
6066 wmi_buf_t buf;
6067 uint32_t len;
6068 int ret;
6069
6070 len = sizeof(*cmd);
6071 for (i = 0; i < req->num_networks; i++) {
6072 buf = wmi_buf_alloc(wmi_handle, len);
6073 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306074 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6075 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306076 }
6077
6078 cmd = (wmi_passpoint_config_cmd_fixed_param *)
6079 wmi_buf_data(buf);
6080
6081 WMITLV_SET_HDR(&cmd->tlv_header,
6082 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
6083 WMITLV_GET_STRUCT_TLVLEN(
6084 wmi_passpoint_config_cmd_fixed_param));
6085 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05306086 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
6087 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306088 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05306089 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306090 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
6091 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05306092 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306093 j, bytes[0], bytes[1], bytes[2], bytes[3],
6094 bytes[4], bytes[5], bytes[6], bytes[7]);
6095
Govind Singhb53420c2016-03-09 14:32:57 +05306096 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05306097 &req->networks[i].roaming_consortium_ids[j],
6098 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
6099 }
Govind Singhb53420c2016-03-09 14:32:57 +05306100 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306101 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05306102 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306103 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
6104
6105 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6106 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6107 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306108 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306109 __func__);
6110 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306111 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306112 }
6113 }
6114
Govind Singhb53420c2016-03-09 14:32:57 +05306115 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306116}
6117
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306118#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306119/**
6120 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6121 * @wmi_handle: wmi handle
6122 * @roam_req: Roam scan offload params
6123 * @buf_ptr: command buffer to send
6124 * @fils_tlv_len: fils tlv length
6125 *
6126 * Return: Updated buffer pointer
6127 */
6128static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6129 struct roam_offload_scan_params *roam_req,
6130 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6131{
6132 wmi_roam_fils_offload_tlv_param *fils_tlv;
6133 wmi_erp_info *erp_info;
6134 struct roam_fils_params *roam_fils_params;
6135
6136 if (!roam_req->add_fils_tlv)
6137 return buf_ptr;
6138
6139 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6140 sizeof(*fils_tlv));
6141 buf_ptr += WMI_TLV_HDR_SIZE;
6142
6143 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6144 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6145 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6146 WMITLV_GET_STRUCT_TLVLEN
6147 (wmi_roam_fils_offload_tlv_param));
6148
6149 roam_fils_params = &roam_req->roam_fils_params;
6150 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6151
6152 erp_info->username_length = roam_fils_params->username_length;
6153 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6154 erp_info->username_length);
6155
6156 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6157
6158 erp_info->rRk_length = roam_fils_params->rrk_length;
6159 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6160 erp_info->rRk_length);
6161
6162 erp_info->rIk_length = roam_fils_params->rik_length;
6163 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6164 erp_info->rIk_length);
6165
6166 erp_info->realm_len = roam_fils_params->realm_len;
6167 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6168 erp_info->realm_len);
6169
6170 buf_ptr += sizeof(*fils_tlv);
6171 return buf_ptr;
6172}
6173#else
6174static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6175 struct roam_offload_scan_params *roam_req,
6176 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6177{
6178 return buf_ptr;
6179}
6180#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306181/**
6182 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6183 * @wmi_handle: wmi handle
6184 * @scan_cmd_fp: start scan command ptr
6185 * @roam_req: roam request param
6186 *
6187 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6188 * of WMI_ROAM_SCAN_MODE.
6189 *
6190 * Return: QDF status
6191 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306192static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306193 wmi_start_scan_cmd_fixed_param *
6194 scan_cmd_fp,
6195 struct roam_offload_scan_params *roam_req)
6196{
6197 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306198 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306199 int len;
6200 uint8_t *buf_ptr;
6201 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306202
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306203#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6204 int auth_mode = roam_req->auth_mode;
6205 wmi_roam_offload_tlv_param *roam_offload_params;
6206 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6207 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6208 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306209 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306210 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306211#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6212 /* Need to create a buf with roam_scan command at
6213 * front and piggyback with scan command */
6214 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6215#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6216 (2 * WMI_TLV_HDR_SIZE) +
6217#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6218 sizeof(wmi_start_scan_cmd_fixed_param);
6219#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006220 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306221 if (roam_req->is_roam_req_valid &&
6222 roam_req->roam_offload_enabled) {
6223 len += sizeof(wmi_roam_offload_tlv_param);
6224 len += WMI_TLV_HDR_SIZE;
6225 if ((auth_mode != WMI_AUTH_NONE) &&
6226 ((auth_mode != WMI_AUTH_OPEN) ||
6227 (auth_mode == WMI_AUTH_OPEN &&
6228 roam_req->mdid.mdie_present) ||
6229 roam_req->is_ese_assoc)) {
6230 len += WMI_TLV_HDR_SIZE;
6231 if (roam_req->is_ese_assoc)
6232 len +=
6233 sizeof(wmi_roam_ese_offload_tlv_param);
6234 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6235 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6236 (auth_mode == WMI_AUTH_OPEN &&
6237 roam_req->mdid.mdie_present))
6238 len +=
6239 sizeof(wmi_roam_11r_offload_tlv_param);
6240 else
6241 len +=
6242 sizeof(wmi_roam_11i_offload_tlv_param);
6243 } else {
6244 len += WMI_TLV_HDR_SIZE;
6245 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306246
6247 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6248 + roundup(roam_req->assoc_ie_length,
6249 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306250
6251 if (roam_req->add_fils_tlv) {
6252 fils_tlv_len = sizeof(
6253 wmi_roam_fils_offload_tlv_param);
6254 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6255 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306256 } else {
6257 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306258 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306259 __func__, roam_req->roam_offload_enabled);
6260 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306261 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306262 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306263 }
6264 if (roam_req->is_roam_req_valid &&
6265 roam_req->roam_offload_enabled) {
6266 roam_req->mode = roam_req->mode |
6267 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6268 }
6269#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6270
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306271 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6272 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6273 len = sizeof(wmi_roam_scan_mode_fixed_param);
6274
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306275 buf = wmi_buf_alloc(wmi_handle, len);
6276 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306277 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306278 return QDF_STATUS_E_NOMEM;
6279 }
6280
6281 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6282 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6283 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6284 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6285 WMITLV_GET_STRUCT_TLVLEN
6286 (wmi_roam_scan_mode_fixed_param));
6287
6288 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6289 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306290 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6291 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6292 roam_scan_mode_fp->flags |=
6293 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306294 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306295 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306296
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306297 /* Fill in scan parameters suitable for roaming scan */
6298 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306299
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306300 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6301 sizeof(wmi_start_scan_cmd_fixed_param));
6302 /* Ensure there is no additional IEs */
6303 scan_cmd_fp->ie_len = 0;
6304 WMITLV_SET_HDR(buf_ptr,
6305 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6306 WMITLV_GET_STRUCT_TLVLEN
6307 (wmi_start_scan_cmd_fixed_param));
6308#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6309 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6310 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6311 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6312 sizeof(wmi_roam_offload_tlv_param));
6313 buf_ptr += WMI_TLV_HDR_SIZE;
6314 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6315 WMITLV_SET_HDR(buf_ptr,
6316 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6317 WMITLV_GET_STRUCT_TLVLEN
6318 (wmi_roam_offload_tlv_param));
6319 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6320 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6321 roam_offload_params->select_5g_margin =
6322 roam_req->select_5ghz_margin;
6323 roam_offload_params->reassoc_failure_timeout =
6324 roam_req->reassoc_failure_timeout;
6325
6326 /* Fill the capabilities */
6327 roam_offload_params->capability =
6328 roam_req->roam_offload_params.capability;
6329 roam_offload_params->ht_caps_info =
6330 roam_req->roam_offload_params.ht_caps_info;
6331 roam_offload_params->ampdu_param =
6332 roam_req->roam_offload_params.ampdu_param;
6333 roam_offload_params->ht_ext_cap =
6334 roam_req->roam_offload_params.ht_ext_cap;
6335 roam_offload_params->ht_txbf =
6336 roam_req->roam_offload_params.ht_txbf;
6337 roam_offload_params->asel_cap =
6338 roam_req->roam_offload_params.asel_cap;
6339 roam_offload_params->qos_caps =
6340 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006341 roam_offload_params->qos_enabled =
6342 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306343 roam_offload_params->wmm_caps =
6344 roam_req->roam_offload_params.wmm_caps;
6345 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6346 (uint8_t *)roam_req->roam_offload_params.mcsset,
6347 ROAM_OFFLOAD_NUM_MCS_SET);
6348
6349 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6350 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6351 * they are filled in the same order.Depending on the
6352 * authentication type, the other mode TLV's are nullified
6353 * and only headers are filled.*/
6354 if ((auth_mode != WMI_AUTH_NONE) &&
6355 ((auth_mode != WMI_AUTH_OPEN) ||
6356 (auth_mode == WMI_AUTH_OPEN
6357 && roam_req->mdid.mdie_present) ||
6358 roam_req->is_ese_assoc)) {
6359 if (roam_req->is_ese_assoc) {
6360 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6361 WMITLV_GET_STRUCT_TLVLEN(0));
6362 buf_ptr += WMI_TLV_HDR_SIZE;
6363 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6364 WMITLV_GET_STRUCT_TLVLEN(0));
6365 buf_ptr += WMI_TLV_HDR_SIZE;
6366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6367 sizeof(wmi_roam_ese_offload_tlv_param));
6368 buf_ptr += WMI_TLV_HDR_SIZE;
6369 roam_offload_ese =
6370 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6371 qdf_mem_copy(roam_offload_ese->krk,
6372 roam_req->krk,
6373 sizeof(roam_req->krk));
6374 qdf_mem_copy(roam_offload_ese->btk,
6375 roam_req->btk,
6376 sizeof(roam_req->btk));
6377 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6378 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6379 WMITLV_GET_STRUCT_TLVLEN
6380 (wmi_roam_ese_offload_tlv_param));
6381 buf_ptr +=
6382 sizeof(wmi_roam_ese_offload_tlv_param);
6383 } else if (auth_mode == WMI_AUTH_FT_RSNA
6384 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6385 || (auth_mode == WMI_AUTH_OPEN
6386 && roam_req->mdid.mdie_present)) {
6387 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6388 0);
6389 buf_ptr += WMI_TLV_HDR_SIZE;
6390 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6391 sizeof(wmi_roam_11r_offload_tlv_param));
6392 buf_ptr += WMI_TLV_HDR_SIZE;
6393 roam_offload_11r =
6394 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6395 roam_offload_11r->r0kh_id_len =
6396 roam_req->rokh_id_length;
6397 qdf_mem_copy(roam_offload_11r->r0kh_id,
6398 roam_req->rokh_id,
6399 roam_offload_11r->r0kh_id_len);
6400 qdf_mem_copy(roam_offload_11r->psk_msk,
6401 roam_req->psk_pmk,
6402 sizeof(roam_req->psk_pmk));
6403 roam_offload_11r->psk_msk_len =
6404 roam_req->pmk_len;
6405 roam_offload_11r->mdie_present =
6406 roam_req->mdid.mdie_present;
6407 roam_offload_11r->mdid =
6408 roam_req->mdid.mobility_domain;
6409 if (auth_mode == WMI_AUTH_OPEN) {
6410 /* If FT-Open ensure pmk length
6411 and r0khid len are zero */
6412 roam_offload_11r->r0kh_id_len = 0;
6413 roam_offload_11r->psk_msk_len = 0;
6414 }
6415 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6416 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6417 WMITLV_GET_STRUCT_TLVLEN
6418 (wmi_roam_11r_offload_tlv_param));
6419 buf_ptr +=
6420 sizeof(wmi_roam_11r_offload_tlv_param);
6421 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6422 WMITLV_GET_STRUCT_TLVLEN(0));
6423 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006424 WMI_LOGD("psk_msk_len = %d",
6425 roam_offload_11r->psk_msk_len);
6426 if (roam_offload_11r->psk_msk_len)
6427 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6428 QDF_TRACE_LEVEL_DEBUG,
6429 roam_offload_11r->psk_msk,
6430 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306431 } else {
6432 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6433 sizeof(wmi_roam_11i_offload_tlv_param));
6434 buf_ptr += WMI_TLV_HDR_SIZE;
6435 roam_offload_11i =
6436 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006437
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006438 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006439 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306440 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6441 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006442 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306443 } else {
6444 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6445 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006446 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006447 }
6448 if (roam_req->roam_key_mgmt_offload_enabled &&
6449 roam_req->fw_pmksa_cache) {
6450 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6451 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006452 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006453 } else {
6454 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6455 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006456 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306457 }
6458
6459 qdf_mem_copy(roam_offload_11i->pmk,
6460 roam_req->psk_pmk,
6461 sizeof(roam_req->psk_pmk));
6462 roam_offload_11i->pmk_len = roam_req->pmk_len;
6463 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6464 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6465 WMITLV_GET_STRUCT_TLVLEN
6466 (wmi_roam_11i_offload_tlv_param));
6467 buf_ptr +=
6468 sizeof(wmi_roam_11i_offload_tlv_param);
6469 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6470 0);
6471 buf_ptr += WMI_TLV_HDR_SIZE;
6472 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6473 0);
6474 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006475 WMI_LOGD("pmk_len = %d",
6476 roam_offload_11i->pmk_len);
6477 if (roam_offload_11i->pmk_len)
6478 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6479 QDF_TRACE_LEVEL_DEBUG,
6480 roam_offload_11i->pmk,
6481 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306482 }
6483 } else {
6484 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6485 WMITLV_GET_STRUCT_TLVLEN(0));
6486 buf_ptr += WMI_TLV_HDR_SIZE;
6487 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6488 WMITLV_GET_STRUCT_TLVLEN(0));
6489 buf_ptr += WMI_TLV_HDR_SIZE;
6490 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6491 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306492 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306493 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306494
6495 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6496 sizeof(*assoc_ies));
6497 buf_ptr += WMI_TLV_HDR_SIZE;
6498
6499 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6500 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6501 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6502 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6503 assoc_ies->buf_len = roam_req->assoc_ie_length;
6504
6505 buf_ptr += sizeof(*assoc_ies);
6506
6507 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6508 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6509 buf_ptr += WMI_TLV_HDR_SIZE;
6510
6511 if (assoc_ies->buf_len != 0) {
6512 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6513 assoc_ies->buf_len);
6514 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306515 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6516 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6517 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306518 } else {
6519 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6520 WMITLV_GET_STRUCT_TLVLEN(0));
6521 buf_ptr += WMI_TLV_HDR_SIZE;
6522 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6523 WMITLV_GET_STRUCT_TLVLEN(0));
6524 buf_ptr += WMI_TLV_HDR_SIZE;
6525 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6526 WMITLV_GET_STRUCT_TLVLEN(0));
6527 buf_ptr += WMI_TLV_HDR_SIZE;
6528 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6529 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306530 buf_ptr += WMI_TLV_HDR_SIZE;
6531 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6532 WMITLV_GET_STRUCT_TLVLEN(0));
6533 buf_ptr += WMI_TLV_HDR_SIZE;
6534 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6535 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306536 }
6537#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306538
6539send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306540 status = wmi_unified_cmd_send(wmi_handle, buf,
6541 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306542 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306543 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306544 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6545 status);
6546 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306547 }
6548
Govind Singh67922e82016-04-01 16:48:57 +05306549 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306550}
6551
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006552static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6553 struct wmi_mawc_roam_params *params)
6554{
6555 wmi_buf_t buf = NULL;
6556 QDF_STATUS status;
6557 int len;
6558 uint8_t *buf_ptr;
6559 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6560
6561 len = sizeof(*wmi_roam_mawc_params);
6562 buf = wmi_buf_alloc(wmi_handle, len);
6563 if (!buf) {
6564 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6565 return QDF_STATUS_E_NOMEM;
6566 }
6567
6568 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6569 wmi_roam_mawc_params =
6570 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6571 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6572 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6573 WMITLV_GET_STRUCT_TLVLEN
6574 (wmi_roam_configure_mawc_cmd_fixed_param));
6575 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6576 if (params->enable)
6577 wmi_roam_mawc_params->enable = 1;
6578 else
6579 wmi_roam_mawc_params->enable = 0;
6580 wmi_roam_mawc_params->traffic_load_threshold =
6581 params->traffic_load_threshold;
6582 wmi_roam_mawc_params->best_ap_rssi_threshold =
6583 params->best_ap_rssi_threshold;
6584 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6585 params->rssi_stationary_high_adjust;
6586 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6587 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006588 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6589 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6590 wmi_roam_mawc_params->traffic_load_threshold,
6591 wmi_roam_mawc_params->best_ap_rssi_threshold,
6592 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6593 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006594
6595 status = wmi_unified_cmd_send(wmi_handle, buf,
6596 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6597 if (QDF_IS_STATUS_ERROR(status)) {
6598 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6599 status);
6600 wmi_buf_free(buf);
6601 return status;
6602 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006603
6604 return QDF_STATUS_SUCCESS;
6605}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306606
6607/**
6608 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6609 * rssi threashold
6610 * @wmi_handle: wmi handle
6611 * @roam_req: Roaming request buffer
6612 *
6613 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6614 *
6615 * Return: QDF status
6616 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306617static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306618 struct roam_offload_scan_rssi_params *roam_req)
6619{
6620 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306621 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306622 int len;
6623 uint8_t *buf_ptr;
6624 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6625 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6626 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306627 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006628 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306629
6630 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6631 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6632 len += sizeof(wmi_roam_scan_extended_threshold_param);
6633 len += WMI_TLV_HDR_SIZE;
6634 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306635 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6636 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006637 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6638 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306639 buf = wmi_buf_alloc(wmi_handle, len);
6640 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306641 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306642 return QDF_STATUS_E_NOMEM;
6643 }
6644
6645 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6646 rssi_threshold_fp =
6647 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6648 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6649 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6650 WMITLV_GET_STRUCT_TLVLEN
6651 (wmi_roam_scan_rssi_threshold_fixed_param));
6652 /* fill in threshold values */
6653 rssi_threshold_fp->vdev_id = roam_req->session_id;
6654 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6655 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6656 rssi_threshold_fp->hirssi_scan_max_count =
6657 roam_req->hi_rssi_scan_max_count;
6658 rssi_threshold_fp->hirssi_scan_delta =
6659 roam_req->hi_rssi_scan_rssi_delta;
6660 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006661 rssi_threshold_fp->rssi_thresh_offset_5g =
6662 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306663
6664 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6665 WMITLV_SET_HDR(buf_ptr,
6666 WMITLV_TAG_ARRAY_STRUC,
6667 sizeof(wmi_roam_scan_extended_threshold_param));
6668 buf_ptr += WMI_TLV_HDR_SIZE;
6669 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6670
6671 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6672 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6673 ext_thresholds->boost_threshold_5g =
6674 roam_req->boost_threshold_5g;
6675
6676 ext_thresholds->boost_algorithm_5g =
6677 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6678 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6679 ext_thresholds->penalty_algorithm_5g =
6680 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6681 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6682 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6683 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6684 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6685
6686 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6687 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6688 WMITLV_GET_STRUCT_TLVLEN
6689 (wmi_roam_scan_extended_threshold_param));
6690 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6691 WMITLV_SET_HDR(buf_ptr,
6692 WMITLV_TAG_ARRAY_STRUC,
6693 sizeof(wmi_roam_earlystop_rssi_thres_param));
6694 buf_ptr += WMI_TLV_HDR_SIZE;
6695 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6696 early_stop_thresholds->roam_earlystop_thres_min =
6697 roam_req->roam_earlystop_thres_min;
6698 early_stop_thresholds->roam_earlystop_thres_max =
6699 roam_req->roam_earlystop_thres_max;
6700 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6701 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6702 WMITLV_GET_STRUCT_TLVLEN
6703 (wmi_roam_earlystop_rssi_thres_param));
6704
Gupta, Kapil7e652922016-04-12 15:02:00 +05306705 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6706 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6707 sizeof(wmi_roam_dense_thres_param));
6708 buf_ptr += WMI_TLV_HDR_SIZE;
6709 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6710 dense_thresholds->roam_dense_rssi_thres_offset =
6711 roam_req->dense_rssi_thresh_offset;
6712 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6713 dense_thresholds->roam_dense_traffic_thres =
6714 roam_req->traffic_threshold;
6715 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6716 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6717 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6718 WMITLV_GET_STRUCT_TLVLEN
6719 (wmi_roam_dense_thres_param));
6720
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006721 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6722 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6723 sizeof(wmi_roam_bg_scan_roaming_param));
6724 buf_ptr += WMI_TLV_HDR_SIZE;
6725 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6726 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6727 roam_req->bg_scan_bad_rssi_thresh;
6728 bg_scan_params->roam_bg_scan_client_bitmap =
6729 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306730 bg_scan_params->bad_rssi_thresh_offset_2g =
6731 roam_req->roam_bad_rssi_thresh_offset_2g;
6732 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006733 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6734 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6735 WMITLV_GET_STRUCT_TLVLEN
6736 (wmi_roam_bg_scan_roaming_param));
6737
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306738 status = wmi_unified_cmd_send(wmi_handle, buf,
6739 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306740 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306741 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306742 status);
6743 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306744 }
6745
Govind Singh67922e82016-04-01 16:48:57 +05306746 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306747}
6748
6749/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306750 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6751 * configuration params
6752 * @wma_handle: wma handler
6753 * @dwelltime_params: pointer to dwelltime_params
6754 *
6755 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6756 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006757static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306758QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6759 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6760{
6761 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6762 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6763 wmi_buf_t buf;
6764 uint8_t *buf_ptr;
6765 int32_t err;
6766 int len;
6767
6768 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6769 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6770 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6771 buf = wmi_buf_alloc(wmi_handle, len);
6772 if (!buf) {
6773 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6774 __func__);
6775 return QDF_STATUS_E_NOMEM;
6776 }
6777 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6778 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6779 WMITLV_SET_HDR(&dwell_param->tlv_header,
6780 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6781 WMITLV_GET_STRUCT_TLVLEN
6782 (wmi_scan_adaptive_dwell_config_fixed_param));
6783
6784 dwell_param->enable = dwelltime_params->is_enabled;
6785 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6786 WMITLV_SET_HDR(buf_ptr,
6787 WMITLV_TAG_ARRAY_STRUC,
6788 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6789 buf_ptr += WMI_TLV_HDR_SIZE;
6790
6791 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6792 WMITLV_SET_HDR(&cmd->tlv_header,
6793 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6794 WMITLV_GET_STRUCT_TLVLEN(
6795 wmi_scan_adaptive_dwell_parameters_tlv));
6796
6797 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6798 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6799 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6800 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6801 err = wmi_unified_cmd_send(wmi_handle, buf,
6802 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6803 if (err) {
6804 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6805 wmi_buf_free(buf);
6806 return QDF_STATUS_E_FAILURE;
6807 }
6808
6809 return QDF_STATUS_SUCCESS;
6810}
6811
Nitesh Shah52323d02017-05-22 15:49:00 +05306812/**
6813 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6814 * configuration params
6815 * @wmi_handle: wmi handler
6816 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6817 *
6818 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6819 */
6820static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6821 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6822{
6823 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6824 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6825 wmi_buf_t buf;
6826 uint8_t *buf_ptr;
6827 QDF_STATUS err;
6828 uint32_t i;
6829 int len;
6830
6831 len = sizeof(*dbs_scan_param);
6832 len += WMI_TLV_HDR_SIZE;
6833 len += dbs_scan_params->num_clients * sizeof(*cmd);
6834
6835 buf = wmi_buf_alloc(wmi_handle, len);
6836 if (!buf) {
6837 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6838 return QDF_STATUS_E_NOMEM;
6839 }
6840
6841 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6842 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6843 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6844 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6845 WMITLV_GET_STRUCT_TLVLEN
6846 (wmi_scan_dbs_duty_cycle_fixed_param));
6847
6848 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6849 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6850 buf_ptr += sizeof(*dbs_scan_param);
6851 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6852 (sizeof(*cmd) * dbs_scan_params->num_clients));
6853 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6854
6855 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6856 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6857 WMITLV_SET_HDR(&cmd->tlv_header,
6858 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6859 WMITLV_GET_STRUCT_TLVLEN(
6860 wmi_scan_dbs_duty_cycle_tlv_param));
6861 cmd->module_id = dbs_scan_params->module_id[i];
6862 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6863 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6864 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6865 }
6866
6867 err = wmi_unified_cmd_send(wmi_handle, buf,
6868 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6869 if (QDF_IS_STATUS_ERROR(err)) {
6870 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6871 wmi_buf_free(buf);
6872 return QDF_STATUS_E_FAILURE;
6873 }
6874
6875 return QDF_STATUS_SUCCESS;
6876}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306877
6878/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306879 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6880 * @wmi_handle: wmi handle
6881 * @roam_req: Request which contains the filters
6882 *
6883 * There are filters such as whitelist, blacklist and preferred
6884 * list that need to be applied to the scan results to form the
6885 * probable candidates for roaming.
6886 *
6887 * Return: Return success upon succesfully passing the
6888 * parameters to the firmware, otherwise failure.
6889 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306890static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306891 struct roam_scan_filter_params *roam_req)
6892{
6893 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306894 QDF_STATUS status;
6895 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306896 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306897 uint8_t *buf_ptr;
6898 wmi_roam_filter_fixed_param *roam_filter;
6899 uint8_t *bssid_src_ptr = NULL;
6900 wmi_mac_addr *bssid_dst_ptr = NULL;
6901 wmi_ssid *ssid_ptr = NULL;
6902 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306903 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306904 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306905
6906 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306907
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306908 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306909 if (roam_req->num_bssid_black_list)
6910 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6911 len += WMI_TLV_HDR_SIZE;
6912 if (roam_req->num_ssid_white_list)
6913 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6914 len += 2 * WMI_TLV_HDR_SIZE;
6915 if (roam_req->num_bssid_preferred_list) {
6916 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
6917 len += roam_req->num_bssid_preferred_list * sizeof(A_UINT32);
6918 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306919 len += WMI_TLV_HDR_SIZE;
6920 if (roam_req->lca_disallow_config_present) {
6921 len += sizeof(*blist_param);
6922 blist_len = sizeof(*blist_param);
6923 }
6924
6925 len += WMI_TLV_HDR_SIZE;
6926 if (roam_req->num_rssi_rejection_ap)
6927 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306928
6929 buf = wmi_buf_alloc(wmi_handle, len);
6930 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306931 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306932 return QDF_STATUS_E_NOMEM;
6933 }
6934
6935 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6936 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6937 WMITLV_SET_HDR(&roam_filter->tlv_header,
6938 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6939 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6940 /* fill in fixed values */
6941 roam_filter->vdev_id = roam_req->session_id;
6942 roam_filter->flags = 0;
6943 roam_filter->op_bitmap = roam_req->op_bitmap;
6944 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6945 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6946 roam_filter->num_bssid_preferred_list =
6947 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306948 roam_filter->num_rssi_rejection_ap =
6949 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306950 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6951
6952 WMITLV_SET_HDR((buf_ptr),
6953 WMITLV_TAG_ARRAY_FIXED_STRUC,
6954 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6955 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6956 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6957 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6958 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6959 bssid_src_ptr += ATH_MAC_LEN;
6960 bssid_dst_ptr++;
6961 }
6962 buf_ptr += WMI_TLV_HDR_SIZE +
6963 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6964 WMITLV_SET_HDR((buf_ptr),
6965 WMITLV_TAG_ARRAY_FIXED_STRUC,
6966 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6967 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6968 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6969 qdf_mem_copy(&ssid_ptr->ssid,
6970 &roam_req->ssid_allowed_list[i].mac_ssid,
6971 roam_req->ssid_allowed_list[i].length);
6972 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6973 ssid_ptr++;
6974 }
6975 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6976 sizeof(wmi_ssid));
6977 WMITLV_SET_HDR((buf_ptr),
6978 WMITLV_TAG_ARRAY_FIXED_STRUC,
6979 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6980 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6981 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6982 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6983 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6984 (wmi_mac_addr *)bssid_dst_ptr);
6985 bssid_src_ptr += ATH_MAC_LEN;
6986 bssid_dst_ptr++;
6987 }
6988 buf_ptr += WMI_TLV_HDR_SIZE +
6989 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6990 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6991 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6992 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6993 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6994 *bssid_preferred_factor_ptr =
6995 roam_req->bssid_favored_factor[i];
6996 bssid_preferred_factor_ptr++;
6997 }
6998 buf_ptr += WMI_TLV_HDR_SIZE +
6999 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
7000
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307001 WMITLV_SET_HDR(buf_ptr,
7002 WMITLV_TAG_ARRAY_STRUC, blist_len);
7003 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307004 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307005 blist_param =
7006 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
7007 WMITLV_SET_HDR(&blist_param->tlv_header,
7008 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
7009 WMITLV_GET_STRUCT_TLVLEN(
7010 wmi_roam_lca_disallow_config_tlv_param));
7011
7012 blist_param->disallow_duration = roam_req->disallow_duration;
7013 blist_param->rssi_channel_penalization =
7014 roam_req->rssi_channel_penalization;
7015 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05307016 blist_param->disallow_lca_enable_source_bitmap =
7017 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
7018 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05307019 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
7020 }
7021
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307022 WMITLV_SET_HDR(buf_ptr,
7023 WMITLV_TAG_ARRAY_STRUC,
7024 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
7025 buf_ptr += WMI_TLV_HDR_SIZE;
7026 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
7027 rssi_rej =
7028 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7029 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7030 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7031 WMITLV_GET_STRUCT_TLVLEN(
7032 wmi_roam_rssi_rejection_oce_config_param));
7033 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7034 roam_req->rssi_rejection_ap[i].bssid.bytes,
7035 &rssi_rej->bssid);
7036 rssi_rej->remaining_disallow_duration =
7037 roam_req->rssi_rejection_ap[i].remaining_duration;
7038 rssi_rej->requested_rssi =
7039 (A_INT32)roam_req->rssi_rejection_ap[i].expected_rssi;
7040 buf_ptr +=
7041 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7042 }
7043
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307044 status = wmi_unified_cmd_send(wmi_handle, buf,
7045 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307046 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307047 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307048 status);
7049 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307050 }
Govind Singh67922e82016-04-01 16:48:57 +05307051
7052 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307053}
7054
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307055#if defined(WLAN_FEATURE_FILS_SK)
7056static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7057 struct hlp_params *params)
7058{
7059 uint32_t len;
7060 uint8_t *buf_ptr;
7061 wmi_buf_t buf = NULL;
7062 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7063
7064 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7065 len += WMI_TLV_HDR_SIZE;
7066 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7067
7068 buf = wmi_buf_alloc(wmi_handle, len);
7069 if (!buf) {
7070 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7071 return QDF_STATUS_E_NOMEM;
7072 }
7073
7074 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7075 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7076 WMITLV_SET_HDR(&hlp_params->tlv_header,
7077 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7078 WMITLV_GET_STRUCT_TLVLEN(
7079 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7080
7081 hlp_params->vdev_id = params->vdev_id;
7082 hlp_params->size = params->hlp_ie_len;
7083 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7084
7085 buf_ptr += sizeof(*hlp_params);
7086
7087 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7088 round_up(params->hlp_ie_len,
7089 sizeof(uint32_t)));
7090 buf_ptr += WMI_TLV_HDR_SIZE;
7091 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7092
7093 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7094 hlp_params->vdev_id, hlp_params->size);
7095 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7096 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7097 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7098 wmi_buf_free(buf);
7099 return QDF_STATUS_E_FAILURE;
7100 }
7101
7102 return QDF_STATUS_SUCCESS;
7103}
7104#endif
7105
Govind Singh4eacd2b2016-03-07 14:24:22 +05307106/** send_set_epno_network_list_cmd_tlv() - set epno network list
7107 * @wmi_handle: wmi handle
7108 * @req: epno config params request structure
7109 *
7110 * This function reads the incoming epno config request structure
7111 * and constructs the WMI message to the firmware.
7112 *
7113 * Returns: 0 on success, error number otherwise
7114 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307115static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307116 struct wifi_enhanched_pno_params *req)
7117{
7118 wmi_nlo_config_cmd_fixed_param *cmd;
7119 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307120 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307121 u_int8_t i, *buf_ptr;
7122 wmi_buf_t buf;
7123 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307124 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307125
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307126 /* Fixed Params */
7127 len = sizeof(*cmd);
7128 if (req->num_networks) {
7129 /* TLV place holder for array of structures
7130 * then each nlo_configured_parameters(nlo_list) TLV.
7131 */
7132 len += WMI_TLV_HDR_SIZE;
7133 len += (sizeof(nlo_configured_parameters)
7134 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
7135 /* TLV for array of uint32 channel_list */
7136 len += WMI_TLV_HDR_SIZE;
7137 /* TLV for nlo_channel_prediction_cfg */
7138 len += WMI_TLV_HDR_SIZE;
7139 /* TLV for candidate score params */
7140 len += sizeof(enlo_candidate_score_params);
7141 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05307142
7143 buf = wmi_buf_alloc(wmi_handle, len);
7144 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307145 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7146 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307147 }
7148
7149 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7150
7151 buf_ptr = (u_int8_t *) cmd;
7152 WMITLV_SET_HDR(&cmd->tlv_header,
7153 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7154 WMITLV_GET_STRUCT_TLVLEN(
7155 wmi_nlo_config_cmd_fixed_param));
7156 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307157
7158 /* set flag to reset if num of networks are 0 */
7159 cmd->flags = (req->num_networks == 0 ?
7160 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307161
7162 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7163
Govind Singhb53420c2016-03-09 14:32:57 +05307164 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307165 WMI_LOGD("SSID count: %d flags: %d",
7166 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307167
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307168 /* Fill nlo_config only when num_networks are non zero */
7169 if (cmd->no_of_ssids) {
7170 /* Fill networks */
7171 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7172 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7173 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307174
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307175 nlo_list = (nlo_configured_parameters *) buf_ptr;
7176 for (i = 0; i < cmd->no_of_ssids; i++) {
7177 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7178 WMITLV_TAG_ARRAY_BYTE,
7179 WMITLV_GET_STRUCT_TLVLEN(
7180 nlo_configured_parameters));
7181 /* Copy ssid and it's length */
7182 nlo_list[i].ssid.valid = true;
7183 nlo_list[i].ssid.ssid.ssid_len =
7184 req->networks[i].ssid.length;
7185 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
7186 req->networks[i].ssid.mac_ssid,
7187 nlo_list[i].ssid.ssid.ssid_len);
7188 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
7189 nlo_list[i].ssid.ssid.ssid_len,
7190 (char *) nlo_list[i].ssid.ssid.ssid,
7191 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307192
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307193 /* Copy pno flags */
7194 nlo_list[i].bcast_nw_type.valid = true;
7195 nlo_list[i].bcast_nw_type.bcast_nw_type =
7196 req->networks[i].flags;
7197 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307198 nlo_list[i].bcast_nw_type.bcast_nw_type);
7199
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307200 /* Copy auth bit field */
7201 nlo_list[i].auth_type.valid = true;
7202 nlo_list[i].auth_type.auth_type =
7203 req->networks[i].auth_bit_field;
7204 WMI_LOGD("Auth bit field (%u)",
7205 nlo_list[i].auth_type.auth_type);
7206 }
7207
7208 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7209 /* Fill the channel list */
7210 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7211 buf_ptr += WMI_TLV_HDR_SIZE;
7212
7213 /* Fill prediction_param */
7214 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7215 buf_ptr += WMI_TLV_HDR_SIZE;
7216
7217 /* Fill epno candidate score params */
7218 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
7219 WMITLV_SET_HDR(buf_ptr,
7220 WMITLV_TAG_STRUC_enlo_candidate_score_param,
7221 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7222 cand_score_params->min5GHz_rssi =
7223 req->min_5ghz_rssi;
7224 cand_score_params->min24GHz_rssi =
7225 req->min_24ghz_rssi;
7226 cand_score_params->initial_score_max =
7227 req->initial_score_max;
7228 cand_score_params->current_connection_bonus =
7229 req->current_connection_bonus;
7230 cand_score_params->same_network_bonus =
7231 req->same_network_bonus;
7232 cand_score_params->secure_bonus =
7233 req->secure_bonus;
7234 cand_score_params->band5GHz_bonus =
7235 req->band_5ghz_bonus;
7236 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307237 }
7238
Govind Singh4eacd2b2016-03-07 14:24:22 +05307239 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307240 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307241 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307242 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307243 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307244 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307245 }
7246
Govind Singhb53420c2016-03-09 14:32:57 +05307247 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307248 req->session_id);
7249
Govind Singh67922e82016-04-01 16:48:57 +05307250 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307251}
7252
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307253
Govind Singh4eacd2b2016-03-07 14:24:22 +05307254/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7255 * @wmi_handle: wmi handle
7256 * @ipa_offload: ipa offload control parameter
7257 *
7258 * Returns: 0 on success, error number otherwise
7259 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307260static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307261 struct ipa_offload_control_params *ipa_offload)
7262{
7263 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7264 wmi_buf_t wmi_buf;
7265 uint32_t len;
7266 u_int8_t *buf_ptr;
7267
7268 len = sizeof(*cmd);
7269 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7270 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307271 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7272 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307273 }
7274
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007275 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307276 ipa_offload->offload_type, ipa_offload->enable);
7277
7278 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7279
7280 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7281 WMITLV_SET_HDR(&cmd->tlv_header,
7282 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7283 WMITLV_GET_STRUCT_TLVLEN(
7284 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7285
7286 cmd->offload_type = ipa_offload->offload_type;
7287 cmd->vdev_id = ipa_offload->vdev_id;
7288 cmd->enable = ipa_offload->enable;
7289
7290 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7291 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307292 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307293 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307294 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307295 }
7296
Govind Singhb53420c2016-03-09 14:32:57 +05307297 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307298}
7299
7300/**
7301 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
7302 * @wmi_handle: wmi handle
7303 * @pgetcapab: get capabilities params
7304 *
7305 * This function send request to fw to get extscan capabilities.
7306 *
7307 * Return: CDF status
7308 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307309static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307310 struct extscan_capabilities_params *pgetcapab)
7311{
7312 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
7313 wmi_buf_t wmi_buf;
7314 uint32_t len;
7315 uint8_t *buf_ptr;
7316
7317 len = sizeof(*cmd);
7318 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7319 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307320 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7321 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307322 }
7323 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7324
7325 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
7326 WMITLV_SET_HDR(&cmd->tlv_header,
7327 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
7328 WMITLV_GET_STRUCT_TLVLEN
7329 (wmi_extscan_get_capabilities_cmd_fixed_param));
7330
7331 cmd->request_id = pgetcapab->request_id;
7332
7333 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7334 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307335 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307336 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307337 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307338 }
Govind Singhb53420c2016-03-09 14:32:57 +05307339 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307340}
7341
7342/**
7343 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
7344 * @wmi_handle: wmi handle
7345 * @pcached_results: cached results parameters
7346 *
7347 * This function send request to fw to get cached results.
7348 *
7349 * Return: CDF status
7350 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307351static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307352 struct extscan_cached_result_params *pcached_results)
7353{
7354 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
7355 wmi_buf_t wmi_buf;
7356 uint32_t len;
7357 uint8_t *buf_ptr;
7358
7359 len = sizeof(*cmd);
7360 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7361 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307362 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7363 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307364 }
7365 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7366
7367 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
7368 WMITLV_SET_HDR(&cmd->tlv_header,
7369 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
7370 WMITLV_GET_STRUCT_TLVLEN
7371 (wmi_extscan_get_cached_results_cmd_fixed_param));
7372
7373 cmd->request_id = pcached_results->request_id;
7374 cmd->vdev_id = pcached_results->session_id;
7375 cmd->control_flags = pcached_results->flush;
7376
7377 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7378 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307379 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307380 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307381 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307382 }
Govind Singhb53420c2016-03-09 14:32:57 +05307383 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307384}
7385
7386/**
7387 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
7388 * @wmi_handle: wmi handle
7389 * @reset_req: Reset change request params
7390 *
7391 * This function sends stop change monitor request to fw.
7392 *
7393 * Return: CDF status
7394 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307395static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307396 struct extscan_capabilities_reset_params *reset_req)
7397{
7398 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7399 wmi_buf_t wmi_buf;
7400 uint32_t len;
7401 uint8_t *buf_ptr;
7402 int change_list = 0;
7403
7404 len = sizeof(*cmd);
7405
7406 /* reset significant change tlv is set to 0 */
7407 len += WMI_TLV_HDR_SIZE;
7408 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
7409 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7410 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307411 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7412 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307413 }
7414 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7415
7416 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7417 buf_ptr;
7418 WMITLV_SET_HDR(&cmd->tlv_header,
7419 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7420 WMITLV_GET_STRUCT_TLVLEN
7421 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7422
7423 cmd->request_id = reset_req->request_id;
7424 cmd->vdev_id = reset_req->session_id;
7425 cmd->mode = 0;
7426
7427 buf_ptr += sizeof(*cmd);
7428 WMITLV_SET_HDR(buf_ptr,
7429 WMITLV_TAG_ARRAY_STRUC,
7430 change_list *
7431 sizeof(wmi_extscan_wlan_change_bssid_param));
7432 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
7433 sizeof
7434 (wmi_extscan_wlan_change_bssid_param));
7435
7436 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7437 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307438 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307439 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307440 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307441 }
Govind Singhb53420c2016-03-09 14:32:57 +05307442 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307443}
7444
7445/**
7446 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
7447 * @wmi_handle: wmi handle
7448 * @psigchange: change monitor request params
7449 * @buf: wmi buffer
7450 * @buf_len: buffer length
7451 *
7452 * This function fills elements of change monitor request buffer.
7453 *
7454 * Return: CDF status
7455 */
Govind Singhb53420c2016-03-09 14:32:57 +05307456static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307457 struct extscan_set_sig_changereq_params
7458 *psigchange, wmi_buf_t *buf, int *buf_len)
7459{
7460 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7461 wmi_extscan_wlan_change_bssid_param *dest_chglist;
7462 uint8_t *buf_ptr;
7463 int j;
7464 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007465 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307466 struct ap_threshold_params *src_ap = psigchange->ap;
7467
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007468 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307469 WMI_LOGE("%s: Invalid number of bssid's", __func__);
7470 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307471 }
7472 len += WMI_TLV_HDR_SIZE;
7473 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
7474
7475 *buf = wmi_buf_alloc(wmi_handle, len);
7476 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307477 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307478 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307479 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307480 }
7481 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7482 cmd =
7483 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7484 buf_ptr;
7485 WMITLV_SET_HDR(&cmd->tlv_header,
7486 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7487 WMITLV_GET_STRUCT_TLVLEN
7488 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7489
7490 cmd->request_id = psigchange->request_id;
7491 cmd->vdev_id = psigchange->session_id;
7492 cmd->total_entries = numap;
7493 cmd->mode = 1;
7494 cmd->num_entries_in_page = numap;
7495 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
7496 cmd->max_rssi_samples = psigchange->rssi_sample_size;
7497 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
7498 cmd->max_out_of_range_count = psigchange->min_breaching;
7499
7500 buf_ptr += sizeof(*cmd);
7501 WMITLV_SET_HDR(buf_ptr,
7502 WMITLV_TAG_ARRAY_STRUC,
7503 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7504 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
7505 (buf_ptr + WMI_TLV_HDR_SIZE);
7506
7507 for (j = 0; j < numap; j++) {
7508 WMITLV_SET_HDR(dest_chglist,
7509 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7510 WMITLV_GET_STRUCT_TLVLEN
7511 (wmi_extscan_wlan_change_bssid_param));
7512
7513 dest_chglist->lower_rssi_limit = src_ap->low;
7514 dest_chglist->upper_rssi_limit = src_ap->high;
7515 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
7516 &dest_chglist->bssid);
7517
Govind Singhb53420c2016-03-09 14:32:57 +05307518 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307519 dest_chglist->lower_rssi_limit);
7520 dest_chglist++;
7521 src_ap++;
7522 }
7523 buf_ptr += WMI_TLV_HDR_SIZE +
7524 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7525 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307526 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307527}
7528
7529/**
7530 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
7531 * @wmi_handle: wmi handle
7532 * @psigchange: change monitor request params
7533 *
7534 * This function sends start change monitor request to fw.
7535 *
7536 * Return: CDF status
7537 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307538static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307539 struct extscan_set_sig_changereq_params *
7540 psigchange)
7541{
Govind Singhb53420c2016-03-09 14:32:57 +05307542 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307543 wmi_buf_t buf;
7544 int len;
7545
7546
Govind Singhb53420c2016-03-09 14:32:57 +05307547 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307548 psigchange, &buf,
7549 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307550 if (qdf_status != QDF_STATUS_SUCCESS) {
7551 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307552 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307553 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307554 }
7555 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307556 WMI_LOGE("%s: Failed to get buffer", __func__);
7557 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307558 }
7559 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7560 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307561 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307562 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307563 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307564 }
Govind Singhb53420c2016-03-09 14:32:57 +05307565 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307566}
7567
7568/**
7569 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
7570 * @wmi_handle: wmi handle
7571 * @photlist_reset: hotlist reset params
7572 *
7573 * This function configures hotlist monitor to stop in fw.
7574 *
7575 * Return: CDF status
7576 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307577static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307578 struct extscan_bssid_hotlist_reset_params *photlist_reset)
7579{
7580 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
7581 wmi_buf_t wmi_buf;
7582 uint32_t len;
7583 uint8_t *buf_ptr;
7584 int hotlist_entries = 0;
7585
7586 len = sizeof(*cmd);
7587
7588 /* reset bssid hotlist with tlv set to 0 */
7589 len += WMI_TLV_HDR_SIZE;
7590 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
7591
7592 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7593 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307594 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7595 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307596 }
7597
7598 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7599 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
7600 buf_ptr;
7601 WMITLV_SET_HDR(&cmd->tlv_header,
7602 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
7603 WMITLV_GET_STRUCT_TLVLEN
7604 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
7605
7606 cmd->request_id = photlist_reset->request_id;
7607 cmd->vdev_id = photlist_reset->session_id;
7608 cmd->mode = 0;
7609
7610 buf_ptr += sizeof(*cmd);
7611 WMITLV_SET_HDR(buf_ptr,
7612 WMITLV_TAG_ARRAY_STRUC,
7613 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7614 buf_ptr += WMI_TLV_HDR_SIZE +
7615 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7616
7617 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7618 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307619 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307620 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307621 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307622 }
Govind Singhb53420c2016-03-09 14:32:57 +05307623 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307624}
7625
7626/**
7627 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
7628 * @wmi_handle: wmi handle
7629 * @pstopcmd: stop scan command request params
7630 *
7631 * This function sends stop extscan request to fw.
7632 *
7633 * Return: CDF Status.
7634 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307635static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307636 struct extscan_stop_req_params *pstopcmd)
7637{
7638 wmi_extscan_stop_cmd_fixed_param *cmd;
7639 wmi_buf_t wmi_buf;
7640 uint32_t len;
7641 uint8_t *buf_ptr;
7642
7643 len = sizeof(*cmd);
7644 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7645 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307646 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7647 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307648 }
7649 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7650 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
7651 WMITLV_SET_HDR(&cmd->tlv_header,
7652 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
7653 WMITLV_GET_STRUCT_TLVLEN
7654 (wmi_extscan_stop_cmd_fixed_param));
7655
7656 cmd->request_id = pstopcmd->request_id;
7657 cmd->vdev_id = pstopcmd->session_id;
7658
7659 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7660 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307661 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307662 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307663 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307664 }
7665
Govind Singhb53420c2016-03-09 14:32:57 +05307666 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307667}
7668
7669/**
7670 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
7671 * @wmi_handle: wmi handle
7672 * @pstart: scan command request params
7673 * @buf: event buffer
7674 * @buf_len: length of buffer
7675 *
7676 * This function fills individual elements of extscan request and
7677 * TLV for buckets, channel list.
7678 *
7679 * Return: CDF Status.
7680 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007681static
Govind Singhb53420c2016-03-09 14:32:57 +05307682QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307683 struct wifi_scan_cmd_req_params *pstart,
7684 wmi_buf_t *buf, int *buf_len)
7685{
7686 wmi_extscan_start_cmd_fixed_param *cmd;
7687 wmi_extscan_bucket *dest_blist;
7688 wmi_extscan_bucket_channel *dest_clist;
7689 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
7690 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
7691 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
7692
7693 uint8_t *buf_ptr;
7694 int i, k, count = 0;
7695 int len = sizeof(*cmd);
7696 int nbuckets = pstart->numBuckets;
7697 int nchannels = 0;
7698
7699 /* These TLV's are are NULL by default */
7700 uint32_t ie_len_with_pad = 0;
7701 int num_ssid = 0;
7702 int num_bssid = 0;
7703 int ie_len = 0;
7704
7705 uint32_t base_period = pstart->basePeriod;
7706
7707 /* TLV placeholder for ssid_list (NULL) */
7708 len += WMI_TLV_HDR_SIZE;
7709 len += num_ssid * sizeof(wmi_ssid);
7710
7711 /* TLV placeholder for bssid_list (NULL) */
7712 len += WMI_TLV_HDR_SIZE;
7713 len += num_bssid * sizeof(wmi_mac_addr);
7714
7715 /* TLV placeholder for ie_data (NULL) */
7716 len += WMI_TLV_HDR_SIZE;
7717 len += ie_len * sizeof(uint32_t);
7718
7719 /* TLV placeholder for bucket */
7720 len += WMI_TLV_HDR_SIZE;
7721 len += nbuckets * sizeof(wmi_extscan_bucket);
7722
7723 /* TLV channel placeholder */
7724 len += WMI_TLV_HDR_SIZE;
7725 for (i = 0; i < nbuckets; i++) {
7726 nchannels += src_bucket->numChannels;
7727 src_bucket++;
7728 }
7729
Govind Singhb53420c2016-03-09 14:32:57 +05307730 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307731 __func__, nbuckets, nchannels);
7732 len += nchannels * sizeof(wmi_extscan_bucket_channel);
7733 /* Allocate the memory */
7734 *buf = wmi_buf_alloc(wmi_handle, len);
7735 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307736 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307737 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307738 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307739 }
7740 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7741 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
7742 WMITLV_SET_HDR(&cmd->tlv_header,
7743 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
7744 WMITLV_GET_STRUCT_TLVLEN
7745 (wmi_extscan_start_cmd_fixed_param));
7746
7747 cmd->request_id = pstart->requestId;
7748 cmd->vdev_id = pstart->sessionId;
7749 cmd->base_period = pstart->basePeriod;
7750 cmd->num_buckets = nbuckets;
7751 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05307752 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307753 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05307754 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307755 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05307756#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05307757 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
7758 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05307759 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
7760 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
7761#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307762 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7763
7764 /* The max dwell time is retrieved from the first channel
7765 * of the first bucket and kept common for all channels.
7766 */
7767 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
7768 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
7769 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
7770 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
7771 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7772 cmd->max_table_usage = pstart->report_threshold_percent;
7773 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
7774
7775 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05307776 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307777 cmd->probe_delay = 0;
7778 cmd->probe_spacing_time = 0;
7779 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307780 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
7781 WMI_SCAN_ADD_CCK_RATES |
7782 WMI_SCAN_ADD_OFDM_RATES |
7783 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
7784 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05307785 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
7786 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05307787 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307788 cmd->num_ssids = 0;
7789 cmd->num_bssid = 0;
7790 cmd->ie_len = 0;
7791 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
7792 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
7793
7794 buf_ptr += sizeof(*cmd);
7795 WMITLV_SET_HDR(buf_ptr,
7796 WMITLV_TAG_ARRAY_FIXED_STRUC,
7797 num_ssid * sizeof(wmi_ssid));
7798 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
7799
7800 WMITLV_SET_HDR(buf_ptr,
7801 WMITLV_TAG_ARRAY_FIXED_STRUC,
7802 num_bssid * sizeof(wmi_mac_addr));
7803 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7804
7805 ie_len_with_pad = 0;
7806 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7807 ie_len_with_pad);
7808 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7809
7810 WMITLV_SET_HDR(buf_ptr,
7811 WMITLV_TAG_ARRAY_STRUC,
7812 nbuckets * sizeof(wmi_extscan_bucket));
7813 dest_blist = (wmi_extscan_bucket *)
7814 (buf_ptr + WMI_TLV_HDR_SIZE);
7815 src_bucket = pstart->buckets;
7816
7817 /* Retrieve scanning information from each bucket and
7818 * channels and send it to the target
7819 */
7820 for (i = 0; i < nbuckets; i++) {
7821 WMITLV_SET_HDR(dest_blist,
7822 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7823 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7824
7825 dest_blist->bucket_id = src_bucket->bucket;
7826 dest_blist->base_period_multiplier =
7827 src_bucket->period / base_period;
7828 dest_blist->min_period = src_bucket->period;
7829 dest_blist->max_period = src_bucket->max_period;
7830 dest_blist->exp_backoff = src_bucket->exponent;
7831 dest_blist->exp_max_step_count = src_bucket->step_count;
7832 dest_blist->channel_band = src_bucket->band;
7833 dest_blist->num_channels = src_bucket->numChannels;
7834 dest_blist->notify_extscan_events = 0;
7835
7836 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7837 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007838 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7839 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307840
7841 if (src_bucket->reportEvents &
7842 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7843 dest_blist->forwarding_flags =
7844 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7845 dest_blist->notify_extscan_events |=
7846 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7847 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7848 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7849 } else {
7850 dest_blist->forwarding_flags =
7851 WMI_EXTSCAN_NO_FORWARDING;
7852 }
7853
7854 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7855 dest_blist->configuration_flags = 0;
7856 else
7857 dest_blist->configuration_flags =
7858 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7859
Govind Singhb53420c2016-03-09 14:32:57 +05307860 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307861 __func__, dest_blist->notify_extscan_events,
7862 dest_blist->configuration_flags,
7863 dest_blist->forwarding_flags);
7864
7865 dest_blist->min_dwell_time_active =
7866 src_bucket->min_dwell_time_active;
7867 dest_blist->max_dwell_time_active =
7868 src_bucket->max_dwell_time_active;
7869 dest_blist->min_dwell_time_passive =
7870 src_bucket->min_dwell_time_passive;
7871 dest_blist->max_dwell_time_passive =
7872 src_bucket->max_dwell_time_passive;
7873 src_channel = src_bucket->channels;
7874
7875 /* save the channel info to later populate
7876 * the channel TLV
7877 */
7878 for (k = 0; k < src_bucket->numChannels; k++) {
7879 save_channel[count++].channel = src_channel->channel;
7880 src_channel++;
7881 }
7882 dest_blist++;
7883 src_bucket++;
7884 }
7885 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7886 WMITLV_SET_HDR(buf_ptr,
7887 WMITLV_TAG_ARRAY_STRUC,
7888 nchannels * sizeof(wmi_extscan_bucket_channel));
7889 dest_clist = (wmi_extscan_bucket_channel *)
7890 (buf_ptr + WMI_TLV_HDR_SIZE);
7891
7892 /* Active or passive scan is based on the bucket dwell time
7893 * and channel specific active,passive scans are not
7894 * supported yet
7895 */
7896 for (i = 0; i < nchannels; i++) {
7897 WMITLV_SET_HDR(dest_clist,
7898 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7899 WMITLV_GET_STRUCT_TLVLEN
7900 (wmi_extscan_bucket_channel));
7901 dest_clist->channel = save_channel[i].channel;
7902 dest_clist++;
7903 }
7904 buf_ptr += WMI_TLV_HDR_SIZE +
7905 (nchannels * sizeof(wmi_extscan_bucket_channel));
7906 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307907 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307908}
7909
7910/**
7911 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7912 * @wmi_handle: wmi handle
7913 * @pstart: scan command request params
7914 *
7915 * This function sends start extscan request to fw.
7916 *
7917 * Return: CDF Status.
7918 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307919static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307920 struct wifi_scan_cmd_req_params *pstart)
7921{
Govind Singhb53420c2016-03-09 14:32:57 +05307922 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307923 wmi_buf_t buf;
7924 int len;
7925
7926 /* Fill individual elements of extscan request and
7927 * TLV for buckets, channel list.
7928 */
Govind Singhb53420c2016-03-09 14:32:57 +05307929 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307930 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307931 if (qdf_status != QDF_STATUS_SUCCESS) {
7932 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7933 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307934 }
7935 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307936 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307937 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307938 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307939 }
7940 if (wmi_unified_cmd_send(wmi_handle, buf,
7941 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307942 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307943 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307944 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307945 }
7946
Govind Singhb53420c2016-03-09 14:32:57 +05307947 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307948}
7949
7950/**
7951 * send_plm_stop_cmd_tlv() - plm stop request
7952 * @wmi_handle: wmi handle
7953 * @plm: plm request parameters
7954 *
7955 * This function request FW to stop PLM.
7956 *
7957 * Return: CDF status
7958 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307959static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307960 const struct plm_req_params *plm)
7961{
7962 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7963 int32_t len;
7964 wmi_buf_t buf;
7965 uint8_t *buf_ptr;
7966 int ret;
7967
7968 len = sizeof(*cmd);
7969 buf = wmi_buf_alloc(wmi_handle, len);
7970 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307971 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7972 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307973 }
7974
7975 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7976
7977 buf_ptr = (uint8_t *) cmd;
7978
7979 WMITLV_SET_HDR(&cmd->tlv_header,
7980 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7981 WMITLV_GET_STRUCT_TLVLEN
7982 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7983
7984 cmd->vdev_id = plm->session_id;
7985
7986 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307987 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307988
7989 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7990 WMI_VDEV_PLMREQ_STOP_CMDID);
7991 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307992 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307993 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307994 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307995 }
7996
Govind Singhb53420c2016-03-09 14:32:57 +05307997 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307998}
7999
8000/**
8001 * send_plm_start_cmd_tlv() - plm start request
8002 * @wmi_handle: wmi handle
8003 * @plm: plm request parameters
8004 *
8005 * This function request FW to start PLM.
8006 *
8007 * Return: CDF status
8008 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308009static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308010 const struct plm_req_params *plm,
8011 uint32_t *gchannel_list)
8012{
8013 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
8014 uint32_t *channel_list;
8015 int32_t len;
8016 wmi_buf_t buf;
8017 uint8_t *buf_ptr;
8018 uint8_t count;
8019 int ret;
8020
8021 /* TLV place holder for channel_list */
8022 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
8023 len += sizeof(uint32_t) * plm->plm_num_ch;
8024
8025 buf = wmi_buf_alloc(wmi_handle, len);
8026 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308027 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8028 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308029 }
8030 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
8031
8032 buf_ptr = (uint8_t *) cmd;
8033
8034 WMITLV_SET_HDR(&cmd->tlv_header,
8035 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
8036 WMITLV_GET_STRUCT_TLVLEN
8037 (wmi_vdev_plmreq_start_cmd_fixed_param));
8038
8039 cmd->vdev_id = plm->session_id;
8040
8041 cmd->meas_token = plm->meas_token;
8042 cmd->dialog_token = plm->diag_token;
8043 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05308044 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308045 cmd->off_duration = plm->meas_duration;
8046 cmd->burst_cycle = plm->burst_len;
8047 cmd->tx_power = plm->desired_tx_pwr;
8048 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
8049 cmd->num_chans = plm->plm_num_ch;
8050
8051 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
8052
Govind Singhb53420c2016-03-09 14:32:57 +05308053 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
8054 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
8055 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
8056 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
8057 WMI_LOGD("off_duration: %d", cmd->off_duration);
8058 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
8059 WMI_LOGD("tx_power: %d", cmd->tx_power);
8060 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308061
8062 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8063 (cmd->num_chans * sizeof(uint32_t)));
8064
8065 buf_ptr += WMI_TLV_HDR_SIZE;
8066 if (cmd->num_chans) {
8067 channel_list = (uint32_t *) buf_ptr;
8068 for (count = 0; count < cmd->num_chans; count++) {
8069 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308070 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308071 channel_list[count] =
8072 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308073 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308074 }
8075 buf_ptr += cmd->num_chans * sizeof(uint32_t);
8076 }
8077
8078 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8079 WMI_VDEV_PLMREQ_START_CMDID);
8080 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308081 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308082 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308083 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308084 }
8085
Govind Singhb53420c2016-03-09 14:32:57 +05308086 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308087}
8088
8089/**
8090 * send_pno_stop_cmd_tlv() - PNO stop request
8091 * @wmi_handle: wmi handle
8092 * @vdev_id: vdev id
8093 *
8094 * This function request FW to stop ongoing PNO operation.
8095 *
8096 * Return: CDF status
8097 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308098static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308099{
8100 wmi_nlo_config_cmd_fixed_param *cmd;
8101 int32_t len = sizeof(*cmd);
8102 wmi_buf_t buf;
8103 uint8_t *buf_ptr;
8104 int ret;
8105
8106 /*
8107 * TLV place holder for array of structures nlo_configured_parameters
8108 * TLV place holder for array of uint32_t channel_list
8109 * TLV place holder for chnl prediction cfg
8110 */
8111 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
8112 buf = wmi_buf_alloc(wmi_handle, len);
8113 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308114 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8115 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308116 }
8117
8118 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8119 buf_ptr = (uint8_t *) cmd;
8120
8121 WMITLV_SET_HDR(&cmd->tlv_header,
8122 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8123 WMITLV_GET_STRUCT_TLVLEN
8124 (wmi_nlo_config_cmd_fixed_param));
8125
8126 cmd->vdev_id = vdev_id;
8127 cmd->flags = WMI_NLO_CONFIG_STOP;
8128 buf_ptr += sizeof(*cmd);
8129
8130 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8131 buf_ptr += WMI_TLV_HDR_SIZE;
8132
8133 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
8134 buf_ptr += WMI_TLV_HDR_SIZE;
8135
8136 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8137 buf_ptr += WMI_TLV_HDR_SIZE;
8138
8139
8140 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8141 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8142 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308143 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308144 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308145 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308146 }
8147
Govind Singhb53420c2016-03-09 14:32:57 +05308148 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308149}
8150
8151/**
Govind Singhccb0c272016-04-01 16:30:08 +05308152 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
8153 * @buf_ptr: Buffer passed by upper layers
8154 * @pno: Buffer to be sent to the firmware
8155 *
8156 * Copy the PNO Channel prediction configuration parameters
8157 * passed by the upper layers to a WMI format TLV and send it
8158 * down to the firmware.
8159 *
8160 * Return: None
8161 */
8162static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
8163 struct pno_scan_req_params *pno)
8164{
8165 nlo_channel_prediction_cfg *channel_prediction_cfg =
8166 (nlo_channel_prediction_cfg *) buf_ptr;
8167 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
8168 WMITLV_TAG_ARRAY_BYTE,
8169 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05308170#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05308171 channel_prediction_cfg->enable = pno->pno_channel_prediction;
8172 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
8173 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
8174 channel_prediction_cfg->full_scan_period_ms =
8175 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05308176#endif
Govind Singhccb0c272016-04-01 16:30:08 +05308177 buf_ptr += sizeof(nlo_channel_prediction_cfg);
8178 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
8179 channel_prediction_cfg->enable,
8180 channel_prediction_cfg->top_k_num,
8181 channel_prediction_cfg->stationary_threshold,
8182 channel_prediction_cfg->full_scan_period_ms);
8183}
8184
8185/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008186 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
8187 * @wmi_handle: wmi handle
8188 * @params: configuration parameters
8189 *
8190 * Return: QDF_STATUS
8191 */
8192static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
8193 struct nlo_mawc_params *params)
8194{
8195 wmi_buf_t buf = NULL;
8196 QDF_STATUS status;
8197 int len;
8198 uint8_t *buf_ptr;
8199 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
8200
8201 len = sizeof(*wmi_nlo_mawc_params);
8202 buf = wmi_buf_alloc(wmi_handle, len);
8203 if (!buf) {
8204 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8205 return QDF_STATUS_E_NOMEM;
8206 }
8207
8208 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8209 wmi_nlo_mawc_params =
8210 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
8211 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
8212 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
8213 WMITLV_GET_STRUCT_TLVLEN
8214 (wmi_nlo_configure_mawc_cmd_fixed_param));
8215 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
8216 if (params->enable)
8217 wmi_nlo_mawc_params->enable = 1;
8218 else
8219 wmi_nlo_mawc_params->enable = 0;
8220 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
8221 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
8222 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07008223 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
8224 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
8225 wmi_nlo_mawc_params->exp_backoff_ratio,
8226 wmi_nlo_mawc_params->init_scan_interval,
8227 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008228
8229 status = wmi_unified_cmd_send(wmi_handle, buf,
8230 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
8231 if (QDF_IS_STATUS_ERROR(status)) {
8232 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
8233 status);
8234 wmi_buf_free(buf);
8235 return QDF_STATUS_E_FAILURE;
8236 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008237
8238 return QDF_STATUS_SUCCESS;
8239}
8240
8241/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05308242 * send_pno_start_cmd_tlv() - PNO start request
8243 * @wmi_handle: wmi handle
8244 * @pno: PNO request
8245 *
8246 * This function request FW to start PNO request.
8247 * Request: CDF status
8248 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308249static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05308250 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308251{
8252 wmi_nlo_config_cmd_fixed_param *cmd;
8253 nlo_configured_parameters *nlo_list;
8254 uint32_t *channel_list;
8255 int32_t len;
8256 wmi_buf_t buf;
8257 uint8_t *buf_ptr;
8258 uint8_t i;
8259 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308260 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308261 connected_nlo_rssi_params *nlo_relative_rssi;
8262 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308263
8264 /*
8265 * TLV place holder for array nlo_configured_parameters(nlo_list)
8266 * TLV place holder for array of uint32_t channel_list
8267 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308268 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308269 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05308270 */
8271 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308272 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308273 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308274
Abhishek Singh5987b632017-03-03 22:09:07 +05308275 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308276 WMI_NLO_MAX_CHAN);
8277 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05308278 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308279 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308280 len += sizeof(enlo_candidate_score_params);
8281 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308282 len += sizeof(connected_nlo_rssi_params);
8283 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308284
8285 buf = wmi_buf_alloc(wmi_handle, len);
8286 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308287 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8288 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308289 }
8290
8291 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8292
8293 buf_ptr = (uint8_t *) cmd;
8294 WMITLV_SET_HDR(&cmd->tlv_header,
8295 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8296 WMITLV_GET_STRUCT_TLVLEN
8297 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05308298 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308299 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
8300
Govind Singh87542482016-06-08 19:40:11 +05308301#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05308302 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05308303 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05308304#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05308305 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05308306 cmd->active_dwell_time = pno->active_dwell_time;
8307 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308308
Manjeet Singhcd2dc062016-08-11 15:31:34 +05308309 if (pno->do_passive_scan)
8310 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308311 /* Copy scan interval */
8312 cmd->fast_scan_period = pno->fast_scan_period;
8313 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08008314 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308315 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07008316 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05308317 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308318 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05308319 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308320
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05308321 /* mac randomization attributes */
8322 if (pno->scan_random.randomize) {
8323 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
8324 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
8325 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
8326 pno->scan_random.mac_mask,
8327 &cmd->mac_addr,
8328 &cmd->mac_mask);
8329 }
8330
Govind Singh4eacd2b2016-03-07 14:24:22 +05308331 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
8332
Abhishek Singh5987b632017-03-03 22:09:07 +05308333 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05308334 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308335 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8336 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
8337 buf_ptr += WMI_TLV_HDR_SIZE;
8338
8339 nlo_list = (nlo_configured_parameters *) buf_ptr;
8340 for (i = 0; i < cmd->no_of_ssids; i++) {
8341 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
8342 WMITLV_TAG_ARRAY_BYTE,
8343 WMITLV_GET_STRUCT_TLVLEN
8344 (nlo_configured_parameters));
8345 /* Copy ssid and it's length */
8346 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05308347 nlo_list[i].ssid.ssid.ssid_len =
8348 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05308349 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05308350 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308351 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05308352 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308353 nlo_list[i].ssid.ssid.ssid_len,
8354 (char *)nlo_list[i].ssid.ssid.ssid,
8355 nlo_list[i].ssid.ssid.ssid_len);
8356
8357 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05308358 if (pno->networks_list[i].rssi_thresh &&
8359 pno->networks_list[i].rssi_thresh >
8360 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05308361 nlo_list[i].rssi_cond.valid = true;
8362 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05308363 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05308364 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308365 nlo_list[i].rssi_cond.rssi);
8366 }
8367 nlo_list[i].bcast_nw_type.valid = true;
8368 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05308369 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07008370 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308371 nlo_list[i].bcast_nw_type.bcast_nw_type);
8372 }
8373 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
8374
8375 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05308376 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308377 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05308378 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308379 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8380 (cmd->num_of_channels * sizeof(uint32_t)));
8381 buf_ptr += WMI_TLV_HDR_SIZE;
8382
8383 channel_list = (uint32_t *) buf_ptr;
8384 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05308385 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05308386
8387 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05308388 channel_list[i] =
8389 wlan_chan_to_freq(pno->
8390 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308391
Govind Singhb53420c2016-03-09 14:32:57 +05308392 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308393 }
8394 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
8395 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8396 sizeof(nlo_channel_prediction_cfg));
8397 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05308398 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308399 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308400 /** TODO: Discrete firmware doesn't have command/option to configure
8401 * App IE which comes from wpa_supplicant as of part PNO start request.
8402 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308403 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
8404 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
8405 buf_ptr += sizeof(enlo_candidate_score_params);
8406
8407 if (ie_whitelist->white_list) {
8408 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
8409 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
8410 &cmd->num_vendor_oui,
8411 ie_whitelist);
8412 }
8413
8414 /* ie white list */
8415 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8416 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
8417 buf_ptr += WMI_TLV_HDR_SIZE;
8418 if (cmd->num_vendor_oui != 0) {
8419 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
8420 ie_whitelist->voui);
8421 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
8422 }
8423
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308424 if (pno->relative_rssi_set)
8425 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
8426
8427 /*
8428 * Firmware calculation using connected PNO params:
8429 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
8430 * deduction of rssi_pref for chosen band_pref and
8431 * addition of rssi_pref for remaining bands (other than chosen band).
8432 */
8433 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
8434 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
8435 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
8436 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
8437 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
8438 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
8439 buf_ptr += sizeof(*nlo_relative_rssi);
8440
8441 /*
8442 * As of now Kernel and Host supports one band and rssi preference.
8443 * Firmware supports array of band and rssi preferences
8444 */
8445 cmd->num_cnlo_band_pref = 1;
8446 WMITLV_SET_HDR(buf_ptr,
8447 WMITLV_TAG_ARRAY_STRUC,
8448 cmd->num_cnlo_band_pref *
8449 sizeof(connected_nlo_bss_band_rssi_pref));
8450 buf_ptr += WMI_TLV_HDR_SIZE;
8451
8452 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
8453 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
8454 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
8455 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
8456 WMITLV_GET_STRUCT_TLVLEN(
8457 connected_nlo_bss_band_rssi_pref));
8458 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
8459 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
8460 WMI_LOGI("band_pref %d, rssi_pref %d",
8461 nlo_band_rssi[i].band,
8462 nlo_band_rssi[i].rssi_pref);
8463 }
8464 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
8465
Govind Singh4eacd2b2016-03-07 14:24:22 +05308466 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8467 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8468 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308469 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308470 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308471 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308472 }
8473
Govind Singhb53420c2016-03-09 14:32:57 +05308474 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308475}
8476
8477/* send_set_ric_req_cmd_tlv() - set ric request element
8478 * @wmi_handle: wmi handle
8479 * @msg: message
8480 * @is_add_ts: is addts required
8481 *
8482 * This function sets ric request element for 11r roaming.
8483 *
8484 * Return: CDF status
8485 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308486static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308487 void *msg, uint8_t is_add_ts)
8488{
8489 wmi_ric_request_fixed_param *cmd;
8490 wmi_ric_tspec *tspec_param;
8491 wmi_buf_t buf;
8492 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05308493 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308494 int32_t len = sizeof(wmi_ric_request_fixed_param) +
8495 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
8496
8497 buf = wmi_buf_alloc(wmi_handle, len);
8498 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308499 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8500 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308501 }
8502
8503 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8504
8505 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
8506 WMITLV_SET_HDR(&cmd->tlv_header,
8507 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
8508 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
8509 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07008510 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308511 else
8512 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
8513 cmd->num_ric_request = 1;
8514 cmd->is_add_ric = is_add_ts;
8515
8516 buf_ptr += sizeof(wmi_ric_request_fixed_param);
8517 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
8518
8519 buf_ptr += WMI_TLV_HDR_SIZE;
8520 tspec_param = (wmi_ric_tspec *) buf_ptr;
8521 WMITLV_SET_HDR(&tspec_param->tlv_header,
8522 WMITLV_TAG_STRUC_wmi_ric_tspec,
8523 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
8524
8525 if (is_add_ts)
8526 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05308527#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05308528 else
8529 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05308530#endif
8531 if (ptspecIE) {
8532 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308533#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05308534 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
8535 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308536#else
Govind Singh87542482016-06-08 19:40:11 +05308537 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
8538 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308539#endif /* ANI_LITTLE_BIT_ENDIAN */
8540
Govind Singh87542482016-06-08 19:40:11 +05308541 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
8542 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
8543 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
8544 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
8545 tspec_param->inactivity_interval = ptspecIE->inactInterval;
8546 tspec_param->suspension_interval = ptspecIE->suspendInterval;
8547 tspec_param->svc_start_time = ptspecIE->svcStartTime;
8548 tspec_param->min_data_rate = ptspecIE->minDataRate;
8549 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
8550 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
8551 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
8552 tspec_param->delay_bound = ptspecIE->delayBound;
8553 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
8554 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
8555 tspec_param->medium_time = 0;
8556 }
Govind Singhb53420c2016-03-09 14:32:57 +05308557 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308558
8559 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8560 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308561 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308562 __func__);
8563 if (is_add_ts)
8564 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05308565 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308566 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308567 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308568 }
8569
Govind Singhb53420c2016-03-09 14:32:57 +05308570 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308571}
8572
8573/**
8574 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
8575 * @wmi_handle: wmi handle
8576 * @clear_req: ll stats clear request command params
8577 *
Govind Singhb53420c2016-03-09 14:32:57 +05308578 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308579 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308580static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308581 const struct ll_stats_clear_params *clear_req,
8582 uint8_t addr[IEEE80211_ADDR_LEN])
8583{
8584 wmi_clear_link_stats_cmd_fixed_param *cmd;
8585 int32_t len;
8586 wmi_buf_t buf;
8587 uint8_t *buf_ptr;
8588 int ret;
8589
8590 len = sizeof(*cmd);
8591 buf = wmi_buf_alloc(wmi_handle, len);
8592
8593 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308594 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8595 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308596 }
8597
8598 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308599 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308600 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
8601
8602 WMITLV_SET_HDR(&cmd->tlv_header,
8603 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
8604 WMITLV_GET_STRUCT_TLVLEN
8605 (wmi_clear_link_stats_cmd_fixed_param));
8606
8607 cmd->stop_stats_collection_req = clear_req->stop_req;
8608 cmd->vdev_id = clear_req->sta_id;
8609 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
8610
8611 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8612 &cmd->peer_macaddr);
8613
Govind Singhb53420c2016-03-09 14:32:57 +05308614 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
8615 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
8616 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
8617 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
8618 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308619 cmd->peer_macaddr); */
8620
8621 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8622 WMI_CLEAR_LINK_STATS_CMDID);
8623 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308624 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308625 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308626 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308627 }
8628
Govind Singhb53420c2016-03-09 14:32:57 +05308629 WMI_LOGD("Clear Link Layer Stats request sent successfully");
8630 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308631}
8632
8633/**
8634 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
8635 * @wmi_handle: wmi handle
8636 * @setReq: ll stats set request command params
8637 *
Govind Singhb53420c2016-03-09 14:32:57 +05308638 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308639 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308640static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308641 const struct ll_stats_set_params *set_req)
8642{
8643 wmi_start_link_stats_cmd_fixed_param *cmd;
8644 int32_t len;
8645 wmi_buf_t buf;
8646 uint8_t *buf_ptr;
8647 int ret;
8648
8649 len = sizeof(*cmd);
8650 buf = wmi_buf_alloc(wmi_handle, len);
8651
8652 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308653 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8654 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308655 }
8656
8657 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308658 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308659 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
8660
8661 WMITLV_SET_HDR(&cmd->tlv_header,
8662 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
8663 WMITLV_GET_STRUCT_TLVLEN
8664 (wmi_start_link_stats_cmd_fixed_param));
8665
8666 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
8667 cmd->aggressive_statistics_gathering =
8668 set_req->aggressive_statistics_gathering;
8669
Govind Singhb53420c2016-03-09 14:32:57 +05308670 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
8671 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
8672 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308673
8674 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8675 WMI_START_LINK_STATS_CMDID);
8676 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308677 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308678 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308679 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308680 }
8681
Govind Singhb53420c2016-03-09 14:32:57 +05308682 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308683}
8684
8685/**
8686 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
8687 * @wmi_handle:wmi handle
8688 * @get_req:ll stats get request command params
8689 * @addr: mac address
8690 *
Govind Singhb53420c2016-03-09 14:32:57 +05308691 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308692 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308693static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308694 const struct ll_stats_get_params *get_req,
8695 uint8_t addr[IEEE80211_ADDR_LEN])
8696{
8697 wmi_request_link_stats_cmd_fixed_param *cmd;
8698 int32_t len;
8699 wmi_buf_t buf;
8700 uint8_t *buf_ptr;
8701 int ret;
8702
8703 len = sizeof(*cmd);
8704 buf = wmi_buf_alloc(wmi_handle, len);
8705
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308706 if (!buf) {
8707 WMI_LOGE("%s: buf allocation failed", __func__);
8708 return QDF_STATUS_E_NOMEM;
8709 }
8710
Govind Singh4eacd2b2016-03-07 14:24:22 +05308711 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308712 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308713 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8714
8715 WMITLV_SET_HDR(&cmd->tlv_header,
8716 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8717 WMITLV_GET_STRUCT_TLVLEN
8718 (wmi_request_link_stats_cmd_fixed_param));
8719
8720 cmd->request_id = get_req->req_id;
8721 cmd->stats_type = get_req->param_id_mask;
8722 cmd->vdev_id = get_req->sta_id;
8723
8724 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8725 &cmd->peer_macaddr);
8726
Govind Singhb53420c2016-03-09 14:32:57 +05308727 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008728 WMI_LOGD("Request ID : %u", cmd->request_id);
8729 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308730 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8731 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308732
8733 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8734 WMI_REQUEST_LINK_STATS_CMDID);
8735 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308736 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308737 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308738 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308739 }
8740
Govind Singhb53420c2016-03-09 14:32:57 +05308741 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308742}
8743
Govind Singh4eacd2b2016-03-07 14:24:22 +05308744
Govind Singh20c5dac2016-03-07 15:33:31 +05308745/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308746 * send_congestion_cmd_tlv() - send request to fw to get CCA
8747 * @wmi_handle: wmi handle
8748 * @vdev_id: vdev id
8749 *
8750 * Return: CDF status
8751 */
8752static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
8753 A_UINT8 vdev_id)
8754{
8755 wmi_buf_t buf;
8756 wmi_request_stats_cmd_fixed_param *cmd;
8757 uint8_t len;
8758 uint8_t *buf_ptr;
8759
8760 len = sizeof(*cmd);
8761 buf = wmi_buf_alloc(wmi_handle, len);
8762 if (!buf) {
8763 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8764 return QDF_STATUS_E_FAILURE;
8765 }
8766
8767 buf_ptr = wmi_buf_data(buf);
8768 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8769 WMITLV_SET_HDR(&cmd->tlv_header,
8770 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8771 WMITLV_GET_STRUCT_TLVLEN
8772 (wmi_request_stats_cmd_fixed_param));
8773
8774 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8775 cmd->vdev_id = vdev_id;
8776 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8777 cmd->vdev_id, cmd->stats_id);
8778
8779 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8780 WMI_REQUEST_STATS_CMDID)) {
8781 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8782 __func__);
8783 wmi_buf_free(buf);
8784 return QDF_STATUS_E_FAILURE;
8785 }
8786
8787 return QDF_STATUS_SUCCESS;
8788}
8789
8790/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308791 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8792 * @wmi_handle: wmi handle
8793 * @rssi_req: get RSSI request
8794 *
8795 * Return: CDF status
8796 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308797static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308798{
8799 wmi_buf_t buf;
8800 wmi_request_stats_cmd_fixed_param *cmd;
8801 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8802
8803 buf = wmi_buf_alloc(wmi_handle, len);
8804 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308805 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8806 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308807 }
8808
8809 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8810 WMITLV_SET_HDR(&cmd->tlv_header,
8811 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8812 WMITLV_GET_STRUCT_TLVLEN
8813 (wmi_request_stats_cmd_fixed_param));
8814 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8815 if (wmi_unified_cmd_send
8816 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308817 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308818 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308819 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308820 }
8821
Govind Singhb53420c2016-03-09 14:32:57 +05308822 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308823}
8824
8825/**
8826 * send_snr_cmd_tlv() - get RSSI from fw
8827 * @wmi_handle: wmi handle
8828 * @vdev_id: vdev id
8829 *
8830 * Return: CDF status
8831 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308832static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308833{
8834 wmi_buf_t buf;
8835 wmi_request_stats_cmd_fixed_param *cmd;
8836 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8837
8838 buf = wmi_buf_alloc(wmi_handle, len);
8839 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308840 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8841 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308842 }
8843
8844 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8845 cmd->vdev_id = vdev_id;
8846
8847 WMITLV_SET_HDR(&cmd->tlv_header,
8848 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8849 WMITLV_GET_STRUCT_TLVLEN
8850 (wmi_request_stats_cmd_fixed_param));
8851 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8852 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8853 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308854 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308855 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308856 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308857 }
8858
Govind Singhb53420c2016-03-09 14:32:57 +05308859 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308860}
8861
8862/**
8863 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8864 * @wmi_handle: wmi handle
8865 * @link_status: get link params
8866 *
8867 * Return: CDF status
8868 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308869static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308870 struct link_status_params *link_status)
8871{
8872 wmi_buf_t buf;
8873 wmi_request_stats_cmd_fixed_param *cmd;
8874 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8875
8876 buf = wmi_buf_alloc(wmi_handle, len);
8877 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308878 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8879 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308880 }
8881
8882 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8883 WMITLV_SET_HDR(&cmd->tlv_header,
8884 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8885 WMITLV_GET_STRUCT_TLVLEN
8886 (wmi_request_stats_cmd_fixed_param));
8887 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8888 cmd->vdev_id = link_status->session_id;
8889 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8890 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308891 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308892 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308893 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308894 }
8895
Govind Singhb53420c2016-03-09 14:32:57 +05308896 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308897}
8898
Govind Singh20c5dac2016-03-07 15:33:31 +05308899/**
8900 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8901 * @wmi_handle: wmi handle
8902 * @ta_dhcp_ind: DHCP indication parameter
8903 *
8904 * Return: CDF Status
8905 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308906static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308907 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8908{
Govind Singh67922e82016-04-01 16:48:57 +05308909 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308910 wmi_buf_t buf = NULL;
8911 uint8_t *buf_ptr;
8912 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8913 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8914
8915
8916 buf = wmi_buf_alloc(wmi_handle, len);
8917 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308918 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8919 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308920 }
8921
8922 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8923 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8924 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8925 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8926 WMITLV_GET_STRUCT_TLVLEN
8927 (wmi_peer_set_param_cmd_fixed_param));
8928
8929 /* fill in values */
8930 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8931 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8932 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308933 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308934 &ta_dhcp_ind->peer_macaddr,
8935 sizeof(ta_dhcp_ind->peer_macaddr));
8936
8937 status = wmi_unified_cmd_send(wmi_handle, buf,
8938 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308939 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308940 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308941 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308942 wmi_buf_free(buf);
8943 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308944
Govind Singh67922e82016-04-01 16:48:57 +05308945 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308946}
8947
8948/**
8949 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8950 * @wmi_handle: wmi handle
8951 * @pLinkSpeed: link speed info
8952 *
8953 * Return: CDF status
8954 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308955static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308956 wmi_mac_addr peer_macaddr)
8957{
8958 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8959 wmi_buf_t wmi_buf;
8960 uint32_t len;
8961 uint8_t *buf_ptr;
8962
8963 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8964 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8965 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308966 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8967 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308968 }
8969 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8970
8971 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8972 WMITLV_SET_HDR(&cmd->tlv_header,
8973 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8974 WMITLV_GET_STRUCT_TLVLEN
8975 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8976
8977 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308978 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308979 &peer_macaddr,
8980 sizeof(peer_macaddr));
8981
8982
8983 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8984 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308985 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308986 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308987 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308988 }
Govind Singhb53420c2016-03-09 14:32:57 +05308989 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308990}
8991
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308992#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308993/**
8994 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8995 * @wmi_handle: wmi handler
8996 * @egap_params: pointer to egap_params
8997 *
8998 * Return: 0 for success, otherwise appropriate error code
8999 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309000static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05309001 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05309002{
9003 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
9004 wmi_buf_t buf;
9005 int32_t err;
9006
9007 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9008 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309009 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
9010 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309011 }
9012 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
9013 WMITLV_SET_HDR(&cmd->tlv_header,
9014 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
9015 WMITLV_GET_STRUCT_TLVLEN(
9016 wmi_ap_ps_egap_param_cmd_fixed_param));
9017
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05309018 cmd->enable = egap_params->host_enable_egap;
9019 cmd->inactivity_time = egap_params->egap_inactivity_time;
9020 cmd->wait_time = egap_params->egap_wait_time;
9021 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05309022 err = wmi_unified_cmd_send(wmi_handle, buf,
9023 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
9024 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05309025 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309026 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309027 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309028 }
9029
Govind Singhb53420c2016-03-09 14:32:57 +05309030 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309031}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05309032#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05309033
9034/**
9035 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
9036 * @wmi_handl: wmi handle
9037 * @cmd: Profiling command index
9038 * @value1: parameter1 value
9039 * @value2: parameter2 value
9040 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309041 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309042 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309043static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309044 uint32_t cmd, uint32_t value1, uint32_t value2)
9045{
9046 wmi_buf_t buf;
9047 int32_t len = 0;
9048 int ret;
9049 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
9050 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
9051 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
9052 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
9053
9054 switch (cmd) {
9055 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
9056 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
9057 buf = wmi_buf_alloc(wmi_handle, len);
9058 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309059 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309060 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309061 }
9062 prof_trig_cmd =
9063 (wmi_wlan_profile_trigger_cmd_fixed_param *)
9064 wmi_buf_data(buf);
9065 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
9066 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
9067 WMITLV_GET_STRUCT_TLVLEN
9068 (wmi_wlan_profile_trigger_cmd_fixed_param));
9069 prof_trig_cmd->enable = value1;
9070 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9071 WMI_WLAN_PROFILE_TRIGGER_CMDID);
9072 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309073 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309074 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309075 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309076 return ret;
9077 }
9078 break;
9079
9080 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
9081 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
9082 buf = wmi_buf_alloc(wmi_handle, len);
9083 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309084 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309085 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309086 }
9087 profile_getdata_cmd =
9088 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
9089 wmi_buf_data(buf);
9090 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
9091 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
9092 WMITLV_GET_STRUCT_TLVLEN
9093 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
9094 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9095 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
9096 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309097 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309098 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309099 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309100 return ret;
9101 }
9102 break;
9103
9104 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
9105 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
9106 buf = wmi_buf_alloc(wmi_handle, len);
9107 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309108 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309109 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309110 }
9111 hist_intvl_cmd =
9112 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
9113 wmi_buf_data(buf);
9114 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
9115 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
9116 WMITLV_GET_STRUCT_TLVLEN
9117 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
9118 hist_intvl_cmd->profile_id = value1;
9119 hist_intvl_cmd->value = value2;
9120 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9121 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
9122 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309123 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309124 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309125 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309126 return ret;
9127 }
9128 break;
9129
9130 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
9131 len =
9132 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
9133 buf = wmi_buf_alloc(wmi_handle, len);
9134 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309135 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309136 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309137 }
9138 profile_enable_cmd =
9139 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
9140 wmi_buf_data(buf);
9141 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
9142 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
9143 WMITLV_GET_STRUCT_TLVLEN
9144 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
9145 profile_enable_cmd->profile_id = value1;
9146 profile_enable_cmd->enable = value2;
9147 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9148 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
9149 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309150 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309151 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309152 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309153 return ret;
9154 }
9155 break;
9156
9157 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309158 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309159 break;
9160 }
9161
9162 return 0;
9163}
9164
Paul Zhang92ab8d32017-12-08 16:08:00 +08009165static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
9166 struct wlm_latency_level_param *params)
9167{
9168 wmi_wlm_config_cmd_fixed_param *cmd;
9169 wmi_buf_t buf;
9170 uint32_t len = sizeof(*cmd);
9171 static uint32_t ll[4] = {100, 60, 40, 20};
9172
9173 buf = wmi_buf_alloc(wmi_handle, len);
9174 if (!buf) {
9175 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9176 return QDF_STATUS_E_NOMEM;
9177 }
9178 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
9179 WMITLV_SET_HDR(&cmd->tlv_header,
9180 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
9181 WMITLV_GET_STRUCT_TLVLEN
9182 (wmi_wlm_config_cmd_fixed_param));
9183 cmd->vdev_id = params->vdev_id;
9184 cmd->latency_level = params->wlm_latency_level;
9185 cmd->ul_latency = ll[params->wlm_latency_level];
9186 cmd->dl_latency = ll[params->wlm_latency_level];
9187 cmd->flags = params->wlm_latency_flags;
9188 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9189 WMI_WLM_CONFIG_CMDID)) {
9190 WMI_LOGE("%s: Failed to send setting latency config command",
9191 __func__);
9192 wmi_buf_free(buf);
9193 return QDF_STATUS_E_FAILURE;
9194 }
9195
9196 return 0;
9197}
Govind Singh20c5dac2016-03-07 15:33:31 +05309198/**
9199 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
9200 * @wmi_handle: wmi handle
9201 * @vdev_id: vdev id
9202 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309203 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309204 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309205static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309206{
9207 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
9208 wmi_buf_t buf;
9209 int32_t len = sizeof(*cmd);
9210
Govind Singhb53420c2016-03-09 14:32:57 +05309211 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309212 buf = wmi_buf_alloc(wmi_handle, len);
9213 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309214 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309215 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309216 }
9217 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
9218 wmi_buf_data(buf);
9219 WMITLV_SET_HDR(&cmd->tlv_header,
9220 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
9221 WMITLV_GET_STRUCT_TLVLEN
9222 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
9223 cmd->vdev_id = vdev_id;
9224 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
9225 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9226 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309227 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309228 __func__);
9229 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309230 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309231 }
9232
9233 return 0;
9234}
9235
9236/**
9237 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
9238 * @wmi_handle: wmi handle
9239 * @vdev_id: vdev id
9240 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309241 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309242 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309243static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309244 uint8_t vdev_id)
9245{
9246 wmi_csa_offload_enable_cmd_fixed_param *cmd;
9247 wmi_buf_t buf;
9248 int32_t len = sizeof(*cmd);
9249
Govind Singhb53420c2016-03-09 14:32:57 +05309250 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309251 buf = wmi_buf_alloc(wmi_handle, len);
9252 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309253 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309254 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309255 }
9256 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
9257 WMITLV_SET_HDR(&cmd->tlv_header,
9258 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
9259 WMITLV_GET_STRUCT_TLVLEN
9260 (wmi_csa_offload_enable_cmd_fixed_param));
9261 cmd->vdev_id = vdev_id;
9262 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
9263 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9264 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309265 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309266 __func__);
9267 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309268 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309269 }
9270
9271 return 0;
9272}
9273
Naveen Rawat42cd1e62017-05-13 15:56:57 -07009274#ifdef WLAN_FEATURE_CIF_CFR
9275/**
9276 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
9277 * @wmi_handle: wmi handle
9278 * @data_len: len of dma cfg req
9279 * @data: dma cfg req
9280 *
9281 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9282 */
9283static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9284 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
9285{
9286 wmi_buf_t buf;
9287 uint8_t *cmd;
9288 QDF_STATUS ret;
9289
9290 WMITLV_SET_HDR(cfg,
9291 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
9292 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
9293
9294 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
9295 if (!buf) {
9296 WMI_LOGE(FL("wmi_buf_alloc failed"));
9297 return QDF_STATUS_E_FAILURE;
9298 }
9299
9300 cmd = (uint8_t *) wmi_buf_data(buf);
9301 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
9302 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
9303 sizeof(*cfg));
9304 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
9305 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
9306 if (QDF_IS_STATUS_ERROR(ret)) {
9307 WMI_LOGE(FL(":wmi cmd send failed"));
9308 wmi_buf_free(buf);
9309 }
9310
9311 return ret;
9312}
9313#endif
9314
Govind Singh20c5dac2016-03-07 15:33:31 +05309315/**
Sathish Kumarf396c722017-11-17 17:30:41 +05309316 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
9317 * @wmi_handle: wmi handle
9318 * @data_len: len of dma cfg req
9319 * @data: dma cfg req
9320 *
9321 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9322 */
9323static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9324 struct direct_buf_rx_cfg_req *cfg)
9325{
9326 wmi_buf_t buf;
9327 wmi_dma_ring_cfg_req_fixed_param *cmd;
9328 QDF_STATUS ret;
9329 int32_t len = sizeof(*cmd);
9330
9331 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9332 if (!buf) {
9333 WMI_LOGE(FL("wmi_buf_alloc failed"));
9334 return QDF_STATUS_E_FAILURE;
9335 }
9336
9337 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
9338
9339 WMITLV_SET_HDR(&cmd->tlv_header,
9340 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
9341 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
9342
9343 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9344 cfg->pdev_id);
9345 cmd->mod_id = cfg->mod_id;
9346 cmd->base_paddr_lo = cfg->base_paddr_lo;
9347 cmd->base_paddr_hi = cfg->base_paddr_hi;
9348 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
9349 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
9350 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
9351 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
9352 cmd->num_elems = cfg->num_elems;
9353 cmd->buf_size = cfg->buf_size;
9354 cmd->num_resp_per_event = cfg->num_resp_per_event;
9355 cmd->event_timeout_ms = cfg->event_timeout_ms;
9356
9357 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
9358 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
9359 "head idx paddr hi %x tail idx paddr lo %x"
9360 "tail idx addr hi %x num elems %d buf size %d num resp %d"
9361 "event timeout %d\n", __func__, cmd->pdev_id,
9362 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
9363 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
9364 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
9365 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
9366 cmd->event_timeout_ms);
9367 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9368 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
9369 if (QDF_IS_STATUS_ERROR(ret)) {
9370 WMI_LOGE(FL(":wmi cmd send failed"));
9371 wmi_buf_free(buf);
9372 }
9373
9374 return ret;
9375}
9376
9377/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009378 * send_start_11d_scan_cmd_tlv() - start 11d scan request
9379 * @wmi_handle: wmi handle
9380 * @start_11d_scan: 11d scan start request parameters
9381 *
9382 * This function request FW to start 11d scan.
9383 *
9384 * Return: QDF status
9385 */
9386static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9387 struct reg_start_11d_scan_req *start_11d_scan)
9388{
9389 wmi_11d_scan_start_cmd_fixed_param *cmd;
9390 int32_t len;
9391 wmi_buf_t buf;
9392 int ret;
9393
9394 len = sizeof(*cmd);
9395 buf = wmi_buf_alloc(wmi_handle, len);
9396 if (!buf) {
9397 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9398 return QDF_STATUS_E_NOMEM;
9399 }
9400
9401 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
9402
9403 WMITLV_SET_HDR(&cmd->tlv_header,
9404 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
9405 WMITLV_GET_STRUCT_TLVLEN
9406 (wmi_11d_scan_start_cmd_fixed_param));
9407
9408 cmd->vdev_id = start_11d_scan->vdev_id;
9409 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
9410 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
9411
9412 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
9413
9414 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9415 WMI_11D_SCAN_START_CMDID);
9416 if (ret) {
9417 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
9418 wmi_buf_free(buf);
9419 return QDF_STATUS_E_FAILURE;
9420 }
9421
9422 return QDF_STATUS_SUCCESS;
9423}
9424
9425/**
9426 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
9427 * @wmi_handle: wmi handle
9428 * @start_11d_scan: 11d scan stop request parameters
9429 *
9430 * This function request FW to stop 11d scan.
9431 *
9432 * Return: QDF status
9433 */
9434static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9435 struct reg_stop_11d_scan_req *stop_11d_scan)
9436{
9437 wmi_11d_scan_stop_cmd_fixed_param *cmd;
9438 int32_t len;
9439 wmi_buf_t buf;
9440 int ret;
9441
9442 len = sizeof(*cmd);
9443 buf = wmi_buf_alloc(wmi_handle, len);
9444 if (!buf) {
9445 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9446 return QDF_STATUS_E_NOMEM;
9447 }
9448
9449 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
9450
9451 WMITLV_SET_HDR(&cmd->tlv_header,
9452 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
9453 WMITLV_GET_STRUCT_TLVLEN
9454 (wmi_11d_scan_stop_cmd_fixed_param));
9455
9456 cmd->vdev_id = stop_11d_scan->vdev_id;
9457
9458 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
9459
9460 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9461 WMI_11D_SCAN_STOP_CMDID);
9462 if (ret) {
9463 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
9464 wmi_buf_free(buf);
9465 return QDF_STATUS_E_FAILURE;
9466 }
9467
9468 return QDF_STATUS_SUCCESS;
9469}
9470
9471/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309472 * send_start_oem_data_cmd_tlv() - start OEM data request to target
9473 * @wmi_handle: wmi handle
9474 * @startOemDataReq: start request params
9475 *
9476 * Return: CDF status
9477 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309478static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07009479 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05309480 uint8_t *data)
9481{
9482 wmi_buf_t buf;
9483 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309484 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309485
9486 buf = wmi_buf_alloc(wmi_handle,
9487 (data_len + WMI_TLV_HDR_SIZE));
9488 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309489 WMI_LOGE(FL("wmi_buf_alloc failed"));
9490 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309491 }
9492
9493 cmd = (uint8_t *) wmi_buf_data(buf);
9494
9495 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
9496 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309497 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05309498 data_len);
9499
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08009500 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309501 data_len);
9502
9503 ret = wmi_unified_cmd_send(wmi_handle, buf,
9504 (data_len +
9505 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
9506
Govind Singh67922e82016-04-01 16:48:57 +05309507 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309508 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309509 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309510 }
9511
Govind Singh67922e82016-04-01 16:48:57 +05309512 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309513}
9514
9515/**
9516 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
9517 * @wmi_handle: wmi handle
9518 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
9519 *
9520 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
9521 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
9522 * to firmware based on phyerr filtering
9523 * offload status.
9524 *
9525 * Return: 1 success, 0 failure
9526 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309527static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05309528send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
9529 bool dfs_phyerr_filter_offload)
9530{
9531 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
9532 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
9533 wmi_buf_t buf;
9534 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05309535 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309536
9537
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07009538 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05309539 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309540 __func__);
9541 len = sizeof(*disable_phyerr_offload_cmd);
9542 buf = wmi_buf_alloc(wmi_handle, len);
9543 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309544 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309545 return 0;
9546 }
9547 disable_phyerr_offload_cmd =
9548 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
9549 wmi_buf_data(buf);
9550
9551 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
9552 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
9553 WMITLV_GET_STRUCT_TLVLEN
9554 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
9555
9556 /*
9557 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
9558 * to the firmware to disable the phyerror
9559 * filtering offload.
9560 */
9561 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9562 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309563 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309564 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309565 __func__, ret);
9566 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309567 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309568 }
Govind Singhb53420c2016-03-09 14:32:57 +05309569 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309570 __func__);
9571 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05309572 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309573 __func__);
9574
9575 len = sizeof(*enable_phyerr_offload_cmd);
9576 buf = wmi_buf_alloc(wmi_handle, len);
9577 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309578 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9579 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309580 }
9581
9582 enable_phyerr_offload_cmd =
9583 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
9584 wmi_buf_data(buf);
9585
9586 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
9587 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
9588 WMITLV_GET_STRUCT_TLVLEN
9589 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
9590
9591 /*
9592 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
9593 * to the firmware to enable the phyerror
9594 * filtering offload.
9595 */
9596 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9597 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
9598
Govind Singh67922e82016-04-01 16:48:57 +05309599 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309600 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309601 __func__, ret);
9602 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309603 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309604 }
Govind Singhb53420c2016-03-09 14:32:57 +05309605 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309606 __func__);
9607 }
9608
Govind Singhb53420c2016-03-09 14:32:57 +05309609 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309610}
9611
Naveen Rawata5817e72017-10-26 18:50:19 -07009612/**
9613 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
9614 * will wake up host after specified time is elapsed
9615 * @wmi_handle: wmi handle
9616 * @vdev_id: vdev id
9617 * @cookie: value to identify reason why host set up wake call.
9618 * @time: time in ms
9619 *
9620 * Return: QDF status
9621 */
9622static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9623 uint8_t vdev_id, uint32_t cookie, uint32_t time)
9624{
9625 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
9626 wmi_buf_t buf;
9627 uint8_t *buf_ptr;
9628 int32_t len;
9629 int ret;
9630
9631 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
9632 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
9633 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
9634 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
9635 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
9636 WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32) +
9637 WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
9638
9639 buf = wmi_buf_alloc(wmi_handle, len);
9640 if (!buf) {
9641 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9642 return QDF_STATUS_E_NOMEM;
9643 }
9644
9645 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9646 buf_ptr = (uint8_t *) cmd;
9647
9648 WMITLV_SET_HDR(&cmd->tlv_header,
9649 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
9650 WMITLV_GET_STRUCT_TLVLEN
9651 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
9652 cmd->vdev_id = vdev_id;
9653 cmd->pattern_id = cookie,
9654 cmd->pattern_type = WOW_TIMER_PATTERN;
9655 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
9656
9657 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
9658 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9659 buf_ptr += WMI_TLV_HDR_SIZE;
9660
9661 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
9662 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9663 buf_ptr += WMI_TLV_HDR_SIZE;
9664
9665 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
9666 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9667 buf_ptr += WMI_TLV_HDR_SIZE;
9668
9669 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
9670 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9671 buf_ptr += WMI_TLV_HDR_SIZE;
9672
9673 /* Fill TLV for pattern_info_timeout, and time value */
9674 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
9675 buf_ptr += WMI_TLV_HDR_SIZE;
9676 *((A_UINT32 *) buf_ptr) = time;
9677 buf_ptr += sizeof(A_UINT32);
9678
9679 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
9680 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
9681 buf_ptr += WMI_TLV_HDR_SIZE;
9682 *((A_UINT32 *) buf_ptr) = 0;
9683
9684 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
9685 __func__, time, vdev_id);
9686
9687 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9688 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9689 if (ret) {
9690 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9691 __func__);
9692 wmi_buf_free(buf);
9693 return QDF_STATUS_E_FAILURE;
9694 }
9695
9696 return QDF_STATUS_SUCCESS;
9697}
9698
Govind Singh20c5dac2016-03-07 15:33:31 +05309699#if !defined(REMOVE_PKT_LOG)
9700/**
9701 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9702 * @wmi_handle: wmi handle
9703 * @pktlog_event: pktlog event
9704 * @cmd_id: pktlog cmd id
9705 *
9706 * Return: CDF status
9707 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309708static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309709 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309710 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309711{
9712 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9713 WMI_CMD_ID CMD_ID;
9714 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9715 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9716 int len = 0;
9717 wmi_buf_t buf;
9718
9719 PKTLOG_EVENT = pktlog_event;
9720 CMD_ID = cmd_id;
9721
9722 switch (CMD_ID) {
9723 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9724 len = sizeof(*cmd);
9725 buf = wmi_buf_alloc(wmi_handle, len);
9726 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309727 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9728 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309729 }
9730 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9731 wmi_buf_data(buf);
9732 WMITLV_SET_HDR(&cmd->tlv_header,
9733 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9734 WMITLV_GET_STRUCT_TLVLEN
9735 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9736 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309737 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9738 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309739 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9740 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309741 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9742 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309743 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309744 goto wmi_send_failed;
9745 }
9746 break;
9747 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9748 len = sizeof(*disable_cmd);
9749 buf = wmi_buf_alloc(wmi_handle, len);
9750 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309751 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9752 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309753 }
9754 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9755 wmi_buf_data(buf);
9756 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9757 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9758 WMITLV_GET_STRUCT_TLVLEN
9759 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309760 disable_cmd->pdev_id =
9761 wmi_handle->ops->convert_pdev_id_host_to_target(
9762 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309763 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9764 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309765 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309766 goto wmi_send_failed;
9767 }
9768 break;
9769 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309770 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309771 break;
9772 }
9773
Govind Singhb53420c2016-03-09 14:32:57 +05309774 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309775
9776wmi_send_failed:
9777 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309778 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309779}
9780#endif /* REMOVE_PKT_LOG */
9781
9782/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309783 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9784 * @wmi_handle: wmi handle
9785 * @ptrn_id: pattern id
9786 * @vdev_id: vdev id
9787 *
9788 * Return: CDF status
9789 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309790static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9791 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309792{
9793 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9794 wmi_buf_t buf;
9795 int32_t len;
9796 int ret;
9797
9798 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9799
9800
9801 buf = wmi_buf_alloc(wmi_handle, len);
9802 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309803 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9804 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309805 }
9806
9807 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9808
9809 WMITLV_SET_HDR(&cmd->tlv_header,
9810 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9811 WMITLV_GET_STRUCT_TLVLEN(
9812 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9813 cmd->vdev_id = vdev_id;
9814 cmd->pattern_id = ptrn_id;
9815 cmd->pattern_type = WOW_BITMAP_PATTERN;
9816
Govind Singhb53420c2016-03-09 14:32:57 +05309817 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309818 cmd->pattern_id, vdev_id);
9819
9820 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9821 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9822 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309823 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309824 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309825 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309826 }
9827
Govind Singhb53420c2016-03-09 14:32:57 +05309828 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309829}
9830
9831/**
9832 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9833 * @wmi_handle: wmi handle
9834 *
9835 * Sends host wakeup indication to FW. On receiving this indication,
9836 * FW will come out of WOW.
9837 *
9838 * Return: CDF status
9839 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309840static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309841{
9842 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9843 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309844 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309845 int32_t len;
9846 int ret;
9847
9848 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9849
9850 buf = wmi_buf_alloc(wmi_handle, len);
9851 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309852 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9853 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309854 }
9855
9856 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9857 wmi_buf_data(buf);
9858 WMITLV_SET_HDR(&cmd->tlv_header,
9859 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9860 WMITLV_GET_STRUCT_TLVLEN
9861 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9862
9863
9864 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9865 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9866 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309867 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309868 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309869 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309870 }
9871
Govind Singhb53420c2016-03-09 14:32:57 +05309872 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309873}
9874
9875/**
9876 * send_del_ts_cmd_tlv() - send DELTS request to fw
9877 * @wmi_handle: wmi handle
9878 * @msg: delts params
9879 *
9880 * Return: CDF status
9881 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309882static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309883 uint8_t ac)
9884{
9885 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9886 wmi_buf_t buf;
9887 int32_t len = sizeof(*cmd);
9888
9889 buf = wmi_buf_alloc(wmi_handle, len);
9890 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309891 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9892 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309893 }
9894 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9895 WMITLV_SET_HDR(&cmd->tlv_header,
9896 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9897 WMITLV_GET_STRUCT_TLVLEN
9898 (wmi_vdev_wmm_delts_cmd_fixed_param));
9899 cmd->vdev_id = vdev_id;
9900 cmd->ac = ac;
9901
Govind Singhb53420c2016-03-09 14:32:57 +05309902 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309903 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9904 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9905 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309906 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309907 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309908 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309909 }
9910
Govind Singhb53420c2016-03-09 14:32:57 +05309911 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309912}
9913
9914/**
9915 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9916 * @wmi_handle: handle to wmi
9917 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9918 *
Govind Singhb53420c2016-03-09 14:32:57 +05309919 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309920 * ADD_TS requestes to firmware in loop for all the ACs with
9921 * active flow.
9922 *
9923 * Return: CDF status
9924 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309925static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309926 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9927{
9928 int i = 0;
9929 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9930 wmi_buf_t buf;
9931 int32_t len = sizeof(*cmd);
9932
9933 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9934 /* if flow in this AC is active */
9935 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9936 /*
9937 * as per implementation of wma_add_ts_req() we
9938 * are not waiting any response from firmware so
9939 * apart from sending ADDTS to firmware just send
9940 * success to upper layers
9941 */
Govind Singhb53420c2016-03-09 14:32:57 +05309942 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309943
9944 buf = wmi_buf_alloc(wmi_handle, len);
9945 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309946 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9947 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309948 }
9949 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9950 wmi_buf_data(buf);
9951 WMITLV_SET_HDR(&cmd->tlv_header,
9952 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9953 WMITLV_GET_STRUCT_TLVLEN
9954 (wmi_vdev_wmm_addts_cmd_fixed_param));
9955 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9956 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309957 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309958 traffic.userPrio);
9959 cmd->medium_time_us =
9960 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9961 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309962 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309963 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9964 cmd->medium_time_us, cmd->downgrade_type);
9965 if (wmi_unified_cmd_send
9966 (wmi_handle, buf, len,
9967 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309968 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309969 __func__);
9970 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309971 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309972 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309973 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309974 }
9975 }
9976 }
9977
Govind Singhb53420c2016-03-09 14:32:57 +05309978 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309979}
9980
9981/**
9982 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9983 * @wmi_handle: wmi handle
9984 * @msg: ADDTS params
9985 *
9986 * Return: CDF status
9987 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309988static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309989 struct add_ts_param *msg)
9990{
9991 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9992 wmi_buf_t buf;
9993 int32_t len = sizeof(*cmd);
9994
Govind Singhb53420c2016-03-09 14:32:57 +05309995 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309996
9997 buf = wmi_buf_alloc(wmi_handle, len);
9998 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309999 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10000 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010001 }
10002 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
10003 WMITLV_SET_HDR(&cmd->tlv_header,
10004 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
10005 WMITLV_GET_STRUCT_TLVLEN
10006 (wmi_vdev_wmm_addts_cmd_fixed_param));
10007 cmd->vdev_id = msg->sme_session_id;
10008 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
10009 cmd->medium_time_us = msg->tspec.mediumTime * 32;
10010 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +053010011 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010012 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
10013 cmd->downgrade_type, __func__, __LINE__);
10014 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10015 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010016 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
10017 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +053010018 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010019 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010020 }
10021
Govind Singhb53420c2016-03-09 14:32:57 +053010022 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010023}
10024
10025/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010026 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
10027 * @wmi_handle: wmi handle
10028 * @pAddPeriodicTxPtrnParams: tx ptrn params
10029 *
10030 * Retrun: CDF status
10031 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010032static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010033 struct periodic_tx_pattern *
10034 pAddPeriodicTxPtrnParams,
10035 uint8_t vdev_id)
10036{
10037 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10038 wmi_buf_t wmi_buf;
10039 uint32_t len;
10040 uint8_t *buf_ptr;
10041 uint32_t ptrn_len, ptrn_len_aligned;
10042 int j;
10043
10044 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
10045 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
10046 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
10047 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
10048
10049 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10050 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010051 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10052 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010053 }
10054
10055 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10056
10057 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
10058 WMITLV_SET_HDR(&cmd->tlv_header,
10059 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10060 WMITLV_GET_STRUCT_TLVLEN
10061 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10062
10063 /* Pass the pattern id to delete for the corresponding vdev id */
10064 cmd->vdev_id = vdev_id;
10065 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
10066 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
10067 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
10068
10069 /* Pattern info */
10070 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10071 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
10072 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010073 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010074 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +053010075 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +053010076
Govind Singhb53420c2016-03-09 14:32:57 +053010077 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010078 __func__, cmd->pattern_id, cmd->vdev_id);
10079
10080 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10081 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010082 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010083 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010084 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010085 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010086 }
Govind Singhb53420c2016-03-09 14:32:57 +053010087 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010088}
10089
10090/**
10091 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
10092 * @wmi_handle: wmi handle
10093 * @vdev_id: vdev id
10094 * @pattern_id: pattern id
10095 *
10096 * Retrun: CDF status
10097 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010098static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010099 uint8_t vdev_id,
10100 uint8_t pattern_id)
10101{
10102 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10103 wmi_buf_t wmi_buf;
10104 uint32_t len =
10105 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10106
10107 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10108 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010109 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10110 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010111 }
10112
10113 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
10114 wmi_buf_data(wmi_buf);
10115 WMITLV_SET_HDR(&cmd->tlv_header,
10116 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10117 WMITLV_GET_STRUCT_TLVLEN
10118 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10119
10120 /* Pass the pattern id to delete for the corresponding vdev id */
10121 cmd->vdev_id = vdev_id;
10122 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +053010123 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010124 __func__, cmd->pattern_id, cmd->vdev_id);
10125
10126 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10127 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010128 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010129 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010130 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010131 }
Govind Singhb53420c2016-03-09 14:32:57 +053010132 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010133}
10134
10135/**
10136 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
10137 * @wmi_handle: wmi handle
10138 * @preq: stats ext params
10139 *
10140 * Return: CDF status
10141 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010142static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010143 struct stats_ext_params *preq)
10144{
Govind Singh67922e82016-04-01 16:48:57 +053010145 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010146 wmi_req_stats_ext_cmd_fixed_param *cmd;
10147 wmi_buf_t buf;
10148 uint16_t len;
10149 uint8_t *buf_ptr;
10150
10151 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
10152
10153 buf = wmi_buf_alloc(wmi_handle, len);
10154 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010155 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010156 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010157 }
10158
10159 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10160 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
10161
10162 WMITLV_SET_HDR(&cmd->tlv_header,
10163 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
10164 WMITLV_GET_STRUCT_TLVLEN
10165 (wmi_req_stats_ext_cmd_fixed_param));
10166 cmd->vdev_id = preq->vdev_id;
10167 cmd->data_len = preq->request_data_len;
10168
Govind Singhb53420c2016-03-09 14:32:57 +053010169 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +053010170 __func__, preq->request_data_len, preq->vdev_id);
10171
10172 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
10173 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
10174
10175 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010176 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010177
10178 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10179 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010180 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010181 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +053010182 ret);
10183 wmi_buf_free(buf);
10184 }
10185
10186 return ret;
10187}
10188
10189/**
10190 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
10191 * @wmi_handle: wmi handle
10192 * @params: ext wow params
10193 *
10194 * Return:0 for success or error code
10195 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010196static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010197 struct ext_wow_params *params)
10198{
10199 wmi_extwow_enable_cmd_fixed_param *cmd;
10200 wmi_buf_t buf;
10201 int32_t len;
10202 int ret;
10203
10204 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
10205 buf = wmi_buf_alloc(wmi_handle, len);
10206 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010207 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10208 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010209 }
10210
10211 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
10212
10213 WMITLV_SET_HDR(&cmd->tlv_header,
10214 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
10215 WMITLV_GET_STRUCT_TLVLEN
10216 (wmi_extwow_enable_cmd_fixed_param));
10217
10218 cmd->vdev_id = params->vdev_id;
10219 cmd->type = params->type;
10220 cmd->wakeup_pin_num = params->wakeup_pin_num;
10221
Govind Singhb53420c2016-03-09 14:32:57 +053010222 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +053010223 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
10224
10225 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10226 WMI_EXTWOW_ENABLE_CMDID);
10227 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010228 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010229 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010230 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010231 }
10232
Govind Singhb53420c2016-03-09 14:32:57 +053010233 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010234
10235}
10236
10237/**
10238 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
10239 * @wmi_handle: wmi handle
10240 * @app_type1_params: app type1 params
10241 *
10242 * Return: CDF status
10243 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010244static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010245 struct app_type1_params *app_type1_params)
10246{
10247 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
10248 wmi_buf_t buf;
10249 int32_t len;
10250 int ret;
10251
10252 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
10253 buf = wmi_buf_alloc(wmi_handle, len);
10254 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010255 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10256 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010257 }
10258
10259 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
10260 wmi_buf_data(buf);
10261
10262 WMITLV_SET_HDR(&cmd->tlv_header,
10263 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
10264 WMITLV_GET_STRUCT_TLVLEN
10265 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
10266
10267 cmd->vdev_id = app_type1_params->vdev_id;
10268 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
10269 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +053010270 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +053010271 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +053010272 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010273 cmd->passwd_len = app_type1_params->pass_length;
10274
Govind Singhb53420c2016-03-09 14:32:57 +053010275 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010276 "identification_id %.8s id_length %u "
10277 "password %.16s pass_length %u",
10278 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
10279 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
10280
10281 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10282 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
10283 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010284 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010285 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010286 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010287 }
10288
Govind Singhb53420c2016-03-09 14:32:57 +053010289 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010290}
10291
10292/**
10293 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
10294 * @wmi_handle: wmi handle
10295 * @appType2Params: app type2 params
10296 *
10297 * Return: CDF status
10298 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010299static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010300 struct app_type2_params *appType2Params)
10301{
10302 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
10303 wmi_buf_t buf;
10304 int32_t len;
10305 int ret;
10306
10307 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
10308 buf = wmi_buf_alloc(wmi_handle, len);
10309 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010310 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10311 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010312 }
10313
10314 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
10315 wmi_buf_data(buf);
10316
10317 WMITLV_SET_HDR(&cmd->tlv_header,
10318 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
10319 WMITLV_GET_STRUCT_TLVLEN
10320 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
10321
10322 cmd->vdev_id = appType2Params->vdev_id;
10323
Govind Singhb53420c2016-03-09 14:32:57 +053010324 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010325 cmd->rc4_key_len = appType2Params->rc4_key_len;
10326
10327 cmd->ip_id = appType2Params->ip_id;
10328 cmd->ip_device_ip = appType2Params->ip_device_ip;
10329 cmd->ip_server_ip = appType2Params->ip_server_ip;
10330
10331 cmd->tcp_src_port = appType2Params->tcp_src_port;
10332 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
10333 cmd->tcp_seq = appType2Params->tcp_seq;
10334 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
10335
10336 cmd->keepalive_init = appType2Params->keepalive_init;
10337 cmd->keepalive_min = appType2Params->keepalive_min;
10338 cmd->keepalive_max = appType2Params->keepalive_max;
10339 cmd->keepalive_inc = appType2Params->keepalive_inc;
10340
10341 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
10342 &cmd->gateway_mac);
10343 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
10344 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
10345
Govind Singhb53420c2016-03-09 14:32:57 +053010346 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010347 "rc4_key %.16s rc4_key_len %u "
10348 "ip_id %x ip_device_ip %x ip_server_ip %x "
10349 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
10350 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
10351 "keepalive_max %u keepalive_inc %u "
10352 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
10353 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
10354 cmd->rc4_key, cmd->rc4_key_len,
10355 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
10356 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
10357 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
10358 cmd->keepalive_max, cmd->keepalive_inc,
10359 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
10360
10361 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10362 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
10363 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010364 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010365 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010366 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010367 }
10368
Govind Singhb53420c2016-03-09 14:32:57 +053010369 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010370
10371}
10372
10373/**
10374 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
10375 * @wmi_handle: wmi handle
10376 * @timer_val: auto shutdown timer value
10377 *
10378 * Return: CDF status
10379 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010380static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010381 uint32_t timer_val)
10382{
Govind Singh67922e82016-04-01 16:48:57 +053010383 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010384 wmi_buf_t buf = NULL;
10385 uint8_t *buf_ptr;
10386 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
10387 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
10388
Govind Singhb53420c2016-03-09 14:32:57 +053010389 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010390 __func__, timer_val);
10391
10392 buf = wmi_buf_alloc(wmi_handle, len);
10393 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010394 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10395 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010396 }
10397
10398 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10399 wmi_auto_sh_cmd =
10400 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
10401 wmi_auto_sh_cmd->timer_value = timer_val;
10402
10403 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
10404 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
10405 WMITLV_GET_STRUCT_TLVLEN
10406 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
10407
10408 status = wmi_unified_cmd_send(wmi_handle, buf,
10409 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010410 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010411 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010412 __func__, status);
10413 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010414 }
10415
Govind Singh67922e82016-04-01 16:48:57 +053010416 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010417}
10418
10419/**
10420 * send_nan_req_cmd_tlv() - to send nan request to target
10421 * @wmi_handle: wmi handle
10422 * @nan_req: request data which will be non-null
10423 *
10424 * Return: CDF status
10425 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010426static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010427 struct nan_req_params *nan_req)
10428{
Govind Singh67922e82016-04-01 16:48:57 +053010429 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010430 wmi_nan_cmd_param *cmd;
10431 wmi_buf_t buf;
10432 uint16_t len = sizeof(*cmd);
10433 uint16_t nan_data_len, nan_data_len_aligned;
10434 uint8_t *buf_ptr;
10435
10436 /*
10437 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
10438 * +------------+----------+-----------------------+--------------+
10439 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
10440 * +------------+----------+-----------------------+--------------+
10441 */
10442 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +053010443 WMI_LOGE("%s:nan req is not valid", __func__);
10444 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010445 }
10446 nan_data_len = nan_req->request_data_len;
10447 nan_data_len_aligned = roundup(nan_req->request_data_len,
10448 sizeof(uint32_t));
10449 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
10450 buf = wmi_buf_alloc(wmi_handle, len);
10451 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010452 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
10453 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010454 }
10455 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10456 cmd = (wmi_nan_cmd_param *) buf_ptr;
10457 WMITLV_SET_HDR(&cmd->tlv_header,
10458 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
10459 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
10460 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +053010461 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +053010462 __func__, nan_req->request_data_len);
10463 buf_ptr += sizeof(wmi_nan_cmd_param);
10464 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
10465 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010466 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010467
10468 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10469 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010470 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010471 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010472 __func__, ret);
10473 wmi_buf_free(buf);
10474 }
10475
10476 return ret;
10477}
10478
10479/**
10480 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
10481 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -070010482 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +053010483 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010484 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010485 */
Jeff Johnsona87370f2017-10-04 19:19:20 -070010486static QDF_STATUS
10487send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
10488 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +053010489{
10490 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
10491 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +053010492 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010493
10494 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10495 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010496 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +053010497 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010498 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010499 }
10500
10501 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010502
10503 WMITLV_SET_HDR(&cmd->tlv_header,
10504 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
10505 WMITLV_GET_STRUCT_TLVLEN
10506 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -070010507 cmd->vdev_id = params->vdev_id;
10508 cmd->enable = params->dhcp_offload_enabled;
10509 cmd->num_client = params->dhcp_client_num;
10510 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +053010511 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +053010512 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +053010513 sizeof(*cmd),
10514 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010515 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010516 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +053010517 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010518 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010519 }
Govind Singhb53420c2016-03-09 14:32:57 +053010520 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -070010521 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +053010522
10523 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010524}
10525
10526/**
10527 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
10528 * @wmi_handle: wmi handle
10529 * @flashing: flashing request
10530 *
10531 * Return: CDF status
10532 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010533static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010534 struct flashing_req_params *flashing)
10535{
10536 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +053010537 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010538 wmi_buf_t buf;
10539 uint8_t *buf_ptr;
10540 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
10541
10542 buf = wmi_buf_alloc(wmi_handle, len);
10543 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010544 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +053010545 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010546 }
10547 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10548 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
10549 WMITLV_SET_HDR(&cmd->tlv_header,
10550 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
10551 WMITLV_GET_STRUCT_TLVLEN
10552 (wmi_set_led_flashing_cmd_fixed_param));
10553 cmd->pattern_id = flashing->pattern_id;
10554 cmd->led_x0 = flashing->led_x0;
10555 cmd->led_x1 = flashing->led_x1;
10556
10557 status = wmi_unified_cmd_send(wmi_handle, buf, len,
10558 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010559 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010560 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +053010561 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010562 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010563 }
Govind Singh67922e82016-04-01 16:48:57 +053010564
10565 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010566}
10567
10568/**
10569 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
10570 * @wmi_handle: wmi handle
10571 * @ch_avoid_update_req: channel avoid update params
10572 *
10573 * Return: CDF status
10574 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010575static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +053010576{
Govind Singh67922e82016-04-01 16:48:57 +053010577 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010578 wmi_buf_t buf = NULL;
10579 uint8_t *buf_ptr;
10580 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
10581 int len = sizeof(wmi_chan_avoid_update_cmd_param);
10582
10583
10584 buf = wmi_buf_alloc(wmi_handle, len);
10585 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010586 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10587 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010588 }
10589
10590 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10591 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
10592 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
10593 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
10594 WMITLV_GET_STRUCT_TLVLEN
10595 (wmi_chan_avoid_update_cmd_param));
10596
10597 status = wmi_unified_cmd_send(wmi_handle, buf,
10598 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010599 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010600 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +053010601 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
10602 " returned Error %d", status);
10603 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010604 }
10605
Govind Singh67922e82016-04-01 16:48:57 +053010606 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010607}
10608
10609/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010610 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
10611 * @wmi_handle: wmi handle
10612 * @param: pointer to pdev regdomain params
10613 *
10614 * Return: 0 for success or error code
10615 */
10616static QDF_STATUS
10617send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
10618 struct pdev_set_regdomain_params *param)
10619{
10620 wmi_buf_t buf;
10621 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10622 int32_t len = sizeof(*cmd);
10623
10624
10625 buf = wmi_buf_alloc(wmi_handle, len);
10626 if (!buf) {
10627 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10628 return QDF_STATUS_E_NOMEM;
10629 }
10630 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10631 WMITLV_SET_HDR(&cmd->tlv_header,
10632 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10633 WMITLV_GET_STRUCT_TLVLEN
10634 (wmi_pdev_set_regdomain_cmd_fixed_param));
10635
10636 cmd->reg_domain = param->currentRDinuse;
10637 cmd->reg_domain_2G = param->currentRD2G;
10638 cmd->reg_domain_5G = param->currentRD5G;
10639 cmd->conformance_test_limit_2G = param->ctl_2G;
10640 cmd->conformance_test_limit_5G = param->ctl_5G;
10641 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010642 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10643 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010644
10645 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10646 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
10647 WMI_LOGE("%s: Failed to send pdev set regdomain command",
10648 __func__);
10649 wmi_buf_free(buf);
10650 return QDF_STATUS_E_FAILURE;
10651 }
10652
10653 return QDF_STATUS_SUCCESS;
10654}
10655
10656/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010657 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
10658 * @wmi_handle: wmi handle
10659 * @reg_dmn: reg domain
10660 * @regdmn2G: 2G reg domain
10661 * @regdmn5G: 5G reg domain
10662 * @ctl2G: 2G test limit
10663 * @ctl5G: 5G test limit
10664 *
10665 * Return: none
10666 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010667static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010668 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +053010669 uint16_t regdmn5G, uint8_t ctl2G,
10670 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +053010671{
10672 wmi_buf_t buf;
10673 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10674 int32_t len = sizeof(*cmd);
10675
10676
10677 buf = wmi_buf_alloc(wmi_handle, len);
10678 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010679 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10680 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010681 }
10682 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10683 WMITLV_SET_HDR(&cmd->tlv_header,
10684 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10685 WMITLV_GET_STRUCT_TLVLEN
10686 (wmi_pdev_set_regdomain_cmd_fixed_param));
10687 cmd->reg_domain = reg_dmn;
10688 cmd->reg_domain_2G = regdmn2G;
10689 cmd->reg_domain_5G = regdmn5G;
10690 cmd->conformance_test_limit_2G = ctl2G;
10691 cmd->conformance_test_limit_5G = ctl5G;
10692
10693 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10694 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010695 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010696 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010697 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010698 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010699 }
10700
Govind Singhb53420c2016-03-09 14:32:57 +053010701 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010702}
10703
10704
10705/**
10706 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10707 * @wmi_handle: wmi handle
10708 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10709 *
10710 * This function sets tdls off channel mode
10711 *
10712 * Return: 0 on success; Negative errno otherwise
10713 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010714static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010715 struct tdls_channel_switch_params *chan_switch_params)
10716{
10717 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10718 wmi_buf_t wmi_buf;
10719 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10720
10721 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10722 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010723 WMI_LOGE(FL("wmi_buf_alloc failed"));
10724 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010725 }
10726 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10727 wmi_buf_data(wmi_buf);
10728 WMITLV_SET_HDR(&cmd->tlv_header,
10729 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10730 WMITLV_GET_STRUCT_TLVLEN(
10731 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10732
10733 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10734 &cmd->peer_macaddr);
10735 cmd->vdev_id = chan_switch_params->vdev_id;
10736 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10737 cmd->is_peer_responder = chan_switch_params->is_responder;
10738 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10739 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10740 cmd->offchan_oper_class = chan_switch_params->oper_class;
10741
Govind Singhb53420c2016-03-09 14:32:57 +053010742 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010743 cmd->peer_macaddr.mac_addr31to0,
10744 cmd->peer_macaddr.mac_addr47to32);
10745
Govind Singhb53420c2016-03-09 14:32:57 +053010746 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010747 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10748 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10749 ),
10750 cmd->vdev_id,
10751 cmd->offchan_mode,
10752 cmd->offchan_num,
10753 cmd->offchan_bw_bitmap,
10754 cmd->is_peer_responder,
10755 cmd->offchan_oper_class);
10756
10757 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10758 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010759 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010760 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010761 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010762 }
10763
10764
Govind Singhb53420c2016-03-09 14:32:57 +053010765 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010766}
10767
10768/**
10769 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10770 * @wmi_handle: wmi handle
10771 * @pwmaTdlsparams: TDLS params
10772 *
10773 * Return: 0 for sucess or error code
10774 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010775static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010776 void *tdls_param, uint8_t tdls_state)
10777{
10778 wmi_tdls_set_state_cmd_fixed_param *cmd;
10779 wmi_buf_t wmi_buf;
10780
10781 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10782 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10783
10784 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10785 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010786 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10787 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010788 }
10789 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10790 WMITLV_SET_HDR(&cmd->tlv_header,
10791 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10792 WMITLV_GET_STRUCT_TLVLEN
10793 (wmi_tdls_set_state_cmd_fixed_param));
10794 cmd->vdev_id = wmi_tdls->vdev_id;
10795 cmd->state = tdls_state;
10796 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10797 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10798 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10799 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10800 cmd->rssi_delta = wmi_tdls->rssi_delta;
10801 cmd->tdls_options = wmi_tdls->tdls_options;
10802 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10803 cmd->tdls_peer_traffic_response_timeout_ms =
10804 wmi_tdls->peer_traffic_response_timeout;
10805 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10806 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10807 cmd->tdls_puapsd_rx_frame_threshold =
10808 wmi_tdls->puapsd_rx_frame_threshold;
10809 cmd->teardown_notification_ms =
10810 wmi_tdls->teardown_notification_ms;
10811 cmd->tdls_peer_kickout_threshold =
10812 wmi_tdls->tdls_peer_kickout_threshold;
10813
Govind Singhb53420c2016-03-09 14:32:57 +053010814 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010815 "notification_interval_ms: %d, "
10816 "tx_discovery_threshold: %d, "
10817 "tx_teardown_threshold: %d, "
10818 "rssi_teardown_threshold: %d, "
10819 "rssi_delta: %d, "
10820 "tdls_options: 0x%x, "
10821 "tdls_peer_traffic_ind_window: %d, "
10822 "tdls_peer_traffic_response_timeout: %d, "
10823 "tdls_puapsd_mask: 0x%x, "
10824 "tdls_puapsd_inactivity_time: %d, "
10825 "tdls_puapsd_rx_frame_threshold: %d, "
10826 "teardown_notification_ms: %d, "
10827 "tdls_peer_kickout_threshold: %d",
10828 __func__, tdls_state, cmd->state,
10829 cmd->notification_interval_ms,
10830 cmd->tx_discovery_threshold,
10831 cmd->tx_teardown_threshold,
10832 cmd->rssi_teardown_threshold,
10833 cmd->rssi_delta,
10834 cmd->tdls_options,
10835 cmd->tdls_peer_traffic_ind_window,
10836 cmd->tdls_peer_traffic_response_timeout_ms,
10837 cmd->tdls_puapsd_mask,
10838 cmd->tdls_puapsd_inactivity_time_ms,
10839 cmd->tdls_puapsd_rx_frame_threshold,
10840 cmd->teardown_notification_ms,
10841 cmd->tdls_peer_kickout_threshold);
10842
10843 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10844 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010845 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010846 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010847 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010848 }
Govind Singhb53420c2016-03-09 14:32:57 +053010849 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010850
Govind Singhb53420c2016-03-09 14:32:57 +053010851 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010852}
10853
10854/**
10855 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10856 * @wmi_handle: wmi handle
10857 * @peerStateParams: TDLS peer state params
10858 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010859 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010860 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010861static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010862 struct tdls_peer_state_params *peerStateParams,
10863 uint32_t *ch_mhz)
10864{
10865 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10866 wmi_tdls_peer_capabilities *peer_cap;
10867 wmi_channel *chan_info;
10868 wmi_buf_t wmi_buf;
10869 uint8_t *buf_ptr;
10870 uint32_t i;
10871 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10872 sizeof(wmi_tdls_peer_capabilities);
10873
10874
10875 len += WMI_TLV_HDR_SIZE +
10876 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10877
10878 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10879 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010880 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10881 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010882 }
10883
10884 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10885 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10886 WMITLV_SET_HDR(&cmd->tlv_header,
10887 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10888 WMITLV_GET_STRUCT_TLVLEN
10889 (wmi_tdls_peer_update_cmd_fixed_param));
10890
10891 cmd->vdev_id = peerStateParams->vdevId;
10892 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10893 &cmd->peer_macaddr);
10894
10895
10896 cmd->peer_state = peerStateParams->peerState;
10897
Govind Singhb53420c2016-03-09 14:32:57 +053010898 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010899 "peer_macaddr.mac_addr31to0: 0x%x, "
10900 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10901 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10902 cmd->peer_macaddr.mac_addr31to0,
10903 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10904
10905 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10906 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10907 WMITLV_SET_HDR(&peer_cap->tlv_header,
10908 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10909 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10910
10911 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10912 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10913 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10914 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10915 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10916 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10917 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10918 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10919
10920 /* Ack and More Data Ack are sent as 0, so no need to set
10921 * but fill SP
10922 */
10923 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10924 peerStateParams->peerCap.peerMaxSp);
10925
10926 peer_cap->buff_sta_support =
10927 peerStateParams->peerCap.peerBuffStaSupport;
10928 peer_cap->off_chan_support =
10929 peerStateParams->peerCap.peerOffChanSupport;
10930 peer_cap->peer_curr_operclass =
10931 peerStateParams->peerCap.peerCurrOperClass;
10932 /* self curr operclass is not being used and so pass op class for
10933 * preferred off chan in it.
10934 */
10935 peer_cap->self_curr_operclass =
10936 peerStateParams->peerCap.opClassForPrefOffChan;
10937 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10938 peer_cap->peer_operclass_len =
10939 peerStateParams->peerCap.peerOperClassLen;
10940
Govind Singhb53420c2016-03-09 14:32:57 +053010941 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010942 __func__, peer_cap->peer_operclass_len);
10943 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10944 peer_cap->peer_operclass[i] =
10945 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010946 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010947 __func__, i, peer_cap->peer_operclass[i]);
10948 }
10949
10950 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10951 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10952 peer_cap->pref_offchan_bw =
10953 peerStateParams->peerCap.prefOffChanBandwidth;
10954
Govind Singhb53420c2016-03-09 14:32:57 +053010955 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010956 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10957 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10958 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10959 " %d, pref_offchan_bw: %d",
10960 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10961 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10962 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10963 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10964 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10965
10966 /* next fill variable size array of peer chan info */
10967 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10968 WMITLV_SET_HDR(buf_ptr,
10969 WMITLV_TAG_ARRAY_STRUC,
10970 sizeof(wmi_channel) *
10971 peerStateParams->peerCap.peerChanLen);
10972 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10973
10974 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10975 WMITLV_SET_HDR(&chan_info->tlv_header,
10976 WMITLV_TAG_STRUC_wmi_channel,
10977 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10978 chan_info->mhz = ch_mhz[i];
10979 chan_info->band_center_freq1 = chan_info->mhz;
10980 chan_info->band_center_freq2 = 0;
10981
Govind Singhb53420c2016-03-09 14:32:57 +053010982 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010983
10984 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10985 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010986 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010987 peerStateParams->peerCap.peerChan[i].chanId,
10988 peerStateParams->peerCap.peerChan[i].dfsSet);
10989 }
10990
10991 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10992 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10993 else
10994 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10995
10996 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10997 peerStateParams->peerCap.
10998 peerChan[i].pwr);
10999
11000 WMI_SET_CHANNEL_REG_POWER(chan_info,
11001 peerStateParams->peerCap.peerChan[i].
11002 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053011003 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053011004 peerStateParams->peerCap.peerChan[i].pwr);
11005
11006 chan_info++;
11007 }
11008
11009 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
11010 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011011 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053011012 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011013 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011014 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053011015 }
11016
11017
Govind Singhb53420c2016-03-09 14:32:57 +053011018 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053011019}
11020
11021/*
Govind Singh20c5dac2016-03-07 15:33:31 +053011022 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
11023 * @wmi_handle: Pointer to WMi handle
11024 * @ie_data: Pointer for ie data
11025 *
11026 * This function sends IE information to firmware
11027 *
Govind Singhb53420c2016-03-09 14:32:57 +053011028 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053011029 *
11030 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011031static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053011032 struct vdev_ie_info_param *ie_info)
11033{
11034 wmi_vdev_set_ie_cmd_fixed_param *cmd;
11035 wmi_buf_t buf;
11036 uint8_t *buf_ptr;
11037 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053011038 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053011039
11040
11041 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
11042 /* Allocate memory for the WMI command */
11043 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
11044
11045 buf = wmi_buf_alloc(wmi_handle, len);
11046 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011047 WMI_LOGE(FL("wmi_buf_alloc failed"));
11048 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053011049 }
11050
11051 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011052 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011053
11054 /* Populate the WMI command */
11055 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
11056
11057 WMITLV_SET_HDR(&cmd->tlv_header,
11058 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
11059 WMITLV_GET_STRUCT_TLVLEN(
11060 wmi_vdev_set_ie_cmd_fixed_param));
11061 cmd->vdev_id = ie_info->vdev_id;
11062 cmd->ie_id = ie_info->ie_id;
11063 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070011064 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053011065
Govind Singhb53420c2016-03-09 14:32:57 +053011066 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053011067 ie_info->length, ie_info->vdev_id);
11068
11069 buf_ptr += sizeof(*cmd);
11070 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
11071 buf_ptr += WMI_TLV_HDR_SIZE;
11072
Govind Singhb53420c2016-03-09 14:32:57 +053011073 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011074
11075 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11076 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011077 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011078 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053011079 wmi_buf_free(buf);
11080 }
11081
11082 return ret;
11083}
11084
Sathish Kumar497bef42017-03-01 14:02:36 +053011085/**
11086 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
11087 *
11088 * @param wmi_handle : handle to WMI.
11089 * @param param : pointer to antenna param
11090 *
11091 * This function sends smart antenna enable command to FW
11092 *
11093 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11094 */
11095static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
11096 struct smart_ant_enable_params *param)
11097{
11098 /* Send WMI COMMAND to Enable */
11099 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
11100 wmi_pdev_smart_ant_gpio_handle *gpio_param;
11101 wmi_buf_t buf;
11102 uint8_t *buf_ptr;
11103 int len = 0;
11104 QDF_STATUS ret;
11105 int loop = 0;
11106
11107 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11108 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
11109 buf = wmi_buf_alloc(wmi_handle, len);
11110
11111 if (!buf) {
11112 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11113 return QDF_STATUS_E_NOMEM;
11114 }
11115
11116 buf_ptr = wmi_buf_data(buf);
11117 qdf_mem_zero(buf_ptr, len);
11118 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
11119
11120 WMITLV_SET_HDR(&cmd->tlv_header,
11121 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
11122 WMITLV_GET_STRUCT_TLVLEN(
11123 wmi_pdev_smart_ant_enable_cmd_fixed_param));
11124
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011125 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11126 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011127 cmd->enable = param->enable;
11128 cmd->mode = param->mode;
11129 cmd->rx_antenna = param->rx_antenna;
11130 cmd->tx_default_antenna = param->rx_antenna;
11131
11132 /* TLV indicating array of structures to follow */
11133 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
11134 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11135 WMI_HAL_MAX_SANTENNA *
11136 sizeof(wmi_pdev_smart_ant_gpio_handle));
11137
11138 buf_ptr += WMI_TLV_HDR_SIZE;
11139 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
11140
11141 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
11142 WMITLV_SET_HDR(&gpio_param->tlv_header,
11143 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
11144 WMITLV_GET_STRUCT_TLVLEN(
11145 wmi_pdev_smart_ant_gpio_handle));
11146 if (param->mode == SMART_ANT_MODE_SERIAL) {
11147 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
11148 gpio_param->gpio_pin = param->gpio_pin[loop];
11149 gpio_param->gpio_func = param->gpio_func[loop];
11150 } else {
11151 gpio_param->gpio_pin = 0;
11152 gpio_param->gpio_func = 0;
11153 }
11154 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
11155 gpio_param->gpio_pin = param->gpio_pin[loop];
11156 gpio_param->gpio_func = param->gpio_func[loop];
11157 }
11158 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011159 gpio_param->pdev_id =
11160 wmi_handle->ops->convert_pdev_id_host_to_target(
11161 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011162 gpio_param++;
11163 }
11164
11165 ret = wmi_unified_cmd_send(wmi_handle,
11166 buf,
11167 len,
11168 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
11169
11170 if (ret != 0) {
11171 WMI_LOGE(" %s :WMI Failed\n", __func__);
11172 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
11173 cmd->enable,
11174 cmd->mode,
11175 cmd->rx_antenna,
11176 param->gpio_pin[0], param->gpio_pin[1],
11177 param->gpio_pin[2], param->gpio_pin[3],
11178 param->gpio_func[0], param->gpio_func[1],
11179 param->gpio_func[2], param->gpio_func[3],
11180 ret);
11181 wmi_buf_free(buf);
11182 }
11183
11184 return ret;
11185}
11186
11187/**
11188 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
11189 *
11190 * @param wmi_handle : handle to WMI.
11191 * @param param : pointer to rx antenna param
11192 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11193 */
11194static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11195 struct smart_ant_rx_ant_params *param)
11196{
11197 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
11198 wmi_buf_t buf;
11199 uint8_t *buf_ptr;
11200 uint32_t len;
11201 QDF_STATUS ret;
11202
11203 len = sizeof(*cmd);
11204 buf = wmi_buf_alloc(wmi_handle, len);
11205 WMI_LOGD("%s:\n", __func__);
11206 if (!buf) {
11207 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11208 return QDF_STATUS_E_NOMEM;
11209 }
11210
11211 buf_ptr = wmi_buf_data(buf);
11212 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
11213 WMITLV_SET_HDR(&cmd->tlv_header,
11214 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
11215 WMITLV_GET_STRUCT_TLVLEN(
11216 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
11217 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011218 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11219 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011220
11221 ret = wmi_unified_cmd_send(wmi_handle,
11222 buf,
11223 len,
11224 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
11225
11226 if (ret != 0) {
11227 WMI_LOGE(" %s :WMI Failed\n", __func__);
11228 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
11229 __func__,
11230 cmd->rx_antenna,
11231 ret);
11232 wmi_buf_free(buf);
11233 }
11234
11235 return ret;
11236}
11237
11238/**
11239 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
11240 * @wmi_handle: wmi handle
11241 * @param: pointer to hold ctl table param
11242 *
11243 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11244 */
11245static QDF_STATUS
11246send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
11247 struct ctl_table_params *param)
11248{
11249 uint16_t len, ctl_tlv_len;
11250 uint8_t *buf_ptr;
11251 wmi_buf_t buf;
11252 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
11253 uint32_t *ctl_array;
11254
11255 if (!param->ctl_array)
11256 return QDF_STATUS_E_FAILURE;
11257
Sathish Kumar497bef42017-03-01 14:02:36 +053011258 ctl_tlv_len = WMI_TLV_HDR_SIZE +
11259 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
11260 len = sizeof(*cmd) + ctl_tlv_len;
11261
11262 buf = wmi_buf_alloc(wmi_handle, len);
11263 if (!buf) {
11264 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11265 return QDF_STATUS_E_FAILURE;
11266 }
11267
11268 buf_ptr = wmi_buf_data(buf);
11269 qdf_mem_zero(buf_ptr, len);
11270
11271 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
11272
11273 WMITLV_SET_HDR(&cmd->tlv_header,
11274 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
11275 WMITLV_GET_STRUCT_TLVLEN(
11276 wmi_pdev_set_ctl_table_cmd_fixed_param));
11277 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011278 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11279 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011280
11281 buf_ptr += sizeof(*cmd);
11282 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11283 (cmd->ctl_len));
11284 buf_ptr += WMI_TLV_HDR_SIZE;
11285 ctl_array = (uint32_t *)buf_ptr;
11286
11287 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
11288 sizeof(param->ctl_band));
11289 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
11290 param->ctl_cmd_len -
11291 sizeof(param->ctl_band));
11292
11293 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11294 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
11295 WMI_LOGE("%s:Failed to send command\n", __func__);
11296 wmi_buf_free(buf);
11297 return QDF_STATUS_E_FAILURE;
11298 }
11299
11300 return QDF_STATUS_SUCCESS;
11301}
11302
11303/**
11304 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
11305 * @wmi_handle: wmi handle
11306 * @param: pointer to hold mimogain table param
11307 *
11308 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11309 */
11310static QDF_STATUS
11311send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
11312 struct mimogain_table_params *param)
11313{
11314 uint16_t len, table_tlv_len;
11315 wmi_buf_t buf;
11316 uint8_t *buf_ptr;
11317 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
11318 uint32_t *gain_table;
11319
11320 if (!param->array_gain)
11321 return QDF_STATUS_E_FAILURE;
11322
11323 /* len must be multiple of a single array gain table */
11324 if (param->tbl_len %
11325 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
11326 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
11327 WMI_LOGE("Array gain table len not correct\n");
11328 return QDF_STATUS_E_FAILURE;
11329 }
11330
11331 table_tlv_len = WMI_TLV_HDR_SIZE +
11332 roundup(param->tbl_len, sizeof(uint32_t));
11333 len = sizeof(*cmd) + table_tlv_len;
11334
11335 buf = wmi_buf_alloc(wmi_handle, len);
11336 if (!buf) {
11337 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11338 return QDF_STATUS_E_FAILURE;
11339 }
11340
11341 buf_ptr = wmi_buf_data(buf);
11342 qdf_mem_zero(buf_ptr, len);
11343
11344 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
11345
11346 WMITLV_SET_HDR(&cmd->tlv_header,
11347 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
11348 WMITLV_GET_STRUCT_TLVLEN(
11349 wmi_pdev_set_mimogain_table_cmd_fixed_param));
11350
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011351 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11352 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011353 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
11354 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
11355 param->multichain_gain_bypass);
11356
11357 buf_ptr += sizeof(*cmd);
11358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11359 (param->tbl_len));
11360 buf_ptr += WMI_TLV_HDR_SIZE;
11361 gain_table = (uint32_t *)buf_ptr;
11362
11363 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
11364 param->array_gain,
11365 param->tbl_len);
11366
11367 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11368 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
11369 return QDF_STATUS_E_FAILURE;
11370 }
11371
11372 return QDF_STATUS_SUCCESS;
11373}
11374
11375/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011376 * enum packet_power_tlv_flags: target defined
11377 * packet power rate flags for TLV
11378 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
11379 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
11380 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
11381 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
11382 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
11383 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
11384 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
11385 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
11386 * @WMI_TLV_FLAG_STBC: STBC is set
11387 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
11388 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
11389 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
11390 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
11391 * @WMI_TLV_FLAG_RTSENA: RTS enabled
11392 * @WMI_TLV_FLAG_CTSENA: CTS enabled
11393 * @WMI_TLV_FLAG_LDPC: LDPC is set
11394 * @WMI_TLV_FLAG_SGI: Short gaurd interval
11395 * @WMI_TLV_FLAG_SU: SU Data
11396 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
11397 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
11398 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
11399 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
11400 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
11401 *
11402 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
11403 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
11404 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
11405 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
11406 */
11407enum packet_power_tlv_flags {
11408 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
11409 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
11410 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
11411 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
11412 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
11413 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
11414 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
11415 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
11416 WMI_TLV_FLAG_STBC = 0x00000100,
11417 WMI_TLV_FLAG_40MHZ = 0x00000200,
11418 WMI_TLV_FLAG_80MHZ = 0x00000300,
11419 WMI_TLV_FLAG_160MHZ = 0x00000400,
11420 WMI_TLV_FLAG_TXBF = 0x00000800,
11421 WMI_TLV_FLAG_RTSENA = 0x00001000,
11422 WMI_TLV_FLAG_CTSENA = 0x00002000,
11423 WMI_TLV_FLAG_LDPC = 0x00004000,
11424 WMI_TLV_FLAG_SGI = 0x00008000,
11425 WMI_TLV_FLAG_SU = 0x00100000,
11426 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
11427 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
11428 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
11429 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
11430 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
11431
11432 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
11433 WMI_TLV_FLAG_BW_MASK = 0x3,
11434 WMI_TLV_FLAG_BW_SHIFT = 9,
11435 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
11436 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
11437};
11438
11439/**
11440 * convert_to_power_info_rate_flags() - convert packet_power_info_params
11441 * to FW understandable format
11442 * @param: pointer to hold packet power info param
11443 *
11444 * @return FW understandable 32 bit rate flags
11445 */
11446static uint32_t
11447convert_to_power_info_rate_flags(struct packet_power_info_params *param)
11448{
11449 uint32_t rateflags = 0;
11450
11451 if (param->chainmask)
11452 rateflags |=
11453 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
11454 if (param->chan_width)
11455 rateflags |=
11456 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
11457 << WMI_TLV_FLAG_BW_SHIFT);
11458 if (param->su_mu_ofdma)
11459 rateflags |=
11460 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
11461 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
11462 if (param->rate_flags & WMI_HOST_FLAG_STBC)
11463 rateflags |= WMI_TLV_FLAG_STBC;
11464 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
11465 rateflags |= WMI_TLV_FLAG_LDPC;
11466 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
11467 rateflags |= WMI_TLV_FLAG_TXBF;
11468 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
11469 rateflags |= WMI_TLV_FLAG_RTSENA;
11470 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
11471 rateflags |= WMI_TLV_FLAG_CTSENA;
11472 if (param->rate_flags & WMI_HOST_FLAG_SGI)
11473 rateflags |= WMI_TLV_FLAG_SGI;
11474
11475 return rateflags;
11476}
11477
11478/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011479 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
11480 * info to fw
11481 * @wmi_handle: wmi handle
11482 * @param: pointer to hold packet power info param
11483 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011484 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053011485 */
11486static QDF_STATUS
11487send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
11488 struct packet_power_info_params *param)
11489{
11490 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
11491 wmi_buf_t wmibuf;
11492 uint8_t *buf_ptr;
11493 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
11494
11495 wmibuf = wmi_buf_alloc(wmi_handle, len);
11496 if (wmibuf == NULL)
11497 return QDF_STATUS_E_NOMEM;
11498
11499 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
11500
11501 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
11502 WMITLV_SET_HDR(&cmd->tlv_header,
11503 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
11504 WMITLV_GET_STRUCT_TLVLEN(
11505 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011506 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11507 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011508 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053011509 cmd->nss = param->nss;
11510 cmd->preamble = param->preamble;
11511 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011512
11513 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
11514 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
11515 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
11516 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
11517
Sathish Kumar497bef42017-03-01 14:02:36 +053011518 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
11519 WMI_PDEV_GET_TPC_CMDID)) {
11520 WMI_LOGE(FL("Failed to get tpc command\n"));
11521 wmi_buf_free(wmibuf);
11522 return QDF_STATUS_E_FAILURE;
11523 }
11524
11525 return QDF_STATUS_SUCCESS;
11526}
11527
11528/**
11529 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
11530 * @wmi_handle: wmi handle
11531 * @param: pointer to hold config ratemask params
11532 *
11533 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11534 */
11535static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
11536 struct config_ratemask_params *param)
11537{
11538 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
11539 wmi_buf_t buf;
11540 int32_t len = sizeof(*cmd);
11541
11542 buf = wmi_buf_alloc(wmi_handle, len);
11543 if (!buf) {
11544 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11545 return QDF_STATUS_E_FAILURE;
11546 }
11547 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
11548 WMITLV_SET_HDR(&cmd->tlv_header,
11549 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
11550 WMITLV_GET_STRUCT_TLVLEN(
11551 wmi_vdev_config_ratemask_cmd_fixed_param));
11552 cmd->vdev_id = param->vdev_id;
11553 cmd->type = param->type;
11554 cmd->mask_lower32 = param->lower32;
11555 cmd->mask_higher32 = param->higher32;
11556 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
11557 param->vdev_id, param->type, param->lower32, param->higher32);
11558
11559 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11560 WMI_VDEV_RATEMASK_CMDID)) {
11561 WMI_LOGE("Seting vdev ratemask failed\n");
11562 wmi_buf_free(buf);
11563 return QDF_STATUS_E_FAILURE;
11564 }
11565
11566 return QDF_STATUS_SUCCESS;
11567}
11568
11569/**
Sathish Kumar6011c742017-11-08 14:49:58 +053011570 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
11571 * @param: param sent from the host side
11572 * @cmd: param to be sent to the fw side
11573 */
11574static inline void copy_custom_aggr_bitmap(
11575 struct set_custom_aggr_size_params *param,
11576 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
11577{
11578 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
11579 param->ac);
11580 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
11581 param->aggr_type);
11582 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11583 param->tx_aggr_size_disable);
11584 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11585 param->rx_aggr_size_disable);
11586 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
11587 param->tx_ac_enable);
11588}
11589
11590/**
11591 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
11592 * @wmi_handle: wmi handle
11593 * @param: pointer to hold custom aggr size params
11594 *
11595 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11596 */
11597static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
11598 wmi_unified_t wmi_handle,
11599 struct set_custom_aggr_size_params *param)
11600{
11601 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
11602 wmi_buf_t buf;
11603 int32_t len = sizeof(*cmd);
11604
11605 buf = wmi_buf_alloc(wmi_handle, len);
11606 if (!buf) {
11607 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11608 return QDF_STATUS_E_FAILURE;
11609 }
11610 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
11611 wmi_buf_data(buf);
11612 WMITLV_SET_HDR(&cmd->tlv_header,
11613 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
11614 WMITLV_GET_STRUCT_TLVLEN(
11615 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
11616 cmd->vdev_id = param->vdev_id;
11617 cmd->tx_aggr_size = param->tx_aggr_size;
11618 cmd->rx_aggr_size = param->rx_aggr_size;
11619 copy_custom_aggr_bitmap(param, cmd);
11620
11621 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
11622 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
11623 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
11624 "tx_ac_enable=0x%X\n",
11625 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
11626 param->ac, param->aggr_type, param->tx_aggr_size_disable,
11627 param->rx_aggr_size_disable, param->tx_ac_enable);
11628
11629 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11630 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
11631 WMI_LOGE("Seting custom aggregation size failed\n");
11632 wmi_buf_free(buf);
11633 return QDF_STATUS_E_FAILURE;
11634 }
11635
11636 return QDF_STATUS_SUCCESS;
11637}
11638
11639/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011640 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
11641 * @param wmi_handle : handle to WMI.
11642 * @param param : pointer to tx antenna param
11643 *
11644 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11645 */
11646
11647static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
11648 struct set_qdepth_thresh_params *param)
11649{
11650 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
11651 wmi_msduq_qdepth_thresh_update *cmd_update;
11652 wmi_buf_t buf;
11653 int32_t len = 0;
11654 int i;
11655 uint8_t *buf_ptr;
11656 QDF_STATUS ret;
11657
11658 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
11659 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
11660 return QDF_STATUS_E_INVAL;
11661 }
11662
11663 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11664 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
11665 param->num_of_msduq_updates);
11666 buf = wmi_buf_alloc(wmi_handle, len);
11667
11668 if (!buf) {
11669 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11670 return QDF_STATUS_E_NOMEM;
11671 }
11672
11673 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11674 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11675 buf_ptr;
11676
11677 WMITLV_SET_HDR(&cmd->tlv_header,
11678 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11679 , WMITLV_GET_STRUCT_TLVLEN(
11680 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11681
11682 cmd->pdev_id =
11683 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11684 cmd->vdev_id = param->vdev_id;
11685 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11686 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11687
11688 buf_ptr += sizeof(
11689 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11690 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11691 param->num_of_msduq_updates *
11692 sizeof(wmi_msduq_qdepth_thresh_update));
11693 buf_ptr += WMI_TLV_HDR_SIZE;
11694 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11695
11696 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11697 WMITLV_SET_HDR(&cmd_update->tlv_header,
11698 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11699 WMITLV_GET_STRUCT_TLVLEN(
11700 wmi_msduq_qdepth_thresh_update));
11701 cmd_update->tid_num = param->update_params[i].tid_num;
11702 cmd_update->msduq_update_mask =
11703 param->update_params[i].msduq_update_mask;
11704 cmd_update->qdepth_thresh_value =
11705 param->update_params[i].qdepth_thresh_value;
11706 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11707 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11708 " update mask=0x%X thresh val=0x%X\n",
11709 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11710 cmd->peer_mac_address.mac_addr31to0,
11711 cmd->peer_mac_address.mac_addr47to32,
11712 cmd_update->msduq_update_mask,
11713 cmd_update->qdepth_thresh_value);
11714 cmd_update++;
11715 }
11716
11717 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11718 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11719
11720 if (ret != 0) {
11721 WMI_LOGE(" %s :WMI Failed\n", __func__);
11722 wmi_buf_free(buf);
11723 }
11724
11725 return ret;
11726}
11727
11728/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011729 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11730 * @wmi_handle: wmi handle
11731 * @param: pointer to hold vap dscp tid map param
11732 *
11733 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11734 */
11735static QDF_STATUS
11736send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11737 struct vap_dscp_tid_map_params *param)
11738{
11739 wmi_buf_t buf;
11740 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11741 int32_t len = sizeof(*cmd);
11742
11743 buf = wmi_buf_alloc(wmi_handle, len);
11744 if (!buf) {
11745 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11746 return QDF_STATUS_E_FAILURE;
11747 }
11748
11749 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11750 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
11751 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
11752
11753 cmd->vdev_id = param->vdev_id;
11754 cmd->enable_override = 0;
11755
11756 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11757 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11758 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11759 WMI_LOGE("Failed to set dscp cmd\n");
11760 wmi_buf_free(buf);
11761 return QDF_STATUS_E_FAILURE;
11762 }
11763
11764 return QDF_STATUS_SUCCESS;
11765}
11766
11767/**
11768 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11769 * @wmi_handle: wmi handle
11770 * @macaddr: vdev mac address
11771 * @param: pointer to hold neigbour rx param
11772 *
11773 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11774 */
11775static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11776 uint8_t macaddr[IEEE80211_ADDR_LEN],
11777 struct set_neighbour_rx_params *param)
11778{
11779 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11780 wmi_buf_t buf;
11781 int32_t len = sizeof(*cmd);
11782
11783 buf = wmi_buf_alloc(wmi_handle, len);
11784 if (!buf) {
11785 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11786 return QDF_STATUS_E_FAILURE;
11787 }
11788 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11789 WMITLV_SET_HDR(&cmd->tlv_header,
11790 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11791 WMITLV_GET_STRUCT_TLVLEN(
11792 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11793 cmd->vdev_id = param->vdev_id;
11794 cmd->bssid_idx = param->idx;
11795 cmd->action = param->action;
11796 cmd->type = param->type;
11797 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11798 cmd->flag = 0;
11799
11800 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11801 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11802 WMI_LOGE("Failed to set neighbour rx param\n");
11803 wmi_buf_free(buf);
11804 return QDF_STATUS_E_FAILURE;
11805 }
11806
11807 return QDF_STATUS_SUCCESS;
11808}
11809
11810/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011811 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011812 * @param wmi_handle : handle to WMI.
11813 * @param macaddr : vdev mac address
11814 * @param param : pointer to tx antenna param
11815 *
11816 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11817 */
11818static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11819 uint8_t macaddr[IEEE80211_ADDR_LEN],
11820 struct smart_ant_tx_ant_params *param)
11821{
11822 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11823 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11824 wmi_buf_t buf;
11825 int32_t len = 0;
11826 int i;
11827 uint8_t *buf_ptr;
11828 QDF_STATUS ret;
11829
11830 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11831 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11832 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11833 buf = wmi_buf_alloc(wmi_handle, len);
11834
11835 if (!buf) {
11836 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11837 return QDF_STATUS_E_NOMEM;
11838 }
11839
11840 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11841 qdf_mem_zero(buf_ptr, len);
11842 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11843
11844 WMITLV_SET_HDR(&cmd->tlv_header,
11845 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11846 WMITLV_GET_STRUCT_TLVLEN(
11847 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11848
11849 cmd->vdev_id = param->vdev_id;
11850 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11851
11852 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11853 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11854 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11855 buf_ptr += WMI_TLV_HDR_SIZE;
11856 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11857
11858 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11859 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11860 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11861 WMITLV_GET_STRUCT_TLVLEN(
11862 wmi_peer_smart_ant_set_tx_antenna_series));
11863 ant_tx_series->antenna_series = param->antenna_array[i];
11864 ant_tx_series++;
11865 }
11866
11867 ret = wmi_unified_cmd_send(wmi_handle,
11868 buf,
11869 len,
11870 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11871
11872 if (ret != 0) {
11873 WMI_LOGE(" %s :WMI Failed\n", __func__);
11874 wmi_buf_free(buf);
11875 }
11876
11877 return ret;
11878}
11879
Sathish Kumar02c3b542017-02-22 17:24:45 +053011880/**
11881 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11882 * @wmi_handle: wmi handle
11883 * @param: pointer to hold ant switch tbl param
11884 *
11885 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11886 */
11887static QDF_STATUS
11888send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11889 struct ant_switch_tbl_params *param)
11890{
11891 uint8_t len;
11892 wmi_buf_t buf;
11893 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11894 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11895 uint8_t *buf_ptr;
11896
11897 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11898 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11899 buf = wmi_buf_alloc(wmi_handle, len);
11900
11901 if (!buf) {
11902 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11903 return QDF_STATUS_E_NOMEM;
11904 }
11905
11906 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11907 qdf_mem_zero(buf_ptr, len);
11908 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11909
11910 WMITLV_SET_HDR(&cmd->tlv_header,
11911 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11912 WMITLV_GET_STRUCT_TLVLEN(
11913 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11914
11915 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11916 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011917 cmd->mac_id =
11918 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011919
11920 /* TLV indicating array of structures to follow */
11921 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11922 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11923 sizeof(wmi_pdev_set_ant_ctrl_chain));
11924 buf_ptr += WMI_TLV_HDR_SIZE;
11925 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11926
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011927 ctrl_chain->pdev_id =
11928 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011929 ctrl_chain->antCtrlChain = param->antCtrlChain;
11930
11931 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11932 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11933 wmi_buf_free(buf);
11934 return QDF_STATUS_E_FAILURE;
11935 }
11936
11937 return QDF_STATUS_SUCCESS;
11938}
11939
11940/**
11941 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11942 * training information function
11943 * @param wmi_handle : handle to WMI.
11944 * @macaddr : vdev mac address
11945 * @param param : pointer to tx antenna param
11946 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11947 */
11948static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11949 wmi_unified_t wmi_handle,
11950 uint8_t macaddr[IEEE80211_ADDR_LEN],
11951 struct smart_ant_training_info_params *param)
11952{
11953 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11954 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11955 wmi_buf_t buf;
11956 uint8_t *buf_ptr;
11957 int32_t len = 0;
11958 QDF_STATUS ret;
11959 int loop;
11960
11961 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11962 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11963 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11964 buf = wmi_buf_alloc(wmi_handle, len);
11965
11966 if (!buf) {
11967 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11968 return QDF_STATUS_E_NOMEM;
11969 }
11970
11971 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11972 qdf_mem_zero(buf_ptr, len);
11973 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11974
11975 WMITLV_SET_HDR(&cmd->tlv_header,
11976 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11977 WMITLV_GET_STRUCT_TLVLEN(
11978 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11979
11980 cmd->vdev_id = param->vdev_id;
11981 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11982 cmd->num_pkts = param->numpkts;
11983
11984 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11985 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11986 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11987 WMI_SMART_ANT_MAX_RATE_SERIES);
11988
11989 buf_ptr += WMI_TLV_HDR_SIZE;
11990 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11991
11992 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11993 WMITLV_SET_HDR(&train_param->tlv_header,
11994 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11995 WMITLV_GET_STRUCT_TLVLEN(
11996 wmi_peer_smart_ant_set_train_antenna_param));
11997 train_param->train_rate_series = param->rate_array[loop];
11998 train_param->train_antenna_series = param->antenna_array[loop];
11999 train_param->rc_flags = 0;
12000 WMI_LOGI(FL("Series number:%d\n"), loop);
12001 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
12002 train_param->train_rate_series,
12003 train_param->train_antenna_series);
12004 train_param++;
12005 }
12006
12007 ret = wmi_unified_cmd_send(wmi_handle,
12008 buf,
12009 len,
12010 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
12011
12012 if (ret != 0) {
12013 WMI_LOGE(" %s :WMI Failed\n", __func__);
12014 wmi_buf_free(buf);
12015 return QDF_STATUS_E_FAILURE;
12016 }
12017
12018 return ret;
12019}
12020
12021/**
12022 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
12023 * configuration function
12024 * @param wmi_handle : handle to WMI.
12025 * @macaddr : vdev mad address
12026 * @param param : pointer to tx antenna param
12027 *
12028 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12029 */
12030static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
12031 wmi_unified_t wmi_handle,
12032 uint8_t macaddr[IEEE80211_ADDR_LEN],
12033 struct smart_ant_node_config_params *param)
12034{
12035 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
12036 wmi_buf_t buf;
12037 uint8_t *buf_ptr;
12038 int32_t len = 0, args_tlv_len;
12039 int ret;
12040 int i = 0;
12041 A_UINT32 *node_config_args;
12042
12043 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
12044 len = sizeof(*cmd) + args_tlv_len;
12045
12046 if ((param->args_count == 0)) {
12047 WMI_LOGE("%s: Can't send a command with %d arguments\n",
12048 __func__, param->args_count);
12049 return QDF_STATUS_E_FAILURE;
12050 }
12051
12052 buf = wmi_buf_alloc(wmi_handle, len);
12053 if (!buf) {
12054 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12055 return QDF_STATUS_E_NOMEM;
12056 }
12057
12058 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
12059 wmi_buf_data(buf);
12060 buf_ptr = (uint8_t *)cmd;
12061 WMITLV_SET_HDR(&cmd->tlv_header,
12062 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
12063 WMITLV_GET_STRUCT_TLVLEN(
12064 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
12065 cmd->vdev_id = param->vdev_id;
12066 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12067 cmd->cmd_id = param->cmd_id;
12068 cmd->args_count = param->args_count;
12069 buf_ptr += sizeof(
12070 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
12071 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12072 (cmd->args_count * sizeof(A_UINT32)));
12073 buf_ptr += WMI_TLV_HDR_SIZE;
12074 node_config_args = (A_UINT32 *)buf_ptr;
12075
12076 for (i = 0; i < param->args_count; i++) {
12077 node_config_args[i] = param->args_arr[i];
12078 WMI_LOGI("%d", param->args_arr[i]);
12079 }
12080
12081 ret = wmi_unified_cmd_send(wmi_handle,
12082 buf,
12083 len,
12084 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
12085
12086 if (ret != 0) {
12087 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
12088 __func__, param->cmd_id, macaddr[0],
12089 macaddr[1], macaddr[2], macaddr[3],
12090 macaddr[4], macaddr[5], ret);
12091 wmi_buf_free(buf);
12092 }
12093
12094 return ret;
12095}
12096
12097/**
12098 * send_set_atf_cmd_tlv() - send set atf command to fw
12099 * @wmi_handle: wmi handle
12100 * @param: pointer to set atf param
12101 *
12102 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12103 */
12104static QDF_STATUS
12105send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
12106 struct set_atf_params *param)
12107{
12108 wmi_atf_peer_info *peer_info;
12109 wmi_peer_atf_request_fixed_param *cmd;
12110 wmi_buf_t buf;
12111 uint8_t *buf_ptr;
12112 int i;
12113 int32_t len = 0;
12114 QDF_STATUS retval;
12115
12116 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12117 len += param->num_peers * sizeof(wmi_atf_peer_info);
12118 buf = wmi_buf_alloc(wmi_handle, len);
12119 if (!buf) {
12120 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12121 return QDF_STATUS_E_FAILURE;
12122 }
12123 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12124 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
12125 WMITLV_SET_HDR(&cmd->tlv_header,
12126 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
12127 WMITLV_GET_STRUCT_TLVLEN(
12128 wmi_peer_atf_request_fixed_param));
12129 cmd->num_peers = param->num_peers;
12130
12131 buf_ptr += sizeof(*cmd);
12132 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12133 sizeof(wmi_atf_peer_info) *
12134 cmd->num_peers);
12135 buf_ptr += WMI_TLV_HDR_SIZE;
12136 peer_info = (wmi_atf_peer_info *)buf_ptr;
12137
12138 for (i = 0; i < cmd->num_peers; i++) {
12139 WMITLV_SET_HDR(&peer_info->tlv_header,
12140 WMITLV_TAG_STRUC_wmi_atf_peer_info,
12141 WMITLV_GET_STRUCT_TLVLEN(
12142 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012143 qdf_mem_copy(&(peer_info->peer_macaddr),
12144 &(param->peer_info[i].peer_macaddr),
12145 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053012146 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012147 peer_info->vdev_id = param->peer_info[i].vdev_id;
12148 peer_info->pdev_id =
12149 wmi_handle->ops->convert_pdev_id_host_to_target(
12150 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053012151 /*
12152 * TLV definition for peer atf request fixed param combines
12153 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
12154 * stats and atf extension stats as two different
12155 * implementations.
12156 * Need to discuss with FW on this.
12157 *
12158 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
12159 * peer_info->atf_units_reserved =
12160 * param->peer_ext_info[i].atf_index_reserved;
12161 */
12162 peer_info++;
12163 }
12164
12165 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12166 WMI_PEER_ATF_REQUEST_CMDID);
12167
12168 if (retval != QDF_STATUS_SUCCESS) {
12169 WMI_LOGE("%s : WMI Failed\n", __func__);
12170 wmi_buf_free(buf);
12171 }
12172
12173 return retval;
12174}
12175
12176/**
12177 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
12178 * @wmi_handle: wmi handle
12179 * @param: pointer to hold fwtest param
12180 *
12181 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12182 */
12183static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
12184 struct set_fwtest_params *param)
12185{
12186 wmi_fwtest_set_param_cmd_fixed_param *cmd;
12187 wmi_buf_t buf;
12188 int32_t len = sizeof(*cmd);
12189
12190 buf = wmi_buf_alloc(wmi_handle, len);
12191
12192 if (!buf) {
12193 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12194 return QDF_STATUS_E_FAILURE;
12195 }
12196
12197 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
12198 WMITLV_SET_HDR(&cmd->tlv_header,
12199 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
12200 WMITLV_GET_STRUCT_TLVLEN(
12201 wmi_fwtest_set_param_cmd_fixed_param));
12202 cmd->param_id = param->arg;
12203 cmd->param_value = param->value;
12204
12205 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
12206 WMI_LOGE("Setting FW test param failed\n");
12207 wmi_buf_free(buf);
12208 return QDF_STATUS_E_FAILURE;
12209 }
12210
12211 return QDF_STATUS_SUCCESS;
12212}
12213
12214/**
12215 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
12216 * @wmi_handle: wmi handle
12217 * @param: pointer to qboost params
12218 * @macaddr: vdev mac address
12219 *
12220 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12221 */
12222static QDF_STATUS
12223send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
12224 uint8_t macaddr[IEEE80211_ADDR_LEN],
12225 struct set_qboost_params *param)
12226{
12227 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
12228 wmi_buf_t buf;
12229 int32_t len;
12230 QDF_STATUS ret;
12231
12232 len = sizeof(*cmd);
12233
12234 buf = wmi_buf_alloc(wmi_handle, len);
12235 if (!buf) {
12236 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12237 return QDF_STATUS_E_FAILURE;
12238 }
12239
12240 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
12241 WMITLV_SET_HDR(&cmd->tlv_header,
12242 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
12243 WMITLV_GET_STRUCT_TLVLEN(
12244 WMI_QBOOST_CFG_CMD_fixed_param));
12245 cmd->vdev_id = param->vdev_id;
12246 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12247 cmd->qb_enable = param->value;
12248
12249 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12250 WMI_QBOOST_CFG_CMDID);
12251
12252 if (ret != 0) {
12253 WMI_LOGE("Setting qboost cmd failed\n");
12254 wmi_buf_free(buf);
12255 }
12256
12257 return ret;
12258}
12259
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012260/**
12261 * send_gpio_config_cmd_tlv() - send gpio config to fw
12262 * @wmi_handle: wmi handle
12263 * @param: pointer to hold gpio config param
12264 *
12265 * Return: 0 for success or error code
12266 */
12267static QDF_STATUS
12268send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
12269 struct gpio_config_params *param)
12270{
12271 wmi_gpio_config_cmd_fixed_param *cmd;
12272 wmi_buf_t buf;
12273 int32_t len;
12274 QDF_STATUS ret;
12275
12276 len = sizeof(*cmd);
12277
12278 /* Sanity Checks */
12279 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
12280 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
12281 return QDF_STATUS_E_FAILURE;
12282 }
12283
12284 buf = wmi_buf_alloc(wmi_handle, len);
12285 if (!buf) {
12286 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12287 return QDF_STATUS_E_FAILURE;
12288 }
12289
12290 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
12291 WMITLV_SET_HDR(&cmd->tlv_header,
12292 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
12293 WMITLV_GET_STRUCT_TLVLEN(
12294 wmi_gpio_config_cmd_fixed_param));
12295 cmd->gpio_num = param->gpio_num;
12296 cmd->input = param->input;
12297 cmd->pull_type = param->pull_type;
12298 cmd->intr_mode = param->intr_mode;
12299
12300 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12301 WMI_GPIO_CONFIG_CMDID);
12302
12303 if (ret != 0) {
12304 WMI_LOGE("Sending GPIO config cmd failed\n");
12305 wmi_buf_free(buf);
12306 }
12307
12308 return ret;
12309}
12310
12311/**
12312 * send_gpio_output_cmd_tlv() - send gpio output to fw
12313 * @wmi_handle: wmi handle
12314 * @param: pointer to hold gpio output param
12315 *
12316 * Return: 0 for success or error code
12317 */
12318static QDF_STATUS
12319send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
12320 struct gpio_output_params *param)
12321{
12322 wmi_gpio_output_cmd_fixed_param *cmd;
12323 wmi_buf_t buf;
12324 int32_t len;
12325 QDF_STATUS ret;
12326
12327 len = sizeof(*cmd);
12328
12329 buf = wmi_buf_alloc(wmi_handle, len);
12330 if (!buf) {
12331 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12332 return QDF_STATUS_E_FAILURE;
12333 }
12334
12335 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
12336 WMITLV_SET_HDR(&cmd->tlv_header,
12337 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
12338 WMITLV_GET_STRUCT_TLVLEN(
12339 wmi_gpio_output_cmd_fixed_param));
12340 cmd->gpio_num = param->gpio_num;
12341 cmd->set = param->set;
12342
12343 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12344 WMI_GPIO_OUTPUT_CMDID);
12345
12346 if (ret != 0) {
12347 WMI_LOGE("Sending GPIO output cmd failed\n");
12348 wmi_buf_free(buf);
12349 }
12350
12351 return ret;
12352
12353}
12354
12355/**
12356 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
12357 *
12358 * @param wmi_handle : handle to WMI.
12359 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12360 */
12361static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
12362{
12363 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
12364 wmi_buf_t buf;
12365 QDF_STATUS ret;
12366 int32_t len;
12367
12368 len = sizeof(*cmd);
12369
12370 buf = wmi_buf_alloc(wmi_handle, len);
12371 if (!buf) {
12372 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12373 return QDF_STATUS_E_FAILURE;
12374 }
12375
12376 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
12377 WMITLV_SET_HDR(&cmd->tlv_header,
12378 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
12379 WMITLV_GET_STRUCT_TLVLEN(
12380 wmi_pdev_dfs_disable_cmd_fixed_param));
12381 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012382 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12383 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012384
12385 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12386 WMI_PDEV_DFS_DISABLE_CMDID);
12387
12388 if (ret != 0) {
12389 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
12390 wmi_buf_free(buf);
12391 }
12392
12393 return ret;
12394}
12395
12396/**
12397 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
12398 *
12399 * @param wmi_handle : handle to WMI.
12400 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12401 */
12402static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
12403{
12404 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
12405 wmi_buf_t buf;
12406 QDF_STATUS ret;
12407 int32_t len;
12408
12409 len = sizeof(*cmd);
12410
12411 buf = wmi_buf_alloc(wmi_handle, len);
12412 if (!buf) {
12413 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12414 return QDF_STATUS_E_FAILURE;
12415 }
12416
12417 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
12418 WMITLV_SET_HDR(&cmd->tlv_header,
12419 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
12420 WMITLV_GET_STRUCT_TLVLEN(
12421 wmi_pdev_dfs_enable_cmd_fixed_param));
12422 /* Reserved for future use */
12423 cmd->reserved0 = 0;
12424
12425 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12426 WMI_PDEV_DFS_ENABLE_CMDID);
12427
12428 if (ret != 0) {
12429 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
12430 wmi_buf_free(buf);
12431 }
12432
12433 return ret;
12434}
12435
12436/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053012437 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
12438 * to fw
12439 * @wmi_handle: wmi handle
12440 * @param: pointer to hold periodic chan stats param
12441 *
12442 * Return: 0 for success or error code
12443 */
12444static QDF_STATUS
12445send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
12446 struct periodic_chan_stats_params *param)
12447{
12448 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
12449 wmi_buf_t buf;
12450 QDF_STATUS ret;
12451 int32_t len;
12452
12453 len = sizeof(*cmd);
12454
12455 buf = wmi_buf_alloc(wmi_handle, len);
12456 if (!buf) {
12457 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12458 return QDF_STATUS_E_FAILURE;
12459 }
12460
12461 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
12462 wmi_buf_data(buf);
12463 WMITLV_SET_HDR(&cmd->tlv_header,
12464 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
12465 WMITLV_GET_STRUCT_TLVLEN(
12466 wmi_set_periodic_channel_stats_config_fixed_param));
12467 cmd->enable = param->enable;
12468 cmd->stats_period = param->stats_period;
12469 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12470 param->pdev_id);
12471
12472 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12473 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
12474
12475 if (ret != 0) {
12476 WMI_LOGE("Sending periodic chan stats config failed");
12477 wmi_buf_free(buf);
12478 }
12479
12480 return ret;
12481}
12482
12483/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012484 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
12485 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080012486 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012487 *
12488 * Return: 0 for success or error code
12489 */
12490static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080012491send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012492{
12493 wmi_buf_t buf;
12494 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080012495 wmi_pdev_get_nfcal_power_fixed_param *cmd;
12496 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012497
nobeljf74583b2018-01-25 16:35:36 -080012498 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012499 if (buf == NULL)
12500 return QDF_STATUS_E_NOMEM;
12501
nobeljf74583b2018-01-25 16:35:36 -080012502 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
12503 WMITLV_SET_HDR(&cmd->tlv_header,
12504 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
12505 WMITLV_GET_STRUCT_TLVLEN
12506 (wmi_pdev_get_nfcal_power_fixed_param));
12507 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
12508
12509 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012510 WMI_PDEV_GET_NFCAL_POWER_CMDID);
12511 if (ret != 0) {
12512 WMI_LOGE("Sending get nfcal power cmd failed\n");
12513 wmi_buf_free(buf);
12514 }
12515
12516 return ret;
12517}
12518
12519/**
12520 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
12521 * @wmi_handle: wmi handle
12522 * @param: pointer to ht ie param
12523 *
12524 * Return: 0 for success or error code
12525 */
12526static QDF_STATUS
12527send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12528 struct ht_ie_params *param)
12529{
12530 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
12531 wmi_buf_t buf;
12532 QDF_STATUS ret;
12533 int32_t len;
12534 uint8_t *buf_ptr;
12535
12536 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12537 roundup(param->ie_len, sizeof(uint32_t));
12538
12539 buf = wmi_buf_alloc(wmi_handle, len);
12540 if (!buf) {
12541 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12542 return QDF_STATUS_E_FAILURE;
12543 }
12544
12545 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12546 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
12547 WMITLV_SET_HDR(&cmd->tlv_header,
12548 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
12549 WMITLV_GET_STRUCT_TLVLEN(
12550 wmi_pdev_set_ht_ie_cmd_fixed_param));
12551 cmd->reserved0 = 0;
12552 cmd->ie_len = param->ie_len;
12553 cmd->tx_streams = param->tx_streams;
12554 cmd->rx_streams = param->rx_streams;
12555
12556 buf_ptr += sizeof(*cmd);
12557 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12558 buf_ptr += WMI_TLV_HDR_SIZE;
12559 if (param->ie_len)
12560 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12561 cmd->ie_len);
12562
12563 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12564 WMI_PDEV_SET_HT_CAP_IE_CMDID);
12565
12566 if (ret != 0) {
12567 WMI_LOGE("Sending set ht ie cmd failed\n");
12568 wmi_buf_free(buf);
12569 }
12570
12571 return ret;
12572}
12573
12574/**
12575 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
12576 * @wmi_handle: wmi handle
12577 * @param: pointer to vht ie param
12578 *
12579 * Return: 0 for success or error code
12580 */
12581static QDF_STATUS
12582send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12583 struct vht_ie_params *param)
12584{
12585 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
12586 wmi_buf_t buf;
12587 QDF_STATUS ret;
12588 int32_t len;
12589 uint8_t *buf_ptr;
12590
12591 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12592 roundup(param->ie_len, sizeof(uint32_t));
12593
12594 buf = wmi_buf_alloc(wmi_handle, len);
12595 if (!buf) {
12596 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12597 return QDF_STATUS_E_FAILURE;
12598 }
12599
12600 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12601 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
12602 WMITLV_SET_HDR(&cmd->tlv_header,
12603 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
12604 WMITLV_GET_STRUCT_TLVLEN(
12605 wmi_pdev_set_vht_ie_cmd_fixed_param));
12606 cmd->reserved0 = 0;
12607 cmd->ie_len = param->ie_len;
12608 cmd->tx_streams = param->tx_streams;
12609 cmd->rx_streams = param->rx_streams;
12610
12611 buf_ptr += sizeof(*cmd);
12612 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12613 buf_ptr += WMI_TLV_HDR_SIZE;
12614 if (param->ie_len)
12615 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12616 cmd->ie_len);
12617
12618 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12619 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
12620
12621 if (ret != 0) {
12622 WMI_LOGE("Sending set vht ie cmd failed\n");
12623 wmi_buf_free(buf);
12624 }
12625
12626 return ret;
12627}
12628
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012629/**
12630 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
12631 * @wmi_handle: wmi handle
12632 * @param: pointer to quiet mode params
12633 *
12634 * Return: 0 for success or error code
12635 */
12636static QDF_STATUS
12637send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
12638 struct set_quiet_mode_params *param)
12639{
12640 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
12641 wmi_buf_t buf;
12642 QDF_STATUS ret;
12643 int32_t len;
12644
12645 len = sizeof(*quiet_cmd);
12646 buf = wmi_buf_alloc(wmi_handle, len);
12647 if (!buf) {
12648 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12649 return QDF_STATUS_E_FAILURE;
12650 }
12651
12652 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12653 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
12654 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
12655 WMITLV_GET_STRUCT_TLVLEN(
12656 wmi_pdev_set_quiet_cmd_fixed_param));
12657 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12658 quiet_cmd->enabled = param->enabled;
12659 quiet_cmd->period = (param->period)*(param->intval);
12660 quiet_cmd->duration = param->duration;
12661 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012662 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12663 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012664
12665 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12666 WMI_PDEV_SET_QUIET_MODE_CMDID);
12667
12668 if (ret != 0) {
12669 WMI_LOGE("Sending set quiet cmd failed\n");
12670 wmi_buf_free(buf);
12671 }
12672
12673 return ret;
12674}
12675
12676/**
12677 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12678 * @wmi_handle: wmi handle
12679 * @param: pointer to set bwf param
12680 *
12681 * Return: 0 for success or error code
12682 */
12683static QDF_STATUS
12684send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12685 struct set_bwf_params *param)
12686{
12687 wmi_bwf_peer_info *peer_info;
12688 wmi_peer_bwf_request_fixed_param *cmd;
12689 wmi_buf_t buf;
12690 QDF_STATUS retval;
12691 int32_t len;
12692 uint8_t *buf_ptr;
12693 int i;
12694
12695 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12696 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12697 buf = wmi_buf_alloc(wmi_handle, len);
12698 if (!buf) {
12699 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12700 return QDF_STATUS_E_FAILURE;
12701 }
12702 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12703 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12704 WMITLV_SET_HDR(&cmd->tlv_header,
12705 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12706 WMITLV_GET_STRUCT_TLVLEN(
12707 wmi_peer_bwf_request_fixed_param));
12708 cmd->num_peers = param->num_peers;
12709
12710 buf_ptr += sizeof(*cmd);
12711 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12712 sizeof(wmi_bwf_peer_info) *
12713 cmd->num_peers);
12714 buf_ptr += WMI_TLV_HDR_SIZE;
12715 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12716
12717 for (i = 0; i < cmd->num_peers; i++) {
12718 WMITLV_SET_HDR(&peer_info->tlv_header,
12719 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12720 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12721 peer_info->bwf_guaranteed_bandwidth =
12722 param->peer_info[i].throughput;
12723 peer_info->bwf_max_airtime =
12724 param->peer_info[i].max_airtime;
12725 peer_info->bwf_peer_priority =
12726 param->peer_info[i].priority;
12727 qdf_mem_copy(&peer_info->peer_macaddr,
12728 &param->peer_info[i].peer_macaddr,
12729 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012730 peer_info->vdev_id =
12731 param->peer_info[i].vdev_id;
12732 peer_info->pdev_id =
12733 wmi_handle->ops->convert_pdev_id_host_to_target(
12734 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012735 peer_info++;
12736 }
12737
12738 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12739 WMI_PEER_BWF_REQUEST_CMDID);
12740
12741 if (retval != QDF_STATUS_SUCCESS) {
12742 WMI_LOGE("%s : WMI Failed\n", __func__);
12743 wmi_buf_free(buf);
12744 }
12745
12746 return retval;
12747}
12748
12749/**
12750 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12751 * @wmi_handle: wmi handle
12752 * @param: pointer to hold mcast update param
12753 *
12754 * Return: 0 for success or error code
12755 */
12756static QDF_STATUS
12757send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12758 struct mcast_group_update_params *param)
12759{
12760 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12761 wmi_buf_t buf;
12762 QDF_STATUS ret;
12763 int32_t len;
12764 int offset = 0;
12765 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12766
12767 len = sizeof(*cmd);
12768 buf = wmi_buf_alloc(wmi_handle, len);
12769 if (!buf) {
12770 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12771 return QDF_STATUS_E_FAILURE;
12772 }
12773 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12774 WMITLV_SET_HDR(&cmd->tlv_header,
12775 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12776 WMITLV_GET_STRUCT_TLVLEN(
12777 wmi_peer_mcast_group_cmd_fixed_param));
12778 /* confirm the buffer is 4-byte aligned */
12779 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12780 qdf_mem_zero(cmd, sizeof(*cmd));
12781
12782 cmd->vdev_id = param->vap_id;
12783 /* construct the message assuming our endianness matches the target */
12784 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12785 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12786 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12787 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12788 if (param->is_action_delete)
12789 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12790
12791 if (param->is_mcast_addr_len)
12792 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12793
12794 if (param->is_filter_mode_snoop)
12795 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12796
12797 /* unicast address spec only applies for non-wildcard cases */
12798 if (!param->wildcard && param->ucast_mac_addr) {
12799 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12800 &cmd->ucast_mac_addr);
12801 }
Amar Singhal5593c902017-10-03 13:00:29 -070012802
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012803 if (param->mcast_ip_addr) {
12804 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12805 sizeof(cmd->mcast_ip_addr));
12806 offset = sizeof(cmd->mcast_ip_addr) -
12807 param->mcast_ip_addr_bytes;
12808 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12809 param->mcast_ip_addr,
12810 param->mcast_ip_addr_bytes);
12811 }
12812 if (!param->mask)
12813 param->mask = &dummymask[0];
12814
12815 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12816 param->mask,
12817 param->mcast_ip_addr_bytes);
12818
12819 if (param->srcs && param->nsrcs) {
12820 cmd->num_filter_addr = param->nsrcs;
12821 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12822 sizeof(cmd->filter_addr));
12823
12824 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12825 param->nsrcs * param->mcast_ip_addr_bytes);
12826 }
12827
12828 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12829 WMI_PEER_MCAST_GROUP_CMDID);
12830
12831 if (ret != QDF_STATUS_SUCCESS) {
12832 WMI_LOGE("%s : WMI Failed\n", __func__);
12833 wmi_buf_free(buf);
12834 }
12835
12836 return ret;
12837}
12838
12839/**
12840 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12841 * command to fw
12842 * @wmi_handle: wmi handle
12843 * @param: pointer to hold spectral config parameter
12844 *
12845 * Return: 0 for success or error code
12846 */
12847static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12848 struct vdev_spectral_configure_params *param)
12849{
12850 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12851 wmi_buf_t buf;
12852 QDF_STATUS ret;
12853 int32_t len;
12854
12855 len = sizeof(*cmd);
12856 buf = wmi_buf_alloc(wmi_handle, len);
12857 if (!buf) {
12858 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12859 return QDF_STATUS_E_FAILURE;
12860 }
12861
12862 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12863 WMITLV_SET_HDR(&cmd->tlv_header,
12864 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12865 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012866 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012867
12868 cmd->vdev_id = param->vdev_id;
12869 cmd->spectral_scan_count = param->count;
12870 cmd->spectral_scan_period = param->period;
12871 cmd->spectral_scan_priority = param->spectral_pri;
12872 cmd->spectral_scan_fft_size = param->fft_size;
12873 cmd->spectral_scan_gc_ena = param->gc_enable;
12874 cmd->spectral_scan_restart_ena = param->restart_enable;
12875 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12876 cmd->spectral_scan_init_delay = param->init_delay;
12877 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12878 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12879 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12880 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12881 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12882 cmd->spectral_scan_pwr_format = param->pwr_format;
12883 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12884 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012885 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012886 cmd->spectral_scan_chn_mask = param->chn_mask;
12887
12888 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12889 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12890
12891 if (ret != 0) {
12892 WMI_LOGE("Sending set quiet cmd failed\n");
12893 wmi_buf_free(buf);
12894 }
12895
12896 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12897 __func__);
12898
12899 WMI_LOGI("vdev_id = %u\n"
12900 "spectral_scan_count = %u\n"
12901 "spectral_scan_period = %u\n"
12902 "spectral_scan_priority = %u\n"
12903 "spectral_scan_fft_size = %u\n"
12904 "spectral_scan_gc_ena = %u\n"
12905 "spectral_scan_restart_ena = %u\n"
12906 "spectral_scan_noise_floor_ref = %u\n"
12907 "spectral_scan_init_delay = %u\n"
12908 "spectral_scan_nb_tone_thr = %u\n"
12909 "spectral_scan_str_bin_thr = %u\n"
12910 "spectral_scan_wb_rpt_mode = %u\n"
12911 "spectral_scan_rssi_rpt_mode = %u\n"
12912 "spectral_scan_rssi_thr = %u\n"
12913 "spectral_scan_pwr_format = %u\n"
12914 "spectral_scan_rpt_mode = %u\n"
12915 "spectral_scan_bin_scale = %u\n"
12916 "spectral_scan_dBm_adj = %u\n"
12917 "spectral_scan_chn_mask = %u\n",
12918 param->vdev_id,
12919 param->count,
12920 param->period,
12921 param->spectral_pri,
12922 param->fft_size,
12923 param->gc_enable,
12924 param->restart_enable,
12925 param->noise_floor_ref,
12926 param->init_delay,
12927 param->nb_tone_thr,
12928 param->str_bin_thr,
12929 param->wb_rpt_mode,
12930 param->rssi_rpt_mode,
12931 param->rssi_thr,
12932 param->pwr_format,
12933 param->rpt_mode,
12934 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012935 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012936 param->chn_mask);
12937 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12938
12939 return ret;
12940}
12941
12942/**
12943 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12944 * command to fw
12945 * @wmi_handle: wmi handle
12946 * @param: pointer to hold spectral enable parameter
12947 *
12948 * Return: 0 for success or error code
12949 */
12950static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12951 struct vdev_spectral_enable_params *param)
12952{
12953 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12954 wmi_buf_t buf;
12955 QDF_STATUS ret;
12956 int32_t len;
12957
12958 len = sizeof(*cmd);
12959 buf = wmi_buf_alloc(wmi_handle, len);
12960 if (!buf) {
12961 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12962 return QDF_STATUS_E_FAILURE;
12963 }
12964
12965 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12966 WMITLV_SET_HDR(&cmd->tlv_header,
12967 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12968 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012969 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012970
12971 cmd->vdev_id = param->vdev_id;
12972
12973 if (param->active_valid) {
12974 cmd->trigger_cmd = param->active ? 1 : 2;
12975 /* 1: Trigger, 2: Clear Trigger */
12976 } else {
12977 cmd->trigger_cmd = 0; /* 0: Ignore */
12978 }
12979
12980 if (param->enabled_valid) {
12981 cmd->enable_cmd = param->enabled ? 1 : 2;
12982 /* 1: Enable 2: Disable */
12983 } else {
12984 cmd->enable_cmd = 0; /* 0: Ignore */
12985 }
12986
12987 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12988 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12989
12990 if (ret != 0) {
12991 WMI_LOGE("Sending scan enable CMD failed\n");
12992 wmi_buf_free(buf);
12993 }
12994
12995 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12996
12997 WMI_LOGI("vdev_id = %u\n"
12998 "trigger_cmd = %u\n"
12999 "enable_cmd = %u\n",
13000 cmd->vdev_id,
13001 cmd->trigger_cmd,
13002 cmd->enable_cmd);
13003
13004 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
13005
13006 return ret;
13007}
13008
13009/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053013010 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
13011 * @param wmi_handle : handle to WMI.
13012 * @param param : pointer to hold thermal mitigation param
13013 *
13014 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
13015 */
13016static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
13017 wmi_unified_t wmi_handle,
13018 struct thermal_mitigation_params *param)
13019{
13020 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
13021 wmi_therm_throt_level_config_info *lvl_conf = NULL;
13022 wmi_buf_t buf = NULL;
13023 uint8_t *buf_ptr = NULL;
13024 int error;
13025 int32_t len;
13026 int i;
13027
13028 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
13029 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
13030
13031 buf = wmi_buf_alloc(wmi_handle, len);
13032 if (!buf) {
13033 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13034 return QDF_STATUS_E_NOMEM;
13035 }
13036 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
13037
13038 /* init fixed params */
13039 WMITLV_SET_HDR(tt_conf,
13040 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
13041 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
13042
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013043 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13044 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053013045 tt_conf->enable = param->enable;
13046 tt_conf->dc = param->dc;
13047 tt_conf->dc_per_event = param->dc_per_event;
13048 tt_conf->therm_throt_levels = THERMAL_LEVELS;
13049
13050 buf_ptr = (uint8_t *) ++tt_conf;
13051 /* init TLV params */
13052 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13053 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
13054
13055 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
13056 for (i = 0; i < THERMAL_LEVELS; i++) {
13057 WMITLV_SET_HDR(&lvl_conf->tlv_header,
13058 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
13059 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
13060 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
13061 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
13062 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
13063 lvl_conf->prio = param->levelconf[i].priority;
13064 lvl_conf++;
13065 }
13066
13067 error = wmi_unified_cmd_send(wmi_handle, buf, len,
13068 WMI_THERM_THROT_SET_CONF_CMDID);
13069 if (QDF_IS_STATUS_ERROR(error)) {
13070 wmi_buf_free(buf);
13071 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
13072 }
13073
13074 return error;
13075}
13076
13077/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013078 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
13079 * @wmi_handle: wmi handle
13080 * @param: pointer to pdev_qvit_params
13081 *
13082 * Return: 0 for success or error code
13083 */
13084static QDF_STATUS
13085send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
13086 struct pdev_qvit_params *param)
13087{
13088 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013089 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013090 uint8_t *cmd;
13091 static uint8_t msgref = 1;
13092 uint8_t segnumber = 0, seginfo, numsegments;
13093 uint16_t chunk_len, total_bytes;
13094 uint8_t *bufpos;
13095 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
13096
13097 bufpos = param->utf_payload;
13098 total_bytes = param->len;
13099 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
13100 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
13101 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
13102
13103 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
13104 numsegments++;
13105
13106 while (param->len) {
13107 if (param->len > MAX_WMI_QVIT_LEN)
13108 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
13109 else
13110 chunk_len = param->len;
13111
13112 buf = wmi_buf_alloc(wmi_handle,
13113 (chunk_len + sizeof(seghdrinfo) +
13114 WMI_TLV_HDR_SIZE));
13115 if (!buf) {
13116 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13117 return QDF_STATUS_E_NOMEM;
13118 }
13119
13120 cmd = (uint8_t *) wmi_buf_data(buf);
13121
13122 seghdrinfo.len = total_bytes;
13123 seghdrinfo.msgref = msgref;
13124 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
13125 seghdrinfo.segmentInfo = seginfo;
13126
13127 segnumber++;
13128
13129 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
13130 (chunk_len + sizeof(seghdrinfo)));
13131 cmd += WMI_TLV_HDR_SIZE;
13132 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
13133 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
13134
13135 ret = wmi_unified_cmd_send(wmi_handle, buf,
13136 (chunk_len + sizeof(seghdrinfo) +
13137 WMI_TLV_HDR_SIZE),
13138 WMI_PDEV_QVIT_CMDID);
13139
13140 if (ret != 0) {
13141 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
13142 wmi_buf_free(buf);
13143 break;
13144 }
13145
13146 param->len -= chunk_len;
13147 bufpos += chunk_len;
13148 }
13149 msgref++;
13150
13151 return ret;
13152}
13153
13154/**
13155 * send_wmm_update_cmd_tlv() - send wmm update command to fw
13156 * @wmi_handle: wmi handle
13157 * @param: pointer to wmm update param
13158 *
13159 * Return: 0 for success or error code
13160 */
13161static QDF_STATUS
13162send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
13163 struct wmm_update_params *param)
13164{
13165 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
13166 wmi_wmm_params *wmm_param;
13167 wmi_buf_t buf;
13168 QDF_STATUS ret;
13169 int32_t len;
13170 int ac = 0;
13171 struct wmi_host_wmeParams *wmep;
13172 uint8_t *buf_ptr;
13173
13174 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
13175 buf = wmi_buf_alloc(wmi_handle, len);
13176 if (!buf) {
13177 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13178 return QDF_STATUS_E_FAILURE;
13179 }
13180
13181 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13182 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
13183 WMITLV_SET_HDR(&cmd->tlv_header,
13184 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
13185 WMITLV_GET_STRUCT_TLVLEN
13186 (wmi_pdev_set_wmm_params_cmd_fixed_param));
13187
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013188 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013189
13190 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
13191
13192 for (ac = 0; ac < WME_NUM_AC; ac++) {
13193 wmep = &param->wmep_array[ac];
13194 wmm_param = (wmi_wmm_params *)buf_ptr;
13195 WMITLV_SET_HDR(&wmm_param->tlv_header,
13196 WMITLV_TAG_STRUC_wmi_wmm_params,
13197 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
13198 wmm_param->aifs = wmep->wmep_aifsn;
13199 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
13200 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
13201 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
13202 wmm_param->acm = wmep->wmep_acm;
13203 wmm_param->no_ack = wmep->wmep_noackPolicy;
13204 buf_ptr += sizeof(wmi_wmm_params);
13205 }
13206 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13207 WMI_PDEV_SET_WMM_PARAMS_CMDID);
13208
13209 if (ret != 0) {
13210 WMI_LOGE("Sending WMM update CMD failed\n");
13211 wmi_buf_free(buf);
13212 }
13213
13214 return ret;
13215}
13216
Sathish Kumar80f4f382017-04-24 11:36:00 +053013217/**
13218 * send_coex_config_cmd_tlv() - send coex config command to fw
13219 * @wmi_handle: wmi handle
13220 * @param: pointer to coex config param
13221 *
13222 * Return: 0 for success or error code
13223 */
13224static QDF_STATUS
13225send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
13226 struct coex_config_params *param)
13227{
13228 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
13229 wmi_buf_t buf;
13230 QDF_STATUS ret;
13231 int32_t len;
13232
13233 len = sizeof(*cmd);
13234 buf = wmi_buf_alloc(wmi_handle, len);
13235 if (!buf) {
13236 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13237 return QDF_STATUS_E_FAILURE;
13238 }
13239
13240 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
13241 WMITLV_SET_HDR(&cmd->tlv_header,
13242 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
13243 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053013244 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053013245
13246 cmd->vdev_id = param->vdev_id;
13247 cmd->config_type = param->config_type;
13248 cmd->config_arg1 = param->config_arg1;
13249 cmd->config_arg2 = param->config_arg2;
13250 cmd->config_arg3 = param->config_arg3;
13251 cmd->config_arg4 = param->config_arg4;
13252 cmd->config_arg5 = param->config_arg5;
13253 cmd->config_arg6 = param->config_arg6;
13254
13255 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13256 WMI_COEX_CONFIG_CMDID);
13257
13258 if (ret != 0) {
13259 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
13260 wmi_buf_free(buf);
13261 }
13262
13263 return ret;
13264}
13265
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013266static
Govind Singh9ddd5162016-03-07 16:30:32 +053013267void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053013268 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053013269{
Govind Singhe7f2f342016-05-23 12:12:52 +053013270 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053013271 resource_cfg->num_peers = tgt_res_cfg->num_peers;
13272 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
13273 resource_cfg->num_offload_reorder_buffs =
13274 tgt_res_cfg->num_offload_reorder_buffs;
13275 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
13276 resource_cfg->num_tids = tgt_res_cfg->num_tids;
13277 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
13278 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
13279 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
13280 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
13281 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
13282 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
13283 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
13284 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
13285 resource_cfg->scan_max_pending_req =
13286 tgt_res_cfg->scan_max_pending_req;
13287 resource_cfg->bmiss_offload_max_vdev =
13288 tgt_res_cfg->bmiss_offload_max_vdev;
13289 resource_cfg->roam_offload_max_vdev =
13290 tgt_res_cfg->roam_offload_max_vdev;
13291 resource_cfg->roam_offload_max_ap_profiles =
13292 tgt_res_cfg->roam_offload_max_ap_profiles;
13293 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
13294 resource_cfg->num_mcast_table_elems =
13295 tgt_res_cfg->num_mcast_table_elems;
13296 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
13297 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
13298 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
13299 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
13300 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
13301 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
13302 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
13303 resource_cfg->vow_config = tgt_res_cfg->vow_config;
13304 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
13305 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
13306 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
13307 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
13308 resource_cfg->num_tdls_conn_table_entries =
13309 tgt_res_cfg->num_tdls_conn_table_entries;
13310 resource_cfg->beacon_tx_offload_max_vdev =
13311 tgt_res_cfg->beacon_tx_offload_max_vdev;
13312 resource_cfg->num_multicast_filter_entries =
13313 tgt_res_cfg->num_multicast_filter_entries;
13314 resource_cfg->num_wow_filters =
13315 tgt_res_cfg->num_wow_filters;
13316 resource_cfg->num_keep_alive_pattern =
13317 tgt_res_cfg->num_keep_alive_pattern;
13318 resource_cfg->keep_alive_pattern_size =
13319 tgt_res_cfg->keep_alive_pattern_size;
13320 resource_cfg->max_tdls_concurrent_sleep_sta =
13321 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
13322 resource_cfg->max_tdls_concurrent_buffer_sta =
13323 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
13324 resource_cfg->wmi_send_separate =
13325 tgt_res_cfg->wmi_send_separate;
13326 resource_cfg->num_ocb_vdevs =
13327 tgt_res_cfg->num_ocb_vdevs;
13328 resource_cfg->num_ocb_channels =
13329 tgt_res_cfg->num_ocb_channels;
13330 resource_cfg->num_ocb_schedules =
13331 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013332 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
13333 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
13334 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013335 resource_cfg->max_num_dbs_scan_duty_cycle =
13336 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080013337 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080013338 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
13339 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053013340
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013341 if (tgt_res_cfg->atf_config)
13342 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
13343 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
13344 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
13345 resource_cfg->flag1, 1);
13346 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
13347 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
13348 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053013349 if (tgt_res_cfg->cce_disable)
13350 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Govind Singh9ddd5162016-03-07 16:30:32 +053013351}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013352
13353/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13354 * @wmi_handle: pointer to wmi handle
13355 * @buf_ptr: pointer to current position in init command buffer
13356 * @len: pointer to length. This will be updated with current lenght of cmd
13357 * @param: point host parameters for init command
13358 *
13359 * Return: Updated pointer of buf_ptr.
13360 */
13361static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
13362 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
13363{
13364 uint16_t idx;
13365
13366 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13367 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13368 wmi_pdev_band_to_mac *band_to_mac;
13369
13370 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13371 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13372 sizeof(wmi_resource_config) +
13373 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13374 sizeof(wlan_host_memory_chunk)));
13375
13376 WMITLV_SET_HDR(&hw_mode->tlv_header,
13377 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13378 (WMITLV_GET_STRUCT_TLVLEN
13379 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13380
13381 hw_mode->hw_mode_index = param->hw_mode_id;
13382 hw_mode->num_band_to_mac = param->num_band_to_mac;
13383
13384 buf_ptr = (uint8_t *) (hw_mode + 1);
13385 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13386 WMI_TLV_HDR_SIZE);
13387 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13388 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13389 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13390 WMITLV_GET_STRUCT_TLVLEN
13391 (wmi_pdev_band_to_mac));
13392 band_to_mac[idx].pdev_id =
13393 wmi_handle->ops->convert_pdev_id_host_to_target(
13394 param->band_to_mac[idx].pdev_id);
13395 band_to_mac[idx].start_freq =
13396 param->band_to_mac[idx].start_freq;
13397 band_to_mac[idx].end_freq =
13398 param->band_to_mac[idx].end_freq;
13399 }
13400 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13401 (param->num_band_to_mac *
13402 sizeof(wmi_pdev_band_to_mac)) +
13403 WMI_TLV_HDR_SIZE;
13404
13405 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13406 (param->num_band_to_mac *
13407 sizeof(wmi_pdev_band_to_mac)));
13408 }
13409
13410 return buf_ptr;
13411}
13412
13413static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
13414 wmi_init_cmd_fixed_param *cmd)
13415{
13416 int num_whitelist;
13417 wmi_abi_version my_vers;
13418
13419 num_whitelist = sizeof(version_whitelist) /
13420 sizeof(wmi_whitelist_version_info);
13421 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
13422 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
13423 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
13424 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13425 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13426 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13427
13428 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13429 &my_vers,
13430 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13431 &cmd->host_abi_vers);
13432
13433 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13434 __func__,
13435 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13436 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13437 cmd->host_abi_vers.abi_version_ns_0,
13438 cmd->host_abi_vers.abi_version_ns_1,
13439 cmd->host_abi_vers.abi_version_ns_2,
13440 cmd->host_abi_vers.abi_version_ns_3);
13441
13442 /* Save version sent from host -
13443 * Will be used to check ready event
13444 */
13445 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13446 sizeof(wmi_abi_version));
13447}
13448
Sathish Kumarfd347372017-02-13 12:29:09 +053013449static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053013450{
13451 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13452 wmi_service_ready_event_fixed_param *ev;
13453
13454
13455 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13456
13457 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13458 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053013459 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013460
13461 /*Save fw version from service ready message */
13462 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053013463 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013464 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013465
Govind Singhb53420c2016-03-09 14:32:57 +053013466 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013467}
13468
13469/**
13470 * wmi_unified_save_fw_version_cmd() - save fw version
13471 * @wmi_handle: pointer to wmi handle
13472 * @res_cfg: resource config
13473 * @num_mem_chunks: no of mem chunck
13474 * @mem_chunk: pointer to mem chunck structure
13475 *
13476 * This function sends IE information to firmware
13477 *
Govind Singhb53420c2016-03-09 14:32:57 +053013478 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053013479 *
13480 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013481static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053013482 void *evt_buf)
13483{
13484 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13485 wmi_ready_event_fixed_param *ev = NULL;
13486
13487 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13488 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013489 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
13490 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013491 &ev->fw_abi_vers)) {
13492 /*
13493 * Error: Our host version and the given firmware version
13494 * are incompatible.
13495 **/
Govind Singhb53420c2016-03-09 14:32:57 +053013496 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053013497 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
13498 __func__,
13499 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
13500 abi_version_0),
13501 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
13502 abi_version_0),
13503 wmi_handle->final_abi_vers.abi_version_ns_0,
13504 wmi_handle->final_abi_vers.abi_version_ns_1,
13505 wmi_handle->final_abi_vers.abi_version_ns_2,
13506 wmi_handle->final_abi_vers.abi_version_ns_3,
13507 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
13508 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
13509 ev->fw_abi_vers.abi_version_ns_0,
13510 ev->fw_abi_vers.abi_version_ns_1,
13511 ev->fw_abi_vers.abi_version_ns_2,
13512 ev->fw_abi_vers.abi_version_ns_3);
13513
Govind Singhb53420c2016-03-09 14:32:57 +053013514 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013515 }
Govind Singhb53420c2016-03-09 14:32:57 +053013516 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013517 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053013518 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013519 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053013520
Govind Singhb53420c2016-03-09 14:32:57 +053013521 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013522}
Govind Singha4836fd2016-03-07 16:45:38 +053013523
13524/**
13525 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
13526 * @wmi_handle: wmi handle
13527 * @custom_addr: base mac address
13528 *
Govind Singhe7f2f342016-05-23 12:12:52 +053013529 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053013530 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013531static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013532 uint8_t *custom_addr)
13533{
13534 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
13535 wmi_buf_t buf;
13536 int err;
13537
13538 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13539 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013540 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053013541 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013542 }
13543
13544 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013545 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053013546
13547 WMITLV_SET_HDR(&cmd->tlv_header,
13548 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
13549 WMITLV_GET_STRUCT_TLVLEN
13550 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
13551 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013552 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13553 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013554 err = wmi_unified_cmd_send(wmi_handle, buf,
13555 sizeof(*cmd),
13556 WMI_PDEV_SET_BASE_MACADDR_CMDID);
13557 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053013558 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053013559 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013560 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013561 }
13562
13563 return 0;
13564}
13565
13566/**
13567 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
13568 * @handle: wmi handle
13569 * @event: Event received from FW
13570 * @len: Length of the event
13571 *
13572 * Enables the low frequency events and disables the high frequency
13573 * events. Bit 17 indicates if the event if low/high frequency.
13574 * 1 - high frequency, 0 - low frequency
13575 *
13576 * Return: 0 on successfully enabling/disabling the events
13577 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013578static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013579 uint8_t *event,
13580 uint32_t len)
13581{
13582 uint32_t num_of_diag_events_logs;
13583 wmi_diag_event_log_config_fixed_param *cmd;
13584 wmi_buf_t buf;
13585 uint8_t *buf_ptr;
13586 uint32_t *cmd_args, *evt_args;
13587 uint32_t buf_len, i;
13588
13589 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
13590 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
13591
Govind Singhb53420c2016-03-09 14:32:57 +053013592 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053013593
13594 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
13595 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013596 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053013597 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013598 }
13599 wmi_event = param_buf->fixed_param;
13600 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070013601
13602 if (num_of_diag_events_logs >
13603 param_buf->num_diag_events_logs_list) {
13604 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
13605 num_of_diag_events_logs,
13606 param_buf->num_diag_events_logs_list);
13607 return QDF_STATUS_E_INVAL;
13608 }
13609
Govind Singha4836fd2016-03-07 16:45:38 +053013610 evt_args = param_buf->diag_events_logs_list;
13611 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053013612 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013613 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053013614 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013615 }
13616
Govind Singhb53420c2016-03-09 14:32:57 +053013617 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013618 __func__, num_of_diag_events_logs);
13619
13620 /* Free any previous allocation */
13621 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053013622 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013623
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070013624 if (num_of_diag_events_logs >
13625 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
13626 WMI_LOGE("%s: excess num of logs:%d", __func__,
13627 num_of_diag_events_logs);
13628 QDF_ASSERT(0);
13629 return QDF_STATUS_E_INVAL;
13630 }
Govind Singha4836fd2016-03-07 16:45:38 +053013631 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053013632 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053013633 sizeof(uint32_t));
13634 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013635 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013636 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013637 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013638 }
13639 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
13640
13641 /* Prepare the send buffer */
13642 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13643 (num_of_diag_events_logs * sizeof(uint32_t));
13644
13645 buf = wmi_buf_alloc(wmi_handle, buf_len);
13646 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013647 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13648 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013649 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013650 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013651 }
13652
13653 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13654 buf_ptr = (uint8_t *) cmd;
13655
13656 WMITLV_SET_HDR(&cmd->tlv_header,
13657 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13658 WMITLV_GET_STRUCT_TLVLEN(
13659 wmi_diag_event_log_config_fixed_param));
13660
13661 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13662
13663 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13664
13665 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13666 (num_of_diag_events_logs * sizeof(uint32_t)));
13667
13668 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13669
13670 /* Populate the events */
13671 for (i = 0; i < num_of_diag_events_logs; i++) {
13672 /* Low freq (0) - Enable (1) the event
13673 * High freq (1) - Disable (0) the event
13674 */
13675 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13676 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13677 /* Set the event ID */
13678 WMI_DIAG_ID_SET(cmd_args[i],
13679 WMI_DIAG_ID_GET(evt_args[i]));
13680 /* Set the type */
13681 WMI_DIAG_TYPE_SET(cmd_args[i],
13682 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013683 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013684 wmi_handle->events_logs_list[i] = evt_args[i];
13685 }
13686
13687 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13688 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013689 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013690 __func__);
13691 wmi_buf_free(buf);
13692 /* Not clearing events_logs_list, though wmi cmd failed.
13693 * Host can still have this list
13694 */
Govind Singh67922e82016-04-01 16:48:57 +053013695 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013696 }
13697
13698 return 0;
13699}
13700
13701/**
13702 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13703 * @wmi_handle: wmi handle
13704 * @start_log: Start logging related parameters
13705 *
13706 * Send the command to the FW based on which specific logging of diag
13707 * event/log id can be started/stopped
13708 *
13709 * Return: None
13710 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013711static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013712 struct wmi_wifi_start_log *start_log)
13713{
13714 wmi_diag_event_log_config_fixed_param *cmd;
13715 wmi_buf_t buf;
13716 uint8_t *buf_ptr;
13717 uint32_t len, count, log_level, i;
13718 uint32_t *cmd_args;
13719 uint32_t total_len;
13720 count = 0;
13721
13722 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013723 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013724 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013725 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013726 }
13727 /* total_len stores the number of events where BITS 17 and 18 are set.
13728 * i.e., events of high frequency (17) and for extended debugging (18)
13729 */
13730 total_len = 0;
13731 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13732 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13733 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13734 total_len++;
13735 }
13736
13737 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13738 (total_len * sizeof(uint32_t));
13739
13740 buf = wmi_buf_alloc(wmi_handle, len);
13741 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013742 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013743 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013744 }
13745 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13746 buf_ptr = (uint8_t *) cmd;
13747
13748 WMITLV_SET_HDR(&cmd->tlv_header,
13749 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13750 WMITLV_GET_STRUCT_TLVLEN(
13751 wmi_diag_event_log_config_fixed_param));
13752
13753 cmd->num_of_diag_events_logs = total_len;
13754
13755 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13756
13757 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13758 (total_len * sizeof(uint32_t)));
13759
13760 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13761
Govind Singh224a7312016-06-21 14:33:26 +053013762 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013763 log_level = 1;
13764 else
13765 log_level = 0;
13766
Govind Singhb53420c2016-03-09 14:32:57 +053013767 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013768 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13769 uint32_t val = wmi_handle->events_logs_list[i];
13770 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13771 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13772
13773 WMI_DIAG_ID_SET(cmd_args[count],
13774 WMI_DIAG_ID_GET(val));
13775 WMI_DIAG_TYPE_SET(cmd_args[count],
13776 WMI_DIAG_TYPE_GET(val));
13777 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13778 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013779 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013780 count++;
13781 }
13782 }
13783
13784 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13785 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013786 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013787 __func__);
13788 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013789 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013790 }
13791
Govind Singhb53420c2016-03-09 14:32:57 +053013792 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013793}
13794
13795/**
13796 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13797 * @wmi_handle: WMI handle
13798 *
13799 * This function is used to send the flush command to the FW,
13800 * that will flush the fw logs that are residue in the FW
13801 *
13802 * Return: None
13803 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013804static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013805{
13806 wmi_debug_mesg_flush_fixed_param *cmd;
13807 wmi_buf_t buf;
13808 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013809 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013810
13811 buf = wmi_buf_alloc(wmi_handle, len);
13812 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013813 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013814 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013815 }
13816
13817 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13818 WMITLV_SET_HDR(&cmd->tlv_header,
13819 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13820 WMITLV_GET_STRUCT_TLVLEN(
13821 wmi_debug_mesg_flush_fixed_param));
13822 cmd->reserved0 = 0;
13823
13824 ret = wmi_unified_cmd_send(wmi_handle,
13825 buf,
13826 len,
13827 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013828 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013829 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013830 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013831 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013832 }
Govind Singhb53420c2016-03-09 14:32:57 +053013833 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013834
Govind Singh67922e82016-04-01 16:48:57 +053013835 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013836}
13837
13838/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013839 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013840 * @wmi_handle: wmi handle
13841 * @msg: PCL structure containing the PCL and the number of channels
13842 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013843 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013844 * firmware. The DBS Manager is the consumer of this information in the WLAN
13845 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13846 * to migrate to a new channel without host driver involvement. An example of
13847 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13848 * manage the channel selection without firmware involvement.
13849 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013850 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13851 * channel list. The weights corresponds to the channels sent in
13852 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13853 * weightage compared to the non PCL channels.
13854 *
Govind Singha4836fd2016-03-07 16:45:38 +053013855 * Return: Success if the cmd is sent successfully to the firmware
13856 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013857static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013858 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013859{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013860 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013861 wmi_buf_t buf;
13862 uint8_t *buf_ptr;
13863 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013864 uint32_t chan_len;
13865
13866 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013867
13868 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013869 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013870
13871 buf = wmi_buf_alloc(wmi_handle, len);
13872 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013873 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13874 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013875 }
13876
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013877 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013878 buf_ptr = (uint8_t *) cmd;
13879 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013880 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13881 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013882
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013883 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13884 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013885 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013886 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013887
13888 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013889 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013890 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013891 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013892 for (i = 0; i < chan_len ; i++) {
13893 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013894 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013895 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013896 }
13897 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013898 WMI_PDEV_SET_PCL_CMDID)) {
13899 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013900 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013901 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013902 }
Govind Singhb53420c2016-03-09 14:32:57 +053013903 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013904}
13905
13906/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013907 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013908 * @wmi_handle: wmi handle
13909 * @msg: Structure containing the following parameters
13910 *
13911 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13912 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13913 *
13914 * Provides notification to the WLAN firmware that host driver is requesting a
13915 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13916 * configurations that include the Dual Band Simultaneous (DBS) feature.
13917 *
13918 * Return: Success if the cmd is sent successfully to the firmware
13919 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013920static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013921 uint32_t hw_mode_index)
13922{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013923 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013924 wmi_buf_t buf;
13925 uint32_t len;
13926
13927 len = sizeof(*cmd);
13928
13929 buf = wmi_buf_alloc(wmi_handle, len);
13930 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013931 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13932 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013933 }
13934
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013935 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013936 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013937 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13938 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13939
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013940 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13941 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013942 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013943 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013944
13945 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013946 WMI_PDEV_SET_HW_MODE_CMDID)) {
13947 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013948 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013949 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013950 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013951 }
13952
Govind Singhb53420c2016-03-09 14:32:57 +053013953 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013954}
13955
13956/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013957 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013958 * @wmi_handle: wmi handle
13959 * @msg: Dual MAC config parameters
13960 *
13961 * Configures WLAN firmware with the dual MAC features
13962 *
Govind Singhb53420c2016-03-09 14:32:57 +053013963 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013964 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013965static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013966QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013967 struct wmi_dual_mac_config *msg)
13968{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013969 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013970 wmi_buf_t buf;
13971 uint32_t len;
13972
13973 len = sizeof(*cmd);
13974
13975 buf = wmi_buf_alloc(wmi_handle, len);
13976 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013977 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13978 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013979 }
13980
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013981 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013982 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013983 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013984 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013985 wmi_pdev_set_mac_config_cmd_fixed_param));
13986
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013987 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13988 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013989 cmd->concurrent_scan_config_bits = msg->scan_config;
13990 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013991 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013992 __func__, msg->scan_config, msg->fw_mode_config);
13993
13994 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013995 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13996 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013997 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013998 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013999 }
Govind Singhb53420c2016-03-09 14:32:57 +053014000 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014001}
14002
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014003#ifdef BIG_ENDIAN_HOST
14004/**
14005* fips_conv_data_be() - LE to BE conversion of FIPS ev data
14006* @param data_len - data length
14007* @param data - pointer to data
14008*
14009* Return: QDF_STATUS - success or error status
14010*/
14011static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14012 struct fips_params *param)
14013{
14014 unsigned char *key_unaligned, *data_unaligned;
14015 int c;
14016 u_int8_t *key_aligned = NULL;
14017 u_int8_t *data_aligned = NULL;
14018
14019 /* Assigning unaligned space to copy the key */
14020 key_unaligned = qdf_mem_malloc(
14021 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
14022 data_unaligned = qdf_mem_malloc(
14023 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
14024
14025 /* Checking if kmalloc is succesful to allocate space */
14026 if (key_unaligned == NULL)
14027 return QDF_STATUS_SUCCESS;
14028 /* Checking if space is aligned */
14029 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
14030 /* align to 4 */
14031 key_aligned =
14032 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
14033 FIPS_ALIGN);
14034 } else {
14035 key_aligned = (u_int8_t *)key_unaligned;
14036 }
14037
14038 /* memset and copy content from key to key aligned */
14039 OS_MEMSET(key_aligned, 0, param->key_len);
14040 OS_MEMCPY(key_aligned, param->key, param->key_len);
14041
14042 /* print a hexdump for host debug */
14043 print_hex_dump(KERN_DEBUG,
14044 "\t Aligned and Copied Key:@@@@ ",
14045 DUMP_PREFIX_NONE,
14046 16, 1, key_aligned, param->key_len, true);
14047
14048 /* Checking if kmalloc is succesful to allocate space */
14049 if (data_unaligned == NULL)
14050 return QDF_STATUS_SUCCESS;
14051 /* Checking of space is aligned */
14052 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
14053 /* align to 4 */
14054 data_aligned =
14055 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
14056 FIPS_ALIGN);
14057 } else {
14058 data_aligned = (u_int8_t *)data_unaligned;
14059 }
14060
14061 /* memset and copy content from data to data aligned */
14062 OS_MEMSET(data_aligned, 0, param->data_len);
14063 OS_MEMCPY(data_aligned, param->data, param->data_len);
14064
14065 /* print a hexdump for host debug */
14066 print_hex_dump(KERN_DEBUG,
14067 "\t Properly Aligned and Copied Data:@@@@ ",
14068 DUMP_PREFIX_NONE,
14069 16, 1, data_aligned, param->data_len, true);
14070
14071 /* converting to little Endian both key_aligned and
14072 * data_aligned*/
14073 for (c = 0; c < param->key_len/4; c++) {
14074 *((u_int32_t *)key_aligned+c) =
14075 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
14076 }
14077 for (c = 0; c < param->data_len/4; c++) {
14078 *((u_int32_t *)data_aligned+c) =
14079 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
14080 }
14081
14082 /* update endian data to key and data vectors */
14083 OS_MEMCPY(param->key, key_aligned, param->key_len);
14084 OS_MEMCPY(param->data, data_aligned, param->data_len);
14085
14086 /* clean up allocated spaces */
14087 qdf_mem_free(key_unaligned);
14088 key_unaligned = NULL;
14089 key_aligned = NULL;
14090
14091 qdf_mem_free(data_unaligned);
14092 data_unaligned = NULL;
14093 data_aligned = NULL;
14094
14095 return QDF_STATUS_SUCCESS;
14096}
14097#else
14098/**
14099* fips_align_data_be() - DUMMY for LE platform
14100*
14101* Return: QDF_STATUS - success
14102*/
14103static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14104 struct fips_params *param)
14105{
14106 return QDF_STATUS_SUCCESS;
14107}
14108#endif
14109
14110
14111/**
14112 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
14113 * @wmi_handle: wmi handle
14114 * @param: pointer to hold pdev fips param
14115 *
14116 * Return: 0 for success or error code
14117 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014118static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014119send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
14120 struct fips_params *param)
14121{
14122 wmi_pdev_fips_cmd_fixed_param *cmd;
14123 wmi_buf_t buf;
14124 uint8_t *buf_ptr;
14125 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
14126 QDF_STATUS retval = QDF_STATUS_SUCCESS;
14127
14128 /* Length TLV placeholder for array of bytes */
14129 len += WMI_TLV_HDR_SIZE;
14130 if (param->data_len)
14131 len += (param->data_len*sizeof(uint8_t));
14132
14133 /*
14134 * Data length must be multiples of 16 bytes - checked against 0xF -
14135 * and must be less than WMI_SVC_MSG_SIZE - static size of
14136 * wmi_pdev_fips_cmd structure
14137 */
14138
14139 /* do sanity on the input */
14140 if (!(((param->data_len & 0xF) == 0) &&
14141 ((param->data_len > 0) &&
14142 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
14143 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
14144 return QDF_STATUS_E_INVAL;
14145 }
14146
14147 buf = wmi_buf_alloc(wmi_handle, len);
14148 if (!buf) {
14149 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
14150 return QDF_STATUS_E_FAILURE;
14151 }
14152
14153 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14154 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
14155 WMITLV_SET_HDR(&cmd->tlv_header,
14156 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
14157 WMITLV_GET_STRUCT_TLVLEN
14158 (wmi_pdev_fips_cmd_fixed_param));
14159
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014160 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14161 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014162 if (param->key != NULL && param->data != NULL) {
14163 cmd->key_len = param->key_len;
14164 cmd->data_len = param->data_len;
14165 cmd->fips_cmd = !!(param->op);
14166
14167 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
14168 return QDF_STATUS_E_FAILURE;
14169
14170 qdf_mem_copy(cmd->key, param->key, param->key_len);
14171
14172 if (param->mode == FIPS_ENGINE_AES_CTR ||
14173 param->mode == FIPS_ENGINE_AES_MIC) {
14174 cmd->mode = param->mode;
14175 } else {
14176 cmd->mode = FIPS_ENGINE_AES_CTR;
14177 }
14178 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
14179 cmd->key_len, cmd->data_len);
14180
14181 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
14182 cmd->key, cmd->key_len, true);
14183 buf_ptr += sizeof(*cmd);
14184
14185 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
14186
14187 buf_ptr += WMI_TLV_HDR_SIZE;
14188 if (param->data_len)
14189 qdf_mem_copy(buf_ptr,
14190 (uint8_t *) param->data, param->data_len);
14191
14192 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
14193 16, 1, buf_ptr, cmd->data_len, true);
14194
14195 buf_ptr += param->data_len;
14196
14197 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
14198 WMI_PDEV_FIPS_CMDID);
14199 qdf_print("%s return value %d\n", __func__, retval);
14200 } else {
14201 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
14202 wmi_buf_free(buf);
14203 retval = -QDF_STATUS_E_BADMSG;
14204 }
14205
14206 return retval;
14207}
14208
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014209#ifdef WLAN_PMO_ENABLE
14210/**
14211 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
14212 * @wmi_handle: wmi handle
14213 * @vdev_id: vdev id
14214 * @bitmap: Event bitmap
14215 * @enable: enable/disable
14216 *
14217 * Return: CDF status
14218 */
14219static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
14220 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014221 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014222 bool enable)
14223{
14224 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
14225 uint16_t len;
14226 wmi_buf_t buf;
14227 int ret;
14228
14229 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
14230 buf = wmi_buf_alloc(wmi_handle, len);
14231 if (!buf) {
14232 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14233 return QDF_STATUS_E_NOMEM;
14234 }
14235 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
14236 WMITLV_SET_HDR(&cmd->tlv_header,
14237 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
14238 WMITLV_GET_STRUCT_TLVLEN
14239 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
14240 cmd->vdev_id = vdev_id;
14241 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014242 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
14243 WMI_WOW_MAX_EVENT_BM_LEN);
14244
14245 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
14246 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
14247 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014248
14249 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14250 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
14251 if (ret) {
14252 WMI_LOGE("Failed to config wow wakeup event");
14253 wmi_buf_free(buf);
14254 return QDF_STATUS_E_FAILURE;
14255 }
14256
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014257 return QDF_STATUS_SUCCESS;
14258}
14259
14260/**
14261 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
14262 * @wmi_handle: wmi handle
14263 * @vdev_id: vdev id
14264 * @ptrn_id: pattern id
14265 * @ptrn: pattern
14266 * @ptrn_len: pattern length
14267 * @ptrn_offset: pattern offset
14268 * @mask: mask
14269 * @mask_len: mask length
14270 * @user: true for user configured pattern and false for default pattern
14271 * @default_patterns: default patterns
14272 *
14273 * Return: CDF status
14274 */
14275static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
14276 uint8_t vdev_id, uint8_t ptrn_id,
14277 const uint8_t *ptrn, uint8_t ptrn_len,
14278 uint8_t ptrn_offset, const uint8_t *mask,
14279 uint8_t mask_len, bool user,
14280 uint8_t default_patterns)
14281{
14282 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14283 WOW_BITMAP_PATTERN_T *bitmap_pattern;
14284 wmi_buf_t buf;
14285 uint8_t *buf_ptr;
14286 int32_t len;
14287 int ret;
14288
14289 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14290 WMI_TLV_HDR_SIZE +
14291 1 * sizeof(WOW_BITMAP_PATTERN_T) +
14292 WMI_TLV_HDR_SIZE +
14293 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14294 WMI_TLV_HDR_SIZE +
14295 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14296 WMI_TLV_HDR_SIZE +
14297 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14298 WMI_TLV_HDR_SIZE +
14299 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
14300
14301 buf = wmi_buf_alloc(wmi_handle, len);
14302 if (!buf) {
14303 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14304 return QDF_STATUS_E_NOMEM;
14305 }
14306
14307 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14308 buf_ptr = (uint8_t *) cmd;
14309
14310 WMITLV_SET_HDR(&cmd->tlv_header,
14311 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14312 WMITLV_GET_STRUCT_TLVLEN
14313 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14314 cmd->vdev_id = vdev_id;
14315 cmd->pattern_id = ptrn_id;
14316
14317 cmd->pattern_type = WOW_BITMAP_PATTERN;
14318 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14319
14320 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14321 sizeof(WOW_BITMAP_PATTERN_T));
14322 buf_ptr += WMI_TLV_HDR_SIZE;
14323 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
14324
14325 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
14326 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
14327 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
14328
14329 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
14330 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
14331
14332 bitmap_pattern->pattern_offset = ptrn_offset;
14333 bitmap_pattern->pattern_len = ptrn_len;
14334
14335 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
14336 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
14337
14338 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
14339 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
14340
14341 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
14342 bitmap_pattern->pattern_id = ptrn_id;
14343
14344 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
14345 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
14346 bitmap_pattern->pattern_offset, user);
14347 WMI_LOGI("Pattern : ");
14348 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14349 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
14350
14351 WMI_LOGI("Mask : ");
14352 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14353 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
14354
14355 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
14356
14357 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14359 buf_ptr += WMI_TLV_HDR_SIZE;
14360
14361 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14362 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14363 buf_ptr += WMI_TLV_HDR_SIZE;
14364
14365 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14366 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14367 buf_ptr += WMI_TLV_HDR_SIZE;
14368
14369 /* Fill TLV for pattern_info_timeout but no data. */
14370 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14371 buf_ptr += WMI_TLV_HDR_SIZE;
14372
14373 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
14374 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
14375 buf_ptr += WMI_TLV_HDR_SIZE;
14376 *(A_UINT32 *) buf_ptr = 0;
14377
14378 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14379 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14380 if (ret) {
14381 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
14382 wmi_buf_free(buf);
14383 return QDF_STATUS_E_FAILURE;
14384 }
14385
14386 return QDF_STATUS_SUCCESS;
14387}
14388
Govind Singha4836fd2016-03-07 16:45:38 +053014389/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014390 * fill_arp_offload_params_tlv() - Fill ARP offload data
14391 * @wmi_handle: wmi handle
14392 * @offload_req: offload request
14393 * @buf_ptr: buffer pointer
14394 *
14395 * To fill ARP offload data to firmware
14396 * when target goes to wow mode.
14397 *
14398 * Return: None
14399 */
14400static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014401 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014402{
14403
14404 int i;
14405 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014406 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014407
14408 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14409 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
14410 *buf_ptr += WMI_TLV_HDR_SIZE;
14411 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
14412 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
14413 WMITLV_SET_HDR(&arp_tuple->tlv_header,
14414 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
14415 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
14416
14417 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014418 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014419 /* Copy the target ip addr and flags */
14420 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
14421 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014422 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014423 WMI_IPV4_ADDR_LEN);
14424 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014425 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014426 }
14427 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
14428 }
14429}
14430
14431#ifdef WLAN_NS_OFFLOAD
14432/**
14433 * fill_ns_offload_params_tlv() - Fill NS offload data
14434 * @wmi|_handle: wmi handle
14435 * @offload_req: offload request
14436 * @buf_ptr: buffer pointer
14437 *
14438 * To fill NS offload data to firmware
14439 * when target goes to wow mode.
14440 *
14441 * Return: None
14442 */
14443static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014444 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014445{
14446
14447 int i;
14448 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014449
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014450 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14451 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14452 *buf_ptr += WMI_TLV_HDR_SIZE;
14453 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
14454 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14455 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14456 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14457 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
14458
14459 /*
14460 * Fill data only for NS offload in the first ARP tuple for LA
14461 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014462 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014463 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14464 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014465 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014466 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014467 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014468 sizeof(WMI_IPV6_ADDR));
14469 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014470 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014471 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014472 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014473 ns_tuple->flags |=
14474 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14475 }
14476 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014477 i, &ns_req->self_ipv6_addr[i],
14478 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014479
14480 /* target MAC is optional, check if it is valid,
14481 * if this is not valid, the target will use the known
14482 * local MAC address rather than the tuple
14483 */
14484 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014485 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014486 &ns_tuple->target_mac);
14487 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14488 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14489 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14490 }
14491 }
14492 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14493 }
14494}
14495
14496
14497/**
14498 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
14499 * @wmi: wmi handle
14500 * @offload_req: offload request
14501 * @buf_ptr: buffer pointer
14502 *
14503 * To fill extended NS offload extended data to firmware
14504 * when target goes to wow mode.
14505 *
14506 * Return: None
14507 */
14508static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014509 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014510{
14511 int i;
14512 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
14513 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014514
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014515 count = ns_req->num_ns_offload_count;
14516 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014517 WMI_MAX_NS_OFFLOADS;
14518
14519 /* Populate extended NS offload tuples */
14520 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14521 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14522 *buf_ptr += WMI_TLV_HDR_SIZE;
14523 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
14524 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14525 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14526 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14527 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
14528
14529 /*
14530 * Fill data only for NS offload in the first ARP tuple for LA
14531 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014532 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014533 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14534 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014535 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014536 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014537 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014538 sizeof(WMI_IPV6_ADDR));
14539 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014540 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014541 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014542 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014543 ns_tuple->flags |=
14544 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14545 }
14546 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014547 i, &ns_req->self_ipv6_addr[i],
14548 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014549
14550 /* target MAC is optional, check if it is valid,
14551 * if this is not valid, the target will use the
14552 * known local MAC address rather than the tuple
14553 */
14554 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014555 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014556 &ns_tuple->target_mac);
14557 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14558 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14559 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14560 }
14561 }
14562 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14563 }
14564}
14565#else
14566static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014567 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014568{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014569}
14570
14571static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014572 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014573{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014574}
14575#endif
14576
14577/**
Govind Singha4836fd2016-03-07 16:45:38 +053014578 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
14579 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014580 * @arp_offload_req: arp offload request
14581 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053014582 * @arp_only: flag
14583 *
14584 * To configure ARP NS off load data to firmware
14585 * when target goes to wow mode.
14586 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014587 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053014588 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014589static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014590 struct pmo_arp_offload_params *arp_offload_req,
14591 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053014592 uint8_t vdev_id)
14593{
Govind Singha4836fd2016-03-07 16:45:38 +053014594 int32_t res;
14595 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053014596 A_UINT8 *buf_ptr;
14597 wmi_buf_t buf;
14598 int32_t len;
14599 uint32_t count = 0, num_ns_ext_tuples = 0;
14600
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014601 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053014602
Govind Singha4836fd2016-03-07 16:45:38 +053014603 /*
14604 * TLV place holder size for array of NS tuples
14605 * TLV place holder size for array of ARP tuples
14606 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014607 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
14608 WMI_TLV_HDR_SIZE +
14609 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
14610 WMI_TLV_HDR_SIZE +
14611 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014612
14613 /*
14614 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
14615 * extra length for extended NS offload tuples which follows ARP offload
14616 * tuples. Host needs to fill this structure in following format:
14617 * 2 NS ofload tuples
14618 * 2 ARP offload tuples
14619 * N numbers of extended NS offload tuples if HDD has given more than
14620 * 2 NS offload addresses
14621 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014622 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053014623 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014624 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
14625 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014626 }
14627
14628 buf = wmi_buf_alloc(wmi_handle, len);
14629 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014630 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014631 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014632 }
14633
14634 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
14635 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
14636 WMITLV_SET_HDR(&cmd->tlv_header,
14637 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
14638 WMITLV_GET_STRUCT_TLVLEN
14639 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
14640 cmd->flags = 0;
14641 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014642 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053014643
Govind Singhb53420c2016-03-09 14:32:57 +053014644 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053014645
Govind Singha4836fd2016-03-07 16:45:38 +053014646 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014647 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
14648 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14649 if (num_ns_ext_tuples)
14650 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014651
14652 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14653 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14654 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014655 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014656 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014657 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014658 }
14659
Govind Singhb53420c2016-03-09 14:32:57 +053014660 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014661}
14662
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014663/**
14664 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14665 * @wmi_handle: wmi handle
14666 * @vdev_id: vdev id
14667 * @action: true for enable else false
14668 *
14669 * To enable enhance multicast offload to firmware
14670 * when target goes to wow mode.
14671 *
14672 * Return: QDF Status
14673 */
14674
14675static
14676QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14677 wmi_unified_t wmi_handle,
14678 uint8_t vdev_id, bool action)
14679{
14680 QDF_STATUS status;
14681 wmi_buf_t buf;
14682 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14683
14684 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14685 if (!buf) {
14686 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14687 return QDF_STATUS_E_NOMEM;
14688 }
14689
14690 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14691 wmi_buf_data(buf);
14692
14693 WMITLV_SET_HDR(&cmd->tlv_header,
14694 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14695 WMITLV_GET_STRUCT_TLVLEN(
14696 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14697
14698 cmd->vdev_id = vdev_id;
14699 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14700 ENHANCED_MCAST_FILTER_ENABLED);
14701 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14702 __func__, action, vdev_id);
14703 status = wmi_unified_cmd_send(wmi_handle, buf,
14704 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14705 if (status != QDF_STATUS_SUCCESS) {
14706 qdf_nbuf_free(buf);
14707 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14708 __func__);
14709 }
14710
14711 return status;
14712}
14713
14714/**
14715 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14716 * @wmi_handle: wmi handle
14717 * @param evt_buf: pointer to event buffer
14718 * @param hdr: Pointer to hold header
14719 * @param bufp: Pointer to hold pointer to rx param buffer
14720 *
14721 * Return: QDF_STATUS_SUCCESS for success or error code
14722 */
14723static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14724 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14725{
14726 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14727 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14728
14729 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14730 if (!param_buf) {
14731 WMI_LOGE("gtk param_buf is NULL");
14732 return QDF_STATUS_E_INVAL;
14733 }
14734
14735 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14736 WMI_LOGE("Invalid length for GTK status");
14737 return QDF_STATUS_E_INVAL;
14738 }
14739
14740 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14741 param_buf->fixed_param;
14742 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14743 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14744 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14745 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14746 &fixed_param->replay_counter,
14747 GTK_REPLAY_COUNTER_BYTES);
14748
14749 return QDF_STATUS_SUCCESS;
14750
14751}
14752
14753#ifdef FEATURE_WLAN_RA_FILTERING
14754/**
14755 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14756 * @wmi_handle: wmi handle
14757 * @vdev_id: vdev id
14758 *
14759 * Return: CDF status
14760 */
14761static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14762 uint8_t vdev_id, uint8_t default_pattern,
14763 uint16_t rate_limit_interval)
14764{
14765
14766 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14767 wmi_buf_t buf;
14768 uint8_t *buf_ptr;
14769 int32_t len;
14770 int ret;
14771
14772 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14773 WMI_TLV_HDR_SIZE +
14774 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14775 WMI_TLV_HDR_SIZE +
14776 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14777 WMI_TLV_HDR_SIZE +
14778 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14779 WMI_TLV_HDR_SIZE +
14780 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14781 WMI_TLV_HDR_SIZE +
14782 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
14783
14784 buf = wmi_buf_alloc(wmi_handle, len);
14785 if (!buf) {
14786 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14787 return QDF_STATUS_E_NOMEM;
14788 }
14789
14790 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14791 buf_ptr = (uint8_t *) cmd;
14792
14793 WMITLV_SET_HDR(&cmd->tlv_header,
14794 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14795 WMITLV_GET_STRUCT_TLVLEN
14796 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14797 cmd->vdev_id = vdev_id;
14798 cmd->pattern_id = default_pattern,
14799 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14800 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14801
14802 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14803 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14804 buf_ptr += WMI_TLV_HDR_SIZE;
14805
14806 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14807 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14808 buf_ptr += WMI_TLV_HDR_SIZE;
14809
14810 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14811 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14812 buf_ptr += WMI_TLV_HDR_SIZE;
14813
14814 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14815 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14816 buf_ptr += WMI_TLV_HDR_SIZE;
14817
14818 /* Fill TLV for pattern_info_timeout but no data. */
14819 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14820 buf_ptr += WMI_TLV_HDR_SIZE;
14821
14822 /* Fill TLV for ra_ratelimit_interval. */
14823 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
14824 buf_ptr += WMI_TLV_HDR_SIZE;
14825
14826 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
14827
14828 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14829 rate_limit_interval, vdev_id);
14830
14831 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14832 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14833 if (ret) {
14834 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14835 wmi_buf_free(buf);
14836 return QDF_STATUS_E_FAILURE;
14837 }
14838
14839 return QDF_STATUS_SUCCESS;
14840
14841}
14842#endif /* FEATURE_WLAN_RA_FILTERING */
14843
14844/**
14845 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14846 * @wmi_handle: wmi handle
14847 * @vdev_id: vdev id
14848 * @multicastAddr: mcast address
14849 * @clearList: clear list flag
14850 *
14851 * Return: QDF_STATUS_SUCCESS for success or error code
14852 */
14853static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14854 uint8_t vdev_id,
14855 struct qdf_mac_addr multicast_addr,
14856 bool clearList)
14857{
14858 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14859 wmi_buf_t buf;
14860 int err;
14861
14862 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14863 if (!buf) {
14864 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14865 return QDF_STATUS_E_NOMEM;
14866 }
14867
14868 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14869 qdf_mem_zero(cmd, sizeof(*cmd));
14870
14871 WMITLV_SET_HDR(&cmd->tlv_header,
14872 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14873 WMITLV_GET_STRUCT_TLVLEN
14874 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14875 cmd->action =
14876 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14877 cmd->vdev_id = vdev_id;
14878 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14879
14880 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14881 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14882
14883 err = wmi_unified_cmd_send(wmi_handle, buf,
14884 sizeof(*cmd),
14885 WMI_SET_MCASTBCAST_FILTER_CMDID);
14886 if (err) {
14887 WMI_LOGE("Failed to send set_param cmd");
14888 wmi_buf_free(buf);
14889 return QDF_STATUS_E_FAILURE;
14890 }
14891
14892 return QDF_STATUS_SUCCESS;
14893}
14894
14895/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014896 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14897 * command to fw
14898 * @wmi_handle: wmi handle
14899 * @vdev_id: vdev id
14900 * @mcast_filter_params: mcast filter params
14901 *
14902 * Return: QDF_STATUS_SUCCESS for success or error code
14903 */
14904static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14905 wmi_unified_t wmi_handle,
14906 uint8_t vdev_id,
14907 struct pmo_mcast_filter_params *filter_param)
14908
14909{
14910 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14911 uint8_t *buf_ptr;
14912 wmi_buf_t buf;
14913 int err;
14914 int i;
14915 uint8_t *mac_addr_src_ptr = NULL;
14916 wmi_mac_addr *mac_addr_dst_ptr;
14917 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14918 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14919
14920 buf = wmi_buf_alloc(wmi_handle, len);
14921 if (!buf) {
14922 WMI_LOGE("Failed to allocate memory");
14923 return QDF_STATUS_E_NOMEM;
14924 }
14925
14926 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
14927 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14928 wmi_buf_data(buf);
14929 qdf_mem_zero(cmd, sizeof(*cmd));
14930
14931 WMITLV_SET_HDR(&cmd->tlv_header,
14932 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14933 WMITLV_GET_STRUCT_TLVLEN
14934 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14935 cmd->operation =
14936 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14937 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14938 cmd->vdev_id = vdev_id;
14939 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14940
14941 buf_ptr += sizeof(*cmd);
14942 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14943 sizeof(wmi_mac_addr) *
14944 filter_param->multicast_addr_cnt);
14945
14946 if (filter_param->multicast_addr_cnt == 0)
14947 goto send_cmd;
14948
14949 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14950 mac_addr_dst_ptr = (wmi_mac_addr *)
14951 (buf_ptr + WMI_TLV_HDR_SIZE);
14952
14953 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14954 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14955 mac_addr_src_ptr += ATH_MAC_LEN;
14956 mac_addr_dst_ptr++;
14957 }
14958
14959send_cmd:
14960 err = wmi_unified_cmd_send(wmi_handle, buf,
14961 len,
14962 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14963 if (err) {
14964 WMI_LOGE("Failed to send set_param cmd");
14965 wmi_buf_free(buf);
14966 return QDF_STATUS_E_FAILURE;
14967 }
14968
14969 return QDF_STATUS_SUCCESS;
14970}
14971
14972
14973/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014974 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14975 * @wmi_handle: wmi handle
14976 * @vdev_id: vdev id
14977 * @params: GTK offload parameters
14978 *
14979 * Return: CDF status
14980 */
14981static
14982QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14983 struct pmo_gtk_req *params,
14984 bool enable_offload,
14985 uint32_t gtk_offload_opcode)
14986{
14987 int len;
14988 wmi_buf_t buf;
14989 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014990 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014991 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014992 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014993
14994 WMI_LOGD("%s Enter", __func__);
14995
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014996 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014997
14998 /* alloc wmi buffer */
14999 buf = wmi_buf_alloc(wmi_handle, len);
15000 if (!buf) {
15001 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
15002 status = QDF_STATUS_E_NOMEM;
15003 goto out;
15004 }
15005
15006 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015007 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015008 WMITLV_SET_HDR(&cmd->tlv_header,
15009 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15010 WMITLV_GET_STRUCT_TLVLEN
15011 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15012
15013 cmd->vdev_id = vdev_id;
15014
15015 /* Request target to enable GTK offload */
15016 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
15017 cmd->flags = gtk_offload_opcode;
15018
15019 /* Copy the keys and replay counter */
15020 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015021 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015022 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
15023 GTK_REPLAY_COUNTER_BYTES);
15024 } else {
15025 cmd->flags = gtk_offload_opcode;
15026 }
15027
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015028 buf_ptr += sizeof(*cmd);
15029 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
15030 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015031
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015032 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
15033 WMITLV_SET_HDR(&ext_param->tlv_header,
15034 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
15035 WMITLV_GET_STRUCT_TLVLEN(
15036 wmi_gtk_offload_fils_tlv_param));
15037 ext_param->vdev_id = vdev_id;
15038 ext_param->flags = cmd->flags;
15039 ext_param->kek_len = params->kek_len;
15040 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
15041 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
15042 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
15043 GTK_REPLAY_COUNTER_BYTES);
15044
15045 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 +053015046 /* send the wmi command */
15047 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15048 WMI_GTK_OFFLOAD_CMDID)) {
15049 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
15050 wmi_buf_free(buf);
15051 status = QDF_STATUS_E_FAILURE;
15052 }
15053
15054out:
15055 WMI_LOGD("%s Exit", __func__);
15056 return status;
15057}
15058
15059/**
15060 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
15061 * @wmi_handle: wmi handle
15062 * @params: GTK offload params
15063 *
15064 * Return: CDF status
15065 */
15066static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
15067 wmi_unified_t wmi_handle,
15068 uint8_t vdev_id,
15069 uint64_t offload_req_opcode)
15070{
15071 int len;
15072 wmi_buf_t buf;
15073 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
15074 QDF_STATUS status = QDF_STATUS_SUCCESS;
15075
15076 len = sizeof(*cmd);
15077
15078 /* alloc wmi buffer */
15079 buf = wmi_buf_alloc(wmi_handle, len);
15080 if (!buf) {
15081 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
15082 status = QDF_STATUS_E_NOMEM;
15083 goto out;
15084 }
15085
15086 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
15087 WMITLV_SET_HDR(&cmd->tlv_header,
15088 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15089 WMITLV_GET_STRUCT_TLVLEN
15090 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15091
15092 /* Request for GTK offload status */
15093 cmd->flags = offload_req_opcode;
15094 cmd->vdev_id = vdev_id;
15095
15096 /* send the wmi command */
15097 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15098 WMI_GTK_OFFLOAD_CMDID)) {
15099 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
15100 wmi_buf_free(buf);
15101 status = QDF_STATUS_E_FAILURE;
15102 }
15103
15104out:
15105 return status;
15106}
15107
15108/**
15109 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
15110 * @wmi_handle: wmi handler
15111 * @action_params: pointer to action_params
15112 *
15113 * Return: 0 for success, otherwise appropriate error code
15114 */
15115static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
15116 struct pmo_action_wakeup_set_params *action_params)
15117{
15118 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
15119 wmi_buf_t buf;
15120 int i;
15121 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015122 uint32_t len = 0, *cmd_args;
15123 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015124
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015125 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32))
15126 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
15127 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015128 if (!buf) {
15129 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
15130 return QDF_STATUS_E_NOMEM;
15131 }
15132 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015133 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015134 WMITLV_SET_HDR(&cmd->tlv_header,
15135 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
15136 WMITLV_GET_STRUCT_TLVLEN(
15137 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
15138
15139 cmd->vdev_id = action_params->vdev_id;
15140 cmd->operation = action_params->operation;
15141
15142 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
15143 cmd->action_category_map[i] =
15144 action_params->action_category_map[i];
15145
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015146 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
15147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15148 (PMO_SUPPORTED_ACTION_CATE * sizeof(A_UINT32)));
15149 buf_ptr += WMI_TLV_HDR_SIZE;
15150 cmd_args = (uint32_t *) buf_ptr;
15151 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
15152 cmd_args[i] = action_params->action_per_category[i];
15153
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015154 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015155 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015156 if (err) {
15157 WMI_LOGE("Failed to send ap_ps_egap cmd");
15158 wmi_buf_free(buf);
15159 return QDF_STATUS_E_FAILURE;
15160 }
15161
15162 return QDF_STATUS_SUCCESS;
15163}
15164
15165#ifdef FEATURE_WLAN_LPHB
15166
15167/**
15168 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
15169 * @wmi_handle: wmi handle
15170 * @lphb_conf_req: configuration info
15171 *
15172 * Return: CDF status
15173 */
15174static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
15175 wmi_hb_set_enable_cmd_fixed_param *params)
15176{
15177 QDF_STATUS status;
15178 wmi_buf_t buf = NULL;
15179 uint8_t *buf_ptr;
15180 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
15181 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
15182
15183
15184 buf = wmi_buf_alloc(wmi_handle, len);
15185 if (!buf) {
15186 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15187 return QDF_STATUS_E_NOMEM;
15188 }
15189
15190 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15191 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
15192 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
15193 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
15194 WMITLV_GET_STRUCT_TLVLEN
15195 (wmi_hb_set_enable_cmd_fixed_param));
15196
15197 /* fill in values */
15198 hb_enable_fp->vdev_id = params->session;
15199 hb_enable_fp->enable = params->enable;
15200 hb_enable_fp->item = params->item;
15201 hb_enable_fp->session = params->session;
15202
15203 status = wmi_unified_cmd_send(wmi_handle, buf,
15204 len, WMI_HB_SET_ENABLE_CMDID);
15205 if (QDF_IS_STATUS_ERROR(status)) {
15206 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
15207 status);
15208 wmi_buf_free(buf);
15209 }
15210
15211 return status;
15212}
15213
15214/**
15215 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
15216 * @wmi_handle: wmi handle
15217 * @lphb_conf_req: lphb config request
15218 *
15219 * Return: CDF status
15220 */
15221static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
15222 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
15223{
15224 QDF_STATUS status;
15225 wmi_buf_t buf = NULL;
15226 uint8_t *buf_ptr;
15227 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
15228 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
15229
15230 buf = wmi_buf_alloc(wmi_handle, len);
15231 if (!buf) {
15232 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15233 return QDF_STATUS_E_NOMEM;
15234 }
15235
15236 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15237 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
15238 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
15239 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
15240 WMITLV_GET_STRUCT_TLVLEN
15241 (wmi_hb_set_tcp_params_cmd_fixed_param));
15242
15243 /* fill in values */
15244 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15245 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15246 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15247 hb_tcp_params_fp->seq = lphb_conf_req->seq;
15248 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
15249 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
15250 hb_tcp_params_fp->interval = lphb_conf_req->interval;
15251 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
15252 hb_tcp_params_fp->session = lphb_conf_req->session;
15253 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
15254 &lphb_conf_req->gateway_mac,
15255 sizeof(hb_tcp_params_fp->gateway_mac));
15256
15257 status = wmi_unified_cmd_send(wmi_handle, buf,
15258 len, WMI_HB_SET_TCP_PARAMS_CMDID);
15259 if (QDF_IS_STATUS_ERROR(status)) {
15260 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
15261 status);
15262 wmi_buf_free(buf);
15263 }
15264
15265 return status;
15266}
15267
15268/**
15269 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
15270 * @wmi_handle: wmi handle
15271 * @lphb_conf_req: lphb config request
15272 *
15273 * Return: CDF status
15274 */
15275static
15276QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15277 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
15278{
15279 QDF_STATUS status;
15280 wmi_buf_t buf = NULL;
15281 uint8_t *buf_ptr;
15282 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
15283 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
15284
15285 buf = wmi_buf_alloc(wmi_handle, len);
15286 if (!buf) {
15287 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15288 return QDF_STATUS_E_NOMEM;
15289 }
15290
15291 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15292 hb_tcp_filter_fp =
15293 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
15294 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
15295 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
15296 WMITLV_GET_STRUCT_TLVLEN
15297 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
15298
15299 /* fill in values */
15300 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
15301 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
15302 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
15303 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
15304 memcpy((void *)&hb_tcp_filter_fp->filter,
15305 (void *)&g_hb_tcp_filter_fp->filter,
15306 WMI_WLAN_HB_MAX_FILTER_SIZE);
15307
15308 status = wmi_unified_cmd_send(wmi_handle, buf,
15309 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
15310 if (QDF_IS_STATUS_ERROR(status)) {
15311 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
15312 status);
15313 wmi_buf_free(buf);
15314 }
15315
15316 return status;
15317}
15318
15319/**
15320 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
15321 * @wmi_handle: wmi handle
15322 * @lphb_conf_req: lphb config request
15323 *
15324 * Return: CDF status
15325 */
15326static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
15327 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
15328{
15329 QDF_STATUS status;
15330 wmi_buf_t buf = NULL;
15331 uint8_t *buf_ptr;
15332 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
15333 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
15334
15335 buf = wmi_buf_alloc(wmi_handle, len);
15336 if (!buf) {
15337 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15338 return QDF_STATUS_E_NOMEM;
15339 }
15340
15341 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15342 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
15343 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
15344 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
15345 WMITLV_GET_STRUCT_TLVLEN
15346 (wmi_hb_set_udp_params_cmd_fixed_param));
15347
15348 /* fill in values */
15349 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15350 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15351 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15352 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
15353 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
15354 hb_udp_params_fp->interval = lphb_conf_req->interval;
15355 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
15356 hb_udp_params_fp->session = lphb_conf_req->session;
15357 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
15358 &lphb_conf_req->gateway_mac,
15359 sizeof(lphb_conf_req->gateway_mac));
15360
15361 status = wmi_unified_cmd_send(wmi_handle, buf,
15362 len, WMI_HB_SET_UDP_PARAMS_CMDID);
15363 if (QDF_IS_STATUS_ERROR(status)) {
15364 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
15365 status);
15366 wmi_buf_free(buf);
15367 }
15368
15369 return status;
15370}
15371
15372/**
15373 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
15374 * @wmi_handle: wmi handle
15375 * @lphb_conf_req: lphb config request
15376 *
15377 * Return: CDF status
15378 */
15379static
15380QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15381 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
15382{
15383 QDF_STATUS status;
15384 wmi_buf_t buf = NULL;
15385 uint8_t *buf_ptr;
15386 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
15387 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
15388
15389 buf = wmi_buf_alloc(wmi_handle, len);
15390 if (!buf) {
15391 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15392 return QDF_STATUS_E_NOMEM;
15393 }
15394
15395 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15396 hb_udp_filter_fp =
15397 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
15398 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
15399 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
15400 WMITLV_GET_STRUCT_TLVLEN
15401 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
15402
15403 /* fill in values */
15404 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
15405 hb_udp_filter_fp->length = lphb_conf_req->length;
15406 hb_udp_filter_fp->offset = lphb_conf_req->offset;
15407 hb_udp_filter_fp->session = lphb_conf_req->session;
15408 memcpy((void *)&hb_udp_filter_fp->filter,
15409 (void *)&lphb_conf_req->filter,
15410 WMI_WLAN_HB_MAX_FILTER_SIZE);
15411
15412 status = wmi_unified_cmd_send(wmi_handle, buf,
15413 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
15414 if (QDF_IS_STATUS_ERROR(status)) {
15415 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
15416 status);
15417 wmi_buf_free(buf);
15418 }
15419
15420 return status;
15421}
15422#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015423
Dustin Brownf31f88b2017-05-12 14:01:44 -070015424static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
15425 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015426{
Dustin Brownf31f88b2017-05-12 14:01:44 -070015427 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015428 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070015429 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015430
Dustin Brownf31f88b2017-05-12 14:01:44 -070015431 if (!req) {
15432 WMI_LOGE("req is null");
15433 return QDF_STATUS_E_INVAL;
15434 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015435
Dustin Brownf31f88b2017-05-12 14:01:44 -070015436 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
15437 if (!wmi_buf) {
15438 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015439 return QDF_STATUS_E_NOMEM;
15440 }
15441
Dustin Brownf31f88b2017-05-12 14:01:44 -070015442 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015443 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070015444 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
15445 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
15446 cmd->vdev_id = req->vdev_id;
15447 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
15448 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015449
Dustin Brownf31f88b2017-05-12 14:01:44 -070015450 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
15451 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015452
Dustin Brownf31f88b2017-05-12 14:01:44 -070015453 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
15454 WMI_HW_DATA_FILTER_CMDID);
15455 if (QDF_IS_STATUS_ERROR(status)) {
15456 WMI_LOGE("Failed to configure hw filter");
15457 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015458 }
15459
Dustin Brownf31f88b2017-05-12 14:01:44 -070015460 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015461}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015462
15463/**
15464 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
15465 * @wmi_handle: wmi handle
15466 * @vdev_id: vdev id
15467 * @enable: Flag to enable/disable packet filter
15468 *
15469 * Return: QDF_STATUS_SUCCESS for success or error code
15470 */
15471static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
15472 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
15473{
15474 int32_t len;
15475 int ret = 0;
15476 wmi_buf_t buf;
15477 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
15478
15479 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
15480
15481 buf = wmi_buf_alloc(wmi_handle, len);
15482 if (!buf) {
15483 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
15484 return QDF_STATUS_E_NOMEM;
15485 }
15486
15487 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
15488 WMITLV_SET_HDR(&cmd->tlv_header,
15489 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
15490 WMITLV_GET_STRUCT_TLVLEN(
15491 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
15492
15493 cmd->vdev_id = vdev_id;
15494 if (enable)
15495 cmd->enable = PACKET_FILTER_SET_ENABLE;
15496 else
15497 cmd->enable = PACKET_FILTER_SET_DISABLE;
15498
15499 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
15500 __func__, cmd->enable, vdev_id);
15501
15502 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15503 WMI_PACKET_FILTER_ENABLE_CMDID);
15504 if (ret) {
15505 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
15506 wmi_buf_free(buf);
15507 }
15508
15509 return ret;
15510}
15511
15512/**
15513 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
15514 * @wmi_handle: wmi handle
15515 * @vdev_id: vdev id
15516 * @rcv_filter_param: Packet filter parameters
15517 * @filter_id: Filter id
15518 * @enable: Flag to add/delete packet filter configuration
15519 *
15520 * Return: QDF_STATUS_SUCCESS for success or error code
15521 */
15522static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
15523 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
15524 uint8_t filter_id, bool enable)
15525{
15526 int len, i;
15527 int err = 0;
15528 wmi_buf_t buf;
15529 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
15530
15531
15532 /* allocate the memory */
15533 len = sizeof(*cmd);
15534 buf = wmi_buf_alloc(wmi_handle, len);
15535 if (!buf) {
15536 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
15537 return QDF_STATUS_E_NOMEM;
15538 }
15539
15540 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
15541 WMITLV_SET_HDR(&cmd->tlv_header,
15542 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
15543 WMITLV_GET_STRUCT_TLVLEN
15544 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
15545
15546 cmd->vdev_id = vdev_id;
15547 cmd->filter_id = filter_id;
15548 if (enable)
15549 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
15550 else
15551 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
15552
15553 if (enable) {
15554 cmd->num_params = QDF_MIN(
15555 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
15556 rcv_filter_param->num_params);
15557 cmd->filter_type = rcv_filter_param->filter_type;
15558 cmd->coalesce_time = rcv_filter_param->coalesce_time;
15559
15560 for (i = 0; i < cmd->num_params; i++) {
15561 cmd->paramsData[i].proto_type =
15562 rcv_filter_param->params_data[i].protocol_layer;
15563 cmd->paramsData[i].cmp_type =
15564 rcv_filter_param->params_data[i].compare_flag;
15565 cmd->paramsData[i].data_length =
15566 rcv_filter_param->params_data[i].data_length;
15567 cmd->paramsData[i].data_offset =
15568 rcv_filter_param->params_data[i].data_offset;
15569 memcpy(&cmd->paramsData[i].compareData,
15570 rcv_filter_param->params_data[i].compare_data,
15571 sizeof(cmd->paramsData[i].compareData));
15572 memcpy(&cmd->paramsData[i].dataMask,
15573 rcv_filter_param->params_data[i].data_mask,
15574 sizeof(cmd->paramsData[i].dataMask));
15575 }
15576 }
15577
15578 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
15579 cmd->filter_action, cmd->filter_id, cmd->num_params);
15580 /* send the command along with data */
15581 err = wmi_unified_cmd_send(wmi_handle, buf, len,
15582 WMI_PACKET_FILTER_CONFIG_CMDID);
15583 if (err) {
15584 WMI_LOGE("Failed to send pkt_filter cmd");
15585 wmi_buf_free(buf);
15586 return QDF_STATUS_E_FAILURE;
15587 }
15588
15589 return QDF_STATUS_SUCCESS;
15590}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053015591#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015592
Govind Singha4836fd2016-03-07 16:45:38 +053015593/**
15594 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
15595 * @wmi_handle: wmi handle
15596 * @request: SSID hotlist set request
15597 *
Govind Singhb53420c2016-03-09 14:32:57 +053015598 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053015599 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015600static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053015601send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
15602 struct ssid_hotlist_request_params *request)
15603{
15604 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
15605 wmi_buf_t wmi_buf;
15606 uint32_t len;
15607 uint32_t array_size;
15608 uint8_t *buf_ptr;
15609
15610 /* length of fixed portion */
15611 len = sizeof(*cmd);
15612
15613 /* length of variable portion */
15614 array_size =
15615 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
15616 len += WMI_TLV_HDR_SIZE + array_size;
15617
15618 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15619 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015620 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15621 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015622 }
15623
15624 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
15625 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
15626 buf_ptr;
15627 WMITLV_SET_HDR
15628 (&cmd->tlv_header,
15629 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15630 WMITLV_GET_STRUCT_TLVLEN
15631 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15632
15633 cmd->request_id = request->request_id;
15634 cmd->requestor_id = 0;
15635 cmd->vdev_id = request->session_id;
15636 cmd->table_id = 0;
15637 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15638 cmd->total_entries = request->ssid_count;
15639 cmd->num_entries_in_page = request->ssid_count;
15640 cmd->first_entry_index = 0;
15641
15642 buf_ptr += sizeof(*cmd);
15643 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15644
15645 if (request->ssid_count) {
15646 wmi_extscan_hotlist_ssid_entry *entry;
15647 int i;
15648
15649 buf_ptr += WMI_TLV_HDR_SIZE;
15650 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15651 for (i = 0; i < request->ssid_count; i++) {
15652 WMITLV_SET_HDR
15653 (entry,
15654 WMITLV_TAG_ARRAY_STRUC,
15655 WMITLV_GET_STRUCT_TLVLEN
15656 (wmi_extscan_hotlist_ssid_entry));
15657 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015658 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015659 request->ssids[i].ssid.mac_ssid,
15660 request->ssids[i].ssid.length);
15661 entry->band = request->ssids[i].band;
15662 entry->min_rssi = request->ssids[i].rssi_low;
15663 entry->max_rssi = request->ssids[i].rssi_high;
15664 entry++;
15665 }
15666 cmd->mode = WMI_EXTSCAN_MODE_START;
15667 } else {
15668 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15669 }
15670
15671 if (wmi_unified_cmd_send
15672 (wmi_handle, wmi_buf, len,
15673 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015674 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015675 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015676 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015677 }
15678
Govind Singhb53420c2016-03-09 14:32:57 +053015679 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015680}
15681
15682/**
15683 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15684 * @wmi_handle: wmi handle
15685 * @vdev_id: vdev id
15686 *
15687 * This function sends roam synch complete event to fw.
15688 *
15689 * Return: CDF STATUS
15690 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015691static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015692 uint8_t vdev_id)
15693{
15694 wmi_roam_synch_complete_fixed_param *cmd;
15695 wmi_buf_t wmi_buf;
15696 uint8_t *buf_ptr;
15697 uint16_t len;
15698 len = sizeof(wmi_roam_synch_complete_fixed_param);
15699
15700 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15701 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015702 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15703 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015704 }
15705 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15706 buf_ptr = (uint8_t *) cmd;
15707 WMITLV_SET_HDR(&cmd->tlv_header,
15708 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15709 WMITLV_GET_STRUCT_TLVLEN
15710 (wmi_roam_synch_complete_fixed_param));
15711 cmd->vdev_id = vdev_id;
15712 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15713 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015714 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015715 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015716 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015717 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015718 }
15719
Govind Singhb53420c2016-03-09 14:32:57 +053015720 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015721}
15722
15723/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015724 * send_fw_test_cmd_tlv() - send fw test command to fw.
15725 * @wmi_handle: wmi handle
15726 * @wmi_fwtest: fw test command
15727 *
15728 * This function sends fw test command to fw.
15729 *
15730 * Return: CDF STATUS
15731 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015732static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015733QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15734 struct set_fwtest_params *wmi_fwtest)
15735{
15736 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15737 wmi_buf_t wmi_buf;
15738 uint16_t len;
15739
15740 len = sizeof(*cmd);
15741
15742 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15743 if (!wmi_buf) {
15744 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15745 return QDF_STATUS_E_NOMEM;
15746 }
15747
15748 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15749 WMITLV_SET_HDR(&cmd->tlv_header,
15750 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15751 WMITLV_GET_STRUCT_TLVLEN(
15752 wmi_fwtest_set_param_cmd_fixed_param));
15753 cmd->param_id = wmi_fwtest->arg;
15754 cmd->param_value = wmi_fwtest->value;
15755
15756 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15757 WMI_FWTEST_CMDID)) {
15758 WMI_LOGP("%s: failed to send fw test command", __func__);
15759 qdf_nbuf_free(wmi_buf);
15760 return QDF_STATUS_E_FAILURE;
15761 }
15762
15763 return QDF_STATUS_SUCCESS;
15764}
15765
15766/**
Govind Singha4836fd2016-03-07 16:45:38 +053015767 * send_unit_test_cmd_tlv() - send unit test command to fw.
15768 * @wmi_handle: wmi handle
15769 * @wmi_utest: unit test command
15770 *
15771 * This function send unit test command to fw.
15772 *
15773 * Return: CDF STATUS
15774 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015775static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015776 struct wmi_unit_test_cmd *wmi_utest)
15777{
15778 wmi_unit_test_cmd_fixed_param *cmd;
15779 wmi_buf_t wmi_buf;
15780 uint8_t *buf_ptr;
15781 int i;
15782 uint16_t len, args_tlv_len;
15783 A_UINT32 *unit_test_cmd_args;
15784
15785 args_tlv_len =
15786 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
15787 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15788
15789 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15790 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015791 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15792 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015793 }
15794
15795 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15796 buf_ptr = (uint8_t *) cmd;
15797 WMITLV_SET_HDR(&cmd->tlv_header,
15798 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15799 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15800 cmd->vdev_id = wmi_utest->vdev_id;
15801 cmd->module_id = wmi_utest->module_id;
15802 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015803 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015804 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15805 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15806 (wmi_utest->num_args * sizeof(uint32_t)));
15807 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015808 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15809 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15810 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015811 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015812 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015813 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015814 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015815 }
15816 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15817 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015818 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015819 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015820 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015821 }
15822
Govind Singhb53420c2016-03-09 14:32:57 +053015823 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015824}
15825
15826/**
15827 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15828 * @wmi_handle: wma handle
15829 * @roaminvoke: roam invoke command
15830 *
15831 * Send roam invoke command to fw for fastreassoc.
15832 *
15833 * Return: CDF STATUS
15834 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015835static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015836 struct wmi_roam_invoke_cmd *roaminvoke,
15837 uint32_t ch_hz)
15838{
15839 wmi_roam_invoke_cmd_fixed_param *cmd;
15840 wmi_buf_t wmi_buf;
15841 u_int8_t *buf_ptr;
15842 u_int16_t len, args_tlv_len;
15843 A_UINT32 *channel_list;
15844 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015845 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015846
15847 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080015848 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
15849 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15850 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015851 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15852 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15853 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015854 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15855 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015856 }
15857
15858 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15859 buf_ptr = (u_int8_t *) cmd;
15860 WMITLV_SET_HDR(&cmd->tlv_header,
15861 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15862 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15863 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015864 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015865 if (roaminvoke->is_same_bssid)
15866 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15867 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015868
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015869 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015870 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015871 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15872 cmd->num_buf = 1;
15873 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015874 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015875 cmd->num_buf = 0;
15876 }
Naveen Rawat77797922017-01-20 17:00:07 -080015877
Govind Singha4836fd2016-03-07 16:45:38 +053015878 cmd->roam_ap_sel_mode = 0;
15879 cmd->roam_delay = 0;
15880 cmd->num_chan = 1;
15881 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015882
Govind Singha4836fd2016-03-07 16:45:38 +053015883 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15884 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15885 (sizeof(u_int32_t)));
15886 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
15887 *channel_list = ch_hz;
15888 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
15889 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15890 (sizeof(wmi_mac_addr)));
15891 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15892 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015893
15894 /* move to next tlv i.e. bcn_prb_buf_list */
15895 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15896
15897 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15898 sizeof(wmi_tlv_buf_len_param));
15899
15900 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15901 buf_len_tlv->buf_len = roaminvoke->frame_len;
15902
15903 /* move to next tlv i.e. bcn_prb_frm */
15904 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15905 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15906 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15907
15908 /* copy frame after the header */
15909 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15910 roaminvoke->frame_buf,
15911 roaminvoke->frame_len);
15912
15913 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
15914 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
15915 buf_ptr + WMI_TLV_HDR_SIZE,
15916 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015917 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15918 cmd->flags, cmd->roam_scan_mode,
15919 cmd->roam_ap_sel_mode, cmd->roam_delay,
15920 cmd->num_chan, cmd->num_bssid);
15921 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015922
Govind Singha4836fd2016-03-07 16:45:38 +053015923 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15924 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015925 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015926 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015927 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015928 }
15929
Govind Singhb53420c2016-03-09 14:32:57 +053015930 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015931}
15932
15933/**
15934 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15935 * @wmi_handle: wmi handle
15936 * @command: command
15937 * @vdev_id: vdev id
15938 *
15939 * This function set roam offload command to fw.
15940 *
15941 * Return: CDF status
15942 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015943static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015944 uint32_t command, uint32_t vdev_id)
15945{
Govind Singh67922e82016-04-01 16:48:57 +053015946 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015947 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15948 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015949 int len;
15950 uint8_t *buf_ptr;
15951
15952 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15953 buf = wmi_buf_alloc(wmi_handle, len);
15954 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015955 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15956 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015957 }
15958
15959 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15960
15961 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15962 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15963 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15964 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15965 cmd_fp->vdev_id = vdev_id;
15966 cmd_fp->command_arg = command;
15967
15968 status = wmi_unified_cmd_send(wmi_handle, buf,
15969 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015970 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015971 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015972 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015973 goto error;
15974 }
15975
Govind Singhb53420c2016-03-09 14:32:57 +053015976 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15977 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015978
15979error:
15980 wmi_buf_free(buf);
15981
Govind Singh67922e82016-04-01 16:48:57 +053015982 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015983}
15984
15985/**
15986 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15987 * @wmi_handle: wmi handle
15988 * @ap_profile_p: ap profile
15989 * @vdev_id: vdev id
15990 *
15991 * Send WMI_ROAM_AP_PROFILE to firmware
15992 *
15993 * Return: CDF status
15994 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015995static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015996 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015997{
Govind Singha4836fd2016-03-07 16:45:38 +053015998 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015999 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016000 int len;
16001 uint8_t *buf_ptr;
16002 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016003 wmi_roam_cnd_scoring_param *score_param;
16004 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053016005
16006 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016007 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053016008 buf = wmi_buf_alloc(wmi_handle, len);
16009 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016010 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16011 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016012 }
16013
16014 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16015 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
16016 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
16017 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
16018 WMITLV_GET_STRUCT_TLVLEN
16019 (wmi_roam_ap_profile_fixed_param));
16020 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016021 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053016022 roam_ap_profile_fp->id = 0;
16023 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
16024
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016025 profile = (wmi_ap_profile *)buf_ptr;
16026 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053016027 WMITLV_TAG_STRUC_wmi_ap_profile,
16028 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016029 profile->flags = ap_profile->profile.flags;
16030 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
16031 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
16032 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
16033 profile->ssid.ssid_len);
16034 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
16035 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
16036 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
16037 profile->rsn_mcastmgmtcipherset =
16038 ap_profile->profile.rsn_mcastmgmtcipherset;
16039 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
16040
16041 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",
16042 profile->flags, profile->rssi_threshold,
16043 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
16044 profile->rsn_authmode, profile->rsn_ucastcipherset,
16045 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
16046 profile->rssi_abs_thresh);
16047
16048 buf_ptr += sizeof(wmi_ap_profile);
16049
16050 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
16051 WMITLV_SET_HDR(&score_param->tlv_header,
16052 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
16053 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
16054 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
16055 score_param->rssi_weightage_pcnt =
16056 ap_profile->param.rssi_weightage;
16057 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
16058 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
16059 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
16060 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
16061 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
16062 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
16063 score_param->esp_qbss_weightage_pcnt =
16064 ap_profile->param.esp_qbss_weightage;
16065 score_param->beamforming_weightage_pcnt =
16066 ap_profile->param.beamforming_weightage;
16067 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
16068 score_param->oce_wan_weightage_pcnt =
16069 ap_profile->param.oce_wan_weightage;
16070
16071 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",
16072 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
16073 score_param->ht_weightage_pcnt,
16074 score_param->vht_weightage_pcnt,
16075 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
16076 score_param->band_weightage_pcnt,
16077 score_param->nss_weightage_pcnt,
16078 score_param->esp_qbss_weightage_pcnt,
16079 score_param->beamforming_weightage_pcnt,
16080 score_param->pcl_weightage_pcnt,
16081 score_param->oce_wan_weightage_pcnt);
16082
16083 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
16084 score_param->band_scoring.score_pcnt =
16085 ap_profile->param.band_index_score;
16086 score_param->nss_scoring.score_pcnt =
16087 ap_profile->param.nss_index_score;
16088
16089 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
16090 score_param->bw_scoring.score_pcnt,
16091 score_param->band_scoring.score_pcnt,
16092 score_param->nss_scoring.score_pcnt);
16093
16094 score_param->rssi_scoring.best_rssi_threshold =
16095 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
16096 score_param->rssi_scoring.good_rssi_threshold =
16097 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
16098 score_param->rssi_scoring.bad_rssi_threshold =
16099 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
16100 score_param->rssi_scoring.good_rssi_pcnt =
16101 ap_profile->param.rssi_scoring.good_rssi_pcnt;
16102 score_param->rssi_scoring.bad_rssi_pcnt =
16103 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
16104 score_param->rssi_scoring.good_bucket_size =
16105 ap_profile->param.rssi_scoring.good_bucket_size;
16106 score_param->rssi_scoring.bad_bucket_size =
16107 ap_profile->param.rssi_scoring.bad_bucket_size;
16108 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
16109 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
16110
16111 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
16112 score_param->rssi_scoring.best_rssi_threshold,
16113 score_param->rssi_scoring.good_rssi_threshold,
16114 score_param->rssi_scoring.bad_rssi_threshold,
16115 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
16116 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
16117 score_param->rssi_scoring.good_rssi_pcnt,
16118 score_param->rssi_scoring.bad_rssi_pcnt,
16119 score_param->rssi_scoring.good_bucket_size,
16120 score_param->rssi_scoring.bad_bucket_size);
16121
16122 score_param->esp_qbss_scoring.num_slot =
16123 ap_profile->param.esp_qbss_scoring.num_slot;
16124 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
16125 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
16126 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
16127 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
16128 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
16129 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
16130 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
16131 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
16132
16133 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16134 score_param->esp_qbss_scoring.num_slot,
16135 score_param->esp_qbss_scoring.score_pcnt3_to_0,
16136 score_param->esp_qbss_scoring.score_pcnt7_to_4,
16137 score_param->esp_qbss_scoring.score_pcnt11_to_8,
16138 score_param->esp_qbss_scoring.score_pcnt15_to_12);
16139
16140 score_param->oce_wan_scoring.num_slot =
16141 ap_profile->param.oce_wan_scoring.num_slot;
16142 score_param->oce_wan_scoring.score_pcnt3_to_0 =
16143 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
16144 score_param->oce_wan_scoring.score_pcnt7_to_4 =
16145 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
16146 score_param->oce_wan_scoring.score_pcnt11_to_8 =
16147 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
16148 score_param->oce_wan_scoring.score_pcnt15_to_12 =
16149 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
16150
16151 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16152 score_param->oce_wan_scoring.num_slot,
16153 score_param->oce_wan_scoring.score_pcnt3_to_0,
16154 score_param->oce_wan_scoring.score_pcnt7_to_4,
16155 score_param->oce_wan_scoring.score_pcnt11_to_8,
16156 score_param->oce_wan_scoring.score_pcnt15_to_12);
16157
Govind Singha4836fd2016-03-07 16:45:38 +053016158 status = wmi_unified_cmd_send(wmi_handle, buf,
16159 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053016160 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016161 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016162 status);
Govind Singh67922e82016-04-01 16:48:57 +053016163 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053016164 }
16165
Govind Singhb53420c2016-03-09 14:32:57 +053016166 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053016167
Govind Singh67922e82016-04-01 16:48:57 +053016168 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016169}
16170
16171/**
16172 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
16173 * @wmi_handle: wmi handle
16174 * @scan_period: scan period
16175 * @scan_age: scan age
16176 * @vdev_id: vdev id
16177 *
16178 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
16179 *
16180 * Return: CDF status
16181 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016182static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016183 uint32_t scan_period,
16184 uint32_t scan_age,
16185 uint32_t vdev_id)
16186{
Govind Singh67922e82016-04-01 16:48:57 +053016187 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016188 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053016189 int len;
16190 uint8_t *buf_ptr;
16191 wmi_roam_scan_period_fixed_param *scan_period_fp;
16192
16193 /* Send scan period values */
16194 len = sizeof(wmi_roam_scan_period_fixed_param);
16195 buf = wmi_buf_alloc(wmi_handle, len);
16196 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016197 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16198 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016199 }
16200
16201 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16202 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
16203 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
16204 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
16205 WMITLV_GET_STRUCT_TLVLEN
16206 (wmi_roam_scan_period_fixed_param));
16207 /* fill in scan period values */
16208 scan_period_fp->vdev_id = vdev_id;
16209 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
16210 scan_period_fp->roam_scan_age = scan_age;
16211
16212 status = wmi_unified_cmd_send(wmi_handle, buf,
16213 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053016214 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016215 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016216 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016217 goto error;
16218 }
16219
Govind Singhb53420c2016-03-09 14:32:57 +053016220 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053016221 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053016222 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016223error:
16224 wmi_buf_free(buf);
16225
Govind Singh67922e82016-04-01 16:48:57 +053016226 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016227}
16228
16229/**
16230 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
16231 * @wmi_handle: wmi handle
16232 * @chan_count: channel count
16233 * @chan_list: channel list
16234 * @list_type: list type
16235 * @vdev_id: vdev id
16236 *
16237 * Set roam offload channel list.
16238 *
16239 * Return: CDF status
16240 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016241static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016242 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070016243 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053016244 uint8_t list_type, uint32_t vdev_id)
16245{
Govind Singha4836fd2016-03-07 16:45:38 +053016246 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016247 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016248 int len, list_tlv_len;
16249 int i;
16250 uint8_t *buf_ptr;
16251 wmi_roam_chan_list_fixed_param *chan_list_fp;
16252 A_UINT32 *roam_chan_list_array;
16253
16254 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053016255 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053016256 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053016257 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053016258 }
16259 /* Channel list is a table of 2 TLV's */
16260 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
16261 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
16262 buf = wmi_buf_alloc(wmi_handle, len);
16263 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016264 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16265 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016266 }
16267
16268 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16269 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
16270 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
16271 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
16272 WMITLV_GET_STRUCT_TLVLEN
16273 (wmi_roam_chan_list_fixed_param));
16274 chan_list_fp->vdev_id = vdev_id;
16275 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053016276 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053016277 /* external app is controlling channel list */
16278 chan_list_fp->chan_list_type =
16279 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
16280 } else {
16281 /* umac supplied occupied channel list in LFR */
16282 chan_list_fp->chan_list_type =
16283 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
16284 }
16285
16286 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
16287 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16288 (chan_list_fp->num_chan * sizeof(uint32_t)));
16289 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016290 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053016291 for (i = 0; ((i < chan_list_fp->num_chan) &&
16292 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
16293 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053016294 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053016295 }
16296
16297 status = wmi_unified_cmd_send(wmi_handle, buf,
16298 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053016299 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016300 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016301 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016302 goto error;
16303 }
16304
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016305 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053016306 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016307error:
16308 wmi_buf_free(buf);
16309
Govind Singh67922e82016-04-01 16:48:57 +053016310 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016311}
16312
16313/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016314 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
16315 * @wmi_handle: wmi handle
16316 * @req_buf: per roam config buffer
16317 *
16318 * Return: QDF status
16319 */
16320static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
16321 struct wmi_per_roam_config_req *req_buf)
16322{
16323 wmi_buf_t buf = NULL;
16324 QDF_STATUS status;
16325 int len;
16326 uint8_t *buf_ptr;
16327 wmi_roam_per_config_fixed_param *wmi_per_config;
16328
16329 len = sizeof(wmi_roam_per_config_fixed_param);
16330 buf = wmi_buf_alloc(wmi_handle, len);
16331 if (!buf) {
16332 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16333 return QDF_STATUS_E_NOMEM;
16334 }
16335
16336 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16337 wmi_per_config =
16338 (wmi_roam_per_config_fixed_param *) buf_ptr;
16339 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
16340 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
16341 WMITLV_GET_STRUCT_TLVLEN
16342 (wmi_roam_per_config_fixed_param));
16343
16344 /* fill in per roam config values */
16345 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016346
16347 wmi_per_config->enable = req_buf->per_config.enable;
16348 wmi_per_config->high_rate_thresh =
16349 (req_buf->per_config.tx_high_rate_thresh << 16) |
16350 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
16351 wmi_per_config->low_rate_thresh =
16352 (req_buf->per_config.tx_low_rate_thresh << 16) |
16353 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
16354 wmi_per_config->pkt_err_rate_thresh_pct =
16355 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
16356 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
16357 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053016358 wmi_per_config->pkt_err_rate_mon_time =
16359 (req_buf->per_config.tx_per_mon_time << 16) |
16360 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053016361 wmi_per_config->min_candidate_rssi =
16362 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016363
16364 /* Send per roam config parameters */
16365 status = wmi_unified_cmd_send(wmi_handle, buf,
16366 len, WMI_ROAM_PER_CONFIG_CMDID);
16367 if (QDF_IS_STATUS_ERROR(status)) {
16368 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
16369 status);
16370 wmi_buf_free(buf);
16371 return status;
16372 }
16373
16374 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
16375 req_buf->per_config.enable, req_buf->vdev_id);
16376 return QDF_STATUS_SUCCESS;
16377}
16378
16379/**
Govind Singha4836fd2016-03-07 16:45:38 +053016380 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
16381 * @wmi_handle: wmi handle
16382 * @rssi_change_thresh: RSSI Change threshold
16383 * @bcn_rssi_weight: beacon RSSI weight
16384 * @vdev_id: vdev id
16385 *
16386 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
16387 *
16388 * Return: CDF status
16389 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016390static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016391 uint32_t vdev_id,
16392 int32_t rssi_change_thresh,
16393 uint32_t bcn_rssi_weight,
16394 uint32_t hirssi_delay_btw_scans)
16395{
Govind Singha4836fd2016-03-07 16:45:38 +053016396 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016397 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016398 int len;
16399 uint8_t *buf_ptr;
16400 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
16401
16402 /* Send rssi change parameters */
16403 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
16404 buf = wmi_buf_alloc(wmi_handle, len);
16405 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016406 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16407 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016408 }
16409
16410 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16411 rssi_change_fp =
16412 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
16413 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
16414 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
16415 WMITLV_GET_STRUCT_TLVLEN
16416 (wmi_roam_scan_rssi_change_threshold_fixed_param));
16417 /* fill in rssi change threshold (hysteresis) values */
16418 rssi_change_fp->vdev_id = vdev_id;
16419 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
16420 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
16421 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
16422
16423 status = wmi_unified_cmd_send(wmi_handle, buf,
16424 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053016425 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016426 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016427 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016428 goto error;
16429 }
16430
Govind Singhb53420c2016-03-09 14:32:57 +053016431 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053016432 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053016433 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
16434 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016435error:
16436 wmi_buf_free(buf);
16437
Govind Singh67922e82016-04-01 16:48:57 +053016438 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016439}
16440
16441/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
16442 * @wmi_handle: wmi handle.
16443 * @cmd: size of command structure.
16444 * @per_entry_size: per entry size.
16445 *
16446 * This utility function calculates how many hotlist entries can
16447 * fit in one page.
16448 *
16449 * Return: number of entries
16450 */
16451static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
16452 size_t cmd_size,
16453 size_t per_entry_size)
16454{
16455 uint32_t avail_space = 0;
16456 int num_entries = 0;
16457 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
16458
16459 /* Calculate number of hotlist entries that can
16460 * be passed in wma message request.
16461 */
16462 avail_space = max_msg_len - cmd_size;
16463 num_entries = avail_space / per_entry_size;
16464 return num_entries;
16465}
16466
16467/**
16468 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
16469 * @wmi_handle: wmi handle
16470 * @photlist: hotlist command params
16471 * @buf_len: buffer length
16472 *
16473 * This function fills individual elements for hotlist request and
16474 * TLV for bssid entries
16475 *
16476 * Return: CDF Status.
16477 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016478static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016479 struct ext_scan_setbssi_hotlist_params *
16480 photlist, int *buf_len)
16481{
16482 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
16483 wmi_extscan_hotlist_entry *dest_hotlist;
16484 struct ap_threshold_params *src_ap = photlist->ap;
16485 wmi_buf_t buf;
16486 uint8_t *buf_ptr;
16487
16488 int j, index = 0;
16489 int cmd_len = 0;
16490 int num_entries;
16491 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016492 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053016493 int len = sizeof(*cmd);
16494
16495 len += WMI_TLV_HDR_SIZE;
16496 cmd_len = len;
16497
16498 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
16499 cmd_len,
16500 sizeof(*dest_hotlist));
16501 /* setbssid hotlist expects the bssid list
16502 * to be non zero value
16503 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016504 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080016505 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053016506 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053016507 }
16508
16509 /* Split the hot list entry pages and send multiple command
16510 * requests if the buffer reaches the maximum request size
16511 */
16512 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053016513 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053016514 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
16515 buf = wmi_buf_alloc(wmi_handle, len);
16516 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016517 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
16518 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016519 }
16520 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16521 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
16522 buf_ptr;
16523 WMITLV_SET_HDR(&cmd->tlv_header,
16524 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
16525 WMITLV_GET_STRUCT_TLVLEN
16526 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
16527
16528 /* Multiple requests are sent until the num_entries_in_page
16529 * matches the total_entries
16530 */
16531 cmd->request_id = photlist->requestId;
16532 cmd->vdev_id = photlist->sessionId;
16533 cmd->total_entries = numap;
16534 cmd->mode = 1;
16535 cmd->num_entries_in_page = min_entries;
16536 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
16537 cmd->first_entry_index = index;
16538
Govind Singhb53420c2016-03-09 14:32:57 +053016539 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016540 __func__, cmd->vdev_id, cmd->total_entries,
16541 cmd->num_entries_in_page,
16542 cmd->lost_ap_scan_count);
16543
16544 buf_ptr += sizeof(*cmd);
16545 WMITLV_SET_HDR(buf_ptr,
16546 WMITLV_TAG_ARRAY_STRUC,
16547 min_entries * sizeof(wmi_extscan_hotlist_entry));
16548 dest_hotlist = (wmi_extscan_hotlist_entry *)
16549 (buf_ptr + WMI_TLV_HDR_SIZE);
16550
16551 /* Populate bssid, channel info and rssi
16552 * for the bssid's that are sent as hotlists.
16553 */
16554 for (j = 0; j < min_entries; j++) {
16555 WMITLV_SET_HDR(dest_hotlist,
16556 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
16557 WMITLV_GET_STRUCT_TLVLEN
16558 (wmi_extscan_hotlist_entry));
16559
16560 dest_hotlist->min_rssi = src_ap->low;
16561 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
16562 &dest_hotlist->bssid);
16563
Govind Singhb53420c2016-03-09 14:32:57 +053016564 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016565 __func__, dest_hotlist->channel,
16566 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053016567 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053016568 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16569 __func__, dest_hotlist->bssid.mac_addr31to0,
16570 dest_hotlist->bssid.mac_addr47to32);
16571 dest_hotlist++;
16572 src_ap++;
16573 }
16574 buf_ptr += WMI_TLV_HDR_SIZE +
16575 (min_entries * sizeof(wmi_extscan_hotlist_entry));
16576
16577 if (wmi_unified_cmd_send(wmi_handle, buf, len,
16578 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016579 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053016580 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053016581 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016582 }
16583 index = index + min_entries;
16584 num_entries = numap - min_entries;
16585 len = cmd_len;
16586 }
Govind Singhb53420c2016-03-09 14:32:57 +053016587 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016588}
16589
Govind Singhbca3b1b2016-05-02 17:59:24 +053016590/**
Dustin Brown4423f632017-01-13 15:24:07 -080016591 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
16592 * @wmi_handle: the WMI handle
16593 * @vdev_id: the Id of the vdev to apply the configuration to
16594 * @ucast_mode: the active BPF mode to configure for unicast packets
16595 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
16596 * packets
16597 *
16598 * Return: QDF status
16599 */
16600static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
16601 uint8_t vdev_id,
16602 enum wmi_host_active_bpf_mode ucast_mode,
16603 enum wmi_host_active_bpf_mode mcast_bcast_mode)
16604{
16605 const WMITLV_TAG_ID tag_id =
16606 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
16607 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
16608 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
16609 QDF_STATUS status;
16610 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
16611 wmi_buf_t buf;
16612
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016613 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080016614 vdev_id, ucast_mode, mcast_bcast_mode);
16615
16616 /* allocate command buffer */
16617 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
16618 if (!buf) {
16619 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
16620 return QDF_STATUS_E_NOMEM;
16621 }
16622
16623 /* set TLV header */
16624 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
16625 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
16626
16627 /* populate data */
16628 cmd->vdev_id = vdev_id;
16629 cmd->uc_mode = ucast_mode;
16630 cmd->mcbc_mode = mcast_bcast_mode;
16631
16632 /* send to FW */
16633 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
16634 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
16635 if (QDF_IS_STATUS_ERROR(status)) {
16636 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
16637 status);
16638 wmi_buf_free(buf);
16639 return status;
16640 }
16641
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016642 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080016643
16644 return QDF_STATUS_SUCCESS;
16645}
16646
16647/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053016648 * send_power_dbg_cmd_tlv() - send power debug commands
16649 * @wmi_handle: wmi handle
16650 * @param: wmi power debug parameter
16651 *
16652 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
16653 *
16654 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16655 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016656static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
16657 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053016658{
16659 wmi_buf_t buf = NULL;
16660 QDF_STATUS status;
16661 int len, args_tlv_len;
16662 uint8_t *buf_ptr;
16663 uint8_t i;
16664 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
16665 uint32_t *cmd_args;
16666
16667 /* Prepare and send power debug cmd parameters */
16668 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
16669 len = sizeof(*cmd) + args_tlv_len;
16670 buf = wmi_buf_alloc(wmi_handle, len);
16671 if (!buf) {
16672 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16673 return QDF_STATUS_E_NOMEM;
16674 }
16675
16676 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16677 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
16678 WMITLV_SET_HDR(&cmd->tlv_header,
16679 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
16680 WMITLV_GET_STRUCT_TLVLEN
16681 (wmi_pdev_wal_power_debug_cmd_fixed_param));
16682
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016683 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16684 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016685 cmd->module_id = param->module_id;
16686 cmd->num_args = param->num_args;
16687 buf_ptr += sizeof(*cmd);
16688 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16689 (param->num_args * sizeof(uint32_t)));
16690 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
16691 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080016692 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053016693 cmd_args[i] = param->args[i];
16694 WMI_LOGI("%d,", param->args[i]);
16695 }
16696
16697 status = wmi_unified_cmd_send(wmi_handle, buf,
16698 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
16699 if (QDF_IS_STATUS_ERROR(status)) {
16700 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
16701 status);
16702 goto error;
16703 }
16704
16705 return QDF_STATUS_SUCCESS;
16706error:
16707 wmi_buf_free(buf);
16708
16709 return status;
16710}
16711
Govind Singhe7f2f342016-05-23 12:12:52 +053016712/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016713 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
16714 * @wmi_handle: wmi handle
16715 * @param: wmi multiple vdev restart req param
16716 *
16717 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
16718 *
16719 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16720 */
16721static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
16722 wmi_unified_t wmi_handle,
16723 struct multiple_vdev_restart_params *param)
16724{
16725 wmi_buf_t buf;
16726 QDF_STATUS qdf_status;
16727 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
16728 int i;
16729 uint8_t *buf_ptr;
16730 uint32_t *vdev_ids;
16731 wmi_channel *chan_info;
16732 struct channel_param *tchan_info;
16733 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
16734
16735 len += sizeof(wmi_channel);
16736 if (param->num_vdevs)
16737 len += sizeof(uint32_t) * param->num_vdevs;
16738
16739 buf = wmi_buf_alloc(wmi_handle, len);
16740 if (!buf) {
16741 WMI_LOGE("Failed to allocate memory\n");
16742 qdf_status = QDF_STATUS_E_NOMEM;
16743 goto end;
16744 }
16745
16746 buf_ptr = (uint8_t *)wmi_buf_data(buf);
16747 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
16748 buf_ptr;
16749
16750 WMITLV_SET_HDR(&cmd->tlv_header,
16751 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
16752 WMITLV_GET_STRUCT_TLVLEN
16753 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016754 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16755 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016756 cmd->requestor_id = param->requestor_id;
16757 cmd->disable_hw_ack = param->disable_hw_ack;
16758 cmd->cac_duration_ms = param->cac_duration_ms;
16759 cmd->num_vdevs = param->num_vdevs;
16760
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016761 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
16762 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
16763 " cmd->num_vdevs: %d ",
16764 __func__, cmd->pdev_id, cmd->requestor_id,
16765 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016766 buf_ptr += sizeof(*cmd);
16767
16768 WMITLV_SET_HDR(buf_ptr,
16769 WMITLV_TAG_ARRAY_UINT32,
16770 sizeof(A_UINT32) * param->num_vdevs);
16771 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
16772 for (i = 0; i < param->num_vdevs; i++) {
16773 vdev_ids[i] = param->vdev_ids[i];
16774 }
16775
16776 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
16777
16778 WMITLV_SET_HDR(buf_ptr,
16779 WMITLV_TAG_STRUC_wmi_channel,
16780 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053016781 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016782 tchan_info = &(param->ch_param);
16783 chan_info->mhz = tchan_info->mhz;
16784 chan_info->band_center_freq1 = tchan_info->cfreq1;
16785 chan_info->band_center_freq2 = tchan_info->cfreq2;
16786 if (tchan_info->is_chan_passive)
16787 WMI_SET_CHANNEL_FLAG(chan_info,
16788 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016789 if (tchan_info->dfs_set)
16790 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
16791
Sathish Kumar45e991b2017-02-27 10:35:40 +053016792 if (tchan_info->allow_vht)
16793 WMI_SET_CHANNEL_FLAG(chan_info,
16794 WMI_CHAN_FLAG_ALLOW_VHT);
16795 else if (tchan_info->allow_ht)
16796 WMI_SET_CHANNEL_FLAG(chan_info,
16797 WMI_CHAN_FLAG_ALLOW_HT);
16798 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
16799 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
16800 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
16801 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
16802 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
16803 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080016804 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016805
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016806 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
16807 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
16808 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
16809 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
16810 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
16811 "tchan_info->reg_class_id: %d ,"
16812 "tchan_info->maxregpower : %d ", __func__,
16813 tchan_info->is_chan_passive, tchan_info->dfs_set,
16814 tchan_info->allow_vht, tchan_info->allow_ht,
16815 tchan_info->antennamax, tchan_info->phy_mode,
16816 tchan_info->minpower, tchan_info->maxpower,
16817 tchan_info->maxregpower, tchan_info->reg_class_id,
16818 tchan_info->maxregpower);
16819
Sathish Kumar45e991b2017-02-27 10:35:40 +053016820 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
16821 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
16822
16823 if (QDF_IS_STATUS_ERROR(qdf_status)) {
16824 WMI_LOGE("%s: Failed to send\n", __func__);
16825 wmi_buf_free(buf);
16826 }
16827
16828end:
16829 return qdf_status;
16830}
16831
16832/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080016833 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
16834 * @wmi_handle: wmi handle
16835 * @pdev_id: pdev id
16836 *
16837 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16838 *
16839 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16840 */
16841static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16842 uint32_t pdev_id)
16843{
16844 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16845 wmi_buf_t buf;
16846 uint16_t len;
16847 QDF_STATUS ret;
16848
16849 len = sizeof(*cmd);
16850 buf = wmi_buf_alloc(wmi_handle, len);
16851
16852 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16853
16854 if (!buf) {
16855 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16856 return QDF_STATUS_E_NOMEM;
16857 }
16858
16859 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16860 wmi_buf_data(buf);
16861
16862 WMITLV_SET_HDR(&cmd->tlv_header,
16863 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16864 WMITLV_GET_STRUCT_TLVLEN(
16865 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16866
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016867 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016868 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16869 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16870 if (QDF_IS_STATUS_ERROR(ret)) {
16871 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16872 __func__, ret, pdev_id);
16873 wmi_buf_free(buf);
16874 return QDF_STATUS_E_FAILURE;
16875 }
16876
16877 return QDF_STATUS_SUCCESS;
16878}
16879
16880/**
16881 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16882 * @wmi_handle: wmi handle
16883 * @pdev_id: pdev id
16884 *
16885 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16886 *
16887 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16888 */
16889static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16890 uint32_t pdev_id)
16891{
16892 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16893 wmi_buf_t buf;
16894 uint16_t len;
16895 QDF_STATUS ret;
16896
16897 len = sizeof(*cmd);
16898 buf = wmi_buf_alloc(wmi_handle, len);
16899
16900 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16901
16902 if (!buf) {
16903 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16904 return QDF_STATUS_E_NOMEM;
16905 }
16906
16907 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16908 wmi_buf_data(buf);
16909
16910 WMITLV_SET_HDR(&cmd->tlv_header,
16911 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16912 WMITLV_GET_STRUCT_TLVLEN(
16913 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16914
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016915 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016916 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16917 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16918 if (QDF_IS_STATUS_ERROR(ret)) {
16919 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16920 __func__, ret, pdev_id);
16921 wmi_buf_free(buf);
16922 return QDF_STATUS_E_FAILURE;
16923 }
16924
16925 return QDF_STATUS_SUCCESS;
16926}
16927
16928/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016929 * init_cmd_send_tlv() - send initialization cmd to fw
16930 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016931 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016932 *
16933 * Return: QDF_STATUS_SUCCESS for success or error code
16934 */
16935static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016936 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016937{
16938 wmi_buf_t buf;
16939 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016940 uint8_t *buf_ptr;
16941 wmi_resource_config *resource_cfg;
16942 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016943 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016944 uint16_t idx;
16945 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016946 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016947
Kiran Venkatappa26117052016-12-23 19:58:54 +053016948 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16949 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016950 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016951
16952 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16953 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16954 WMI_TLV_HDR_SIZE +
16955 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16956
16957 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016958 if (!buf) {
16959 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16960 return QDF_STATUS_E_FAILURE;
16961 }
16962
16963 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16964 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16965 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16966
16967 host_mem_chunks = (wlan_host_memory_chunk *)
16968 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16969 + WMI_TLV_HDR_SIZE);
16970
16971 WMITLV_SET_HDR(&cmd->tlv_header,
16972 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16973 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16974
Kiran Venkatappa26117052016-12-23 19:58:54 +053016975 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016976 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16977 WMITLV_TAG_STRUC_wmi_resource_config,
16978 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16979
Kiran Venkatappa26117052016-12-23 19:58:54 +053016980 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016981 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16982 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16983 WMITLV_GET_STRUCT_TLVLEN
16984 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016985 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16986 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16987 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016988 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16989 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016990 idx, host_mem_chunks[idx].size,
16991 host_mem_chunks[idx].ptr);
16992 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016993 cmd->num_host_mem_chunks = param->num_mem_chunks;
16994 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16995
Govind Singhe7f2f342016-05-23 12:12:52 +053016996 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16997 WMITLV_TAG_ARRAY_STRUC,
16998 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016999 param->num_mem_chunks));
17000
17001 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017002 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053017003
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017004 /* Fill fw_abi_vers */
17005 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053017006
Abhishek Singh716c46c2016-05-04 16:24:07 +053017007 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
17008 if (QDF_IS_STATUS_ERROR(ret)) {
17009 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
17010 ret);
17011 wmi_buf_free(buf);
17012 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017013
Abhishek Singh716c46c2016-05-04 16:24:07 +053017014 return ret;
17015
Govind Singhe7f2f342016-05-23 12:12:52 +053017016}
17017
17018/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080017019 * send_addba_send_cmd_tlv() - send addba send command to fw
17020 * @wmi_handle: wmi handle
17021 * @param: pointer to delba send params
17022 * @macaddr: peer mac address
17023 *
17024 * Send WMI_ADDBA_SEND_CMDID command to firmware
17025 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17026 */
17027static QDF_STATUS
17028send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
17029 uint8_t macaddr[IEEE80211_ADDR_LEN],
17030 struct addba_send_params *param)
17031{
17032 wmi_addba_send_cmd_fixed_param *cmd;
17033 wmi_buf_t buf;
17034 uint16_t len;
17035 QDF_STATUS ret;
17036
17037 len = sizeof(*cmd);
17038
17039 buf = wmi_buf_alloc(wmi_handle, len);
17040 if (!buf) {
17041 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17042 return QDF_STATUS_E_NOMEM;
17043 }
17044
17045 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
17046
17047 WMITLV_SET_HDR(&cmd->tlv_header,
17048 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
17049 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
17050
17051 cmd->vdev_id = param->vdev_id;
17052 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17053 cmd->tid = param->tidno;
17054 cmd->buffersize = param->buffersize;
17055
17056 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
17057 if (QDF_IS_STATUS_ERROR(ret)) {
17058 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17059 wmi_buf_free(buf);
17060 return QDF_STATUS_E_FAILURE;
17061 }
17062
17063 return QDF_STATUS_SUCCESS;
17064}
17065
17066/**
17067 * send_delba_send_cmd_tlv() - send delba send command to fw
17068 * @wmi_handle: wmi handle
17069 * @param: pointer to delba send params
17070 * @macaddr: peer mac address
17071 *
17072 * Send WMI_DELBA_SEND_CMDID command to firmware
17073 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17074 */
17075static QDF_STATUS
17076send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
17077 uint8_t macaddr[IEEE80211_ADDR_LEN],
17078 struct delba_send_params *param)
17079{
17080 wmi_delba_send_cmd_fixed_param *cmd;
17081 wmi_buf_t buf;
17082 uint16_t len;
17083 QDF_STATUS ret;
17084
17085 len = sizeof(*cmd);
17086
17087 buf = wmi_buf_alloc(wmi_handle, len);
17088 if (!buf) {
17089 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17090 return QDF_STATUS_E_NOMEM;
17091 }
17092
17093 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
17094
17095 WMITLV_SET_HDR(&cmd->tlv_header,
17096 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
17097 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
17098
17099 cmd->vdev_id = param->vdev_id;
17100 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17101 cmd->tid = param->tidno;
17102 cmd->initiator = param->initiator;
17103 cmd->reasoncode = param->reasoncode;
17104
17105 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
17106 if (QDF_IS_STATUS_ERROR(ret)) {
17107 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17108 wmi_buf_free(buf);
17109 return QDF_STATUS_E_FAILURE;
17110 }
17111
17112 return QDF_STATUS_SUCCESS;
17113}
17114
17115/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080017116 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
17117 * to fw
17118 * @wmi_handle: wmi handle
17119 * @param: pointer to addba clearresp params
17120 * @macaddr: peer mac address
17121 * Return: 0 for success or error code
17122 */
17123static QDF_STATUS
17124send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
17125 uint8_t macaddr[IEEE80211_ADDR_LEN],
17126 struct addba_clearresponse_params *param)
17127{
17128 wmi_addba_clear_resp_cmd_fixed_param *cmd;
17129 wmi_buf_t buf;
17130 uint16_t len;
17131 QDF_STATUS ret;
17132
17133 len = sizeof(*cmd);
17134
17135 buf = wmi_buf_alloc(wmi_handle, len);
17136 if (!buf) {
17137 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
17138 return QDF_STATUS_E_FAILURE;
17139 }
17140 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
17141
17142 WMITLV_SET_HDR(&cmd->tlv_header,
17143 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
17144 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
17145
17146 cmd->vdev_id = param->vdev_id;
17147 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17148
17149 ret = wmi_unified_cmd_send(wmi_handle,
17150 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
17151 if (QDF_IS_STATUS_ERROR(ret)) {
17152 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17153 wmi_buf_free(buf);
17154 return QDF_STATUS_E_FAILURE;
17155 }
17156
17157 return QDF_STATUS_SUCCESS;
17158}
17159
17160/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017161 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
17162 * @wmi_handle: wmi handle
17163 * @bcn_ctrl_param: pointer to bcn_offload_control param
17164 *
17165 * Return: QDF_STATUS_SUCCESS for success or error code
17166 */
17167static
17168QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
17169 struct bcn_offload_control *bcn_ctrl_param)
17170{
17171 wmi_buf_t buf;
17172 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
17173 QDF_STATUS ret;
17174 uint32_t len;
17175
17176 len = sizeof(*cmd);
17177
17178 buf = wmi_buf_alloc(wmi_handle, len);
17179 if (!buf) {
17180 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17181 return QDF_STATUS_E_FAILURE;
17182 }
17183
17184 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
17185 WMITLV_SET_HDR(&cmd->tlv_header,
17186 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
17187 WMITLV_GET_STRUCT_TLVLEN
17188 (wmi_bcn_offload_ctrl_cmd_fixed_param));
17189 cmd->vdev_id = bcn_ctrl_param->vdev_id;
17190 if (bcn_ctrl_param->bcn_tx_enable)
17191 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
17192 else
17193 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
17194
17195
17196 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
17197 WMI_BCN_OFFLOAD_CTRL_CMDID);
17198
17199 if (QDF_IS_STATUS_ERROR(ret)) {
17200 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
17201 ret);
17202 wmi_buf_free(buf);
17203 }
17204
17205 return ret;
17206}
17207
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017208#ifdef WLAN_FEATURE_NAN_CONVERGENCE
17209static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
17210 struct nan_datapath_initiator_req *ndp_req)
17211{
17212 uint16_t len;
17213 wmi_buf_t buf;
17214 uint8_t *tlv_ptr;
17215 QDF_STATUS status;
17216 wmi_channel *ch_tlv;
17217 wmi_ndp_initiator_req_fixed_param *cmd;
17218 uint32_t passphrase_len, service_name_len;
17219 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
17220
17221 /*
17222 * WMI command expects 4 byte alligned len:
17223 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17224 */
17225 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
17226 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
17227 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
17228 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
17229 service_name_len =
17230 qdf_roundup(ndp_req->service_name.service_name_len, 4);
17231 /* allocated memory for fixed params as well as variable size data */
17232 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
17233 + ndp_cfg_len + ndp_app_info_len + pmk_len
17234 + passphrase_len + service_name_len;
17235
17236 buf = wmi_buf_alloc(wmi_handle, len);
17237 if (!buf) {
17238 WMI_LOGE("wmi_buf_alloc failed");
17239 return QDF_STATUS_E_NOMEM;
17240 }
17241
17242 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
17243 WMITLV_SET_HDR(&cmd->tlv_header,
17244 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
17245 WMITLV_GET_STRUCT_TLVLEN(
17246 wmi_ndp_initiator_req_fixed_param));
17247 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
17248 cmd->transaction_id = ndp_req->transaction_id;
17249 cmd->service_instance_id = ndp_req->service_instance_id;
17250 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
17251 &cmd->peer_discovery_mac_addr);
17252
17253 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
17254 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
17255 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
17256 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
17257 cmd->nan_csid = ndp_req->ncs_sk_type;
17258 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
17259 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
17260
17261 ch_tlv = (wmi_channel *)&cmd[1];
17262 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
17263 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
17264 ch_tlv->mhz = ndp_req->channel;
17265 tlv_ptr = (uint8_t *)&ch_tlv[1];
17266
17267 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17268 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17269 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17270 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17271
17272 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17273 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17274 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
17275 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17276
17277 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17278 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
17279 cmd->nan_pmk_len);
17280 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17281
17282 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17283 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
17284 cmd->nan_passphrase_len);
17285 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17286
17287 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17288 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17289 ndp_req->service_name.service_name,
17290 cmd->nan_servicename_len);
17291 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17292
17293 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
17294 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
17295 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
17296 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
17297 cmd->peer_discovery_mac_addr.mac_addr31to0,
17298 cmd->peer_discovery_mac_addr.mac_addr47to32);
17299
17300 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
17301 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17302 ndp_req->ndp_config.ndp_cfg,
17303 ndp_req->ndp_config.ndp_cfg_len);
17304
17305 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
17306 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17307 ndp_req->ndp_info.ndp_app_info,
17308 ndp_req->ndp_info.ndp_app_info_len);
17309
17310 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17311 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17312 ndp_req->pmk.pmk, cmd->nan_pmk_len);
17313
17314 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17315 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17316 ndp_req->passphrase.passphrase,
17317 cmd->nan_passphrase_len);
17318
17319 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17320 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17321 ndp_req->service_name.service_name,
17322 cmd->nan_servicename_len);
17323
17324 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
17325 WMI_NDP_INITIATOR_REQ_CMDID);
17326
17327 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17328 WMI_NDP_INITIATOR_REQ_CMDID);
17329 if (QDF_IS_STATUS_ERROR(status)) {
17330 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
17331 wmi_buf_free(buf);
17332 }
17333
17334 return status;
17335}
17336
17337static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
17338 struct nan_datapath_responder_req *req)
17339{
17340 uint16_t len;
17341 wmi_buf_t buf;
17342 uint8_t *tlv_ptr;
17343 QDF_STATUS status;
17344 wmi_ndp_responder_req_fixed_param *cmd;
17345 uint32_t passphrase_len, service_name_len;
17346 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
17347
17348 vdev_id = wlan_vdev_get_id(req->vdev);
17349 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
17350 vdev_id, req->transaction_id,
17351 req->ndp_rsp,
17352 req->ndp_instance_id,
17353 req->ndp_info.ndp_app_info_len);
17354
17355 /*
17356 * WMI command expects 4 byte alligned len:
17357 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17358 */
17359 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
17360 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
17361 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
17362 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
17363 service_name_len =
17364 qdf_roundup(req->service_name.service_name_len, 4);
17365
17366 /* allocated memory for fixed params as well as variable size data */
17367 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
17368 + pmk_len + passphrase_len + service_name_len;
17369
17370 buf = wmi_buf_alloc(wmi_handle, len);
17371 if (!buf) {
17372 WMI_LOGE("wmi_buf_alloc failed");
17373 return QDF_STATUS_E_NOMEM;
17374 }
17375 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
17376 WMITLV_SET_HDR(&cmd->tlv_header,
17377 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
17378 WMITLV_GET_STRUCT_TLVLEN(
17379 wmi_ndp_responder_req_fixed_param));
17380 cmd->vdev_id = vdev_id;
17381 cmd->transaction_id = req->transaction_id;
17382 cmd->ndp_instance_id = req->ndp_instance_id;
17383 cmd->rsp_code = req->ndp_rsp;
17384 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
17385 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
17386 cmd->nan_pmk_len = req->pmk.pmk_len;
17387 cmd->nan_csid = req->ncs_sk_type;
17388 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
17389 cmd->nan_servicename_len = req->service_name.service_name_len;
17390
17391 tlv_ptr = (uint8_t *)&cmd[1];
17392 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17393 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17394 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17395
17396 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17397 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17398 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17399 req->ndp_info.ndp_app_info,
17400 req->ndp_info.ndp_app_info_len);
17401
17402 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17403 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17404 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
17405 cmd->nan_pmk_len);
17406
17407 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17408 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17409 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17410 req->passphrase.passphrase,
17411 cmd->nan_passphrase_len);
17412 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17413
17414 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17415 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17416 req->service_name.service_name,
17417 cmd->nan_servicename_len);
17418
17419 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17420
17421 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
17422 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
17423
17424 WMI_LOGD("ndp_config len: %d",
17425 req->ndp_config.ndp_cfg_len);
17426 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17427 req->ndp_config.ndp_cfg,
17428 req->ndp_config.ndp_cfg_len);
17429
17430 WMI_LOGD("ndp_app_info len: %d",
17431 req->ndp_info.ndp_app_info_len);
17432 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17433 req->ndp_info.ndp_app_info,
17434 req->ndp_info.ndp_app_info_len);
17435
17436 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17437 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17438 req->pmk.pmk, cmd->nan_pmk_len);
17439
17440 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17441 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17442 req->passphrase.passphrase,
17443 cmd->nan_passphrase_len);
17444
17445 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17446 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17447 req->service_name.service_name,
17448 cmd->nan_servicename_len);
17449
17450 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
17451 WMI_NDP_RESPONDER_REQ_CMDID);
17452 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17453 WMI_NDP_RESPONDER_REQ_CMDID);
17454 if (QDF_IS_STATUS_ERROR(status)) {
17455 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
17456 wmi_buf_free(buf);
17457 }
17458 return status;
17459}
17460
17461static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
17462 struct nan_datapath_end_req *req)
17463{
17464 uint16_t len;
17465 wmi_buf_t buf;
17466 QDF_STATUS status;
17467 uint32_t ndp_end_req_len, i;
17468 wmi_ndp_end_req *ndp_end_req_lst;
17469 wmi_ndp_end_req_fixed_param *cmd;
17470
17471 /* len of tlv following fixed param */
17472 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
17473 /* above comes out to 4 byte alligned already, no need of padding */
17474 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
17475 buf = wmi_buf_alloc(wmi_handle, len);
17476 if (!buf) {
17477 WMI_LOGE("Malloc failed");
17478 return QDF_STATUS_E_NOMEM;
17479 }
17480
17481 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
17482 WMITLV_SET_HDR(&cmd->tlv_header,
17483 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
17484 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
17485
17486 cmd->transaction_id = req->transaction_id;
17487
17488 /* set tlv pointer to end of fixed param */
17489 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
17490 ndp_end_req_len);
17491
17492 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
17493 WMI_TLV_HDR_SIZE);
17494 for (i = 0; i < req->num_ndp_instances; i++) {
17495 WMITLV_SET_HDR(&ndp_end_req_lst[i],
17496 WMITLV_TAG_ARRAY_FIXED_STRUC,
17497 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
17498
17499 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
17500 }
17501
17502 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
17503 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17504 WMI_NDP_END_REQ_CMDID);
17505 if (QDF_IS_STATUS_ERROR(status)) {
17506 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
17507 wmi_buf_free(buf);
17508 }
17509
17510 return status;
17511}
17512
17513static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
17514 uint8_t *data, struct nan_datapath_initiator_rsp **rsp)
17515{
17516 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
17517 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
17518
17519 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
17520 fixed_params = event->fixed_param;
17521
17522 *rsp = qdf_mem_malloc(sizeof(**rsp));
17523 if (!(*rsp)) {
17524 WMI_LOGE("malloc failed");
17525 return QDF_STATUS_E_NOMEM;
17526 }
17527
17528 (*rsp)->vdev =
17529 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17530 fixed_params->vdev_id,
17531 WLAN_NAN_ID);
17532 if (!(*rsp)->vdev) {
17533 WMI_LOGE("vdev is null");
17534 qdf_mem_free(*rsp);
17535 return QDF_STATUS_E_INVAL;
17536 }
17537
17538 (*rsp)->transaction_id = fixed_params->transaction_id;
17539 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17540 (*rsp)->status = fixed_params->rsp_status;
17541 (*rsp)->reason = fixed_params->reason_code;
17542
17543 return QDF_STATUS_SUCCESS;
17544}
17545
17546static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
17547 uint8_t *data, struct nan_datapath_indication_event **rsp)
17548{
17549 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
17550 wmi_ndp_indication_event_fixed_param *fixed_params;
17551
17552 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
17553 fixed_params =
17554 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
17555
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017556 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17557 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17558 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17559 return QDF_STATUS_E_INVAL;
17560 }
17561
17562 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17563 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17564 fixed_params->ndp_app_info_len,
17565 event->num_ndp_app_info);
17566 return QDF_STATUS_E_INVAL;
17567 }
17568
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017569 *rsp = qdf_mem_malloc(sizeof(**rsp));
17570 if (!(*rsp)) {
17571 WMI_LOGE("malloc failed");
17572 return QDF_STATUS_E_NOMEM;
17573 }
17574
17575 (*rsp)->vdev =
17576 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17577 fixed_params->vdev_id,
17578 WLAN_NAN_ID);
17579 if (!(*rsp)->vdev) {
17580 WMI_LOGE("vdev is null");
17581 qdf_mem_free(*rsp);
17582 return QDF_STATUS_E_INVAL;
17583 }
17584 (*rsp)->service_instance_id = fixed_params->service_instance_id;
17585 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17586 (*rsp)->role = fixed_params->self_ndp_role;
17587 (*rsp)->policy = fixed_params->accept_policy;
17588
17589 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17590 (*rsp)->peer_mac_addr.bytes);
17591 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
17592 (*rsp)->peer_discovery_mac_addr.bytes);
17593
17594 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
17595 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
17596 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
17597 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
17598 fixed_params->service_instance_id,
17599 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
17600 fixed_params->accept_policy,
17601 fixed_params->nan_csid, fixed_params->nan_scid_len,
17602 (*rsp)->peer_mac_addr.bytes,
17603 (*rsp)->peer_discovery_mac_addr.bytes);
17604
17605 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17606 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17607 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17608
17609 WMI_LOGD("ndp_app_info - %d bytes",
17610 fixed_params->ndp_app_info_len);
17611 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17612 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17613
17614 (*rsp)->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
17615 (*rsp)->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17616 (*rsp)->ncs_sk_type = fixed_params->nan_csid;
17617 (*rsp)->scid.scid_len = fixed_params->nan_scid_len;
17618 qdf_mem_copy((*rsp)->ndp_config.ndp_cfg, event->ndp_cfg,
17619 (*rsp)->ndp_config.ndp_cfg_len);
17620 qdf_mem_copy((*rsp)->ndp_info.ndp_app_info, event->ndp_app_info,
17621 (*rsp)->ndp_info.ndp_app_info_len);
17622 qdf_mem_copy((*rsp)->scid.scid, event->ndp_scid, (*rsp)->scid.scid_len);
17623 WMI_LOGD("scid hex dump:");
17624 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17625 (*rsp)->scid.scid, (*rsp)->scid.scid_len);
17626
17627 return QDF_STATUS_SUCCESS;
17628}
17629
17630static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
17631 uint8_t *data, struct nan_datapath_confirm_event **rsp)
17632{
17633 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
17634 wmi_ndp_confirm_event_fixed_param *fixed_params;
17635
17636 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
17637 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
17638 WMI_LOGD("WMI_NDP_CONFIRM_EVENTID(0x%X) recieved. vdev %d, ndp_instance %d, rsp_code %d, reason_code: %d, num_active_ndps_on_peer: %d",
17639 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
17640 fixed_params->ndp_instance_id, fixed_params->rsp_code,
17641 fixed_params->reason_code,
17642 fixed_params->num_active_ndps_on_peer);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017643
17644 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17645 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17646 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17647 return QDF_STATUS_E_INVAL;
17648 }
17649
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017650 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17651 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17652 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17653
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017654 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17655 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17656 fixed_params->ndp_app_info_len,
17657 event->num_ndp_app_info);
17658 return QDF_STATUS_E_INVAL;
17659 }
17660
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017661 WMI_LOGD("ndp_app_info - %d bytes",
17662 fixed_params->ndp_app_info_len);
17663 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17664 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17665
17666 *rsp = qdf_mem_malloc(sizeof(**rsp));
17667 if (!(*rsp)) {
17668 WMI_LOGE("malloc failed");
17669 return QDF_STATUS_E_NOMEM;
17670 }
17671
17672 (*rsp)->vdev =
17673 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17674 fixed_params->vdev_id,
17675 WLAN_NAN_ID);
17676 if (!(*rsp)->vdev) {
17677 WMI_LOGE("vdev is null");
17678 qdf_mem_free(*rsp);
17679 return QDF_STATUS_E_INVAL;
17680 }
17681 (*rsp)->ndp_instance_id = fixed_params->ndp_instance_id;
17682 (*rsp)->rsp_code = fixed_params->rsp_code;
17683 (*rsp)->reason_code = fixed_params->reason_code;
17684 (*rsp)->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
17685 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17686 (*rsp)->peer_ndi_mac_addr.bytes);
17687 (*rsp)->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17688 qdf_mem_copy((*rsp)->ndp_info.ndp_app_info, event->ndp_app_info,
17689 (*rsp)->ndp_info.ndp_app_info_len);
17690
17691 return QDF_STATUS_SUCCESS;
17692}
17693
17694static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
17695 uint8_t *data, struct nan_datapath_responder_rsp **rsp)
17696{
17697 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17698 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17699
17700 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17701 fixed_params = event->fixed_param;
17702
17703 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",
17704 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
17705 (*rsp)->peer_mac_addr.bytes, (*rsp)->transaction_id,
17706 (*rsp)->status, (*rsp)->reason, (*rsp)->create_peer);
17707
17708 *rsp = qdf_mem_malloc(sizeof(**rsp));
17709 if (!(*rsp)) {
17710 WMI_LOGE("malloc failed");
17711 return QDF_STATUS_E_NOMEM;
17712 }
17713
17714 (*rsp)->vdev =
17715 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17716 fixed_params->vdev_id,
17717 WLAN_NAN_ID);
17718 if (!(*rsp)->vdev) {
17719 WMI_LOGE("vdev is null");
17720 qdf_mem_free(*rsp);
17721 return QDF_STATUS_E_INVAL;
17722 }
17723 (*rsp)->transaction_id = fixed_params->transaction_id;
17724 (*rsp)->reason = fixed_params->reason_code;
17725 (*rsp)->status = fixed_params->rsp_status;
17726 (*rsp)->create_peer = fixed_params->create_peer;
17727 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
17728 (*rsp)->peer_mac_addr.bytes);
17729
17730 return QDF_STATUS_SUCCESS;
17731}
17732
17733static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
17734 uint8_t *data, struct nan_datapath_end_rsp_event **rsp)
17735{
17736 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17737 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17738
17739 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17740 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
17741 WMI_LOGD("WMI_NDP_END_RSP_EVENTID(0x%X) recieved. transaction_id: %d, rsp_status: %d, reason_code: %d",
17742 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17743 fixed_params->rsp_status, fixed_params->reason_code);
17744
17745 *rsp = qdf_mem_malloc(sizeof(**rsp));
17746 if (!(*rsp)) {
17747 WMI_LOGE("malloc failed");
17748 return QDF_STATUS_E_NOMEM;
17749 }
17750
17751 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17752 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17753 if (!(*rsp)->vdev) {
17754 WMI_LOGE("vdev is null");
17755 qdf_mem_free(*rsp);
17756 return QDF_STATUS_E_INVAL;
17757 }
17758 (*rsp)->transaction_id = fixed_params->transaction_id;
17759 (*rsp)->reason = fixed_params->reason_code;
17760 (*rsp)->status = fixed_params->rsp_status;
17761
17762 return QDF_STATUS_SUCCESS;
17763}
17764
17765static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17766 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17767{
17768 uint32_t i, buf_size;
17769 wmi_ndp_end_indication *ind;
17770 struct qdf_mac_addr peer_addr;
17771 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17772
17773 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17774 ind = event->ndp_end_indication_list;
17775
17776 if (event->num_ndp_end_indication_list == 0) {
17777 WMI_LOGE("Error: Event ignored, 0 ndp instances");
17778 return -EINVAL;
17779 }
17780
17781 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17782 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17783 if (!(*rsp)->vdev) {
17784 WMI_LOGE("vdev is null");
17785 qdf_mem_free(*rsp);
17786 return QDF_STATUS_E_INVAL;
17787 }
17788
17789 WMI_LOGD("number of ndp instances = %d",
17790 event->num_ndp_end_indication_list);
17791 buf_size = sizeof(*rsp) + event->num_ndp_end_indication_list *
17792 sizeof((*rsp)->ndp_map[0]);
17793 *rsp = qdf_mem_malloc(buf_size);
17794 if (!(*rsp)) {
17795 WMI_LOGE("Failed to allocate memory");
17796 return -ENOMEM;
17797 }
17798
17799 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17800 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17801 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17802 peer_addr.bytes);
17803 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17804 i, ind[i].type, ind[i].reason_code,
17805 ind[i].ndp_instance_id,
17806 ind[i].num_active_ndps_on_peer);
17807 /* Add each instance entry to the list */
17808 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17809 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17810 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17811 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17812 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17813 ind[i].num_active_ndps_on_peer;
17814 (*rsp)->ndp_map[i].type = ind[i].type;
17815 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17816 }
17817
17818 return QDF_STATUS_SUCCESS;
17819}
17820#endif
17821
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017822/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017823 * save_service_bitmap_tlv() - save service bitmap
17824 * @wmi_handle: wmi handle
17825 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017826 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017827 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017828 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017829 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017830static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017831QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017832 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017833{
17834 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017835 struct wmi_soc *soc = wmi_handle->soc;
17836
Govind Singhe7f2f342016-05-23 12:12:52 +053017837 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17838
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017839 /* If it is already allocated, use that buffer. This can happen
17840 * during target stop/start scenarios where host allocation is skipped.
17841 */
17842 if (!soc->wmi_service_bitmap) {
17843 soc->wmi_service_bitmap =
17844 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17845 if (!soc->wmi_service_bitmap) {
17846 WMI_LOGE("Failed memory allocation for service bitmap");
17847 return QDF_STATUS_E_NOMEM;
17848 }
17849 }
17850
17851 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017852 param_buf->wmi_service_bitmap,
17853 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017854
17855 if (bitmap_buf)
17856 qdf_mem_copy(bitmap_buf,
17857 param_buf->wmi_service_bitmap,
17858 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017859
17860 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017861}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017862
17863/**
17864 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17865 * @wmi_handle: wmi handle
17866 * @param evt_buf: pointer to event buffer
17867 * @param bitmap_buf: bitmap buffer, for converged legacy support
17868 *
17869 * Return: QDF_STATUS
17870 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017871static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017872QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017873 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017874{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017875 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17876 wmi_service_available_event_fixed_param *ev;
17877 struct wmi_soc *soc = wmi_handle->soc;
17878
17879 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17880
17881 ev = param_buf->fixed_param;
17882
17883 /* If it is already allocated, use that buffer. This can happen
17884 * during target stop/start scenarios where host allocation is skipped.
17885 */
17886 if (!soc->wmi_ext_service_bitmap) {
17887 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17888 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17889 if (!soc->wmi_ext_service_bitmap) {
17890 WMI_LOGE("Failed memory allocation for service bitmap");
17891 return QDF_STATUS_E_NOMEM;
17892 }
17893 }
17894
17895 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17896 ev->wmi_service_segment_bitmap,
17897 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017898
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017899 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17900 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17901 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17902
Rajeev Kumar77901472017-02-12 02:12:17 -080017903 if (bitmap_buf)
17904 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017905 soc->wmi_ext_service_bitmap,
17906 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017907
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017908 return QDF_STATUS_SUCCESS;
17909}
Govind Singhe7f2f342016-05-23 12:12:52 +053017910/**
17911 * is_service_enabled_tlv() - Check if service enabled
17912 * @param wmi_handle: wmi handle
17913 * @param service_id: service identifier
17914 *
17915 * Return: 1 enabled, 0 disabled
17916 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017917static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17918 uint32_t service_id)
17919{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017920 struct wmi_soc *soc = wmi_handle->soc;
17921
17922 if (!soc->wmi_service_bitmap) {
17923 WMI_LOGE("WMI service bit map is not saved yet\n");
17924 return false;
17925 }
17926
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017927 /* if wmi_service_enabled was received with extended bitmap,
17928 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017929 */
17930 if (soc->wmi_ext_service_bitmap)
17931 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17932 soc->wmi_ext_service_bitmap,
17933 service_id);
17934
17935 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17936 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017937}
Govind Singhe7f2f342016-05-23 12:12:52 +053017938
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017939static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17940 struct wlan_psoc_target_capability_info *cap)
17941{
17942 /* except LDPC all flags are common betwen legacy and here
17943 * also IBFEER is not defined for TLV
17944 */
17945 cap->ht_cap_info |= ev_target_cap & (
17946 WMI_HT_CAP_ENABLED
17947 | WMI_HT_CAP_HT20_SGI
17948 | WMI_HT_CAP_DYNAMIC_SMPS
17949 | WMI_HT_CAP_TX_STBC
17950 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17951 | WMI_HT_CAP_RX_STBC
17952 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17953 | WMI_HT_CAP_LDPC
17954 | WMI_HT_CAP_L_SIG_TXOP_PROT
17955 | WMI_HT_CAP_MPDU_DENSITY
17956 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17957 | WMI_HT_CAP_HT40_SGI);
17958 if (ev_target_cap & WMI_HT_CAP_LDPC)
17959 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17960 WMI_HOST_HT_CAP_TX_LDPC;
17961}
Govind Singhe7f2f342016-05-23 12:12:52 +053017962/**
17963 * extract_service_ready_tlv() - extract service ready event
17964 * @wmi_handle: wmi handle
17965 * @param evt_buf: pointer to received event buffer
17966 * @param cap: pointer to hold target capability information extracted from even
17967 *
17968 * Return: QDF_STATUS_SUCCESS for success or error code
17969 */
17970static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017971 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017972{
17973 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17974 wmi_service_ready_event_fixed_param *ev;
17975
17976
17977 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17978
17979 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17980 if (!ev) {
17981 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17982 return QDF_STATUS_E_FAILURE;
17983 }
17984
17985 cap->phy_capability = ev->phy_capability;
17986 cap->max_frag_entry = ev->max_frag_entry;
17987 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017988 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017989 cap->vht_cap_info = ev->vht_cap_info;
17990 cap->vht_supp_mcs = ev->vht_supp_mcs;
17991 cap->hw_min_tx_power = ev->hw_min_tx_power;
17992 cap->hw_max_tx_power = ev->hw_max_tx_power;
17993 cap->sys_cap_info = ev->sys_cap_info;
17994 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17995 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17996 cap->max_num_scan_channels = ev->max_num_scan_channels;
17997 cap->max_supported_macs = ev->max_supported_macs;
17998 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17999 cap->txrx_chainmask = ev->txrx_chainmask;
18000 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
18001 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053018002 cap->fw_version = ev->fw_build_vers;
18003 /* fw_version_1 is not available in TLV. */
18004 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053018005
18006 return QDF_STATUS_SUCCESS;
18007}
18008
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018009/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
18010 * to host internal WMI_HOST_REGDMN_MODE values.
18011 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
18012 * host currently. Add this in the future if required.
18013 * 11AX (Phase II) : 11ax related values are not currently
18014 * advertised separately by FW. As part of phase II regulatory bring-up,
18015 * finalize the advertisement mechanism.
18016 * @target_wireless_mode: target wireless mode received in message
18017 *
18018 * Return: returns the host internal wireless mode.
18019 */
18020static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
18021{
18022
18023 uint32_t wireless_modes = 0;
18024
18025 if (target_wireless_mode & REGDMN_MODE_11A)
18026 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
18027
18028 if (target_wireless_mode & REGDMN_MODE_TURBO)
18029 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
18030
18031 if (target_wireless_mode & REGDMN_MODE_11B)
18032 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
18033
18034 if (target_wireless_mode & REGDMN_MODE_PUREG)
18035 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
18036
18037 if (target_wireless_mode & REGDMN_MODE_11G)
18038 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
18039
18040 if (target_wireless_mode & REGDMN_MODE_108G)
18041 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
18042
18043 if (target_wireless_mode & REGDMN_MODE_108A)
18044 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
18045
18046 if (target_wireless_mode & REGDMN_MODE_XR)
18047 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
18048
18049 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
18050 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
18051
18052 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
18053 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
18054
18055 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
18056 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
18057
18058 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
18059 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
18060
18061 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
18062 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
18063
18064 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
18065 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
18066
18067 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
18068 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
18069
18070 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
18071 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
18072
18073 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
18074 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
18075
18076 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
18077 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
18078
18079 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
18080 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
18081
18082 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
18083 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
18084
18085 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
18086 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
18087
18088 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
18089 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
18090
18091 return wireless_modes;
18092}
18093
Govind Singhe7f2f342016-05-23 12:12:52 +053018094/**
18095 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
18096 * @wmi_handle: wmi handle
18097 * @param evt_buf: Pointer to event buffer
18098 * @param cap: pointer to hold HAL reg capabilities
18099 *
18100 * Return: QDF_STATUS_SUCCESS for success or error code
18101 */
18102static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018103 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053018104{
18105 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18106
18107 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18108
18109 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
18110 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080018111 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053018112
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018113 cap->wireless_modes = convert_wireless_modes_tlv(
18114 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053018115
Govind Singhe7f2f342016-05-23 12:12:52 +053018116 return QDF_STATUS_SUCCESS;
18117}
18118
18119/**
18120 * extract_host_mem_req_tlv() - Extract host memory request event
18121 * @wmi_handle: wmi handle
18122 * @param evt_buf: pointer to event buffer
18123 * @param num_entries: pointer to hold number of entries requested
18124 *
18125 * Return: Number of entries requested
18126 */
18127static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
18128 void *evt_buf, uint8_t *num_entries)
18129{
18130 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18131 wmi_service_ready_event_fixed_param *ev;
18132
18133 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18134
18135 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18136 if (!ev) {
18137 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18138 return NULL;
18139 }
18140
18141 *num_entries = ev->num_mem_reqs;
18142
18143 return (host_mem_req *)param_buf->mem_reqs;
18144}
18145
18146/**
18147 * save_fw_version_in_service_ready_tlv() - Save fw version in service
18148 * ready function
18149 * @wmi_handle: wmi handle
18150 * @param evt_buf: pointer to event buffer
18151 *
18152 * Return: QDF_STATUS_SUCCESS for success or error code
18153 */
18154static QDF_STATUS
18155save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
18156{
18157 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18158 wmi_service_ready_event_fixed_param *ev;
18159
18160
18161 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18162
18163 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18164 if (!ev) {
18165 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18166 return QDF_STATUS_E_FAILURE;
18167 }
18168
18169 /*Save fw version from service ready message */
18170 /*This will be used while sending INIT message */
18171 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
18172 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053018173
Govind Singhe7f2f342016-05-23 12:12:52 +053018174 return QDF_STATUS_SUCCESS;
18175}
18176
18177/**
18178 * ready_extract_init_status_tlv() - Extract init status from ready event
18179 * @wmi_handle: wmi handle
18180 * @param evt_buf: Pointer to event buffer
18181 *
18182 * Return: ready status
18183 */
18184static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
18185 void *evt_buf)
18186{
18187 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18188 wmi_ready_event_fixed_param *ev = NULL;
18189
Govind Singhe7f2f342016-05-23 12:12:52 +053018190 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18191 ev = param_buf->fixed_param;
18192
18193 qdf_print("%s:%d\n", __func__, ev->status);
18194
18195 return ev->status;
18196}
18197
18198/**
18199 * ready_extract_mac_addr_tlv() - extract mac address from ready event
18200 * @wmi_handle: wmi handle
18201 * @param evt_buf: pointer to event buffer
18202 * @param macaddr: Pointer to hold MAC address
18203 *
18204 * Return: QDF_STATUS_SUCCESS for success or error code
18205 */
18206static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
18207 void *evt_buf, uint8_t *macaddr)
18208{
18209 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18210 wmi_ready_event_fixed_param *ev = NULL;
18211
18212
18213 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18214 ev = param_buf->fixed_param;
18215
18216 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
18217
18218 return QDF_STATUS_SUCCESS;
18219}
18220
18221/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070018222 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
18223 * @wmi_handle: wmi handle
18224 * @param evt_buf: pointer to event buffer
18225 * @param macaddr: Pointer to hold number of MAC addresses
18226 *
18227 * Return: Pointer to addr list
18228 */
18229static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
18230 void *evt_buf, uint8_t *num_mac)
18231{
18232 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18233 wmi_ready_event_fixed_param *ev = NULL;
18234
18235 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18236 ev = param_buf->fixed_param;
18237
18238 *num_mac = ev->num_extra_mac_addr;
18239
18240 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
18241}
18242
18243/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018244 * extract_ready_params_tlv() - Extract data from ready event apart from
18245 * status, macaddr and version.
18246 * @wmi_handle: Pointer to WMI handle.
18247 * @evt_buf: Pointer to Ready event buffer.
18248 * @ev_param: Pointer to host defined struct to copy the data from event.
18249 *
18250 * Return: QDF_STATUS_SUCCESS on success.
18251 */
18252static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
18253 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
18254{
18255 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18256 wmi_ready_event_fixed_param *ev = NULL;
18257
18258 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18259 ev = param_buf->fixed_param;
18260
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018261 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018262 ev_param->num_dscp_table = ev->num_dscp_table;
18263 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
18264 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018265 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018266 /* Agile_cap in ready event is not supported in TLV target */
18267 ev_param->agile_capability = false;
18268
18269 return QDF_STATUS_SUCCESS;
18270}
18271
18272/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018273 * extract_dbglog_data_len_tlv() - extract debuglog data length
18274 * @wmi_handle: wmi handle
18275 * @param evt_buf: pointer to event buffer
18276 *
18277 * Return: length
18278 */
18279static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080018280 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053018281{
18282 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
18283
18284 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
18285
18286 *len = param_buf->num_bufp;
18287
18288 return param_buf->bufp;
18289}
18290
18291/**
18292 * extract_vdev_start_resp_tlv() - extract vdev start response
18293 * @wmi_handle: wmi handle
18294 * @param evt_buf: pointer to event buffer
18295 * @param vdev_rsp: Pointer to hold vdev response
18296 *
18297 * Return: QDF_STATUS_SUCCESS for success or error code
18298 */
18299static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
18300 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
18301{
18302 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
18303 wmi_vdev_start_response_event_fixed_param *ev;
18304
18305 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
18306 if (!param_buf) {
18307 qdf_print("Invalid start response event buffer\n");
18308 return QDF_STATUS_E_INVAL;
18309 }
18310
18311 ev = param_buf->fixed_param;
18312 if (!ev) {
18313 qdf_print("Invalid start response event buffer\n");
18314 return QDF_STATUS_E_INVAL;
18315 }
18316
18317 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
18318
18319 vdev_rsp->vdev_id = ev->vdev_id;
18320 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070018321 switch (ev->resp_type) {
18322 case WMI_VDEV_START_RESP_EVENT:
18323 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
18324 break;
18325 case WMI_VDEV_RESTART_RESP_EVENT:
18326 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
18327 break;
18328 default:
18329 qdf_print("Invalid start response event buffer\n");
18330 break;
18331 };
Govind Singhe7f2f342016-05-23 12:12:52 +053018332 vdev_rsp->status = ev->status;
18333 vdev_rsp->chain_mask = ev->chain_mask;
18334 vdev_rsp->smps_mode = ev->smps_mode;
18335 vdev_rsp->mac_id = ev->mac_id;
18336 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
18337 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
18338
18339 return QDF_STATUS_SUCCESS;
18340}
18341
18342/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053018343 * extract_vdev_delete_resp_tlv() - extract vdev delete response
18344 * @wmi_handle: wmi handle
18345 * @param evt_buf: pointer to event buffer
18346 * @param delete_rsp: Pointer to hold vdev delete response
18347 *
18348 * Return: QDF_STATUS_SUCCESS for success or error code
18349 */
18350static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
18351 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
18352{
18353 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
18354 wmi_vdev_delete_resp_event_fixed_param *ev;
18355
18356 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
18357 if (!param_buf) {
18358 WMI_LOGE("Invalid vdev delete response event buffer\n");
18359 return QDF_STATUS_E_INVAL;
18360 }
18361
18362 ev = param_buf->fixed_param;
18363 if (!ev) {
18364 WMI_LOGE("Invalid vdev delete response event\n");
18365 return QDF_STATUS_E_INVAL;
18366 }
18367
18368 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
18369 delete_rsp->vdev_id = ev->vdev_id;
18370
18371 return QDF_STATUS_SUCCESS;
18372}
18373
18374
18375/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018376 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053018377 * @wmi_handle: wmi handle
18378 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018379 * @param num_vdevs: Pointer to hold num vdev
18380 *
18381 * Return: QDF_STATUS_SUCCESS for success or error code
18382 */
18383static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18384 void *evt_buf, uint32_t *num_vdevs)
18385{
18386 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18387 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
18388 uint32_t vdev_map;
18389
18390 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
18391 if (!param_buf) {
18392 qdf_print("Invalid tbtt update ext event buffer\n");
18393 return QDF_STATUS_E_INVAL;
18394 }
18395 tbtt_offset_event = param_buf->fixed_param;
18396 vdev_map = tbtt_offset_event->vdev_map;
18397 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18398
18399 return QDF_STATUS_SUCCESS;
18400}
18401
18402/**
18403 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
18404 * @wmi_handle: wmi handle
18405 * @param evt_buf: pointer to event buffer
18406 * @param num_vdevs: Pointer to hold num vdev
18407 *
18408 * Return: QDF_STATUS_SUCCESS for success or error code
18409 */
18410static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18411 void *evt_buf, uint32_t *num_vdevs)
18412{
18413 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18414 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
18415
18416 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18417 if (!param_buf) {
18418 qdf_print("Invalid tbtt update ext event buffer\n");
18419 return QDF_STATUS_E_INVAL;
18420 }
18421 tbtt_offset_ext_event = param_buf->fixed_param;
18422
18423 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
18424
18425 return QDF_STATUS_SUCCESS;
18426}
18427
18428/**
18429 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
18430 * @wmi_handle: wmi handle
18431 * @param evt_buf: pointer to event buffer
18432 * @param idx: Index refering to a vdev
18433 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053018434 *
18435 * Return: QDF_STATUS_SUCCESS for success or error code
18436 */
18437static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018438 void *evt_buf, uint8_t idx,
18439 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018440{
18441 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18442 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018443 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018444
18445 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
18446 if (!param_buf) {
18447 qdf_print("Invalid tbtt update event buffer\n");
18448 return QDF_STATUS_E_INVAL;
18449 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018450
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018451 tbtt_offset_event = param_buf->fixed_param;
18452 vdev_map = tbtt_offset_event->vdev_map;
18453 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
18454 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
18455 return QDF_STATUS_E_INVAL;
18456 tbtt_param->tbttoffset =
18457 param_buf->tbttoffset_list[tbtt_param->vdev_id];
18458
18459 return QDF_STATUS_SUCCESS;
18460}
18461
18462/**
18463 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
18464 * @wmi_handle: wmi handle
18465 * @param evt_buf: pointer to event buffer
18466 * @param idx: Index refering to a vdev
18467 * @param tbtt_param: Pointer to tbttoffset event param
18468 *
18469 * Return: QDF_STATUS_SUCCESS for success or error code
18470 */
18471static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
18472 void *evt_buf, uint8_t idx,
18473 struct tbttoffset_params *tbtt_param)
18474{
18475 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18476 wmi_tbtt_offset_info *tbtt_offset_info;
18477
18478 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18479 if (!param_buf) {
18480 qdf_print("Invalid tbtt update event buffer\n");
18481 return QDF_STATUS_E_INVAL;
18482 }
18483 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
18484
18485 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
18486 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053018487
18488 return QDF_STATUS_SUCCESS;
18489}
18490
18491/**
18492 * extract_mgmt_rx_params_tlv() - extract management rx params from event
18493 * @wmi_handle: wmi handle
18494 * @param evt_buf: pointer to event buffer
18495 * @param hdr: Pointer to hold header
18496 * @param bufp: Pointer to hold pointer to rx param buffer
18497 *
18498 * Return: QDF_STATUS_SUCCESS for success or error code
18499 */
18500static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053018501 void *evt_buf, struct mgmt_rx_event_params *hdr,
18502 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053018503{
18504 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
18505 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018506 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053018507
18508 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
18509 if (!param_tlvs) {
18510 WMI_LOGE("Get NULL point message from FW");
18511 return QDF_STATUS_E_INVAL;
18512 }
18513
18514 ev_hdr = param_tlvs->hdr;
18515 if (!hdr) {
18516 WMI_LOGE("Rx event is NULL");
18517 return QDF_STATUS_E_INVAL;
18518 }
18519
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018520 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18521 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018522
18523 hdr->channel = ev_hdr->channel;
18524 hdr->snr = ev_hdr->snr;
18525 hdr->rate = ev_hdr->rate;
18526 hdr->phy_mode = ev_hdr->phy_mode;
18527 hdr->buf_len = ev_hdr->buf_len;
18528 hdr->status = ev_hdr->status;
18529 hdr->flags = ev_hdr->flags;
18530 hdr->rssi = ev_hdr->rssi;
18531 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018532 for (i = 0; i < ATH_MAX_ANTENNA; i++)
18533 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053018534
18535 *bufp = param_tlvs->bufp;
18536
18537 return QDF_STATUS_SUCCESS;
18538}
18539
18540/**
18541 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
18542 * @wmi_handle: wmi handle
18543 * @param evt_buf: pointer to event buffer
18544 * @param vdev_id: Pointer to hold vdev identifier
18545 *
18546 * Return: QDF_STATUS_SUCCESS for success or error code
18547 */
18548static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
18549 void *evt_buf, uint32_t *vdev_id)
18550{
18551 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
18552 wmi_vdev_stopped_event_fixed_param *resp_event;
18553
18554 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
18555 if (!param_buf) {
18556 WMI_LOGE("Invalid event buffer");
18557 return QDF_STATUS_E_INVAL;
18558 }
18559 resp_event = param_buf->fixed_param;
18560 *vdev_id = resp_event->vdev_id;
18561
18562 return QDF_STATUS_SUCCESS;
18563}
18564
18565/**
18566 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
18567 * @wmi_handle: wmi handle
18568 * @param evt_buf: pointer to event buffer
18569 * @param param: Pointer to hold roam param
18570 *
18571 * Return: QDF_STATUS_SUCCESS for success or error code
18572 */
18573static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
18574 void *evt_buf, wmi_host_roam_event *param)
18575{
18576 WMI_ROAM_EVENTID_param_tlvs *param_buf;
18577 wmi_roam_event_fixed_param *evt;
18578
18579 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18580 if (!param_buf) {
18581 WMI_LOGE("Invalid roam event buffer");
18582 return QDF_STATUS_E_INVAL;
18583 }
18584
18585 evt = param_buf->fixed_param;
18586 qdf_mem_zero(param, sizeof(*param));
18587
18588 param->vdev_id = evt->vdev_id;
18589 param->reason = evt->reason;
18590 param->rssi = evt->rssi;
18591
18592 return QDF_STATUS_SUCCESS;
18593}
18594
18595/**
18596 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18597 * @wmi_handle: wmi handle
18598 * @param evt_buf: pointer to event buffer
18599 * @param param: Pointer to hold vdev scan param
18600 *
18601 * Return: QDF_STATUS_SUCCESS for success or error code
18602 */
18603static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018604 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018605{
18606 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18607 wmi_scan_event_fixed_param *evt = NULL;
18608
18609 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18610 evt = param_buf->fixed_param;
18611
18612 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018613
Govind Singhe7f2f342016-05-23 12:12:52 +053018614 switch (evt->event) {
18615 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018616 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018617 break;
18618 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018619 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018620 break;
18621 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018622 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018623 break;
18624 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018625 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018626 break;
18627 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018628 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018629 break;
18630 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018631 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018632 break;
18633 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018634 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018635 break;
18636 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018637 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018638 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018639 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018640 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018641 break;
18642 case WMI_SCAN_EVENT_MAX:
18643 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018644 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018645 break;
18646 };
18647
18648 switch (evt->reason) {
18649 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018650 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018651 break;
18652 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018653 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018654 break;
18655 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018656 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018657 break;
18658 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018659 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018660 break;
18661 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018662 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018663 break;
18664 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018665 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018666 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018667 case WMI_SCAN_REASON_SUSPENDED:
18668 param->reason = SCAN_REASON_SUSPENDED;
18669 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018670 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018671 param->reason = SCAN_REASON_MAX;
18672 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018673 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018674 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018675 break;
18676 };
18677
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018678 param->chan_freq = evt->channel_freq;
18679 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018680 param->scan_id = evt->scan_id;
18681 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018682 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018683
18684 return QDF_STATUS_SUCCESS;
18685}
18686
Frank Liu3d5e9992017-03-15 17:51:43 +080018687#ifdef CONVERGED_TDLS_ENABLE
18688/**
18689 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18690 * @wmi_handle: wmi handle
18691 * @param evt_buf: pointer to event buffer
18692 * @param param: Pointer to hold vdev tdls param
18693 *
18694 * Return: QDF_STATUS_SUCCESS for success or error code
18695 */
18696static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18697 void *evt_buf, struct tdls_event_info *param)
18698{
18699 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18700 wmi_tdls_peer_event_fixed_param *evt;
18701
18702 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18703 if (!param_buf) {
18704 WMI_LOGE("%s: NULL param_buf", __func__);
18705 return QDF_STATUS_E_NULL_VALUE;
18706 }
18707
18708 evt = param_buf->fixed_param;
18709
18710 qdf_mem_zero(param, sizeof(*param));
18711
18712 param->vdev_id = evt->vdev_id;
18713 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18714 param->peermac.bytes);
18715 switch (evt->peer_status) {
18716 case WMI_TDLS_SHOULD_DISCOVER:
18717 param->message_type = TDLS_SHOULD_DISCOVER;
18718 break;
18719 case WMI_TDLS_SHOULD_TEARDOWN:
18720 param->message_type = TDLS_SHOULD_TEARDOWN;
18721 break;
18722 case WMI_TDLS_PEER_DISCONNECTED:
18723 param->message_type = TDLS_PEER_DISCONNECTED;
18724 break;
18725 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18726 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18727 break;
18728 default:
18729 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18730 __func__, evt->peer_status);
18731 return QDF_STATUS_E_INVAL;
18732 };
18733
18734 switch (evt->peer_reason) {
18735 case WMI_TDLS_TEARDOWN_REASON_TX:
18736 param->peer_reason = TDLS_TEARDOWN_TX;
18737 break;
18738 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18739 param->peer_reason = TDLS_TEARDOWN_RSSI;
18740 break;
18741 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18742 param->peer_reason = TDLS_TEARDOWN_SCAN;
18743 break;
18744 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18745 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18746 break;
18747 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18748 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18749 break;
18750 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18751 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18752 break;
18753 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18754 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18755 break;
18756 case WMI_TDLS_ENTER_BUF_STA:
18757 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18758 break;
18759 case WMI_TDLS_EXIT_BUF_STA:
18760 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18761 break;
18762 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18763 param->peer_reason = TDLS_ENTER_BT_BUSY;
18764 break;
18765 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18766 param->peer_reason = TDLS_EXIT_BT_BUSY;
18767 break;
18768 case WMI_TDLS_SCAN_STARTED_EVENT:
18769 param->peer_reason = TDLS_SCAN_STARTED;
18770 break;
18771 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18772 param->peer_reason = TDLS_SCAN_COMPLETED;
18773 break;
18774
18775 default:
18776 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18777 __func__, evt->peer_reason, evt->peer_status);
18778 return QDF_STATUS_E_INVAL;
18779 };
18780
18781 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18782 __func__, param->peermac.bytes, param->message_type,
18783 param->peer_reason, param->vdev_id);
18784
18785 return QDF_STATUS_SUCCESS;
18786}
18787#endif
18788
Govind Singhe7f2f342016-05-23 12:12:52 +053018789/**
18790 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18791 * @wmi_handle: wmi handle
18792 * @param evt_buf: pointer to event buffer
18793 * @param param: Pointer to hold MGMT TX completion params
18794 *
18795 * Return: QDF_STATUS_SUCCESS for success or error code
18796 */
18797static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18798 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18799{
18800 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18801 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18802
18803 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18804 evt_buf;
18805 if (!param_buf) {
18806 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18807 return QDF_STATUS_E_INVAL;
18808 }
18809 cmpl_params = param_buf->fixed_param;
18810
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018811 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18812 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018813 param->desc_id = cmpl_params->desc_id;
18814 param->status = cmpl_params->status;
18815
18816 return QDF_STATUS_SUCCESS;
18817}
18818
18819/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018820 * extract_offchan_data_tx_compl_param_tlv() -
18821 * extract Offchan data tx completion event params
18822 * @wmi_handle: wmi handle
18823 * @param evt_buf: pointer to event buffer
18824 * @param param: Pointer to hold offchan data TX completion params
18825 *
18826 * Return: QDF_STATUS_SUCCESS for success or error code
18827 */
18828static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18829 wmi_unified_t wmi_handle, void *evt_buf,
18830 struct wmi_host_offchan_data_tx_compl_event *param)
18831{
18832 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18833 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18834
18835 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18836 evt_buf;
18837 if (!param_buf) {
18838 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18839 return QDF_STATUS_E_INVAL;
18840 }
18841 cmpl_params = param_buf->fixed_param;
18842
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018843 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18844 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018845 param->desc_id = cmpl_params->desc_id;
18846 param->status = cmpl_params->status;
18847
18848 return QDF_STATUS_SUCCESS;
18849}
18850
18851/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018852 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18853 * status tlv
18854 * @wmi_handle: wmi handle
18855 * @param evt_buf: pointer to event buffer
18856 * @param param: Pointer to hold csa switch count status event param
18857 *
18858 * Return: QDF_STATUS_SUCCESS for success or error code
18859 */
18860static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18861 wmi_unified_t wmi_handle,
18862 void *evt_buf,
18863 struct pdev_csa_switch_count_status *param)
18864{
18865 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18866 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18867
18868 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18869 evt_buf;
18870 if (!param_buf) {
18871 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18872 return QDF_STATUS_E_INVAL;
18873 }
18874
18875 csa_status = param_buf->fixed_param;
18876
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018877 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18878 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018879 param->current_switch_count = csa_status->current_switch_count;
18880 param->num_vdevs = csa_status->num_vdevs;
18881 param->vdev_ids = param_buf->vdev_ids;
18882
18883 return QDF_STATUS_SUCCESS;
18884}
18885
18886/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018887 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18888 * param from event
18889 * @wmi_handle: wmi handle
18890 * @param evt_buf: pointer to event buffer
18891 * @param param: Pointer to hold tpc configuration
18892 *
18893 * Return: 0 for success or error code
18894 */
18895static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18896 void *evt_buf,
18897 wmi_host_pdev_tpc_config_event *param)
18898{
18899 wmi_pdev_tpc_config_event_fixed_param *event =
18900 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18901
18902 if (!event) {
18903 WMI_LOGE("Invalid event buffer");
18904 return QDF_STATUS_E_INVAL;
18905 }
18906
18907 param->pdev_id = event->pdev_id;
18908 param->regDomain = event->regDomain;
18909 param->chanFreq = event->chanFreq;
18910 param->phyMode = event->phyMode;
18911 param->twiceAntennaReduction = event->twiceAntennaReduction;
18912 param->twiceMaxRDPower = event->twiceMaxRDPower;
18913 param->powerLimit = event->powerLimit;
18914 param->rateMax = event->rateMax;
18915 param->numTxChain = event->numTxChain;
18916 param->ctl = event->ctl;
18917 param->flags = event->flags;
18918
18919 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18920 sizeof(param->maxRegAllowedPower));
18921 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18922 event->maxRegAllowedPowerAGCDD,
18923 sizeof(param->maxRegAllowedPowerAGCDD));
18924 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18925 event->maxRegAllowedPowerAGSTBC,
18926 sizeof(param->maxRegAllowedPowerAGSTBC));
18927 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18928 event->maxRegAllowedPowerAGTXBF,
18929 sizeof(param->maxRegAllowedPowerAGTXBF));
18930 WMI_LOGD("%s:extract success", __func__);
18931
18932 return QDF_STATUS_SUCCESS;
18933}
18934
18935/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018936 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018937 * @wmi_handle: wmi handle
18938 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018939 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018940 *
18941 * Return: QDF_STATUS_SUCCESS for success or error code
18942 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018943static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18944 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018945{
18946 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18947 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018948 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018949
18950 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18951 if (!param_buf) {
18952 WMI_LOGE("Invalid swba event buffer");
18953 return QDF_STATUS_E_INVAL;
18954 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018955
Govind Singhe7f2f342016-05-23 12:12:52 +053018956 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018957 *num_vdevs = swba_event->num_vdevs;
18958 if (!(*num_vdevs)) {
18959 vdev_map = swba_event->vdev_map;
18960 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18961 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018962
18963 return QDF_STATUS_SUCCESS;
18964}
18965
18966/**
18967 * extract_swba_tim_info_tlv() - extract swba tim info from event
18968 * @wmi_handle: wmi handle
18969 * @param evt_buf: pointer to event buffer
18970 * @param idx: Index to bcn info
18971 * @param tim_info: Pointer to hold tim info
18972 *
18973 * Return: QDF_STATUS_SUCCESS for success or error code
18974 */
18975static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18976 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18977{
18978 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18979 wmi_tim_info *tim_info_ev;
18980
18981 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18982 if (!param_buf) {
18983 WMI_LOGE("Invalid swba event buffer");
18984 return QDF_STATUS_E_INVAL;
18985 }
18986
18987 tim_info_ev = &param_buf->tim_info[idx];
18988
18989 tim_info->tim_len = tim_info_ev->tim_len;
18990 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18991 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18992 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18993 tim_info->tim_changed = tim_info_ev->tim_changed;
18994 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018995 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018996
18997 return QDF_STATUS_SUCCESS;
18998}
18999
19000/**
19001 * extract_swba_noa_info_tlv() - extract swba NoA information from event
19002 * @wmi_handle: wmi handle
19003 * @param evt_buf: pointer to event buffer
19004 * @param idx: Index to bcn info
19005 * @param p2p_desc: Pointer to hold p2p NoA info
19006 *
19007 * Return: QDF_STATUS_SUCCESS for success or error code
19008 */
19009static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
19010 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
19011{
19012 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
19013 wmi_p2p_noa_info *p2p_noa_info;
19014 uint8_t i = 0;
19015
19016 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
19017 if (!param_buf) {
19018 WMI_LOGE("Invalid swba event buffer");
19019 return QDF_STATUS_E_INVAL;
19020 }
19021
19022 p2p_noa_info = &param_buf->p2p_noa_info[idx];
19023
19024 p2p_desc->modified = false;
19025 p2p_desc->num_descriptors = 0;
19026 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
19027 p2p_desc->modified = true;
19028 p2p_desc->index =
19029 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
19030 p2p_desc->oppPS =
19031 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
19032 p2p_desc->ctwindow =
19033 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
19034 p2p_desc->num_descriptors =
19035 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
19036 (p2p_noa_info);
19037 for (i = 0; i < p2p_desc->num_descriptors; i++) {
19038 p2p_desc->noa_descriptors[i].type_count =
19039 (uint8_t) p2p_noa_info->noa_descriptors[i].
19040 type_count;
19041 p2p_desc->noa_descriptors[i].duration =
19042 p2p_noa_info->noa_descriptors[i].duration;
19043 p2p_desc->noa_descriptors[i].interval =
19044 p2p_noa_info->noa_descriptors[i].interval;
19045 p2p_desc->noa_descriptors[i].start_time =
19046 p2p_noa_info->noa_descriptors[i].start_time;
19047 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019048 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019049 }
19050
19051 return QDF_STATUS_SUCCESS;
19052}
19053
Wu Gaocd3a8512017-03-13 20:17:34 +080019054#ifdef CONVERGED_P2P_ENABLE
19055/**
19056 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
19057 * @wmi_handle: wmi handle
19058 * @param evt_buf: pointer to event buffer
19059 * @param param: Pointer to hold p2p noa info
19060 *
19061 * Return: QDF_STATUS_SUCCESS for success or error code
19062 */
19063static QDF_STATUS extract_p2p_noa_ev_param_tlv(
19064 wmi_unified_t wmi_handle, void *evt_buf,
19065 struct p2p_noa_info *param)
19066{
19067 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
19068 wmi_p2p_noa_event_fixed_param *fixed_param;
19069 uint8_t i;
19070 wmi_p2p_noa_info *wmi_noa_info;
19071 uint8_t *buf_ptr;
19072 uint32_t descriptors;
19073
19074 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
19075 if (!param_tlvs) {
19076 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
19077 return QDF_STATUS_E_INVAL;
19078 }
19079
19080 if (!param) {
19081 WMI_LOGE("noa information param is null");
19082 return QDF_STATUS_E_INVAL;
19083 }
19084
19085 fixed_param = param_tlvs->fixed_param;
19086 buf_ptr = (uint8_t *) fixed_param;
19087 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
19088 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
19089
19090 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
19091 WMI_LOGE("%s: noa attr is not modified", __func__);
19092 return QDF_STATUS_E_INVAL;
19093 }
19094
19095 param->vdev_id = fixed_param->vdev_id;
19096 param->index =
19097 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
19098 param->opps_ps =
19099 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
19100 param->ct_window =
19101 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
19102 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
19103 param->num_desc = (uint8_t) descriptors;
19104
19105 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
19106 param->index, param->opps_ps, param->ct_window,
19107 param->num_desc);
19108 for (i = 0; i < param->num_desc; i++) {
19109 param->noa_desc[i].type_count =
19110 (uint8_t) wmi_noa_info->noa_descriptors[i].
19111 type_count;
19112 param->noa_desc[i].duration =
19113 wmi_noa_info->noa_descriptors[i].duration;
19114 param->noa_desc[i].interval =
19115 wmi_noa_info->noa_descriptors[i].interval;
19116 param->noa_desc[i].start_time =
19117 wmi_noa_info->noa_descriptors[i].start_time;
19118 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
19119 __func__, i, param->noa_desc[i].type_count,
19120 param->noa_desc[i].duration,
19121 param->noa_desc[i].interval,
19122 param->noa_desc[i].start_time);
19123 }
19124
19125 return QDF_STATUS_SUCCESS;
19126}
19127
19128/**
19129 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
19130 * information from event
19131 * @wmi_handle: wmi handle
19132 * @param evt_buf: pointer to event buffer
19133 * @param param: Pointer to hold p2p lo stop event information
19134 *
19135 * Return: QDF_STATUS_SUCCESS for success or error code
19136 */
19137static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
19138 wmi_unified_t wmi_handle, void *evt_buf,
19139 struct p2p_lo_event *param)
19140{
19141 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
19142 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
19143
19144 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
19145 evt_buf;
19146 if (!param_tlvs) {
19147 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
19148 return QDF_STATUS_E_INVAL;
19149 }
19150
19151 if (!param) {
19152 WMI_LOGE("lo stop event param is null");
19153 return QDF_STATUS_E_INVAL;
19154 }
19155
19156 lo_param = param_tlvs->fixed_param;
19157 param->vdev_id = lo_param->vdev_id;
19158 param->reason_code = lo_param->reason;
19159 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
19160 param->vdev_id, param->reason_code);
19161
19162 return QDF_STATUS_SUCCESS;
19163}
19164#endif /* End of CONVERGED_P2P_ENABLE */
19165
Govind Singhe7f2f342016-05-23 12:12:52 +053019166/**
19167 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
19168 * @wmi_handle: wmi handle
19169 * @param evt_buf: pointer to event buffer
19170 * @param ev: Pointer to hold peer param
19171 *
19172 * Return: QDF_STATUS_SUCCESS for success or error code
19173 */
19174static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
19175 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
19176{
19177 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
19178 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
19179
19180 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
19181 kickout_event = param_buf->fixed_param;
19182
19183 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
19184 ev->peer_macaddr);
19185
19186 ev->reason = kickout_event->reason;
19187 ev->rssi = kickout_event->rssi;
19188
19189 return QDF_STATUS_SUCCESS;
19190}
19191
19192/**
19193 * extract_all_stats_counts_tlv() - extract all stats count from event
19194 * @wmi_handle: wmi handle
19195 * @param evt_buf: pointer to event buffer
19196 * @param stats_param: Pointer to hold stats count
19197 *
19198 * Return: QDF_STATUS_SUCCESS for success or error code
19199 */
19200static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
19201 void *evt_buf, wmi_host_stats_event *stats_param)
19202{
19203 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19204 wmi_stats_event_fixed_param *ev;
19205
19206 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19207
19208 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19209 if (!ev) {
19210 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
19211 return QDF_STATUS_E_FAILURE;
19212 }
19213
19214 switch (ev->stats_id) {
19215 case WMI_REQUEST_PEER_STAT:
19216 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
19217 break;
19218
19219 case WMI_REQUEST_AP_STAT:
19220 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
19221 break;
19222
19223 case WMI_REQUEST_PDEV_STAT:
19224 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
19225 break;
19226
19227 case WMI_REQUEST_VDEV_STAT:
19228 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
19229 break;
19230
19231 case WMI_REQUEST_BCNFLT_STAT:
19232 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
19233 break;
19234
19235 case WMI_REQUEST_VDEV_RATE_STAT:
19236 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
19237 break;
19238
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019239 case WMI_REQUEST_BCN_STAT:
19240 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
19241 break;
19242
Govind Singhe7f2f342016-05-23 12:12:52 +053019243 default:
19244 stats_param->stats_id = 0;
19245 break;
19246
19247 }
19248
19249 stats_param->num_pdev_stats = ev->num_pdev_stats;
19250 stats_param->num_pdev_ext_stats = 0;
19251 stats_param->num_vdev_stats = ev->num_vdev_stats;
19252 stats_param->num_peer_stats = ev->num_peer_stats;
19253 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
19254 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019255 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053019256 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19257 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053019258
19259 return QDF_STATUS_SUCCESS;
19260}
19261
19262/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019263 * extract_pdev_tx_stats() - extract pdev tx stats from event
19264 */
19265static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
19266{
19267 /* Tx Stats */
19268 tx->comp_queued = tx_stats->comp_queued;
19269 tx->comp_delivered = tx_stats->comp_delivered;
19270 tx->msdu_enqued = tx_stats->msdu_enqued;
19271 tx->mpdu_enqued = tx_stats->mpdu_enqued;
19272 tx->wmm_drop = tx_stats->wmm_drop;
19273 tx->local_enqued = tx_stats->local_enqued;
19274 tx->local_freed = tx_stats->local_freed;
19275 tx->hw_queued = tx_stats->hw_queued;
19276 tx->hw_reaped = tx_stats->hw_reaped;
19277 tx->underrun = tx_stats->underrun;
19278 tx->tx_abort = tx_stats->tx_abort;
19279 tx->mpdus_requed = tx_stats->mpdus_requed;
19280 tx->data_rc = tx_stats->data_rc;
19281 tx->self_triggers = tx_stats->self_triggers;
19282 tx->sw_retry_failure = tx_stats->sw_retry_failure;
19283 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
19284 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
19285 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
19286 tx->pdev_resets = tx_stats->pdev_resets;
19287 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
19288 tx->phy_underrun = tx_stats->phy_underrun;
19289 tx->txop_ovf = tx_stats->txop_ovf;
19290
19291 return;
19292}
19293
19294
19295/**
19296 * extract_pdev_rx_stats() - extract pdev rx stats from event
19297 */
19298static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
19299{
19300 /* Rx Stats */
19301 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
19302 rx->status_rcvd = rx_stats->status_rcvd;
19303 rx->r0_frags = rx_stats->r0_frags;
19304 rx->r1_frags = rx_stats->r1_frags;
19305 rx->r2_frags = rx_stats->r2_frags;
19306 /* Only TLV */
19307 rx->r3_frags = 0;
19308 rx->htt_msdus = rx_stats->htt_msdus;
19309 rx->htt_mpdus = rx_stats->htt_mpdus;
19310 rx->loc_msdus = rx_stats->loc_msdus;
19311 rx->loc_mpdus = rx_stats->loc_mpdus;
19312 rx->oversize_amsdu = rx_stats->oversize_amsdu;
19313 rx->phy_errs = rx_stats->phy_errs;
19314 rx->phy_err_drop = rx_stats->phy_err_drop;
19315 rx->mpdu_errs = rx_stats->mpdu_errs;
19316
19317 return;
19318}
19319
19320/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019321 * extract_pdev_stats_tlv() - extract pdev stats from event
19322 * @wmi_handle: wmi handle
19323 * @param evt_buf: pointer to event buffer
19324 * @param index: Index into pdev stats
19325 * @param pdev_stats: Pointer to hold pdev stats
19326 *
19327 * Return: QDF_STATUS_SUCCESS for success or error code
19328 */
19329static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
19330 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
19331{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019332 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19333 wmi_stats_event_fixed_param *ev_param;
19334 uint8_t *data;
19335
19336 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19337 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19338
19339 data = param_buf->data;
19340
19341 if (index < ev_param->num_pdev_stats) {
19342 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
19343 (index * sizeof(wmi_pdev_stats)));
19344
19345 pdev_stats->chan_nf = ev->chan_nf;
19346 pdev_stats->tx_frame_count = ev->tx_frame_count;
19347 pdev_stats->rx_frame_count = ev->rx_frame_count;
19348 pdev_stats->rx_clear_count = ev->rx_clear_count;
19349 pdev_stats->cycle_count = ev->cycle_count;
19350 pdev_stats->phy_err_count = ev->phy_err_count;
19351 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
19352
19353 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
19354 &(ev->pdev_stats.tx));
19355 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
19356 &(ev->pdev_stats.rx));
19357 }
19358
Govind Singhe7f2f342016-05-23 12:12:52 +053019359 return QDF_STATUS_SUCCESS;
19360}
19361
19362/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070019363 * extract_unit_test_tlv() - extract unit test data
19364 * @wmi_handle: wmi handle
19365 * @param evt_buf: pointer to event buffer
19366 * @param unit_test: pointer to hold unit test data
19367 * @param maxspace: Amount of space in evt_buf
19368 *
19369 * Return: QDF_STATUS_SUCCESS for success or error code
19370 */
19371static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
19372 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
19373{
19374 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
19375 wmi_unit_test_event_fixed_param *ev_param;
19376 uint32_t num_bufp;
19377 uint32_t copy_size;
19378 uint8_t *bufp;
19379
19380 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
19381 ev_param = param_buf->fixed_param;
19382 bufp = param_buf->bufp;
19383 num_bufp = param_buf->num_bufp;
19384 unit_test->vdev_id = ev_param->vdev_id;
19385 unit_test->module_id = ev_param->module_id;
19386 unit_test->diag_token = ev_param->diag_token;
19387 unit_test->flag = ev_param->flag;
19388 unit_test->payload_len = ev_param->payload_len;
19389 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
19390 ev_param->vdev_id,
19391 ev_param->module_id,
19392 ev_param->diag_token,
19393 ev_param->flag);
19394 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
19395 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
19396 bufp, num_bufp);
19397 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
19398 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
19399 unit_test->buffer_len = copy_size;
19400
19401 return QDF_STATUS_SUCCESS;
19402}
19403
19404/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019405 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
19406 * @wmi_handle: wmi handle
19407 * @param evt_buf: pointer to event buffer
19408 * @param index: Index into extended pdev stats
19409 * @param pdev_ext_stats: Pointer to hold extended pdev stats
19410 *
19411 * Return: QDF_STATUS_SUCCESS for success or error code
19412 */
19413static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
19414 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
19415{
19416 return QDF_STATUS_SUCCESS;
19417}
19418
19419/**
19420 * extract_vdev_stats_tlv() - extract vdev stats from event
19421 * @wmi_handle: wmi handle
19422 * @param evt_buf: pointer to event buffer
19423 * @param index: Index into vdev stats
19424 * @param vdev_stats: Pointer to hold vdev stats
19425 *
19426 * Return: QDF_STATUS_SUCCESS for success or error code
19427 */
19428static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
19429 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
19430{
19431 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19432 wmi_stats_event_fixed_param *ev_param;
19433 uint8_t *data;
19434
19435 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19436 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19437 data = (uint8_t *) param_buf->data;
19438
19439 if (index < ev_param->num_vdev_stats) {
19440 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
19441 ((ev_param->num_pdev_stats) *
19442 sizeof(wmi_pdev_stats)) +
19443 (index * sizeof(wmi_vdev_stats)));
19444
19445 vdev_stats->vdev_id = ev->vdev_id;
19446 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
19447 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
19448
19449 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
19450 sizeof(ev->tx_frm_cnt));
19451 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
19452 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
19453 ev->multiple_retry_cnt,
19454 sizeof(ev->multiple_retry_cnt));
19455 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
19456 sizeof(ev->fail_cnt));
19457 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
19458 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
19459 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
19460 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
19461 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
19462 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
19463 sizeof(ev->tx_rate_history));
19464 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
19465 sizeof(ev->bcn_rssi_history));
19466
19467 }
19468
19469 return QDF_STATUS_SUCCESS;
19470}
19471
19472/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019473 * extract_bcn_stats_tlv() - extract bcn stats from event
19474 * @wmi_handle: wmi handle
19475 * @param evt_buf: pointer to event buffer
19476 * @param index: Index into vdev stats
19477 * @param bcn_stats: Pointer to hold bcn stats
19478 *
19479 * Return: QDF_STATUS_SUCCESS for success or error code
19480 */
19481static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
19482 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
19483{
19484 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19485 wmi_stats_event_fixed_param *ev_param;
19486 uint8_t *data;
19487
19488 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19489 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19490 data = (uint8_t *) param_buf->data;
19491
19492 if (index < ev_param->num_bcn_stats) {
19493 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
19494 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19495 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19496 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19497 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
19498 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
19499 (index * sizeof(wmi_bcn_stats)));
19500
19501 bcn_stats->vdev_id = ev->vdev_id;
19502 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
19503 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
19504 }
19505
19506 return QDF_STATUS_SUCCESS;
19507}
19508
19509/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019510 * extract_peer_stats_tlv() - extract peer stats from event
19511 * @wmi_handle: wmi handle
19512 * @param evt_buf: pointer to event buffer
19513 * @param index: Index into peer stats
19514 * @param peer_stats: Pointer to hold peer stats
19515 *
19516 * Return: QDF_STATUS_SUCCESS for success or error code
19517 */
19518static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19519 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19520{
19521 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19522 wmi_stats_event_fixed_param *ev_param;
19523 uint8_t *data;
19524
19525 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19526 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19527 data = (uint8_t *) param_buf->data;
19528
19529 if (index < ev_param->num_peer_stats) {
19530 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19531 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19532 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19533 (index * sizeof(wmi_peer_stats)));
19534
19535 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19536
19537 OS_MEMCPY(&(peer_stats->peer_macaddr),
19538 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19539
19540 peer_stats->peer_rssi = ev->peer_rssi;
19541 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19542 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19543 }
19544
19545 return QDF_STATUS_SUCCESS;
19546}
19547
19548/**
19549 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19550 * @wmi_handle: wmi handle
19551 * @param evt_buf: pointer to event buffer
19552 * @param index: Index into bcn fault stats
19553 * @param bcnflt_stats: Pointer to hold bcn fault stats
19554 *
19555 * Return: QDF_STATUS_SUCCESS for success or error code
19556 */
19557static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19558 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19559{
19560 return QDF_STATUS_SUCCESS;
19561}
19562
19563/**
19564 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19565 * @wmi_handle: wmi handle
19566 * @param evt_buf: pointer to event buffer
19567 * @param index: Index into extended peer stats
19568 * @param peer_extd_stats: Pointer to hold extended peer stats
19569 *
19570 * Return: QDF_STATUS_SUCCESS for success or error code
19571 */
19572static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19573 void *evt_buf, uint32_t index,
19574 wmi_host_peer_extd_stats *peer_extd_stats)
19575{
19576 return QDF_STATUS_SUCCESS;
19577}
19578
19579/**
19580 * extract_chan_stats_tlv() - extract chan stats from event
19581 * @wmi_handle: wmi handle
19582 * @param evt_buf: pointer to event buffer
19583 * @param index: Index into chan stats
19584 * @param vdev_extd_stats: Pointer to hold chan stats
19585 *
19586 * Return: QDF_STATUS_SUCCESS for success or error code
19587 */
19588static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19589 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19590{
19591 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19592 wmi_stats_event_fixed_param *ev_param;
19593 uint8_t *data;
19594
19595 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19596 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19597 data = (uint8_t *) param_buf->data;
19598
19599 if (index < ev_param->num_chan_stats) {
19600 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19601 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19602 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19603 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19604 (index * sizeof(wmi_chan_stats)));
19605
19606
19607 /* Non-TLV doesnt have num_chan_stats */
19608 chan_stats->chan_mhz = ev->chan_mhz;
19609 chan_stats->sampling_period_us = ev->sampling_period_us;
19610 chan_stats->rx_clear_count = ev->rx_clear_count;
19611 chan_stats->tx_duration_us = ev->tx_duration_us;
19612 chan_stats->rx_duration_us = ev->rx_duration_us;
19613 }
19614
19615 return QDF_STATUS_SUCCESS;
19616}
19617
19618/**
19619 * extract_profile_ctx_tlv() - extract profile context from event
19620 * @wmi_handle: wmi handle
19621 * @param evt_buf: pointer to event buffer
19622 * @idx: profile stats index to extract
19623 * @param profile_ctx: Pointer to hold profile context
19624 *
19625 * Return: QDF_STATUS_SUCCESS for success or error code
19626 */
19627static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19628 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19629{
19630 return QDF_STATUS_SUCCESS;
19631}
19632
19633/**
19634 * extract_profile_data_tlv() - extract profile data from event
19635 * @wmi_handle: wmi handle
19636 * @param evt_buf: pointer to event buffer
19637 * @param profile_data: Pointer to hold profile data
19638 *
19639 * Return: QDF_STATUS_SUCCESS for success or error code
19640 */
19641static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19642 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19643{
19644
19645 return QDF_STATUS_SUCCESS;
19646}
19647
19648/**
19649 * extract_chan_info_event_tlv() - extract chan information from event
19650 * @wmi_handle: wmi handle
19651 * @param evt_buf: pointer to event buffer
19652 * @param chan_info: Pointer to hold chan information
19653 *
19654 * Return: QDF_STATUS_SUCCESS for success or error code
19655 */
19656static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19657 void *evt_buf, wmi_host_chan_info_event *chan_info)
19658{
19659 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19660 wmi_chan_info_event_fixed_param *ev;
19661
19662 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19663
19664 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19665 if (!ev) {
19666 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19667 return QDF_STATUS_E_FAILURE;
19668 }
19669
19670 chan_info->err_code = ev->err_code;
19671 chan_info->freq = ev->freq;
19672 chan_info->cmd_flags = ev->cmd_flags;
19673 chan_info->noise_floor = ev->noise_floor;
19674 chan_info->rx_clear_count = ev->rx_clear_count;
19675 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019676 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19677 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019678 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19679 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19680 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019681 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19682 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19683 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19684 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19685 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19686 chan_info->rx_frame_count = ev->rx_frame_count;
19687 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19688 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019689
19690 return QDF_STATUS_SUCCESS;
19691}
19692
19693/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019694 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19695 * @wmi_handle: WMI handle
19696 * @param evt_buf: Pointer to event buffer
19697 * @param param: Pointer to hold data
19698 *
19699 * Return : QDF_STATUS_SUCCESS for success or error code
19700 */
19701static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19702 uint8_t *evt_buf,
19703 struct wmi_host_pdev_utf_event *event)
19704{
19705 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019706 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019707
19708 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19709 event->data = param_buf->data;
19710 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019711 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019712 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019713 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019714 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019715
19716 return QDF_STATUS_SUCCESS;
19717}
Govind Singhe7f2f342016-05-23 12:12:52 +053019718
Kiran Venkatappa06520822016-08-10 23:55:40 +053019719/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019720 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19721 * @wmi_handle: wmi handle
19722 * @param evt_buf: pointer to event buffer
19723 * @param param: Pointer to hold evt buf
19724 *
19725 * Return: QDF_STATUS_SUCCESS for success or error code
19726 */
19727static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19728 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19729{
19730 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19731 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19732 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19733 uint8_t i = 0, j = 0;
19734
19735 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19736 if (!param_buf)
19737 return QDF_STATUS_E_INVAL;
19738
19739 hw_caps = param_buf->soc_hw_mode_caps;
19740 if (!hw_caps)
19741 return QDF_STATUS_E_INVAL;
19742
19743 if (!hw_caps->num_chainmask_tables)
19744 return QDF_STATUS_E_INVAL;
19745
19746 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19747
19748 if (chainmask_caps == NULL)
19749 return QDF_STATUS_E_INVAL;
19750
19751 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19752
19753 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19754 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19755
19756 chainmask_table[i].cap_list[j].chainmask =
19757 chainmask_caps->chainmask;
19758
19759 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19760 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19761
19762 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19763 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19764
19765 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19766 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19767
19768 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19769 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19770
19771 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19772 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19773
19774 chainmask_table[i].cap_list[j].chain_mask_2G =
19775 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19776
19777 chainmask_table[i].cap_list[j].chain_mask_5G =
19778 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19779
19780 chainmask_table[i].cap_list[j].chain_mask_tx =
19781 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19782
19783 chainmask_table[i].cap_list[j].chain_mask_rx =
19784 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19785
19786 chainmask_table[i].cap_list[j].supports_aDFS =
19787 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19788
19789 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19790 chainmask_caps->supported_flags,
19791 chainmask_caps->chainmask
19792 );
19793 chainmask_caps++;
19794 }
19795 }
19796
19797 return QDF_STATUS_SUCCESS;
19798}
19799
19800/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019801 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19802 * from event
19803 * @wmi_handle: wmi handle
19804 * @param evt_buf: pointer to event buffer
19805 * @param param: Pointer to hold evt buf
19806 *
19807 * Return: QDF_STATUS_SUCCESS for success or error code
19808 */
19809static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019810 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019811{
19812 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19813 wmi_service_ready_ext_event_fixed_param *ev;
19814 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19815 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019816 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19817 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019818
19819 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19820 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019821 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019822
19823 ev = param_buf->fixed_param;
19824 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019825 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019826
19827 /* Move this to host based bitmap */
19828 param->default_conc_scan_config_bits =
19829 ev->default_conc_scan_config_bits;
19830 param->default_fw_config_bits = ev->default_fw_config_bits;
19831 param->he_cap_info = ev->he_cap_info;
19832 param->mpdu_density = ev->mpdu_density;
19833 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019834 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019835 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019836 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19837
19838 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019839 if (hw_caps)
19840 param->num_hw_modes = hw_caps->num_hw_modes;
19841 else
19842 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019843
19844 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019845 if (reg_caps)
19846 param->num_phy = reg_caps->num_phy;
19847 else
19848 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019849
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019850 if (hw_caps) {
19851 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
19852 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
19853 } else
19854 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019855
19856 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19857
19858 if (chain_mask_combo == NULL)
19859 return QDF_STATUS_SUCCESS;
19860
19861 qdf_print("Dumping chain mask combo data\n");
19862
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019863 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019864
19865 qdf_print("table_id : %d Num valid chainmasks: %d\n",
19866 chain_mask_combo->chainmask_table_id,
19867 chain_mask_combo->num_valid_chainmask
19868 );
19869
19870 param->chainmask_table[i].table_id =
19871 chain_mask_combo->chainmask_table_id;
19872 param->chainmask_table[i].num_valid_chainmasks =
19873 chain_mask_combo->num_valid_chainmask;
19874 chain_mask_combo++;
19875 }
19876 qdf_print("chain mask combo end\n");
19877
Kiran Venkatappa06520822016-08-10 23:55:40 +053019878 return QDF_STATUS_SUCCESS;
19879}
19880
19881/**
19882 * extract_hw_mode_cap_service_ready_ext_tlv() -
19883 * extract HW mode cap from service ready event
19884 * @wmi_handle: wmi handle
19885 * @param evt_buf: pointer to event buffer
19886 * @param param: Pointer to hold evt buf
19887 * @param hw_mode_idx: hw mode idx should be less than num_mode
19888 *
19889 * Return: QDF_STATUS_SUCCESS for success or error code
19890 */
19891static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19892 wmi_unified_t wmi_handle,
19893 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019894 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019895{
19896 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19897 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19898
19899 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19900 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019901 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019902
19903 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019904 if (!hw_caps)
19905 return QDF_STATUS_E_INVAL;
19906
Kiran Venkatappa06520822016-08-10 23:55:40 +053019907 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019908 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019909
19910 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19911 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19912
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019913 param->hw_mode_config_type =
19914 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19915
Kiran Venkatappa06520822016-08-10 23:55:40 +053019916 return QDF_STATUS_SUCCESS;
19917}
19918
19919/**
19920 * extract_mac_phy_cap_service_ready_ext_tlv() -
19921 * extract MAC phy cap from service ready event
19922 * @wmi_handle: wmi handle
19923 * @param evt_buf: pointer to event buffer
19924 * @param param: Pointer to hold evt buf
19925 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019926 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019927 *
19928 * Return: QDF_STATUS_SUCCESS for success or error code
19929 */
19930static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19931 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019932 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019933 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019934{
19935 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019936 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019937 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19938 uint32_t phy_map;
19939 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019940
19941 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19942 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019943 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019944
19945 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019946 if (!hw_caps)
19947 return QDF_STATUS_E_INVAL;
19948
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019949 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19950 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19951 break;
19952
19953 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19954 while (phy_map) {
19955 phy_map >>= 1;
19956 phy_idx++;
19957 }
19958 }
19959
19960 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019961 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019962
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019963 phy_idx += phy_id;
19964 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019965 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019966
19967 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019968
19969 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019970 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19971 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019972 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019973 param->supports_11b =
19974 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19975 param->supports_11g =
19976 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19977 param->supports_11a =
19978 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19979 param->supports_11n =
19980 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19981 param->supports_11ac =
19982 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19983 param->supports_11ax =
19984 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019985
19986 param->supported_bands = mac_phy_caps->supported_bands;
19987 param->ampdu_density = mac_phy_caps->ampdu_density;
19988 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19989 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19990 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19991 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19992 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19993 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19994 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19995 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19996 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19997 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19998 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19999 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
20000 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
20001 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
20002 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
20003 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080020004 qdf_mem_copy(&param->he_cap_phy_info_2G,
20005 &mac_phy_caps->he_cap_phy_info_2G,
20006 sizeof(param->he_cap_phy_info_2G));
20007 qdf_mem_copy(&param->he_cap_phy_info_5G,
20008 &mac_phy_caps->he_cap_phy_info_5G,
20009 sizeof(param->he_cap_phy_info_5G));
20010 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
20011 sizeof(param->he_ppet2G));
20012 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
20013 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053020014 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020015
20016 return QDF_STATUS_SUCCESS;
20017}
20018
20019/**
20020 * extract_reg_cap_service_ready_ext_tlv() -
20021 * extract REG cap from service ready event
20022 * @wmi_handle: wmi handle
20023 * @param evt_buf: pointer to event buffer
20024 * @param param: Pointer to hold evt buf
20025 * @param phy_idx: phy idx should be less than num_mode
20026 *
20027 * Return: QDF_STATUS_SUCCESS for success or error code
20028 */
20029static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
20030 wmi_unified_t wmi_handle,
20031 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080020032 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053020033{
20034 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20035 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
20036 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
20037
20038 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
20039 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020040 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020041
20042 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020043 if (!reg_caps)
20044 return QDF_STATUS_E_INVAL;
20045
Kiran Venkatappa06520822016-08-10 23:55:40 +053020046 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020047 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020048
20049 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
20050
20051 param->phy_id = ext_reg_cap->phy_id;
20052 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
20053 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
20054 param->regcap1 = ext_reg_cap->regcap1;
20055 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053020056 param->wireless_modes = convert_wireless_modes_tlv(
20057 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053020058 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
20059 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
20060 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
20061 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
20062
20063 return QDF_STATUS_SUCCESS;
20064}
20065
Sathish Kumarf396c722017-11-17 17:30:41 +053020066static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
20067 wmi_unified_t wmi_handle,
20068 uint8_t *event, uint8_t idx,
20069 struct wlan_psoc_host_dbr_ring_caps *param)
20070{
20071 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20072 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
20073
20074 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
20075 if (!param_buf)
20076 return QDF_STATUS_E_INVAL;
20077
20078 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
20079
20080 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20081 dbr_ring_caps->pdev_id);
20082 param->mod_id = dbr_ring_caps->mod_id;
20083 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
20084 param->min_buf_size = dbr_ring_caps->min_buf_size;
20085 param->min_buf_align = dbr_ring_caps->min_buf_align;
20086
20087 return QDF_STATUS_SUCCESS;
20088}
20089
20090static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
20091 uint8_t *event, struct direct_buf_rx_rsp *param)
20092{
20093 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20094 wmi_dma_buf_release_fixed_param *ev;
20095
20096 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20097 if (!param_buf)
20098 return QDF_STATUS_E_INVAL;
20099
20100 ev = param_buf->fixed_param;
20101 if (!ev)
20102 return QDF_STATUS_E_INVAL;
20103
20104 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20105 ev->pdev_id);
20106 param->mod_id = ev->mod_id;
20107 param->num_buf_release_entry = ev->num_buf_release_entry;
20108 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
20109 param->pdev_id, param->mod_id, param->num_buf_release_entry);
20110
20111 return QDF_STATUS_SUCCESS;
20112}
20113
20114static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
20115 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
20116{
20117 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20118 wmi_dma_buf_release_entry *entry;
20119
20120 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20121 if (!param_buf)
20122 return QDF_STATUS_E_INVAL;
20123
20124 entry = &param_buf->entries[idx];
20125
20126 if (!entry) {
20127 WMI_LOGE("%s: Entry is NULL\n", __func__);
20128 return QDF_STATUS_E_FAILURE;
20129 }
20130
20131 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
20132
20133 param->paddr_lo = entry->paddr_lo;
20134 param->paddr_hi = entry->paddr_hi;
20135
20136 return QDF_STATUS_SUCCESS;
20137}
20138
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020139/**
20140 * extract_dcs_interference_type_tlv() - extract dcs interference type
20141 * from event
20142 * @wmi_handle: wmi handle
20143 * @param evt_buf: pointer to event buffer
20144 * @param param: Pointer to hold dcs interference param
20145 *
20146 * Return: 0 for success or error code
20147 */
20148static QDF_STATUS extract_dcs_interference_type_tlv(
20149 wmi_unified_t wmi_handle,
20150 void *evt_buf, struct wmi_host_dcs_interference_param *param)
20151{
20152 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20153
20154 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20155 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020156 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020157
20158 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020159 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20160 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020161
20162 return QDF_STATUS_SUCCESS;
20163}
20164
20165/*
20166 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
20167 * @wmi_handle: wmi handle
20168 * @param evt_buf: pointer to event buffer
20169 * @param cw_int: Pointer to hold cw interference
20170 *
20171 * Return: 0 for success or error code
20172 */
20173static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
20174 void *evt_buf,
20175 wmi_host_ath_dcs_cw_int *cw_int)
20176{
20177 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20178 wlan_dcs_cw_int *ev;
20179
20180 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20181 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020182 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020183
20184 ev = param_buf->cw_int;
20185
20186 cw_int->channel = ev->channel;
20187
20188 return QDF_STATUS_SUCCESS;
20189}
20190
20191/**
20192 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
20193 * @wmi_handle: wmi handle
20194 * @param evt_buf: pointer to event buffer
20195 * @param wlan_stat: Pointer to hold wlan stats
20196 *
20197 * Return: 0 for success or error code
20198 */
20199static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
20200 void *evt_buf,
20201 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
20202{
20203 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20204 wlan_dcs_im_tgt_stats_t *ev;
20205
20206 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20207 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020208 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020209
20210 ev = param_buf->wlan_stat;
20211 wlan_stat->reg_tsf32 = ev->reg_tsf32;
20212 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
20213 wlan_stat->tx_waste_time = ev->tx_waste_time;
20214 wlan_stat->rx_time = ev->rx_time;
20215 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
20216 wlan_stat->mib_stats.listen_time = ev->listen_time;
20217 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
20218 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
20219 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
20220 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
20221 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
20222 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
20223 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
20224 wlan_stat->chan_nf = ev->chan_nf;
20225 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
20226
20227 return QDF_STATUS_SUCCESS;
20228}
20229
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020230/**
20231 * extract_thermal_stats_tlv() - extract thermal stats from event
20232 * @wmi_handle: wmi handle
20233 * @param evt_buf: Pointer to event buffer
20234 * @param temp: Pointer to hold extracted temperature
20235 * @param level: Pointer to hold extracted level
20236 *
20237 * Return: 0 for success or error code
20238 */
20239static QDF_STATUS
20240extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
20241 void *evt_buf, uint32_t *temp,
20242 uint32_t *level, uint32_t *pdev_id)
20243{
20244 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20245 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
20246
20247 param_buf =
20248 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20249 if (!param_buf)
20250 return QDF_STATUS_E_INVAL;
20251
20252 tt_stats_event = param_buf->fixed_param;
20253
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020254 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20255 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020256 *temp = tt_stats_event->temp;
20257 *level = tt_stats_event->level;
20258
20259 return QDF_STATUS_SUCCESS;
20260}
20261
20262/**
20263 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
20264 * @wmi_handle: wmi handle
20265 * @param evt_buf: pointer to event buffer
20266 * @param idx: Index to level stats
20267 * @param levelcount: Pointer to hold levelcount
20268 * @param dccount: Pointer to hold dccount
20269 *
20270 * Return: 0 for success or error code
20271 */
20272static QDF_STATUS
20273extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
20274 void *evt_buf, uint8_t idx, uint32_t *levelcount,
20275 uint32_t *dccount)
20276{
20277 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20278 wmi_therm_throt_level_stats_info *tt_level_info;
20279
20280 param_buf =
20281 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20282 if (!param_buf)
20283 return QDF_STATUS_E_INVAL;
20284
20285 tt_level_info = param_buf->therm_throt_level_stats_info;
20286
20287 if (idx < THERMAL_LEVELS) {
20288 *levelcount = tt_level_info[idx].level_count;
20289 *dccount = tt_level_info[idx].dc_count;
20290 return QDF_STATUS_SUCCESS;
20291 }
20292
20293 return QDF_STATUS_E_FAILURE;
20294}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020295#ifdef BIG_ENDIAN_HOST
20296/**
20297 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
20298 * @param data_len - data length
20299 * @param data - pointer to data
20300 *
20301 * Return: QDF_STATUS - success or error status
20302 */
20303static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20304{
20305 uint8_t *data_aligned = NULL;
20306 int c;
20307 unsigned char *data_unaligned;
20308
20309 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
20310 FIPS_ALIGN));
20311 /* Assigning unaligned space to copy the data */
20312 /* Checking if kmalloc does succesful allocation */
20313 if (data_unaligned == NULL)
20314 return QDF_STATUS_E_FAILURE;
20315
20316 /* Checking if space is alligned */
20317 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
20318 /* align the data space */
20319 data_aligned =
20320 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
20321 } else {
20322 data_aligned = (u_int8_t *)data_unaligned;
20323 }
20324
20325 /* memset and copy content from data to data aligned */
20326 OS_MEMSET(data_aligned, 0, data_len);
20327 OS_MEMCPY(data_aligned, data, data_len);
20328 /* Endianness to LE */
20329 for (c = 0; c < data_len/4; c++) {
20330 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020331 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020332 }
20333
20334 /* Copy content to event->data */
20335 OS_MEMCPY(data, data_aligned, data_len);
20336
20337 /* clean up allocated space */
20338 qdf_mem_free(data_unaligned);
20339 data_aligned = NULL;
20340 data_unaligned = NULL;
20341
20342 /*************************************************************/
20343
20344 return QDF_STATUS_SUCCESS;
20345}
20346#else
20347/**
20348 * fips_conv_data_be() - DUMMY for LE platform
20349 *
20350 * Return: QDF_STATUS - success
20351 */
20352static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20353{
20354 return QDF_STATUS_SUCCESS;
20355}
20356#endif
20357
20358/**
20359 * extract_fips_event_data_tlv() - extract fips event data
20360 * @wmi_handle: wmi handle
20361 * @param evt_buf: pointer to event buffer
20362 * @param param: pointer FIPS event params
20363 *
20364 * Return: 0 for success or error code
20365 */
20366static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
20367 void *evt_buf, struct wmi_host_fips_event_param *param)
20368{
20369 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
20370 wmi_pdev_fips_event_fixed_param *event;
20371
20372 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
20373 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
20374
20375 if (fips_conv_data_be(event->data_len, param_buf->data) !=
20376 QDF_STATUS_SUCCESS)
20377 return QDF_STATUS_E_FAILURE;
20378
20379 param->data = (uint32_t *)param_buf->data;
20380 param->data_len = event->data_len;
20381 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020382 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20383 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020384
20385 return QDF_STATUS_SUCCESS;
20386}
20387
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020388/*
20389 * extract_peer_delete_response_event_tlv() - extract peer delete response event
20390 * @wmi_handle: wmi handle
20391 * @param evt_buf: pointer to event buffer
20392 * @param vdev_id: Pointer to hold vdev_id
20393 * @param mac_addr: Pointer to hold peer mac address
20394 *
20395 * Return: QDF_STATUS_SUCCESS for success or error code
20396 */
20397static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
20398 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
20399{
20400 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
20401 wmi_peer_delete_resp_event_fixed_param *ev;
20402
20403 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
20404
20405 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
20406 if (!ev) {
20407 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
20408 return QDF_STATUS_E_FAILURE;
20409 }
20410
20411 param->vdev_id = ev->vdev_id;
20412 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
20413 &param->mac_address.bytes[0]);
20414
20415 return QDF_STATUS_SUCCESS;
20416}
20417
Govind Singhecf03cd2016-05-12 12:45:51 +053020418static bool is_management_record_tlv(uint32_t cmd_id)
20419{
jiad36c94d22018-01-22 15:37:03 +080020420 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
20421 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
20422 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053020423 return true;
jiad36c94d22018-01-22 15:37:03 +080020424 }
Govind Singhe7f2f342016-05-23 12:12:52 +053020425
Govind Singhecf03cd2016-05-12 12:45:51 +053020426 return false;
20427}
20428
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053020429static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20430{
20431 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
20432
20433 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
20434
20435 switch (set_cmd->param_id) {
20436 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
20437 case WMI_VDEV_PARAM_DTIM_POLICY:
20438 return HTC_TX_PACKET_TAG_AUTO_PM;
20439 default:
20440 break;
20441 }
20442
20443 return 0;
20444}
20445
20446static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20447{
20448 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
20449
20450 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20451
20452 switch (ps_cmd->param) {
20453 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20454 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20455 case WMI_STA_PS_ENABLE_QPOWER:
20456 return HTC_TX_PACKET_TAG_AUTO_PM;
20457 default:
20458 break;
20459 }
20460
20461 return 0;
20462}
20463
20464static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20465 uint32_t cmd_id)
20466{
20467 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20468 return 0;
20469
20470 switch (cmd_id) {
20471 case WMI_VDEV_SET_PARAM_CMDID:
20472 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20473 case WMI_STA_POWERSAVE_PARAM_CMDID:
20474 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20475 default:
20476 break;
20477 }
20478
20479 return 0;
20480}
20481
20482static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20483{
20484 uint16_t tag = 0;
20485
20486 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20487 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20488 __func__);
20489 return tag;
20490 }
20491
20492 if (wmi_handle->tag_crash_inject)
20493 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20494
20495 wmi_handle->tag_crash_inject = false;
20496 return tag;
20497}
20498
20499/**
20500 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20501 * @wmi_handle: WMI handle
20502 * @buf: WMI buffer
20503 * @cmd_id: WMI command Id
20504 *
20505 * Return htc_tx_tag
20506 */
20507static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20508 wmi_buf_t buf,
20509 uint32_t cmd_id)
20510{
20511 uint16_t htc_tx_tag = 0;
20512
20513 switch (cmd_id) {
20514 case WMI_WOW_ENABLE_CMDID:
20515 case WMI_PDEV_SUSPEND_CMDID:
20516 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20517 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20518 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20519 case WMI_PDEV_RESUME_CMDID:
20520 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20521 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20522#ifdef FEATURE_WLAN_D0WOW
20523 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20524#endif
20525 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20526 break;
20527 case WMI_FORCE_FW_HANG_CMDID:
20528 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20529 break;
20530 case WMI_VDEV_SET_PARAM_CMDID:
20531 case WMI_STA_POWERSAVE_PARAM_CMDID:
20532 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20533 default:
20534 break;
20535 }
20536
20537 return htc_tx_tag;
20538}
20539
Sathish Kumard3ab1002017-02-07 17:10:59 +053020540/**
20541 * extract_channel_hopping_event_tlv() - extract channel hopping param
20542 * from event
20543 * @wmi_handle: wmi handle
20544 * @param evt_buf: pointer to event buffer
20545 * @param ch_hopping: Pointer to hold channel hopping param
20546 *
20547 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20548 */
20549static QDF_STATUS extract_channel_hopping_event_tlv(
20550 wmi_unified_t wmi_handle, void *evt_buf,
20551 wmi_host_pdev_channel_hopping_event *ch_hopping)
20552{
20553 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20554 wmi_pdev_channel_hopping_event_fixed_param *event;
20555
20556 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20557 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20558 param_buf->fixed_param;
20559
20560 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20561 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020562 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20563 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020564
20565 return QDF_STATUS_SUCCESS;
20566}
20567
20568/**
20569 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20570 * @wmi_handle: wmi handle
20571 * @param evt_buf: pointer to event buffer
20572 * @param param: Pointer to hold tpc param
20573 *
20574 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20575 */
20576static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20577 void *evt_buf,
20578 wmi_host_pdev_tpc_event *param)
20579{
20580 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20581 wmi_pdev_tpc_event_fixed_param *event;
20582
20583 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20584 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20585
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020586 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20587 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020588 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20589
20590 return QDF_STATUS_SUCCESS;
20591}
20592
nobeljf74583b2018-01-25 16:35:36 -080020593/**
20594 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20595 * power param from event
20596 * @wmi_handle: wmi handle
20597 * @param evt_buf: pointer to event buffer
20598 * @param param: Pointer to hold nf cal power param
20599 *
20600 * Return: 0 for success or error code
20601 */
20602static QDF_STATUS
20603extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20604 void *evt_buf,
20605 wmi_host_pdev_nfcal_power_all_channels_event *param)
20606{
20607 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20608 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20609 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20610 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20611 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20612 uint32_t i;
20613
20614 param_buf =
20615 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20616 event = param_buf->fixed_param;
20617 ch_nfdbr = param_buf->nfdbr;
20618 ch_nfdbm = param_buf->nfdbm;
20619 ch_freqnum = param_buf->freqnum;
20620
20621 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20622 event->pdev_id, param_buf->num_nfdbr,
20623 param_buf->num_nfdbm, param_buf->num_freqnum);
20624
20625 if (param_buf->num_nfdbr >
20626 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20627 WMI_LOGE("invalid number of nfdBr");
20628 return QDF_STATUS_E_FAILURE;
20629 }
20630
20631 if (param_buf->num_nfdbm >
20632 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20633 WMI_LOGE("invalid number of nfdBm");
20634 return QDF_STATUS_E_FAILURE;
20635 }
20636
20637 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20638 WMI_LOGE("invalid number of freqNum");
20639 return QDF_STATUS_E_FAILURE;
20640 }
20641
20642 for (i = 0; i < param_buf->num_nfdbr; i++) {
20643 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20644 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20645 ch_nfdbr++;
20646 ch_nfdbm++;
20647 }
20648
20649 for (i = 0; i < param_buf->num_freqnum; i++) {
20650 param->freqnum[i] = ch_freqnum->freqNum;
20651 ch_freqnum++;
20652 }
20653
20654 param->pdev_id = event->pdev_id;
20655
20656 return QDF_STATUS_SUCCESS;
20657}
20658
Sathish Kumard3ab1002017-02-07 17:10:59 +053020659
20660#ifdef BIG_ENDIAN_HOST
20661/**
20662 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20663 * @param data_len - data length
20664 * @param data - pointer to data
20665 *
20666 * Return: QDF_STATUS - success or error status
20667 */
20668static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20669{
20670 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020671 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020672 /* Skip swapping the first word */
20673 datap += sizeof(uint32_t);
20674 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20675 i++, datap += sizeof(uint32_t)) {
20676 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20677 }
20678
20679 return QDF_STATUS_SUCCESS;
20680}
20681#else
20682/**
20683 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20684 * @param data_len - data length
20685 * @param data - pointer to data
20686 *
20687 * Return: QDF_STATUS - success or error status
20688 */
20689static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20690{
20691 return QDF_STATUS_SUCCESS;
20692}
20693#endif
20694
20695/**
20696 * extract_wds_addr_event_tlv() - extract wds address from event
20697 * @wmi_handle: wmi handle
20698 * @param evt_buf: pointer to event buffer
20699 * @param wds_ev: Pointer to hold wds address
20700 *
20701 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20702 */
20703static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20704 void *evt_buf,
20705 uint16_t len, wds_addr_event_t *wds_ev)
20706{
20707 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20708 wmi_wds_addr_event_fixed_param *ev;
20709 int i;
20710
20711 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20712 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20713
20714 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20715 return QDF_STATUS_E_FAILURE;
20716
20717 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20718 sizeof(wds_ev->event_type));
20719 for (i = 0; i < 4; i++) {
20720 wds_ev->peer_mac[i] =
20721 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20722 wds_ev->dest_mac[i] =
20723 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20724 }
20725 for (i = 0; i < 2; i++) {
20726 wds_ev->peer_mac[4+i] =
20727 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20728 wds_ev->dest_mac[4+i] =
20729 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20730 }
20731 return QDF_STATUS_SUCCESS;
20732}
20733
20734/**
20735 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20736 * from event
20737 * @wmi_handle: wmi handle
20738 * @param evt_buf: pointer to event buffer
20739 * @param ev: Pointer to hold peer param and ps state
20740 *
20741 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20742 */
20743static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20744 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20745{
20746 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20747 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20748
20749 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20750 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20751 param_buf->fixed_param;
20752
20753 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20754 ev->peer_ps_state = event->peer_ps_state;
20755
20756 return QDF_STATUS_SUCCESS;
20757}
20758
20759/**
20760 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20761 * @wmi_handle: wmi handle
20762 * @param evt_buf: pointer to event buffer
20763 * @param inst_rssi_resp: Pointer to hold inst rssi response
20764 *
20765 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20766 */
20767static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20768 wmi_unified_t wmi_handle, void *evt_buf,
20769 wmi_host_inst_stats_resp *inst_rssi_resp)
20770{
20771 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20772 wmi_inst_rssi_stats_resp_fixed_param *event;
20773
20774 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20775 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20776
20777 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20778 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20779 inst_rssi_resp->iRSSI = event->iRSSI;
20780
20781 return QDF_STATUS_SUCCESS;
20782}
20783
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020784static struct cur_reg_rule
20785*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20786 wmi_regulatory_rule_struct *wmi_reg_rule)
20787{
20788 struct cur_reg_rule *reg_rule_ptr;
20789 uint32_t count;
20790
20791 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20792
20793 if (NULL == reg_rule_ptr) {
20794 WMI_LOGE("memory allocation failure");
20795 return NULL;
20796 }
20797
20798 for (count = 0; count < num_reg_rules; count++) {
20799 reg_rule_ptr[count].start_freq =
20800 WMI_REG_RULE_START_FREQ_GET(
20801 wmi_reg_rule[count].freq_info);
20802 reg_rule_ptr[count].end_freq =
20803 WMI_REG_RULE_END_FREQ_GET(
20804 wmi_reg_rule[count].freq_info);
20805 reg_rule_ptr[count].max_bw =
20806 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020807 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020808 reg_rule_ptr[count].reg_power =
20809 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020810 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020811 reg_rule_ptr[count].ant_gain =
20812 WMI_REG_RULE_ANTENNA_GAIN_GET(
20813 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020814 reg_rule_ptr[count].flags =
20815 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020816 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020817 }
20818
20819 return reg_rule_ptr;
20820}
20821
20822static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20823 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20824 struct cur_regulatory_info *reg_info, uint32_t len)
20825{
20826 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20827 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20828 wmi_regulatory_rule_struct *wmi_reg_rule;
20829 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20830
20831 WMI_LOGD("processing regulatory channel list");
20832
20833 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20834 if (!param_buf) {
20835 WMI_LOGE("invalid channel list event buf");
20836 return QDF_STATUS_E_FAILURE;
20837 }
20838
20839 chan_list_event_hdr = param_buf->fixed_param;
20840
20841 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20842 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20843 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020844 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020845 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20846 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020847 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020848 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020849 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020850 reg_info->ctry_code = chan_list_event_hdr->country_id;
20851 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20852 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20853 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20854 else if (chan_list_event_hdr->status_code ==
20855 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20856 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20857 else if (chan_list_event_hdr->status_code ==
20858 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20859 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20860 else if (chan_list_event_hdr->status_code ==
20861 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20862 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20863 else if (chan_list_event_hdr->status_code ==
20864 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20865 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20866 else if (chan_list_event_hdr->status_code ==
20867 WMI_REG_SET_CC_STATUS_FAIL)
20868 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20869
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020870 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20871 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20872 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20873 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20874
20875 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20876 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20877
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020878 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20879 __func__, reg_info->alpha2, reg_info->dfs_region,
20880 reg_info->min_bw_2g, reg_info->max_bw_2g,
20881 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020882
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020883 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20884 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020885 wmi_reg_rule =
20886 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20887 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20888 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020889 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20890 wmi_reg_rule);
20891 wmi_reg_rule += num_2g_reg_rules;
20892
20893 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20894 wmi_reg_rule);
20895
20896 WMI_LOGD("processed regulatory channel list");
20897
20898 return QDF_STATUS_SUCCESS;
20899}
20900
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020901static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20902 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20903 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20904{
20905 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20906 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20907
20908 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20909 if (!param_buf) {
20910 WMI_LOGE("invalid 11d country event buf");
20911 return QDF_STATUS_E_FAILURE;
20912 }
20913
20914 reg_11d_country_event = param_buf->fixed_param;
20915
20916 qdf_mem_copy(reg_11d_country->alpha2,
20917 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20918
20919 WMI_LOGD("processed 11d country event, new cc %s",
20920 reg_11d_country->alpha2);
20921
20922 return QDF_STATUS_SUCCESS;
20923}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020924
20925static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20926 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20927 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20928{
20929 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20930 wmi_avoid_freq_range_desc *afr_desc;
20931 uint32_t num_freq_ranges, freq_range_idx;
20932 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20933 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20934
20935 if (!param_buf) {
20936 WMI_LOGE("Invalid channel avoid event buffer");
20937 return QDF_STATUS_E_INVAL;
20938 }
20939
20940 afr_fixed_param = param_buf->fixed_param;
20941 if (!afr_fixed_param) {
20942 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20943 return QDF_STATUS_E_INVAL;
20944 }
20945
20946 if (!ch_avoid_ind) {
20947 WMI_LOGE("Invalid channel avoid indication buffer");
20948 return QDF_STATUS_E_INVAL;
20949 }
20950 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20951 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20952 afr_fixed_param->num_freq_ranges;
20953
20954 WMI_LOGD("Channel avoid event received with %d ranges",
20955 num_freq_ranges);
20956
20957 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20958 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20959 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20960 freq_range_idx++) {
20961 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20962 afr_desc->start_freq;
20963 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20964 afr_desc->end_freq;
20965 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20966 freq_range_idx, afr_desc->tlv_header,
20967 afr_desc->start_freq, afr_desc->end_freq);
20968 afr_desc++;
20969 }
20970
20971 return QDF_STATUS_SUCCESS;
20972}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020973#ifdef DFS_COMPONENT_ENABLE
20974/**
20975 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20976 * @wmi_handle: wma handle
20977 * @evt_buf: event buffer
20978 * @vdev_id: vdev id
20979 * @len: length of buffer
20980 *
20981 * Return: 0 for success or error code
20982 */
20983static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20984 uint8_t *evt_buf,
20985 uint32_t *vdev_id,
20986 uint32_t len)
20987{
20988 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20989 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20990
20991 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20992 if (!param_tlvs) {
20993 WMI_LOGE("invalid cac complete event buf");
20994 return QDF_STATUS_E_FAILURE;
20995 }
20996
20997 cac_event = param_tlvs->fixed_param;
20998 *vdev_id = cac_event->vdev_id;
20999 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
21000
21001 return QDF_STATUS_SUCCESS;
21002}
21003
21004/**
21005 * extract_dfs_radar_detection_event_tlv() - extract radar found event
21006 * @wmi_handle: wma handle
21007 * @evt_buf: event buffer
21008 * @radar_found: radar found event info
21009 * @len: length of buffer
21010 *
21011 * Return: 0 for success or error code
21012 */
21013static QDF_STATUS extract_dfs_radar_detection_event_tlv(
21014 wmi_unified_t wmi_handle,
21015 uint8_t *evt_buf,
21016 struct radar_found_info *radar_found,
21017 uint32_t len)
21018{
21019 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
21020 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
21021
21022 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
21023 if (!param_tlv) {
21024 WMI_LOGE("invalid radar detection event buf");
21025 return QDF_STATUS_E_FAILURE;
21026 }
21027
21028 radar_event = param_tlv->fixed_param;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021029 radar_found->pdev_id = wmi_handle->ops->
21030 convert_pdev_id_target_to_host(radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021031 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021032 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021033 radar_found->chan_width = radar_event->chan_width;
21034 radar_found->detector_id = radar_event->detector_id;
21035 radar_found->segment_id = radar_event->segment_id;
21036 radar_found->timestamp = radar_event->timestamp;
21037 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021038 radar_found->freq_offset = radar_event->freq_offset;
21039 radar_found->sidx = radar_event->sidx;
21040
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080021041 WMI_LOGI("processed radar found event pdev %d,"
21042 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
21043 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
21044 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
21045 "is_chirp %d,detection mode %d\n",
21046 radar_event->pdev_id, radar_event->pdev_id,
21047 radar_event->timestamp, radar_event->chan_freq,
21048 radar_event->chan_width, radar_event->detector_id,
21049 radar_event->freq_offset, radar_event->segment_id,
21050 radar_event->sidx, radar_event->is_chirp,
21051 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021052
21053 return QDF_STATUS_SUCCESS;
21054}
bings1ea12532017-12-18 16:56:53 +080021055
21056#ifdef QCA_MCL_DFS_SUPPORT
21057/**
21058 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
21059 * @wmi_handle: wma handle
21060 * @evt_buf: event buffer
21061 * @wlan_radar_event: Pointer to struct radar_event_info
21062 * @len: length of buffer
21063 *
21064 * Return: QDF_STATUS
21065 */
21066static QDF_STATUS extract_wlan_radar_event_info_tlv(
21067 wmi_unified_t wmi_handle,
21068 uint8_t *evt_buf,
21069 struct radar_event_info *wlan_radar_event,
21070 uint32_t len)
21071{
21072 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
21073 wmi_dfs_radar_event_fixed_param *radar_event;
21074
21075 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
21076 if (!param_tlv) {
21077 WMI_LOGE("invalid wlan radar event buf");
21078 return QDF_STATUS_E_FAILURE;
21079 }
21080
21081 radar_event = param_tlv->fixed_param;
21082 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
21083 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
21084 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
21085 wlan_radar_event->rssi = radar_event->rssi;
21086 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
21087 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
21088 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
21089 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080021090 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
21091 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings1ea12532017-12-18 16:56:53 +080021092 wlan_radar_event->pdev_id = radar_event->pdev_id;
21093
21094 return QDF_STATUS_SUCCESS;
21095}
21096#else
21097static QDF_STATUS extract_wlan_radar_event_info_tlv(
21098 wmi_unified_t wmi_handle,
21099 uint8_t *evt_buf,
21100 struct radar_event_info *wlan_radar_event,
21101 uint32_t len)
21102{
21103 return QDF_STATUS_SUCCESS;
21104}
21105#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021106#endif
21107
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021108/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021109 * send_get_rcpi_cmd_tlv() - send request for rcpi value
21110 * @wmi_handle: wmi handle
21111 * @get_rcpi_param: rcpi params
21112 *
21113 * Return: QDF status
21114 */
21115static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
21116 struct rcpi_req *get_rcpi_param)
21117{
21118 wmi_buf_t buf;
21119 wmi_request_rcpi_cmd_fixed_param *cmd;
21120 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
21121
21122 buf = wmi_buf_alloc(wmi_handle, len);
21123 if (!buf) {
21124 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21125 return QDF_STATUS_E_NOMEM;
21126 }
21127
21128 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
21129 WMITLV_SET_HDR(&cmd->tlv_header,
21130 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
21131 WMITLV_GET_STRUCT_TLVLEN
21132 (wmi_request_rcpi_cmd_fixed_param));
21133
21134 cmd->vdev_id = get_rcpi_param->vdev_id;
21135 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
21136 &cmd->peer_macaddr);
21137 cmd->measurement_type = get_rcpi_param->measurement_type;
21138 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
21139 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21140 WMI_REQUEST_RCPI_CMDID)) {
21141
21142 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
21143 __func__);
21144 wmi_buf_free(buf);
21145 return QDF_STATUS_E_FAILURE;
21146 }
21147
21148 return QDF_STATUS_SUCCESS;
21149}
21150
21151/**
21152 * extract_rcpi_response_event_tlv() - Extract RCPI event params
21153 * @wmi_handle: wmi handle
21154 * @evt_buf: pointer to event buffer
21155 * @res: pointer to hold rcpi response from firmware
21156 *
21157 * Return: QDF_STATUS_SUCCESS for successful event parse
21158 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
21159 */
21160static QDF_STATUS
21161extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
21162 void *evt_buf, struct rcpi_res *res)
21163{
21164 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
21165 wmi_update_rcpi_event_fixed_param *event;
21166
21167 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
21168 if (!param_buf) {
21169 WMI_LOGE(FL("Invalid rcpi event"));
21170 return QDF_STATUS_E_INVAL;
21171 }
21172
21173 event = param_buf->fixed_param;
21174 res->vdev_id = event->vdev_id;
21175 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
21176
21177 switch (event->measurement_type) {
21178
21179 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21180 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21181 break;
21182
21183 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
21184 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
21185 break;
21186
21187 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21188 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21189 break;
21190
21191 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
21192 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
21193 break;
21194
21195 default:
21196 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
21197 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
21198 return QDF_STATUS_E_FAILURE;
21199 }
21200
21201 if (event->status)
21202 return QDF_STATUS_E_FAILURE;
21203 else
21204 return QDF_STATUS_SUCCESS;
21205}
21206
21207/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053021208 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
21209 * host to target defines. For legacy there is not conversion
21210 * required. Just return pdev_id as it is.
21211 * @param pdev_id: host pdev_id to be converted.
21212 * Return: target pdev_id after conversion.
21213 */
21214static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
21215 uint32_t pdev_id)
21216{
21217 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
21218 return WMI_PDEV_ID_SOC;
21219
21220 /*No conversion required*/
21221 return pdev_id;
21222}
21223
21224/**
21225 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
21226 * target to host defines. For legacy there is not conversion
21227 * required. Just return pdev_id as it is.
21228 * @param pdev_id: target pdev_id to be converted.
21229 * Return: host pdev_id after conversion.
21230 */
21231static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
21232 uint32_t pdev_id)
21233{
21234 /*No conversion required*/
21235 return pdev_id;
21236}
21237
21238/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021239 * send_set_country_cmd_tlv() - WMI scan channel list function
21240 * @param wmi_handle : handle to WMI.
21241 * @param param : pointer to hold scan channel list parameter
21242 *
21243 * Return: 0 on success and -ve on failure.
21244 */
21245static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
21246 struct set_country *params)
21247{
21248 wmi_buf_t buf;
21249 QDF_STATUS qdf_status;
21250 wmi_set_current_country_cmd_fixed_param *cmd;
21251 uint16_t len = sizeof(*cmd);
21252
21253 buf = wmi_buf_alloc(wmi_handle, len);
21254 if (!buf) {
21255 WMI_LOGE("Failed to allocate memory");
21256 qdf_status = QDF_STATUS_E_NOMEM;
21257 goto end;
21258 }
21259
21260 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
21261 WMITLV_SET_HDR(&cmd->tlv_header,
21262 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
21263 WMITLV_GET_STRUCT_TLVLEN
21264 (wmi_set_current_country_cmd_fixed_param));
21265
21266 WMI_LOGD("setting cuurnet country to %s", params->country);
21267
21268 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
21269
21270 cmd->pdev_id = params->pdev_id;
21271
21272 qdf_status = wmi_unified_cmd_send(wmi_handle,
21273 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
21274
21275 if (QDF_IS_STATUS_ERROR(qdf_status)) {
21276 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
21277 wmi_buf_free(buf);
21278 }
21279
21280end:
21281 return qdf_status;
21282}
21283
Abhijit Pradhand38a2692017-06-29 12:32:20 +053021284#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
21285 WMI_SET_BITS(alpha, 0, 8, val0); \
21286 WMI_SET_BITS(alpha, 8, 8, val1); \
21287 WMI_SET_BITS(alpha, 16, 8, val2); \
21288 } while (0)
21289
21290static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
21291 uint8_t pdev_id, struct cc_regdmn_s *rd)
21292{
21293 wmi_set_init_country_cmd_fixed_param *cmd;
21294 uint16_t len;
21295 wmi_buf_t buf;
21296 int ret;
21297
21298 len = sizeof(wmi_set_init_country_cmd_fixed_param);
21299 buf = wmi_buf_alloc(wmi_handle, len);
21300 if (!buf) {
21301 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
21302 return QDF_STATUS_E_NOMEM;
21303 }
21304 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
21305 WMITLV_SET_HDR(&cmd->tlv_header,
21306 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
21307 WMITLV_GET_STRUCT_TLVLEN
21308 (wmi_set_init_country_cmd_fixed_param));
21309
21310 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
21311
21312 if (rd->flags == CC_IS_SET) {
21313 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
21314 cmd->country_code.country_id = rd->cc.country_code;
21315 } else if (rd->flags == ALPHA_IS_SET) {
21316 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
21317 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
21318 rd->cc.alpha[0],
21319 rd->cc.alpha[1],
21320 rd->cc.alpha[2]);
21321 } else if (rd->flags == REGDMN_IS_SET) {
21322 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
21323 cmd->country_code.domain_code = rd->cc.regdmn_id;
21324 }
21325
21326 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
21327 WMI_SET_INIT_COUNTRY_CMDID);
21328 if (ret) {
21329 WMI_LOGE("Failed to config wow wakeup event");
21330 wmi_buf_free(buf);
21331 return QDF_STATUS_E_FAILURE;
21332 }
21333
21334 return QDF_STATUS_SUCCESS;
21335}
21336
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053021337/**
21338 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
21339 * configuration params
21340 * @wmi_handle: wmi handler
21341 * @limit_off_chan_param: pointer to wmi_off_chan_param
21342 *
21343 * Return: 0 for success and non zero for failure
21344 */
21345static
21346QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
21347 struct wmi_limit_off_chan_param *limit_off_chan_param)
21348{
21349 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
21350 wmi_buf_t buf;
21351 uint32_t len = sizeof(*cmd);
21352 int err;
21353
21354 buf = wmi_buf_alloc(wmi_handle, len);
21355 if (!buf) {
21356 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
21357 __func__);
21358 return QDF_STATUS_E_NOMEM;
21359 }
21360
21361 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
21362
21363 WMITLV_SET_HDR(&cmd->tlv_header,
21364 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
21365 WMITLV_GET_STRUCT_TLVLEN(
21366 wmi_vdev_limit_offchan_cmd_fixed_param));
21367
21368 cmd->vdev_id = limit_off_chan_param->vdev_id;
21369
21370 cmd->flags &= 0;
21371 if (limit_off_chan_param->status)
21372 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
21373 if (limit_off_chan_param->skip_dfs_chans)
21374 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
21375
21376 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
21377 cmd->rest_time = limit_off_chan_param->rest_time;
21378
21379 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
21380 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
21381 cmd->rest_time);
21382
21383 err = wmi_unified_cmd_send(wmi_handle, buf,
21384 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
21385 if (QDF_IS_STATUS_ERROR(err)) {
21386 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
21387 wmi_buf_free(buf);
21388 return QDF_STATUS_E_FAILURE;
21389 }
21390
21391 return QDF_STATUS_SUCCESS;
21392}
21393
Anurag Chouhan97f00422017-09-11 14:56:30 +053021394/**
21395 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
21396 * @wmi_handle: wmi handler
21397 * @req_buf: set arp stats request buffer
21398 *
21399 * Return: 0 for success and non zero for failure
21400 */
21401static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21402 struct set_arp_stats *req_buf)
21403{
21404 wmi_buf_t buf = NULL;
21405 QDF_STATUS status;
21406 int len;
21407 uint8_t *buf_ptr;
21408 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
21409
21410 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021411 if (req_buf->pkt_type_bitmap) {
21412 len += WMI_TLV_HDR_SIZE;
21413 len += sizeof(wmi_vdev_set_connectivity_check_stats);
21414 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053021415 buf = wmi_buf_alloc(wmi_handle, len);
21416 if (!buf) {
21417 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21418 return QDF_STATUS_E_NOMEM;
21419 }
21420
21421 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21422 wmi_set_arp =
21423 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
21424 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
21425 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
21426 WMITLV_GET_STRUCT_TLVLEN
21427 (wmi_vdev_set_arp_stats_cmd_fixed_param));
21428
21429 /* fill in per roam config values */
21430 wmi_set_arp->vdev_id = req_buf->vdev_id;
21431
21432 wmi_set_arp->set_clr = req_buf->flag;
21433 wmi_set_arp->pkt_type = req_buf->pkt_type;
21434 wmi_set_arp->ipv4 = req_buf->ip_addr;
21435
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021436 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
21437 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
21438 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
21439
21440 /*
21441 * pkt_type_bitmap should be non-zero to ensure
21442 * presence of additional stats.
21443 */
21444 if (req_buf->pkt_type_bitmap) {
21445 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
21446
21447 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21448 WMITLV_SET_HDR(buf_ptr,
21449 WMITLV_TAG_ARRAY_STRUC,
21450 sizeof(wmi_vdev_set_connectivity_check_stats));
21451 buf_ptr += WMI_TLV_HDR_SIZE;
21452 wmi_set_connect_stats =
21453 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
21454 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
21455 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
21456 WMITLV_GET_STRUCT_TLVLEN(
21457 wmi_vdev_set_connectivity_check_stats));
21458 wmi_set_connect_stats->pkt_type_bitmap =
21459 req_buf->pkt_type_bitmap;
21460 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
21461 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
21462 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
21463
21464 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
21465 wmi_set_connect_stats->pkt_type_bitmap,
21466 wmi_set_connect_stats->tcp_src_port,
21467 wmi_set_connect_stats->tcp_dst_port,
21468 wmi_set_connect_stats->icmp_ipv4);
21469 }
21470
Anurag Chouhan97f00422017-09-11 14:56:30 +053021471 /* Send per roam config parameters */
21472 status = wmi_unified_cmd_send(wmi_handle, buf,
21473 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21474 if (QDF_IS_STATUS_ERROR(status)) {
21475 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21476 status);
21477 goto error;
21478 }
21479
21480 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
21481 req_buf->flag, req_buf->vdev_id);
21482 return QDF_STATUS_SUCCESS;
21483error:
21484 wmi_buf_free(buf);
21485
21486 return status;
21487}
21488
21489/**
21490 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21491 * @wmi_handle: wmi handler
21492 * @req_buf: get arp stats request buffer
21493 *
21494 * Return: 0 for success and non zero for failure
21495 */
21496static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21497 struct get_arp_stats *req_buf)
21498{
21499 wmi_buf_t buf = NULL;
21500 QDF_STATUS status;
21501 int len;
21502 uint8_t *buf_ptr;
21503 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21504
21505 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21506 buf = wmi_buf_alloc(wmi_handle, len);
21507 if (!buf) {
21508 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21509 return QDF_STATUS_E_NOMEM;
21510 }
21511
21512 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21513 get_arp_stats =
21514 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21515 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21516 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21517 WMITLV_GET_STRUCT_TLVLEN
21518 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21519
21520 /* fill in arp stats req cmd values */
21521 get_arp_stats->vdev_id = req_buf->vdev_id;
21522
21523 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21524 /* Send per roam config parameters */
21525 status = wmi_unified_cmd_send(wmi_handle, buf,
21526 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21527 if (QDF_IS_STATUS_ERROR(status)) {
21528 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21529 status);
21530 goto error;
21531 }
21532
21533 return QDF_STATUS_SUCCESS;
21534error:
21535 wmi_buf_free(buf);
21536
21537 return status;
21538}
21539
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021540/**
21541 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21542 * @wmi_handle: wmi handler
21543 * @pmk_info: pointer to PMK cache entry
21544 * @vdev_id: vdev id
21545 *
21546 * Return: 0 for success and non zero for failure
21547 */
21548static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21549 struct wmi_unified_pmk_cache *pmk_info)
21550{
21551 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21552 wmi_buf_t buf;
21553 QDF_STATUS status;
21554 uint8_t *buf_ptr;
21555 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021556 uint32_t len = sizeof(*cmd);
21557
21558 if (pmk_info->pmk_len)
21559 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021560
21561 buf = wmi_buf_alloc(wmi_handle, len);
21562 if (!buf) {
21563 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21564 __func__);
21565 return QDF_STATUS_E_NOMEM;
21566 }
21567
21568 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21569 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21570
21571 WMITLV_SET_HDR(&cmd->tlv_header,
21572 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21573 WMITLV_GET_STRUCT_TLVLEN(
21574 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21575
21576 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021577
21578 /* If pmk_info->pmk_len is 0, this is a flush request */
21579 if (!pmk_info->pmk_len) {
21580 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21581 cmd->num_cache = 0;
21582 goto send_cmd;
21583 }
21584
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021585 cmd->num_cache = 1;
21586 buf_ptr += sizeof(*cmd);
21587
21588 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21589 sizeof(*pmksa));
21590 buf_ptr += WMI_TLV_HDR_SIZE;
21591
21592 pmksa = (wmi_pmk_cache *)buf_ptr;
21593 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21594 WMITLV_GET_STRUCT_TLVLEN
21595 (wmi_pmk_cache));
21596 pmksa->pmk_len = pmk_info->pmk_len;
21597 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21598 pmksa->pmkid_len = pmk_info->pmkid_len;
21599 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21600 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21601 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21602 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21603 pmksa->ssid.ssid_len);
21604 pmksa->cache_id = pmk_info->cache_id;
21605 pmksa->cat_flag = pmk_info->cat_flag;
21606 pmksa->action_flag = pmk_info->action_flag;
21607
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021608send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021609 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21610 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21611 if (status != QDF_STATUS_SUCCESS) {
21612 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21613 __func__, status);
21614 wmi_buf_free(buf);
21615 }
21616
21617 return status;
21618}
21619
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021620/**
21621 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21622 * @wmi_handle: wmi handle
21623 * @param: reserved param
21624 *
21625 * Return: 0 for success or error code
21626 */
21627static QDF_STATUS
21628send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21629 uint32_t param)
21630{
21631 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21632 wmi_buf_t buf;
21633 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21634
21635 buf = wmi_buf_alloc(wmi_handle, len);
21636 if (!buf) {
21637 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21638 return QDF_STATUS_E_FAILURE;
21639 }
21640 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21641 WMITLV_SET_HDR(&cmd->tlv_header,
21642 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21643 WMITLV_GET_STRUCT_TLVLEN
21644 (wmi_pdev_check_cal_version_cmd_fixed_param));
21645 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21646 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21647 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21648 wmi_buf_free(buf);
21649 return QDF_STATUS_E_FAILURE;
21650 }
21651
21652 return QDF_STATUS_SUCCESS;
21653}
21654
21655/**
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053021656 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
21657 * host to target defines.
21658 * @param pdev_id: host pdev_id to be converted.
21659 * Return: target pdev_id after conversion.
21660 */
21661static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
21662{
21663 switch (pdev_id) {
21664 case WMI_HOST_PDEV_ID_SOC:
21665 return WMI_PDEV_ID_SOC;
21666 case WMI_HOST_PDEV_ID_0:
21667 return WMI_PDEV_ID_1ST;
21668 case WMI_HOST_PDEV_ID_1:
21669 return WMI_PDEV_ID_2ND;
21670 case WMI_HOST_PDEV_ID_2:
21671 return WMI_PDEV_ID_3RD;
21672 }
21673
21674 QDF_ASSERT(0);
21675
21676 return WMI_PDEV_ID_SOC;
21677}
21678
21679/**
21680 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
21681 * target to host defines.
21682 * @param pdev_id: target pdev_id to be converted.
21683 * Return: host pdev_id after conversion.
21684 */
21685static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
21686{
21687 switch (pdev_id) {
21688 case WMI_PDEV_ID_SOC:
21689 return WMI_HOST_PDEV_ID_SOC;
21690 case WMI_PDEV_ID_1ST:
21691 return WMI_HOST_PDEV_ID_0;
21692 case WMI_PDEV_ID_2ND:
21693 return WMI_HOST_PDEV_ID_1;
21694 case WMI_PDEV_ID_3RD:
21695 return WMI_HOST_PDEV_ID_2;
21696 }
21697
21698 QDF_ASSERT(0);
21699
21700 return WMI_HOST_PDEV_ID_SOC;
21701}
21702
21703/**
21704 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
21705 *
21706 * Return None.
21707 */
21708static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
21709{
21710 wmi_handle->ops->convert_pdev_id_host_to_target =
21711 convert_host_pdev_id_to_target_pdev_id;
21712 wmi_handle->ops->convert_pdev_id_target_to_host =
21713 convert_target_pdev_id_to_host_pdev_id;
21714}
21715
21716/**
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021717 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21718 * @wmi_handle: wmi handle
21719 * @param evt_buf: pointer to event buffer
21720 * @param param: Pointer to hold peer caldata version data
21721 *
21722 * Return: 0 for success or error code
21723 */
21724static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21725 wmi_unified_t wmi_handle,
21726 void *evt_buf,
21727 wmi_host_pdev_check_cal_version_event *param)
21728{
21729 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21730 wmi_pdev_check_cal_version_event_fixed_param *event;
21731
21732 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21733 if (!param_tlvs) {
21734 WMI_LOGE("invalid cal version event buf");
21735 return QDF_STATUS_E_FAILURE;
21736 }
21737 event = param_tlvs->fixed_param;
21738 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21739 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21740 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21741 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21742
21743 param->software_cal_version = event->software_cal_version;
21744 param->board_cal_version = event->board_cal_version;
21745 param->cal_ok = event->cal_status;
21746
21747 return QDF_STATUS_SUCCESS;
21748}
21749
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021750/*
21751 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21752 * @wmi_handle: wmi handle
21753 * @params: pointer to wmi_btm_config
21754 *
21755 * Return: QDF_STATUS
21756 */
21757static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21758 struct wmi_btm_config *params)
21759{
21760
21761 wmi_btm_config_fixed_param *cmd;
21762 wmi_buf_t buf;
21763 uint32_t len;
21764
21765 len = sizeof(*cmd);
21766 buf = wmi_buf_alloc(wmi_handle, len);
21767 if (!buf) {
21768 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21769 return QDF_STATUS_E_NOMEM;
21770 }
21771
21772 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21773 WMITLV_SET_HDR(&cmd->tlv_header,
21774 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21775 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21776 cmd->vdev_id = params->vdev_id;
21777 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021778 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21779 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21780 cmd->stick_time_seconds = params->btm_sticky_time;
21781
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021782 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21783 WMI_ROAM_BTM_CONFIG_CMDID)) {
21784 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21785 __func__);
21786 wmi_buf_free(buf);
21787 return QDF_STATUS_E_FAILURE;
21788 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021789
21790 return QDF_STATUS_SUCCESS;
21791}
21792
21793/**
21794 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21795 * configurations to firmware.
21796 * @wmi_handle: wmi handle
21797 * @obss_cfg_param: obss detection configurations
21798 *
21799 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21800 *
21801 * Return: QDF_STATUS
21802 */
21803static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21804 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21805{
21806 wmi_buf_t buf;
21807 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21808 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21809
21810 buf = wmi_buf_alloc(wmi_handle, len);
21811 if (!buf) {
21812 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21813 return QDF_STATUS_E_NOMEM;
21814 }
21815
21816 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21817 WMITLV_SET_HDR(&cmd->tlv_header,
21818 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21819 WMITLV_GET_STRUCT_TLVLEN
21820 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21821
21822 cmd->vdev_id = obss_cfg_param->vdev_id;
21823 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21824 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21825 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21826 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21827 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21828 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21829 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21830 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021831
21832 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21833 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21834 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21835 wmi_buf_free(buf);
21836 return QDF_STATUS_E_FAILURE;
21837 }
21838
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021839 return QDF_STATUS_SUCCESS;
21840}
21841
Arif Hussain33d98502018-01-12 13:15:04 -080021842/**
21843 * extract_obss_detection_info_tlv() - Extract obss detection info
21844 * received from firmware.
21845 * @evt_buf: pointer to event buffer
21846 * @obss_detection: Pointer to hold obss detection info
21847 *
21848 * Return: QDF_STATUS
21849 */
21850static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21851 struct wmi_obss_detect_info
21852 *obss_detection)
21853{
21854 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21855 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21856
21857 if (!obss_detection) {
21858 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21859 return QDF_STATUS_E_INVAL;
21860 }
21861
21862 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21863 if (!param_buf) {
21864 WMI_LOGE("%s: Invalid evt_buf", __func__);
21865 return QDF_STATUS_E_INVAL;
21866 }
21867
21868 fix_param = param_buf->fixed_param;
21869 obss_detection->vdev_id = fix_param->vdev_id;
21870 obss_detection->matched_detection_masks =
21871 fix_param->matched_detection_masks;
21872 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21873 &obss_detection->matched_bssid_addr[0]);
21874 switch (fix_param->reason) {
21875 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21876 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21877 break;
21878 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21879 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21880 break;
21881 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21882 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21883 break;
21884 default:
21885 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21886 return QDF_STATUS_E_INVAL;
21887 }
21888
21889 return QDF_STATUS_SUCCESS;
21890}
21891
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021892/**
21893 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21894 * @wmi_handle: wmi handler
21895 * @params: pointer to 11k offload params
21896 *
21897 * Return: 0 for success and non zero for failure
21898 */
21899static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21900 struct wmi_11k_offload_params *params)
21901{
21902 wmi_11k_offload_report_fixed_param *cmd;
21903 wmi_buf_t buf;
21904 QDF_STATUS status;
21905 uint8_t *buf_ptr;
21906 wmi_neighbor_report_11k_offload_tlv_param
21907 *neighbor_report_offload_params;
21908 wmi_neighbor_report_offload *neighbor_report_offload;
21909
21910 uint32_t len = sizeof(*cmd);
21911
21912 if (params->offload_11k_bitmask &
21913 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21914 len += WMI_TLV_HDR_SIZE +
21915 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21916
21917 buf = wmi_buf_alloc(wmi_handle, len);
21918 if (!buf) {
21919 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21920 __func__);
21921 return QDF_STATUS_E_NOMEM;
21922 }
21923
21924 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21925 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21926
21927 WMITLV_SET_HDR(&cmd->tlv_header,
21928 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21929 WMITLV_GET_STRUCT_TLVLEN(
21930 wmi_11k_offload_report_fixed_param));
21931
21932 cmd->vdev_id = params->vdev_id;
21933 cmd->offload_11k = params->offload_11k_bitmask;
21934
21935 if (params->offload_11k_bitmask &
21936 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21937 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21938
21939 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21940 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21941 buf_ptr += WMI_TLV_HDR_SIZE;
21942
21943 neighbor_report_offload_params =
21944 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21945 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21946 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21947 WMITLV_GET_STRUCT_TLVLEN(
21948 wmi_neighbor_report_11k_offload_tlv_param));
21949
21950 neighbor_report_offload = &neighbor_report_offload_params->
21951 neighbor_rep_ofld_params;
21952
21953 neighbor_report_offload->time_offset =
21954 params->neighbor_report_params.time_offset;
21955 neighbor_report_offload->low_rssi_offset =
21956 params->neighbor_report_params.low_rssi_offset;
21957 neighbor_report_offload->bmiss_count_trigger =
21958 params->neighbor_report_params.bmiss_count_trigger;
21959 neighbor_report_offload->per_threshold_offset =
21960 params->neighbor_report_params.per_threshold_offset;
21961 neighbor_report_offload->neighbor_report_cache_timeout =
21962 params->neighbor_report_params.
21963 neighbor_report_cache_timeout;
21964 neighbor_report_offload->max_neighbor_report_req_cap =
21965 params->neighbor_report_params.
21966 max_neighbor_report_req_cap;
21967 neighbor_report_offload->ssid.ssid_len =
21968 params->neighbor_report_params.ssid.length;
21969 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21970 &params->neighbor_report_params.ssid.mac_ssid,
21971 neighbor_report_offload->ssid.ssid_len);
21972 }
21973
21974 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21975 WMI_11K_OFFLOAD_REPORT_CMDID);
21976 if (status != QDF_STATUS_SUCCESS) {
21977 WMI_LOGE("%s: failed to send 11k offload command %d",
21978 __func__, status);
21979 wmi_buf_free(buf);
21980 }
21981
21982 return status;
21983}
21984
21985/**
21986 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
21987 * command
21988 * @wmi_handle: wmi handler
21989 * @params: pointer to neighbor report invoke params
21990 *
21991 * Return: 0 for success and non zero for failure
21992 */
21993static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
21994 struct wmi_invoke_neighbor_report_params *params)
21995{
21996 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
21997 wmi_buf_t buf;
21998 QDF_STATUS status;
21999 uint8_t *buf_ptr;
22000 uint32_t len = sizeof(*cmd);
22001
22002 buf = wmi_buf_alloc(wmi_handle, len);
22003 if (!buf) {
22004 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
22005 __func__);
22006 return QDF_STATUS_E_NOMEM;
22007 }
22008
22009 buf_ptr = (uint8_t *) wmi_buf_data(buf);
22010 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
22011
22012 WMITLV_SET_HDR(&cmd->tlv_header,
22013 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
22014 WMITLV_GET_STRUCT_TLVLEN(
22015 wmi_11k_offload_invoke_neighbor_report_fixed_param));
22016
22017 cmd->vdev_id = params->vdev_id;
22018 cmd->flags = params->send_resp_to_host;
22019
22020 cmd->ssid.ssid_len = params->ssid.length;
22021 qdf_mem_copy(cmd->ssid.ssid,
22022 &params->ssid.mac_ssid,
22023 cmd->ssid.ssid_len);
22024
22025 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22026 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
22027 if (status != QDF_STATUS_SUCCESS) {
22028 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
22029 __func__, status);
22030 wmi_buf_free(buf);
22031 }
22032
22033 return status;
22034}
22035
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022036#ifdef WLAN_SUPPORT_GREEN_AP
22037static QDF_STATUS extract_green_ap_egap_status_info_tlv(
22038 uint8_t *evt_buf,
22039 struct wlan_green_ap_egap_status_info *egap_status_info_params)
22040{
22041 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
22042 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
22043 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
22044
22045 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
22046 if (!param_buf) {
22047 WMI_LOGE("Invalid EGAP Info status event buffer");
22048 return QDF_STATUS_E_INVAL;
22049 }
22050
22051 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
22052 param_buf->fixed_param;
22053 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
22054 param_buf->chainmask_list;
22055
22056 egap_status_info_params->status = egap_info_event->status;
22057 egap_status_info_params->mac_id = chainmask_event->mac_id;
22058 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
22059 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
22060
22061 return QDF_STATUS_SUCCESS;
22062}
22063#endif
22064
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022065/*
22066 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
22067 * updating bss color change within firmware when AP announces bss color change.
22068 * @wmi_handle: wmi handle
22069 * @vdev_id: vdev ID
22070 * @enable: enable bss color change within firmware
22071 *
22072 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
22073 *
22074 * Return: QDF_STATUS
22075 */
22076static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
22077 uint32_t vdev_id,
22078 bool enable)
22079{
22080 wmi_buf_t buf;
22081 wmi_bss_color_change_enable_fixed_param *cmd;
22082 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
22083
22084 buf = wmi_buf_alloc(wmi_handle, len);
22085 if (!buf) {
22086 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22087 return QDF_STATUS_E_NOMEM;
22088 }
22089
22090 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
22091 WMITLV_SET_HDR(&cmd->tlv_header,
22092 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
22093 WMITLV_GET_STRUCT_TLVLEN
22094 (wmi_bss_color_change_enable_fixed_param));
22095 cmd->vdev_id = vdev_id;
22096 cmd->enable = enable;
22097 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22098 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
22099 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
22100 wmi_buf_free(buf);
22101 return QDF_STATUS_E_FAILURE;
22102 }
22103
22104 return QDF_STATUS_SUCCESS;
22105}
22106
22107/**
22108 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
22109 * configurations to firmware.
22110 * @wmi_handle: wmi handle
22111 * @cfg_param: obss detection configurations
22112 *
22113 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
22114 *
22115 * Return: QDF_STATUS
22116 */
22117static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
22118 wmi_unified_t wmi_handle,
22119 struct wmi_obss_color_collision_cfg_param *cfg_param)
22120{
22121 wmi_buf_t buf;
22122 wmi_obss_color_collision_det_config_fixed_param *cmd;
22123 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
22124
22125 buf = wmi_buf_alloc(wmi_handle, len);
22126 if (!buf) {
22127 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22128 return QDF_STATUS_E_NOMEM;
22129 }
22130
22131 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
22132 buf);
22133 WMITLV_SET_HDR(&cmd->tlv_header,
22134 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
22135 WMITLV_GET_STRUCT_TLVLEN
22136 (wmi_obss_color_collision_det_config_fixed_param));
22137 cmd->vdev_id = cfg_param->vdev_id;
22138 cmd->flags = cfg_param->flags;
22139 cmd->current_bss_color = cfg_param->current_bss_color;
22140 cmd->detection_period_ms = cfg_param->detection_period_ms;
22141 cmd->scan_period_ms = cfg_param->scan_period_ms;
22142 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
22143
22144 switch (cfg_param->evt_type) {
22145 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
22146 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
22147 break;
22148 case OBSS_COLOR_COLLISION_DETECTION:
22149 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
22150 break;
22151 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22152 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22153 break;
22154 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
22155 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
22156 break;
22157 default:
22158 WMI_LOGE("%s: invalid event type: %d",
22159 __func__, cfg_param->evt_type);
22160 wmi_buf_free(buf);
22161 return QDF_STATUS_E_FAILURE;
22162 }
22163
22164 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22165 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
22166 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
22167 __func__, cfg_param->vdev_id);
22168 wmi_buf_free(buf);
22169 return QDF_STATUS_E_FAILURE;
22170 }
22171
22172 return QDF_STATUS_SUCCESS;
22173}
22174
22175/**
22176 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
22177 * received from firmware.
22178 * @evt_buf: pointer to event buffer
22179 * @info: Pointer to hold bss collision info
22180 *
22181 * Return: QDF_STATUS
22182 */
22183static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
22184 struct wmi_obss_color_collision_info *info)
22185{
22186 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
22187 wmi_obss_color_collision_evt_fixed_param *fix_param;
22188
22189 if (!info) {
22190 WMI_LOGE("%s: Invalid obss color buffer", __func__);
22191 return QDF_STATUS_E_INVAL;
22192 }
22193
22194 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
22195 evt_buf;
22196 if (!param_buf) {
22197 WMI_LOGE("%s: Invalid evt_buf", __func__);
22198 return QDF_STATUS_E_INVAL;
22199 }
22200
22201 fix_param = param_buf->fixed_param;
22202 info->vdev_id = fix_param->vdev_id;
22203 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
22204 info->obss_color_bitmap_bit32to63 =
22205 fix_param->bss_color_bitmap_bit32to63;
22206
22207 switch (fix_param->evt_type) {
22208 case WMI_BSS_COLOR_COLLISION_DISABLE:
22209 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
22210 break;
22211 case WMI_BSS_COLOR_COLLISION_DETECTION:
22212 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
22213 break;
22214 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22215 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22216 break;
22217 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
22218 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
22219 break;
22220 default:
22221 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
22222 __func__, fix_param->evt_type, fix_param->vdev_id);
22223 return QDF_STATUS_E_FAILURE;
22224 }
22225
22226 return QDF_STATUS_SUCCESS;
22227}
22228
Arif Hussaine0eb7302018-03-01 14:40:59 -080022229/*
22230 * extract_comb_phyerr_tlv() - extract comb phy error from event
22231 * @wmi_handle: wmi handle
22232 * @evt_buf: pointer to event buffer
22233 * @datalen: data length of event buffer
22234 * @buf_offset: Pointer to hold value of current event buffer offset
22235 * post extraction
22236 * @phyerr: Pointer to hold phyerr
22237 *
22238 * Return: QDF_STATUS
22239 */
22240static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
22241 void *evt_buf,
22242 uint16_t datalen,
22243 uint16_t *buf_offset,
22244 wmi_host_phyerr_t *phyerr)
22245{
22246 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
22247 wmi_comb_phyerr_rx_hdr *pe_hdr;
22248
22249 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
22250 if (!param_tlvs) {
22251 WMI_LOGD("%s: Received null data from FW", __func__);
22252 return QDF_STATUS_E_FAILURE;
22253 }
22254
22255 pe_hdr = param_tlvs->hdr;
22256 if (!pe_hdr) {
22257 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
22258 return QDF_STATUS_E_FAILURE;
22259 }
22260
22261 /* Ensure it's at least the size of the header */
22262 if (datalen < sizeof(*pe_hdr)) {
22263 WMI_LOGD("%s: Expected minimum size %zu, received %d",
22264 __func__, sizeof(*pe_hdr), datalen);
22265 return QDF_STATUS_E_FAILURE;
22266 }
22267
22268 phyerr->pdev_id = wmi_handle->ops->
22269 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
22270 phyerr->tsf64 = pe_hdr->tsf_l32;
22271 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
22272 phyerr->bufp = param_tlvs->bufp;
22273 phyerr->buf_len = pe_hdr->buf_len;
22274 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
22275 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
22276 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
22277
22278 return QDF_STATUS_SUCCESS;
22279}
22280
22281/**
22282 * extract_single_phyerr_tlv() - extract single phy error from event
22283 * @wmi_handle: wmi handle
22284 * @evt_buf: pointer to event buffer
22285 * @datalen: data length of event buffer
22286 * @buf_offset: Pointer to hold value of current event buffer offset
22287 * post extraction
22288 * @phyerr: Pointer to hold phyerr
22289 *
22290 * Return: QDF_STATUS
22291 */
22292static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
22293 void *evt_buf,
22294 uint16_t datalen,
22295 uint16_t *buf_offset,
22296 wmi_host_phyerr_t *phyerr)
22297{
22298 wmi_single_phyerr_rx_event *ev;
22299 uint16_t n = *buf_offset;
22300 uint8_t *data = (uint8_t *)evt_buf;
22301
22302 if (n < datalen) {
22303 if ((datalen - n) < sizeof(ev->hdr)) {
22304 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
22305 __func__, datalen, n, sizeof(ev->hdr));
22306 return QDF_STATUS_E_FAILURE;
22307 }
22308
22309 /*
22310 * Obtain a pointer to the beginning of the current event.
22311 * data[0] is the beginning of the WMI payload.
22312 */
22313 ev = (wmi_single_phyerr_rx_event *)&data[n];
22314
22315 /*
22316 * Sanity check the buffer length of the event against
22317 * what we currently have.
22318 *
22319 * Since buf_len is 32 bits, we check if it overflows
22320 * a large 32 bit value. It's not 0x7fffffff because
22321 * we increase n by (buf_len + sizeof(hdr)), which would
22322 * in itself cause n to overflow.
22323 *
22324 * If "int" is 64 bits then this becomes a moot point.
22325 */
22326 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
22327 WMI_LOGD("%s: buf_len is garbage 0x%x",
22328 __func__, ev->hdr.buf_len);
22329 return QDF_STATUS_E_FAILURE;
22330 }
22331
22332 if ((n + ev->hdr.buf_len) > datalen) {
22333 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
22334 __func__, n, ev->hdr.buf_len, datalen);
22335 return QDF_STATUS_E_FAILURE;
22336 }
22337
22338 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
22339 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
22340 phyerr->bufp = &ev->bufp[0];
22341 phyerr->buf_len = ev->hdr.buf_len;
22342 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
22343
22344 /*
22345 * Advance the buffer pointer to the next PHY error.
22346 * buflen is the length of this payload, so we need to
22347 * advance past the current header _AND_ the payload.
22348 */
22349 n += sizeof(*ev) + ev->hdr.buf_len;
22350 }
22351 *buf_offset = n;
22352
22353 return QDF_STATUS_SUCCESS;
22354}
22355
Govind Singh5eb51532016-03-09 11:34:12 +053022356struct wmi_ops tlv_ops = {
22357 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
22358 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
22359 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053022360 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
22361 .send_hidden_ssid_vdev_restart_cmd =
22362 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022363 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
22364 .send_peer_param_cmd = send_peer_param_cmd_tlv,
22365 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022366 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022367 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022368 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070022369 .send_peer_rx_reorder_queue_setup_cmd =
22370 send_peer_rx_reorder_queue_setup_cmd_tlv,
22371 .send_peer_rx_reorder_queue_remove_cmd =
22372 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053022373 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
22374 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
22375 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022376 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
22377 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022378 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022379 .send_suspend_cmd = send_suspend_cmd_tlv,
22380 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080022381#ifdef FEATURE_WLAN_D0WOW
22382 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
22383 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
22384#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022385 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
22386 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
22387 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
22388 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
22389 .send_dbglog_cmd = send_dbglog_cmd_tlv,
22390 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
22391 .send_stats_request_cmd = send_stats_request_cmd_tlv,
22392 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053022393 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070022394 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022395 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022396 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022397 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
22398 .send_scan_start_cmd = send_scan_start_cmd_tlv,
22399 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
22400 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022401 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022402 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022403 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
22404 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022405 .send_set_sta_uapsd_auto_trig_cmd =
22406 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022407 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
22408 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
22409 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022410#ifdef CONVERGED_P2P_ENABLE
22411 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
22412 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
22413#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053022414 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
22415 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022416#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053022417 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
22418 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
22419 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
22420 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
22421 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
22422 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
22423 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022424 .send_ocb_start_timing_advert_cmd =
22425 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022426 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
22427 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
22428 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
22429 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
22430#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053022431 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
22432 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
22433 .send_set_mcc_channel_time_latency_cmd =
22434 send_set_mcc_channel_time_latency_cmd_tlv,
22435 .send_set_mcc_channel_time_quota_cmd =
22436 send_set_mcc_channel_time_quota_cmd_tlv,
22437 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
22438 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053022439 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022440 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
22441 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
22442 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022443 .send_probe_rsp_tmpl_send_cmd =
22444 send_probe_rsp_tmpl_send_cmd_tlv,
22445 .send_p2p_go_set_beacon_ie_cmd =
22446 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053022447 .send_setup_install_key_cmd =
22448 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022449 .send_set_gateway_params_cmd =
22450 send_set_gateway_params_cmd_tlv,
22451 .send_set_rssi_monitoring_cmd =
22452 send_set_rssi_monitoring_cmd_tlv,
22453 .send_scan_probe_setoui_cmd =
22454 send_scan_probe_setoui_cmd_tlv,
22455 .send_reset_passpoint_network_list_cmd =
22456 send_reset_passpoint_network_list_cmd_tlv,
22457 .send_set_passpoint_network_list_cmd =
22458 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022459 .send_roam_scan_offload_rssi_thresh_cmd =
22460 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070022461 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022462 .send_roam_scan_filter_cmd =
22463 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022464 .send_set_epno_network_list_cmd =
22465 send_set_epno_network_list_cmd_tlv,
22466 .send_ipa_offload_control_cmd =
22467 send_ipa_offload_control_cmd_tlv,
22468 .send_extscan_get_capabilities_cmd =
22469 send_extscan_get_capabilities_cmd_tlv,
22470 .send_extscan_get_cached_results_cmd =
22471 send_extscan_get_cached_results_cmd_tlv,
22472 .send_extscan_stop_change_monitor_cmd =
22473 send_extscan_stop_change_monitor_cmd_tlv,
22474 .send_extscan_start_change_monitor_cmd =
22475 send_extscan_start_change_monitor_cmd_tlv,
22476 .send_extscan_stop_hotlist_monitor_cmd =
22477 send_extscan_stop_hotlist_monitor_cmd_tlv,
22478 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
22479 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
22480 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
22481 .send_plm_start_cmd = send_plm_start_cmd_tlv,
22482 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
22483 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070022484 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022485 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
22486 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
22487 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
22488 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053022489 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022490 .send_snr_request_cmd = send_snr_request_cmd_tlv,
22491 .send_snr_cmd = send_snr_cmd_tlv,
22492 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022493#ifdef WLAN_PMO_ENABLE
22494 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
22495 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
22496 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
22497 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053022498 .send_multiple_add_clear_mcbc_filter_cmd =
22499 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070022500 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022501 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
22502 .send_process_gtk_offload_getinfo_cmd =
22503 send_process_gtk_offload_getinfo_cmd_tlv,
22504 .send_enable_enhance_multicast_offload_cmd =
22505 send_enable_enhance_multicast_offload_tlv,
22506 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
22507#ifdef FEATURE_WLAN_RA_FILTERING
22508 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
22509#endif
22510 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022511 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
22512 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022513 .send_lphb_config_tcp_pkt_filter_cmd =
22514 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022515 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22516 .send_lphb_config_udp_pkt_filter_cmd =
22517 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022518 .send_enable_disable_packet_filter_cmd =
22519 send_enable_disable_packet_filter_cmd_tlv,
22520 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022521#endif /* End of WLAN_PMO_ENABLE */
22522#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022523 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22524 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022525 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022526 .send_roam_scan_offload_mode_cmd =
22527 send_roam_scan_offload_mode_cmd_tlv,
22528 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
22529 .send_roam_scan_offload_ap_profile_cmd =
22530 send_roam_scan_offload_ap_profile_cmd_tlv,
22531#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022532#ifdef WLAN_SUPPORT_GREEN_AP
22533 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22534 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022535 .extract_green_ap_egap_status_info =
22536 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022537#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022538 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22539 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022540 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022541 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022542 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022543#ifdef WLAN_FEATURE_CIF_CFR
22544 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22545#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022546 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022547 .send_dfs_phyerr_filter_offload_en_cmd =
22548 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022549 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22550 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22551 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22552 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22553 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022554 .send_process_add_periodic_tx_ptrn_cmd =
22555 send_process_add_periodic_tx_ptrn_cmd_tlv,
22556 .send_process_del_periodic_tx_ptrn_cmd =
22557 send_process_del_periodic_tx_ptrn_cmd_tlv,
22558 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22559 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22560 .send_set_app_type2_params_in_fw_cmd =
22561 send_set_app_type2_params_in_fw_cmd_tlv,
22562 .send_set_auto_shutdown_timer_cmd =
22563 send_set_auto_shutdown_timer_cmd_tlv,
22564 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22565 .send_process_dhcpserver_offload_cmd =
22566 send_process_dhcpserver_offload_cmd_tlv,
22567 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22568 .send_process_ch_avoid_update_cmd =
22569 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022570 .send_pdev_set_regdomain_cmd =
22571 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022572 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22573 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22574 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22575 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022576 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022577 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022578 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022579 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022580 .send_set_base_macaddr_indicate_cmd =
22581 send_set_base_macaddr_indicate_cmd_tlv,
22582 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22583 .send_enable_specific_fw_logs_cmd =
22584 send_enable_specific_fw_logs_cmd_tlv,
22585 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022586 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022587 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022588 .send_pdev_set_dual_mac_config_cmd =
22589 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022590 .send_app_type1_params_in_fw_cmd =
22591 send_app_type1_params_in_fw_cmd_tlv,
22592 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22593 .send_process_roam_synch_complete_cmd =
22594 send_process_roam_synch_complete_cmd_tlv,
22595 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22596 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22597 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022598 .send_roam_scan_offload_scan_period_cmd =
22599 send_roam_scan_offload_scan_period_cmd_tlv,
22600 .send_roam_scan_offload_chan_list_cmd =
22601 send_roam_scan_offload_chan_list_cmd_tlv,
22602 .send_roam_scan_offload_rssi_change_cmd =
22603 send_roam_scan_offload_rssi_change_cmd_tlv,
22604 .send_get_buf_extscan_hotlist_cmd =
22605 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080022606 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053022607 .send_adapt_dwelltime_params_cmd =
22608 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022609 .send_dbs_scan_sel_params_cmd =
22610 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022611 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022612 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22613 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22614 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22615 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22616 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22617 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022618 .send_vdev_set_custom_aggr_size_cmd =
22619 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022620 .send_vdev_set_qdepth_thresh_cmd =
22621 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022622 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22623 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22624 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022625 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22626 .send_smart_ant_set_training_info_cmd =
22627 send_smart_ant_set_training_info_cmd_tlv,
22628 .send_smart_ant_set_node_config_cmd =
22629 send_smart_ant_set_node_config_cmd_tlv,
22630 .send_set_atf_cmd = send_set_atf_cmd_tlv,
22631 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22632 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022633 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22634 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22635 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22636 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022637 .send_periodic_chan_stats_config_cmd =
22638 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022639 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22640 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22641 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022642 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22643 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22644 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22645 .send_vdev_spectral_configure_cmd =
22646 send_vdev_spectral_configure_cmd_tlv,
22647 .send_vdev_spectral_enable_cmd =
22648 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022649 .send_thermal_mitigation_param_cmd =
22650 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022651 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22652 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022653 .send_process_update_edca_param_cmd =
22654 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022655 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022656 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022657 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022658 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22659 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022660 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022661 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22662 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22663 .extract_host_mem_req = extract_host_mem_req_tlv,
22664 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022665 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022666 .is_service_enabled = is_service_enabled_tlv,
22667 .save_fw_version = save_fw_version_in_service_ready_tlv,
22668 .ready_extract_init_status = ready_extract_init_status_tlv,
22669 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022670 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022671 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022672 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22673 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022674 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022675 .extract_tbttoffset_update_params =
22676 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022677 .extract_ext_tbttoffset_update_params =
22678 extract_ext_tbttoffset_update_params_tlv,
22679 .extract_tbttoffset_num_vdevs =
22680 extract_tbttoffset_num_vdevs_tlv,
22681 .extract_ext_tbttoffset_num_vdevs =
22682 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022683 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22684 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22685 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22686 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022687#ifdef CONVERGED_TDLS_ENABLE
22688 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22689#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022690 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022691 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022692 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22693 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022694#ifdef CONVERGED_P2P_ENABLE
22695 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22696 .extract_p2p_lo_stop_ev_param =
22697 extract_p2p_lo_stop_ev_param_tlv,
22698#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022699 .extract_offchan_data_tx_compl_param =
22700 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022701 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22702 .extract_all_stats_count = extract_all_stats_counts_tlv,
22703 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022704 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022705 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22706 .extract_vdev_stats = extract_vdev_stats_tlv,
22707 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022708 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022709 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22710 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22711 .extract_chan_stats = extract_chan_stats_tlv,
22712 .extract_profile_ctx = extract_profile_ctx_tlv,
22713 .extract_profile_data = extract_profile_data_tlv,
22714 .extract_chan_info_event = extract_chan_info_event_tlv,
22715 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022716 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022717#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022718 .send_encrypt_decrypt_send_cmd =
22719 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022720 .extract_encrypt_decrypt_resp_event =
22721 extract_encrypt_decrypt_resp_event_tlv,
22722#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022723 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022724 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22725 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022726 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022727 .send_multiple_vdev_restart_req_cmd =
22728 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022729 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22730 .extract_hw_mode_cap_service_ready_ext =
22731 extract_hw_mode_cap_service_ready_ext_tlv,
22732 .extract_mac_phy_cap_service_ready_ext =
22733 extract_mac_phy_cap_service_ready_ext_tlv,
22734 .extract_reg_cap_service_ready_ext =
22735 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022736 .extract_dbr_ring_cap_service_ready_ext =
22737 extract_dbr_ring_cap_service_ready_ext_tlv,
22738 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22739 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022740 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022741 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022742 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22743 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22744 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022745 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022746 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022747 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022748 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022749 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022750 .extract_pdev_csa_switch_count_status =
22751 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022752 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022753 .extract_pdev_tpc_config_ev_param =
22754 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022755 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022756 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22757 .extract_peer_sta_ps_statechange_ev =
22758 extract_peer_sta_ps_statechange_ev_tlv,
22759 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022760 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080022761 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22762 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022763 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022764 extract_reg_chan_list_update_event_tlv,
22765 .extract_chainmask_tables =
22766 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022767 .extract_thermal_stats = extract_thermal_stats_tlv,
22768 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022769 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22770 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022771#ifdef DFS_COMPONENT_ENABLE
22772 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22773 .extract_dfs_radar_detection_event =
22774 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022775 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022776#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022777 .convert_pdev_id_host_to_target =
22778 convert_host_pdev_id_to_target_pdev_id_legacy,
22779 .convert_pdev_id_target_to_host =
22780 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022781
22782 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22783 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22784 .extract_reg_11d_new_country_event =
22785 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022786 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022787 .send_limit_off_chan_cmd =
22788 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022789 .extract_reg_ch_avoid_event =
22790 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022791 .send_pdev_caldata_version_check_cmd =
22792 send_pdev_caldata_version_check_cmd_tlv,
22793 .extract_pdev_caldata_version_check_ev_param =
22794 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022795 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22796 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022797 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22798#if defined(WLAN_FEATURE_FILS_SK)
22799 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22800#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022801 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022802#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22803 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22804 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22805 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22806 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22807 .extract_ndp_ind = extract_ndp_ind_tlv,
22808 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22809 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22810 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22811 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
22812#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022813 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022814 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022815 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022816#ifdef WLAN_SUPPORT_FILS
22817 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22818 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22819 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22820#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022821 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22822 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022823 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22824 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22825 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22826 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022827 .send_bss_color_change_enable_cmd =
22828 send_bss_color_change_enable_cmd_tlv,
22829 .send_obss_color_collision_cfg_cmd =
22830 send_obss_color_collision_cfg_cmd_tlv,
22831 .extract_obss_color_collision_info =
22832 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022833 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22834 .extract_single_phyerr = extract_single_phyerr_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022835};
22836
Govind Singhe7f2f342016-05-23 12:12:52 +053022837/**
22838 * populate_tlv_event_id() - populates wmi event ids
22839 *
22840 * @param event_ids: Pointer to hold event ids
22841 * Return: None
22842 */
22843static void populate_tlv_events_id(uint32_t *event_ids)
22844{
22845 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22846 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22847 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22848 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22849 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22850 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22851 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22852 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22853 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22854 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22855 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22856 event_ids[wmi_service_ready_ext_event_id] =
22857 WMI_SERVICE_READY_EXT_EVENTID;
22858 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22859 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22860 event_ids[wmi_vdev_install_key_complete_event_id] =
22861 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22862 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22863 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22864
22865 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22866 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22867 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22868 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22869 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22870 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22871 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22872 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022873 event_ids[wmi_peer_delete_response_event_id] =
22874 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022875 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22876 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22877 event_ids[wmi_tbttoffset_update_event_id] =
22878 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022879 event_ids[wmi_ext_tbttoffset_update_event_id] =
22880 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022881 event_ids[wmi_offload_bcn_tx_status_event_id] =
22882 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22883 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22884 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22885 event_ids[wmi_mgmt_tx_completion_event_id] =
22886 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022887 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22888 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022889 event_ids[wmi_tx_delba_complete_event_id] =
22890 WMI_TX_DELBA_COMPLETE_EVENTID;
22891 event_ids[wmi_tx_addba_complete_event_id] =
22892 WMI_TX_ADDBA_COMPLETE_EVENTID;
22893 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22894
22895 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22896
22897 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22898 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22899
22900 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022901 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022902
22903 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22904
22905 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022906 event_ids[wmi_p2p_lo_stop_event_id] =
22907 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022908 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22909 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022910 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022911 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22912 event_ids[wmi_wow_initial_wakeup_event_id] =
22913 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22914
22915 event_ids[wmi_rtt_meas_report_event_id] =
22916 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22917 event_ids[wmi_tsf_meas_report_event_id] =
22918 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22919 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22920 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22921 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22922 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22923 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022924 event_ids[wmi_diag_event_id_log_supported_event_id] =
22925 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22926 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22927 event_ids[wmi_nlo_scan_complete_event_id] =
22928 WMI_NLO_SCAN_COMPLETE_EVENTID;
22929 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22930 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22931
22932 event_ids[wmi_gtk_offload_status_event_id] =
22933 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22934 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22935 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22936 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22937
22938 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22939
22940 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22941
22942 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22943 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22944 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22945 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22946 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22947 event_ids[wmi_wlan_profile_data_event_id] =
22948 WMI_WLAN_PROFILE_DATA_EVENTID;
22949 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22950 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22951 event_ids[wmi_vdev_get_keepalive_event_id] =
22952 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22953 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22954
22955 event_ids[wmi_diag_container_event_id] =
22956 WMI_DIAG_DATA_CONTAINER_EVENTID;
22957
22958 event_ids[wmi_host_auto_shutdown_event_id] =
22959 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22960
22961 event_ids[wmi_update_whal_mib_stats_event_id] =
22962 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22963
22964 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22965 event_ids[wmi_update_vdev_rate_stats_event_id] =
22966 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22967
22968 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022969 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022970
22971 /** Set OCB Sched Response, deprecated */
22972 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
22973
22974 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
22975 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
22976 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
22977
22978 /* GPIO Event */
22979 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
22980 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
22981
22982 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
22983 event_ids[wmi_rfkill_state_change_event_id] =
22984 WMI_RFKILL_STATE_CHANGE_EVENTID;
22985
22986 /* TDLS Event */
22987 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
22988
22989 event_ids[wmi_batch_scan_enabled_event_id] =
22990 WMI_BATCH_SCAN_ENABLED_EVENTID;
22991 event_ids[wmi_batch_scan_result_event_id] =
22992 WMI_BATCH_SCAN_RESULT_EVENTID;
22993 /* OEM Event */
22994 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
22995 event_ids[wmi_oem_meas_report_event_id] =
22996 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
22997 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
22998
22999 /* NAN Event */
23000 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
23001
23002 /* LPI Event */
23003 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
23004 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
23005 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
23006
23007 /* ExtScan events */
23008 event_ids[wmi_extscan_start_stop_event_id] =
23009 WMI_EXTSCAN_START_STOP_EVENTID;
23010 event_ids[wmi_extscan_operation_event_id] =
23011 WMI_EXTSCAN_OPERATION_EVENTID;
23012 event_ids[wmi_extscan_table_usage_event_id] =
23013 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
23014 event_ids[wmi_extscan_cached_results_event_id] =
23015 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
23016 event_ids[wmi_extscan_wlan_change_results_event_id] =
23017 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
23018 event_ids[wmi_extscan_hotlist_match_event_id] =
23019 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
23020 event_ids[wmi_extscan_capabilities_event_id] =
23021 WMI_EXTSCAN_CAPABILITIES_EVENTID;
23022 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
23023 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
23024
23025 /* mDNS offload events */
23026 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
23027
23028 /* SAP Authentication offload events */
23029 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
23030 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
23031
23032 /** Out-of-context-of-bss (OCB) events */
23033 event_ids[wmi_ocb_set_config_resp_event_id] =
23034 WMI_OCB_SET_CONFIG_RESP_EVENTID;
23035 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
23036 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
23037 event_ids[wmi_dcc_get_stats_resp_event_id] =
23038 WMI_DCC_GET_STATS_RESP_EVENTID;
23039 event_ids[wmi_dcc_update_ndl_resp_event_id] =
23040 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
23041 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
23042 /* System-On-Chip events */
23043 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
23044 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
23045 event_ids[wmi_soc_hw_mode_transition_event_id] =
23046 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
23047 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
23048 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053023049 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053023050 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
23051 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053023052 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053023053 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
23054 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
23055 event_ids[wmi_peer_sta_ps_statechg_event_id] =
23056 WMI_PEER_STA_PS_STATECHG_EVENTID;
23057 event_ids[wmi_pdev_channel_hopping_event_id] =
23058 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053023059 event_ids[wmi_offchan_data_tx_completion_event] =
23060 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070023061 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
23062 event_ids[wmi_dfs_radar_detection_event_id] =
23063 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053023064 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070023065 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053023066 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053023067 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053023068 event_ids[wmi_service_available_event_id] =
23069 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053023070 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053023071 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053023072 /* NDP events */
23073 event_ids[wmi_ndp_initiator_rsp_event_id] =
23074 WMI_NDP_INITIATOR_RSP_EVENTID;
23075 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
23076 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
23077 event_ids[wmi_ndp_responder_rsp_event_id] =
23078 WMI_NDP_RESPONDER_RSP_EVENTID;
23079 event_ids[wmi_ndp_end_indication_event_id] =
23080 WMI_NDP_END_INDICATION_EVENTID;
23081 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
23082
23083 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
23084 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
23085 event_ids[wmi_pdev_chip_power_stats_event_id] =
23086 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
23087 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
23088 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
23089 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
23090 event_ids[wmi_bpf_capability_info_event_id] =
23091 WMI_BPF_CAPABILIY_INFO_EVENTID;
23092 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
23093 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
23094 event_ids[wmi_report_rx_aggr_failure_event_id] =
23095 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
23096 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
23097 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
23098 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
23099 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
23100 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
23101 event_ids[wmi_pdev_hw_mode_transition_event_id] =
23102 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
23103 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
23104 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
23105 event_ids[wmi_coex_bt_activity_event_id] =
23106 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
23107 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
23108 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
23109 event_ids[wmi_radio_tx_power_level_stats_event_id] =
23110 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
23111 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053023112 event_ids[wmi_dma_buf_release_event_id] =
23113 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080023114 event_ids[wmi_sap_obss_detection_report_event_id] =
23115 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053023116 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080023117 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080023118 event_ids[wmi_obss_color_collision_report_event_id] =
23119 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023120}
23121
Soumya Bhat488092d2017-03-22 14:41:01 +053023122/**
23123 * populate_tlv_service() - populates wmi services
23124 *
23125 * @param wmi_service: Pointer to hold wmi_service
23126 * Return: None
23127 */
23128static void populate_tlv_service(uint32_t *wmi_service)
23129{
23130 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023131 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023132 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
23133 wmi_service[wmi_service_roam_scan_offload] =
23134 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
23135 wmi_service[wmi_service_bcn_miss_offload] =
23136 WMI_SERVICE_BCN_MISS_OFFLOAD;
23137 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
23138 wmi_service[wmi_service_sta_advanced_pwrsave] =
23139 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
23140 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
23141 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
23142 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
23143 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
23144 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
23145 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
23146 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
23147 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
23148 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
23149 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
23150 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
23151 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
23152 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
23153 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
23154 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
23155 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
23156 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
23157 wmi_service[wmi_service_packet_power_save] =
23158 WMI_SERVICE_PACKET_POWER_SAVE;
23159 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
23160 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
23161 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
23162 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
23163 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
23164 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
23165 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
23166 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
23167 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
23168 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
23169 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
23170 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
23171 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
23172 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
23173 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
23174 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
23175 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
23176 wmi_service[wmi_service_mcc_bcn_interval_change] =
23177 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
23178 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
23179 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
23180 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
23181 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
23182 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
23183 wmi_service[wmi_service_lte_ant_share_support] =
23184 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
23185 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
23186 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
23187 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
23188 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
23189 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
23190 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
23191 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
23192 wmi_service[wmi_service_bcn_txrate_override] =
23193 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
23194 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
23195 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
23196 wmi_service[wmi_service_estimate_linkspeed] =
23197 WMI_SERVICE_ESTIMATE_LINKSPEED;
23198 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
23199 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
23200 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
23201 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
23202 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
23203 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
23204 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
23205 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
23206 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
23207 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
23208 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
23209 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
23210 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
23211 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
23212 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
23213 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
23214 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
23215 wmi_service[wmi_service_sap_auth_offload] =
23216 WMI_SERVICE_SAP_AUTH_OFFLOAD;
23217 wmi_service[wmi_service_dual_band_simultaneous_support] =
23218 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
23219 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
23220 wmi_service[wmi_service_ap_arpns_offload] =
23221 WMI_SERVICE_AP_ARPNS_OFFLOAD;
23222 wmi_service[wmi_service_per_band_chainmask_support] =
23223 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
23224 wmi_service[wmi_service_packet_filter_offload] =
23225 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
23226 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
23227 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
23228 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
23229 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
23230 wmi_service[wmi_service_multiple_vdev_restart] =
23231 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
23232
23233 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
23234 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
23235 wmi_service[wmi_service_smart_antenna_sw_support] =
23236 WMI_SERVICE_UNAVAILABLE;
23237 wmi_service[wmi_service_smart_antenna_hw_support] =
23238 WMI_SERVICE_UNAVAILABLE;
23239 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053023240 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023241 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053023242 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
23243 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
23244 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
23245 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
23246 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
23247 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
23248 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
23249 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053023250 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
23251 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
23252 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053023253 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023254 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
23255 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
23256 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
23257 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
23258 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
23259 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053023260 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
23261 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
23262 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
23263 wmi_service[wmi_service_unified_wow_capability] =
23264 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
23265 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
23266 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
23267 wmi_service[wmi_service_sync_delete_cmds] =
23268 WMI_SERVICE_SYNC_DELETE_CMDS;
23269 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
23270 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
23271 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
23272 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
23273 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
23274 wmi_service[wmi_service_deprecated_replace] =
23275 WMI_SERVICE_DEPRECATED_REPLACE;
23276 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
23277 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
23278 wmi_service[wmi_service_enhanced_mcast_filter] =
23279 WMI_SERVICE_ENHANCED_MCAST_FILTER;
23280 wmi_service[wmi_service_half_rate_quarter_rate_support] =
23281 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
23282 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
23283 wmi_service[wmi_service_p2p_listen_offload_support] =
23284 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
23285 wmi_service[wmi_service_mark_first_wakeup_packet] =
23286 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
23287 wmi_service[wmi_service_multiple_mcast_filter_set] =
23288 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
23289 wmi_service[wmi_service_host_managed_rx_reorder] =
23290 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
23291 wmi_service[wmi_service_flash_rdwr_support] =
23292 WMI_SERVICE_FLASH_RDWR_SUPPORT;
23293 wmi_service[wmi_service_wlan_stats_report] =
23294 WMI_SERVICE_WLAN_STATS_REPORT;
23295 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
23296 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
23297 wmi_service[wmi_service_dfs_phyerr_offload] =
23298 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
23299 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
23300 wmi_service[wmi_service_fw_mem_dump_support] =
23301 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
23302 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
23303 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
23304 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
23305 wmi_service[wmi_service_hw_data_filtering] =
23306 WMI_SERVICE_HW_DATA_FILTERING;
23307 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
23308 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053023309 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053023310 wmi_service[wmi_service_extended_nss_support] =
23311 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053023312 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053023313 wmi_service[wmi_service_bcn_offload_start_stop_support] =
23314 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053023315 wmi_service[wmi_service_offchan_data_tid_support] =
23316 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053023317 wmi_service[wmi_service_support_dma] =
23318 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023319 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
23320 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
23321 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053023322 wmi_service[wmi_service_11k_neighbour_report_support] =
23323 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080023324 wmi_service[wmi_service_ap_obss_detection_offload] =
23325 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
23326 wmi_service[wmi_service_bss_color_offload] =
23327 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053023328 wmi_service[wmi_service_gmac_offload_support] =
23329 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023330
Soumya Bhat488092d2017-03-22 14:41:01 +053023331}
23332
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023333#ifndef CONFIG_MCL
23334
Govind Singhe7f2f342016-05-23 12:12:52 +053023335/**
23336 * populate_pdev_param_tlv() - populates pdev params
23337 *
23338 * @param pdev_param: Pointer to hold pdev params
23339 * Return: None
23340 */
23341static void populate_pdev_param_tlv(uint32_t *pdev_param)
23342{
23343 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
23344 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
23345 pdev_param[wmi_pdev_param_txpower_limit2g] =
23346 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
23347 pdev_param[wmi_pdev_param_txpower_limit5g] =
23348 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
23349 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
23350 pdev_param[wmi_pdev_param_beacon_gen_mode] =
23351 WMI_PDEV_PARAM_BEACON_GEN_MODE;
23352 pdev_param[wmi_pdev_param_beacon_tx_mode] =
23353 WMI_PDEV_PARAM_BEACON_TX_MODE;
23354 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
23355 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
23356 pdev_param[wmi_pdev_param_protection_mode] =
23357 WMI_PDEV_PARAM_PROTECTION_MODE;
23358 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
23359 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
23360 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
23361 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
23362 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
23363 pdev_param[wmi_pdev_param_sta_kickout_th] =
23364 WMI_PDEV_PARAM_STA_KICKOUT_TH;
23365 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
23366 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
23367 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
23368 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
23369 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
23370 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
23371 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
23372 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
23373 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
23374 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
23375 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
23376 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
23377 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
23378 pdev_param[wmi_pdev_param_ltr_sleep_override] =
23379 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
23380 pdev_param[wmi_pdev_param_ltr_rx_override] =
23381 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
23382 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
23383 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
23384 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
23385 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
23386 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
23387 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
23388 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
23389 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
23390 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
23391 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
23392 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
23393 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
23394 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
23395 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
23396 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
23397 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
23398 pdev_param[wmi_pdev_param_peer_stats_update_period] =
23399 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
23400 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
23401 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
23402 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
23403 pdev_param[wmi_pdev_param_arp_ac_override] =
23404 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
23405 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
23406 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
23407 pdev_param[wmi_pdev_param_ani_poll_period] =
23408 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
23409 pdev_param[wmi_pdev_param_ani_listen_period] =
23410 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
23411 pdev_param[wmi_pdev_param_ani_ofdm_level] =
23412 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
23413 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
23414 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
23415 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
23416 pdev_param[wmi_pdev_param_idle_ps_config] =
23417 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
23418 pdev_param[wmi_pdev_param_power_gating_sleep] =
23419 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
23420 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
23421 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
23422 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
23423 pdev_param[wmi_pdev_param_hw_rfkill_config] =
23424 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
23425 pdev_param[wmi_pdev_param_low_power_rf_enable] =
23426 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
23427 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
23428 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
23429 pdev_param[wmi_pdev_param_power_collapse_enable] =
23430 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
23431 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
23432 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
23433 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
23434 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
23435 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
23436 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
23437 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
23438 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
23439 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
23440 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
23441 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
23442 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
23443 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
23444 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
23445 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
23446 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
23447 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
23448 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
23449 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
23450 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
23451 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
23452 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
23453 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
23454 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
23455 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
23456 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
23457 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
23458 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
23459 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
23460 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
23461 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
23462 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
23463 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
23464 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
23465 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
23466 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
23467 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
23468 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
23469 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23470 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23471 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23472 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23473 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23474 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023475 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23476 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23477 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023478 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23479 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023480 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023481 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023482 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23483 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23484 WMI_PDEV_PARAM_PROXY_STA_MODE;
23485 pdev_param[wmi_pdev_param_mu_group_policy] =
23486 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23487 pdev_param[wmi_pdev_param_noise_detection] =
23488 WMI_PDEV_PARAM_NOISE_DETECTION;
23489 pdev_param[wmi_pdev_param_noise_threshold] =
23490 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23491 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23492 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23493 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023494 pdev_param[wmi_pdev_param_atf_strict_sch] =
23495 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23496 pdev_param[wmi_pdev_param_atf_sched_duration] =
23497 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023498 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23499 pdev_param[wmi_pdev_param_sensitivity_level] =
23500 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23501 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23502 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23503 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23504 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023505 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23506 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23507 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23508 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023509 pdev_param[wmi_pdev_param_cca_threshold] =
23510 WMI_PDEV_PARAM_CCA_THRESHOLD;
23511 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23512 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023513 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023514 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23515 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23516 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23517 pdev_param[wmi_pdev_param_arp_srcaddr] =
23518 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23519 pdev_param[wmi_pdev_param_arp_dstaddr] =
23520 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23521 pdev_param[wmi_pdev_param_txpower_decr_db] =
23522 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023523 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23524 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023525 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23526 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023527 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023528 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023529 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23530 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023531 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23532 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023533 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23534 WMI_UNAVAILABLE_PARAM;
23535 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
23536 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023537 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23538 pdev_param[wmi_pdev_param_block_interbss] =
23539 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023540 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023541 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23542 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23543 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023544 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023545 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023546 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23547 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023548 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023549 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23550 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023551 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23552 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23553 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23554 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
23555 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
23556 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23557 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23558 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23559 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23560 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23561 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23562 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23563 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23564 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23565 pdev_param[wmi_pdev_param_fast_channel_reset] =
23566 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23567 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023568 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023569 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023570}
23571
23572/**
23573 * populate_vdev_param_tlv() - populates vdev params
23574 *
23575 * @param vdev_param: Pointer to hold vdev params
23576 * Return: None
23577 */
23578static void populate_vdev_param_tlv(uint32_t *vdev_param)
23579{
23580 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23581 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23582 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23583 vdev_param[wmi_vdev_param_beacon_interval] =
23584 WMI_VDEV_PARAM_BEACON_INTERVAL;
23585 vdev_param[wmi_vdev_param_listen_interval] =
23586 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23587 vdev_param[wmi_vdev_param_multicast_rate] =
23588 WMI_VDEV_PARAM_MULTICAST_RATE;
23589 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23590 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23591 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23592 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23593 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23594 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23595 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23596 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23597 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23598 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23599 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23600 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23601 vdev_param[wmi_vdev_param_bmiss_count_max] =
23602 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23603 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23604 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23605 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23606 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23607 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23608 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23609 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23610 vdev_param[wmi_vdev_param_disable_htprotection] =
23611 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23612 vdev_param[wmi_vdev_param_sta_quickkickout] =
23613 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23614 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23615 vdev_param[wmi_vdev_param_protection_mode] =
23616 WMI_VDEV_PARAM_PROTECTION_MODE;
23617 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23618 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23619 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23620 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23621 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23622 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23623 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23624 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23625 vdev_param[wmi_vdev_param_bcast_data_rate] =
23626 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23627 vdev_param[wmi_vdev_param_mcast_data_rate] =
23628 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23629 vdev_param[wmi_vdev_param_mcast_indicate] =
23630 WMI_VDEV_PARAM_MCAST_INDICATE;
23631 vdev_param[wmi_vdev_param_dhcp_indicate] =
23632 WMI_VDEV_PARAM_DHCP_INDICATE;
23633 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23634 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23635 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23636 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23637 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23638 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23639 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23640 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23641 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23642 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23643 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23644 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23645 vdev_param[wmi_vdev_param_packet_powersave] =
23646 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23647 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23648 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23649 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23650 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23651 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23652 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23653 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23654 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23655 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23656 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23657 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23658 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23659 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23660 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23661 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23662 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23663 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23664 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23665 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23666 vdev_param[wmi_vdev_param_roam_fw_offload] =
23667 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23668 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23669 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23670 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23671 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23672 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23673 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23674 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23675 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23676 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23677 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23678 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23679 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23680 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23681 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23682 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23683 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23684 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23685 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23686 vdev_param[wmi_vdev_param_inactivity_cnt] =
23687 WMI_VDEV_PARAM_INACTIVITY_CNT;
23688 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23689 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23690 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23691 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23692 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23693 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23694 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23695 vdev_param[wmi_vdev_param_rx_leak_window] =
23696 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23697 vdev_param[wmi_vdev_param_stats_avg_factor] =
23698 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23699 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23700 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23701 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23702 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23703 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23704 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023705 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23706 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023707 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023708 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23709 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23710 WMI_VDEV_PARAM_HE_RANGE_EXT;
23711 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23712 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023713 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023714 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23715 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23716 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23717 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23718 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23719 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23720 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023721 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23722 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23723 vdev_param[wmi_vdev_param_rc_num_retries] =
23724 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23725 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23726 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23727 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23728 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23729 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23730 vdev_param[wmi_vdev_param_vht80_ratemask] =
23731 WMI_VDEV_PARAM_VHT80_RATEMASK;
23732 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23733 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23734 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika88e11832017-09-18 15:59:34 -070023735 vdev_param[wmi_vdev_param_set_he_ltf] = WMI_VDEV_PARAM_HE_LTF;
Sathish Kumar6011c742017-11-08 14:49:58 +053023736 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23737 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023738 vdev_param[wmi_vdev_param_set_ba_mode] =
23739 WMI_VDEV_PARAM_BA_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023740}
23741#endif
23742
Govind Singh5eb51532016-03-09 11:34:12 +053023743/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023744 * populate_target_defines_tlv() - Populate target defines and params
23745 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023746 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023747 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023748 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023749#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023750static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023751{
Govind Singhe7f2f342016-05-23 12:12:52 +053023752 populate_pdev_param_tlv(wmi_handle->pdev_param);
23753 populate_vdev_param_tlv(wmi_handle->vdev_param);
23754}
23755#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023756static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23757{ }
23758#endif
23759
23760/**
Zhang Qian537fca62018-01-03 16:33:24 +080023761 * wmi_ocb_ut_attach() - Attach OCB test framework
23762 * @wmi_handle: wmi handle
23763 *
23764 * Return: None
23765 */
23766#ifdef WLAN_OCB_UT
23767void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23768#else
23769static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23770{
23771 return;
23772}
23773#endif
23774
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023775/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023776 * wmi_tlv_attach() - Attach TLV APIs
23777 *
23778 * Return: None
23779 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023780void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023781{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023782 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023783 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023784 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023785#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023786 /* Skip saving WMI_CMD_HDR and TLV HDR */
23787 wmi_handle->log_info.buf_offset_command = 8;
23788 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023789 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023790#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023791 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023792 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023793 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023794}
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023795EXPORT_SYMBOL(wmi_tlv_attach);
23796
23797/**
23798 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23799 *
23800 * Return: None
23801 */
23802void wmi_tlv_init(void)
23803{
23804 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23805}