blob: c001dfe05ae9c387a57072803cbdf53ab0f51ad3 [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"
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080033#include <qdf_module.h>
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053034#include <wlan_defs.h>
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053035#include <htc_services.h>
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053036
Wu Gaocd3a8512017-03-13 20:17:34 +080037#ifdef CONVERGED_P2P_ENABLE
38#include "wlan_p2p_public_struct.h"
39#endif
Dustin Brownf31f88b2017-05-12 14:01:44 -070040#ifdef WLAN_PMO_ENABLE
41#include "wlan_pmo_hw_filter_public_struct.h"
42#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053043#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053044#ifdef WLAN_SUPPORT_GREEN_AP
45#include "wlan_green_ap_api.h"
46#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053047
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080048#ifdef WLAN_FEATURE_NAN_CONVERGENCE
49#include "nan_public_structs.h"
50#endif
51
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053052/* HTC service ids for WMI for multi-radio */
53static const uint32_t multi_svc_ids[] = {WMI_CONTROL_SVC,
54 WMI_CONTROL_SVC_WMAC1,
55 WMI_CONTROL_SVC_WMAC2};
56
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053057/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
58 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053059 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053060 * @cmd: pointer target vdev create command buffer
61 * @param: pointer host params for vdev create
62 *
63 * Return: None
64 */
65#ifdef CONFIG_MCL
66static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053067 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053068 wmi_vdev_create_cmd_fixed_param * cmd,
69 struct vdev_create_params *param)
70{
71 cmd->pdev_id = WMI_PDEV_ID_SOC;
72}
73#else
74static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053075 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053076 wmi_vdev_create_cmd_fixed_param * cmd,
77 struct vdev_create_params *param)
78{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053079 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
80 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053081}
82#endif
83
Govind Singh5eb51532016-03-09 11:34:12 +053084/**
85 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
86 * @wmi_handle: wmi handle
87 * @param: pointer to hold vdev create parameter
88 * @macaddr: vdev mac address
89 *
Govind Singhe7f2f342016-05-23 12:12:52 +053090 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053091 */
Sathish Kumarfd347372017-02-13 12:29:09 +053092static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053093 uint8_t macaddr[IEEE80211_ADDR_LEN],
94 struct vdev_create_params *param)
95{
96 wmi_vdev_create_cmd_fixed_param *cmd;
97 wmi_buf_t buf;
98 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053099 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700100 int num_bands = 2;
101 uint8_t *buf_ptr;
102 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +0530103
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700104 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530105 buf = wmi_buf_alloc(wmi_handle, len);
106 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530107 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530108 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530109 }
110 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
111 WMITLV_SET_HDR(&cmd->tlv_header,
112 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
113 WMITLV_GET_STRUCT_TLVLEN
114 (wmi_vdev_create_cmd_fixed_param));
115 cmd->vdev_id = param->if_id;
116 cmd->vdev_type = param->type;
117 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700118 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530119 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530120 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700121 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
122 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530123 macaddr[0], macaddr[1], macaddr[2],
124 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700125 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
126 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
127 (num_bands * sizeof(wmi_vdev_txrx_streams)));
128 buf_ptr += WMI_TLV_HDR_SIZE;
129
Govind Singh224a7312016-06-21 14:33:26 +0530130 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700131 param->type, param->subtype,
132 param->nss_2g, param->nss_5g);
133 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
134 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
135 txrx_streams->supported_tx_streams = param->nss_2g;
136 txrx_streams->supported_rx_streams = param->nss_2g;
137 WMITLV_SET_HDR(&txrx_streams->tlv_header,
138 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
139 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
140
141 txrx_streams++;
142 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
143 txrx_streams->supported_tx_streams = param->nss_5g;
144 txrx_streams->supported_rx_streams = param->nss_5g;
145 WMITLV_SET_HDR(&txrx_streams->tlv_header,
146 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
147 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530148 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530149 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530150 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530151 wmi_buf_free(buf);
152 }
153
154 return ret;
155}
156
157/**
158 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
159 * @wmi_handle: wmi handle
160 * @if_id: vdev id
161 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530162 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530163 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530164static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530165 uint8_t if_id)
166{
167 wmi_vdev_delete_cmd_fixed_param *cmd;
168 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530169 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530170
171 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
172 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530173 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530174 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530175 }
176
177 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
178 WMITLV_SET_HDR(&cmd->tlv_header,
179 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
180 WMITLV_GET_STRUCT_TLVLEN
181 (wmi_vdev_delete_cmd_fixed_param));
182 cmd->vdev_id = if_id;
183 ret = wmi_unified_cmd_send(wmi_handle, buf,
184 sizeof(wmi_vdev_delete_cmd_fixed_param),
185 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530186 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530187 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530188 wmi_buf_free(buf);
189 }
Govind Singhb53420c2016-03-09 14:32:57 +0530190 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530191
192 return ret;
193}
194
195/**
196 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
197 * @wmi: wmi handle
198 * @vdev_id: vdev id
199 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530200 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530201 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530202static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530203 uint8_t vdev_id)
204{
205 wmi_vdev_stop_cmd_fixed_param *cmd;
206 wmi_buf_t buf;
207 int32_t len = sizeof(*cmd);
208
209 buf = wmi_buf_alloc(wmi, len);
210 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530211 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530212 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530213 }
214 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
215 WMITLV_SET_HDR(&cmd->tlv_header,
216 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
217 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
218 cmd->vdev_id = vdev_id;
219 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530220 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530221 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530222 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530223 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530224 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530225
226 return 0;
227}
228
229/**
230 * send_vdev_down_cmd_tlv() - send vdev down command to fw
231 * @wmi: wmi handle
232 * @vdev_id: vdev id
233 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530234 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530235 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530236static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530237{
238 wmi_vdev_down_cmd_fixed_param *cmd;
239 wmi_buf_t buf;
240 int32_t len = sizeof(*cmd);
241
242 buf = wmi_buf_alloc(wmi, len);
243 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530244 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530245 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530246 }
247 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
248 WMITLV_SET_HDR(&cmd->tlv_header,
249 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
250 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
251 cmd->vdev_id = vdev_id;
252 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530253 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530254 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530255 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530256 }
Govind Singhb53420c2016-03-09 14:32:57 +0530257 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530258
259 return 0;
260}
261
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530262#ifdef CONFIG_MCL
263static inline void copy_channel_info(
264 wmi_vdev_start_request_cmd_fixed_param * cmd,
265 wmi_channel *chan,
266 struct vdev_start_params *req)
267{
268 chan->mhz = req->chan_freq;
269
270 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
271
272 chan->band_center_freq1 = req->band_center_freq1;
273 chan->band_center_freq2 = req->band_center_freq2;
274
275 if (req->is_half_rate)
276 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
277 else if (req->is_quarter_rate)
278 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
279
Naveen Rawat44f2f432016-12-01 12:58:57 -0800280 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530281 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
282 cmd->disable_hw_ack = req->dis_hw_ack;
283 }
284
285 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
286 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
287
288}
289#else
290static inline void copy_channel_info(
291 wmi_vdev_start_request_cmd_fixed_param * cmd,
292 wmi_channel *chan,
293 struct vdev_start_params *req)
294{
295 chan->mhz = req->channel.mhz;
296
297 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
298
299 chan->band_center_freq1 = req->channel.cfreq1;
300 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800301 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530302
303 if (req->channel.half_rate)
304 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
305 else if (req->channel.quarter_rate)
306 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
307
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800308 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
309
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530310 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530311 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530312 cmd->disable_hw_ack = req->disable_hw_ack;
313 }
314
Krishna Rao0b952ea2017-03-20 13:30:10 +0530315 if (req->channel.dfs_set_cfreq2)
316 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
317
Kai Chen4710d462017-12-15 14:06:06 -0800318 /* According to firmware both reg power and max tx power
319 * on set channel power is used and set it to max reg
320 * power from regulatory.
321 */
322 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
323 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530324 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800325 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
326 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
327 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530328
329}
330#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530331/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530332 * send_vdev_start_cmd_tlv() - send vdev start request to fw
333 * @wmi_handle: wmi handle
334 * @req: vdev start params
335 *
336 * Return: QDF status
337 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530338static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530339 struct vdev_start_params *req)
340{
341 wmi_vdev_start_request_cmd_fixed_param *cmd;
342 wmi_buf_t buf;
343 wmi_channel *chan;
344 int32_t len, ret;
345 uint8_t *buf_ptr;
346
347 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
348 buf = wmi_buf_alloc(wmi_handle, len);
349 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530350 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530351 return QDF_STATUS_E_NOMEM;
352 }
353 buf_ptr = (uint8_t *) wmi_buf_data(buf);
354 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
355 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
356 WMITLV_SET_HDR(&cmd->tlv_header,
357 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
358 WMITLV_GET_STRUCT_TLVLEN
359 (wmi_vdev_start_request_cmd_fixed_param));
360 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
361 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
362 cmd->vdev_id = req->vdev_id;
363
364 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530365 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530366
367 cmd->beacon_interval = req->beacon_intval;
368 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530369
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800370 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
371 if (req->bcn_tx_rate_code)
372 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
373
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530374 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530375 cmd->beacon_interval = req->beacon_intval;
376 cmd->dtim_period = req->dtim_period;
377
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530378 /* Copy the SSID */
379 if (req->ssid.length) {
380 if (req->ssid.length < sizeof(cmd->ssid.ssid))
381 cmd->ssid.ssid_len = req->ssid.length;
382 else
383 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
384 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
385 cmd->ssid.ssid_len);
386 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530387
388 if (req->hidden_ssid)
389 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
390
391 if (req->pmf_enabled)
392 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530393 }
394
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700395 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530396 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530397 cmd->preferred_rx_streams = req->preferred_rx_streams;
398 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700399 cmd->cac_duration_ms = req->cac_duration_ms;
400 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700401 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530402
403 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
404 sizeof(wmi_channel));
405 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
406 cmd->num_noa_descriptors *
407 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800408 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530409 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
410 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800411 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
412 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
413 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530414 req->is_dfs, req->beacon_intval, cmd->dtim_period,
415 chan->band_center_freq1, chan->band_center_freq2,
416 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700417 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700418 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800419 req->regdomain, req->he_ops,
420 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530421
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530422 if (req->is_restart)
423 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
424 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530425 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530426 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
427 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530428 if (ret) {
429 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530430 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530431 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530432 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530433
434 return QDF_STATUS_SUCCESS;
435}
436
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530437/**
438 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
439 * @wmi_handle: wmi handle
440 * @restart_params: vdev restart params
441 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530442 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530443 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530444static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530445 struct hidden_ssid_vdev_restart_params *restart_params)
446{
447 wmi_vdev_start_request_cmd_fixed_param *cmd;
448 wmi_buf_t buf;
449 wmi_channel *chan;
450 int32_t len;
451 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530452 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530453
454 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
455 buf = wmi_buf_alloc(wmi_handle, len);
456 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530457 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530458 return QDF_STATUS_E_NOMEM;
459 }
460 buf_ptr = (uint8_t *) wmi_buf_data(buf);
461 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
462 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
463
464 WMITLV_SET_HDR(&cmd->tlv_header,
465 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
466 WMITLV_GET_STRUCT_TLVLEN
467 (wmi_vdev_start_request_cmd_fixed_param));
468
469 WMITLV_SET_HDR(&chan->tlv_header,
470 WMITLV_TAG_STRUC_wmi_channel,
471 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
472
473 cmd->vdev_id = restart_params->session_id;
474 cmd->ssid.ssid_len = restart_params->ssid_len;
475 qdf_mem_copy(cmd->ssid.ssid,
476 restart_params->ssid,
477 cmd->ssid.ssid_len);
478 cmd->flags = restart_params->flags;
479 cmd->requestor_id = restart_params->requestor_id;
480 cmd->disable_hw_ack = restart_params->disable_hw_ack;
481
482 chan->mhz = restart_params->mhz;
483 chan->band_center_freq1 =
484 restart_params->band_center_freq1;
485 chan->band_center_freq2 =
486 restart_params->band_center_freq2;
487 chan->info = restart_params->info;
488 chan->reg_info_1 = restart_params->reg_info_1;
489 chan->reg_info_2 = restart_params->reg_info_2;
490
491 cmd->num_noa_descriptors = 0;
492 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
493 sizeof(wmi_channel));
494 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
495 cmd->num_noa_descriptors *
496 sizeof(wmi_p2p_noa_descriptor));
497
498 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
499 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530500 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530501 wmi_buf_free(buf);
502 return QDF_STATUS_E_FAILURE;
503 }
504 return QDF_STATUS_SUCCESS;
505}
506
507
508/**
Govind Singh5eb51532016-03-09 11:34:12 +0530509 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
510 * @wmi: wmi handle
511 * @peer_addr: peer mac address
512 * @param: pointer to hold peer flush tid parameter
513 *
514 * Return: 0 for sucess or error code
515 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530516static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530517 uint8_t peer_addr[IEEE80211_ADDR_LEN],
518 struct peer_flush_params *param)
519{
520 wmi_peer_flush_tids_cmd_fixed_param *cmd;
521 wmi_buf_t buf;
522 int32_t len = sizeof(*cmd);
523
524 buf = wmi_buf_alloc(wmi, len);
525 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530526 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530527 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530528 }
529 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
530 WMITLV_SET_HDR(&cmd->tlv_header,
531 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
532 WMITLV_GET_STRUCT_TLVLEN
533 (wmi_peer_flush_tids_cmd_fixed_param));
534 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
535 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
536 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530537 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530538 peer_addr, param->vdev_id,
539 param->peer_tid_bitmap);
540 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530541 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530542 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530543 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530544 }
545
546 return 0;
547}
548
549/**
550 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
551 * @wmi: wmi handle
552 * @peer_addr: peer mac addr
553 * @vdev_id: vdev id
554 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530555 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530556 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530557static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530558 uint8_t peer_addr[IEEE80211_ADDR_LEN],
559 uint8_t vdev_id)
560{
561 wmi_peer_delete_cmd_fixed_param *cmd;
562 wmi_buf_t buf;
563 int32_t len = sizeof(*cmd);
564 buf = wmi_buf_alloc(wmi, len);
565 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530566 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530567 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530568 }
569 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
570 WMITLV_SET_HDR(&cmd->tlv_header,
571 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
572 WMITLV_GET_STRUCT_TLVLEN
573 (wmi_peer_delete_cmd_fixed_param));
574 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
575 cmd->vdev_id = vdev_id;
576
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800577 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530578 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530579 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530580 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530581 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530582 }
Govind Singh5eb51532016-03-09 11:34:12 +0530583
584 return 0;
585}
586
587/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530588 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
589 * to target id.
590 * @targ_paramid: Target parameter id to hold the result.
591 * @peer_param_id: host param id.
592 *
593 * Return: QDF_STATUS_SUCCESS for success
594 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
595 */
596#ifdef CONFIG_MCL
597static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
598 uint32_t *targ_paramid,
599 uint32_t peer_param_id)
600{
601 *targ_paramid = peer_param_id;
602 return QDF_STATUS_SUCCESS;
603}
604#else
605static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
606 uint32_t *targ_paramid,
607 uint32_t peer_param_id)
608{
609 switch (peer_param_id) {
610 case WMI_HOST_PEER_MIMO_PS_STATE:
611 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
612 break;
613 case WMI_HOST_PEER_AMPDU:
614 *targ_paramid = WMI_PEER_AMPDU;
615 break;
616 case WMI_HOST_PEER_AUTHORIZE:
617 *targ_paramid = WMI_PEER_AUTHORIZE;
618 break;
619 case WMI_HOST_PEER_CHWIDTH:
620 *targ_paramid = WMI_PEER_CHWIDTH;
621 break;
622 case WMI_HOST_PEER_NSS:
623 *targ_paramid = WMI_PEER_NSS;
624 break;
625 case WMI_HOST_PEER_USE_4ADDR:
626 *targ_paramid = WMI_PEER_USE_4ADDR;
627 break;
628 case WMI_HOST_PEER_MEMBERSHIP:
629 *targ_paramid = WMI_PEER_MEMBERSHIP;
630 break;
631 case WMI_HOST_PEER_USERPOS:
632 *targ_paramid = WMI_PEER_USERPOS;
633 break;
634 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
635 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
636 break;
637 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
638 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
639 break;
640 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
641 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
642 break;
643 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
644 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
645 break;
646 case WMI_HOST_PEER_PHYMODE:
647 *targ_paramid = WMI_PEER_PHYMODE;
648 break;
649 case WMI_HOST_PEER_USE_FIXED_PWR:
650 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
651 break;
652 case WMI_HOST_PEER_PARAM_FIXED_RATE:
653 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
654 break;
655 case WMI_HOST_PEER_SET_MU_WHITELIST:
656 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
657 break;
658 case WMI_HOST_PEER_SET_MAC_TX_RATE:
659 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
660 break;
661 case WMI_HOST_PEER_SET_MIN_TX_RATE:
662 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
663 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530664 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
665 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
666 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530667 case WMI_HOST_PEER_NSS_VHT160:
668 *targ_paramid = WMI_PEER_NSS_VHT160;
669 break;
670 case WMI_HOST_PEER_NSS_VHT80_80:
671 *targ_paramid = WMI_PEER_NSS_VHT80_80;
672 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530673 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
674 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
675 break;
676 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
677 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
678 break;
679 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
680 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
681 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530682 case WMI_HOST_PEER_PARAM_MU_ENABLE:
683 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
684 break;
685 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
686 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
687 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530688 default:
689 return QDF_STATUS_E_NOSUPPORT;
690 }
691
692 return QDF_STATUS_SUCCESS;
693}
694#endif
695/**
Govind Singh5eb51532016-03-09 11:34:12 +0530696 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530697 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530698 * @peer_addr: peer mac address
699 * @param : pointer to hold peer set parameter
700 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530701 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530702 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530703static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530704 uint8_t peer_addr[IEEE80211_ADDR_LEN],
705 struct peer_set_params *param)
706{
707 wmi_peer_set_param_cmd_fixed_param *cmd;
708 wmi_buf_t buf;
709 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530710 uint32_t param_id;
711
712 if (convert_host_peer_id_to_target_id_tlv(&param_id,
713 param->param_id) != QDF_STATUS_SUCCESS)
714 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530715
716 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
717 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530718 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530719 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530720 }
721 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
722 WMITLV_SET_HDR(&cmd->tlv_header,
723 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
724 WMITLV_GET_STRUCT_TLVLEN
725 (wmi_peer_set_param_cmd_fixed_param));
726 cmd->vdev_id = param->vdev_id;
727 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530728 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530729 cmd->param_value = param->param_value;
730 err = wmi_unified_cmd_send(wmi, buf,
731 sizeof(wmi_peer_set_param_cmd_fixed_param),
732 WMI_PEER_SET_PARAM_CMDID);
733 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530734 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530735 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530736 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530737 }
738
739 return 0;
740}
741
742/**
743 * send_vdev_up_cmd_tlv() - send vdev up command in fw
744 * @wmi: wmi handle
745 * @bssid: bssid
746 * @vdev_up_params: pointer to hold vdev up parameter
747 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530748 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530749 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530750static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530751 uint8_t bssid[IEEE80211_ADDR_LEN],
752 struct vdev_up_params *params)
753{
754 wmi_vdev_up_cmd_fixed_param *cmd;
755 wmi_buf_t buf;
756 int32_t len = sizeof(*cmd);
757
Govind Singhb53420c2016-03-09 14:32:57 +0530758 WMI_LOGD("%s: VDEV_UP", __func__);
759 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530760 params->vdev_id, params->assoc_id, bssid);
761 buf = wmi_buf_alloc(wmi, len);
762 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530763 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530764 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530765 }
766 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
767 WMITLV_SET_HDR(&cmd->tlv_header,
768 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
769 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
770 cmd->vdev_id = params->vdev_id;
771 cmd->vdev_assoc_id = params->assoc_id;
772 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
773 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530774 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530775 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530776 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530777 }
778
779 return 0;
780}
781
782/**
783 * send_peer_create_cmd_tlv() - send peer create command to fw
784 * @wmi: wmi handle
785 * @peer_addr: peer mac address
786 * @peer_type: peer type
787 * @vdev_id: vdev id
788 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530789 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530790 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530791static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530792 struct peer_create_params *param)
793{
794 wmi_peer_create_cmd_fixed_param *cmd;
795 wmi_buf_t buf;
796 int32_t len = sizeof(*cmd);
797
798 buf = wmi_buf_alloc(wmi, len);
799 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530800 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530801 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530802 }
803 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
804 WMITLV_SET_HDR(&cmd->tlv_header,
805 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
806 WMITLV_GET_STRUCT_TLVLEN
807 (wmi_peer_create_cmd_fixed_param));
808 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
809 cmd->peer_type = param->peer_type;
810 cmd->vdev_id = param->vdev_id;
811
812 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530813 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530814 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530815 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530816 }
Govind Singhb53420c2016-03-09 14:32:57 +0530817 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530818 param->vdev_id);
819
820 return 0;
821}
822
823/**
Leo Changeee40872016-09-28 13:43:36 -0700824 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
825 * command to fw
826 * @wmi: wmi handle
827 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
828 *
829 * Return: 0 for success or error code
830 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700831static
Leo Changeee40872016-09-28 13:43:36 -0700832QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
833 struct rx_reorder_queue_setup_params *param)
834{
835 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
836 wmi_buf_t buf;
837 int32_t len = sizeof(*cmd);
838
839 buf = wmi_buf_alloc(wmi, len);
840 if (!buf) {
841 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
842 return QDF_STATUS_E_NOMEM;
843 }
844 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
845 WMITLV_SET_HDR(&cmd->tlv_header,
846 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
847 WMITLV_GET_STRUCT_TLVLEN
848 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
849 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
850 cmd->vdev_id = param->vdev_id;
851 cmd->tid = param->tid;
852 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
853 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
854 cmd->queue_no = param->queue_no;
855
856 if (wmi_unified_cmd_send(wmi, buf, len,
857 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
858 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
859 __func__);
860 qdf_nbuf_free(buf);
861 return QDF_STATUS_E_FAILURE;
862 }
863 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
864 param->peer_macaddr, param->vdev_id, param->tid);
865
866 return QDF_STATUS_SUCCESS;
867}
868
869/**
870 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
871 * command to fw
872 * @wmi: wmi handle
873 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
874 *
875 * Return: 0 for success or error code
876 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700877static
Leo Changeee40872016-09-28 13:43:36 -0700878QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
879 struct rx_reorder_queue_remove_params *param)
880{
881 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
882 wmi_buf_t buf;
883 int32_t len = sizeof(*cmd);
884
885 buf = wmi_buf_alloc(wmi, len);
886 if (!buf) {
887 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
888 return QDF_STATUS_E_NOMEM;
889 }
890 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
891 wmi_buf_data(buf);
892 WMITLV_SET_HDR(&cmd->tlv_header,
893 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
894 WMITLV_GET_STRUCT_TLVLEN
895 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
896 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
897 cmd->vdev_id = param->vdev_id;
898 cmd->tid_mask = param->peer_tid_bitmap;
899
900 if (wmi_unified_cmd_send(wmi, buf, len,
901 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
902 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
903 __func__);
904 qdf_nbuf_free(buf);
905 return QDF_STATUS_E_FAILURE;
906 }
907 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
908 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
909
910 return QDF_STATUS_SUCCESS;
911}
912
913/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530914 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
915 * @wmi_handle: wmi handle
916 * @param: pointer holding peer details
917 *
918 * Return: 0 for success or error code
919 */
920static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
921 struct peer_add_wds_entry_params *param)
922{
923 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
924 wmi_buf_t buf;
925 int len = sizeof(*cmd);
926
927 buf = wmi_buf_alloc(wmi_handle, len);
928 if (!buf) {
929 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
930 return QDF_STATUS_E_FAILURE;
931 }
932 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
933 WMITLV_SET_HDR(&cmd->tlv_header,
934 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
935 WMITLV_GET_STRUCT_TLVLEN
936 (wmi_peer_add_wds_entry_cmd_fixed_param));
937 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
938 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800939 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
940 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530941
942 return wmi_unified_cmd_send(wmi_handle, buf, len,
943 WMI_PEER_ADD_WDS_ENTRY_CMDID);
944}
945
946/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530947 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530948 * @wmi_handle: wmi handle
949 * @param: pointer holding peer details
950 *
951 * Return: 0 for success or error code
952 */
953static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
954 struct peer_del_wds_entry_params *param)
955{
956 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
957 wmi_buf_t buf;
958 int len = sizeof(*cmd);
959
960 buf = wmi_buf_alloc(wmi_handle, len);
961 if (!buf) {
962 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
963 return QDF_STATUS_E_NOMEM;
964 }
965 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
966 WMITLV_SET_HDR(&cmd->tlv_header,
967 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
968 WMITLV_GET_STRUCT_TLVLEN
969 (wmi_peer_remove_wds_entry_cmd_fixed_param));
970 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800971 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530972 return wmi_unified_cmd_send(wmi_handle, buf, len,
973 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
974}
975
976/**
977 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
978 * @wmi_handle: wmi handle
979 * @param: pointer holding peer details
980 *
981 * Return: 0 for success or error code
982 */
983static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
984 struct peer_update_wds_entry_params *param)
985{
986 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
987 wmi_buf_t buf;
988 int len = sizeof(*cmd);
989
990 buf = wmi_buf_alloc(wmi_handle, len);
991 if (!buf) {
992 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
993 return QDF_STATUS_E_NOMEM;
994 }
995
996 /* wmi_buf_alloc returns zeroed command buffer */
997 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
998 WMITLV_SET_HDR(&cmd->tlv_header,
999 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
1000 WMITLV_GET_STRUCT_TLVLEN
1001 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001002 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1003 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301004 if (param->wds_macaddr)
1005 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
1006 &cmd->wds_macaddr);
1007 if (param->peer_macaddr)
1008 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1009 &cmd->peer_macaddr);
1010 return wmi_unified_cmd_send(wmi_handle, buf, len,
1011 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1012}
1013
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001014/**
1015 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1016 * @wmi_handle: wmi handle
1017 * @param: pointer to get tpc config params
1018 *
1019 * Return: 0 for success or error code
1020 */
1021static QDF_STATUS
1022send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1023 uint32_t param)
1024{
1025 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1026 wmi_buf_t buf;
1027 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1028
1029 buf = wmi_buf_alloc(wmi_handle, len);
1030 if (!buf) {
1031 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1032 return QDF_STATUS_E_NOMEM;
1033 }
1034 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1035 WMITLV_SET_HDR(&cmd->tlv_header,
1036 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1037 WMITLV_GET_STRUCT_TLVLEN
1038 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1039
1040 cmd->param = param;
1041 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1042 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1043 WMI_LOGE("Send pdev get tpc config cmd failed");
1044 wmi_buf_free(buf);
1045 return QDF_STATUS_E_FAILURE;
1046
1047 }
1048 WMI_LOGD("%s:send success", __func__);
1049
1050 return QDF_STATUS_SUCCESS;
1051}
1052
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301053#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301054/**
Govind Singh5eb51532016-03-09 11:34:12 +05301055 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1056 * @wmi_handle: wmi handle
1057 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301058 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301059 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301060 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301061 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301062static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301063 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301064{
1065 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1066 wmi_buf_t buf;
1067 int32_t len = sizeof(*cmd);
1068
Govind Singhb53420c2016-03-09 14:32:57 +05301069 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301070
1071 buf = wmi_buf_alloc(wmi_handle, len);
1072 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301073 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301074 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301075 }
1076
1077 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1078 WMITLV_SET_HDR(&cmd->tlv_header,
1079 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1080 WMITLV_GET_STRUCT_TLVLEN
1081 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301082 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301083 cmd->enable = value;
1084
1085 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1086 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301087 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301088 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301089 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301090 }
1091
1092 return 0;
1093}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301094#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301095
1096/**
1097 * send_pdev_utf_cmd_tlv() - send utf command to fw
1098 * @wmi_handle: wmi handle
1099 * @param: pointer to pdev_utf_params
1100 * @mac_id: mac id to have radio context
1101 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301102 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301103 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301104static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301105send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1106 struct pdev_utf_params *param,
1107 uint8_t mac_id)
1108{
1109 wmi_buf_t buf;
1110 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001111 /* if param->len is 0 no data is sent, return error */
1112 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301113 static uint8_t msgref = 1;
1114 uint8_t segNumber = 0, segInfo, numSegments;
1115 uint16_t chunk_len, total_bytes;
1116 uint8_t *bufpos;
1117 struct seg_hdr_info segHdrInfo;
1118
1119 bufpos = param->utf_payload;
1120 total_bytes = param->len;
1121 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1122 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1123 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1124
1125 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1126 numSegments++;
1127
1128 while (param->len) {
1129 if (param->len > MAX_WMI_UTF_LEN)
1130 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1131 else
1132 chunk_len = param->len;
1133
1134 buf = wmi_buf_alloc(wmi_handle,
1135 (chunk_len + sizeof(segHdrInfo) +
1136 WMI_TLV_HDR_SIZE));
1137 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301138 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301139 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301140 }
1141
1142 cmd = (uint8_t *) wmi_buf_data(buf);
1143
1144 segHdrInfo.len = total_bytes;
1145 segHdrInfo.msgref = msgref;
1146 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1147 segHdrInfo.segmentInfo = segInfo;
1148 segHdrInfo.pad = 0;
1149
Govind Singhb53420c2016-03-09 14:32:57 +05301150 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301151 " segHdrInfo.segmentInfo = %d",
1152 __func__, segHdrInfo.len, segHdrInfo.msgref,
1153 segHdrInfo.segmentInfo);
1154
Govind Singhb53420c2016-03-09 14:32:57 +05301155 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301156 "chunk len %d", __func__, total_bytes, segNumber,
1157 numSegments, chunk_len);
1158
1159 segNumber++;
1160
1161 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1162 (chunk_len + sizeof(segHdrInfo)));
1163 cmd += WMI_TLV_HDR_SIZE;
1164 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1165 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1166
1167 ret = wmi_unified_cmd_send(wmi_handle, buf,
1168 (chunk_len + sizeof(segHdrInfo) +
1169 WMI_TLV_HDR_SIZE),
1170 WMI_PDEV_UTF_CMDID);
1171
Govind Singh67922e82016-04-01 16:48:57 +05301172 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301173 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301174 wmi_buf_free(buf);
1175 break;
1176 }
1177
1178 param->len -= chunk_len;
1179 bufpos += chunk_len;
1180 }
1181
1182 msgref++;
1183
1184 return ret;
1185}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301186#ifdef CONFIG_MCL
1187static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1188 uint32_t host_param)
1189{
1190 return host_param;
1191}
1192#else
1193static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1194 uint32_t host_param)
1195{
1196 if (host_param < wmi_pdev_param_max)
1197 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301198
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301199 return WMI_UNAVAILABLE_PARAM;
1200}
1201#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301202/**
1203 * send_pdev_param_cmd_tlv() - set pdev parameters
1204 * @wmi_handle: wmi handle
1205 * @param: pointer to pdev parameter
1206 * @mac_id: radio context
1207 *
1208 * Return: 0 on success, errno on failure
1209 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301210static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301211send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1212 struct pdev_params *param,
1213 uint8_t mac_id)
1214{
Govind Singh67922e82016-04-01 16:48:57 +05301215 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301216 wmi_pdev_set_param_cmd_fixed_param *cmd;
1217 wmi_buf_t buf;
1218 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301219 uint32_t pdev_param;
1220
1221 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1222 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1223 WMI_LOGW("%s: Unavailable param %d\n",
1224 __func__, param->param_id);
1225 return QDF_STATUS_E_INVAL;
1226 }
Govind Singh5eb51532016-03-09 11:34:12 +05301227
1228 buf = wmi_buf_alloc(wmi_handle, len);
1229 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301230 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301231 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301232 }
1233 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1234 WMITLV_SET_HDR(&cmd->tlv_header,
1235 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1236 WMITLV_GET_STRUCT_TLVLEN
1237 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301238 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301239 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301240 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301241 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301242 param->param_value);
1243 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1244 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301245 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301246 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301247 wmi_buf_free(buf);
1248 }
1249 return ret;
1250}
1251
1252/**
1253 * send_suspend_cmd_tlv() - WMI suspend function
1254 * @param wmi_handle : handle to WMI.
1255 * @param param : pointer to hold suspend parameter
1256 * @mac_id: radio context
1257 *
1258 * Return 0 on success and -ve on failure.
1259 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301260static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301261 struct suspend_params *param,
1262 uint8_t mac_id)
1263{
1264 wmi_pdev_suspend_cmd_fixed_param *cmd;
1265 wmi_buf_t wmibuf;
1266 uint32_t len = sizeof(*cmd);
1267 int32_t ret;
1268
1269 /*
1270 * send the comand to Target to ignore the
1271 * PCIE reset so as to ensure that Host and target
1272 * states are in sync
1273 */
1274 wmibuf = wmi_buf_alloc(wmi_handle, len);
1275 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301276 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301277
1278 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1279 WMITLV_SET_HDR(&cmd->tlv_header,
1280 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1281 WMITLV_GET_STRUCT_TLVLEN
1282 (wmi_pdev_suspend_cmd_fixed_param));
1283 if (param->disable_target_intr)
1284 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1285 else
1286 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301287
1288 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1289
Govind Singh5eb51532016-03-09 11:34:12 +05301290 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1291 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301292 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301293 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301294 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301295 }
1296
1297 return ret;
1298}
1299
1300/**
1301 * send_resume_cmd_tlv() - WMI resume function
1302 * @param wmi_handle : handle to WMI.
1303 * @mac_id: radio context
1304 *
1305 * Return: 0 on success and -ve on failure.
1306 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301307static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301308 uint8_t mac_id)
1309{
1310 wmi_buf_t wmibuf;
1311 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301312 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301313
1314 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1315 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301316 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301317 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1318 WMITLV_SET_HDR(&cmd->tlv_header,
1319 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1320 WMITLV_GET_STRUCT_TLVLEN
1321 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301322 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301323 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1324 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301325 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301326 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301327 wmi_buf_free(wmibuf);
1328 }
1329
1330 return ret;
1331}
1332
Will Huang422ac9a2017-11-17 13:19:16 +08001333#ifdef FEATURE_WLAN_D0WOW
1334/**
1335 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1336 * @param wmi_handle: handle to WMI.
1337 * @mac_id: radio context
1338 *
1339 * Return: 0 on success and error code on failure.
1340 */
1341static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1342 uint8_t mac_id)
1343{
1344 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1345 wmi_buf_t buf;
1346 int32_t len;
1347 QDF_STATUS status;
1348
1349 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1350
1351 buf = wmi_buf_alloc(wmi_handle, len);
1352 if (!buf) {
1353 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1354 return QDF_STATUS_E_NOMEM;
1355 }
1356 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1357 WMITLV_SET_HDR(&cmd->tlv_header,
1358 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1359 WMITLV_GET_STRUCT_TLVLEN
1360 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1361
1362 cmd->enable = true;
1363
1364 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1365 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1366 if (QDF_IS_STATUS_ERROR(status))
1367 wmi_buf_free(buf);
1368
1369 return status;
1370}
1371
1372/**
1373 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1374 * @param wmi_handle: handle to WMI.
1375 * @mac_id: radio context
1376 *
1377 * Return: 0 on success and error code on failure.
1378 */
1379static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1380 uint8_t mac_id)
1381{
1382 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1383 wmi_buf_t buf;
1384 int32_t len;
1385 QDF_STATUS status;
1386
1387 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1388
1389 buf = wmi_buf_alloc(wmi_handle, len);
1390 if (!buf) {
1391 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1392 return QDF_STATUS_E_NOMEM;
1393 }
1394 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1395 WMITLV_SET_HDR(&cmd->tlv_header,
1396 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1397 WMITLV_GET_STRUCT_TLVLEN
1398 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1399
1400 cmd->enable = false;
1401
1402 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1403 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1404 if (QDF_IS_STATUS_ERROR(status))
1405 wmi_buf_free(buf);
1406
1407 return status;
1408}
1409#endif
1410
Govind Singh5eb51532016-03-09 11:34:12 +05301411/**
1412 * send_wow_enable_cmd_tlv() - WMI wow enable function
1413 * @param wmi_handle : handle to WMI.
1414 * @param param : pointer to hold wow enable parameter
1415 * @mac_id: radio context
1416 *
1417 * Return: 0 on success and -ve on failure.
1418 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301419static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301420 struct wow_cmd_params *param,
1421 uint8_t mac_id)
1422{
1423 wmi_wow_enable_cmd_fixed_param *cmd;
1424 wmi_buf_t buf;
1425 int32_t len;
1426 int32_t ret;
1427
1428 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1429
1430 buf = wmi_buf_alloc(wmi_handle, len);
1431 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301432 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1433 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301434 }
1435 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1436 WMITLV_SET_HDR(&cmd->tlv_header,
1437 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1438 WMITLV_GET_STRUCT_TLVLEN
1439 (wmi_wow_enable_cmd_fixed_param));
1440 cmd->enable = param->enable;
1441 if (param->can_suspend_link)
1442 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1443 else
1444 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001445 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301446
Govind Singhb53420c2016-03-09 14:32:57 +05301447 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301448 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1449 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1450
1451 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1452 WMI_WOW_ENABLE_CMDID);
1453 if (ret)
1454 wmi_buf_free(buf);
1455
1456 return ret;
1457}
1458
1459/**
1460 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301461 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301462 * @peer_addr: peer mac address
1463 * @param: pointer to ap_ps parameter structure
1464 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301465 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301466 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301467static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301468 uint8_t *peer_addr,
1469 struct ap_ps_params *param)
1470{
1471 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1472 wmi_buf_t buf;
1473 int32_t err;
1474
1475 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1476 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301477 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301478 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301479 }
1480 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1481 WMITLV_SET_HDR(&cmd->tlv_header,
1482 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1483 WMITLV_GET_STRUCT_TLVLEN
1484 (wmi_ap_ps_peer_cmd_fixed_param));
1485 cmd->vdev_id = param->vdev_id;
1486 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1487 cmd->param = param->param;
1488 cmd->value = param->value;
1489 err = wmi_unified_cmd_send(wmi_handle, buf,
1490 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1491 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301492 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301493 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301494 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301495 }
1496
1497 return 0;
1498}
1499
1500/**
1501 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301502 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301503 * @peer_addr: peer mac address
1504 * @param: pointer to sta_ps parameter structure
1505 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301506 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301507 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301508static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301509 struct sta_ps_params *param)
1510{
1511 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1512 wmi_buf_t buf;
1513 int32_t len = sizeof(*cmd);
1514
1515 buf = wmi_buf_alloc(wmi_handle, len);
1516 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301517 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301518 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301519 }
1520
1521 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1522 WMITLV_SET_HDR(&cmd->tlv_header,
1523 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1524 WMITLV_GET_STRUCT_TLVLEN
1525 (wmi_sta_powersave_param_cmd_fixed_param));
1526 cmd->vdev_id = param->vdev_id;
1527 cmd->param = param->param;
1528 cmd->value = param->value;
1529
1530 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1531 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301532 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301533 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301534 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301535 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301536 }
1537
1538 return 0;
1539}
1540
1541/**
1542 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301543 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301544 * @param: ponirt to crash inject paramter structure
1545 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301546 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301547 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301548static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301549 struct crash_inject *param)
1550{
1551 int32_t ret = 0;
1552 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1553 uint16_t len = sizeof(*cmd);
1554 wmi_buf_t buf;
1555
1556 buf = wmi_buf_alloc(wmi_handle, len);
1557 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301558 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301559 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301560 }
1561
1562 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1563 WMITLV_SET_HDR(&cmd->tlv_header,
1564 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1565 WMITLV_GET_STRUCT_TLVLEN
1566 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1567 cmd->type = param->type;
1568 cmd->delay_time_ms = param->delay_time_ms;
1569
1570 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1571 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301572 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301573 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301574 __func__, ret);
1575 wmi_buf_free(buf);
1576 }
1577
1578 return ret;
1579}
1580
1581/**
1582 * send_dbglog_cmd_tlv() - set debug log level
1583 * @param wmi_handle : handle to WMI.
1584 * @param param : pointer to hold dbglog level parameter
1585 *
1586 * Return: 0 on success and -ve on failure.
1587 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301588 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301589send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1590 struct dbglog_params *dbglog_param)
1591{
1592 wmi_buf_t buf;
1593 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001594 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301595 int32_t i;
1596 int32_t len;
1597 int8_t *buf_ptr;
1598 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1599
Alok Kumar240afea2017-08-30 14:45:34 +05301600 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301601
1602 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1603 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1604 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1605 buf = wmi_buf_alloc(wmi_handle, len);
1606 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001607 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301608
1609 configmsg =
1610 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1611 buf_ptr = (int8_t *) configmsg;
1612 WMITLV_SET_HDR(&configmsg->tlv_header,
1613 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1614 WMITLV_GET_STRUCT_TLVLEN
1615 (wmi_debug_log_config_cmd_fixed_param));
1616 configmsg->dbg_log_param = dbglog_param->param;
1617 configmsg->value = dbglog_param->val;
1618 /* Filling in the data part of second tlv -- should
1619 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301620 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301621 sizeof
1622 (wmi_debug_log_config_cmd_fixed_param)
1623 + WMI_TLV_HDR_SIZE);
1624 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1625 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301626 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301627 if (dbglog_param->module_id_bitmap) {
1628 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1629 module_id_bitmap_array[i] =
1630 dbglog_param->module_id_bitmap[i];
1631 }
1632 }
1633
1634 status = wmi_unified_cmd_send(wmi_handle, buf,
1635 len, WMI_DBGLOG_CFG_CMDID);
1636
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001637 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301638 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301639
1640 return status;
1641}
1642
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301643#ifdef CONFIG_MCL
1644static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1645 uint32_t host_param)
1646{
1647 return host_param;
1648}
1649#else
1650static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1651 uint32_t host_param)
1652{
1653 if (host_param < wmi_vdev_param_max)
1654 return wmi_handle->vdev_param[host_param];
1655
1656 return WMI_UNAVAILABLE_PARAM;
1657}
1658#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301659/**
1660 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1661 * @param wmi_handle : handle to WMI.
1662 * @param macaddr : MAC address
1663 * @param param : pointer to hold vdev set parameter
1664 *
1665 * Return: 0 on success and -ve on failure.
1666 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301667static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301668 struct vdev_set_params *param)
1669{
Govind Singh67922e82016-04-01 16:48:57 +05301670 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301671 wmi_vdev_set_param_cmd_fixed_param *cmd;
1672 wmi_buf_t buf;
1673 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301674 uint32_t vdev_param;
1675
1676 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1677 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1678 WMI_LOGW("%s:Vdev param %d not available", __func__,
1679 param->param_id);
1680 return QDF_STATUS_E_INVAL;
1681
1682 }
Govind Singh5eb51532016-03-09 11:34:12 +05301683
1684 buf = wmi_buf_alloc(wmi_handle, len);
1685 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301686 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301687 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301688 }
1689 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1690 WMITLV_SET_HDR(&cmd->tlv_header,
1691 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1692 WMITLV_GET_STRUCT_TLVLEN
1693 (wmi_vdev_set_param_cmd_fixed_param));
1694 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301695 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301696 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301697 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001698 cmd->vdev_id, cmd->param_id, cmd->param_value);
Govind Singh5eb51532016-03-09 11:34:12 +05301699 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1700 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301701 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301702 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301703 wmi_buf_free(buf);
1704 }
1705
1706 return ret;
1707}
1708
1709/**
1710 * send_stats_request_cmd_tlv() - WMI request stats function
1711 * @param wmi_handle : handle to WMI.
1712 * @param macaddr : MAC address
1713 * @param param : pointer to hold stats request parameter
1714 *
1715 * Return: 0 on success and -ve on failure.
1716 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301717static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301718 uint8_t macaddr[IEEE80211_ADDR_LEN],
1719 struct stats_request_params *param)
1720{
Govind Singhd3156eb2016-02-26 17:50:39 +05301721 int32_t ret;
1722 wmi_request_stats_cmd_fixed_param *cmd;
1723 wmi_buf_t buf;
1724 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1725
1726 buf = wmi_buf_alloc(wmi_handle, len);
1727 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301728 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1729 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301730 }
1731
1732 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1733 WMITLV_SET_HDR(&cmd->tlv_header,
1734 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1735 WMITLV_GET_STRUCT_TLVLEN
1736 (wmi_request_stats_cmd_fixed_param));
1737 cmd->stats_id = param->stats_id;
1738 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301739 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1740 param->pdev_id);
1741 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001742
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301743 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1744 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001745
1746 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1747 WMI_REQUEST_STATS_CMDID);
1748
Govind Singhd3156eb2016-02-26 17:50:39 +05301749 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301750 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301751 wmi_buf_free(buf);
1752 }
1753
1754 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301755}
1756
Govind Singh87542482016-06-08 19:40:11 +05301757#ifdef CONFIG_WIN
1758/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001759 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301760 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001761 * @param PKTLOG_EVENT : packet log event
1762 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301763 *
1764 * Return: 0 on success and -ve on failure.
1765 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301766static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001767 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301768{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001769 int32_t ret;
1770 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1771 wmi_buf_t buf;
1772 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1773
1774 buf = wmi_buf_alloc(wmi_handle, len);
1775 if (!buf) {
1776 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1777 return -QDF_STATUS_E_NOMEM;
1778 }
1779
1780 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1781 WMITLV_SET_HDR(&cmd->tlv_header,
1782 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1783 WMITLV_GET_STRUCT_TLVLEN
1784 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1785 cmd->evlist = PKTLOG_EVENT;
1786 cmd->pdev_id = mac_id;
1787 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1788 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1789 if (ret) {
1790 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1791 wmi_buf_free(buf);
1792 }
1793
1794 return ret;
1795}
1796
1797/**
1798 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1799 * @param wmi_handle : handle to WMI.
1800 * @mac_id: mac id to have radio context
1801 *
1802 * Return: 0 on success and -ve on failure.
1803 */
1804static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001805 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001806{
1807 int32_t ret;
1808 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1809 wmi_buf_t buf;
1810 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1811
1812 buf = wmi_buf_alloc(wmi_handle, len);
1813 if (!buf) {
1814 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1815 return -QDF_STATUS_E_NOMEM;
1816 }
1817
1818 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1819 WMITLV_SET_HDR(&cmd->tlv_header,
1820 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1821 WMITLV_GET_STRUCT_TLVLEN
1822 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1823 cmd->pdev_id = mac_id;
1824 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1825 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1826 if (ret) {
1827 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1828 wmi_buf_free(buf);
1829 }
1830
1831 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301832}
1833#else
Govind Singh5eb51532016-03-09 11:34:12 +05301834/**
Keyur Parekhde522342017-08-18 14:01:05 -07001835 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1836 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301837 * @param wmi_handle : handle to WMI.
1838 * @param macaddr : MAC address
1839 * @param param : pointer to hold stats request parameter
1840 *
1841 * Return: 0 on success and -ve on failure.
1842 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301843static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301844 uint8_t macaddr[IEEE80211_ADDR_LEN],
1845 struct packet_enable_params *param)
1846{
1847 return 0;
1848}
Keyur Parekhde522342017-08-18 14:01:05 -07001849/**
1850 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1851 * packet-log
1852 * @param wmi_handle : handle to WMI.
1853 * @mac_id: mac id to have radio context
1854 *
1855 * Return: 0 on success and -ve on failure.
1856 */
1857static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1858 uint8_t mac_id)
1859{
1860 return 0;
1861}
Govind Singh87542482016-06-08 19:40:11 +05301862#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301863
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301864#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1865/**
1866 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1867 * sync time between bwtween host and firmware
1868 * @param wmi_handle : handle to WMI.
1869 *
1870 * Return: None
1871 */
1872static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1873{
1874 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07001875 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301876 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1877 int32_t len;
1878 qdf_time_t time_ms;
1879
1880 len = sizeof(*time_stamp);
1881 buf = wmi_buf_alloc(wmi_handle, len);
1882
1883 if (!buf) {
1884 WMI_LOGP(FL("wmi_buf_alloc failed"));
1885 return;
1886 }
1887 time_stamp =
1888 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1889 (wmi_buf_data(buf));
1890 WMITLV_SET_HDR(&time_stamp->tlv_header,
1891 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1892 WMITLV_GET_STRUCT_TLVLEN(
1893 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1894
1895 time_ms = qdf_get_time_of_the_day_ms();
1896 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1897 time_stamp->time_stamp_low = time_ms &
1898 WMI_FW_TIME_STAMP_LOW_MASK;
1899 /*
1900 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1901 * wont exceed 27 bit
1902 */
1903 time_stamp->time_stamp_high = 0;
1904 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1905 time_stamp->mode, time_stamp->time_stamp_low,
1906 time_stamp->time_stamp_high);
1907
1908 status = wmi_unified_cmd_send(wmi_handle, buf,
1909 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
1910 if (status) {
1911 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
1912 wmi_buf_free(buf);
1913 }
1914
1915}
1916
Subrat Mishrad7c7a562017-09-27 14:41:20 +05301917#ifdef WLAN_SUPPORT_FILS
1918/**
1919 * extract_swfda_vdev_id_tlv() - extract swfda vdev id from event
1920 * @wmi_handle: wmi handle
1921 * @evt_buf: pointer to event buffer
1922 * @vdev_id: pointer to hold vdev id
1923 *
1924 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
1925 */
1926static QDF_STATUS
1927extract_swfda_vdev_id_tlv(wmi_unified_t wmi_handle,
1928 void *evt_buf, uint32_t *vdev_id)
1929{
1930 WMI_HOST_SWFDA_EVENTID_param_tlvs *param_buf;
1931 wmi_host_swfda_event_fixed_param *swfda_event;
1932
1933 param_buf = (WMI_HOST_SWFDA_EVENTID_param_tlvs *)evt_buf;
1934 if (!param_buf) {
1935 WMI_LOGE("Invalid swfda event buffer");
1936 return QDF_STATUS_E_INVAL;
1937 }
1938 swfda_event = param_buf->fixed_param;
1939 *vdev_id = swfda_event->vdev_id;
1940
1941 return QDF_STATUS_SUCCESS;
1942}
1943
1944/**
1945 * send_vdev_fils_enable_cmd_tlv() - enable/Disable FD Frame command to fw
1946 * @wmi_handle: wmi handle
1947 * @param: pointer to hold FILS discovery enable param
1948 *
1949 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure
1950 */
1951static QDF_STATUS
1952send_vdev_fils_enable_cmd_tlv(wmi_unified_t wmi_handle,
1953 struct config_fils_params *param)
1954{
1955 wmi_enable_fils_cmd_fixed_param *cmd;
1956 wmi_buf_t buf;
1957 QDF_STATUS status;
1958 uint32_t len = sizeof(wmi_enable_fils_cmd_fixed_param);
1959
1960 buf = wmi_buf_alloc(wmi_handle, len);
1961 if (!buf) {
1962 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
1963 return QDF_STATUS_E_NOMEM;
1964 }
1965 cmd = (wmi_enable_fils_cmd_fixed_param *)wmi_buf_data(buf);
1966 WMITLV_SET_HDR(&cmd->tlv_header,
1967 WMITLV_TAG_STRUC_wmi_enable_fils_cmd_fixed_param,
1968 WMITLV_GET_STRUCT_TLVLEN(
1969 wmi_enable_fils_cmd_fixed_param));
1970 cmd->vdev_id = param->vdev_id;
1971 cmd->fd_period = param->fd_period;
1972 WMI_LOGI("Setting FD period to %d vdev id : %d\n",
1973 param->fd_period, param->vdev_id);
1974
1975 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1976 WMI_ENABLE_FILS_CMDID);
1977 if (status != QDF_STATUS_SUCCESS) {
1978 wmi_buf_free(buf);
1979 return QDF_STATUS_E_FAILURE;
1980 }
1981
1982 return QDF_STATUS_SUCCESS;
1983}
1984
1985/**
1986 * send_fils_discovery_send_cmd_tlv() - WMI FILS Discovery send function
1987 * @wmi_handle: wmi handle
1988 * @param: pointer to hold FD send cmd parameter
1989 *
1990 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_NOMEM on failure.
1991 */
1992static QDF_STATUS
1993send_fils_discovery_send_cmd_tlv(wmi_unified_t wmi_handle,
1994 struct fd_params *param)
1995{
1996 QDF_STATUS ret;
1997 wmi_fd_send_from_host_cmd_fixed_param *cmd;
1998 wmi_buf_t wmi_buf;
1999 qdf_dma_addr_t dma_addr;
2000
2001 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2002 if (!wmi_buf) {
2003 WMI_LOGE("%s : wmi_buf_alloc failed\n", __func__);
2004 return QDF_STATUS_E_NOMEM;
2005 }
2006 cmd = (wmi_fd_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
2007 WMITLV_SET_HDR(&cmd->tlv_header,
2008 WMITLV_TAG_STRUC_wmi_fd_send_from_host_cmd_fixed_param,
2009 WMITLV_GET_STRUCT_TLVLEN(
2010 wmi_fd_send_from_host_cmd_fixed_param));
2011 cmd->vdev_id = param->vdev_id;
2012 cmd->data_len = qdf_nbuf_len(param->wbuf);
2013 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2014 qdf_dmaaddr_to_32s(dma_addr, &cmd->frag_ptr_lo, &cmd->frag_ptr_hi);
2015 cmd->frame_ctrl = param->frame_ctrl;
2016
2017 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
2018 WMI_PDEV_SEND_FD_CMDID);
2019 if (ret != QDF_STATUS_SUCCESS) {
2020 WMI_LOGE("%s: Failed to send fils discovery frame: %d",
2021 __func__, ret);
2022 wmi_buf_free(wmi_buf);
2023 }
2024
2025 return ret;
2026}
2027#endif /* WLAN_SUPPORT_FILS */
2028
Sathish Kumarfd347372017-02-13 12:29:09 +05302029static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302030 struct beacon_params *param)
2031{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05302032 QDF_STATUS ret;
2033 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
2034 wmi_buf_t wmi_buf;
2035 qdf_dma_addr_t dma_addr;
2036 uint32_t dtim_flag = 0;
2037
2038 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2039 if (!wmi_buf) {
2040 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2041 return QDF_STATUS_E_NOMEM;
2042 }
2043 if (param->is_dtim_count_zero) {
2044 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
2045 if (param->is_bitctl_reqd) {
2046 /* deliver CAB traffic in next DTIM beacon */
2047 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
2048 }
2049 }
2050 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2051 WMITLV_SET_HDR(&cmd->tlv_header,
2052 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
2053 WMITLV_GET_STRUCT_TLVLEN
2054 (wmi_bcn_send_from_host_cmd_fixed_param));
2055 cmd->vdev_id = param->vdev_id;
2056 cmd->data_len = qdf_nbuf_len(param->wbuf);
2057 cmd->frame_ctrl = param->frame_ctrl;
2058 cmd->dtim_flag = dtim_flag;
2059 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
2060 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
2061#if defined(HTT_PADDR64)
2062 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
2063#endif
2064 cmd->bcn_antenna = param->bcn_txant;
2065
2066 ret = wmi_unified_cmd_send(wmi_handle,
2067 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
2068 if (ret != QDF_STATUS_SUCCESS) {
2069 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
2070 wmi_buf_free(wmi_buf);
2071 }
2072
2073 return ret;
Govind Singh87542482016-06-08 19:40:11 +05302074}
2075
2076/**
2077 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
2078 * @param wmi_handle : handle to WMI.
2079 * @param param : pointer to hold beacon send cmd parameter
2080 *
2081 * Return: 0 on success and -ve on failure.
2082 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302083static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302084 struct beacon_tmpl_params *param)
2085{
2086 int32_t ret;
2087 wmi_bcn_tmpl_cmd_fixed_param *cmd;
2088 wmi_bcn_prb_info *bcn_prb_info;
2089 wmi_buf_t wmi_buf;
2090 uint8_t *buf_ptr;
2091 uint32_t wmi_buf_len;
2092
2093 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
2094 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
2095 param->tmpl_len_aligned;
2096 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
2097 if (!wmi_buf) {
2098 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
2099 return QDF_STATUS_E_NOMEM;
2100 }
2101 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2102 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
2103 WMITLV_SET_HDR(&cmd->tlv_header,
2104 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
2105 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
2106 cmd->vdev_id = param->vdev_id;
2107 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05302108 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
2109 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05302110 cmd->buf_len = param->tmpl_len;
2111 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
2112
2113 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
2114 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
2115 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
2116 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
2117 bcn_prb_info->caps = 0;
2118 bcn_prb_info->erp = 0;
2119 buf_ptr += sizeof(wmi_bcn_prb_info);
2120
2121 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
2122 buf_ptr += WMI_TLV_HDR_SIZE;
2123 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
2124
2125 ret = wmi_unified_cmd_send(wmi_handle,
2126 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
2127 if (ret) {
2128 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
2129 wmi_buf_free(wmi_buf);
2130 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05302131
Govind Singh87542482016-06-08 19:40:11 +05302132 return 0;
2133}
Govind Singh5eb51532016-03-09 11:34:12 +05302134
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302135#ifdef CONFIG_MCL
2136static inline void copy_peer_flags_tlv(
2137 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2138 struct peer_assoc_params *param)
2139{
2140 cmd->peer_flags = param->peer_flags;
2141}
2142#else
2143static inline void copy_peer_flags_tlv(
2144 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2145 struct peer_assoc_params *param)
2146{
2147 /*
2148 * The target only needs a subset of the flags maintained in the host.
2149 * Just populate those flags and send it down
2150 */
2151 cmd->peer_flags = 0;
2152
2153 /*
2154 * Do not enable HT/VHT if WMM/wme is disabled for vap.
2155 */
2156 if (param->is_wme_set) {
2157
2158 if (param->qos_flag)
2159 cmd->peer_flags |= WMI_PEER_QOS;
2160 if (param->apsd_flag)
2161 cmd->peer_flags |= WMI_PEER_APSD;
2162 if (param->ht_flag)
2163 cmd->peer_flags |= WMI_PEER_HT;
2164 if (param->bw_40)
2165 cmd->peer_flags |= WMI_PEER_40MHZ;
2166 if (param->bw_80)
2167 cmd->peer_flags |= WMI_PEER_80MHZ;
2168 if (param->bw_160)
2169 cmd->peer_flags |= WMI_PEER_160MHZ;
2170
2171 /* Typically if STBC is enabled for VHT it should be enabled
2172 * for HT as well
2173 **/
2174 if (param->stbc_flag)
2175 cmd->peer_flags |= WMI_PEER_STBC;
2176
2177 /* Typically if LDPC is enabled for VHT it should be enabled
2178 * for HT as well
2179 **/
2180 if (param->ldpc_flag)
2181 cmd->peer_flags |= WMI_PEER_LDPC;
2182
2183 if (param->static_mimops_flag)
2184 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
2185 if (param->dynamic_mimops_flag)
2186 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
2187 if (param->spatial_mux_flag)
2188 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
2189 if (param->vht_flag)
2190 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002191 if (param->he_flag)
2192 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302193 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08002194
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05302195 if (param->is_pmf_enabled)
2196 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302197 /*
2198 * Suppress authorization for all AUTH modes that need 4-way handshake
2199 * (during re-association).
2200 * Authorization will be done for these modes on key installation.
2201 */
2202 if (param->auth_flag)
2203 cmd->peer_flags |= WMI_PEER_AUTH;
2204 if (param->need_ptk_4_way)
2205 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
2206 else
2207 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
2208 if (param->need_gtk_2_way)
2209 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
2210 /* safe mode bypass the 4-way handshake */
2211 if (param->safe_mode_enabled)
2212 cmd->peer_flags &=
2213 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
2214 /* Disable AMSDU for station transmit, if user configures it */
2215 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
2216 * it
2217 * if (param->amsdu_disable) Add after FW support
2218 **/
2219
2220 /* Target asserts if node is marked HT and all MCS is set to 0.
2221 * Mark the node as non-HT if all the mcs rates are disabled through
2222 * iwpriv
2223 **/
2224 if (param->peer_ht_rates.num_rates == 0)
2225 cmd->peer_flags &= ~WMI_PEER_HT;
2226}
2227#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302228
2229#ifdef CONFIG_MCL
2230static inline void copy_peer_mac_addr_tlv(
2231 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2232 struct peer_assoc_params *param)
2233{
2234 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2235 sizeof(param->peer_macaddr));
2236}
2237#else
2238static inline void copy_peer_mac_addr_tlv(
2239 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2240 struct peer_assoc_params *param)
2241{
2242 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2243}
2244#endif
2245
Govind Singh5eb51532016-03-09 11:34:12 +05302246/**
2247 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2248 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302249 * @param param : pointer to peer assoc parameter
2250 *
2251 * Return: 0 on success and -ve on failure.
2252 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302253static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302254 struct peer_assoc_params *param)
2255{
Govind Singhd3156eb2016-02-26 17:50:39 +05302256 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2257 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002258 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302259 wmi_buf_t buf;
2260 int32_t len;
2261 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302262 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302263 uint32_t peer_legacy_rates_align;
2264 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002265 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302266
2267
2268 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2269 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302270
2271 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002272 (peer_legacy_rates_align * sizeof(uint8_t)) +
2273 WMI_TLV_HDR_SIZE +
2274 (peer_ht_rates_align * sizeof(uint8_t)) +
2275 sizeof(wmi_vht_rate_set) +
2276 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2277 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302278
2279 buf = wmi_buf_alloc(wmi_handle, len);
2280 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302281 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302282 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302283 }
2284
2285 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2286 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2287 WMITLV_SET_HDR(&cmd->tlv_header,
2288 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2289 WMITLV_GET_STRUCT_TLVLEN
2290 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302291
Govind Singhd3156eb2016-02-26 17:50:39 +05302292 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302293
Govind Singhd3156eb2016-02-26 17:50:39 +05302294 cmd->peer_new_assoc = param->peer_new_assoc;
2295 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302296
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302297 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302298 copy_peer_mac_addr_tlv(cmd, param);
2299
Govind Singhd3156eb2016-02-26 17:50:39 +05302300 cmd->peer_rate_caps = param->peer_rate_caps;
2301 cmd->peer_caps = param->peer_caps;
2302 cmd->peer_listen_intval = param->peer_listen_intval;
2303 cmd->peer_ht_caps = param->peer_ht_caps;
2304 cmd->peer_max_mpdu = param->peer_max_mpdu;
2305 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302306 cmd->peer_vht_caps = param->peer_vht_caps;
2307 cmd->peer_phymode = param->peer_phymode;
2308
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002309 /* Update 11ax capabilities */
2310 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
2311 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002312 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2313 sizeof(param->peer_he_cap_phyinfo));
2314 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2315 sizeof(param->peer_ppet));
2316
Govind Singhd3156eb2016-02-26 17:50:39 +05302317 /* Update peer legacy rate information */
2318 buf_ptr += sizeof(*cmd);
2319 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302320 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302321 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302322 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302323 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302324 param->peer_legacy_rates.num_rates);
2325
2326 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002327 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302328 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302329 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302330 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302331 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302332 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302333 param->peer_ht_rates.num_rates);
2334
2335 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002336 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302337 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2338 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2339
2340 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302341
2342 /* Update bandwidth-NSS mapping */
2343 cmd->peer_bw_rxnss_override = 0;
2344 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2345
Govind Singhd3156eb2016-02-26 17:50:39 +05302346 mcs = (wmi_vht_rate_set *) buf_ptr;
2347 if (param->vht_capable) {
2348 mcs->rx_max_rate = param->rx_max_rate;
2349 mcs->rx_mcs_set = param->rx_mcs_set;
2350 mcs->tx_max_rate = param->tx_max_rate;
2351 mcs->tx_mcs_set = param->tx_mcs_set;
2352 }
2353
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002354 /* HE Rates */
2355 cmd->peer_he_mcs = param->peer_he_mcs_count;
2356 buf_ptr += sizeof(wmi_vht_rate_set);
2357 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2358 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2359 buf_ptr += WMI_TLV_HDR_SIZE;
2360
2361 /* Loop through the HE rate set */
2362 for (i = 0; i < param->peer_he_mcs_count; i++) {
2363 he_mcs = (wmi_he_rate_set *) buf_ptr;
2364 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2365 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2366
2367 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2368 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2369 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2370 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2371 buf_ptr += sizeof(wmi_he_rate_set);
2372 }
2373
2374
Govind Singhb53420c2016-03-09 14:32:57 +05302375 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302376 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2377 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002378 "cmd->peer_vht_caps %x "
2379 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302380 "HE phy %x %x %x "
2381 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302382 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2383 cmd->peer_rate_caps, cmd->peer_caps,
2384 cmd->peer_listen_intval, cmd->peer_ht_caps,
2385 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2386 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002387 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2388 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302389 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2390 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302391
2392 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2393 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302394 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302395 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302396 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302397 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302398 }
2399
2400 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302401}
2402
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302403/* copy_scan_notify_events() - Helper routine to copy scan notify events
2404 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302405static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302406 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302407 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302408{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302409
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302410 /* Scan events subscription */
2411 if (param->scan_ev_started)
2412 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2413 if (param->scan_ev_completed)
2414 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2415 if (param->scan_ev_bss_chan)
2416 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2417 if (param->scan_ev_foreign_chan)
2418 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2419 if (param->scan_ev_dequeued)
2420 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2421 if (param->scan_ev_preempted)
2422 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2423 if (param->scan_ev_start_failed)
2424 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2425 if (param->scan_ev_restarted)
2426 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2427 if (param->scan_ev_foreign_chn_exit)
2428 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2429 if (param->scan_ev_suspended)
2430 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2431 if (param->scan_ev_resumed)
2432 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302433
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302434 /** Set scan control flags */
2435 cmd->scan_ctrl_flags = 0;
2436 if (param->scan_f_passive)
2437 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2438 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302439 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302440 if (param->scan_f_promisc_mode)
2441 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2442 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302443 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302444 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302445 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302446 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302447 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302448 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302449 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302450 if (param->scan_f_ofdm_rates)
2451 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2452 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302453 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302454 if (param->scan_f_filter_prb_req)
2455 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2456 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302457 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302458 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302459 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302460 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302461 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302462 if (param->scan_f_force_active_dfs_chn)
2463 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2464 if (param->scan_f_add_tpc_ie_in_probe)
2465 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2466 if (param->scan_f_add_ds_ie_in_probe)
2467 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2468 if (param->scan_f_add_spoofed_mac_in_probe)
2469 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2470 if (param->scan_f_add_rand_seq_in_probe)
2471 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2472 if (param->scan_f_en_ie_whitelist_in_probe)
2473 cmd->scan_ctrl_flags |=
2474 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302475
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302476 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2477 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2478 param->adaptive_dwell_time_mode);
2479}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302480
2481/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302482static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302483 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302484{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302485 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302486}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302487
Govind Singh5eb51532016-03-09 11:34:12 +05302488/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302489 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2490 * @mac: random mac addr
2491 * @mask: random mac mask
2492 * @mac_addr: wmi random mac
2493 * @mac_mask: wmi random mac mask
2494 *
2495 * Return None.
2496 */
2497static inline
2498void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2499 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2500{
2501 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2502 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2503}
2504
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302505/*
2506 * wmi_fill_vendor_oui() - fill vendor OUIs
2507 * @buf_ptr: pointer to wmi tlv buffer
2508 * @num_vendor_oui: number of vendor OUIs to be filled
2509 * @param_voui: pointer to OUI buffer
2510 *
2511 * This function populates the wmi tlv buffer when vendor specific OUIs are
2512 * present.
2513 *
2514 * Return: None
2515 */
2516static inline
2517void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2518 uint32_t *pvoui)
2519{
2520 wmi_vendor_oui *voui = NULL;
2521 uint32_t i;
2522
2523 voui = (wmi_vendor_oui *)buf_ptr;
2524
2525 for (i = 0; i < num_vendor_oui; i++) {
2526 WMITLV_SET_HDR(&voui[i].tlv_header,
2527 WMITLV_TAG_STRUC_wmi_vendor_oui,
2528 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2529 voui[i].oui_type_subtype = pvoui[i];
2530 }
2531}
2532
2533/*
2534 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2535 * @ie_bitmap: output pointer to ie bit map in cmd
2536 * @num_vendor_oui: output pointer to num vendor OUIs
2537 * @ie_whitelist: input parameter
2538 *
2539 * This function populates the IE whitelist attrs of scan, pno and
2540 * scan oui commands for ie_whitelist parameter.
2541 *
2542 * Return: None
2543 */
2544static inline
2545void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2546 uint32_t *num_vendor_oui,
2547 struct probe_req_whitelist_attr *ie_whitelist)
2548{
2549 uint32_t i = 0;
2550
2551 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2552 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2553
2554 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2555}
2556
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302557/**
Govind Singh5eb51532016-03-09 11:34:12 +05302558 * send_scan_start_cmd_tlv() - WMI scan start function
2559 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302560 * @param param : pointer to hold scan start cmd parameter
2561 *
2562 * Return: 0 on success and -ve on failure.
2563 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302564static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302565 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302566{
Govind Singhd3156eb2016-02-26 17:50:39 +05302567 int32_t ret = 0;
2568 int32_t i;
2569 wmi_buf_t wmi_buf;
2570 wmi_start_scan_cmd_fixed_param *cmd;
2571 uint8_t *buf_ptr;
2572 uint32_t *tmp_ptr;
2573 wmi_ssid *ssid = NULL;
2574 wmi_mac_addr *bssid;
2575 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302576 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302577 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302578 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302579
2580 /* Length TLV placeholder for array of uint32_t */
2581 len += WMI_TLV_HDR_SIZE;
2582 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302583 if (params->chan_list.num_chan)
2584 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302585
2586 /* Length TLV placeholder for array of wmi_ssid structures */
2587 len += WMI_TLV_HDR_SIZE;
2588 if (params->num_ssids)
2589 len += params->num_ssids * sizeof(wmi_ssid);
2590
2591 /* Length TLV placeholder for array of wmi_mac_addr structures */
2592 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302593 if (params->num_bssid)
2594 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302595
2596 /* Length TLV placeholder for array of bytes */
2597 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302598 if (params->extraie.len)
2599 extraie_len_with_pad =
2600 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002601 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302602
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302603 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2604 if (ie_whitelist->num_vendor_oui)
2605 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2606
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302607 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2608 if (params->scan_f_wide_band)
2609 phymode_roundup =
2610 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2611 sizeof(uint32_t));
2612 len += phymode_roundup;
2613
Govind Singhd3156eb2016-02-26 17:50:39 +05302614 /* Allocate the memory */
2615 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2616 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302617 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302618 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302619 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302620 }
2621 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2622 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2623 WMITLV_SET_HDR(&cmd->tlv_header,
2624 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2625 WMITLV_GET_STRUCT_TLVLEN
2626 (wmi_start_scan_cmd_fixed_param));
2627
2628 cmd->scan_id = params->scan_id;
2629 cmd->scan_req_id = params->scan_req_id;
2630 cmd->vdev_id = params->vdev_id;
2631 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302632
2633 copy_scan_event_cntrl_flags(cmd, params);
2634
Govind Singhd3156eb2016-02-26 17:50:39 +05302635 cmd->dwell_time_active = params->dwell_time_active;
2636 cmd->dwell_time_passive = params->dwell_time_passive;
2637 cmd->min_rest_time = params->min_rest_time;
2638 cmd->max_rest_time = params->max_rest_time;
2639 cmd->repeat_probe_time = params->repeat_probe_time;
2640 cmd->probe_spacing_time = params->probe_spacing_time;
2641 cmd->idle_time = params->idle_time;
2642 cmd->max_scan_time = params->max_scan_time;
2643 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302644 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302645 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302646 cmd->num_bssid = params->num_bssid;
2647 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302648 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302649 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302650 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2651
2652 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2653
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302654 if (params->scan_random.randomize)
2655 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2656 params->scan_random.mac_mask,
2657 &cmd->mac_addr,
2658 &cmd->mac_mask);
2659
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302660 if (ie_whitelist->white_list)
2661 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2662 &cmd->num_vendor_oui,
2663 ie_whitelist);
2664
Govind Singhd3156eb2016-02-26 17:50:39 +05302665 buf_ptr += sizeof(*cmd);
2666 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302667 for (i = 0; i < params->chan_list.num_chan; ++i)
2668 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302669
2670 WMITLV_SET_HDR(buf_ptr,
2671 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302672 (params->chan_list.num_chan * sizeof(uint32_t)));
2673 buf_ptr += WMI_TLV_HDR_SIZE +
2674 (params->chan_list.num_chan * sizeof(uint32_t));
2675
Govind Singh4eacd2b2016-03-07 14:24:22 +05302676 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302677 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302678 goto error;
2679 }
2680
2681 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2682 (params->num_ssids * sizeof(wmi_ssid)));
2683
2684 if (params->num_ssids) {
2685 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2686 for (i = 0; i < params->num_ssids; ++i) {
2687 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302688 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302689 params->ssid[i].length);
2690 ssid++;
2691 }
2692 }
2693 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2694
2695 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2696 (params->num_bssid * sizeof(wmi_mac_addr)));
2697 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302698
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302699 if (params->num_bssid) {
2700 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302701 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2702 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302703 bssid++;
2704 }
2705 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302706
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302707 buf_ptr += WMI_TLV_HDR_SIZE +
2708 (params->num_bssid * sizeof(wmi_mac_addr));
2709
2710 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2711 if (params->extraie.len)
2712 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2713 params);
2714
2715 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302716
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302717 /* probe req ie whitelisting */
2718 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2719 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2720
2721 buf_ptr += WMI_TLV_HDR_SIZE;
2722
2723 if (cmd->num_vendor_oui) {
2724 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2725 ie_whitelist->voui);
2726 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2727 }
2728
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302729 /* Add phy mode TLV if it's a wide band scan */
2730 if (params->scan_f_wide_band) {
2731 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2732 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2733 for (i = 0; i < params->chan_list.num_chan; ++i)
2734 buf_ptr[i] =
2735 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2736 buf_ptr += phymode_roundup;
2737 } else {
2738 /* Add ZERO legth phy mode TLV */
2739 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2740 }
2741
Santosh Anbu1e11b472018-03-07 15:33:27 +05302742 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002743 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302744 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302745 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302746 wmi_buf_free(wmi_buf);
2747 }
2748 return ret;
2749error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302750 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302751 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302752}
2753
2754/**
2755 * send_scan_stop_cmd_tlv() - WMI scan start function
2756 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302757 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302758 *
2759 * Return: 0 on success and -ve on failure.
2760 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302761static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302762 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302763{
Govind Singhd3156eb2016-02-26 17:50:39 +05302764 wmi_stop_scan_cmd_fixed_param *cmd;
2765 int ret;
2766 int len = sizeof(*cmd);
2767 wmi_buf_t wmi_buf;
2768
2769 /* Allocate the memory */
2770 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2771 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302772 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302773 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302774 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302775 goto error;
2776 }
2777
2778 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2779 WMITLV_SET_HDR(&cmd->tlv_header,
2780 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2781 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2782 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302783 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302784 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302785 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2786 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302787 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302788 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2789 /* Cancelling all scans */
2790 cmd->req_type = WMI_SCAN_STOP_ALL;
2791 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2792 /* Cancelling VAP scans */
2793 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2794 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2795 /* Cancelling specific scan */
2796 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302797 } else {
2798 WMI_LOGE("%s: Invalid Command : ", __func__);
2799 wmi_buf_free(wmi_buf);
2800 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302801 }
2802
Santosh Anbu1e11b472018-03-07 15:33:27 +05302803 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002804 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302805 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302806 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302807 wmi_buf_free(wmi_buf);
2808 }
2809
2810error:
2811 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302812}
2813
Govind Singh87542482016-06-08 19:40:11 +05302814#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302815/**
2816 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2817 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302818 * @param param : pointer to hold scan channel list parameter
2819 *
2820 * Return: 0 on success and -ve on failure.
2821 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302822static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302823 struct scan_chan_list_params *chan_list)
2824{
2825 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302826 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302827 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302828 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302829 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302830 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302831 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2832
2833 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2834 buf = wmi_buf_alloc(wmi_handle, len);
2835 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302836 WMI_LOGE("Failed to allocate memory");
2837 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302838 goto end;
2839 }
2840
2841 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2842 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2843 WMITLV_SET_HDR(&cmd->tlv_header,
2844 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2845 WMITLV_GET_STRUCT_TLVLEN
2846 (wmi_scan_chan_list_cmd_fixed_param));
2847
Govind Singhb53420c2016-03-09 14:32:57 +05302848 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302849
2850 cmd->num_scan_chans = chan_list->num_scan_chans;
2851 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2852 WMITLV_TAG_ARRAY_STRUC,
2853 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302854 chan_info = (wmi_channel_param *)
2855 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302856 tchan_info = chan_list->chan_info;
2857
2858 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2859 WMITLV_SET_HDR(&chan_info->tlv_header,
2860 WMITLV_TAG_STRUC_wmi_channel,
2861 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2862 chan_info->mhz = tchan_info->mhz;
2863 chan_info->band_center_freq1 =
2864 tchan_info->band_center_freq1;
2865 chan_info->band_center_freq2 =
2866 tchan_info->band_center_freq2;
2867 chan_info->info = tchan_info->info;
2868 chan_info->reg_info_1 = tchan_info->reg_info_1;
2869 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302870 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302871
2872 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2873 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2874 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2875 tchan_info++;
2876 chan_info++;
2877 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302878 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2879 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302880
Anish Natarajdd855152017-03-20 12:49:08 +05302881 qdf_status = wmi_unified_cmd_send(wmi_handle,
2882 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302883
Govind Singh67922e82016-04-01 16:48:57 +05302884 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302885 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302886 wmi_buf_free(buf);
2887 }
Govind Singh67922e82016-04-01 16:48:57 +05302888
Govind Singhd3156eb2016-02-26 17:50:39 +05302889end:
Govind Singhb53420c2016-03-09 14:32:57 +05302890 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302891}
Govind Singh87542482016-06-08 19:40:11 +05302892#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302893static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302894 struct scan_chan_list_params *chan_list)
2895{
2896 wmi_buf_t buf;
2897 QDF_STATUS qdf_status;
2898 wmi_scan_chan_list_cmd_fixed_param *cmd;
2899 int i;
2900 uint8_t *buf_ptr;
2901 wmi_channel *chan_info;
2902 struct channel_param *tchan_info;
2903 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302904
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302905 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302906 buf = wmi_buf_alloc(wmi_handle, len);
2907 if (!buf) {
2908 WMI_LOGE("Failed to allocate memory");
2909 qdf_status = QDF_STATUS_E_NOMEM;
2910 goto end;
2911 }
2912
2913 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2914 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2915 WMITLV_SET_HDR(&cmd->tlv_header,
2916 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2917 WMITLV_GET_STRUCT_TLVLEN
2918 (wmi_scan_chan_list_cmd_fixed_param));
2919
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302920 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302921
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302922 if (chan_list->append)
2923 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2924
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302925 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2926 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302927 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302928 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2929 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302930 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302931 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2932 tchan_info = &(chan_list->ch_param[0]);
2933
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302934 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302935 WMITLV_SET_HDR(&chan_info->tlv_header,
2936 WMITLV_TAG_STRUC_wmi_channel,
2937 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2938 chan_info->mhz = tchan_info->mhz;
2939 chan_info->band_center_freq1 =
2940 tchan_info->cfreq1;
2941 chan_info->band_center_freq2 =
2942 tchan_info->cfreq2;
2943
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302944 if (tchan_info->is_chan_passive)
2945 WMI_SET_CHANNEL_FLAG(chan_info,
2946 WMI_CHAN_FLAG_PASSIVE);
2947
2948 if (tchan_info->allow_vht)
2949 WMI_SET_CHANNEL_FLAG(chan_info,
2950 WMI_CHAN_FLAG_ALLOW_VHT);
2951 else if (tchan_info->allow_ht)
2952 WMI_SET_CHANNEL_FLAG(chan_info,
2953 WMI_CHAN_FLAG_ALLOW_HT);
2954 WMI_SET_CHANNEL_MODE(chan_info,
2955 tchan_info->phy_mode);
2956
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05302957 if (tchan_info->half_rate)
2958 WMI_SET_CHANNEL_FLAG(chan_info,
2959 WMI_CHAN_FLAG_HALF_RATE);
2960
2961 if (tchan_info->quarter_rate)
2962 WMI_SET_CHANNEL_FLAG(chan_info,
2963 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302964
2965 /* also fill in power information */
2966 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2967 tchan_info->minpower);
2968 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2969 tchan_info->maxpower);
2970 WMI_SET_CHANNEL_REG_POWER(chan_info,
2971 tchan_info->maxregpower);
2972 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2973 tchan_info->antennamax);
2974 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2975 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08002976 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
2977 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302978
Govind Singh87542482016-06-08 19:40:11 +05302979 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2980
Govind Singh87542482016-06-08 19:40:11 +05302981 tchan_info++;
2982 chan_info++;
2983 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302984 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2985 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302986
Anish Natarajdd855152017-03-20 12:49:08 +05302987 qdf_status = wmi_unified_cmd_send(
2988 wmi_handle,
2989 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302990
2991 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2992 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2993 wmi_buf_free(buf);
2994 }
2995
2996end:
2997 return qdf_status;
2998}
2999#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05303000
3001/**
3002 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
3003 *
3004 * @bufp: Pointer to buffer
3005 * @param: Pointer to tx param
3006 *
3007 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
3008 */
3009static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
3010 struct tx_send_params param)
3011{
3012 wmi_tx_send_params *tx_param;
3013 QDF_STATUS status = QDF_STATUS_SUCCESS;
3014
3015 if (!bufp) {
3016 status = QDF_STATUS_E_FAILURE;
3017 return status;
3018 }
3019 tx_param = (wmi_tx_send_params *)bufp;
3020 WMITLV_SET_HDR(&tx_param->tlv_header,
3021 WMITLV_TAG_STRUC_wmi_tx_send_params,
3022 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
3023 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
3024 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
3025 param.mcs_mask);
3026 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
3027 param.nss_mask);
3028 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
3029 param.retry_limit);
3030 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
3031 param.chain_mask);
3032 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
3033 param.bw_mask);
3034 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
3035 param.preamble_type);
3036 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
3037 param.frame_type);
3038
3039 return status;
3040}
3041
Govind Singhd3156eb2016-02-26 17:50:39 +05303042/**
3043 * send_mgmt_cmd_tlv() - WMI scan start function
3044 * @wmi_handle : handle to WMI.
3045 * @param : pointer to hold mgmt cmd parameter
3046 *
3047 * Return: 0 on success and -ve on failure.
3048 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303049static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303050 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303051{
Govind Singh427ee5a2016-02-26 18:09:36 +05303052 wmi_buf_t buf;
3053 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3054 int32_t cmd_len;
3055 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303056 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303057 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303058 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303059 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3060 mgmt_tx_dl_frm_len;
3061
3062 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303063 WMI_TLV_HDR_SIZE +
3064 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303065
Sathish Kumar5b636932017-06-28 14:40:32 +05303066 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303067 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303068 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3069 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303070 }
3071
3072 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3073 bufp = (uint8_t *) cmd;
3074 WMITLV_SET_HDR(&cmd->tlv_header,
3075 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3076 WMITLV_GET_STRUCT_TLVLEN
3077 (wmi_mgmt_tx_send_cmd_fixed_param));
3078
3079 cmd->vdev_id = param->vdev_id;
3080
Govind Singh224a7312016-06-21 14:33:26 +05303081 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303082 cmd->chanfreq = param->chanfreq;
3083 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3084 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3085 sizeof(uint32_t)));
3086 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303087 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303088
3089 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3090 QDF_DMA_TO_DEVICE);
3091 if (status != QDF_STATUS_SUCCESS) {
3092 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303093 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303094 }
3095
Govind Singhb53420c2016-03-09 14:32:57 +05303096 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303097 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003098#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303099 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3100#endif
3101 cmd->frame_len = param->frm_len;
3102 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303103 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303104
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003105 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003106 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003107
Sathish Kumar5b636932017-06-28 14:40:32 +05303108 bufp += roundup(bufp_len, sizeof(uint32_t));
3109 if (param->tx_params_valid) {
3110 status = populate_tx_send_params(bufp, param->tx_param);
3111 if (status != QDF_STATUS_SUCCESS) {
3112 WMI_LOGE("%s: Populate TX send params failed",
3113 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303114 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303115 }
3116 cmd_len += sizeof(wmi_tx_send_params);
3117 }
3118
Govind Singh427ee5a2016-02-26 18:09:36 +05303119 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3120 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303121 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303122 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303123 }
Govind Singhb53420c2016-03-09 14:32:57 +05303124 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303125
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303126unmap_tx_frame:
3127 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3128 QDF_DMA_TO_DEVICE);
3129free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303130 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303131 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303132}
3133
3134/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303135 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3136 * @wmi_handle : handle to WMI.
3137 * @param : pointer to offchan data tx cmd parameter
3138 *
3139 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3140 */
3141static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3142 struct wmi_offchan_data_tx_params *param)
3143{
3144 wmi_buf_t buf;
3145 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3146 int32_t cmd_len;
3147 uint64_t dma_addr;
3148 void *qdf_ctx = param->qdf_ctx;
3149 uint8_t *bufp;
3150 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3151 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303152 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303153
3154 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303155 WMI_TLV_HDR_SIZE +
3156 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303157
Sathish Kumar5b636932017-06-28 14:40:32 +05303158 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303159 if (!buf) {
3160 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3161 return QDF_STATUS_E_NOMEM;
3162 }
3163
3164 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3165 bufp = (uint8_t *) cmd;
3166 WMITLV_SET_HDR(&cmd->tlv_header,
3167 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3168 WMITLV_GET_STRUCT_TLVLEN
3169 (wmi_offchan_data_tx_send_cmd_fixed_param));
3170
3171 cmd->vdev_id = param->vdev_id;
3172
3173 cmd->desc_id = param->desc_id;
3174 cmd->chanfreq = param->chanfreq;
3175 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3176 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3177 sizeof(uint32_t)));
3178 bufp += WMI_TLV_HDR_SIZE;
3179 qdf_mem_copy(bufp, param->pdata, bufp_len);
3180 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3181 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3182 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3183#if defined(HTT_PADDR64)
3184 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3185#endif
3186 cmd->frame_len = param->frm_len;
3187 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303188 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303189
3190 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3191 bufp, cmd->vdev_id, cmd->chanfreq);
3192
Sathish Kumar5b636932017-06-28 14:40:32 +05303193 bufp += roundup(bufp_len, sizeof(uint32_t));
3194 if (param->tx_params_valid) {
3195 status = populate_tx_send_params(bufp, param->tx_param);
3196 if (status != QDF_STATUS_SUCCESS) {
3197 WMI_LOGE("%s: Populate TX send params failed",
3198 __func__);
3199 goto err1;
3200 }
3201 cmd_len += sizeof(wmi_tx_send_params);
3202 }
3203
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303204 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3205 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3206 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303207 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303208 }
3209
3210 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303211
3212err1:
3213 wmi_buf_free(buf);
3214 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303215}
3216
3217/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303218 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3219 * @wmi_handle: wmi handle
3220 * @param_value: parameter value
3221 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303222 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303223 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303224static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303225 uint32_t param_value)
3226{
Govind Singh67922e82016-04-01 16:48:57 +05303227 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303228 wmi_modem_power_state_cmd_param *cmd;
3229 wmi_buf_t buf;
3230 uint16_t len = sizeof(*cmd);
3231
3232 buf = wmi_buf_alloc(wmi_handle, len);
3233 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303234 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303235 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303236 }
3237 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3238 WMITLV_SET_HDR(&cmd->tlv_header,
3239 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3240 WMITLV_GET_STRUCT_TLVLEN
3241 (wmi_modem_power_state_cmd_param));
3242 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303243 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303244 param_value);
3245 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3246 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303247 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303248 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303249 wmi_buf_free(buf);
3250 }
Govind Singh67922e82016-04-01 16:48:57 +05303251
Govind Singh427ee5a2016-02-26 18:09:36 +05303252 return ret;
3253}
3254
3255/**
3256 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3257 * @wmi_handle: wmi handle
3258 * @vdev_id: vdev id
3259 * @val: value
3260 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303261 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303262 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303263static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303264 uint32_t vdev_id, uint8_t val)
3265{
3266 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3267 wmi_buf_t buf;
3268 int32_t len = sizeof(*cmd);
3269
Govind Singhb53420c2016-03-09 14:32:57 +05303270 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303271
3272 buf = wmi_buf_alloc(wmi_handle, len);
3273 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303274 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303275 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303276 }
3277 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3278 WMITLV_SET_HDR(&cmd->tlv_header,
3279 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3280 WMITLV_GET_STRUCT_TLVLEN
3281 (wmi_sta_powersave_mode_cmd_fixed_param));
3282 cmd->vdev_id = vdev_id;
3283 if (val)
3284 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3285 else
3286 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3287
3288 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3289 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303290 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303291 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303292 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303293 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303294 }
Govind Singh5eb51532016-03-09 11:34:12 +05303295 return 0;
3296}
3297
Govind Singh427ee5a2016-02-26 18:09:36 +05303298/**
3299 * send_set_mimops_cmd_tlv() - set MIMO powersave
3300 * @wmi_handle: wmi handle
3301 * @vdev_id: vdev id
3302 * @value: value
3303 *
Govind Singhb53420c2016-03-09 14:32:57 +05303304 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303305 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303306static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303307 uint8_t vdev_id, int value)
3308{
Govind Singh67922e82016-04-01 16:48:57 +05303309 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303310 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3311 wmi_buf_t buf;
3312 uint16_t len = sizeof(*cmd);
3313
3314 buf = wmi_buf_alloc(wmi_handle, len);
3315 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303316 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303317 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303318 }
3319 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3320 WMITLV_SET_HDR(&cmd->tlv_header,
3321 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3322 WMITLV_GET_STRUCT_TLVLEN
3323 (wmi_sta_smps_force_mode_cmd_fixed_param));
3324
3325 cmd->vdev_id = vdev_id;
3326
Houston Hoffmanb5168052016-04-14 02:18:01 -07003327 /* WMI_SMPS_FORCED_MODE values do not directly map
3328 * to SM power save values defined in the specification.
3329 * Make sure to send the right mapping.
3330 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303331 switch (value) {
3332 case 0:
3333 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3334 break;
3335 case 1:
3336 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3337 break;
3338 case 2:
3339 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3340 break;
3341 case 3:
3342 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3343 break;
3344 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303345 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
3346 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303347 }
3348
Govind Singhb53420c2016-03-09 14:32:57 +05303349 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303350
3351 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3352 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303353 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303354 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303355 wmi_buf_free(buf);
3356 }
3357
3358 return ret;
3359}
3360
3361/**
3362 * send_set_smps_params_cmd_tlv() - set smps params
3363 * @wmi_handle: wmi handle
3364 * @vdev_id: vdev id
3365 * @value: value
3366 *
Govind Singhb53420c2016-03-09 14:32:57 +05303367 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303368 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303369static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303370 int value)
3371{
Govind Singh67922e82016-04-01 16:48:57 +05303372 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303373 wmi_sta_smps_param_cmd_fixed_param *cmd;
3374 wmi_buf_t buf;
3375 uint16_t len = sizeof(*cmd);
3376
3377 buf = wmi_buf_alloc(wmi_handle, len);
3378 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303379 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303380 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303381 }
3382 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3383 WMITLV_SET_HDR(&cmd->tlv_header,
3384 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3385 WMITLV_GET_STRUCT_TLVLEN
3386 (wmi_sta_smps_param_cmd_fixed_param));
3387
3388 cmd->vdev_id = vdev_id;
3389 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3390 cmd->param =
3391 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3392
Govind Singhb53420c2016-03-09 14:32:57 +05303393 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303394 cmd->param);
3395
3396 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3397 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303398 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303399 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303400 wmi_buf_free(buf);
3401 }
3402
3403 return ret;
3404}
3405
3406/**
3407 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3408 * @wmi_handle: wmi handle
3409 * @noa: p2p power save parameters
3410 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303411 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303412 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303413static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303414 struct p2p_ps_params *noa)
3415{
3416 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3417 wmi_p2p_noa_descriptor *noa_discriptor;
3418 wmi_buf_t buf;
3419 uint8_t *buf_ptr;
3420 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303421 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303422 uint32_t duration;
3423
Govind Singhb53420c2016-03-09 14:32:57 +05303424 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303425 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3426 buf = wmi_buf_alloc(wmi_handle, len);
3427 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303428 WMI_LOGE("Failed to allocate memory");
3429 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303430 goto end;
3431 }
3432
3433 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3434 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3435 WMITLV_SET_HDR(&cmd->tlv_header,
3436 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3437 WMITLV_GET_STRUCT_TLVLEN
3438 (wmi_p2p_set_noa_cmd_fixed_param));
3439 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3440 cmd->vdev_id = noa->session_id;
3441 cmd->enable = (duration) ? true : false;
3442 cmd->num_noa = 1;
3443
3444 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3445 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3446 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3447 sizeof
3448 (wmi_p2p_set_noa_cmd_fixed_param)
3449 + WMI_TLV_HDR_SIZE);
3450 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3451 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3452 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3453 noa_discriptor->type_count = noa->count;
3454 noa_discriptor->duration = duration;
3455 noa_discriptor->interval = noa->interval;
3456 noa_discriptor->start_time = 0;
3457
Govind Singhb53420c2016-03-09 14:32:57 +05303458 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303459 cmd->vdev_id, noa->count, noa_discriptor->duration,
3460 noa->interval);
3461 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3462 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303463 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303464 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303465 wmi_buf_free(buf);
3466 }
3467
3468end:
Govind Singhb53420c2016-03-09 14:32:57 +05303469 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303470 return status;
3471}
3472
3473
3474/**
3475 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3476 * @wmi_handle: wmi handle
3477 * @noa: p2p opp power save parameters
3478 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303479 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303480 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303481static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303482 struct p2p_ps_params *oppps)
3483{
3484 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3485 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303486 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303487
Govind Singhb53420c2016-03-09 14:32:57 +05303488 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303489 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303491 WMI_LOGE("Failed to allocate memory");
3492 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303493 goto end;
3494 }
3495
3496 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3497 WMITLV_SET_HDR(&cmd->tlv_header,
3498 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3499 WMITLV_GET_STRUCT_TLVLEN
3500 (wmi_p2p_set_oppps_cmd_fixed_param));
3501 cmd->vdev_id = oppps->session_id;
3502 if (oppps->ctwindow)
3503 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3504
3505 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303506 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303507 cmd->vdev_id, oppps->ctwindow);
3508 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3509 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303510 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303511 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303512 wmi_buf_free(buf);
3513 }
3514
3515end:
Govind Singhb53420c2016-03-09 14:32:57 +05303516 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303517 return status;
3518}
3519
Wu Gaocd3a8512017-03-13 20:17:34 +08003520#ifdef CONVERGED_P2P_ENABLE
3521/**
3522 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3523 * @wmi_handle: wmi handle
3524 * @param: p2p listen offload start parameters
3525 *
3526 * Return: QDF status
3527 */
3528static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3529 struct p2p_lo_start *param)
3530{
3531 wmi_buf_t buf;
3532 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3533 int32_t len = sizeof(*cmd);
3534 uint8_t *buf_ptr;
3535 QDF_STATUS status;
3536 int device_types_len_aligned;
3537 int probe_resp_len_aligned;
3538
3539 if (!param) {
3540 WMI_LOGE("lo start param is null");
3541 return QDF_STATUS_E_INVAL;
3542 }
3543
3544 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3545
3546 device_types_len_aligned =
3547 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303548 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003549 probe_resp_len_aligned =
3550 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303551 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003552
3553 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3554 probe_resp_len_aligned;
3555
3556 buf = wmi_buf_alloc(wmi_handle, len);
3557 if (!buf) {
3558 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3559 __func__);
3560 return QDF_STATUS_E_NOMEM;
3561 }
3562
3563 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3564 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3565
3566 WMITLV_SET_HDR(&cmd->tlv_header,
3567 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3568 WMITLV_GET_STRUCT_TLVLEN(
3569 wmi_p2p_lo_start_cmd_fixed_param));
3570
3571 cmd->vdev_id = param->vdev_id;
3572 cmd->ctl_flags = param->ctl_flags;
3573 cmd->channel = param->freq;
3574 cmd->period = param->period;
3575 cmd->interval = param->interval;
3576 cmd->count = param->count;
3577 cmd->device_types_len = param->dev_types_len;
3578 cmd->prob_resp_len = param->probe_resp_len;
3579
3580 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3581 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3582 device_types_len_aligned);
3583 buf_ptr += WMI_TLV_HDR_SIZE;
3584 qdf_mem_copy(buf_ptr, param->device_types,
3585 param->dev_types_len);
3586
3587 buf_ptr += device_types_len_aligned;
3588 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3589 probe_resp_len_aligned);
3590 buf_ptr += WMI_TLV_HDR_SIZE;
3591 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3592 param->probe_resp_len);
3593
3594 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3595 cmd->channel, cmd->period, cmd->interval, cmd->count);
3596
3597 status = wmi_unified_cmd_send(wmi_handle,
3598 buf, len,
3599 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3600 if (status != QDF_STATUS_SUCCESS) {
3601 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3602 __func__, status);
3603 wmi_buf_free(buf);
3604 return status;
3605 }
3606
3607 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3608
3609 return QDF_STATUS_SUCCESS;
3610}
3611
3612/**
3613 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3614 * @wmi_handle: wmi handle
3615 * @param: p2p listen offload stop parameters
3616 *
3617 * Return: QDF status
3618 */
3619static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3620 uint8_t vdev_id)
3621{
3622 wmi_buf_t buf;
3623 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3624 int32_t len;
3625 QDF_STATUS status;
3626
3627 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3628
3629 len = sizeof(*cmd);
3630 buf = wmi_buf_alloc(wmi_handle, len);
3631 if (!buf) {
3632 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3633 __func__);
3634 return QDF_STATUS_E_NOMEM;
3635 }
3636 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3637
3638 WMITLV_SET_HDR(&cmd->tlv_header,
3639 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3640 WMITLV_GET_STRUCT_TLVLEN(
3641 wmi_p2p_lo_stop_cmd_fixed_param));
3642
3643 cmd->vdev_id = vdev_id;
3644
3645 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3646
3647 status = wmi_unified_cmd_send(wmi_handle,
3648 buf, len,
3649 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3650 if (status != QDF_STATUS_SUCCESS) {
3651 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3652 __func__, status);
3653 wmi_buf_free(buf);
3654 return status;
3655 }
3656
3657 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3658
3659 return QDF_STATUS_SUCCESS;
3660}
3661#endif /* End of CONVERGED_P2P_ENABLE */
3662
Govind Singh427ee5a2016-02-26 18:09:36 +05303663/**
3664 * send_get_temperature_cmd_tlv() - get pdev temperature req
3665 * @wmi_handle: wmi handle
3666 *
Govind Singhb53420c2016-03-09 14:32:57 +05303667 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303668 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303669static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303670{
3671 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3672 wmi_buf_t wmi_buf;
3673 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3674 uint8_t *buf_ptr;
3675
3676 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303677 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3678 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303679 }
3680
3681 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3682 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303683 WMI_LOGE(FL("wmi_buf_alloc failed"));
3684 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303685 }
3686
3687 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3688
3689 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3690 WMITLV_SET_HDR(&cmd->tlv_header,
3691 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3692 WMITLV_GET_STRUCT_TLVLEN
3693 (wmi_pdev_get_temperature_cmd_fixed_param));
3694
3695 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3696 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303697 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303698 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303699 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303700 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303701
Govind Singhb53420c2016-03-09 14:32:57 +05303702 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303703}
3704
3705/**
3706 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3707 * @wmi_handle: wmi handle
3708 * @vdevid: vdev id
3709 * @peer_addr: peer mac address
3710 * @auto_triggerparam: auto trigger parameters
3711 * @num_ac: number of access category
3712 *
3713 * This function sets the trigger
3714 * uapsd params such as service interval, delay interval
3715 * and suspend interval which will be used by the firmware
3716 * to send trigger frames periodically when there is no
3717 * traffic on the transmit side.
3718 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303719 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303720 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303721static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303722 struct sta_uapsd_trig_params *param)
3723{
3724 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303725 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303726 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3727 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3728 uint32_t i;
3729 wmi_buf_t buf;
3730 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003731 struct sta_uapsd_params *uapsd_param;
3732 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303733
3734 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3735 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303736 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303737 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303738 }
3739
3740 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3741 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3742 WMITLV_SET_HDR(&cmd->tlv_header,
3743 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3744 WMITLV_GET_STRUCT_TLVLEN
3745 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3746 cmd->vdev_id = param->vdevid;
3747 cmd->num_ac = param->num_ac;
3748 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3749
3750 /* TLV indicating array of structures to follow */
3751 buf_ptr += sizeof(*cmd);
3752 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3753
3754 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303755
3756 /*
3757 * Update tag and length for uapsd auto trigger params (this will take
3758 * care of updating tag and length if it is not pre-filled by caller).
3759 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003760 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3761 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303762 for (i = 0; i < param->num_ac; i++) {
3763 WMITLV_SET_HDR((buf_ptr +
3764 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3765 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3766 WMITLV_GET_STRUCT_TLVLEN
3767 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003768 trig_param->wmm_ac = uapsd_param->wmm_ac;
3769 trig_param->user_priority = uapsd_param->user_priority;
3770 trig_param->service_interval = uapsd_param->service_interval;
3771 trig_param->suspend_interval = uapsd_param->suspend_interval;
3772 trig_param->delay_interval = uapsd_param->delay_interval;
3773 trig_param++;
3774 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303775 }
3776
3777 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3778 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303779 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303780 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303781 wmi_buf_free(buf);
3782 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303783
Govind Singh427ee5a2016-02-26 18:09:36 +05303784 return ret;
3785}
3786
Zhang Qian11c0de32018-01-05 16:50:53 +08003787#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303788/**
3789 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3790 * @wmi_handle: pointer to the wmi handle
3791 * @utc: pointer to the UTC time struct
3792 *
3793 * Return: 0 on succes
3794 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303795static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303796 struct ocb_utc_param *utc)
3797{
Govind Singh67922e82016-04-01 16:48:57 +05303798 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303799 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3800 uint8_t *buf_ptr;
3801 uint32_t len, i;
3802 wmi_buf_t buf;
3803
3804 len = sizeof(*cmd);
3805 buf = wmi_buf_alloc(wmi_handle, len);
3806 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303807 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303808 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303809 }
3810
3811 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3812 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3813 WMITLV_SET_HDR(&cmd->tlv_header,
3814 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3815 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3816 cmd->vdev_id = utc->vdev_id;
3817
3818 for (i = 0; i < SIZE_UTC_TIME; i++)
3819 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3820
3821 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3822 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3823
3824 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3825 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303826 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303827 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303828 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303829 }
3830
Govind Singh67922e82016-04-01 16:48:57 +05303831 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303832}
3833
3834/**
3835 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3836 * frames on a channel
3837 * @wmi_handle: pointer to the wmi handle
3838 * @timing_advert: pointer to the timing advertisement struct
3839 *
3840 * Return: 0 on succes
3841 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303842static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303843 struct ocb_timing_advert_param *timing_advert)
3844{
Govind Singh67922e82016-04-01 16:48:57 +05303845 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303846 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3847 uint8_t *buf_ptr;
3848 uint32_t len, len_template;
3849 wmi_buf_t buf;
3850
3851 len = sizeof(*cmd) +
3852 WMI_TLV_HDR_SIZE;
3853
3854 len_template = timing_advert->template_length;
3855 /* Add padding to the template if needed */
3856 if (len_template % 4 != 0)
3857 len_template += 4 - (len_template % 4);
3858 len += len_template;
3859
3860 buf = wmi_buf_alloc(wmi_handle, len);
3861 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303862 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303863 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303864 }
3865
3866 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3867 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3868 WMITLV_SET_HDR(&cmd->tlv_header,
3869 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3870 WMITLV_GET_STRUCT_TLVLEN(
3871 wmi_ocb_start_timing_advert_cmd_fixed_param));
3872 cmd->vdev_id = timing_advert->vdev_id;
3873 cmd->repeat_rate = timing_advert->repeat_rate;
3874 cmd->channel_freq = timing_advert->chan_freq;
3875 cmd->timestamp_offset = timing_advert->timestamp_offset;
3876 cmd->time_value_offset = timing_advert->time_value_offset;
3877 cmd->timing_advert_template_length = timing_advert->template_length;
3878 buf_ptr += sizeof(*cmd);
3879
3880 /* Add the timing advert template */
3881 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3882 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303883 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303884 (uint8_t *)timing_advert->template_value,
3885 timing_advert->template_length);
3886
3887 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3888 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303889 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303890 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303891 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303892 }
3893
Govind Singh67922e82016-04-01 16:48:57 +05303894 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303895}
3896
3897/**
3898 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3899 * on a channel
3900 * @wmi_handle: pointer to the wmi handle
3901 * @timing_advert: pointer to the timing advertisement struct
3902 *
3903 * Return: 0 on succes
3904 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303905static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303906 struct ocb_timing_advert_param *timing_advert)
3907{
Govind Singh67922e82016-04-01 16:48:57 +05303908 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303909 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3910 uint8_t *buf_ptr;
3911 uint32_t len;
3912 wmi_buf_t buf;
3913
3914 len = sizeof(*cmd);
3915 buf = wmi_buf_alloc(wmi_handle, len);
3916 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303917 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303918 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303919 }
3920
3921 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3922 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3923 WMITLV_SET_HDR(&cmd->tlv_header,
3924 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3925 WMITLV_GET_STRUCT_TLVLEN(
3926 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3927 cmd->vdev_id = timing_advert->vdev_id;
3928 cmd->channel_freq = timing_advert->chan_freq;
3929
3930 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3931 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303932 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303933 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303934 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303935 }
3936
Govind Singh67922e82016-04-01 16:48:57 +05303937 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303938}
3939
3940/**
3941 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3942 * @wmi_handle: pointer to the wmi handle
3943 * @request: pointer to the request
3944 *
3945 * Return: 0 on succes
3946 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303947static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303948 uint8_t vdev_id)
3949{
Govind Singhb53420c2016-03-09 14:32:57 +05303950 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303951 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3952 uint8_t *buf_ptr;
3953 wmi_buf_t buf;
3954 int32_t len;
3955
3956 len = sizeof(*cmd);
3957 buf = wmi_buf_alloc(wmi_handle, len);
3958 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303959 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303960 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303961 }
3962 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3963
3964 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303965 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303966 WMITLV_SET_HDR(&cmd->tlv_header,
3967 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3968 WMITLV_GET_STRUCT_TLVLEN(
3969 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3970 cmd->vdev_id = vdev_id;
3971
3972 /* Send the WMI command */
3973 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3974 WMI_OCB_GET_TSF_TIMER_CMDID);
3975 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303976 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303977 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303978 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303979 }
3980
Govind Singh67922e82016-04-01 16:48:57 +05303981 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303982}
3983
3984/**
3985 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3986 * @wmi_handle: pointer to the wmi handle
3987 * @get_stats_param: pointer to the dcc stats
3988 *
3989 * Return: 0 on succes
3990 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303991static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08003992 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05303993{
Govind Singh67922e82016-04-01 16:48:57 +05303994 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303995 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3996 wmi_dcc_channel_stats_request *channel_stats_array;
3997 wmi_buf_t buf;
3998 uint8_t *buf_ptr;
3999 uint32_t len;
4000 uint32_t i;
4001
4002 /* Validate the input */
4003 if (get_stats_param->request_array_len !=
4004 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304005 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304006 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304007 }
4008
4009 /* Allocate memory for the WMI command */
4010 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4011 get_stats_param->request_array_len;
4012
4013 buf = wmi_buf_alloc(wmi_handle, len);
4014 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304015 WMI_LOGE(FL("wmi_buf_alloc failed"));
4016 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304017 }
4018
4019 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304020 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304021
4022 /* Populate the WMI command */
4023 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4024 buf_ptr += sizeof(*cmd);
4025
4026 WMITLV_SET_HDR(&cmd->tlv_header,
4027 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4028 WMITLV_GET_STRUCT_TLVLEN(
4029 wmi_dcc_get_stats_cmd_fixed_param));
4030 cmd->vdev_id = get_stats_param->vdev_id;
4031 cmd->num_channels = get_stats_param->channel_count;
4032
4033 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4034 get_stats_param->request_array_len);
4035 buf_ptr += WMI_TLV_HDR_SIZE;
4036
4037 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304038 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304039 get_stats_param->request_array_len);
4040 for (i = 0; i < cmd->num_channels; i++)
4041 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4042 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4043 WMITLV_GET_STRUCT_TLVLEN(
4044 wmi_dcc_channel_stats_request));
4045
4046 /* Send the WMI command */
4047 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4048 WMI_DCC_GET_STATS_CMDID);
4049
Govind Singh67922e82016-04-01 16:48:57 +05304050 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304051 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304052 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304053 }
4054
Govind Singh67922e82016-04-01 16:48:57 +05304055 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304056}
4057
4058/**
4059 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4060 * @wmi_handle: pointer to the wmi handle
4061 * @vdev_id: vdev id
4062 * @dcc_stats_bitmap: dcc status bitmap
4063 *
4064 * Return: 0 on succes
4065 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304066static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304067 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4068{
Govind Singh67922e82016-04-01 16:48:57 +05304069 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304070 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4071 wmi_buf_t buf;
4072 uint8_t *buf_ptr;
4073 uint32_t len;
4074
4075 /* Allocate memory for the WMI command */
4076 len = sizeof(*cmd);
4077
4078 buf = wmi_buf_alloc(wmi_handle, len);
4079 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304080 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304081 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304082 }
4083
4084 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304085 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304086
4087 /* Populate the WMI command */
4088 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4089
4090 WMITLV_SET_HDR(&cmd->tlv_header,
4091 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4092 WMITLV_GET_STRUCT_TLVLEN(
4093 wmi_dcc_clear_stats_cmd_fixed_param));
4094 cmd->vdev_id = vdev_id;
4095 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4096
4097 /* Send the WMI command */
4098 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4099 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304100 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304101 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304102 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304103 }
4104
Govind Singh67922e82016-04-01 16:48:57 +05304105 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304106}
4107
4108/**
4109 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4110 * @wmi_handle: pointer to the wmi handle
4111 * @update_ndl_param: pointer to the request parameters
4112 *
4113 * Return: 0 on success
4114 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304115static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004116 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304117{
Govind Singhb53420c2016-03-09 14:32:57 +05304118 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304119 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4120 wmi_dcc_ndl_chan *ndl_chan_array;
4121 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4122 uint32_t active_state_count;
4123 wmi_buf_t buf;
4124 uint8_t *buf_ptr;
4125 uint32_t len;
4126 uint32_t i;
4127
4128 /* validate the input */
4129 if (update_ndl_param->dcc_ndl_chan_list_len !=
4130 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304131 WMI_LOGE(FL("Invalid parameter"));
4132 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304133 }
4134 active_state_count = 0;
4135 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4136 for (i = 0; i < update_ndl_param->channel_count; i++)
4137 active_state_count +=
4138 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4139 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4140 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304141 WMI_LOGE(FL("Invalid parameter"));
4142 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304143 }
4144
4145 /* Allocate memory for the WMI command */
4146 len = sizeof(*cmd) +
4147 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4148 WMI_TLV_HDR_SIZE +
4149 update_ndl_param->dcc_ndl_active_state_list_len;
4150
4151 buf = wmi_buf_alloc(wmi_handle, len);
4152 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304153 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304154 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304155 }
4156
4157 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304158 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304159
4160 /* Populate the WMI command */
4161 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4162 buf_ptr += sizeof(*cmd);
4163
4164 WMITLV_SET_HDR(&cmd->tlv_header,
4165 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4166 WMITLV_GET_STRUCT_TLVLEN(
4167 wmi_dcc_update_ndl_cmd_fixed_param));
4168 cmd->vdev_id = update_ndl_param->vdev_id;
4169 cmd->num_channel = update_ndl_param->channel_count;
4170
4171 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4172 update_ndl_param->dcc_ndl_chan_list_len);
4173 buf_ptr += WMI_TLV_HDR_SIZE;
4174
4175 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304176 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304177 update_ndl_param->dcc_ndl_chan_list_len);
4178 for (i = 0; i < cmd->num_channel; i++)
4179 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4180 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4181 WMITLV_GET_STRUCT_TLVLEN(
4182 wmi_dcc_ndl_chan));
4183 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4184
4185 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4186 update_ndl_param->dcc_ndl_active_state_list_len);
4187 buf_ptr += WMI_TLV_HDR_SIZE;
4188
4189 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304190 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304191 update_ndl_param->dcc_ndl_active_state_list,
4192 update_ndl_param->dcc_ndl_active_state_list_len);
4193 for (i = 0; i < active_state_count; i++) {
4194 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4195 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4196 WMITLV_GET_STRUCT_TLVLEN(
4197 wmi_dcc_ndl_active_state_config));
4198 }
4199 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4200
4201 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304202 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304203 WMI_DCC_UPDATE_NDL_CMDID);
4204 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304205 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304206 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304207 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304208 }
4209
Govind Singh67922e82016-04-01 16:48:57 +05304210 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304211}
4212
4213/**
4214 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4215 * @wmi_handle: pointer to the wmi handle
4216 * @config: the OCB configuration
4217 *
4218 * Return: 0 on success
4219 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304220static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004221 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304222{
Govind Singh67922e82016-04-01 16:48:57 +05304223 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304224 wmi_ocb_set_config_cmd_fixed_param *cmd;
4225 wmi_channel *chan;
4226 wmi_ocb_channel *ocb_chan;
4227 wmi_qos_parameter *qos_param;
4228 wmi_dcc_ndl_chan *ndl_chan;
4229 wmi_dcc_ndl_active_state_config *ndl_active_config;
4230 wmi_ocb_schedule_element *sched_elem;
4231 uint8_t *buf_ptr;
4232 wmi_buf_t buf;
4233 int32_t len;
4234 int32_t i, j, active_state_count;
4235
4236 /*
4237 * Validate the dcc_ndl_chan_list_len and count the number of active
4238 * states. Validate dcc_ndl_active_state_list_len.
4239 */
4240 active_state_count = 0;
4241 if (config->dcc_ndl_chan_list_len) {
4242 if (!config->dcc_ndl_chan_list ||
4243 config->dcc_ndl_chan_list_len !=
4244 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304245 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304246 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304247 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304248 }
4249
4250 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4251 i < config->channel_count; ++i, ++ndl_chan)
4252 active_state_count +=
4253 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4254
4255 if (active_state_count) {
4256 if (!config->dcc_ndl_active_state_list ||
4257 config->dcc_ndl_active_state_list_len !=
4258 active_state_count *
4259 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304260 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304261 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304262 }
4263 }
4264 }
4265
4266 len = sizeof(*cmd) +
4267 WMI_TLV_HDR_SIZE + config->channel_count *
4268 sizeof(wmi_channel) +
4269 WMI_TLV_HDR_SIZE + config->channel_count *
4270 sizeof(wmi_ocb_channel) +
4271 WMI_TLV_HDR_SIZE + config->channel_count *
4272 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4273 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4274 WMI_TLV_HDR_SIZE + active_state_count *
4275 sizeof(wmi_dcc_ndl_active_state_config) +
4276 WMI_TLV_HDR_SIZE + config->schedule_size *
4277 sizeof(wmi_ocb_schedule_element);
4278 buf = wmi_buf_alloc(wmi_handle, len);
4279 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304280 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304281 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304282 }
4283
4284 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4285 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4286 WMITLV_SET_HDR(&cmd->tlv_header,
4287 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4288 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004289 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304290 cmd->channel_count = config->channel_count;
4291 cmd->schedule_size = config->schedule_size;
4292 cmd->flags = config->flags;
4293 buf_ptr += sizeof(*cmd);
4294
4295 /* Add the wmi_channel info */
4296 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4297 config->channel_count*sizeof(wmi_channel));
4298 buf_ptr += WMI_TLV_HDR_SIZE;
4299 for (i = 0; i < config->channel_count; i++) {
4300 chan = (wmi_channel *)buf_ptr;
4301 WMITLV_SET_HDR(&chan->tlv_header,
4302 WMITLV_TAG_STRUC_wmi_channel,
4303 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4304 chan->mhz = config->channels[i].chan_freq;
4305 chan->band_center_freq1 = config->channels[i].chan_freq;
4306 chan->band_center_freq2 = 0;
4307 chan->info = 0;
4308
Zhang Qian11c0de32018-01-05 16:50:53 +08004309 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304310 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4311 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4312 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4313 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4314 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4315 config->channels[i].antenna_max);
4316
4317 if (config->channels[i].bandwidth < 10)
4318 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4319 else if (config->channels[i].bandwidth < 20)
4320 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4321 buf_ptr += sizeof(*chan);
4322 }
4323
4324 /* Add the wmi_ocb_channel info */
4325 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4326 config->channel_count*sizeof(wmi_ocb_channel));
4327 buf_ptr += WMI_TLV_HDR_SIZE;
4328 for (i = 0; i < config->channel_count; i++) {
4329 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4330 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4331 WMITLV_TAG_STRUC_wmi_ocb_channel,
4332 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4333 ocb_chan->bandwidth = config->channels[i].bandwidth;
4334 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4335 config->channels[i].mac_address.bytes,
4336 &ocb_chan->mac_address);
4337 buf_ptr += sizeof(*ocb_chan);
4338 }
4339
4340 /* Add the wmi_qos_parameter info */
4341 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4342 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4343 buf_ptr += WMI_TLV_HDR_SIZE;
4344 /* WMI_MAX_NUM_AC parameters for each channel */
4345 for (i = 0; i < config->channel_count; i++) {
4346 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4347 qos_param = (wmi_qos_parameter *)buf_ptr;
4348 WMITLV_SET_HDR(&qos_param->tlv_header,
4349 WMITLV_TAG_STRUC_wmi_qos_parameter,
4350 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4351 qos_param->aifsn =
4352 config->channels[i].qos_params[j].aifsn;
4353 qos_param->cwmin =
4354 config->channels[i].qos_params[j].cwmin;
4355 qos_param->cwmax =
4356 config->channels[i].qos_params[j].cwmax;
4357 buf_ptr += sizeof(*qos_param);
4358 }
4359 }
4360
4361 /* Add the wmi_dcc_ndl_chan (per channel) */
4362 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4363 config->dcc_ndl_chan_list_len);
4364 buf_ptr += WMI_TLV_HDR_SIZE;
4365 if (config->dcc_ndl_chan_list_len) {
4366 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304367 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304368 config->dcc_ndl_chan_list_len);
4369 for (i = 0; i < config->channel_count; i++)
4370 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4371 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4372 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4373 buf_ptr += config->dcc_ndl_chan_list_len;
4374 }
4375
4376 /* Add the wmi_dcc_ndl_active_state_config */
4377 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4378 sizeof(wmi_dcc_ndl_active_state_config));
4379 buf_ptr += WMI_TLV_HDR_SIZE;
4380 if (active_state_count) {
4381 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304382 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304383 config->dcc_ndl_active_state_list,
4384 active_state_count * sizeof(*ndl_active_config));
4385 for (i = 0; i < active_state_count; ++i)
4386 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4387 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4388 WMITLV_GET_STRUCT_TLVLEN(
4389 wmi_dcc_ndl_active_state_config));
4390 buf_ptr += active_state_count *
4391 sizeof(*ndl_active_config);
4392 }
4393
4394 /* Add the wmi_ocb_schedule_element info */
4395 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4396 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4397 buf_ptr += WMI_TLV_HDR_SIZE;
4398 for (i = 0; i < config->schedule_size; i++) {
4399 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4400 WMITLV_SET_HDR(&sched_elem->tlv_header,
4401 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4402 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4403 sched_elem->channel_freq = config->schedule[i].chan_freq;
4404 sched_elem->total_duration = config->schedule[i].total_duration;
4405 sched_elem->guard_interval = config->schedule[i].guard_interval;
4406 buf_ptr += sizeof(*sched_elem);
4407 }
4408
4409
4410 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4411 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304412 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304413 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304414 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304415 }
4416
Govind Singh67922e82016-04-01 16:48:57 +05304417 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304418}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304419
4420/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004421 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4422 * @wmi_handle: wmi handle
4423 * @evt_buf: wmi event buffer
4424 * @status: status buffer
4425 *
4426 * Return: QDF_STATUS_SUCCESS on success
4427 */
4428static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4429 void *evt_buf,
4430 uint32_t *status)
4431{
4432 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4433 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4434
4435 param_tlvs = evt_buf;
4436 fix_param = param_tlvs->fixed_param;
4437
4438 *status = fix_param->status;
4439 return QDF_STATUS_SUCCESS;
4440}
4441
4442/**
4443 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4444 * @wmi_handle: wmi handle
4445 * @evt_buf: wmi event buffer
4446 * @resp: response buffer
4447 *
4448 * Return: QDF_STATUS_SUCCESS on success
4449 */
4450static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4451 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4452{
4453 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4454 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4455
4456 param_tlvs = evt_buf;
4457 fix_param = param_tlvs->fixed_param;
4458 resp->vdev_id = fix_param->vdev_id;
4459 resp->timer_high = fix_param->tsf_timer_high;
4460 resp->timer_low = fix_param->tsf_timer_low;
4461
4462 return QDF_STATUS_SUCCESS;
4463}
4464
4465/**
4466 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4467 * @wmi_handle: wmi handle
4468 * @evt_buf: wmi event buffer
4469 * @resp: response buffer
4470 *
4471 * Return: QDF_STATUS_SUCCESS on success
4472 */
4473static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4474 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4475{
4476 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4477 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4478
4479 param_tlvs = evt_buf;
4480 fix_param = param_tlvs->fixed_param;
4481 resp->vdev_id = fix_param->vdev_id;
4482 resp->status = fix_param->status;
4483 return QDF_STATUS_SUCCESS;
4484}
4485
4486/**
4487 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4488 * @wmi_handle: wmi handle
4489 * @evt_buf: wmi event buffer
4490 * @resp: response buffer
4491 *
4492 * Since length of stats is variable, buffer for DCC stats will be allocated
4493 * in this function. The caller must free the buffer.
4494 *
4495 * Return: QDF_STATUS_SUCCESS on success
4496 */
4497static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4498 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4499{
4500 struct ocb_dcc_get_stats_response *response;
4501 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4502 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4503
4504 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4505 fix_param = param_tlvs->fixed_param;
4506
4507 /* Allocate and populate the response */
4508 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4509 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4510 WMI_LOGE("%s: too many channels:%d", __func__,
4511 fix_param->num_channels);
4512 QDF_ASSERT(0);
4513 *resp = NULL;
4514 return QDF_STATUS_E_INVAL;
4515 }
4516 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4517 sizeof(wmi_dcc_ndl_stats_per_channel));
4518 *resp = response;
4519 if (!response)
4520 return QDF_STATUS_E_NOMEM;
4521
4522 response->vdev_id = fix_param->vdev_id;
4523 response->num_channels = fix_param->num_channels;
4524 response->channel_stats_array_len =
4525 fix_param->num_channels *
4526 sizeof(wmi_dcc_ndl_stats_per_channel);
4527 response->channel_stats_array = ((uint8_t *)response) +
4528 sizeof(*response);
4529 qdf_mem_copy(response->channel_stats_array,
4530 param_tlvs->stats_per_channel_list,
4531 response->channel_stats_array_len);
4532
4533 return QDF_STATUS_SUCCESS;
4534}
4535#endif
4536
4537/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304538 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4539 * @wmi_handle: wmi handle
4540 * @mcc_adaptive_scheduler: enable/disable
4541 *
4542 * This function enable/disable mcc adaptive scheduler in fw.
4543 *
Govind Singhb53420c2016-03-09 14:32:57 +05304544 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304545 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304546static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004547 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4548 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304549{
Govind Singh67922e82016-04-01 16:48:57 +05304550 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304551 wmi_buf_t buf = 0;
4552 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4553 uint16_t len =
4554 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4555
4556 buf = wmi_buf_alloc(wmi_handle, len);
4557 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304558 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4559 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304560 }
4561 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4562 wmi_buf_data(buf);
4563
4564 WMITLV_SET_HDR(&cmd->tlv_header,
4565 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4566 WMITLV_GET_STRUCT_TLVLEN
4567 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4568 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304569 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304570
4571 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4572 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304573 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304574 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304575 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304576 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304577 }
Govind Singh67922e82016-04-01 16:48:57 +05304578
4579 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304580}
4581
4582/**
4583 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4584 * @wmi: wmi handle
4585 * @mcc_channel: mcc channel
4586 * @mcc_channel_time_latency: MCC channel time latency.
4587 *
4588 * Currently used to set time latency for an MCC vdev/adapter using operating
4589 * channel of it and channel number. The info is provided run time using
4590 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4591 *
4592 * Return: CDF status
4593 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304594static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304595 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4596{
Govind Singh67922e82016-04-01 16:48:57 +05304597 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304598 wmi_buf_t buf = 0;
4599 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4600 uint16_t len = 0;
4601 uint8_t *buf_ptr = NULL;
4602 wmi_resmgr_chan_latency chan_latency;
4603 /* Note: we only support MCC time latency for a single channel */
4604 uint32_t num_channels = 1;
4605 uint32_t chan1_freq = mcc_channel_freq;
4606 uint32_t latency_chan1 = mcc_channel_time_latency;
4607
4608
4609 /* If 0ms latency is provided, then FW will set to a default.
4610 * Otherwise, latency must be at least 30ms.
4611 */
4612 if ((latency_chan1 > 0) &&
4613 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304614 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304615 "Minimum is 30ms (or 0 to use default value by "
4616 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304617 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304618 }
4619
4620 /* Set WMI CMD for channel time latency here */
4621 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4622 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4623 num_channels * sizeof(wmi_resmgr_chan_latency);
4624 buf = wmi_buf_alloc(wmi_handle, len);
4625 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304626 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4627 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304628 }
4629 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4630 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4631 wmi_buf_data(buf);
4632 WMITLV_SET_HDR(&cmdTL->tlv_header,
4633 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4634 WMITLV_GET_STRUCT_TLVLEN
4635 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4636 cmdTL->num_chans = num_channels;
4637 /* Update channel time latency information for home channel(s) */
4638 buf_ptr += sizeof(*cmdTL);
4639 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4640 num_channels * sizeof(wmi_resmgr_chan_latency));
4641 buf_ptr += WMI_TLV_HDR_SIZE;
4642 chan_latency.chan_mhz = chan1_freq;
4643 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304644 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304645 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4646 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304647 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304648 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304649 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304650 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304651 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304652 }
Govind Singh67922e82016-04-01 16:48:57 +05304653
4654 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304655}
4656
4657/**
4658 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4659 * @wmi: wmi handle
4660 * @adapter_1_chan_number: adapter 1 channel number
4661 * @adapter_1_quota: adapter 1 quota
4662 * @adapter_2_chan_number: adapter 2 channel number
4663 *
4664 * Return: CDF status
4665 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304666static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304667 uint32_t adapter_1_chan_freq,
4668 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4669{
Govind Singh67922e82016-04-01 16:48:57 +05304670 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304671 wmi_buf_t buf = 0;
4672 uint16_t len = 0;
4673 uint8_t *buf_ptr = NULL;
4674 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4675 wmi_resmgr_chan_time_quota chan_quota;
4676 uint32_t quota_chan1 = adapter_1_quota;
4677 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4678 uint32_t quota_chan2 = 100 - quota_chan1;
4679 /* Note: setting time quota for MCC requires info for 2 channels */
4680 uint32_t num_channels = 2;
4681 uint32_t chan1_freq = adapter_1_chan_freq;
4682 uint32_t chan2_freq = adapter_2_chan_freq;
4683
Govind Singhb53420c2016-03-09 14:32:57 +05304684 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304685 "freq2:%dMHz, Quota2:%dms", __func__,
4686 chan1_freq, quota_chan1, chan2_freq,
4687 quota_chan2);
4688
4689 /*
4690 * Perform sanity check on time quota values provided.
4691 */
4692 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4693 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304694 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304695 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304696 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304697 }
4698 /* Set WMI CMD for channel time quota here */
4699 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4700 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4701 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4702 buf = wmi_buf_alloc(wmi_handle, len);
4703 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304704 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4705 QDF_ASSERT(0);
4706 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304707 }
4708 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4709 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4710 wmi_buf_data(buf);
4711 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4712 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4713 WMITLV_GET_STRUCT_TLVLEN
4714 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4715 cmdTQ->num_chans = num_channels;
4716
4717 /* Update channel time quota information for home channel(s) */
4718 buf_ptr += sizeof(*cmdTQ);
4719 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4720 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4721 buf_ptr += WMI_TLV_HDR_SIZE;
4722 chan_quota.chan_mhz = chan1_freq;
4723 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304724 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304725 /* Construct channel and quota record for the 2nd MCC mode. */
4726 buf_ptr += sizeof(chan_quota);
4727 chan_quota.chan_mhz = chan2_freq;
4728 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304729 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304730
4731 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4732 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304733 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304734 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304735 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304736 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304737 }
Govind Singh67922e82016-04-01 16:48:57 +05304738
4739 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304740}
4741
4742/**
4743 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4744 * @wmi_handle: Pointer to wmi handle
4745 * @thermal_info: Thermal command information
4746 *
4747 * This function sends the thermal management command
4748 * to the firmware
4749 *
Govind Singhb53420c2016-03-09 14:32:57 +05304750 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304751 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304752static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304753 struct thermal_cmd_params *thermal_info)
4754{
4755 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4756 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304757 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304758 uint32_t len = 0;
4759
4760 len = sizeof(*cmd);
4761
4762 buf = wmi_buf_alloc(wmi_handle, len);
4763 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304764 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4765 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304766 }
4767
4768 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4769
4770 WMITLV_SET_HDR(&cmd->tlv_header,
4771 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4772 WMITLV_GET_STRUCT_TLVLEN
4773 (wmi_thermal_mgmt_cmd_fixed_param));
4774
4775 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4776 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4777 cmd->enable = thermal_info->thermal_enable;
4778
Govind Singhb53420c2016-03-09 14:32:57 +05304779 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304780 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4781
4782 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4783 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304784 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304785 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304786 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304787 }
4788
Govind Singh67922e82016-04-01 16:48:57 +05304789 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304790}
4791
4792
4793/**
4794 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304795 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304796 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4797 *
4798 * This function sends down the LRO configuration parameters to
4799 * the firmware to enable LRO, sets the TCP flags and sets the
4800 * seed values for the toeplitz hash generation
4801 *
Govind Singhb53420c2016-03-09 14:32:57 +05304802 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304803 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304804static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304805 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4806{
4807 wmi_lro_info_cmd_fixed_param *cmd;
4808 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304809 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304810
4811
4812 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4813 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304814 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4815 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304816 }
4817
4818 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4819
4820 WMITLV_SET_HDR(&cmd->tlv_header,
4821 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4822 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4823
4824 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4825 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4826 wmi_lro_cmd->tcp_flag);
4827 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4828 wmi_lro_cmd->tcp_flag_mask);
4829 cmd->toeplitz_hash_ipv4_0_3 =
4830 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4831 cmd->toeplitz_hash_ipv4_4_7 =
4832 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4833 cmd->toeplitz_hash_ipv4_8_11 =
4834 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4835 cmd->toeplitz_hash_ipv4_12_15 =
4836 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4837 cmd->toeplitz_hash_ipv4_16 =
4838 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4839
4840 cmd->toeplitz_hash_ipv6_0_3 =
4841 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4842 cmd->toeplitz_hash_ipv6_4_7 =
4843 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4844 cmd->toeplitz_hash_ipv6_8_11 =
4845 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4846 cmd->toeplitz_hash_ipv6_12_15 =
4847 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4848 cmd->toeplitz_hash_ipv6_16_19 =
4849 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4850 cmd->toeplitz_hash_ipv6_20_23 =
4851 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4852 cmd->toeplitz_hash_ipv6_24_27 =
4853 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4854 cmd->toeplitz_hash_ipv6_28_31 =
4855 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4856 cmd->toeplitz_hash_ipv6_32_35 =
4857 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4858 cmd->toeplitz_hash_ipv6_36_39 =
4859 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4860 cmd->toeplitz_hash_ipv6_40 =
4861 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4862
Govind Singhb53420c2016-03-09 14:32:57 +05304863 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304864 cmd->lro_enable, cmd->tcp_flag_u32);
4865
4866 status = wmi_unified_cmd_send(wmi_handle, buf,
4867 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304868 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304869 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304870 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304871 }
4872
Govind Singh67922e82016-04-01 16:48:57 +05304873 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304874}
4875
Govind Singh4eacd2b2016-03-07 14:24:22 +05304876/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304877 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4878 * @wmi_handle: Pointer to wmi handle
4879 * @rate_report_params: Pointer to peer rate report parameters
4880 *
4881 *
4882 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4883 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304884static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304885 struct wmi_peer_rate_report_params *rate_report_params)
4886{
4887 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4888 wmi_buf_t buf = NULL;
4889 QDF_STATUS status = 0;
4890 uint32_t len = 0;
4891 uint32_t i, j;
4892
4893 len = sizeof(*cmd);
4894
4895 buf = wmi_buf_alloc(wmi_handle, len);
4896 if (!buf) {
4897 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4898 return QDF_STATUS_E_FAILURE;
4899 }
4900
4901 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4902 wmi_buf_data(buf);
4903
4904 WMITLV_SET_HDR(
4905 &cmd->tlv_header,
4906 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4907 WMITLV_GET_STRUCT_TLVLEN(
4908 wmi_peer_set_rate_report_condition_fixed_param));
4909
4910 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4911 cmd->report_backoff_time = rate_report_params->backoff_time;
4912 cmd->report_timer_period = rate_report_params->timer_period;
4913 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4914 cmd->cond_per_phy[i].val_cond_flags =
4915 rate_report_params->report_per_phy[i].cond_flags;
4916 cmd->cond_per_phy[i].rate_delta.min_delta =
4917 rate_report_params->report_per_phy[i].delta.delta_min;
4918 cmd->cond_per_phy[i].rate_delta.percentage =
4919 rate_report_params->report_per_phy[i].delta.percent;
4920 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4921 cmd->cond_per_phy[i].rate_threshold[j] =
4922 rate_report_params->report_per_phy[i].
4923 report_rate_threshold[j];
4924 }
4925 }
4926
4927 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4928 cmd->enable_rate_report,
4929 cmd->report_backoff_time, cmd->report_timer_period);
4930
4931 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4932 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4933 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304934 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304935 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4936 __func__);
4937 }
4938 return status;
4939}
4940
4941/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304942 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4943 * @wmi_handle: wmi handle
4944 * @param: bcn ll cmd parameter
4945 *
Govind Singhb53420c2016-03-09 14:32:57 +05304946 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304947 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304948static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304949 wmi_bcn_send_from_host_cmd_fixed_param *param)
4950{
4951 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4952 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304953 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304954
4955 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4956 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304957 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4958 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304959 }
4960
4961 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4962 WMITLV_SET_HDR(&cmd->tlv_header,
4963 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4964 WMITLV_GET_STRUCT_TLVLEN
4965 (wmi_bcn_send_from_host_cmd_fixed_param));
4966 cmd->vdev_id = param->vdev_id;
4967 cmd->data_len = param->data_len;
4968 cmd->frame_ctrl = param->frame_ctrl;
4969 cmd->frag_ptr = param->frag_ptr;
4970 cmd->dtim_flag = param->dtim_flag;
4971
4972 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4973 WMI_PDEV_SEND_BCN_CMDID);
4974
Govind Singh67922e82016-04-01 16:48:57 +05304975 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304976 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304977 wmi_buf_free(wmi_buf);
4978 }
4979
4980 return ret;
4981}
4982
4983/**
4984 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4985 * @wmi_handle: wmi handle
4986 * @vdev_id: vdev id
4987 * @max_retries: max retries
4988 * @retry_interval: retry interval
4989 * This function sets sta query related parameters in fw.
4990 *
Govind Singhb53420c2016-03-09 14:32:57 +05304991 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304992 */
4993
Sathish Kumarfd347372017-02-13 12:29:09 +05304994static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304995 uint8_t vdev_id, uint32_t max_retries,
4996 uint32_t retry_interval)
4997{
4998 wmi_buf_t buf;
4999 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5000 int len;
5001
5002 len = sizeof(*cmd);
5003 buf = wmi_buf_alloc(wmi_handle, len);
5004 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305005 WMI_LOGE(FL("wmi_buf_alloc failed"));
5006 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305007 }
5008
5009 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5010 WMITLV_SET_HDR(&cmd->tlv_header,
5011 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5012 WMITLV_GET_STRUCT_TLVLEN
5013 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5014
5015
5016 cmd->vdev_id = vdev_id;
5017 cmd->sa_query_max_retry_count = max_retries;
5018 cmd->sa_query_retry_interval = retry_interval;
5019
Govind Singhb53420c2016-03-09 14:32:57 +05305020 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305021 vdev_id, retry_interval, max_retries);
5022
5023 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5024 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305025 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305026 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305027 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305028 }
5029
Govind Singhb53420c2016-03-09 14:32:57 +05305030 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305031 return 0;
5032}
5033
5034/**
5035 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5036 * @wmi_handle: wmi handle
5037 * @params: sta keep alive parameter
5038 *
5039 * This function sets keep alive related parameters in fw.
5040 *
5041 * Return: CDF status
5042 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305043static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305044 struct sta_params *params)
5045{
5046 wmi_buf_t buf;
5047 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5048 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5049 uint8_t *buf_ptr;
5050 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305051 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305052
Govind Singhb53420c2016-03-09 14:32:57 +05305053 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305054
Govind Singh4eacd2b2016-03-07 14:24:22 +05305055 len = sizeof(*cmd) + sizeof(*arp_rsp);
5056 buf = wmi_buf_alloc(wmi_handle, len);
5057 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305058 WMI_LOGE("wmi_buf_alloc failed");
5059 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305060 }
5061
5062 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5063 buf_ptr = (uint8_t *) cmd;
5064 WMITLV_SET_HDR(&cmd->tlv_header,
5065 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5066 WMITLV_GET_STRUCT_TLVLEN
5067 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5068 cmd->interval = params->timeperiod;
5069 cmd->enable = (params->timeperiod) ? 1 : 0;
5070 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305071 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305072 params->timeperiod, params->method);
5073 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5074 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5075 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5076 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5077
c_manjee2772b9c2017-01-23 15:14:13 +05305078 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5079 (params->method ==
5080 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305081 if ((NULL == params->hostv4addr) ||
5082 (NULL == params->destv4addr) ||
5083 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005084 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5085 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305086 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305087 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305088 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305089 }
c_manjee2772b9c2017-01-23 15:14:13 +05305090 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305091 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305092 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305093 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305094 WMI_IPV4_ADDR_LEN);
5095 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5096 } else {
5097 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5098 }
5099
Govind Singh67922e82016-04-01 16:48:57 +05305100 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5101 WMI_STA_KEEPALIVE_CMDID);
5102 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305103 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305104 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305105 }
5106
Govind Singhb53420c2016-03-09 14:32:57 +05305107 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305108 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305109}
5110
5111/**
5112 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5113 * @wmi_handle: wmi handle
5114 * @if_id: vdev id
5115 * @gtx_info: GTX config params
5116 *
5117 * This function set GTX related params in firmware.
5118 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305119 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305120 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305121static 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 +05305122 struct wmi_gtx_config *gtx_info)
5123{
5124 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5125 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305126 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305127 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305128
Govind Singh4eacd2b2016-03-07 14:24:22 +05305129 buf = wmi_buf_alloc(wmi_handle, len);
5130 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305131 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305132 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305133 }
5134 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5135 WMITLV_SET_HDR(&cmd->tlv_header,
5136 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5137 WMITLV_GET_STRUCT_TLVLEN
5138 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5139 cmd->vdev_id = if_id;
5140
5141 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5142 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5143 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5144 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5145 cmd->gtxPERMargin = gtx_info->gtx_margin;
5146 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5147 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5148 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5149
Govind Singhb53420c2016-03-09 14:32:57 +05305150 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305151 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5152 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5153 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5154 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5155
Abhishek Singh716c46c2016-05-04 16:24:07 +05305156 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305157 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305158 if (QDF_IS_STATUS_ERROR(ret)) {
5159 WMI_LOGE("Failed to set GTX PARAMS");
5160 wmi_buf_free(buf);
5161 }
5162 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305163}
5164
5165/**
5166 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5167 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305168 * @vdev_id: vdev id.
5169 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305170 *
5171 * This function updates EDCA parameters to the target
5172 *
5173 * Return: CDF Status
5174 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305175static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005176 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305177 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305178{
5179 uint8_t *buf_ptr;
5180 wmi_buf_t buf;
5181 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305182 wmi_wmm_vparams *wmm_param;
5183 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305184 int len = sizeof(*cmd);
5185 int ac;
5186
5187 buf = wmi_buf_alloc(wmi_handle, len);
5188
5189 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305190 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5191 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305192 }
5193
5194 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5195 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5196 WMITLV_SET_HDR(&cmd->tlv_header,
5197 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5198 WMITLV_GET_STRUCT_TLVLEN
5199 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5200 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005201 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305202
5203 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5204 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305205 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305206 WMITLV_SET_HDR(&wmm_param->tlv_header,
5207 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5208 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5209 wmm_param->cwmin = twmm_param->cwmin;
5210 wmm_param->cwmax = twmm_param->cwmax;
5211 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005212 if (mu_edca_param)
5213 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5214 else
5215 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305216 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305217 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305218 }
5219
5220 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5221 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5222 goto fail;
5223
Govind Singhb53420c2016-03-09 14:32:57 +05305224 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305225
5226fail:
5227 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305228 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5229 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305230}
5231
5232/**
5233 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5234 * @wmi_handle: wmi handle
5235 * @vdev_id: vdev id
5236 * @probe_rsp_info: probe response info
5237 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305238 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305239 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305240static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305241 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005242 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305243{
5244 wmi_prb_tmpl_cmd_fixed_param *cmd;
5245 wmi_bcn_prb_info *bcn_prb_info;
5246 wmi_buf_t wmi_buf;
5247 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5248 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305249 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305250
Govind Singhb53420c2016-03-09 14:32:57 +05305251 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305252
Krunal Soni89426862017-11-14 15:42:48 -08005253 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305254 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305255
5256 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5257 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5258 tmpl_len_aligned;
5259
5260 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305261 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305262 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305263 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305264 }
5265
5266 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5267 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305268 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305269 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305270 }
5271
5272 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5273
5274 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5275 WMITLV_SET_HDR(&cmd->tlv_header,
5276 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5277 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5278 cmd->vdev_id = vdev_id;
5279 cmd->buf_len = tmpl_len;
5280 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5281
5282 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5283 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5284 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5285 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5286 bcn_prb_info->caps = 0;
5287 bcn_prb_info->erp = 0;
5288 buf_ptr += sizeof(wmi_bcn_prb_info);
5289
5290 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5291 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005292 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305293
5294 ret = wmi_unified_cmd_send(wmi_handle,
5295 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305296 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305297 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305298 wmi_buf_free(wmi_buf);
5299 }
5300
5301 return ret;
5302}
5303
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305304#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305305#define WPI_IV_LEN 16
5306
5307/**
5308 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5309 *
5310 * @dest_tx: destination address of tsc key counter
5311 * @src_tx: source address of tsc key counter
5312 * @dest_rx: destination address of rsc key counter
5313 * @src_rx: source address of rsc key counter
5314 *
5315 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5316 *
5317 * Return: None
5318 *
5319 */
5320static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5321 uint8_t *dest_rx, uint8_t *src_rx)
5322{
5323 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5324 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5325}
5326#else
5327static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5328 uint8_t *dest_rx, uint8_t *src_rx)
5329{
5330 return;
5331}
5332#endif
5333
5334/**
5335 * send_setup_install_key_cmd_tlv() - set key parameters
5336 * @wmi_handle: wmi handle
5337 * @key_params: key parameters
5338 *
5339 * This function fills structure from information
5340 * passed in key_params.
5341 *
5342 * Return: QDF_STATUS_SUCCESS - success
5343 * QDF_STATUS_E_FAILURE - failure
5344 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5345 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305346static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305347 struct set_key_params *key_params)
5348{
5349 wmi_vdev_install_key_cmd_fixed_param *cmd;
5350 wmi_buf_t buf;
5351 uint8_t *buf_ptr;
5352 uint32_t len;
5353 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305354 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305355
5356 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5357 WMI_TLV_HDR_SIZE;
5358
5359 buf = wmi_buf_alloc(wmi_handle, len);
5360 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305361 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305362 return QDF_STATUS_E_NOMEM;
5363 }
5364
5365 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5366 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5367 WMITLV_SET_HDR(&cmd->tlv_header,
5368 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5369 WMITLV_GET_STRUCT_TLVLEN
5370 (wmi_vdev_install_key_cmd_fixed_param));
5371 cmd->vdev_id = key_params->vdev_id;
5372 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305373
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305374
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305375 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5376 cmd->key_flags |= key_params->key_flags;
5377 cmd->key_cipher = key_params->key_cipher;
5378 if ((key_params->key_txmic_len) &&
5379 (key_params->key_rxmic_len)) {
5380 cmd->key_txmic_len = key_params->key_txmic_len;
5381 cmd->key_rxmic_len = key_params->key_rxmic_len;
5382 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305383#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305384 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5385 key_params->tx_iv,
5386 cmd->wpi_key_rsc_counter,
5387 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305388#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305389 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5390 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5391 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305392 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305393 qdf_mem_copy((void *)key_data,
5394 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005395 if (key_params->key_rsc_counter)
5396 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5397 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305398 cmd->key_len = key_params->key_len;
5399
5400 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5401 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305402 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305403 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305404
Govind Singh67922e82016-04-01 16:48:57 +05305405 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305406}
5407
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305408/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005409 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5410 * @wmi_handle: wmi handle
5411 * @params: sar limit params
5412 *
5413 * Return: QDF_STATUS_SUCCESS for success or error code
5414 */
5415static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5416 struct sar_limit_cmd_params *sar_limit_params)
5417{
5418 wmi_buf_t buf;
5419 QDF_STATUS qdf_status;
5420 wmi_sar_limits_cmd_fixed_param *cmd;
5421 int i;
5422 uint8_t *buf_ptr;
5423 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5424 struct sar_limit_cmd_row *sar_rows_list;
5425 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5426
5427 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5428 buf = wmi_buf_alloc(wmi_handle, len);
5429 if (!buf) {
5430 WMI_LOGE("Failed to allocate memory");
5431 qdf_status = QDF_STATUS_E_NOMEM;
5432 goto end;
5433 }
5434
5435 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5436 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5437 WMITLV_SET_HDR(&cmd->tlv_header,
5438 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5439 WMITLV_GET_STRUCT_TLVLEN
5440 (wmi_sar_limits_cmd_fixed_param));
5441 cmd->sar_enable = sar_limit_params->sar_enable;
5442 cmd->commit_limits = sar_limit_params->commit_limits;
5443 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5444
5445 WMI_LOGD("no of sar rows = %d, len = %d",
5446 sar_limit_params->num_limit_rows, len);
5447 buf_ptr += sizeof(*cmd);
5448 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5449 sizeof(wmi_sar_limit_cmd_row) *
5450 sar_limit_params->num_limit_rows);
5451 if (cmd->num_limit_rows == 0)
5452 goto send_sar_limits;
5453
5454 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5455 (buf_ptr + WMI_TLV_HDR_SIZE);
5456 sar_rows_list = sar_limit_params->sar_limit_row_list;
5457
5458 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5459 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5460 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5461 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5462 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5463 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5464 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5465 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5466 wmi_sar_rows_list->validity_bitmap =
5467 sar_rows_list->validity_bitmap;
5468 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5469 i, wmi_sar_rows_list->band_id,
5470 wmi_sar_rows_list->chain_id,
5471 wmi_sar_rows_list->mod_id,
5472 wmi_sar_rows_list->limit_value,
5473 wmi_sar_rows_list->validity_bitmap);
5474 sar_rows_list++;
5475 wmi_sar_rows_list++;
5476 }
5477send_sar_limits:
5478 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5479 WMI_SAR_LIMITS_CMDID);
5480
5481 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5482 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5483 wmi_buf_free(buf);
5484 }
5485
5486end:
5487 return qdf_status;
5488}
5489
Jeff Johnson4783f902017-12-14 15:50:16 -08005490static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5491{
5492 wmi_sar_get_limits_cmd_fixed_param *cmd;
5493 wmi_buf_t wmi_buf;
5494 uint32_t len;
5495 QDF_STATUS status;
5496
5497 WMI_LOGD(FL("Enter"));
5498
5499 len = sizeof(*cmd);
5500 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5501 if (!wmi_buf) {
5502 WMI_LOGP(FL("failed to allocate memory for msg"));
5503 return QDF_STATUS_E_NOMEM;
5504 }
5505
5506 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5507
5508 WMITLV_SET_HDR(&cmd->tlv_header,
5509 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5510 WMITLV_GET_STRUCT_TLVLEN
5511 (wmi_sar_get_limits_cmd_fixed_param));
5512
5513 cmd->reserved = 0;
5514
5515 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5516 WMI_SAR_GET_LIMITS_CMDID);
5517 if (QDF_IS_STATUS_ERROR(status)) {
5518 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5519 wmi_buf_free(wmi_buf);
5520 }
5521
5522 WMI_LOGD(FL("Exit"));
5523
5524 return status;
5525}
5526
5527static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5528 uint8_t *evt_buf,
5529 struct sar_limit_event *event)
5530{
5531 wmi_sar_get_limits_event_fixed_param *fixed_param;
5532 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5533 wmi_sar_get_limit_event_row *row_in;
5534 struct sar_limit_event_row *row_out;
5535 uint32_t row;
5536
5537 if (!evt_buf) {
5538 WMI_LOGE(FL("input event is NULL"));
5539 return QDF_STATUS_E_INVAL;
5540 }
5541 if (!event) {
5542 WMI_LOGE(FL("output event is NULL"));
5543 return QDF_STATUS_E_INVAL;
5544 }
5545
5546 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5547
5548 fixed_param = param_buf->fixed_param;
5549 if (!fixed_param) {
5550 WMI_LOGE(FL("Invalid fixed param"));
5551 return QDF_STATUS_E_INVAL;
5552 }
5553
5554 event->sar_enable = fixed_param->sar_enable;
5555 event->num_limit_rows = fixed_param->num_limit_rows;
5556
5557 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5558 QDF_ASSERT(0);
5559 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5560 event->num_limit_rows,
5561 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5562 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5563 }
5564
5565 row_in = param_buf->sar_get_limits;
5566 row_out = &event->sar_limit_row[0];
5567 for (row = 0; row < event->num_limit_rows; row++) {
5568 row_out->band_id = row_in->band_id;
5569 row_out->chain_id = row_in->chain_id;
5570 row_out->mod_id = row_in->mod_id;
5571 row_out->limit_value = row_in->limit_value;
5572 row_out++;
5573 row_in++;
5574 }
5575
5576 return QDF_STATUS_SUCCESS;
5577}
5578
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305579#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005580/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305581 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5582 * @wmi_handle: wmi handle
5583 * @params: encrypt/decrypt params
5584 *
5585 * Return: QDF_STATUS_SUCCESS for success or error code
5586 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005587static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305588QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305589 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305590{
5591 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5592 wmi_buf_t wmi_buf;
5593 uint8_t *buf_ptr;
5594 QDF_STATUS ret;
5595 uint32_t len;
5596
5597 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5598
5599 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305600 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305601 WMI_TLV_HDR_SIZE;
5602 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5603 if (!wmi_buf) {
5604 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5605 __func__);
5606 return QDF_STATUS_E_NOMEM;
5607 }
5608
5609 buf_ptr = wmi_buf_data(wmi_buf);
5610 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5611
5612 WMITLV_SET_HDR(&cmd->tlv_header,
5613 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5614 WMITLV_GET_STRUCT_TLVLEN(
5615 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5616
5617 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5618 cmd->key_flag = encrypt_decrypt_params->key_flag;
5619 cmd->key_idx = encrypt_decrypt_params->key_idx;
5620 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5621 cmd->key_len = encrypt_decrypt_params->key_len;
5622 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5623 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5624
5625 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5626 encrypt_decrypt_params->key_len);
5627
5628 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5629 MAX_MAC_HEADER_LEN);
5630
5631 cmd->data_len = encrypt_decrypt_params->data_len;
5632
5633 if (cmd->data_len) {
5634 buf_ptr += sizeof(*cmd);
5635 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5636 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305637 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305638 buf_ptr += WMI_TLV_HDR_SIZE;
5639 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5640 encrypt_decrypt_params->data_len);
5641 }
5642
5643 /* This conversion is to facilitate data to FW in little endian */
5644 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5645 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5646 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5647 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5648 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5649 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5650
5651 ret = wmi_unified_cmd_send(wmi_handle,
5652 wmi_buf, len,
5653 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5654 if (QDF_IS_STATUS_ERROR(ret)) {
5655 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5656 wmi_buf_free(wmi_buf);
5657 }
5658
5659 return ret;
5660}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305661
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305662/**
5663 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5664 * params from event
5665 * @wmi_handle: wmi handle
5666 * @evt_buf: pointer to event buffer
5667 * @resp: Pointer to hold resp parameters
5668 *
5669 * Return: QDF_STATUS_SUCCESS for success or error code
5670 */
5671static
5672QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5673 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5674{
5675 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5676 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5677
5678 param_buf = evt_buf;
5679 if (!param_buf) {
5680 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5681 return QDF_STATUS_E_INVAL;
5682 }
5683
5684 data_event = param_buf->fixed_param;
5685
5686 resp->vdev_id = data_event->vdev_id;
5687 resp->status = data_event->status;
5688
5689 if (data_event->data_length > param_buf->num_enc80211_frame) {
5690 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5691 data_event->data_length,
5692 param_buf->num_enc80211_frame);
5693 return QDF_STATUS_E_INVAL;
5694 }
5695
5696 resp->data_len = data_event->data_length;
5697
5698 if (resp->data_len)
5699 resp->data = (uint8_t *)param_buf->enc80211_frame;
5700
5701 return QDF_STATUS_SUCCESS;
5702}
5703#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305704
Govind Singh4eacd2b2016-03-07 14:24:22 +05305705/**
5706 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5707 * @wmi_handle: wmi handle
5708 * @vdev_id: vdev id
5709 * @p2p_ie: p2p IE
5710 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305711 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305712 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305713static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05305714 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305715{
Govind Singh67922e82016-04-01 16:48:57 +05305716 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305717 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5718 wmi_buf_t wmi_buf;
5719 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5720 uint8_t *buf_ptr;
5721
5722 ie_len = (uint32_t) (p2p_ie[1] + 2);
5723
5724 /* More than one P2P IE may be included in a single frame.
5725 If multiple P2P IEs are present, the complete P2P attribute
5726 data consists of the concatenation of the P2P Attribute
5727 fields of the P2P IEs. The P2P Attributes field of each
5728 P2P IE may be any length up to the maximum (251 octets).
5729 In this case host sends one P2P IE to firmware so the length
5730 should not exceed more than 251 bytes
5731 */
5732 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305733 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305734 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305735 }
5736
Vivekc5823092018-03-22 23:27:21 +05305737 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305738
5739 wmi_buf_len =
5740 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5741 WMI_TLV_HDR_SIZE;
5742
5743 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5744 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305745 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305746 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305747 }
5748
5749 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5750
5751 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5752 WMITLV_SET_HDR(&cmd->tlv_header,
5753 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5754 WMITLV_GET_STRUCT_TLVLEN
5755 (wmi_p2p_go_set_beacon_ie_fixed_param));
5756 cmd->vdev_id = vdev_id;
5757 cmd->ie_buf_len = ie_len;
5758
5759 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5760 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5761 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305762 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305763
Govind Singhb53420c2016-03-09 14:32:57 +05305764 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305765
5766 ret = wmi_unified_cmd_send(wmi_handle,
5767 wmi_buf, wmi_buf_len,
5768 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305769 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305770 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305771 wmi_buf_free(wmi_buf);
5772 }
5773
Govind Singhb53420c2016-03-09 14:32:57 +05305774 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305775 return ret;
5776}
5777
5778/**
5779 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5780 * @wmi_handle: wmi handle
5781 * @req: gateway parameter update request structure
5782 *
5783 * This function reads the incoming @req and fill in the destination
5784 * WMI structure and sends down the gateway configs down to the firmware
5785 *
Govind Singhb53420c2016-03-09 14:32:57 +05305786 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305787 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305788static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305789 struct gateway_update_req_param *req)
5790{
5791 wmi_roam_subnet_change_config_fixed_param *cmd;
5792 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305793 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305794 int len = sizeof(*cmd);
5795
5796 buf = wmi_buf_alloc(wmi_handle, len);
5797 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305798 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5799 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305800 }
5801
5802 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5803 WMITLV_SET_HDR(&cmd->tlv_header,
5804 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5805 WMITLV_GET_STRUCT_TLVLEN(
5806 wmi_roam_subnet_change_config_fixed_param));
5807
5808 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305809 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5810 QDF_IPV4_ADDR_SIZE);
5811 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5812 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305813 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5814 &cmd->inet_gw_mac_addr);
5815 cmd->max_retries = req->max_retries;
5816 cmd->timeout = req->timeout;
5817 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5818 cmd->flag = 0;
5819 if (req->ipv4_addr_type)
5820 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5821
5822 if (req->ipv6_addr_type)
5823 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5824
5825 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5826 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305827 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305828 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305829 ret);
5830 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305831 }
5832
Govind Singh67922e82016-04-01 16:48:57 +05305833 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305834}
5835
5836/**
5837 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5838 * @wmi_handle: wmi handle
5839 * @req: rssi monitoring request structure
5840 *
5841 * This function reads the incoming @req and fill in the destination
5842 * WMI structure and send down the rssi monitoring configs down to the firmware
5843 *
5844 * Return: 0 on success; error number otherwise
5845 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305846static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305847 struct rssi_monitor_param *req)
5848{
5849 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5850 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305851 QDF_STATUS ret;
5852 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305853
5854 buf = wmi_buf_alloc(wmi_handle, len);
5855 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305856 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5857 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305858 }
5859
5860 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5861 WMITLV_SET_HDR(&cmd->tlv_header,
5862 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5863 WMITLV_GET_STRUCT_TLVLEN(
5864 wmi_rssi_breach_monitor_config_fixed_param));
5865
5866 cmd->vdev_id = req->session_id;
5867 cmd->request_id = req->request_id;
5868 cmd->lo_rssi_reenable_hysteresis = 0;
5869 cmd->hi_rssi_reenable_histeresis = 0;
5870 cmd->min_report_interval = 0;
5871 cmd->max_num_report = 1;
5872 if (req->control) {
5873 /* enable one threshold for each min/max */
5874 cmd->enabled_bitmap = 0x09;
5875 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5876 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5877 } else {
5878 cmd->enabled_bitmap = 0;
5879 cmd->low_rssi_breach_threshold[0] = 0;
5880 cmd->hi_rssi_breach_threshold[0] = 0;
5881 }
5882
5883 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5884 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305885 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305886 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305887 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305888 }
5889
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005890 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5891
Govind Singh67922e82016-04-01 16:48:57 +05305892 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305893}
5894
5895/**
5896 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5897 * @wmi_handle: wmi handle
5898 * @psetoui: OUI parameters
5899 *
5900 * set scan probe OUI parameters in firmware
5901 *
5902 * Return: CDF status
5903 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305904static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305905 struct scan_mac_oui *psetoui)
5906{
5907 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5908 wmi_buf_t wmi_buf;
5909 uint32_t len;
5910 uint8_t *buf_ptr;
5911 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305912 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305913
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305914 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5915 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5916
Govind Singh4eacd2b2016-03-07 14:24:22 +05305917 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5918 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305919 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5920 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305921 }
5922 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5923 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5924 WMITLV_SET_HDR(&cmd->tlv_header,
5925 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5926 WMITLV_GET_STRUCT_TLVLEN
5927 (wmi_scan_prob_req_oui_cmd_fixed_param));
5928
5929 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305930 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305931 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5932 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305933 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305934 cmd->prob_req_oui);
5935
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05305936 cmd->vdev_id = psetoui->vdev_id;
5937 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
5938 if (psetoui->enb_probe_req_sno_randomization)
5939 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
5940
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305941 if (ie_whitelist->white_list) {
5942 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
5943 &cmd->num_vendor_oui,
5944 ie_whitelist);
5945 cmd->flags |=
5946 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
5947 }
5948
5949 buf_ptr += sizeof(*cmd);
5950 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5951 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
5952 buf_ptr += WMI_TLV_HDR_SIZE;
5953
5954 if (cmd->num_vendor_oui != 0) {
5955 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
5956 ie_whitelist->voui);
5957 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
5958 }
5959
Govind Singh4eacd2b2016-03-07 14:24:22 +05305960 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5961 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305962 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305963 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305964 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305965 }
Govind Singhb53420c2016-03-09 14:32:57 +05305966 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305967}
5968
5969/**
5970 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5971 * @wmi_handle: wmi handle
5972 * @req: passpoint network request structure
5973 *
5974 * This function sends down WMI command with network id set to wildcard id.
5975 * firmware shall clear all the config entries
5976 *
Govind Singhb53420c2016-03-09 14:32:57 +05305977 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305978 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305979static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305980 struct wifi_passpoint_req_param *req)
5981{
5982 wmi_passpoint_config_cmd_fixed_param *cmd;
5983 wmi_buf_t buf;
5984 uint32_t len;
5985 int ret;
5986
5987 len = sizeof(*cmd);
5988 buf = wmi_buf_alloc(wmi_handle, len);
5989 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305990 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5991 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305992 }
5993
5994 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5995
5996 WMITLV_SET_HDR(&cmd->tlv_header,
5997 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5998 WMITLV_GET_STRUCT_TLVLEN(
5999 wmi_passpoint_config_cmd_fixed_param));
6000 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
6001
6002 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6003 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6004 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306005 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306006 __func__);
6007 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306008 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306009 }
6010
Govind Singhb53420c2016-03-09 14:32:57 +05306011 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306012}
6013
6014/**
6015 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
6016 * @wmi_handle: wmi handle
6017 * @req: passpoint network request structure
6018 *
6019 * This function reads the incoming @req and fill in the destination
6020 * WMI structure and send down the passpoint configs down to the firmware
6021 *
Govind Singhb53420c2016-03-09 14:32:57 +05306022 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05306023 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306024static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306025 struct wifi_passpoint_req_param *req)
6026{
6027 wmi_passpoint_config_cmd_fixed_param *cmd;
6028 u_int8_t i, j, *bytes;
6029 wmi_buf_t buf;
6030 uint32_t len;
6031 int ret;
6032
6033 len = sizeof(*cmd);
6034 for (i = 0; i < req->num_networks; i++) {
6035 buf = wmi_buf_alloc(wmi_handle, len);
6036 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306037 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6038 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306039 }
6040
6041 cmd = (wmi_passpoint_config_cmd_fixed_param *)
6042 wmi_buf_data(buf);
6043
6044 WMITLV_SET_HDR(&cmd->tlv_header,
6045 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
6046 WMITLV_GET_STRUCT_TLVLEN(
6047 wmi_passpoint_config_cmd_fixed_param));
6048 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05306049 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
6050 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306051 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05306052 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306053 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
6054 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05306055 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306056 j, bytes[0], bytes[1], bytes[2], bytes[3],
6057 bytes[4], bytes[5], bytes[6], bytes[7]);
6058
Govind Singhb53420c2016-03-09 14:32:57 +05306059 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05306060 &req->networks[i].roaming_consortium_ids[j],
6061 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
6062 }
Govind Singhb53420c2016-03-09 14:32:57 +05306063 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306064 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05306065 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306066 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
6067
6068 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6069 WMI_PASSPOINT_LIST_CONFIG_CMDID);
6070 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306071 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306072 __func__);
6073 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306074 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306075 }
6076 }
6077
Govind Singhb53420c2016-03-09 14:32:57 +05306078 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306079}
6080
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306081#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306082/**
6083 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6084 * @wmi_handle: wmi handle
6085 * @roam_req: Roam scan offload params
6086 * @buf_ptr: command buffer to send
6087 * @fils_tlv_len: fils tlv length
6088 *
6089 * Return: Updated buffer pointer
6090 */
6091static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6092 struct roam_offload_scan_params *roam_req,
6093 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6094{
6095 wmi_roam_fils_offload_tlv_param *fils_tlv;
6096 wmi_erp_info *erp_info;
6097 struct roam_fils_params *roam_fils_params;
6098
6099 if (!roam_req->add_fils_tlv)
6100 return buf_ptr;
6101
6102 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6103 sizeof(*fils_tlv));
6104 buf_ptr += WMI_TLV_HDR_SIZE;
6105
6106 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6107 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6108 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6109 WMITLV_GET_STRUCT_TLVLEN
6110 (wmi_roam_fils_offload_tlv_param));
6111
6112 roam_fils_params = &roam_req->roam_fils_params;
6113 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6114
6115 erp_info->username_length = roam_fils_params->username_length;
6116 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6117 erp_info->username_length);
6118
6119 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6120
6121 erp_info->rRk_length = roam_fils_params->rrk_length;
6122 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6123 erp_info->rRk_length);
6124
6125 erp_info->rIk_length = roam_fils_params->rik_length;
6126 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6127 erp_info->rIk_length);
6128
6129 erp_info->realm_len = roam_fils_params->realm_len;
6130 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6131 erp_info->realm_len);
6132
6133 buf_ptr += sizeof(*fils_tlv);
6134 return buf_ptr;
6135}
6136#else
6137static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6138 struct roam_offload_scan_params *roam_req,
6139 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6140{
6141 return buf_ptr;
6142}
6143#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306144/**
6145 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6146 * @wmi_handle: wmi handle
6147 * @scan_cmd_fp: start scan command ptr
6148 * @roam_req: roam request param
6149 *
6150 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6151 * of WMI_ROAM_SCAN_MODE.
6152 *
6153 * Return: QDF status
6154 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306155static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306156 wmi_start_scan_cmd_fixed_param *
6157 scan_cmd_fp,
6158 struct roam_offload_scan_params *roam_req)
6159{
6160 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306161 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306162 int len;
6163 uint8_t *buf_ptr;
6164 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306165
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306166#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6167 int auth_mode = roam_req->auth_mode;
6168 wmi_roam_offload_tlv_param *roam_offload_params;
6169 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6170 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6171 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306172 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306173 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306174#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6175 /* Need to create a buf with roam_scan command at
6176 * front and piggyback with scan command */
6177 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6178#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6179 (2 * WMI_TLV_HDR_SIZE) +
6180#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6181 sizeof(wmi_start_scan_cmd_fixed_param);
6182#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006183 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306184 if (roam_req->is_roam_req_valid &&
6185 roam_req->roam_offload_enabled) {
6186 len += sizeof(wmi_roam_offload_tlv_param);
6187 len += WMI_TLV_HDR_SIZE;
6188 if ((auth_mode != WMI_AUTH_NONE) &&
6189 ((auth_mode != WMI_AUTH_OPEN) ||
6190 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306191 roam_req->mdid.mdie_present &&
6192 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306193 roam_req->is_ese_assoc)) {
6194 len += WMI_TLV_HDR_SIZE;
6195 if (roam_req->is_ese_assoc)
6196 len +=
6197 sizeof(wmi_roam_ese_offload_tlv_param);
6198 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6199 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6200 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306201 roam_req->mdid.mdie_present &&
6202 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306203 len +=
6204 sizeof(wmi_roam_11r_offload_tlv_param);
6205 else
6206 len +=
6207 sizeof(wmi_roam_11i_offload_tlv_param);
6208 } else {
6209 len += WMI_TLV_HDR_SIZE;
6210 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306211
6212 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6213 + roundup(roam_req->assoc_ie_length,
6214 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306215
6216 if (roam_req->add_fils_tlv) {
6217 fils_tlv_len = sizeof(
6218 wmi_roam_fils_offload_tlv_param);
6219 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6220 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306221 } else {
6222 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306223 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306224 __func__, roam_req->roam_offload_enabled);
6225 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306226 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306227 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306228 }
6229 if (roam_req->is_roam_req_valid &&
6230 roam_req->roam_offload_enabled) {
6231 roam_req->mode = roam_req->mode |
6232 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6233 }
6234#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6235
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306236 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6237 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6238 len = sizeof(wmi_roam_scan_mode_fixed_param);
6239
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306240 buf = wmi_buf_alloc(wmi_handle, len);
6241 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306242 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306243 return QDF_STATUS_E_NOMEM;
6244 }
6245
6246 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6247 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6248 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6249 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6250 WMITLV_GET_STRUCT_TLVLEN
6251 (wmi_roam_scan_mode_fixed_param));
6252
Abhinav Kumar334355f2018-04-06 17:18:52 +05306253 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6254 roam_req->roam_trigger_reason_bitmask;
6255 roam_scan_mode_fp->min_delay_btw_scans =
6256 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306257 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6258 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306259 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6260 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6261 roam_scan_mode_fp->flags |=
6262 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306263 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306264 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306265
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306266 /* Fill in scan parameters suitable for roaming scan */
6267 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306268
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306269 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6270 sizeof(wmi_start_scan_cmd_fixed_param));
6271 /* Ensure there is no additional IEs */
6272 scan_cmd_fp->ie_len = 0;
6273 WMITLV_SET_HDR(buf_ptr,
6274 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6275 WMITLV_GET_STRUCT_TLVLEN
6276 (wmi_start_scan_cmd_fixed_param));
6277#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6278 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6279 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6280 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6281 sizeof(wmi_roam_offload_tlv_param));
6282 buf_ptr += WMI_TLV_HDR_SIZE;
6283 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6284 WMITLV_SET_HDR(buf_ptr,
6285 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6286 WMITLV_GET_STRUCT_TLVLEN
6287 (wmi_roam_offload_tlv_param));
6288 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6289 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6290 roam_offload_params->select_5g_margin =
6291 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306292 roam_offload_params->handoff_delay_for_rx =
6293 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306294 roam_offload_params->reassoc_failure_timeout =
6295 roam_req->reassoc_failure_timeout;
6296
6297 /* Fill the capabilities */
6298 roam_offload_params->capability =
6299 roam_req->roam_offload_params.capability;
6300 roam_offload_params->ht_caps_info =
6301 roam_req->roam_offload_params.ht_caps_info;
6302 roam_offload_params->ampdu_param =
6303 roam_req->roam_offload_params.ampdu_param;
6304 roam_offload_params->ht_ext_cap =
6305 roam_req->roam_offload_params.ht_ext_cap;
6306 roam_offload_params->ht_txbf =
6307 roam_req->roam_offload_params.ht_txbf;
6308 roam_offload_params->asel_cap =
6309 roam_req->roam_offload_params.asel_cap;
6310 roam_offload_params->qos_caps =
6311 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006312 roam_offload_params->qos_enabled =
6313 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306314 roam_offload_params->wmm_caps =
6315 roam_req->roam_offload_params.wmm_caps;
6316 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6317 (uint8_t *)roam_req->roam_offload_params.mcsset,
6318 ROAM_OFFLOAD_NUM_MCS_SET);
6319
6320 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6321 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6322 * they are filled in the same order.Depending on the
6323 * authentication type, the other mode TLV's are nullified
6324 * and only headers are filled.*/
6325 if ((auth_mode != WMI_AUTH_NONE) &&
6326 ((auth_mode != WMI_AUTH_OPEN) ||
6327 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306328 && roam_req->mdid.mdie_present &&
6329 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306330 roam_req->is_ese_assoc)) {
6331 if (roam_req->is_ese_assoc) {
6332 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6333 WMITLV_GET_STRUCT_TLVLEN(0));
6334 buf_ptr += WMI_TLV_HDR_SIZE;
6335 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6336 WMITLV_GET_STRUCT_TLVLEN(0));
6337 buf_ptr += WMI_TLV_HDR_SIZE;
6338 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6339 sizeof(wmi_roam_ese_offload_tlv_param));
6340 buf_ptr += WMI_TLV_HDR_SIZE;
6341 roam_offload_ese =
6342 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6343 qdf_mem_copy(roam_offload_ese->krk,
6344 roam_req->krk,
6345 sizeof(roam_req->krk));
6346 qdf_mem_copy(roam_offload_ese->btk,
6347 roam_req->btk,
6348 sizeof(roam_req->btk));
6349 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6350 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6351 WMITLV_GET_STRUCT_TLVLEN
6352 (wmi_roam_ese_offload_tlv_param));
6353 buf_ptr +=
6354 sizeof(wmi_roam_ese_offload_tlv_param);
6355 } else if (auth_mode == WMI_AUTH_FT_RSNA
6356 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6357 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306358 && roam_req->mdid.mdie_present &&
6359 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306360 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6361 0);
6362 buf_ptr += WMI_TLV_HDR_SIZE;
6363 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6364 sizeof(wmi_roam_11r_offload_tlv_param));
6365 buf_ptr += WMI_TLV_HDR_SIZE;
6366 roam_offload_11r =
6367 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6368 roam_offload_11r->r0kh_id_len =
6369 roam_req->rokh_id_length;
6370 qdf_mem_copy(roam_offload_11r->r0kh_id,
6371 roam_req->rokh_id,
6372 roam_offload_11r->r0kh_id_len);
6373 qdf_mem_copy(roam_offload_11r->psk_msk,
6374 roam_req->psk_pmk,
6375 sizeof(roam_req->psk_pmk));
6376 roam_offload_11r->psk_msk_len =
6377 roam_req->pmk_len;
6378 roam_offload_11r->mdie_present =
6379 roam_req->mdid.mdie_present;
6380 roam_offload_11r->mdid =
6381 roam_req->mdid.mobility_domain;
6382 if (auth_mode == WMI_AUTH_OPEN) {
6383 /* If FT-Open ensure pmk length
6384 and r0khid len are zero */
6385 roam_offload_11r->r0kh_id_len = 0;
6386 roam_offload_11r->psk_msk_len = 0;
6387 }
6388 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6389 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6390 WMITLV_GET_STRUCT_TLVLEN
6391 (wmi_roam_11r_offload_tlv_param));
6392 buf_ptr +=
6393 sizeof(wmi_roam_11r_offload_tlv_param);
6394 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6395 WMITLV_GET_STRUCT_TLVLEN(0));
6396 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006397 WMI_LOGD("psk_msk_len = %d",
6398 roam_offload_11r->psk_msk_len);
6399 if (roam_offload_11r->psk_msk_len)
6400 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6401 QDF_TRACE_LEVEL_DEBUG,
6402 roam_offload_11r->psk_msk,
6403 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306404 } else {
6405 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6406 sizeof(wmi_roam_11i_offload_tlv_param));
6407 buf_ptr += WMI_TLV_HDR_SIZE;
6408 roam_offload_11i =
6409 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006410
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006411 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006412 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306413 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6414 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006415 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306416 } else {
6417 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6418 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006419 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006420 }
6421 if (roam_req->roam_key_mgmt_offload_enabled &&
6422 roam_req->fw_pmksa_cache) {
6423 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6424 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006425 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006426 } else {
6427 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6428 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006429 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306430 }
6431
6432 qdf_mem_copy(roam_offload_11i->pmk,
6433 roam_req->psk_pmk,
6434 sizeof(roam_req->psk_pmk));
6435 roam_offload_11i->pmk_len = roam_req->pmk_len;
6436 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6437 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6438 WMITLV_GET_STRUCT_TLVLEN
6439 (wmi_roam_11i_offload_tlv_param));
6440 buf_ptr +=
6441 sizeof(wmi_roam_11i_offload_tlv_param);
6442 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6443 0);
6444 buf_ptr += WMI_TLV_HDR_SIZE;
6445 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6446 0);
6447 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006448 WMI_LOGD("pmk_len = %d",
6449 roam_offload_11i->pmk_len);
6450 if (roam_offload_11i->pmk_len)
6451 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6452 QDF_TRACE_LEVEL_DEBUG,
6453 roam_offload_11i->pmk,
6454 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306455 }
6456 } else {
6457 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6458 WMITLV_GET_STRUCT_TLVLEN(0));
6459 buf_ptr += WMI_TLV_HDR_SIZE;
6460 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6461 WMITLV_GET_STRUCT_TLVLEN(0));
6462 buf_ptr += WMI_TLV_HDR_SIZE;
6463 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6464 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306465 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306466 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306467
6468 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6469 sizeof(*assoc_ies));
6470 buf_ptr += WMI_TLV_HDR_SIZE;
6471
6472 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6473 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6474 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6475 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6476 assoc_ies->buf_len = roam_req->assoc_ie_length;
6477
6478 buf_ptr += sizeof(*assoc_ies);
6479
6480 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6481 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6482 buf_ptr += WMI_TLV_HDR_SIZE;
6483
6484 if (assoc_ies->buf_len != 0) {
6485 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6486 assoc_ies->buf_len);
6487 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306488 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6489 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6490 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306491 } else {
6492 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6493 WMITLV_GET_STRUCT_TLVLEN(0));
6494 buf_ptr += WMI_TLV_HDR_SIZE;
6495 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6496 WMITLV_GET_STRUCT_TLVLEN(0));
6497 buf_ptr += WMI_TLV_HDR_SIZE;
6498 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6499 WMITLV_GET_STRUCT_TLVLEN(0));
6500 buf_ptr += WMI_TLV_HDR_SIZE;
6501 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6502 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306503 buf_ptr += WMI_TLV_HDR_SIZE;
6504 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6505 WMITLV_GET_STRUCT_TLVLEN(0));
6506 buf_ptr += WMI_TLV_HDR_SIZE;
6507 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6508 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306509 }
6510#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306511
6512send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306513 status = wmi_unified_cmd_send(wmi_handle, buf,
6514 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306515 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306516 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306517 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6518 status);
6519 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306520 }
6521
Govind Singh67922e82016-04-01 16:48:57 +05306522 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306523}
6524
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006525static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6526 struct wmi_mawc_roam_params *params)
6527{
6528 wmi_buf_t buf = NULL;
6529 QDF_STATUS status;
6530 int len;
6531 uint8_t *buf_ptr;
6532 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6533
6534 len = sizeof(*wmi_roam_mawc_params);
6535 buf = wmi_buf_alloc(wmi_handle, len);
6536 if (!buf) {
6537 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6538 return QDF_STATUS_E_NOMEM;
6539 }
6540
6541 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6542 wmi_roam_mawc_params =
6543 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6544 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6545 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6546 WMITLV_GET_STRUCT_TLVLEN
6547 (wmi_roam_configure_mawc_cmd_fixed_param));
6548 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6549 if (params->enable)
6550 wmi_roam_mawc_params->enable = 1;
6551 else
6552 wmi_roam_mawc_params->enable = 0;
6553 wmi_roam_mawc_params->traffic_load_threshold =
6554 params->traffic_load_threshold;
6555 wmi_roam_mawc_params->best_ap_rssi_threshold =
6556 params->best_ap_rssi_threshold;
6557 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6558 params->rssi_stationary_high_adjust;
6559 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6560 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006561 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6562 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6563 wmi_roam_mawc_params->traffic_load_threshold,
6564 wmi_roam_mawc_params->best_ap_rssi_threshold,
6565 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6566 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006567
6568 status = wmi_unified_cmd_send(wmi_handle, buf,
6569 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6570 if (QDF_IS_STATUS_ERROR(status)) {
6571 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6572 status);
6573 wmi_buf_free(buf);
6574 return status;
6575 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006576
6577 return QDF_STATUS_SUCCESS;
6578}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306579
6580/**
6581 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6582 * rssi threashold
6583 * @wmi_handle: wmi handle
6584 * @roam_req: Roaming request buffer
6585 *
6586 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6587 *
6588 * Return: QDF status
6589 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306590static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306591 struct roam_offload_scan_rssi_params *roam_req)
6592{
6593 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306594 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306595 int len;
6596 uint8_t *buf_ptr;
6597 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6598 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6599 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306600 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006601 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306602
6603 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6604 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6605 len += sizeof(wmi_roam_scan_extended_threshold_param);
6606 len += WMI_TLV_HDR_SIZE;
6607 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306608 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6609 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006610 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6611 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306612 buf = wmi_buf_alloc(wmi_handle, len);
6613 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306614 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306615 return QDF_STATUS_E_NOMEM;
6616 }
6617
6618 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6619 rssi_threshold_fp =
6620 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6621 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6622 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6623 WMITLV_GET_STRUCT_TLVLEN
6624 (wmi_roam_scan_rssi_threshold_fixed_param));
6625 /* fill in threshold values */
6626 rssi_threshold_fp->vdev_id = roam_req->session_id;
6627 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6628 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6629 rssi_threshold_fp->hirssi_scan_max_count =
6630 roam_req->hi_rssi_scan_max_count;
6631 rssi_threshold_fp->hirssi_scan_delta =
6632 roam_req->hi_rssi_scan_rssi_delta;
6633 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006634 rssi_threshold_fp->rssi_thresh_offset_5g =
6635 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306636
6637 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6638 WMITLV_SET_HDR(buf_ptr,
6639 WMITLV_TAG_ARRAY_STRUC,
6640 sizeof(wmi_roam_scan_extended_threshold_param));
6641 buf_ptr += WMI_TLV_HDR_SIZE;
6642 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6643
6644 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6645 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6646 ext_thresholds->boost_threshold_5g =
6647 roam_req->boost_threshold_5g;
6648
6649 ext_thresholds->boost_algorithm_5g =
6650 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6651 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6652 ext_thresholds->penalty_algorithm_5g =
6653 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6654 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6655 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6656 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6657 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6658
6659 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6660 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6661 WMITLV_GET_STRUCT_TLVLEN
6662 (wmi_roam_scan_extended_threshold_param));
6663 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6664 WMITLV_SET_HDR(buf_ptr,
6665 WMITLV_TAG_ARRAY_STRUC,
6666 sizeof(wmi_roam_earlystop_rssi_thres_param));
6667 buf_ptr += WMI_TLV_HDR_SIZE;
6668 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6669 early_stop_thresholds->roam_earlystop_thres_min =
6670 roam_req->roam_earlystop_thres_min;
6671 early_stop_thresholds->roam_earlystop_thres_max =
6672 roam_req->roam_earlystop_thres_max;
6673 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6674 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6675 WMITLV_GET_STRUCT_TLVLEN
6676 (wmi_roam_earlystop_rssi_thres_param));
6677
Gupta, Kapil7e652922016-04-12 15:02:00 +05306678 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6679 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6680 sizeof(wmi_roam_dense_thres_param));
6681 buf_ptr += WMI_TLV_HDR_SIZE;
6682 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6683 dense_thresholds->roam_dense_rssi_thres_offset =
6684 roam_req->dense_rssi_thresh_offset;
6685 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6686 dense_thresholds->roam_dense_traffic_thres =
6687 roam_req->traffic_threshold;
6688 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6689 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6690 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6691 WMITLV_GET_STRUCT_TLVLEN
6692 (wmi_roam_dense_thres_param));
6693
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006694 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6695 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6696 sizeof(wmi_roam_bg_scan_roaming_param));
6697 buf_ptr += WMI_TLV_HDR_SIZE;
6698 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6699 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6700 roam_req->bg_scan_bad_rssi_thresh;
6701 bg_scan_params->roam_bg_scan_client_bitmap =
6702 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306703 bg_scan_params->bad_rssi_thresh_offset_2g =
6704 roam_req->roam_bad_rssi_thresh_offset_2g;
6705 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006706 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6707 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6708 WMITLV_GET_STRUCT_TLVLEN
6709 (wmi_roam_bg_scan_roaming_param));
6710
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306711 status = wmi_unified_cmd_send(wmi_handle, buf,
6712 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306713 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306714 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306715 status);
6716 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306717 }
6718
Govind Singh67922e82016-04-01 16:48:57 +05306719 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306720}
6721
6722/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306723 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6724 * configuration params
6725 * @wma_handle: wma handler
6726 * @dwelltime_params: pointer to dwelltime_params
6727 *
6728 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6729 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006730static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306731QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6732 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6733{
6734 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6735 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6736 wmi_buf_t buf;
6737 uint8_t *buf_ptr;
6738 int32_t err;
6739 int len;
6740
6741 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6742 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6743 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6744 buf = wmi_buf_alloc(wmi_handle, len);
6745 if (!buf) {
6746 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6747 __func__);
6748 return QDF_STATUS_E_NOMEM;
6749 }
6750 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6751 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6752 WMITLV_SET_HDR(&dwell_param->tlv_header,
6753 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6754 WMITLV_GET_STRUCT_TLVLEN
6755 (wmi_scan_adaptive_dwell_config_fixed_param));
6756
6757 dwell_param->enable = dwelltime_params->is_enabled;
6758 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6759 WMITLV_SET_HDR(buf_ptr,
6760 WMITLV_TAG_ARRAY_STRUC,
6761 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6762 buf_ptr += WMI_TLV_HDR_SIZE;
6763
6764 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6765 WMITLV_SET_HDR(&cmd->tlv_header,
6766 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6767 WMITLV_GET_STRUCT_TLVLEN(
6768 wmi_scan_adaptive_dwell_parameters_tlv));
6769
6770 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6771 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6772 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6773 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6774 err = wmi_unified_cmd_send(wmi_handle, buf,
6775 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6776 if (err) {
6777 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6778 wmi_buf_free(buf);
6779 return QDF_STATUS_E_FAILURE;
6780 }
6781
6782 return QDF_STATUS_SUCCESS;
6783}
6784
Nitesh Shah52323d02017-05-22 15:49:00 +05306785/**
6786 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6787 * configuration params
6788 * @wmi_handle: wmi handler
6789 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6790 *
6791 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6792 */
6793static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6794 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6795{
6796 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6797 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6798 wmi_buf_t buf;
6799 uint8_t *buf_ptr;
6800 QDF_STATUS err;
6801 uint32_t i;
6802 int len;
6803
6804 len = sizeof(*dbs_scan_param);
6805 len += WMI_TLV_HDR_SIZE;
6806 len += dbs_scan_params->num_clients * sizeof(*cmd);
6807
6808 buf = wmi_buf_alloc(wmi_handle, len);
6809 if (!buf) {
6810 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6811 return QDF_STATUS_E_NOMEM;
6812 }
6813
6814 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6815 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6816 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6817 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6818 WMITLV_GET_STRUCT_TLVLEN
6819 (wmi_scan_dbs_duty_cycle_fixed_param));
6820
6821 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6822 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6823 buf_ptr += sizeof(*dbs_scan_param);
6824 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6825 (sizeof(*cmd) * dbs_scan_params->num_clients));
6826 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6827
6828 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6829 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6830 WMITLV_SET_HDR(&cmd->tlv_header,
6831 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6832 WMITLV_GET_STRUCT_TLVLEN(
6833 wmi_scan_dbs_duty_cycle_tlv_param));
6834 cmd->module_id = dbs_scan_params->module_id[i];
6835 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6836 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6837 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6838 }
6839
6840 err = wmi_unified_cmd_send(wmi_handle, buf,
6841 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6842 if (QDF_IS_STATUS_ERROR(err)) {
6843 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6844 wmi_buf_free(buf);
6845 return QDF_STATUS_E_FAILURE;
6846 }
6847
6848 return QDF_STATUS_SUCCESS;
6849}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306850
6851/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306852 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6853 * @wmi_handle: wmi handle
6854 * @roam_req: Request which contains the filters
6855 *
6856 * There are filters such as whitelist, blacklist and preferred
6857 * list that need to be applied to the scan results to form the
6858 * probable candidates for roaming.
6859 *
6860 * Return: Return success upon succesfully passing the
6861 * parameters to the firmware, otherwise failure.
6862 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306863static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306864 struct roam_scan_filter_params *roam_req)
6865{
6866 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306867 QDF_STATUS status;
6868 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306869 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306870 uint8_t *buf_ptr;
6871 wmi_roam_filter_fixed_param *roam_filter;
6872 uint8_t *bssid_src_ptr = NULL;
6873 wmi_mac_addr *bssid_dst_ptr = NULL;
6874 wmi_ssid *ssid_ptr = NULL;
6875 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306876 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306877 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306878
6879 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306880
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306881 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306882 if (roam_req->num_bssid_black_list)
6883 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6884 len += WMI_TLV_HDR_SIZE;
6885 if (roam_req->num_ssid_white_list)
6886 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6887 len += 2 * WMI_TLV_HDR_SIZE;
6888 if (roam_req->num_bssid_preferred_list) {
6889 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05306890 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306891 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306892 len += WMI_TLV_HDR_SIZE;
6893 if (roam_req->lca_disallow_config_present) {
6894 len += sizeof(*blist_param);
6895 blist_len = sizeof(*blist_param);
6896 }
6897
6898 len += WMI_TLV_HDR_SIZE;
6899 if (roam_req->num_rssi_rejection_ap)
6900 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306901
6902 buf = wmi_buf_alloc(wmi_handle, len);
6903 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306904 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306905 return QDF_STATUS_E_NOMEM;
6906 }
6907
6908 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6909 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6910 WMITLV_SET_HDR(&roam_filter->tlv_header,
6911 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6912 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6913 /* fill in fixed values */
6914 roam_filter->vdev_id = roam_req->session_id;
6915 roam_filter->flags = 0;
6916 roam_filter->op_bitmap = roam_req->op_bitmap;
6917 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6918 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6919 roam_filter->num_bssid_preferred_list =
6920 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306921 roam_filter->num_rssi_rejection_ap =
6922 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306923 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6924
6925 WMITLV_SET_HDR((buf_ptr),
6926 WMITLV_TAG_ARRAY_FIXED_STRUC,
6927 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6928 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6929 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6930 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6931 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6932 bssid_src_ptr += ATH_MAC_LEN;
6933 bssid_dst_ptr++;
6934 }
6935 buf_ptr += WMI_TLV_HDR_SIZE +
6936 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6937 WMITLV_SET_HDR((buf_ptr),
6938 WMITLV_TAG_ARRAY_FIXED_STRUC,
6939 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6940 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6941 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6942 qdf_mem_copy(&ssid_ptr->ssid,
6943 &roam_req->ssid_allowed_list[i].mac_ssid,
6944 roam_req->ssid_allowed_list[i].length);
6945 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6946 ssid_ptr++;
6947 }
6948 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6949 sizeof(wmi_ssid));
6950 WMITLV_SET_HDR((buf_ptr),
6951 WMITLV_TAG_ARRAY_FIXED_STRUC,
6952 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6953 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6954 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6955 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6956 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6957 (wmi_mac_addr *)bssid_dst_ptr);
6958 bssid_src_ptr += ATH_MAC_LEN;
6959 bssid_dst_ptr++;
6960 }
6961 buf_ptr += WMI_TLV_HDR_SIZE +
6962 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6963 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6964 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6965 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6966 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6967 *bssid_preferred_factor_ptr =
6968 roam_req->bssid_favored_factor[i];
6969 bssid_preferred_factor_ptr++;
6970 }
6971 buf_ptr += WMI_TLV_HDR_SIZE +
6972 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6973
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306974 WMITLV_SET_HDR(buf_ptr,
6975 WMITLV_TAG_ARRAY_STRUC, blist_len);
6976 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306977 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306978 blist_param =
6979 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6980 WMITLV_SET_HDR(&blist_param->tlv_header,
6981 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6982 WMITLV_GET_STRUCT_TLVLEN(
6983 wmi_roam_lca_disallow_config_tlv_param));
6984
6985 blist_param->disallow_duration = roam_req->disallow_duration;
6986 blist_param->rssi_channel_penalization =
6987 roam_req->rssi_channel_penalization;
6988 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05306989 blist_param->disallow_lca_enable_source_bitmap =
6990 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
6991 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306992 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6993 }
6994
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306995 WMITLV_SET_HDR(buf_ptr,
6996 WMITLV_TAG_ARRAY_STRUC,
6997 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
6998 buf_ptr += WMI_TLV_HDR_SIZE;
6999 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
7000 rssi_rej =
7001 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
7002 WMITLV_SET_HDR(&rssi_rej->tlv_header,
7003 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
7004 WMITLV_GET_STRUCT_TLVLEN(
7005 wmi_roam_rssi_rejection_oce_config_param));
7006 WMI_CHAR_ARRAY_TO_MAC_ADDR(
7007 roam_req->rssi_rejection_ap[i].bssid.bytes,
7008 &rssi_rej->bssid);
7009 rssi_rej->remaining_disallow_duration =
7010 roam_req->rssi_rejection_ap[i].remaining_duration;
7011 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05307012 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05307013 buf_ptr +=
7014 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
7015 }
7016
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307017 status = wmi_unified_cmd_send(wmi_handle, buf,
7018 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307019 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307020 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307021 status);
7022 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307023 }
Govind Singh67922e82016-04-01 16:48:57 +05307024
7025 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05307026}
7027
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05307028#if defined(WLAN_FEATURE_FILS_SK)
7029static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7030 struct hlp_params *params)
7031{
7032 uint32_t len;
7033 uint8_t *buf_ptr;
7034 wmi_buf_t buf = NULL;
7035 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7036
7037 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7038 len += WMI_TLV_HDR_SIZE;
7039 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7040
7041 buf = wmi_buf_alloc(wmi_handle, len);
7042 if (!buf) {
7043 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7044 return QDF_STATUS_E_NOMEM;
7045 }
7046
7047 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7048 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7049 WMITLV_SET_HDR(&hlp_params->tlv_header,
7050 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7051 WMITLV_GET_STRUCT_TLVLEN(
7052 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7053
7054 hlp_params->vdev_id = params->vdev_id;
7055 hlp_params->size = params->hlp_ie_len;
7056 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7057
7058 buf_ptr += sizeof(*hlp_params);
7059
7060 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7061 round_up(params->hlp_ie_len,
7062 sizeof(uint32_t)));
7063 buf_ptr += WMI_TLV_HDR_SIZE;
7064 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7065
7066 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7067 hlp_params->vdev_id, hlp_params->size);
7068 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7069 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7070 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7071 wmi_buf_free(buf);
7072 return QDF_STATUS_E_FAILURE;
7073 }
7074
7075 return QDF_STATUS_SUCCESS;
7076}
7077#endif
7078
Govind Singh4eacd2b2016-03-07 14:24:22 +05307079/** send_set_epno_network_list_cmd_tlv() - set epno network list
7080 * @wmi_handle: wmi handle
7081 * @req: epno config params request structure
7082 *
7083 * This function reads the incoming epno config request structure
7084 * and constructs the WMI message to the firmware.
7085 *
7086 * Returns: 0 on success, error number otherwise
7087 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307088static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307089 struct wifi_enhanched_pno_params *req)
7090{
7091 wmi_nlo_config_cmd_fixed_param *cmd;
7092 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307093 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307094 u_int8_t i, *buf_ptr;
7095 wmi_buf_t buf;
7096 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307097 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307098
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307099 /* Fixed Params */
7100 len = sizeof(*cmd);
7101 if (req->num_networks) {
7102 /* TLV place holder for array of structures
7103 * then each nlo_configured_parameters(nlo_list) TLV.
7104 */
7105 len += WMI_TLV_HDR_SIZE;
7106 len += (sizeof(nlo_configured_parameters)
7107 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
7108 /* TLV for array of uint32 channel_list */
7109 len += WMI_TLV_HDR_SIZE;
7110 /* TLV for nlo_channel_prediction_cfg */
7111 len += WMI_TLV_HDR_SIZE;
7112 /* TLV for candidate score params */
7113 len += sizeof(enlo_candidate_score_params);
7114 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05307115
7116 buf = wmi_buf_alloc(wmi_handle, len);
7117 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307118 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7119 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307120 }
7121
7122 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7123
7124 buf_ptr = (u_int8_t *) cmd;
7125 WMITLV_SET_HDR(&cmd->tlv_header,
7126 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7127 WMITLV_GET_STRUCT_TLVLEN(
7128 wmi_nlo_config_cmd_fixed_param));
7129 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307130
7131 /* set flag to reset if num of networks are 0 */
7132 cmd->flags = (req->num_networks == 0 ?
7133 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307134
7135 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7136
Govind Singhb53420c2016-03-09 14:32:57 +05307137 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307138 WMI_LOGD("SSID count: %d flags: %d",
7139 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307140
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307141 /* Fill nlo_config only when num_networks are non zero */
7142 if (cmd->no_of_ssids) {
7143 /* Fill networks */
7144 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7145 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7146 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307147
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307148 nlo_list = (nlo_configured_parameters *) buf_ptr;
7149 for (i = 0; i < cmd->no_of_ssids; i++) {
7150 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7151 WMITLV_TAG_ARRAY_BYTE,
7152 WMITLV_GET_STRUCT_TLVLEN(
7153 nlo_configured_parameters));
7154 /* Copy ssid and it's length */
7155 nlo_list[i].ssid.valid = true;
7156 nlo_list[i].ssid.ssid.ssid_len =
7157 req->networks[i].ssid.length;
7158 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
7159 req->networks[i].ssid.mac_ssid,
7160 nlo_list[i].ssid.ssid.ssid_len);
7161 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
7162 nlo_list[i].ssid.ssid.ssid_len,
7163 (char *) nlo_list[i].ssid.ssid.ssid,
7164 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307165
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307166 /* Copy pno flags */
7167 nlo_list[i].bcast_nw_type.valid = true;
7168 nlo_list[i].bcast_nw_type.bcast_nw_type =
7169 req->networks[i].flags;
7170 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307171 nlo_list[i].bcast_nw_type.bcast_nw_type);
7172
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307173 /* Copy auth bit field */
7174 nlo_list[i].auth_type.valid = true;
7175 nlo_list[i].auth_type.auth_type =
7176 req->networks[i].auth_bit_field;
7177 WMI_LOGD("Auth bit field (%u)",
7178 nlo_list[i].auth_type.auth_type);
7179 }
7180
7181 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7182 /* Fill the channel list */
7183 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7184 buf_ptr += WMI_TLV_HDR_SIZE;
7185
7186 /* Fill prediction_param */
7187 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7188 buf_ptr += WMI_TLV_HDR_SIZE;
7189
7190 /* Fill epno candidate score params */
7191 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
7192 WMITLV_SET_HDR(buf_ptr,
7193 WMITLV_TAG_STRUC_enlo_candidate_score_param,
7194 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7195 cand_score_params->min5GHz_rssi =
7196 req->min_5ghz_rssi;
7197 cand_score_params->min24GHz_rssi =
7198 req->min_24ghz_rssi;
7199 cand_score_params->initial_score_max =
7200 req->initial_score_max;
7201 cand_score_params->current_connection_bonus =
7202 req->current_connection_bonus;
7203 cand_score_params->same_network_bonus =
7204 req->same_network_bonus;
7205 cand_score_params->secure_bonus =
7206 req->secure_bonus;
7207 cand_score_params->band5GHz_bonus =
7208 req->band_5ghz_bonus;
7209 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307210 }
7211
Govind Singh4eacd2b2016-03-07 14:24:22 +05307212 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307213 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307214 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307215 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307216 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05307217 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307218 }
7219
Govind Singhb53420c2016-03-09 14:32:57 +05307220 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307221 req->session_id);
7222
Govind Singh67922e82016-04-01 16:48:57 +05307223 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307224}
7225
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307226#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307227/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7228 * @wmi_handle: wmi handle
7229 * @ipa_offload: ipa offload control parameter
7230 *
7231 * Returns: 0 on success, error number otherwise
7232 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307233static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307234 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307235{
7236 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7237 wmi_buf_t wmi_buf;
7238 uint32_t len;
7239 u_int8_t *buf_ptr;
7240
7241 len = sizeof(*cmd);
7242 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7243 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307244 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7245 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307246 }
7247
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007248 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307249 ipa_offload->offload_type, ipa_offload->enable);
7250
7251 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7252
7253 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7254 WMITLV_SET_HDR(&cmd->tlv_header,
7255 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7256 WMITLV_GET_STRUCT_TLVLEN(
7257 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7258
7259 cmd->offload_type = ipa_offload->offload_type;
7260 cmd->vdev_id = ipa_offload->vdev_id;
7261 cmd->enable = ipa_offload->enable;
7262
7263 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7264 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307265 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307266 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307267 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307268 }
7269
Govind Singhb53420c2016-03-09 14:32:57 +05307270 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307271}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307272#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307273
7274/**
7275 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
7276 * @wmi_handle: wmi handle
7277 * @pgetcapab: get capabilities params
7278 *
7279 * This function send request to fw to get extscan capabilities.
7280 *
7281 * Return: CDF status
7282 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307283static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307284 struct extscan_capabilities_params *pgetcapab)
7285{
7286 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
7287 wmi_buf_t wmi_buf;
7288 uint32_t len;
7289 uint8_t *buf_ptr;
7290
7291 len = sizeof(*cmd);
7292 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7293 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307294 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7295 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307296 }
7297 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7298
7299 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
7300 WMITLV_SET_HDR(&cmd->tlv_header,
7301 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
7302 WMITLV_GET_STRUCT_TLVLEN
7303 (wmi_extscan_get_capabilities_cmd_fixed_param));
7304
7305 cmd->request_id = pgetcapab->request_id;
7306
7307 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7308 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307309 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307310 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307311 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307312 }
Govind Singhb53420c2016-03-09 14:32:57 +05307313 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307314}
7315
7316/**
7317 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
7318 * @wmi_handle: wmi handle
7319 * @pcached_results: cached results parameters
7320 *
7321 * This function send request to fw to get cached results.
7322 *
7323 * Return: CDF status
7324 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307325static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307326 struct extscan_cached_result_params *pcached_results)
7327{
7328 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
7329 wmi_buf_t wmi_buf;
7330 uint32_t len;
7331 uint8_t *buf_ptr;
7332
7333 len = sizeof(*cmd);
7334 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7335 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307336 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7337 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307338 }
7339 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7340
7341 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
7342 WMITLV_SET_HDR(&cmd->tlv_header,
7343 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
7344 WMITLV_GET_STRUCT_TLVLEN
7345 (wmi_extscan_get_cached_results_cmd_fixed_param));
7346
7347 cmd->request_id = pcached_results->request_id;
7348 cmd->vdev_id = pcached_results->session_id;
7349 cmd->control_flags = pcached_results->flush;
7350
7351 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7352 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307353 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307354 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307355 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307356 }
Govind Singhb53420c2016-03-09 14:32:57 +05307357 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307358}
7359
7360/**
7361 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
7362 * @wmi_handle: wmi handle
7363 * @reset_req: Reset change request params
7364 *
7365 * This function sends stop change monitor request to fw.
7366 *
7367 * Return: CDF status
7368 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307369static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307370 struct extscan_capabilities_reset_params *reset_req)
7371{
7372 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7373 wmi_buf_t wmi_buf;
7374 uint32_t len;
7375 uint8_t *buf_ptr;
7376 int change_list = 0;
7377
7378 len = sizeof(*cmd);
7379
7380 /* reset significant change tlv is set to 0 */
7381 len += WMI_TLV_HDR_SIZE;
7382 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
7383 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7384 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307385 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7386 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307387 }
7388 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7389
7390 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7391 buf_ptr;
7392 WMITLV_SET_HDR(&cmd->tlv_header,
7393 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7394 WMITLV_GET_STRUCT_TLVLEN
7395 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7396
7397 cmd->request_id = reset_req->request_id;
7398 cmd->vdev_id = reset_req->session_id;
7399 cmd->mode = 0;
7400
7401 buf_ptr += sizeof(*cmd);
7402 WMITLV_SET_HDR(buf_ptr,
7403 WMITLV_TAG_ARRAY_STRUC,
7404 change_list *
7405 sizeof(wmi_extscan_wlan_change_bssid_param));
7406 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
7407 sizeof
7408 (wmi_extscan_wlan_change_bssid_param));
7409
7410 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7411 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307412 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307413 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307414 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307415 }
Govind Singhb53420c2016-03-09 14:32:57 +05307416 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307417}
7418
7419/**
7420 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
7421 * @wmi_handle: wmi handle
7422 * @psigchange: change monitor request params
7423 * @buf: wmi buffer
7424 * @buf_len: buffer length
7425 *
7426 * This function fills elements of change monitor request buffer.
7427 *
7428 * Return: CDF status
7429 */
Govind Singhb53420c2016-03-09 14:32:57 +05307430static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307431 struct extscan_set_sig_changereq_params
7432 *psigchange, wmi_buf_t *buf, int *buf_len)
7433{
7434 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
7435 wmi_extscan_wlan_change_bssid_param *dest_chglist;
7436 uint8_t *buf_ptr;
7437 int j;
7438 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007439 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307440 struct ap_threshold_params *src_ap = psigchange->ap;
7441
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08007442 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307443 WMI_LOGE("%s: Invalid number of bssid's", __func__);
7444 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307445 }
7446 len += WMI_TLV_HDR_SIZE;
7447 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
7448
7449 *buf = wmi_buf_alloc(wmi_handle, len);
7450 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307451 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307452 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307453 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307454 }
7455 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7456 cmd =
7457 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
7458 buf_ptr;
7459 WMITLV_SET_HDR(&cmd->tlv_header,
7460 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
7461 WMITLV_GET_STRUCT_TLVLEN
7462 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
7463
7464 cmd->request_id = psigchange->request_id;
7465 cmd->vdev_id = psigchange->session_id;
7466 cmd->total_entries = numap;
7467 cmd->mode = 1;
7468 cmd->num_entries_in_page = numap;
7469 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
7470 cmd->max_rssi_samples = psigchange->rssi_sample_size;
7471 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
7472 cmd->max_out_of_range_count = psigchange->min_breaching;
7473
7474 buf_ptr += sizeof(*cmd);
7475 WMITLV_SET_HDR(buf_ptr,
7476 WMITLV_TAG_ARRAY_STRUC,
7477 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7478 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
7479 (buf_ptr + WMI_TLV_HDR_SIZE);
7480
7481 for (j = 0; j < numap; j++) {
7482 WMITLV_SET_HDR(dest_chglist,
7483 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7484 WMITLV_GET_STRUCT_TLVLEN
7485 (wmi_extscan_wlan_change_bssid_param));
7486
7487 dest_chglist->lower_rssi_limit = src_ap->low;
7488 dest_chglist->upper_rssi_limit = src_ap->high;
7489 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
7490 &dest_chglist->bssid);
7491
Govind Singhb53420c2016-03-09 14:32:57 +05307492 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307493 dest_chglist->lower_rssi_limit);
7494 dest_chglist++;
7495 src_ap++;
7496 }
7497 buf_ptr += WMI_TLV_HDR_SIZE +
7498 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
7499 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307500 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307501}
7502
7503/**
7504 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
7505 * @wmi_handle: wmi handle
7506 * @psigchange: change monitor request params
7507 *
7508 * This function sends start change monitor request to fw.
7509 *
7510 * Return: CDF status
7511 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307512static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307513 struct extscan_set_sig_changereq_params *
7514 psigchange)
7515{
Govind Singhb53420c2016-03-09 14:32:57 +05307516 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307517 wmi_buf_t buf;
7518 int len;
7519
7520
Govind Singhb53420c2016-03-09 14:32:57 +05307521 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307522 psigchange, &buf,
7523 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307524 if (qdf_status != QDF_STATUS_SUCCESS) {
7525 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307526 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307527 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307528 }
7529 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307530 WMI_LOGE("%s: Failed to get buffer", __func__);
7531 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307532 }
7533 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7534 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307535 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307536 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307537 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307538 }
Govind Singhb53420c2016-03-09 14:32:57 +05307539 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307540}
7541
7542/**
7543 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
7544 * @wmi_handle: wmi handle
7545 * @photlist_reset: hotlist reset params
7546 *
7547 * This function configures hotlist monitor to stop in fw.
7548 *
7549 * Return: CDF status
7550 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307551static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307552 struct extscan_bssid_hotlist_reset_params *photlist_reset)
7553{
7554 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
7555 wmi_buf_t wmi_buf;
7556 uint32_t len;
7557 uint8_t *buf_ptr;
7558 int hotlist_entries = 0;
7559
7560 len = sizeof(*cmd);
7561
7562 /* reset bssid hotlist with tlv set to 0 */
7563 len += WMI_TLV_HDR_SIZE;
7564 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
7565
7566 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7567 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307568 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7569 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307570 }
7571
7572 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7573 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
7574 buf_ptr;
7575 WMITLV_SET_HDR(&cmd->tlv_header,
7576 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
7577 WMITLV_GET_STRUCT_TLVLEN
7578 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
7579
7580 cmd->request_id = photlist_reset->request_id;
7581 cmd->vdev_id = photlist_reset->session_id;
7582 cmd->mode = 0;
7583
7584 buf_ptr += sizeof(*cmd);
7585 WMITLV_SET_HDR(buf_ptr,
7586 WMITLV_TAG_ARRAY_STRUC,
7587 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7588 buf_ptr += WMI_TLV_HDR_SIZE +
7589 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
7590
7591 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7592 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307593 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307594 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307595 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307596 }
Govind Singhb53420c2016-03-09 14:32:57 +05307597 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307598}
7599
7600/**
7601 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
7602 * @wmi_handle: wmi handle
7603 * @pstopcmd: stop scan command request params
7604 *
7605 * This function sends stop extscan request to fw.
7606 *
7607 * Return: CDF Status.
7608 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307609static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307610 struct extscan_stop_req_params *pstopcmd)
7611{
7612 wmi_extscan_stop_cmd_fixed_param *cmd;
7613 wmi_buf_t wmi_buf;
7614 uint32_t len;
7615 uint8_t *buf_ptr;
7616
7617 len = sizeof(*cmd);
7618 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7619 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307620 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7621 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307622 }
7623 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7624 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
7625 WMITLV_SET_HDR(&cmd->tlv_header,
7626 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
7627 WMITLV_GET_STRUCT_TLVLEN
7628 (wmi_extscan_stop_cmd_fixed_param));
7629
7630 cmd->request_id = pstopcmd->request_id;
7631 cmd->vdev_id = pstopcmd->session_id;
7632
7633 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7634 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307635 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307636 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307637 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307638 }
7639
Govind Singhb53420c2016-03-09 14:32:57 +05307640 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307641}
7642
7643/**
7644 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
7645 * @wmi_handle: wmi handle
7646 * @pstart: scan command request params
7647 * @buf: event buffer
7648 * @buf_len: length of buffer
7649 *
7650 * This function fills individual elements of extscan request and
7651 * TLV for buckets, channel list.
7652 *
7653 * Return: CDF Status.
7654 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007655static
Govind Singhb53420c2016-03-09 14:32:57 +05307656QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307657 struct wifi_scan_cmd_req_params *pstart,
7658 wmi_buf_t *buf, int *buf_len)
7659{
7660 wmi_extscan_start_cmd_fixed_param *cmd;
7661 wmi_extscan_bucket *dest_blist;
7662 wmi_extscan_bucket_channel *dest_clist;
7663 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
7664 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
7665 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
7666
7667 uint8_t *buf_ptr;
7668 int i, k, count = 0;
7669 int len = sizeof(*cmd);
7670 int nbuckets = pstart->numBuckets;
7671 int nchannels = 0;
7672
7673 /* These TLV's are are NULL by default */
7674 uint32_t ie_len_with_pad = 0;
7675 int num_ssid = 0;
7676 int num_bssid = 0;
7677 int ie_len = 0;
7678
7679 uint32_t base_period = pstart->basePeriod;
7680
7681 /* TLV placeholder for ssid_list (NULL) */
7682 len += WMI_TLV_HDR_SIZE;
7683 len += num_ssid * sizeof(wmi_ssid);
7684
7685 /* TLV placeholder for bssid_list (NULL) */
7686 len += WMI_TLV_HDR_SIZE;
7687 len += num_bssid * sizeof(wmi_mac_addr);
7688
7689 /* TLV placeholder for ie_data (NULL) */
7690 len += WMI_TLV_HDR_SIZE;
7691 len += ie_len * sizeof(uint32_t);
7692
7693 /* TLV placeholder for bucket */
7694 len += WMI_TLV_HDR_SIZE;
7695 len += nbuckets * sizeof(wmi_extscan_bucket);
7696
7697 /* TLV channel placeholder */
7698 len += WMI_TLV_HDR_SIZE;
7699 for (i = 0; i < nbuckets; i++) {
7700 nchannels += src_bucket->numChannels;
7701 src_bucket++;
7702 }
7703
Govind Singhb53420c2016-03-09 14:32:57 +05307704 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307705 __func__, nbuckets, nchannels);
7706 len += nchannels * sizeof(wmi_extscan_bucket_channel);
7707 /* Allocate the memory */
7708 *buf = wmi_buf_alloc(wmi_handle, len);
7709 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307710 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307711 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307712 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307713 }
7714 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
7715 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
7716 WMITLV_SET_HDR(&cmd->tlv_header,
7717 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
7718 WMITLV_GET_STRUCT_TLVLEN
7719 (wmi_extscan_start_cmd_fixed_param));
7720
7721 cmd->request_id = pstart->requestId;
7722 cmd->vdev_id = pstart->sessionId;
7723 cmd->base_period = pstart->basePeriod;
7724 cmd->num_buckets = nbuckets;
7725 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05307726 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307727 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05307728 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307729 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05307730#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05307731 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
7732 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05307733 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
7734 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
7735#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307736 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7737
7738 /* The max dwell time is retrieved from the first channel
7739 * of the first bucket and kept common for all channels.
7740 */
7741 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
7742 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
7743 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
7744 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
7745 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
7746 cmd->max_table_usage = pstart->report_threshold_percent;
7747 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
7748
7749 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05307750 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307751 cmd->probe_delay = 0;
7752 cmd->probe_spacing_time = 0;
7753 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307754 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
7755 WMI_SCAN_ADD_CCK_RATES |
7756 WMI_SCAN_ADD_OFDM_RATES |
7757 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
7758 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05307759 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
7760 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05307761 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307762 cmd->num_ssids = 0;
7763 cmd->num_bssid = 0;
7764 cmd->ie_len = 0;
7765 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
7766 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
7767
7768 buf_ptr += sizeof(*cmd);
7769 WMITLV_SET_HDR(buf_ptr,
7770 WMITLV_TAG_ARRAY_FIXED_STRUC,
7771 num_ssid * sizeof(wmi_ssid));
7772 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
7773
7774 WMITLV_SET_HDR(buf_ptr,
7775 WMITLV_TAG_ARRAY_FIXED_STRUC,
7776 num_bssid * sizeof(wmi_mac_addr));
7777 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
7778
7779 ie_len_with_pad = 0;
7780 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7781 ie_len_with_pad);
7782 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
7783
7784 WMITLV_SET_HDR(buf_ptr,
7785 WMITLV_TAG_ARRAY_STRUC,
7786 nbuckets * sizeof(wmi_extscan_bucket));
7787 dest_blist = (wmi_extscan_bucket *)
7788 (buf_ptr + WMI_TLV_HDR_SIZE);
7789 src_bucket = pstart->buckets;
7790
7791 /* Retrieve scanning information from each bucket and
7792 * channels and send it to the target
7793 */
7794 for (i = 0; i < nbuckets; i++) {
7795 WMITLV_SET_HDR(dest_blist,
7796 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
7797 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
7798
7799 dest_blist->bucket_id = src_bucket->bucket;
7800 dest_blist->base_period_multiplier =
7801 src_bucket->period / base_period;
7802 dest_blist->min_period = src_bucket->period;
7803 dest_blist->max_period = src_bucket->max_period;
7804 dest_blist->exp_backoff = src_bucket->exponent;
7805 dest_blist->exp_max_step_count = src_bucket->step_count;
7806 dest_blist->channel_band = src_bucket->band;
7807 dest_blist->num_channels = src_bucket->numChannels;
7808 dest_blist->notify_extscan_events = 0;
7809
7810 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
7811 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07007812 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
7813 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307814
7815 if (src_bucket->reportEvents &
7816 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
7817 dest_blist->forwarding_flags =
7818 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
7819 dest_blist->notify_extscan_events |=
7820 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
7821 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
7822 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
7823 } else {
7824 dest_blist->forwarding_flags =
7825 WMI_EXTSCAN_NO_FORWARDING;
7826 }
7827
7828 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
7829 dest_blist->configuration_flags = 0;
7830 else
7831 dest_blist->configuration_flags =
7832 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
7833
Govind Singhb53420c2016-03-09 14:32:57 +05307834 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307835 __func__, dest_blist->notify_extscan_events,
7836 dest_blist->configuration_flags,
7837 dest_blist->forwarding_flags);
7838
7839 dest_blist->min_dwell_time_active =
7840 src_bucket->min_dwell_time_active;
7841 dest_blist->max_dwell_time_active =
7842 src_bucket->max_dwell_time_active;
7843 dest_blist->min_dwell_time_passive =
7844 src_bucket->min_dwell_time_passive;
7845 dest_blist->max_dwell_time_passive =
7846 src_bucket->max_dwell_time_passive;
7847 src_channel = src_bucket->channels;
7848
7849 /* save the channel info to later populate
7850 * the channel TLV
7851 */
7852 for (k = 0; k < src_bucket->numChannels; k++) {
7853 save_channel[count++].channel = src_channel->channel;
7854 src_channel++;
7855 }
7856 dest_blist++;
7857 src_bucket++;
7858 }
7859 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
7860 WMITLV_SET_HDR(buf_ptr,
7861 WMITLV_TAG_ARRAY_STRUC,
7862 nchannels * sizeof(wmi_extscan_bucket_channel));
7863 dest_clist = (wmi_extscan_bucket_channel *)
7864 (buf_ptr + WMI_TLV_HDR_SIZE);
7865
7866 /* Active or passive scan is based on the bucket dwell time
7867 * and channel specific active,passive scans are not
7868 * supported yet
7869 */
7870 for (i = 0; i < nchannels; i++) {
7871 WMITLV_SET_HDR(dest_clist,
7872 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
7873 WMITLV_GET_STRUCT_TLVLEN
7874 (wmi_extscan_bucket_channel));
7875 dest_clist->channel = save_channel[i].channel;
7876 dest_clist++;
7877 }
7878 buf_ptr += WMI_TLV_HDR_SIZE +
7879 (nchannels * sizeof(wmi_extscan_bucket_channel));
7880 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05307881 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307882}
7883
7884/**
7885 * send_start_extscan_cmd_tlv() - start extscan command to fw.
7886 * @wmi_handle: wmi handle
7887 * @pstart: scan command request params
7888 *
7889 * This function sends start extscan request to fw.
7890 *
7891 * Return: CDF Status.
7892 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307893static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307894 struct wifi_scan_cmd_req_params *pstart)
7895{
Govind Singhb53420c2016-03-09 14:32:57 +05307896 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307897 wmi_buf_t buf;
7898 int len;
7899
7900 /* Fill individual elements of extscan request and
7901 * TLV for buckets, channel list.
7902 */
Govind Singhb53420c2016-03-09 14:32:57 +05307903 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307904 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05307905 if (qdf_status != QDF_STATUS_SUCCESS) {
7906 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
7907 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307908 }
7909 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307910 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05307911 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05307912 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307913 }
7914 if (wmi_unified_cmd_send(wmi_handle, buf,
7915 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307916 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307917 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307918 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307919 }
7920
Govind Singhb53420c2016-03-09 14:32:57 +05307921 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307922}
7923
7924/**
7925 * send_plm_stop_cmd_tlv() - plm stop request
7926 * @wmi_handle: wmi handle
7927 * @plm: plm request parameters
7928 *
7929 * This function request FW to stop PLM.
7930 *
7931 * Return: CDF status
7932 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307933static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307934 const struct plm_req_params *plm)
7935{
7936 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7937 int32_t len;
7938 wmi_buf_t buf;
7939 uint8_t *buf_ptr;
7940 int ret;
7941
7942 len = sizeof(*cmd);
7943 buf = wmi_buf_alloc(wmi_handle, len);
7944 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307945 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7946 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307947 }
7948
7949 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7950
7951 buf_ptr = (uint8_t *) cmd;
7952
7953 WMITLV_SET_HDR(&cmd->tlv_header,
7954 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7955 WMITLV_GET_STRUCT_TLVLEN
7956 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7957
7958 cmd->vdev_id = plm->session_id;
7959
7960 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307961 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307962
7963 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7964 WMI_VDEV_PLMREQ_STOP_CMDID);
7965 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307966 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307967 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307968 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307969 }
7970
Govind Singhb53420c2016-03-09 14:32:57 +05307971 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307972}
7973
7974/**
7975 * send_plm_start_cmd_tlv() - plm start request
7976 * @wmi_handle: wmi handle
7977 * @plm: plm request parameters
7978 *
7979 * This function request FW to start PLM.
7980 *
7981 * Return: CDF status
7982 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307983static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307984 const struct plm_req_params *plm,
7985 uint32_t *gchannel_list)
7986{
7987 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7988 uint32_t *channel_list;
7989 int32_t len;
7990 wmi_buf_t buf;
7991 uint8_t *buf_ptr;
7992 uint8_t count;
7993 int ret;
7994
7995 /* TLV place holder for channel_list */
7996 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7997 len += sizeof(uint32_t) * plm->plm_num_ch;
7998
7999 buf = wmi_buf_alloc(wmi_handle, len);
8000 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308001 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8002 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308003 }
8004 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
8005
8006 buf_ptr = (uint8_t *) cmd;
8007
8008 WMITLV_SET_HDR(&cmd->tlv_header,
8009 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
8010 WMITLV_GET_STRUCT_TLVLEN
8011 (wmi_vdev_plmreq_start_cmd_fixed_param));
8012
8013 cmd->vdev_id = plm->session_id;
8014
8015 cmd->meas_token = plm->meas_token;
8016 cmd->dialog_token = plm->diag_token;
8017 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05308018 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308019 cmd->off_duration = plm->meas_duration;
8020 cmd->burst_cycle = plm->burst_len;
8021 cmd->tx_power = plm->desired_tx_pwr;
8022 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
8023 cmd->num_chans = plm->plm_num_ch;
8024
8025 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
8026
Govind Singhb53420c2016-03-09 14:32:57 +05308027 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
8028 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
8029 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
8030 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
8031 WMI_LOGD("off_duration: %d", cmd->off_duration);
8032 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
8033 WMI_LOGD("tx_power: %d", cmd->tx_power);
8034 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308035
8036 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8037 (cmd->num_chans * sizeof(uint32_t)));
8038
8039 buf_ptr += WMI_TLV_HDR_SIZE;
8040 if (cmd->num_chans) {
8041 channel_list = (uint32_t *) buf_ptr;
8042 for (count = 0; count < cmd->num_chans; count++) {
8043 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308044 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308045 channel_list[count] =
8046 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05308047 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308048 }
8049 buf_ptr += cmd->num_chans * sizeof(uint32_t);
8050 }
8051
8052 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8053 WMI_VDEV_PLMREQ_START_CMDID);
8054 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308055 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308056 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308057 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308058 }
8059
Govind Singhb53420c2016-03-09 14:32:57 +05308060 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308061}
8062
8063/**
8064 * send_pno_stop_cmd_tlv() - PNO stop request
8065 * @wmi_handle: wmi handle
8066 * @vdev_id: vdev id
8067 *
8068 * This function request FW to stop ongoing PNO operation.
8069 *
8070 * Return: CDF status
8071 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308072static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308073{
8074 wmi_nlo_config_cmd_fixed_param *cmd;
8075 int32_t len = sizeof(*cmd);
8076 wmi_buf_t buf;
8077 uint8_t *buf_ptr;
8078 int ret;
8079
8080 /*
8081 * TLV place holder for array of structures nlo_configured_parameters
8082 * TLV place holder for array of uint32_t channel_list
8083 * TLV place holder for chnl prediction cfg
8084 */
8085 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
8086 buf = wmi_buf_alloc(wmi_handle, len);
8087 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308088 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8089 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308090 }
8091
8092 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8093 buf_ptr = (uint8_t *) cmd;
8094
8095 WMITLV_SET_HDR(&cmd->tlv_header,
8096 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8097 WMITLV_GET_STRUCT_TLVLEN
8098 (wmi_nlo_config_cmd_fixed_param));
8099
8100 cmd->vdev_id = vdev_id;
8101 cmd->flags = WMI_NLO_CONFIG_STOP;
8102 buf_ptr += sizeof(*cmd);
8103
8104 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8105 buf_ptr += WMI_TLV_HDR_SIZE;
8106
8107 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
8108 buf_ptr += WMI_TLV_HDR_SIZE;
8109
8110 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8111 buf_ptr += WMI_TLV_HDR_SIZE;
8112
8113
8114 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8115 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8116 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308117 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308118 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308119 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308120 }
8121
Govind Singhb53420c2016-03-09 14:32:57 +05308122 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308123}
8124
8125/**
Govind Singhccb0c272016-04-01 16:30:08 +05308126 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
8127 * @buf_ptr: Buffer passed by upper layers
8128 * @pno: Buffer to be sent to the firmware
8129 *
8130 * Copy the PNO Channel prediction configuration parameters
8131 * passed by the upper layers to a WMI format TLV and send it
8132 * down to the firmware.
8133 *
8134 * Return: None
8135 */
8136static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
8137 struct pno_scan_req_params *pno)
8138{
8139 nlo_channel_prediction_cfg *channel_prediction_cfg =
8140 (nlo_channel_prediction_cfg *) buf_ptr;
8141 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
8142 WMITLV_TAG_ARRAY_BYTE,
8143 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05308144#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05308145 channel_prediction_cfg->enable = pno->pno_channel_prediction;
8146 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
8147 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
8148 channel_prediction_cfg->full_scan_period_ms =
8149 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05308150#endif
Govind Singhccb0c272016-04-01 16:30:08 +05308151 buf_ptr += sizeof(nlo_channel_prediction_cfg);
8152 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
8153 channel_prediction_cfg->enable,
8154 channel_prediction_cfg->top_k_num,
8155 channel_prediction_cfg->stationary_threshold,
8156 channel_prediction_cfg->full_scan_period_ms);
8157}
8158
8159/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008160 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
8161 * @wmi_handle: wmi handle
8162 * @params: configuration parameters
8163 *
8164 * Return: QDF_STATUS
8165 */
8166static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
8167 struct nlo_mawc_params *params)
8168{
8169 wmi_buf_t buf = NULL;
8170 QDF_STATUS status;
8171 int len;
8172 uint8_t *buf_ptr;
8173 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
8174
8175 len = sizeof(*wmi_nlo_mawc_params);
8176 buf = wmi_buf_alloc(wmi_handle, len);
8177 if (!buf) {
8178 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8179 return QDF_STATUS_E_NOMEM;
8180 }
8181
8182 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8183 wmi_nlo_mawc_params =
8184 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
8185 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
8186 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
8187 WMITLV_GET_STRUCT_TLVLEN
8188 (wmi_nlo_configure_mawc_cmd_fixed_param));
8189 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
8190 if (params->enable)
8191 wmi_nlo_mawc_params->enable = 1;
8192 else
8193 wmi_nlo_mawc_params->enable = 0;
8194 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
8195 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
8196 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07008197 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
8198 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
8199 wmi_nlo_mawc_params->exp_backoff_ratio,
8200 wmi_nlo_mawc_params->init_scan_interval,
8201 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008202
8203 status = wmi_unified_cmd_send(wmi_handle, buf,
8204 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
8205 if (QDF_IS_STATUS_ERROR(status)) {
8206 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
8207 status);
8208 wmi_buf_free(buf);
8209 return QDF_STATUS_E_FAILURE;
8210 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07008211
8212 return QDF_STATUS_SUCCESS;
8213}
8214
8215/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05308216 * send_pno_start_cmd_tlv() - PNO start request
8217 * @wmi_handle: wmi handle
8218 * @pno: PNO request
8219 *
8220 * This function request FW to start PNO request.
8221 * Request: CDF status
8222 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308223static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05308224 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05308225{
8226 wmi_nlo_config_cmd_fixed_param *cmd;
8227 nlo_configured_parameters *nlo_list;
8228 uint32_t *channel_list;
8229 int32_t len;
8230 wmi_buf_t buf;
8231 uint8_t *buf_ptr;
8232 uint8_t i;
8233 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308234 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308235 connected_nlo_rssi_params *nlo_relative_rssi;
8236 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308237
8238 /*
8239 * TLV place holder for array nlo_configured_parameters(nlo_list)
8240 * TLV place holder for array of uint32_t channel_list
8241 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308242 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308243 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05308244 */
8245 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308246 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308247 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308248
Abhishek Singh5987b632017-03-03 22:09:07 +05308249 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308250 WMI_NLO_MAX_CHAN);
8251 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05308252 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308253 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308254 len += sizeof(enlo_candidate_score_params);
8255 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308256 len += sizeof(connected_nlo_rssi_params);
8257 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308258
8259 buf = wmi_buf_alloc(wmi_handle, len);
8260 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308261 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8262 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308263 }
8264
8265 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
8266
8267 buf_ptr = (uint8_t *) cmd;
8268 WMITLV_SET_HDR(&cmd->tlv_header,
8269 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
8270 WMITLV_GET_STRUCT_TLVLEN
8271 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05308272 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308273 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
8274
Govind Singh87542482016-06-08 19:40:11 +05308275#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05308276 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05308277 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05308278#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05308279 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05308280 cmd->active_dwell_time = pno->active_dwell_time;
8281 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308282
Manjeet Singhcd2dc062016-08-11 15:31:34 +05308283 if (pno->do_passive_scan)
8284 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308285 /* Copy scan interval */
8286 cmd->fast_scan_period = pno->fast_scan_period;
8287 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08008288 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308289 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07008290 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05308291 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308292 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05308293 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308294
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05308295 /* mac randomization attributes */
8296 if (pno->scan_random.randomize) {
8297 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
8298 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
8299 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
8300 pno->scan_random.mac_mask,
8301 &cmd->mac_addr,
8302 &cmd->mac_mask);
8303 }
8304
Govind Singh4eacd2b2016-03-07 14:24:22 +05308305 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
8306
Abhishek Singh5987b632017-03-03 22:09:07 +05308307 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05308308 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308309 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8310 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
8311 buf_ptr += WMI_TLV_HDR_SIZE;
8312
8313 nlo_list = (nlo_configured_parameters *) buf_ptr;
8314 for (i = 0; i < cmd->no_of_ssids; i++) {
8315 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
8316 WMITLV_TAG_ARRAY_BYTE,
8317 WMITLV_GET_STRUCT_TLVLEN
8318 (nlo_configured_parameters));
8319 /* Copy ssid and it's length */
8320 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05308321 nlo_list[i].ssid.ssid.ssid_len =
8322 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05308323 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05308324 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308325 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05308326 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308327 nlo_list[i].ssid.ssid.ssid_len,
8328 (char *)nlo_list[i].ssid.ssid.ssid,
8329 nlo_list[i].ssid.ssid.ssid_len);
8330
8331 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05308332 if (pno->networks_list[i].rssi_thresh &&
8333 pno->networks_list[i].rssi_thresh >
8334 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05308335 nlo_list[i].rssi_cond.valid = true;
8336 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05308337 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05308338 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308339 nlo_list[i].rssi_cond.rssi);
8340 }
8341 nlo_list[i].bcast_nw_type.valid = true;
8342 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05308343 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07008344 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308345 nlo_list[i].bcast_nw_type.bcast_nw_type);
8346 }
8347 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
8348
8349 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05308350 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308351 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05308352 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308353 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
8354 (cmd->num_of_channels * sizeof(uint32_t)));
8355 buf_ptr += WMI_TLV_HDR_SIZE;
8356
8357 channel_list = (uint32_t *) buf_ptr;
8358 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05308359 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05308360
8361 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05308362 channel_list[i] =
8363 wlan_chan_to_freq(pno->
8364 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308365
Govind Singhb53420c2016-03-09 14:32:57 +05308366 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308367 }
8368 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
8369 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8370 sizeof(nlo_channel_prediction_cfg));
8371 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05308372 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308373 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308374 /** TODO: Discrete firmware doesn't have command/option to configure
8375 * App IE which comes from wpa_supplicant as of part PNO start request.
8376 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05308377 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
8378 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
8379 buf_ptr += sizeof(enlo_candidate_score_params);
8380
8381 if (ie_whitelist->white_list) {
8382 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
8383 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
8384 &cmd->num_vendor_oui,
8385 ie_whitelist);
8386 }
8387
8388 /* ie white list */
8389 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
8390 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
8391 buf_ptr += WMI_TLV_HDR_SIZE;
8392 if (cmd->num_vendor_oui != 0) {
8393 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
8394 ie_whitelist->voui);
8395 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
8396 }
8397
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05308398 if (pno->relative_rssi_set)
8399 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
8400
8401 /*
8402 * Firmware calculation using connected PNO params:
8403 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
8404 * deduction of rssi_pref for chosen band_pref and
8405 * addition of rssi_pref for remaining bands (other than chosen band).
8406 */
8407 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
8408 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
8409 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
8410 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
8411 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
8412 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
8413 buf_ptr += sizeof(*nlo_relative_rssi);
8414
8415 /*
8416 * As of now Kernel and Host supports one band and rssi preference.
8417 * Firmware supports array of band and rssi preferences
8418 */
8419 cmd->num_cnlo_band_pref = 1;
8420 WMITLV_SET_HDR(buf_ptr,
8421 WMITLV_TAG_ARRAY_STRUC,
8422 cmd->num_cnlo_band_pref *
8423 sizeof(connected_nlo_bss_band_rssi_pref));
8424 buf_ptr += WMI_TLV_HDR_SIZE;
8425
8426 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
8427 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
8428 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
8429 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
8430 WMITLV_GET_STRUCT_TLVLEN(
8431 connected_nlo_bss_band_rssi_pref));
8432 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
8433 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
8434 WMI_LOGI("band_pref %d, rssi_pref %d",
8435 nlo_band_rssi[i].band,
8436 nlo_band_rssi[i].rssi_pref);
8437 }
8438 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
8439
Govind Singh4eacd2b2016-03-07 14:24:22 +05308440 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8441 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
8442 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308443 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308444 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308445 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308446 }
8447
Govind Singhb53420c2016-03-09 14:32:57 +05308448 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308449}
8450
8451/* send_set_ric_req_cmd_tlv() - set ric request element
8452 * @wmi_handle: wmi handle
8453 * @msg: message
8454 * @is_add_ts: is addts required
8455 *
8456 * This function sets ric request element for 11r roaming.
8457 *
8458 * Return: CDF status
8459 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308460static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308461 void *msg, uint8_t is_add_ts)
8462{
8463 wmi_ric_request_fixed_param *cmd;
8464 wmi_ric_tspec *tspec_param;
8465 wmi_buf_t buf;
8466 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05308467 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308468 int32_t len = sizeof(wmi_ric_request_fixed_param) +
8469 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
8470
8471 buf = wmi_buf_alloc(wmi_handle, len);
8472 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308473 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8474 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308475 }
8476
8477 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8478
8479 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
8480 WMITLV_SET_HDR(&cmd->tlv_header,
8481 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
8482 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
8483 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07008484 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308485 else
8486 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
8487 cmd->num_ric_request = 1;
8488 cmd->is_add_ric = is_add_ts;
8489
8490 buf_ptr += sizeof(wmi_ric_request_fixed_param);
8491 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
8492
8493 buf_ptr += WMI_TLV_HDR_SIZE;
8494 tspec_param = (wmi_ric_tspec *) buf_ptr;
8495 WMITLV_SET_HDR(&tspec_param->tlv_header,
8496 WMITLV_TAG_STRUC_wmi_ric_tspec,
8497 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
8498
8499 if (is_add_ts)
8500 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05308501#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05308502 else
8503 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05308504#endif
8505 if (ptspecIE) {
8506 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05308507#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05308508 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
8509 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308510#else
Govind Singh87542482016-06-08 19:40:11 +05308511 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
8512 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308513#endif /* ANI_LITTLE_BIT_ENDIAN */
8514
Govind Singh87542482016-06-08 19:40:11 +05308515 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
8516 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
8517 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
8518 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
8519 tspec_param->inactivity_interval = ptspecIE->inactInterval;
8520 tspec_param->suspension_interval = ptspecIE->suspendInterval;
8521 tspec_param->svc_start_time = ptspecIE->svcStartTime;
8522 tspec_param->min_data_rate = ptspecIE->minDataRate;
8523 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
8524 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
8525 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
8526 tspec_param->delay_bound = ptspecIE->delayBound;
8527 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
8528 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
8529 tspec_param->medium_time = 0;
8530 }
Govind Singhb53420c2016-03-09 14:32:57 +05308531 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308532
8533 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8534 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308535 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308536 __func__);
8537 if (is_add_ts)
8538 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05308539 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308540 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308541 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308542 }
8543
Govind Singhb53420c2016-03-09 14:32:57 +05308544 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308545}
8546
8547/**
8548 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
8549 * @wmi_handle: wmi handle
8550 * @clear_req: ll stats clear request command params
8551 *
Govind Singhb53420c2016-03-09 14:32:57 +05308552 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308553 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308554static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308555 const struct ll_stats_clear_params *clear_req,
8556 uint8_t addr[IEEE80211_ADDR_LEN])
8557{
8558 wmi_clear_link_stats_cmd_fixed_param *cmd;
8559 int32_t len;
8560 wmi_buf_t buf;
8561 uint8_t *buf_ptr;
8562 int ret;
8563
8564 len = sizeof(*cmd);
8565 buf = wmi_buf_alloc(wmi_handle, len);
8566
8567 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308568 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8569 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308570 }
8571
8572 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308573 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308574 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
8575
8576 WMITLV_SET_HDR(&cmd->tlv_header,
8577 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
8578 WMITLV_GET_STRUCT_TLVLEN
8579 (wmi_clear_link_stats_cmd_fixed_param));
8580
8581 cmd->stop_stats_collection_req = clear_req->stop_req;
8582 cmd->vdev_id = clear_req->sta_id;
8583 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
8584
8585 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8586 &cmd->peer_macaddr);
8587
Govind Singhb53420c2016-03-09 14:32:57 +05308588 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
8589 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
8590 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
8591 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
8592 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05308593 cmd->peer_macaddr); */
8594
8595 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8596 WMI_CLEAR_LINK_STATS_CMDID);
8597 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308598 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308599 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308600 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308601 }
8602
Govind Singhb53420c2016-03-09 14:32:57 +05308603 WMI_LOGD("Clear Link Layer Stats request sent successfully");
8604 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308605}
8606
8607/**
8608 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
8609 * @wmi_handle: wmi handle
8610 * @setReq: ll stats set request command params
8611 *
Govind Singhb53420c2016-03-09 14:32:57 +05308612 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308613 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308614static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308615 const struct ll_stats_set_params *set_req)
8616{
8617 wmi_start_link_stats_cmd_fixed_param *cmd;
8618 int32_t len;
8619 wmi_buf_t buf;
8620 uint8_t *buf_ptr;
8621 int ret;
8622
8623 len = sizeof(*cmd);
8624 buf = wmi_buf_alloc(wmi_handle, len);
8625
8626 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308627 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8628 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308629 }
8630
8631 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308632 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308633 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
8634
8635 WMITLV_SET_HDR(&cmd->tlv_header,
8636 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
8637 WMITLV_GET_STRUCT_TLVLEN
8638 (wmi_start_link_stats_cmd_fixed_param));
8639
8640 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
8641 cmd->aggressive_statistics_gathering =
8642 set_req->aggressive_statistics_gathering;
8643
Govind Singhb53420c2016-03-09 14:32:57 +05308644 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
8645 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
8646 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308647
8648 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8649 WMI_START_LINK_STATS_CMDID);
8650 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308651 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308652 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308653 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308654 }
8655
Govind Singhb53420c2016-03-09 14:32:57 +05308656 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308657}
8658
8659/**
8660 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
8661 * @wmi_handle:wmi handle
8662 * @get_req:ll stats get request command params
8663 * @addr: mac address
8664 *
Govind Singhb53420c2016-03-09 14:32:57 +05308665 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05308666 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308667static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05308668 const struct ll_stats_get_params *get_req,
8669 uint8_t addr[IEEE80211_ADDR_LEN])
8670{
8671 wmi_request_link_stats_cmd_fixed_param *cmd;
8672 int32_t len;
8673 wmi_buf_t buf;
8674 uint8_t *buf_ptr;
8675 int ret;
8676
8677 len = sizeof(*cmd);
8678 buf = wmi_buf_alloc(wmi_handle, len);
8679
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05308680 if (!buf) {
8681 WMI_LOGE("%s: buf allocation failed", __func__);
8682 return QDF_STATUS_E_NOMEM;
8683 }
8684
Govind Singh4eacd2b2016-03-07 14:24:22 +05308685 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308686 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308687 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
8688
8689 WMITLV_SET_HDR(&cmd->tlv_header,
8690 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
8691 WMITLV_GET_STRUCT_TLVLEN
8692 (wmi_request_link_stats_cmd_fixed_param));
8693
8694 cmd->request_id = get_req->req_id;
8695 cmd->stats_type = get_req->param_id_mask;
8696 cmd->vdev_id = get_req->sta_id;
8697
8698 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
8699 &cmd->peer_macaddr);
8700
Govind Singhb53420c2016-03-09 14:32:57 +05308701 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08008702 WMI_LOGD("Request ID : %u", cmd->request_id);
8703 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05308704 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
8705 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308706
8707 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8708 WMI_REQUEST_LINK_STATS_CMDID);
8709 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308710 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05308711 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308712 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308713 }
8714
Govind Singhb53420c2016-03-09 14:32:57 +05308715 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05308716}
8717
Govind Singh4eacd2b2016-03-07 14:24:22 +05308718
Govind Singh20c5dac2016-03-07 15:33:31 +05308719/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308720 * send_congestion_cmd_tlv() - send request to fw to get CCA
8721 * @wmi_handle: wmi handle
8722 * @vdev_id: vdev id
8723 *
8724 * Return: CDF status
8725 */
8726static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05308727 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05308728{
8729 wmi_buf_t buf;
8730 wmi_request_stats_cmd_fixed_param *cmd;
8731 uint8_t len;
8732 uint8_t *buf_ptr;
8733
8734 len = sizeof(*cmd);
8735 buf = wmi_buf_alloc(wmi_handle, len);
8736 if (!buf) {
8737 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
8738 return QDF_STATUS_E_FAILURE;
8739 }
8740
8741 buf_ptr = wmi_buf_data(buf);
8742 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
8743 WMITLV_SET_HDR(&cmd->tlv_header,
8744 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8745 WMITLV_GET_STRUCT_TLVLEN
8746 (wmi_request_stats_cmd_fixed_param));
8747
8748 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
8749 cmd->vdev_id = vdev_id;
8750 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
8751 cmd->vdev_id, cmd->stats_id);
8752
8753 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8754 WMI_REQUEST_STATS_CMDID)) {
8755 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
8756 __func__);
8757 wmi_buf_free(buf);
8758 return QDF_STATUS_E_FAILURE;
8759 }
8760
8761 return QDF_STATUS_SUCCESS;
8762}
8763
8764/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308765 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
8766 * @wmi_handle: wmi handle
8767 * @rssi_req: get RSSI request
8768 *
8769 * Return: CDF status
8770 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308771static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308772{
8773 wmi_buf_t buf;
8774 wmi_request_stats_cmd_fixed_param *cmd;
8775 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8776
8777 buf = wmi_buf_alloc(wmi_handle, len);
8778 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308779 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8780 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308781 }
8782
8783 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8784 WMITLV_SET_HDR(&cmd->tlv_header,
8785 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8786 WMITLV_GET_STRUCT_TLVLEN
8787 (wmi_request_stats_cmd_fixed_param));
8788 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8789 if (wmi_unified_cmd_send
8790 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308791 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308792 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308793 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308794 }
8795
Govind Singhb53420c2016-03-09 14:32:57 +05308796 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308797}
8798
8799/**
8800 * send_snr_cmd_tlv() - get RSSI from fw
8801 * @wmi_handle: wmi handle
8802 * @vdev_id: vdev id
8803 *
8804 * Return: CDF status
8805 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308806static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308807{
8808 wmi_buf_t buf;
8809 wmi_request_stats_cmd_fixed_param *cmd;
8810 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8811
8812 buf = wmi_buf_alloc(wmi_handle, len);
8813 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308814 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8815 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308816 }
8817
8818 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8819 cmd->vdev_id = vdev_id;
8820
8821 WMITLV_SET_HDR(&cmd->tlv_header,
8822 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8823 WMITLV_GET_STRUCT_TLVLEN
8824 (wmi_request_stats_cmd_fixed_param));
8825 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8826 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8827 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308828 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308829 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308830 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308831 }
8832
Govind Singhb53420c2016-03-09 14:32:57 +05308833 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308834}
8835
8836/**
8837 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8838 * @wmi_handle: wmi handle
8839 * @link_status: get link params
8840 *
8841 * Return: CDF status
8842 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308843static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308844 struct link_status_params *link_status)
8845{
8846 wmi_buf_t buf;
8847 wmi_request_stats_cmd_fixed_param *cmd;
8848 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8849
8850 buf = wmi_buf_alloc(wmi_handle, len);
8851 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308852 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8853 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308854 }
8855
8856 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8857 WMITLV_SET_HDR(&cmd->tlv_header,
8858 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8859 WMITLV_GET_STRUCT_TLVLEN
8860 (wmi_request_stats_cmd_fixed_param));
8861 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8862 cmd->vdev_id = link_status->session_id;
8863 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8864 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308865 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308866 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308867 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308868 }
8869
Govind Singhb53420c2016-03-09 14:32:57 +05308870 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308871}
8872
Govind Singh20c5dac2016-03-07 15:33:31 +05308873/**
8874 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8875 * @wmi_handle: wmi handle
8876 * @ta_dhcp_ind: DHCP indication parameter
8877 *
8878 * Return: CDF Status
8879 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308880static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308881 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8882{
Govind Singh67922e82016-04-01 16:48:57 +05308883 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308884 wmi_buf_t buf = NULL;
8885 uint8_t *buf_ptr;
8886 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8887 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8888
8889
8890 buf = wmi_buf_alloc(wmi_handle, len);
8891 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308892 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8893 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308894 }
8895
8896 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8897 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8898 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8899 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8900 WMITLV_GET_STRUCT_TLVLEN
8901 (wmi_peer_set_param_cmd_fixed_param));
8902
8903 /* fill in values */
8904 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8905 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8906 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308907 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308908 &ta_dhcp_ind->peer_macaddr,
8909 sizeof(ta_dhcp_ind->peer_macaddr));
8910
8911 status = wmi_unified_cmd_send(wmi_handle, buf,
8912 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308913 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308914 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308915 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308916 wmi_buf_free(buf);
8917 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308918
Govind Singh67922e82016-04-01 16:48:57 +05308919 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308920}
8921
8922/**
8923 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8924 * @wmi_handle: wmi handle
8925 * @pLinkSpeed: link speed info
8926 *
8927 * Return: CDF status
8928 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308929static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308930 wmi_mac_addr peer_macaddr)
8931{
8932 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8933 wmi_buf_t wmi_buf;
8934 uint32_t len;
8935 uint8_t *buf_ptr;
8936
8937 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8938 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8939 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308940 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8941 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308942 }
8943 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8944
8945 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8946 WMITLV_SET_HDR(&cmd->tlv_header,
8947 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8948 WMITLV_GET_STRUCT_TLVLEN
8949 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8950
8951 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308952 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308953 &peer_macaddr,
8954 sizeof(peer_macaddr));
8955
8956
8957 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8958 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308959 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308960 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308961 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308962 }
Govind Singhb53420c2016-03-09 14:32:57 +05308963 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308964}
8965
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308966#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308967/**
8968 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8969 * @wmi_handle: wmi handler
8970 * @egap_params: pointer to egap_params
8971 *
8972 * Return: 0 for success, otherwise appropriate error code
8973 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308974static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308975 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308976{
8977 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8978 wmi_buf_t buf;
8979 int32_t err;
8980
8981 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8982 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308983 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8984 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308985 }
8986 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8987 WMITLV_SET_HDR(&cmd->tlv_header,
8988 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8989 WMITLV_GET_STRUCT_TLVLEN(
8990 wmi_ap_ps_egap_param_cmd_fixed_param));
8991
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308992 cmd->enable = egap_params->host_enable_egap;
8993 cmd->inactivity_time = egap_params->egap_inactivity_time;
8994 cmd->wait_time = egap_params->egap_wait_time;
8995 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308996 err = wmi_unified_cmd_send(wmi_handle, buf,
8997 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8998 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308999 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309000 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309001 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309002 }
9003
Govind Singhb53420c2016-03-09 14:32:57 +05309004 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309005}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05309006#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05309007
9008/**
9009 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
9010 * @wmi_handl: wmi handle
9011 * @cmd: Profiling command index
9012 * @value1: parameter1 value
9013 * @value2: parameter2 value
9014 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309015 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309016 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309017static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309018 uint32_t cmd, uint32_t value1, uint32_t value2)
9019{
9020 wmi_buf_t buf;
9021 int32_t len = 0;
9022 int ret;
9023 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
9024 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
9025 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
9026 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
9027
9028 switch (cmd) {
9029 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
9030 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
9031 buf = wmi_buf_alloc(wmi_handle, len);
9032 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309033 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309034 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309035 }
9036 prof_trig_cmd =
9037 (wmi_wlan_profile_trigger_cmd_fixed_param *)
9038 wmi_buf_data(buf);
9039 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
9040 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
9041 WMITLV_GET_STRUCT_TLVLEN
9042 (wmi_wlan_profile_trigger_cmd_fixed_param));
9043 prof_trig_cmd->enable = value1;
9044 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9045 WMI_WLAN_PROFILE_TRIGGER_CMDID);
9046 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309047 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309048 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309049 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309050 return ret;
9051 }
9052 break;
9053
9054 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
9055 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
9056 buf = wmi_buf_alloc(wmi_handle, len);
9057 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309058 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309059 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309060 }
9061 profile_getdata_cmd =
9062 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
9063 wmi_buf_data(buf);
9064 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
9065 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
9066 WMITLV_GET_STRUCT_TLVLEN
9067 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
9068 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9069 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
9070 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309071 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309072 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309073 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309074 return ret;
9075 }
9076 break;
9077
9078 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
9079 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
9080 buf = wmi_buf_alloc(wmi_handle, len);
9081 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309082 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309083 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309084 }
9085 hist_intvl_cmd =
9086 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
9087 wmi_buf_data(buf);
9088 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
9089 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
9090 WMITLV_GET_STRUCT_TLVLEN
9091 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
9092 hist_intvl_cmd->profile_id = value1;
9093 hist_intvl_cmd->value = value2;
9094 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9095 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
9096 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309097 WMI_LOGE("HIST_INTVL 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_ENABLE_PROFILE_ID_CMDID:
9105 len =
9106 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
9107 buf = wmi_buf_alloc(wmi_handle, len);
9108 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309109 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309110 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309111 }
9112 profile_enable_cmd =
9113 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
9114 wmi_buf_data(buf);
9115 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
9116 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
9117 WMITLV_GET_STRUCT_TLVLEN
9118 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
9119 profile_enable_cmd->profile_id = value1;
9120 profile_enable_cmd->enable = value2;
9121 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9122 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
9123 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309124 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309125 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309126 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309127 return ret;
9128 }
9129 break;
9130
9131 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309132 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309133 break;
9134 }
9135
9136 return 0;
9137}
9138
Paul Zhang92ab8d32017-12-08 16:08:00 +08009139static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
9140 struct wlm_latency_level_param *params)
9141{
9142 wmi_wlm_config_cmd_fixed_param *cmd;
9143 wmi_buf_t buf;
9144 uint32_t len = sizeof(*cmd);
9145 static uint32_t ll[4] = {100, 60, 40, 20};
9146
9147 buf = wmi_buf_alloc(wmi_handle, len);
9148 if (!buf) {
9149 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9150 return QDF_STATUS_E_NOMEM;
9151 }
9152 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
9153 WMITLV_SET_HDR(&cmd->tlv_header,
9154 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
9155 WMITLV_GET_STRUCT_TLVLEN
9156 (wmi_wlm_config_cmd_fixed_param));
9157 cmd->vdev_id = params->vdev_id;
9158 cmd->latency_level = params->wlm_latency_level;
9159 cmd->ul_latency = ll[params->wlm_latency_level];
9160 cmd->dl_latency = ll[params->wlm_latency_level];
9161 cmd->flags = params->wlm_latency_flags;
9162 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9163 WMI_WLM_CONFIG_CMDID)) {
9164 WMI_LOGE("%s: Failed to send setting latency config command",
9165 __func__);
9166 wmi_buf_free(buf);
9167 return QDF_STATUS_E_FAILURE;
9168 }
9169
9170 return 0;
9171}
Govind Singh20c5dac2016-03-07 15:33:31 +05309172/**
9173 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
9174 * @wmi_handle: wmi handle
9175 * @vdev_id: vdev id
9176 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309177 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309178 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309179static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309180{
9181 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
9182 wmi_buf_t buf;
9183 int32_t len = sizeof(*cmd);
9184
Govind Singhb53420c2016-03-09 14:32:57 +05309185 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309186 buf = wmi_buf_alloc(wmi_handle, len);
9187 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309188 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309189 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309190 }
9191 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
9192 wmi_buf_data(buf);
9193 WMITLV_SET_HDR(&cmd->tlv_header,
9194 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
9195 WMITLV_GET_STRUCT_TLVLEN
9196 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
9197 cmd->vdev_id = vdev_id;
9198 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
9199 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9200 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309201 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309202 __func__);
9203 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309204 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309205 }
9206
9207 return 0;
9208}
9209
9210/**
9211 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
9212 * @wmi_handle: wmi handle
9213 * @vdev_id: vdev id
9214 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309215 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309216 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309217static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309218 uint8_t vdev_id)
9219{
9220 wmi_csa_offload_enable_cmd_fixed_param *cmd;
9221 wmi_buf_t buf;
9222 int32_t len = sizeof(*cmd);
9223
Govind Singhb53420c2016-03-09 14:32:57 +05309224 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309225 buf = wmi_buf_alloc(wmi_handle, len);
9226 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309227 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309228 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309229 }
9230 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
9231 WMITLV_SET_HDR(&cmd->tlv_header,
9232 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
9233 WMITLV_GET_STRUCT_TLVLEN
9234 (wmi_csa_offload_enable_cmd_fixed_param));
9235 cmd->vdev_id = vdev_id;
9236 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
9237 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9238 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309239 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309240 __func__);
9241 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309242 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309243 }
9244
9245 return 0;
9246}
9247
Naveen Rawat42cd1e62017-05-13 15:56:57 -07009248#ifdef WLAN_FEATURE_CIF_CFR
9249/**
9250 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
9251 * @wmi_handle: wmi handle
9252 * @data_len: len of dma cfg req
9253 * @data: dma cfg req
9254 *
9255 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9256 */
9257static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9258 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
9259{
9260 wmi_buf_t buf;
9261 uint8_t *cmd;
9262 QDF_STATUS ret;
9263
9264 WMITLV_SET_HDR(cfg,
9265 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
9266 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
9267
9268 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
9269 if (!buf) {
9270 WMI_LOGE(FL("wmi_buf_alloc failed"));
9271 return QDF_STATUS_E_FAILURE;
9272 }
9273
9274 cmd = (uint8_t *) wmi_buf_data(buf);
9275 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
9276 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
9277 sizeof(*cfg));
9278 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
9279 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
9280 if (QDF_IS_STATUS_ERROR(ret)) {
9281 WMI_LOGE(FL(":wmi cmd send failed"));
9282 wmi_buf_free(buf);
9283 }
9284
9285 return ret;
9286}
9287#endif
9288
Govind Singh20c5dac2016-03-07 15:33:31 +05309289/**
Sathish Kumarf396c722017-11-17 17:30:41 +05309290 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
9291 * @wmi_handle: wmi handle
9292 * @data_len: len of dma cfg req
9293 * @data: dma cfg req
9294 *
9295 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
9296 */
9297static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
9298 struct direct_buf_rx_cfg_req *cfg)
9299{
9300 wmi_buf_t buf;
9301 wmi_dma_ring_cfg_req_fixed_param *cmd;
9302 QDF_STATUS ret;
9303 int32_t len = sizeof(*cmd);
9304
9305 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9306 if (!buf) {
9307 WMI_LOGE(FL("wmi_buf_alloc failed"));
9308 return QDF_STATUS_E_FAILURE;
9309 }
9310
9311 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
9312
9313 WMITLV_SET_HDR(&cmd->tlv_header,
9314 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
9315 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
9316
9317 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9318 cfg->pdev_id);
9319 cmd->mod_id = cfg->mod_id;
9320 cmd->base_paddr_lo = cfg->base_paddr_lo;
9321 cmd->base_paddr_hi = cfg->base_paddr_hi;
9322 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
9323 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
9324 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
9325 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
9326 cmd->num_elems = cfg->num_elems;
9327 cmd->buf_size = cfg->buf_size;
9328 cmd->num_resp_per_event = cfg->num_resp_per_event;
9329 cmd->event_timeout_ms = cfg->event_timeout_ms;
9330
9331 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
9332 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
9333 "head idx paddr hi %x tail idx paddr lo %x"
9334 "tail idx addr hi %x num elems %d buf size %d num resp %d"
9335 "event timeout %d\n", __func__, cmd->pdev_id,
9336 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
9337 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
9338 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
9339 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
9340 cmd->event_timeout_ms);
9341 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9342 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
9343 if (QDF_IS_STATUS_ERROR(ret)) {
9344 WMI_LOGE(FL(":wmi cmd send failed"));
9345 wmi_buf_free(buf);
9346 }
9347
9348 return ret;
9349}
9350
9351/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009352 * send_start_11d_scan_cmd_tlv() - start 11d scan request
9353 * @wmi_handle: wmi handle
9354 * @start_11d_scan: 11d scan start request parameters
9355 *
9356 * This function request FW to start 11d scan.
9357 *
9358 * Return: QDF status
9359 */
9360static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9361 struct reg_start_11d_scan_req *start_11d_scan)
9362{
9363 wmi_11d_scan_start_cmd_fixed_param *cmd;
9364 int32_t len;
9365 wmi_buf_t buf;
9366 int ret;
9367
9368 len = sizeof(*cmd);
9369 buf = wmi_buf_alloc(wmi_handle, len);
9370 if (!buf) {
9371 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9372 return QDF_STATUS_E_NOMEM;
9373 }
9374
9375 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
9376
9377 WMITLV_SET_HDR(&cmd->tlv_header,
9378 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
9379 WMITLV_GET_STRUCT_TLVLEN
9380 (wmi_11d_scan_start_cmd_fixed_param));
9381
9382 cmd->vdev_id = start_11d_scan->vdev_id;
9383 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
9384 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
9385
9386 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
9387
9388 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9389 WMI_11D_SCAN_START_CMDID);
9390 if (ret) {
9391 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
9392 wmi_buf_free(buf);
9393 return QDF_STATUS_E_FAILURE;
9394 }
9395
9396 return QDF_STATUS_SUCCESS;
9397}
9398
9399/**
9400 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
9401 * @wmi_handle: wmi handle
9402 * @start_11d_scan: 11d scan stop request parameters
9403 *
9404 * This function request FW to stop 11d scan.
9405 *
9406 * Return: QDF status
9407 */
9408static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
9409 struct reg_stop_11d_scan_req *stop_11d_scan)
9410{
9411 wmi_11d_scan_stop_cmd_fixed_param *cmd;
9412 int32_t len;
9413 wmi_buf_t buf;
9414 int ret;
9415
9416 len = sizeof(*cmd);
9417 buf = wmi_buf_alloc(wmi_handle, len);
9418 if (!buf) {
9419 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9420 return QDF_STATUS_E_NOMEM;
9421 }
9422
9423 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
9424
9425 WMITLV_SET_HDR(&cmd->tlv_header,
9426 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
9427 WMITLV_GET_STRUCT_TLVLEN
9428 (wmi_11d_scan_stop_cmd_fixed_param));
9429
9430 cmd->vdev_id = stop_11d_scan->vdev_id;
9431
9432 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
9433
9434 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9435 WMI_11D_SCAN_STOP_CMDID);
9436 if (ret) {
9437 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
9438 wmi_buf_free(buf);
9439 return QDF_STATUS_E_FAILURE;
9440 }
9441
9442 return QDF_STATUS_SUCCESS;
9443}
9444
9445/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309446 * send_start_oem_data_cmd_tlv() - start OEM data request to target
9447 * @wmi_handle: wmi handle
9448 * @startOemDataReq: start request params
9449 *
9450 * Return: CDF status
9451 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309452static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07009453 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05309454 uint8_t *data)
9455{
9456 wmi_buf_t buf;
9457 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309458 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309459
9460 buf = wmi_buf_alloc(wmi_handle,
9461 (data_len + WMI_TLV_HDR_SIZE));
9462 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309463 WMI_LOGE(FL("wmi_buf_alloc failed"));
9464 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309465 }
9466
9467 cmd = (uint8_t *) wmi_buf_data(buf);
9468
9469 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
9470 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309471 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05309472 data_len);
9473
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08009474 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309475 data_len);
9476
9477 ret = wmi_unified_cmd_send(wmi_handle, buf,
9478 (data_len +
9479 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
9480
Govind Singh67922e82016-04-01 16:48:57 +05309481 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309482 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309483 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309484 }
9485
Govind Singh67922e82016-04-01 16:48:57 +05309486 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309487}
9488
9489/**
9490 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
9491 * @wmi_handle: wmi handle
9492 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
9493 *
9494 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
9495 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
9496 * to firmware based on phyerr filtering
9497 * offload status.
9498 *
9499 * Return: 1 success, 0 failure
9500 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309501static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05309502send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
9503 bool dfs_phyerr_filter_offload)
9504{
9505 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
9506 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
9507 wmi_buf_t buf;
9508 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05309509 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309510
9511
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07009512 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05309513 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309514 __func__);
9515 len = sizeof(*disable_phyerr_offload_cmd);
9516 buf = wmi_buf_alloc(wmi_handle, len);
9517 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309518 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309519 return 0;
9520 }
9521 disable_phyerr_offload_cmd =
9522 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
9523 wmi_buf_data(buf);
9524
9525 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
9526 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
9527 WMITLV_GET_STRUCT_TLVLEN
9528 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
9529
9530 /*
9531 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
9532 * to the firmware to disable the phyerror
9533 * filtering offload.
9534 */
9535 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9536 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309537 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309538 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309539 __func__, ret);
9540 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309541 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309542 }
Govind Singhb53420c2016-03-09 14:32:57 +05309543 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309544 __func__);
9545 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05309546 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05309547 __func__);
9548
9549 len = sizeof(*enable_phyerr_offload_cmd);
9550 buf = wmi_buf_alloc(wmi_handle, len);
9551 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309552 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9553 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309554 }
9555
9556 enable_phyerr_offload_cmd =
9557 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
9558 wmi_buf_data(buf);
9559
9560 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
9561 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
9562 WMITLV_GET_STRUCT_TLVLEN
9563 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
9564
9565 /*
9566 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
9567 * to the firmware to enable the phyerror
9568 * filtering offload.
9569 */
9570 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9571 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
9572
Govind Singh67922e82016-04-01 16:48:57 +05309573 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309574 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309575 __func__, ret);
9576 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309577 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309578 }
Govind Singhb53420c2016-03-09 14:32:57 +05309579 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05309580 __func__);
9581 }
9582
Govind Singhb53420c2016-03-09 14:32:57 +05309583 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309584}
9585
Naveen Rawata5817e72017-10-26 18:50:19 -07009586/**
9587 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
9588 * will wake up host after specified time is elapsed
9589 * @wmi_handle: wmi handle
9590 * @vdev_id: vdev id
9591 * @cookie: value to identify reason why host set up wake call.
9592 * @time: time in ms
9593 *
9594 * Return: QDF status
9595 */
9596static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9597 uint8_t vdev_id, uint32_t cookie, uint32_t time)
9598{
9599 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
9600 wmi_buf_t buf;
9601 uint8_t *buf_ptr;
9602 int32_t len;
9603 int ret;
9604
9605 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
9606 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
9607 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
9608 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
9609 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05309610 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
9611 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07009612
9613 buf = wmi_buf_alloc(wmi_handle, len);
9614 if (!buf) {
9615 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9616 return QDF_STATUS_E_NOMEM;
9617 }
9618
9619 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9620 buf_ptr = (uint8_t *) cmd;
9621
9622 WMITLV_SET_HDR(&cmd->tlv_header,
9623 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
9624 WMITLV_GET_STRUCT_TLVLEN
9625 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
9626 cmd->vdev_id = vdev_id;
9627 cmd->pattern_id = cookie,
9628 cmd->pattern_type = WOW_TIMER_PATTERN;
9629 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
9630
9631 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
9632 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9633 buf_ptr += WMI_TLV_HDR_SIZE;
9634
9635 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
9636 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9637 buf_ptr += WMI_TLV_HDR_SIZE;
9638
9639 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
9640 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9641 buf_ptr += WMI_TLV_HDR_SIZE;
9642
9643 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
9644 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
9645 buf_ptr += WMI_TLV_HDR_SIZE;
9646
9647 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05309648 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07009649 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05309650 *((uint32_t *) buf_ptr) = time;
9651 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07009652
9653 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05309654 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07009655 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05309656 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07009657
9658 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
9659 __func__, time, vdev_id);
9660
9661 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9662 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
9663 if (ret) {
9664 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
9665 __func__);
9666 wmi_buf_free(buf);
9667 return QDF_STATUS_E_FAILURE;
9668 }
9669
9670 return QDF_STATUS_SUCCESS;
9671}
9672
Govind Singh20c5dac2016-03-07 15:33:31 +05309673#if !defined(REMOVE_PKT_LOG)
9674/**
9675 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
9676 * @wmi_handle: wmi handle
9677 * @pktlog_event: pktlog event
9678 * @cmd_id: pktlog cmd id
9679 *
9680 * Return: CDF status
9681 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309682static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309683 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05309684 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05309685{
9686 WMI_PKTLOG_EVENT PKTLOG_EVENT;
9687 WMI_CMD_ID CMD_ID;
9688 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
9689 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
9690 int len = 0;
9691 wmi_buf_t buf;
9692
9693 PKTLOG_EVENT = pktlog_event;
9694 CMD_ID = cmd_id;
9695
9696 switch (CMD_ID) {
9697 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
9698 len = sizeof(*cmd);
9699 buf = wmi_buf_alloc(wmi_handle, len);
9700 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309701 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9702 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309703 }
9704 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
9705 wmi_buf_data(buf);
9706 WMITLV_SET_HDR(&cmd->tlv_header,
9707 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
9708 WMITLV_GET_STRUCT_TLVLEN
9709 (wmi_pdev_pktlog_enable_cmd_fixed_param));
9710 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05309711 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
9712 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309713 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9714 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309715 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9716 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309717 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309718 goto wmi_send_failed;
9719 }
9720 break;
9721 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
9722 len = sizeof(*disable_cmd);
9723 buf = wmi_buf_alloc(wmi_handle, len);
9724 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309725 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9726 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309727 }
9728 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
9729 wmi_buf_data(buf);
9730 WMITLV_SET_HDR(&disable_cmd->tlv_header,
9731 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
9732 WMITLV_GET_STRUCT_TLVLEN
9733 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309734 disable_cmd->pdev_id =
9735 wmi_handle->ops->convert_pdev_id_host_to_target(
9736 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05309737 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9738 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309739 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05309740 goto wmi_send_failed;
9741 }
9742 break;
9743 default:
Govind Singhb53420c2016-03-09 14:32:57 +05309744 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309745 break;
9746 }
9747
Govind Singhb53420c2016-03-09 14:32:57 +05309748 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309749
9750wmi_send_failed:
9751 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309752 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309753}
9754#endif /* REMOVE_PKT_LOG */
9755
9756/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309757 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
9758 * @wmi_handle: wmi handle
9759 * @ptrn_id: pattern id
9760 * @vdev_id: vdev id
9761 *
9762 * Return: CDF status
9763 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05309764static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
9765 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05309766{
9767 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
9768 wmi_buf_t buf;
9769 int32_t len;
9770 int ret;
9771
9772 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
9773
9774
9775 buf = wmi_buf_alloc(wmi_handle, len);
9776 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309777 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9778 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309779 }
9780
9781 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
9782
9783 WMITLV_SET_HDR(&cmd->tlv_header,
9784 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
9785 WMITLV_GET_STRUCT_TLVLEN(
9786 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
9787 cmd->vdev_id = vdev_id;
9788 cmd->pattern_id = ptrn_id;
9789 cmd->pattern_type = WOW_BITMAP_PATTERN;
9790
Govind Singhb53420c2016-03-09 14:32:57 +05309791 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05309792 cmd->pattern_id, vdev_id);
9793
9794 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9795 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
9796 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309797 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309798 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309799 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309800 }
9801
Govind Singhb53420c2016-03-09 14:32:57 +05309802 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309803}
9804
9805/**
9806 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
9807 * @wmi_handle: wmi handle
9808 *
9809 * Sends host wakeup indication to FW. On receiving this indication,
9810 * FW will come out of WOW.
9811 *
9812 * Return: CDF status
9813 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309814static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309815{
9816 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
9817 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05309818 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309819 int32_t len;
9820 int ret;
9821
9822 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
9823
9824 buf = wmi_buf_alloc(wmi_handle, len);
9825 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309826 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9827 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309828 }
9829
9830 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9831 wmi_buf_data(buf);
9832 WMITLV_SET_HDR(&cmd->tlv_header,
9833 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9834 WMITLV_GET_STRUCT_TLVLEN
9835 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9836
9837
9838 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9839 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9840 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309841 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309842 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309843 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309844 }
9845
Govind Singhb53420c2016-03-09 14:32:57 +05309846 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309847}
9848
9849/**
9850 * send_del_ts_cmd_tlv() - send DELTS request to fw
9851 * @wmi_handle: wmi handle
9852 * @msg: delts params
9853 *
9854 * Return: CDF status
9855 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309856static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309857 uint8_t ac)
9858{
9859 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9860 wmi_buf_t buf;
9861 int32_t len = sizeof(*cmd);
9862
9863 buf = wmi_buf_alloc(wmi_handle, len);
9864 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309865 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9866 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309867 }
9868 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9869 WMITLV_SET_HDR(&cmd->tlv_header,
9870 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9871 WMITLV_GET_STRUCT_TLVLEN
9872 (wmi_vdev_wmm_delts_cmd_fixed_param));
9873 cmd->vdev_id = vdev_id;
9874 cmd->ac = ac;
9875
Govind Singhb53420c2016-03-09 14:32:57 +05309876 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309877 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9878 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9879 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309880 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309881 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309882 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309883 }
9884
Govind Singhb53420c2016-03-09 14:32:57 +05309885 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309886}
9887
9888/**
9889 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9890 * @wmi_handle: handle to wmi
9891 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9892 *
Govind Singhb53420c2016-03-09 14:32:57 +05309893 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309894 * ADD_TS requestes to firmware in loop for all the ACs with
9895 * active flow.
9896 *
9897 * Return: CDF status
9898 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309899static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309900 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9901{
9902 int i = 0;
9903 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9904 wmi_buf_t buf;
9905 int32_t len = sizeof(*cmd);
9906
9907 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9908 /* if flow in this AC is active */
9909 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9910 /*
9911 * as per implementation of wma_add_ts_req() we
9912 * are not waiting any response from firmware so
9913 * apart from sending ADDTS to firmware just send
9914 * success to upper layers
9915 */
Govind Singhb53420c2016-03-09 14:32:57 +05309916 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309917
9918 buf = wmi_buf_alloc(wmi_handle, len);
9919 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309920 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9921 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309922 }
9923 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9924 wmi_buf_data(buf);
9925 WMITLV_SET_HDR(&cmd->tlv_header,
9926 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9927 WMITLV_GET_STRUCT_TLVLEN
9928 (wmi_vdev_wmm_addts_cmd_fixed_param));
9929 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9930 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309931 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309932 traffic.userPrio);
9933 cmd->medium_time_us =
9934 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9935 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309936 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309937 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9938 cmd->medium_time_us, cmd->downgrade_type);
9939 if (wmi_unified_cmd_send
9940 (wmi_handle, buf, len,
9941 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309942 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309943 __func__);
9944 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309945 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309946 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309947 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309948 }
9949 }
9950 }
9951
Govind Singhb53420c2016-03-09 14:32:57 +05309952 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309953}
9954
9955/**
9956 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9957 * @wmi_handle: wmi handle
9958 * @msg: ADDTS params
9959 *
9960 * Return: CDF status
9961 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309962static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309963 struct add_ts_param *msg)
9964{
9965 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9966 wmi_buf_t buf;
9967 int32_t len = sizeof(*cmd);
9968
Govind Singhb53420c2016-03-09 14:32:57 +05309969 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309970
9971 buf = wmi_buf_alloc(wmi_handle, len);
9972 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309973 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9974 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309975 }
9976 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9977 WMITLV_SET_HDR(&cmd->tlv_header,
9978 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9979 WMITLV_GET_STRUCT_TLVLEN
9980 (wmi_vdev_wmm_addts_cmd_fixed_param));
9981 cmd->vdev_id = msg->sme_session_id;
9982 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9983 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9984 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309985 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309986 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9987 cmd->downgrade_type, __func__, __LINE__);
9988 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9989 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309990 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9991 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309992 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309993 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309994 }
9995
Govind Singhb53420c2016-03-09 14:32:57 +05309996 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309997}
9998
9999/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010000 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
10001 * @wmi_handle: wmi handle
10002 * @pAddPeriodicTxPtrnParams: tx ptrn params
10003 *
10004 * Retrun: CDF status
10005 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010006static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010007 struct periodic_tx_pattern *
10008 pAddPeriodicTxPtrnParams,
10009 uint8_t vdev_id)
10010{
10011 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10012 wmi_buf_t wmi_buf;
10013 uint32_t len;
10014 uint8_t *buf_ptr;
10015 uint32_t ptrn_len, ptrn_len_aligned;
10016 int j;
10017
10018 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
10019 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
10020 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
10021 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
10022
10023 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10024 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010025 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10026 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010027 }
10028
10029 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10030
10031 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
10032 WMITLV_SET_HDR(&cmd->tlv_header,
10033 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10034 WMITLV_GET_STRUCT_TLVLEN
10035 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10036
10037 /* Pass the pattern id to delete for the corresponding vdev id */
10038 cmd->vdev_id = vdev_id;
10039 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
10040 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
10041 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
10042
10043 /* Pattern info */
10044 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10045 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
10046 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010047 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010048 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +053010049 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +053010050
Govind Singhb53420c2016-03-09 14:32:57 +053010051 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010052 __func__, cmd->pattern_id, cmd->vdev_id);
10053
10054 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10055 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010056 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010057 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010058 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010059 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010060 }
Govind Singhb53420c2016-03-09 14:32:57 +053010061 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010062}
10063
10064/**
10065 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
10066 * @wmi_handle: wmi handle
10067 * @vdev_id: vdev id
10068 * @pattern_id: pattern id
10069 *
10070 * Retrun: CDF status
10071 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010072static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010073 uint8_t vdev_id,
10074 uint8_t pattern_id)
10075{
10076 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
10077 wmi_buf_t wmi_buf;
10078 uint32_t len =
10079 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
10080
10081 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10082 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010083 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10084 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010085 }
10086
10087 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
10088 wmi_buf_data(wmi_buf);
10089 WMITLV_SET_HDR(&cmd->tlv_header,
10090 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
10091 WMITLV_GET_STRUCT_TLVLEN
10092 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
10093
10094 /* Pass the pattern id to delete for the corresponding vdev id */
10095 cmd->vdev_id = vdev_id;
10096 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +053010097 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010098 __func__, cmd->pattern_id, cmd->vdev_id);
10099
10100 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10101 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010102 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010103 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010104 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010105 }
Govind Singhb53420c2016-03-09 14:32:57 +053010106 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010107}
10108
10109/**
10110 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
10111 * @wmi_handle: wmi handle
10112 * @preq: stats ext params
10113 *
10114 * Return: CDF status
10115 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010116static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010117 struct stats_ext_params *preq)
10118{
Govind Singh67922e82016-04-01 16:48:57 +053010119 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010120 wmi_req_stats_ext_cmd_fixed_param *cmd;
10121 wmi_buf_t buf;
10122 uint16_t len;
10123 uint8_t *buf_ptr;
10124
10125 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
10126
10127 buf = wmi_buf_alloc(wmi_handle, len);
10128 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010129 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010130 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010131 }
10132
10133 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10134 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
10135
10136 WMITLV_SET_HDR(&cmd->tlv_header,
10137 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
10138 WMITLV_GET_STRUCT_TLVLEN
10139 (wmi_req_stats_ext_cmd_fixed_param));
10140 cmd->vdev_id = preq->vdev_id;
10141 cmd->data_len = preq->request_data_len;
10142
Govind Singhb53420c2016-03-09 14:32:57 +053010143 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +053010144 __func__, preq->request_data_len, preq->vdev_id);
10145
10146 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
10147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
10148
10149 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010150 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010151
10152 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10153 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010154 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010155 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +053010156 ret);
10157 wmi_buf_free(buf);
10158 }
10159
10160 return ret;
10161}
10162
10163/**
10164 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
10165 * @wmi_handle: wmi handle
10166 * @params: ext wow params
10167 *
10168 * Return:0 for success or error code
10169 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010170static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010171 struct ext_wow_params *params)
10172{
10173 wmi_extwow_enable_cmd_fixed_param *cmd;
10174 wmi_buf_t buf;
10175 int32_t len;
10176 int ret;
10177
10178 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
10179 buf = wmi_buf_alloc(wmi_handle, len);
10180 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010181 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10182 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010183 }
10184
10185 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
10186
10187 WMITLV_SET_HDR(&cmd->tlv_header,
10188 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
10189 WMITLV_GET_STRUCT_TLVLEN
10190 (wmi_extwow_enable_cmd_fixed_param));
10191
10192 cmd->vdev_id = params->vdev_id;
10193 cmd->type = params->type;
10194 cmd->wakeup_pin_num = params->wakeup_pin_num;
10195
Govind Singhb53420c2016-03-09 14:32:57 +053010196 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +053010197 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
10198
10199 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10200 WMI_EXTWOW_ENABLE_CMDID);
10201 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010202 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010203 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010204 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010205 }
10206
Govind Singhb53420c2016-03-09 14:32:57 +053010207 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010208
10209}
10210
10211/**
10212 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
10213 * @wmi_handle: wmi handle
10214 * @app_type1_params: app type1 params
10215 *
10216 * Return: CDF status
10217 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010218static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010219 struct app_type1_params *app_type1_params)
10220{
10221 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
10222 wmi_buf_t buf;
10223 int32_t len;
10224 int ret;
10225
10226 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
10227 buf = wmi_buf_alloc(wmi_handle, len);
10228 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010229 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10230 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010231 }
10232
10233 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
10234 wmi_buf_data(buf);
10235
10236 WMITLV_SET_HDR(&cmd->tlv_header,
10237 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
10238 WMITLV_GET_STRUCT_TLVLEN
10239 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
10240
10241 cmd->vdev_id = app_type1_params->vdev_id;
10242 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
10243 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +053010244 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +053010245 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +053010246 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010247 cmd->passwd_len = app_type1_params->pass_length;
10248
Govind Singhb53420c2016-03-09 14:32:57 +053010249 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010250 "identification_id %.8s id_length %u "
10251 "password %.16s pass_length %u",
10252 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
10253 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
10254
10255 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10256 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
10257 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010258 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010259 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010260 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010261 }
10262
Govind Singhb53420c2016-03-09 14:32:57 +053010263 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010264}
10265
10266/**
10267 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
10268 * @wmi_handle: wmi handle
10269 * @appType2Params: app type2 params
10270 *
10271 * Return: CDF status
10272 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010273static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010274 struct app_type2_params *appType2Params)
10275{
10276 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
10277 wmi_buf_t buf;
10278 int32_t len;
10279 int ret;
10280
10281 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
10282 buf = wmi_buf_alloc(wmi_handle, len);
10283 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010284 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10285 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010286 }
10287
10288 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
10289 wmi_buf_data(buf);
10290
10291 WMITLV_SET_HDR(&cmd->tlv_header,
10292 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
10293 WMITLV_GET_STRUCT_TLVLEN
10294 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
10295
10296 cmd->vdev_id = appType2Params->vdev_id;
10297
Govind Singhb53420c2016-03-09 14:32:57 +053010298 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +053010299 cmd->rc4_key_len = appType2Params->rc4_key_len;
10300
10301 cmd->ip_id = appType2Params->ip_id;
10302 cmd->ip_device_ip = appType2Params->ip_device_ip;
10303 cmd->ip_server_ip = appType2Params->ip_server_ip;
10304
10305 cmd->tcp_src_port = appType2Params->tcp_src_port;
10306 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
10307 cmd->tcp_seq = appType2Params->tcp_seq;
10308 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
10309
10310 cmd->keepalive_init = appType2Params->keepalive_init;
10311 cmd->keepalive_min = appType2Params->keepalive_min;
10312 cmd->keepalive_max = appType2Params->keepalive_max;
10313 cmd->keepalive_inc = appType2Params->keepalive_inc;
10314
10315 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
10316 &cmd->gateway_mac);
10317 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
10318 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
10319
Govind Singhb53420c2016-03-09 14:32:57 +053010320 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +053010321 "rc4_key %.16s rc4_key_len %u "
10322 "ip_id %x ip_device_ip %x ip_server_ip %x "
10323 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
10324 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
10325 "keepalive_max %u keepalive_inc %u "
10326 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
10327 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
10328 cmd->rc4_key, cmd->rc4_key_len,
10329 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
10330 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
10331 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
10332 cmd->keepalive_max, cmd->keepalive_inc,
10333 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
10334
10335 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10336 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
10337 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010338 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +053010339 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010340 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010341 }
10342
Govind Singhb53420c2016-03-09 14:32:57 +053010343 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010344
10345}
10346
10347/**
10348 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
10349 * @wmi_handle: wmi handle
10350 * @timer_val: auto shutdown timer value
10351 *
10352 * Return: CDF status
10353 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010354static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010355 uint32_t timer_val)
10356{
Govind Singh67922e82016-04-01 16:48:57 +053010357 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010358 wmi_buf_t buf = NULL;
10359 uint8_t *buf_ptr;
10360 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
10361 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
10362
Govind Singhb53420c2016-03-09 14:32:57 +053010363 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010364 __func__, timer_val);
10365
10366 buf = wmi_buf_alloc(wmi_handle, len);
10367 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010368 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10369 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010370 }
10371
10372 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10373 wmi_auto_sh_cmd =
10374 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
10375 wmi_auto_sh_cmd->timer_value = timer_val;
10376
10377 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
10378 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
10379 WMITLV_GET_STRUCT_TLVLEN
10380 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
10381
10382 status = wmi_unified_cmd_send(wmi_handle, buf,
10383 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010384 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010385 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010386 __func__, status);
10387 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010388 }
10389
Govind Singh67922e82016-04-01 16:48:57 +053010390 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010391}
10392
10393/**
10394 * send_nan_req_cmd_tlv() - to send nan request to target
10395 * @wmi_handle: wmi handle
10396 * @nan_req: request data which will be non-null
10397 *
10398 * Return: CDF status
10399 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010400static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010401 struct nan_req_params *nan_req)
10402{
Govind Singh67922e82016-04-01 16:48:57 +053010403 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010404 wmi_nan_cmd_param *cmd;
10405 wmi_buf_t buf;
10406 uint16_t len = sizeof(*cmd);
10407 uint16_t nan_data_len, nan_data_len_aligned;
10408 uint8_t *buf_ptr;
10409
10410 /*
10411 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
10412 * +------------+----------+-----------------------+--------------+
10413 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
10414 * +------------+----------+-----------------------+--------------+
10415 */
10416 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +053010417 WMI_LOGE("%s:nan req is not valid", __func__);
10418 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010419 }
10420 nan_data_len = nan_req->request_data_len;
10421 nan_data_len_aligned = roundup(nan_req->request_data_len,
10422 sizeof(uint32_t));
10423 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
10424 buf = wmi_buf_alloc(wmi_handle, len);
10425 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010426 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
10427 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010428 }
10429 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10430 cmd = (wmi_nan_cmd_param *) buf_ptr;
10431 WMITLV_SET_HDR(&cmd->tlv_header,
10432 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
10433 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
10434 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +053010435 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +053010436 __func__, nan_req->request_data_len);
10437 buf_ptr += sizeof(wmi_nan_cmd_param);
10438 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
10439 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +053010440 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010441
10442 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10443 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010444 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010445 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010446 __func__, ret);
10447 wmi_buf_free(buf);
10448 }
10449
10450 return ret;
10451}
10452
10453/**
10454 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
10455 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -070010456 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +053010457 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010458 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010459 */
Jeff Johnsona87370f2017-10-04 19:19:20 -070010460static QDF_STATUS
10461send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
10462 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +053010463{
10464 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
10465 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +053010466 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010467
10468 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10469 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010470 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +053010471 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010472 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010473 }
10474
10475 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010476
10477 WMITLV_SET_HDR(&cmd->tlv_header,
10478 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
10479 WMITLV_GET_STRUCT_TLVLEN
10480 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -070010481 cmd->vdev_id = params->vdev_id;
10482 cmd->enable = params->dhcp_offload_enabled;
10483 cmd->num_client = params->dhcp_client_num;
10484 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +053010485 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +053010486 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +053010487 sizeof(*cmd),
10488 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010489 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010490 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +053010491 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010492 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010493 }
Govind Singhb53420c2016-03-09 14:32:57 +053010494 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -070010495 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +053010496
10497 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010498}
10499
10500/**
10501 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
10502 * @wmi_handle: wmi handle
10503 * @flashing: flashing request
10504 *
10505 * Return: CDF status
10506 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010507static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010508 struct flashing_req_params *flashing)
10509{
10510 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +053010511 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010512 wmi_buf_t buf;
10513 uint8_t *buf_ptr;
10514 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
10515
10516 buf = wmi_buf_alloc(wmi_handle, len);
10517 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010518 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +053010519 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010520 }
10521 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10522 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
10523 WMITLV_SET_HDR(&cmd->tlv_header,
10524 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
10525 WMITLV_GET_STRUCT_TLVLEN
10526 (wmi_set_led_flashing_cmd_fixed_param));
10527 cmd->pattern_id = flashing->pattern_id;
10528 cmd->led_x0 = flashing->led_x0;
10529 cmd->led_x1 = flashing->led_x1;
10530
10531 status = wmi_unified_cmd_send(wmi_handle, buf, len,
10532 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010533 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010534 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +053010535 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010536 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010537 }
Govind Singh67922e82016-04-01 16:48:57 +053010538
10539 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010540}
10541
10542/**
10543 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
10544 * @wmi_handle: wmi handle
10545 * @ch_avoid_update_req: channel avoid update params
10546 *
10547 * Return: CDF status
10548 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010549static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +053010550{
Govind Singh67922e82016-04-01 16:48:57 +053010551 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010552 wmi_buf_t buf = NULL;
10553 uint8_t *buf_ptr;
10554 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
10555 int len = sizeof(wmi_chan_avoid_update_cmd_param);
10556
10557
10558 buf = wmi_buf_alloc(wmi_handle, len);
10559 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010560 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
10561 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010562 }
10563
10564 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10565 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
10566 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
10567 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
10568 WMITLV_GET_STRUCT_TLVLEN
10569 (wmi_chan_avoid_update_cmd_param));
10570
10571 status = wmi_unified_cmd_send(wmi_handle, buf,
10572 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010573 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010574 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +053010575 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
10576 " returned Error %d", status);
10577 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +053010578 }
10579
Govind Singh67922e82016-04-01 16:48:57 +053010580 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +053010581}
10582
10583/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010584 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
10585 * @wmi_handle: wmi handle
10586 * @param: pointer to pdev regdomain params
10587 *
10588 * Return: 0 for success or error code
10589 */
10590static QDF_STATUS
10591send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
10592 struct pdev_set_regdomain_params *param)
10593{
10594 wmi_buf_t buf;
10595 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10596 int32_t len = sizeof(*cmd);
10597
10598
10599 buf = wmi_buf_alloc(wmi_handle, len);
10600 if (!buf) {
10601 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10602 return QDF_STATUS_E_NOMEM;
10603 }
10604 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10605 WMITLV_SET_HDR(&cmd->tlv_header,
10606 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10607 WMITLV_GET_STRUCT_TLVLEN
10608 (wmi_pdev_set_regdomain_cmd_fixed_param));
10609
10610 cmd->reg_domain = param->currentRDinuse;
10611 cmd->reg_domain_2G = param->currentRD2G;
10612 cmd->reg_domain_5G = param->currentRD5G;
10613 cmd->conformance_test_limit_2G = param->ctl_2G;
10614 cmd->conformance_test_limit_5G = param->ctl_5G;
10615 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010616 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10617 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010618
10619 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10620 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
10621 WMI_LOGE("%s: Failed to send pdev set regdomain command",
10622 __func__);
10623 wmi_buf_free(buf);
10624 return QDF_STATUS_E_FAILURE;
10625 }
10626
10627 return QDF_STATUS_SUCCESS;
10628}
10629
10630/**
Govind Singh20c5dac2016-03-07 15:33:31 +053010631 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
10632 * @wmi_handle: wmi handle
10633 * @reg_dmn: reg domain
10634 * @regdmn2G: 2G reg domain
10635 * @regdmn5G: 5G reg domain
10636 * @ctl2G: 2G test limit
10637 * @ctl5G: 5G test limit
10638 *
10639 * Return: none
10640 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010641static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010642 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +053010643 uint16_t regdmn5G, uint8_t ctl2G,
10644 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +053010645{
10646 wmi_buf_t buf;
10647 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
10648 int32_t len = sizeof(*cmd);
10649
10650
10651 buf = wmi_buf_alloc(wmi_handle, len);
10652 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010653 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
10654 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010655 }
10656 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
10657 WMITLV_SET_HDR(&cmd->tlv_header,
10658 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
10659 WMITLV_GET_STRUCT_TLVLEN
10660 (wmi_pdev_set_regdomain_cmd_fixed_param));
10661 cmd->reg_domain = reg_dmn;
10662 cmd->reg_domain_2G = regdmn2G;
10663 cmd->reg_domain_5G = regdmn5G;
10664 cmd->conformance_test_limit_2G = ctl2G;
10665 cmd->conformance_test_limit_5G = ctl5G;
10666
10667 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10668 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010669 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010670 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010671 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010672 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010673 }
10674
Govind Singhb53420c2016-03-09 14:32:57 +053010675 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010676}
10677
10678
10679/**
10680 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
10681 * @wmi_handle: wmi handle
10682 * @chan_switch_params: Pointer to tdls channel switch parameter structure
10683 *
10684 * This function sets tdls off channel mode
10685 *
10686 * Return: 0 on success; Negative errno otherwise
10687 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010688static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010689 struct tdls_channel_switch_params *chan_switch_params)
10690{
10691 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
10692 wmi_buf_t wmi_buf;
10693 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
10694
10695 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10696 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010697 WMI_LOGE(FL("wmi_buf_alloc failed"));
10698 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010699 }
10700 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
10701 wmi_buf_data(wmi_buf);
10702 WMITLV_SET_HDR(&cmd->tlv_header,
10703 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
10704 WMITLV_GET_STRUCT_TLVLEN(
10705 wmi_tdls_set_offchan_mode_cmd_fixed_param));
10706
10707 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
10708 &cmd->peer_macaddr);
10709 cmd->vdev_id = chan_switch_params->vdev_id;
10710 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
10711 cmd->is_peer_responder = chan_switch_params->is_responder;
10712 cmd->offchan_num = chan_switch_params->tdls_off_ch;
10713 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
10714 cmd->offchan_oper_class = chan_switch_params->oper_class;
10715
Govind Singhb53420c2016-03-09 14:32:57 +053010716 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +053010717 cmd->peer_macaddr.mac_addr31to0,
10718 cmd->peer_macaddr.mac_addr47to32);
10719
Govind Singhb53420c2016-03-09 14:32:57 +053010720 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +053010721 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
10722 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
10723 ),
10724 cmd->vdev_id,
10725 cmd->offchan_mode,
10726 cmd->offchan_num,
10727 cmd->offchan_bw_bitmap,
10728 cmd->is_peer_responder,
10729 cmd->offchan_oper_class);
10730
10731 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10732 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010733 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +053010734 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010735 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010736 }
10737
10738
Govind Singhb53420c2016-03-09 14:32:57 +053010739 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010740}
10741
10742/**
10743 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
10744 * @wmi_handle: wmi handle
10745 * @pwmaTdlsparams: TDLS params
10746 *
10747 * Return: 0 for sucess or error code
10748 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010749static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010750 void *tdls_param, uint8_t tdls_state)
10751{
10752 wmi_tdls_set_state_cmd_fixed_param *cmd;
10753 wmi_buf_t wmi_buf;
10754
10755 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
10756 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
10757
10758 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10759 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010760 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
10761 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010762 }
10763 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
10764 WMITLV_SET_HDR(&cmd->tlv_header,
10765 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
10766 WMITLV_GET_STRUCT_TLVLEN
10767 (wmi_tdls_set_state_cmd_fixed_param));
10768 cmd->vdev_id = wmi_tdls->vdev_id;
10769 cmd->state = tdls_state;
10770 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
10771 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
10772 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
10773 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
10774 cmd->rssi_delta = wmi_tdls->rssi_delta;
10775 cmd->tdls_options = wmi_tdls->tdls_options;
10776 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
10777 cmd->tdls_peer_traffic_response_timeout_ms =
10778 wmi_tdls->peer_traffic_response_timeout;
10779 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
10780 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
10781 cmd->tdls_puapsd_rx_frame_threshold =
10782 wmi_tdls->puapsd_rx_frame_threshold;
10783 cmd->teardown_notification_ms =
10784 wmi_tdls->teardown_notification_ms;
10785 cmd->tdls_peer_kickout_threshold =
10786 wmi_tdls->tdls_peer_kickout_threshold;
10787
Govind Singhb53420c2016-03-09 14:32:57 +053010788 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010789 "notification_interval_ms: %d, "
10790 "tx_discovery_threshold: %d, "
10791 "tx_teardown_threshold: %d, "
10792 "rssi_teardown_threshold: %d, "
10793 "rssi_delta: %d, "
10794 "tdls_options: 0x%x, "
10795 "tdls_peer_traffic_ind_window: %d, "
10796 "tdls_peer_traffic_response_timeout: %d, "
10797 "tdls_puapsd_mask: 0x%x, "
10798 "tdls_puapsd_inactivity_time: %d, "
10799 "tdls_puapsd_rx_frame_threshold: %d, "
10800 "teardown_notification_ms: %d, "
10801 "tdls_peer_kickout_threshold: %d",
10802 __func__, tdls_state, cmd->state,
10803 cmd->notification_interval_ms,
10804 cmd->tx_discovery_threshold,
10805 cmd->tx_teardown_threshold,
10806 cmd->rssi_teardown_threshold,
10807 cmd->rssi_delta,
10808 cmd->tdls_options,
10809 cmd->tdls_peer_traffic_ind_window,
10810 cmd->tdls_peer_traffic_response_timeout_ms,
10811 cmd->tdls_puapsd_mask,
10812 cmd->tdls_puapsd_inactivity_time_ms,
10813 cmd->tdls_puapsd_rx_frame_threshold,
10814 cmd->teardown_notification_ms,
10815 cmd->tdls_peer_kickout_threshold);
10816
10817 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10818 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010819 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010820 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010821 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010822 }
Govind Singhb53420c2016-03-09 14:32:57 +053010823 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010824
Govind Singhb53420c2016-03-09 14:32:57 +053010825 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010826}
10827
10828/**
10829 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10830 * @wmi_handle: wmi handle
10831 * @peerStateParams: TDLS peer state params
10832 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010833 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010834 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010835static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010836 struct tdls_peer_state_params *peerStateParams,
10837 uint32_t *ch_mhz)
10838{
10839 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10840 wmi_tdls_peer_capabilities *peer_cap;
10841 wmi_channel *chan_info;
10842 wmi_buf_t wmi_buf;
10843 uint8_t *buf_ptr;
10844 uint32_t i;
10845 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10846 sizeof(wmi_tdls_peer_capabilities);
10847
10848
10849 len += WMI_TLV_HDR_SIZE +
10850 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10851
10852 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10853 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010854 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10855 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010856 }
10857
10858 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10859 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10860 WMITLV_SET_HDR(&cmd->tlv_header,
10861 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10862 WMITLV_GET_STRUCT_TLVLEN
10863 (wmi_tdls_peer_update_cmd_fixed_param));
10864
10865 cmd->vdev_id = peerStateParams->vdevId;
10866 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10867 &cmd->peer_macaddr);
10868
10869
10870 cmd->peer_state = peerStateParams->peerState;
10871
Govind Singhb53420c2016-03-09 14:32:57 +053010872 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010873 "peer_macaddr.mac_addr31to0: 0x%x, "
10874 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10875 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10876 cmd->peer_macaddr.mac_addr31to0,
10877 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10878
10879 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10880 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10881 WMITLV_SET_HDR(&peer_cap->tlv_header,
10882 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10883 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10884
10885 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10886 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10887 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10888 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10889 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10890 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10891 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10892 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10893
10894 /* Ack and More Data Ack are sent as 0, so no need to set
10895 * but fill SP
10896 */
10897 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10898 peerStateParams->peerCap.peerMaxSp);
10899
10900 peer_cap->buff_sta_support =
10901 peerStateParams->peerCap.peerBuffStaSupport;
10902 peer_cap->off_chan_support =
10903 peerStateParams->peerCap.peerOffChanSupport;
10904 peer_cap->peer_curr_operclass =
10905 peerStateParams->peerCap.peerCurrOperClass;
10906 /* self curr operclass is not being used and so pass op class for
10907 * preferred off chan in it.
10908 */
10909 peer_cap->self_curr_operclass =
10910 peerStateParams->peerCap.opClassForPrefOffChan;
10911 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10912 peer_cap->peer_operclass_len =
10913 peerStateParams->peerCap.peerOperClassLen;
10914
Govind Singhb53420c2016-03-09 14:32:57 +053010915 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010916 __func__, peer_cap->peer_operclass_len);
10917 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10918 peer_cap->peer_operclass[i] =
10919 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010920 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010921 __func__, i, peer_cap->peer_operclass[i]);
10922 }
10923
10924 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10925 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10926 peer_cap->pref_offchan_bw =
10927 peerStateParams->peerCap.prefOffChanBandwidth;
10928
Govind Singhb53420c2016-03-09 14:32:57 +053010929 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010930 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10931 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10932 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10933 " %d, pref_offchan_bw: %d",
10934 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10935 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10936 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10937 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10938 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10939
10940 /* next fill variable size array of peer chan info */
10941 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10942 WMITLV_SET_HDR(buf_ptr,
10943 WMITLV_TAG_ARRAY_STRUC,
10944 sizeof(wmi_channel) *
10945 peerStateParams->peerCap.peerChanLen);
10946 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10947
10948 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10949 WMITLV_SET_HDR(&chan_info->tlv_header,
10950 WMITLV_TAG_STRUC_wmi_channel,
10951 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10952 chan_info->mhz = ch_mhz[i];
10953 chan_info->band_center_freq1 = chan_info->mhz;
10954 chan_info->band_center_freq2 = 0;
10955
Govind Singhb53420c2016-03-09 14:32:57 +053010956 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010957
10958 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10959 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010960 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010961 peerStateParams->peerCap.peerChan[i].chanId,
10962 peerStateParams->peerCap.peerChan[i].dfsSet);
10963 }
10964
10965 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10966 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10967 else
10968 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10969
10970 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10971 peerStateParams->peerCap.
10972 peerChan[i].pwr);
10973
10974 WMI_SET_CHANNEL_REG_POWER(chan_info,
10975 peerStateParams->peerCap.peerChan[i].
10976 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010977 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010978 peerStateParams->peerCap.peerChan[i].pwr);
10979
10980 chan_info++;
10981 }
10982
10983 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10984 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010985 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010986 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010987 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010988 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010989 }
10990
10991
Govind Singhb53420c2016-03-09 14:32:57 +053010992 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010993}
10994
10995/*
Govind Singh20c5dac2016-03-07 15:33:31 +053010996 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10997 * @wmi_handle: Pointer to WMi handle
10998 * @ie_data: Pointer for ie data
10999 *
11000 * This function sends IE information to firmware
11001 *
Govind Singhb53420c2016-03-09 14:32:57 +053011002 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053011003 *
11004 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011005static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053011006 struct vdev_ie_info_param *ie_info)
11007{
11008 wmi_vdev_set_ie_cmd_fixed_param *cmd;
11009 wmi_buf_t buf;
11010 uint8_t *buf_ptr;
11011 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053011012 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053011013
11014
11015 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
11016 /* Allocate memory for the WMI command */
11017 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
11018
11019 buf = wmi_buf_alloc(wmi_handle, len);
11020 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011021 WMI_LOGE(FL("wmi_buf_alloc failed"));
11022 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053011023 }
11024
11025 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011026 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011027
11028 /* Populate the WMI command */
11029 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
11030
11031 WMITLV_SET_HDR(&cmd->tlv_header,
11032 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
11033 WMITLV_GET_STRUCT_TLVLEN(
11034 wmi_vdev_set_ie_cmd_fixed_param));
11035 cmd->vdev_id = ie_info->vdev_id;
11036 cmd->ie_id = ie_info->ie_id;
11037 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070011038 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053011039
Govind Singhb53420c2016-03-09 14:32:57 +053011040 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053011041 ie_info->length, ie_info->vdev_id);
11042
11043 buf_ptr += sizeof(*cmd);
11044 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
11045 buf_ptr += WMI_TLV_HDR_SIZE;
11046
Govind Singhb53420c2016-03-09 14:32:57 +053011047 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053011048
11049 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11050 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011051 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011052 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053011053 wmi_buf_free(buf);
11054 }
11055
11056 return ret;
11057}
11058
Sathish Kumar497bef42017-03-01 14:02:36 +053011059/**
11060 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
11061 *
11062 * @param wmi_handle : handle to WMI.
11063 * @param param : pointer to antenna param
11064 *
11065 * This function sends smart antenna enable command to FW
11066 *
11067 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11068 */
11069static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
11070 struct smart_ant_enable_params *param)
11071{
11072 /* Send WMI COMMAND to Enable */
11073 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
11074 wmi_pdev_smart_ant_gpio_handle *gpio_param;
11075 wmi_buf_t buf;
11076 uint8_t *buf_ptr;
11077 int len = 0;
11078 QDF_STATUS ret;
11079 int loop = 0;
11080
11081 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11082 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
11083 buf = wmi_buf_alloc(wmi_handle, len);
11084
11085 if (!buf) {
11086 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11087 return QDF_STATUS_E_NOMEM;
11088 }
11089
11090 buf_ptr = wmi_buf_data(buf);
11091 qdf_mem_zero(buf_ptr, len);
11092 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
11093
11094 WMITLV_SET_HDR(&cmd->tlv_header,
11095 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
11096 WMITLV_GET_STRUCT_TLVLEN(
11097 wmi_pdev_smart_ant_enable_cmd_fixed_param));
11098
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011099 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11100 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011101 cmd->enable = param->enable;
11102 cmd->mode = param->mode;
11103 cmd->rx_antenna = param->rx_antenna;
11104 cmd->tx_default_antenna = param->rx_antenna;
11105
11106 /* TLV indicating array of structures to follow */
11107 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
11108 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11109 WMI_HAL_MAX_SANTENNA *
11110 sizeof(wmi_pdev_smart_ant_gpio_handle));
11111
11112 buf_ptr += WMI_TLV_HDR_SIZE;
11113 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
11114
11115 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
11116 WMITLV_SET_HDR(&gpio_param->tlv_header,
11117 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
11118 WMITLV_GET_STRUCT_TLVLEN(
11119 wmi_pdev_smart_ant_gpio_handle));
11120 if (param->mode == SMART_ANT_MODE_SERIAL) {
11121 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
11122 gpio_param->gpio_pin = param->gpio_pin[loop];
11123 gpio_param->gpio_func = param->gpio_func[loop];
11124 } else {
11125 gpio_param->gpio_pin = 0;
11126 gpio_param->gpio_func = 0;
11127 }
11128 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
11129 gpio_param->gpio_pin = param->gpio_pin[loop];
11130 gpio_param->gpio_func = param->gpio_func[loop];
11131 }
11132 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011133 gpio_param->pdev_id =
11134 wmi_handle->ops->convert_pdev_id_host_to_target(
11135 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011136 gpio_param++;
11137 }
11138
11139 ret = wmi_unified_cmd_send(wmi_handle,
11140 buf,
11141 len,
11142 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
11143
11144 if (ret != 0) {
11145 WMI_LOGE(" %s :WMI Failed\n", __func__);
11146 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
11147 cmd->enable,
11148 cmd->mode,
11149 cmd->rx_antenna,
11150 param->gpio_pin[0], param->gpio_pin[1],
11151 param->gpio_pin[2], param->gpio_pin[3],
11152 param->gpio_func[0], param->gpio_func[1],
11153 param->gpio_func[2], param->gpio_func[3],
11154 ret);
11155 wmi_buf_free(buf);
11156 }
11157
11158 return ret;
11159}
11160
11161/**
11162 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
11163 *
11164 * @param wmi_handle : handle to WMI.
11165 * @param param : pointer to rx antenna param
11166 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11167 */
11168static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11169 struct smart_ant_rx_ant_params *param)
11170{
11171 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
11172 wmi_buf_t buf;
11173 uint8_t *buf_ptr;
11174 uint32_t len;
11175 QDF_STATUS ret;
11176
11177 len = sizeof(*cmd);
11178 buf = wmi_buf_alloc(wmi_handle, len);
11179 WMI_LOGD("%s:\n", __func__);
11180 if (!buf) {
11181 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11182 return QDF_STATUS_E_NOMEM;
11183 }
11184
11185 buf_ptr = wmi_buf_data(buf);
11186 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
11187 WMITLV_SET_HDR(&cmd->tlv_header,
11188 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
11189 WMITLV_GET_STRUCT_TLVLEN(
11190 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
11191 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011192 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11193 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011194
11195 ret = wmi_unified_cmd_send(wmi_handle,
11196 buf,
11197 len,
11198 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
11199
11200 if (ret != 0) {
11201 WMI_LOGE(" %s :WMI Failed\n", __func__);
11202 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
11203 __func__,
11204 cmd->rx_antenna,
11205 ret);
11206 wmi_buf_free(buf);
11207 }
11208
11209 return ret;
11210}
11211
11212/**
11213 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
11214 * @wmi_handle: wmi handle
11215 * @param: pointer to hold ctl table param
11216 *
11217 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11218 */
11219static QDF_STATUS
11220send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
11221 struct ctl_table_params *param)
11222{
11223 uint16_t len, ctl_tlv_len;
11224 uint8_t *buf_ptr;
11225 wmi_buf_t buf;
11226 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
11227 uint32_t *ctl_array;
11228
11229 if (!param->ctl_array)
11230 return QDF_STATUS_E_FAILURE;
11231
Sathish Kumar497bef42017-03-01 14:02:36 +053011232 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053011233 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053011234 len = sizeof(*cmd) + ctl_tlv_len;
11235
11236 buf = wmi_buf_alloc(wmi_handle, len);
11237 if (!buf) {
11238 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11239 return QDF_STATUS_E_FAILURE;
11240 }
11241
11242 buf_ptr = wmi_buf_data(buf);
11243 qdf_mem_zero(buf_ptr, len);
11244
11245 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
11246
11247 WMITLV_SET_HDR(&cmd->tlv_header,
11248 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
11249 WMITLV_GET_STRUCT_TLVLEN(
11250 wmi_pdev_set_ctl_table_cmd_fixed_param));
11251 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011252 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11253 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011254
11255 buf_ptr += sizeof(*cmd);
11256 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11257 (cmd->ctl_len));
11258 buf_ptr += WMI_TLV_HDR_SIZE;
11259 ctl_array = (uint32_t *)buf_ptr;
11260
11261 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
11262 sizeof(param->ctl_band));
11263 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
11264 param->ctl_cmd_len -
11265 sizeof(param->ctl_band));
11266
11267 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11268 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
11269 WMI_LOGE("%s:Failed to send command\n", __func__);
11270 wmi_buf_free(buf);
11271 return QDF_STATUS_E_FAILURE;
11272 }
11273
11274 return QDF_STATUS_SUCCESS;
11275}
11276
11277/**
11278 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
11279 * @wmi_handle: wmi handle
11280 * @param: pointer to hold mimogain table param
11281 *
11282 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11283 */
11284static QDF_STATUS
11285send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
11286 struct mimogain_table_params *param)
11287{
11288 uint16_t len, table_tlv_len;
11289 wmi_buf_t buf;
11290 uint8_t *buf_ptr;
11291 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
11292 uint32_t *gain_table;
11293
11294 if (!param->array_gain)
11295 return QDF_STATUS_E_FAILURE;
11296
11297 /* len must be multiple of a single array gain table */
11298 if (param->tbl_len %
11299 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
11300 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
11301 WMI_LOGE("Array gain table len not correct\n");
11302 return QDF_STATUS_E_FAILURE;
11303 }
11304
11305 table_tlv_len = WMI_TLV_HDR_SIZE +
11306 roundup(param->tbl_len, sizeof(uint32_t));
11307 len = sizeof(*cmd) + table_tlv_len;
11308
11309 buf = wmi_buf_alloc(wmi_handle, len);
11310 if (!buf) {
11311 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11312 return QDF_STATUS_E_FAILURE;
11313 }
11314
11315 buf_ptr = wmi_buf_data(buf);
11316 qdf_mem_zero(buf_ptr, len);
11317
11318 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
11319
11320 WMITLV_SET_HDR(&cmd->tlv_header,
11321 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
11322 WMITLV_GET_STRUCT_TLVLEN(
11323 wmi_pdev_set_mimogain_table_cmd_fixed_param));
11324
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011325 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11326 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053011327 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
11328 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
11329 param->multichain_gain_bypass);
11330
11331 buf_ptr += sizeof(*cmd);
11332 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11333 (param->tbl_len));
11334 buf_ptr += WMI_TLV_HDR_SIZE;
11335 gain_table = (uint32_t *)buf_ptr;
11336
11337 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
11338 param->array_gain,
11339 param->tbl_len);
11340
11341 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11342 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
11343 return QDF_STATUS_E_FAILURE;
11344 }
11345
11346 return QDF_STATUS_SUCCESS;
11347}
11348
11349/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011350 * enum packet_power_tlv_flags: target defined
11351 * packet power rate flags for TLV
11352 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
11353 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
11354 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
11355 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
11356 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
11357 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
11358 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
11359 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
11360 * @WMI_TLV_FLAG_STBC: STBC is set
11361 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
11362 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
11363 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
11364 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
11365 * @WMI_TLV_FLAG_RTSENA: RTS enabled
11366 * @WMI_TLV_FLAG_CTSENA: CTS enabled
11367 * @WMI_TLV_FLAG_LDPC: LDPC is set
11368 * @WMI_TLV_FLAG_SGI: Short gaurd interval
11369 * @WMI_TLV_FLAG_SU: SU Data
11370 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
11371 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
11372 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
11373 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
11374 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
11375 *
11376 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
11377 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
11378 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
11379 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
11380 */
11381enum packet_power_tlv_flags {
11382 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
11383 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
11384 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
11385 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
11386 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
11387 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
11388 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
11389 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
11390 WMI_TLV_FLAG_STBC = 0x00000100,
11391 WMI_TLV_FLAG_40MHZ = 0x00000200,
11392 WMI_TLV_FLAG_80MHZ = 0x00000300,
11393 WMI_TLV_FLAG_160MHZ = 0x00000400,
11394 WMI_TLV_FLAG_TXBF = 0x00000800,
11395 WMI_TLV_FLAG_RTSENA = 0x00001000,
11396 WMI_TLV_FLAG_CTSENA = 0x00002000,
11397 WMI_TLV_FLAG_LDPC = 0x00004000,
11398 WMI_TLV_FLAG_SGI = 0x00008000,
11399 WMI_TLV_FLAG_SU = 0x00100000,
11400 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
11401 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
11402 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
11403 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
11404 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
11405
11406 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
11407 WMI_TLV_FLAG_BW_MASK = 0x3,
11408 WMI_TLV_FLAG_BW_SHIFT = 9,
11409 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
11410 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
11411};
11412
11413/**
11414 * convert_to_power_info_rate_flags() - convert packet_power_info_params
11415 * to FW understandable format
11416 * @param: pointer to hold packet power info param
11417 *
11418 * @return FW understandable 32 bit rate flags
11419 */
11420static uint32_t
11421convert_to_power_info_rate_flags(struct packet_power_info_params *param)
11422{
11423 uint32_t rateflags = 0;
11424
11425 if (param->chainmask)
11426 rateflags |=
11427 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
11428 if (param->chan_width)
11429 rateflags |=
11430 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
11431 << WMI_TLV_FLAG_BW_SHIFT);
11432 if (param->su_mu_ofdma)
11433 rateflags |=
11434 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
11435 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
11436 if (param->rate_flags & WMI_HOST_FLAG_STBC)
11437 rateflags |= WMI_TLV_FLAG_STBC;
11438 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
11439 rateflags |= WMI_TLV_FLAG_LDPC;
11440 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
11441 rateflags |= WMI_TLV_FLAG_TXBF;
11442 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
11443 rateflags |= WMI_TLV_FLAG_RTSENA;
11444 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
11445 rateflags |= WMI_TLV_FLAG_CTSENA;
11446 if (param->rate_flags & WMI_HOST_FLAG_SGI)
11447 rateflags |= WMI_TLV_FLAG_SGI;
11448
11449 return rateflags;
11450}
11451
11452/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011453 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
11454 * info to fw
11455 * @wmi_handle: wmi handle
11456 * @param: pointer to hold packet power info param
11457 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011458 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053011459 */
11460static QDF_STATUS
11461send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
11462 struct packet_power_info_params *param)
11463{
11464 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
11465 wmi_buf_t wmibuf;
11466 uint8_t *buf_ptr;
11467 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
11468
11469 wmibuf = wmi_buf_alloc(wmi_handle, len);
11470 if (wmibuf == NULL)
11471 return QDF_STATUS_E_NOMEM;
11472
11473 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
11474
11475 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
11476 WMITLV_SET_HDR(&cmd->tlv_header,
11477 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
11478 WMITLV_GET_STRUCT_TLVLEN(
11479 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011480 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11481 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011482 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053011483 cmd->nss = param->nss;
11484 cmd->preamble = param->preamble;
11485 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011486
11487 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
11488 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
11489 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
11490 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
11491
Sathish Kumar497bef42017-03-01 14:02:36 +053011492 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
11493 WMI_PDEV_GET_TPC_CMDID)) {
11494 WMI_LOGE(FL("Failed to get tpc command\n"));
11495 wmi_buf_free(wmibuf);
11496 return QDF_STATUS_E_FAILURE;
11497 }
11498
11499 return QDF_STATUS_SUCCESS;
11500}
11501
11502/**
11503 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
11504 * @wmi_handle: wmi handle
11505 * @param: pointer to hold config ratemask params
11506 *
11507 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11508 */
11509static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
11510 struct config_ratemask_params *param)
11511{
11512 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
11513 wmi_buf_t buf;
11514 int32_t len = sizeof(*cmd);
11515
11516 buf = wmi_buf_alloc(wmi_handle, len);
11517 if (!buf) {
11518 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11519 return QDF_STATUS_E_FAILURE;
11520 }
11521 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
11522 WMITLV_SET_HDR(&cmd->tlv_header,
11523 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
11524 WMITLV_GET_STRUCT_TLVLEN(
11525 wmi_vdev_config_ratemask_cmd_fixed_param));
11526 cmd->vdev_id = param->vdev_id;
11527 cmd->type = param->type;
11528 cmd->mask_lower32 = param->lower32;
11529 cmd->mask_higher32 = param->higher32;
11530 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
11531 param->vdev_id, param->type, param->lower32, param->higher32);
11532
11533 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11534 WMI_VDEV_RATEMASK_CMDID)) {
11535 WMI_LOGE("Seting vdev ratemask failed\n");
11536 wmi_buf_free(buf);
11537 return QDF_STATUS_E_FAILURE;
11538 }
11539
11540 return QDF_STATUS_SUCCESS;
11541}
11542
11543/**
Sathish Kumar6011c742017-11-08 14:49:58 +053011544 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
11545 * @param: param sent from the host side
11546 * @cmd: param to be sent to the fw side
11547 */
11548static inline void copy_custom_aggr_bitmap(
11549 struct set_custom_aggr_size_params *param,
11550 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
11551{
11552 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
11553 param->ac);
11554 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
11555 param->aggr_type);
11556 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11557 param->tx_aggr_size_disable);
11558 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
11559 param->rx_aggr_size_disable);
11560 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
11561 param->tx_ac_enable);
11562}
11563
11564/**
11565 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
11566 * @wmi_handle: wmi handle
11567 * @param: pointer to hold custom aggr size params
11568 *
11569 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11570 */
11571static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
11572 wmi_unified_t wmi_handle,
11573 struct set_custom_aggr_size_params *param)
11574{
11575 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
11576 wmi_buf_t buf;
11577 int32_t len = sizeof(*cmd);
11578
11579 buf = wmi_buf_alloc(wmi_handle, len);
11580 if (!buf) {
11581 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11582 return QDF_STATUS_E_FAILURE;
11583 }
11584 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
11585 wmi_buf_data(buf);
11586 WMITLV_SET_HDR(&cmd->tlv_header,
11587 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
11588 WMITLV_GET_STRUCT_TLVLEN(
11589 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
11590 cmd->vdev_id = param->vdev_id;
11591 cmd->tx_aggr_size = param->tx_aggr_size;
11592 cmd->rx_aggr_size = param->rx_aggr_size;
11593 copy_custom_aggr_bitmap(param, cmd);
11594
11595 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
11596 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
11597 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
11598 "tx_ac_enable=0x%X\n",
11599 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
11600 param->ac, param->aggr_type, param->tx_aggr_size_disable,
11601 param->rx_aggr_size_disable, param->tx_ac_enable);
11602
11603 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11604 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
11605 WMI_LOGE("Seting custom aggregation size failed\n");
11606 wmi_buf_free(buf);
11607 return QDF_STATUS_E_FAILURE;
11608 }
11609
11610 return QDF_STATUS_SUCCESS;
11611}
11612
11613/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011614 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
11615 * @param wmi_handle : handle to WMI.
11616 * @param param : pointer to tx antenna param
11617 *
11618 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11619 */
11620
11621static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
11622 struct set_qdepth_thresh_params *param)
11623{
11624 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
11625 wmi_msduq_qdepth_thresh_update *cmd_update;
11626 wmi_buf_t buf;
11627 int32_t len = 0;
11628 int i;
11629 uint8_t *buf_ptr;
11630 QDF_STATUS ret;
11631
11632 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
11633 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
11634 return QDF_STATUS_E_INVAL;
11635 }
11636
11637 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11638 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
11639 param->num_of_msduq_updates);
11640 buf = wmi_buf_alloc(wmi_handle, len);
11641
11642 if (!buf) {
11643 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11644 return QDF_STATUS_E_NOMEM;
11645 }
11646
11647 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11648 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
11649 buf_ptr;
11650
11651 WMITLV_SET_HDR(&cmd->tlv_header,
11652 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
11653 , WMITLV_GET_STRUCT_TLVLEN(
11654 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
11655
11656 cmd->pdev_id =
11657 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
11658 cmd->vdev_id = param->vdev_id;
11659 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
11660 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
11661
11662 buf_ptr += sizeof(
11663 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
11664 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11665 param->num_of_msduq_updates *
11666 sizeof(wmi_msduq_qdepth_thresh_update));
11667 buf_ptr += WMI_TLV_HDR_SIZE;
11668 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
11669
11670 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
11671 WMITLV_SET_HDR(&cmd_update->tlv_header,
11672 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
11673 WMITLV_GET_STRUCT_TLVLEN(
11674 wmi_msduq_qdepth_thresh_update));
11675 cmd_update->tid_num = param->update_params[i].tid_num;
11676 cmd_update->msduq_update_mask =
11677 param->update_params[i].msduq_update_mask;
11678 cmd_update->qdepth_thresh_value =
11679 param->update_params[i].qdepth_thresh_value;
11680 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
11681 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
11682 " update mask=0x%X thresh val=0x%X\n",
11683 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
11684 cmd->peer_mac_address.mac_addr31to0,
11685 cmd->peer_mac_address.mac_addr47to32,
11686 cmd_update->msduq_update_mask,
11687 cmd_update->qdepth_thresh_value);
11688 cmd_update++;
11689 }
11690
11691 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11692 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
11693
11694 if (ret != 0) {
11695 WMI_LOGE(" %s :WMI Failed\n", __func__);
11696 wmi_buf_free(buf);
11697 }
11698
11699 return ret;
11700}
11701
11702/**
Sathish Kumar497bef42017-03-01 14:02:36 +053011703 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
11704 * @wmi_handle: wmi handle
11705 * @param: pointer to hold vap dscp tid map param
11706 *
11707 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11708 */
11709static QDF_STATUS
11710send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
11711 struct vap_dscp_tid_map_params *param)
11712{
11713 wmi_buf_t buf;
11714 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
11715 int32_t len = sizeof(*cmd);
11716
11717 buf = wmi_buf_alloc(wmi_handle, len);
11718 if (!buf) {
11719 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11720 return QDF_STATUS_E_FAILURE;
11721 }
11722
11723 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
11724 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053011725 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053011726
11727 cmd->vdev_id = param->vdev_id;
11728 cmd->enable_override = 0;
11729
11730 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
11731 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11732 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
11733 WMI_LOGE("Failed to set dscp cmd\n");
11734 wmi_buf_free(buf);
11735 return QDF_STATUS_E_FAILURE;
11736 }
11737
11738 return QDF_STATUS_SUCCESS;
11739}
11740
11741/**
11742 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
11743 * @wmi_handle: wmi handle
11744 * @macaddr: vdev mac address
11745 * @param: pointer to hold neigbour rx param
11746 *
11747 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11748 */
11749static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
11750 uint8_t macaddr[IEEE80211_ADDR_LEN],
11751 struct set_neighbour_rx_params *param)
11752{
11753 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
11754 wmi_buf_t buf;
11755 int32_t len = sizeof(*cmd);
11756
11757 buf = wmi_buf_alloc(wmi_handle, len);
11758 if (!buf) {
11759 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11760 return QDF_STATUS_E_FAILURE;
11761 }
11762 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
11763 WMITLV_SET_HDR(&cmd->tlv_header,
11764 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
11765 WMITLV_GET_STRUCT_TLVLEN(
11766 wmi_vdev_filter_nrp_config_cmd_fixed_param));
11767 cmd->vdev_id = param->vdev_id;
11768 cmd->bssid_idx = param->idx;
11769 cmd->action = param->action;
11770 cmd->type = param->type;
11771 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
11772 cmd->flag = 0;
11773
11774 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11775 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
11776 WMI_LOGE("Failed to set neighbour rx param\n");
11777 wmi_buf_free(buf);
11778 return QDF_STATUS_E_FAILURE;
11779 }
11780
11781 return QDF_STATUS_SUCCESS;
11782}
11783
11784/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011785 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053011786 * @param wmi_handle : handle to WMI.
11787 * @param macaddr : vdev mac address
11788 * @param param : pointer to tx antenna param
11789 *
11790 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11791 */
11792static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
11793 uint8_t macaddr[IEEE80211_ADDR_LEN],
11794 struct smart_ant_tx_ant_params *param)
11795{
11796 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
11797 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
11798 wmi_buf_t buf;
11799 int32_t len = 0;
11800 int i;
11801 uint8_t *buf_ptr;
11802 QDF_STATUS ret;
11803
11804 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11805 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11806 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
11807 buf = wmi_buf_alloc(wmi_handle, len);
11808
11809 if (!buf) {
11810 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11811 return QDF_STATUS_E_NOMEM;
11812 }
11813
11814 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11815 qdf_mem_zero(buf_ptr, len);
11816 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11817
11818 WMITLV_SET_HDR(&cmd->tlv_header,
11819 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11820 WMITLV_GET_STRUCT_TLVLEN(
11821 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11822
11823 cmd->vdev_id = param->vdev_id;
11824 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11825
11826 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11827 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11828 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11829 buf_ptr += WMI_TLV_HDR_SIZE;
11830 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11831
11832 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11833 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11834 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11835 WMITLV_GET_STRUCT_TLVLEN(
11836 wmi_peer_smart_ant_set_tx_antenna_series));
11837 ant_tx_series->antenna_series = param->antenna_array[i];
11838 ant_tx_series++;
11839 }
11840
11841 ret = wmi_unified_cmd_send(wmi_handle,
11842 buf,
11843 len,
11844 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11845
11846 if (ret != 0) {
11847 WMI_LOGE(" %s :WMI Failed\n", __func__);
11848 wmi_buf_free(buf);
11849 }
11850
11851 return ret;
11852}
11853
Sathish Kumar02c3b542017-02-22 17:24:45 +053011854/**
11855 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11856 * @wmi_handle: wmi handle
11857 * @param: pointer to hold ant switch tbl param
11858 *
11859 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11860 */
11861static QDF_STATUS
11862send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11863 struct ant_switch_tbl_params *param)
11864{
11865 uint8_t len;
11866 wmi_buf_t buf;
11867 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11868 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11869 uint8_t *buf_ptr;
11870
11871 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11872 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11873 buf = wmi_buf_alloc(wmi_handle, len);
11874
11875 if (!buf) {
11876 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11877 return QDF_STATUS_E_NOMEM;
11878 }
11879
11880 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11881 qdf_mem_zero(buf_ptr, len);
11882 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11883
11884 WMITLV_SET_HDR(&cmd->tlv_header,
11885 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11886 WMITLV_GET_STRUCT_TLVLEN(
11887 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11888
11889 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11890 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011891 cmd->mac_id =
11892 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011893
11894 /* TLV indicating array of structures to follow */
11895 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11896 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11897 sizeof(wmi_pdev_set_ant_ctrl_chain));
11898 buf_ptr += WMI_TLV_HDR_SIZE;
11899 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11900
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011901 ctrl_chain->pdev_id =
11902 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011903 ctrl_chain->antCtrlChain = param->antCtrlChain;
11904
11905 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11906 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11907 wmi_buf_free(buf);
11908 return QDF_STATUS_E_FAILURE;
11909 }
11910
11911 return QDF_STATUS_SUCCESS;
11912}
11913
11914/**
11915 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11916 * training information function
11917 * @param wmi_handle : handle to WMI.
11918 * @macaddr : vdev mac address
11919 * @param param : pointer to tx antenna param
11920 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11921 */
11922static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11923 wmi_unified_t wmi_handle,
11924 uint8_t macaddr[IEEE80211_ADDR_LEN],
11925 struct smart_ant_training_info_params *param)
11926{
11927 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11928 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11929 wmi_buf_t buf;
11930 uint8_t *buf_ptr;
11931 int32_t len = 0;
11932 QDF_STATUS ret;
11933 int loop;
11934
11935 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11936 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11937 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11938 buf = wmi_buf_alloc(wmi_handle, len);
11939
11940 if (!buf) {
11941 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11942 return QDF_STATUS_E_NOMEM;
11943 }
11944
11945 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11946 qdf_mem_zero(buf_ptr, len);
11947 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11948
11949 WMITLV_SET_HDR(&cmd->tlv_header,
11950 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11951 WMITLV_GET_STRUCT_TLVLEN(
11952 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11953
11954 cmd->vdev_id = param->vdev_id;
11955 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11956 cmd->num_pkts = param->numpkts;
11957
11958 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11959 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11960 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11961 WMI_SMART_ANT_MAX_RATE_SERIES);
11962
11963 buf_ptr += WMI_TLV_HDR_SIZE;
11964 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11965
11966 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11967 WMITLV_SET_HDR(&train_param->tlv_header,
11968 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11969 WMITLV_GET_STRUCT_TLVLEN(
11970 wmi_peer_smart_ant_set_train_antenna_param));
11971 train_param->train_rate_series = param->rate_array[loop];
11972 train_param->train_antenna_series = param->antenna_array[loop];
11973 train_param->rc_flags = 0;
11974 WMI_LOGI(FL("Series number:%d\n"), loop);
11975 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11976 train_param->train_rate_series,
11977 train_param->train_antenna_series);
11978 train_param++;
11979 }
11980
11981 ret = wmi_unified_cmd_send(wmi_handle,
11982 buf,
11983 len,
11984 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11985
11986 if (ret != 0) {
11987 WMI_LOGE(" %s :WMI Failed\n", __func__);
11988 wmi_buf_free(buf);
11989 return QDF_STATUS_E_FAILURE;
11990 }
11991
11992 return ret;
11993}
11994
11995/**
11996 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11997 * configuration function
11998 * @param wmi_handle : handle to WMI.
11999 * @macaddr : vdev mad address
12000 * @param param : pointer to tx antenna param
12001 *
12002 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12003 */
12004static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
12005 wmi_unified_t wmi_handle,
12006 uint8_t macaddr[IEEE80211_ADDR_LEN],
12007 struct smart_ant_node_config_params *param)
12008{
12009 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
12010 wmi_buf_t buf;
12011 uint8_t *buf_ptr;
12012 int32_t len = 0, args_tlv_len;
12013 int ret;
12014 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053012015 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053012016
Vivekc5823092018-03-22 23:27:21 +053012017 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053012018 len = sizeof(*cmd) + args_tlv_len;
12019
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070012020 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053012021 WMI_LOGE("%s: Can't send a command with %d arguments\n",
12022 __func__, param->args_count);
12023 return QDF_STATUS_E_FAILURE;
12024 }
12025
12026 buf = wmi_buf_alloc(wmi_handle, len);
12027 if (!buf) {
12028 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12029 return QDF_STATUS_E_NOMEM;
12030 }
12031
12032 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
12033 wmi_buf_data(buf);
12034 buf_ptr = (uint8_t *)cmd;
12035 WMITLV_SET_HDR(&cmd->tlv_header,
12036 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
12037 WMITLV_GET_STRUCT_TLVLEN(
12038 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
12039 cmd->vdev_id = param->vdev_id;
12040 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12041 cmd->cmd_id = param->cmd_id;
12042 cmd->args_count = param->args_count;
12043 buf_ptr += sizeof(
12044 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
12045 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053012046 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053012047 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053012048 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053012049
12050 for (i = 0; i < param->args_count; i++) {
12051 node_config_args[i] = param->args_arr[i];
12052 WMI_LOGI("%d", param->args_arr[i]);
12053 }
12054
12055 ret = wmi_unified_cmd_send(wmi_handle,
12056 buf,
12057 len,
12058 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
12059
12060 if (ret != 0) {
12061 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
12062 __func__, param->cmd_id, macaddr[0],
12063 macaddr[1], macaddr[2], macaddr[3],
12064 macaddr[4], macaddr[5], ret);
12065 wmi_buf_free(buf);
12066 }
12067
12068 return ret;
12069}
12070
12071/**
12072 * send_set_atf_cmd_tlv() - send set atf command to fw
12073 * @wmi_handle: wmi handle
12074 * @param: pointer to set atf param
12075 *
12076 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12077 */
12078static QDF_STATUS
12079send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
12080 struct set_atf_params *param)
12081{
12082 wmi_atf_peer_info *peer_info;
12083 wmi_peer_atf_request_fixed_param *cmd;
12084 wmi_buf_t buf;
12085 uint8_t *buf_ptr;
12086 int i;
12087 int32_t len = 0;
12088 QDF_STATUS retval;
12089
12090 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12091 len += param->num_peers * sizeof(wmi_atf_peer_info);
12092 buf = wmi_buf_alloc(wmi_handle, len);
12093 if (!buf) {
12094 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12095 return QDF_STATUS_E_FAILURE;
12096 }
12097 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12098 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
12099 WMITLV_SET_HDR(&cmd->tlv_header,
12100 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
12101 WMITLV_GET_STRUCT_TLVLEN(
12102 wmi_peer_atf_request_fixed_param));
12103 cmd->num_peers = param->num_peers;
12104
12105 buf_ptr += sizeof(*cmd);
12106 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12107 sizeof(wmi_atf_peer_info) *
12108 cmd->num_peers);
12109 buf_ptr += WMI_TLV_HDR_SIZE;
12110 peer_info = (wmi_atf_peer_info *)buf_ptr;
12111
12112 for (i = 0; i < cmd->num_peers; i++) {
12113 WMITLV_SET_HDR(&peer_info->tlv_header,
12114 WMITLV_TAG_STRUC_wmi_atf_peer_info,
12115 WMITLV_GET_STRUCT_TLVLEN(
12116 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012117 qdf_mem_copy(&(peer_info->peer_macaddr),
12118 &(param->peer_info[i].peer_macaddr),
12119 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053012120 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012121 peer_info->vdev_id = param->peer_info[i].vdev_id;
12122 peer_info->pdev_id =
12123 wmi_handle->ops->convert_pdev_id_host_to_target(
12124 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053012125 /*
12126 * TLV definition for peer atf request fixed param combines
12127 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
12128 * stats and atf extension stats as two different
12129 * implementations.
12130 * Need to discuss with FW on this.
12131 *
12132 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
12133 * peer_info->atf_units_reserved =
12134 * param->peer_ext_info[i].atf_index_reserved;
12135 */
12136 peer_info++;
12137 }
12138
12139 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12140 WMI_PEER_ATF_REQUEST_CMDID);
12141
12142 if (retval != QDF_STATUS_SUCCESS) {
12143 WMI_LOGE("%s : WMI Failed\n", __func__);
12144 wmi_buf_free(buf);
12145 }
12146
12147 return retval;
12148}
12149
12150/**
12151 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
12152 * @wmi_handle: wmi handle
12153 * @param: pointer to hold fwtest param
12154 *
12155 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12156 */
12157static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
12158 struct set_fwtest_params *param)
12159{
12160 wmi_fwtest_set_param_cmd_fixed_param *cmd;
12161 wmi_buf_t buf;
12162 int32_t len = sizeof(*cmd);
12163
12164 buf = wmi_buf_alloc(wmi_handle, len);
12165
12166 if (!buf) {
12167 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12168 return QDF_STATUS_E_FAILURE;
12169 }
12170
12171 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
12172 WMITLV_SET_HDR(&cmd->tlv_header,
12173 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
12174 WMITLV_GET_STRUCT_TLVLEN(
12175 wmi_fwtest_set_param_cmd_fixed_param));
12176 cmd->param_id = param->arg;
12177 cmd->param_value = param->value;
12178
12179 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
12180 WMI_LOGE("Setting FW test param failed\n");
12181 wmi_buf_free(buf);
12182 return QDF_STATUS_E_FAILURE;
12183 }
12184
12185 return QDF_STATUS_SUCCESS;
12186}
12187
12188/**
12189 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
12190 * @wmi_handle: wmi handle
12191 * @param: pointer to qboost params
12192 * @macaddr: vdev mac address
12193 *
12194 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12195 */
12196static QDF_STATUS
12197send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
12198 uint8_t macaddr[IEEE80211_ADDR_LEN],
12199 struct set_qboost_params *param)
12200{
12201 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
12202 wmi_buf_t buf;
12203 int32_t len;
12204 QDF_STATUS ret;
12205
12206 len = sizeof(*cmd);
12207
12208 buf = wmi_buf_alloc(wmi_handle, len);
12209 if (!buf) {
12210 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12211 return QDF_STATUS_E_FAILURE;
12212 }
12213
12214 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
12215 WMITLV_SET_HDR(&cmd->tlv_header,
12216 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
12217 WMITLV_GET_STRUCT_TLVLEN(
12218 WMI_QBOOST_CFG_CMD_fixed_param));
12219 cmd->vdev_id = param->vdev_id;
12220 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
12221 cmd->qb_enable = param->value;
12222
12223 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12224 WMI_QBOOST_CFG_CMDID);
12225
12226 if (ret != 0) {
12227 WMI_LOGE("Setting qboost cmd failed\n");
12228 wmi_buf_free(buf);
12229 }
12230
12231 return ret;
12232}
12233
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012234/**
12235 * send_gpio_config_cmd_tlv() - send gpio config to fw
12236 * @wmi_handle: wmi handle
12237 * @param: pointer to hold gpio config param
12238 *
12239 * Return: 0 for success or error code
12240 */
12241static QDF_STATUS
12242send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
12243 struct gpio_config_params *param)
12244{
12245 wmi_gpio_config_cmd_fixed_param *cmd;
12246 wmi_buf_t buf;
12247 int32_t len;
12248 QDF_STATUS ret;
12249
12250 len = sizeof(*cmd);
12251
12252 /* Sanity Checks */
12253 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
12254 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
12255 return QDF_STATUS_E_FAILURE;
12256 }
12257
12258 buf = wmi_buf_alloc(wmi_handle, len);
12259 if (!buf) {
12260 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12261 return QDF_STATUS_E_FAILURE;
12262 }
12263
12264 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
12265 WMITLV_SET_HDR(&cmd->tlv_header,
12266 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
12267 WMITLV_GET_STRUCT_TLVLEN(
12268 wmi_gpio_config_cmd_fixed_param));
12269 cmd->gpio_num = param->gpio_num;
12270 cmd->input = param->input;
12271 cmd->pull_type = param->pull_type;
12272 cmd->intr_mode = param->intr_mode;
12273
12274 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12275 WMI_GPIO_CONFIG_CMDID);
12276
12277 if (ret != 0) {
12278 WMI_LOGE("Sending GPIO config cmd failed\n");
12279 wmi_buf_free(buf);
12280 }
12281
12282 return ret;
12283}
12284
12285/**
12286 * send_gpio_output_cmd_tlv() - send gpio output to fw
12287 * @wmi_handle: wmi handle
12288 * @param: pointer to hold gpio output param
12289 *
12290 * Return: 0 for success or error code
12291 */
12292static QDF_STATUS
12293send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
12294 struct gpio_output_params *param)
12295{
12296 wmi_gpio_output_cmd_fixed_param *cmd;
12297 wmi_buf_t buf;
12298 int32_t len;
12299 QDF_STATUS ret;
12300
12301 len = sizeof(*cmd);
12302
12303 buf = wmi_buf_alloc(wmi_handle, len);
12304 if (!buf) {
12305 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12306 return QDF_STATUS_E_FAILURE;
12307 }
12308
12309 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
12310 WMITLV_SET_HDR(&cmd->tlv_header,
12311 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
12312 WMITLV_GET_STRUCT_TLVLEN(
12313 wmi_gpio_output_cmd_fixed_param));
12314 cmd->gpio_num = param->gpio_num;
12315 cmd->set = param->set;
12316
12317 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12318 WMI_GPIO_OUTPUT_CMDID);
12319
12320 if (ret != 0) {
12321 WMI_LOGE("Sending GPIO output cmd failed\n");
12322 wmi_buf_free(buf);
12323 }
12324
12325 return ret;
12326
12327}
12328
12329/**
12330 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
12331 *
12332 * @param wmi_handle : handle to WMI.
12333 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12334 */
12335static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
12336{
12337 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
12338 wmi_buf_t buf;
12339 QDF_STATUS ret;
12340 int32_t len;
12341
12342 len = sizeof(*cmd);
12343
12344 buf = wmi_buf_alloc(wmi_handle, len);
12345 if (!buf) {
12346 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12347 return QDF_STATUS_E_FAILURE;
12348 }
12349
12350 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
12351 WMITLV_SET_HDR(&cmd->tlv_header,
12352 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
12353 WMITLV_GET_STRUCT_TLVLEN(
12354 wmi_pdev_dfs_disable_cmd_fixed_param));
12355 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012356 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12357 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012358
12359 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12360 WMI_PDEV_DFS_DISABLE_CMDID);
12361
12362 if (ret != 0) {
12363 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
12364 wmi_buf_free(buf);
12365 }
12366
12367 return ret;
12368}
12369
12370/**
12371 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
12372 *
12373 * @param wmi_handle : handle to WMI.
12374 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12375 */
12376static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
12377{
12378 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
12379 wmi_buf_t buf;
12380 QDF_STATUS ret;
12381 int32_t len;
12382
12383 len = sizeof(*cmd);
12384
12385 buf = wmi_buf_alloc(wmi_handle, len);
12386 if (!buf) {
12387 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12388 return QDF_STATUS_E_FAILURE;
12389 }
12390
12391 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
12392 WMITLV_SET_HDR(&cmd->tlv_header,
12393 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
12394 WMITLV_GET_STRUCT_TLVLEN(
12395 wmi_pdev_dfs_enable_cmd_fixed_param));
12396 /* Reserved for future use */
12397 cmd->reserved0 = 0;
12398
12399 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12400 WMI_PDEV_DFS_ENABLE_CMDID);
12401
12402 if (ret != 0) {
12403 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
12404 wmi_buf_free(buf);
12405 }
12406
12407 return ret;
12408}
12409
12410/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053012411 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
12412 * to fw
12413 * @wmi_handle: wmi handle
12414 * @param: pointer to hold periodic chan stats param
12415 *
12416 * Return: 0 for success or error code
12417 */
12418static QDF_STATUS
12419send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
12420 struct periodic_chan_stats_params *param)
12421{
12422 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
12423 wmi_buf_t buf;
12424 QDF_STATUS ret;
12425 int32_t len;
12426
12427 len = sizeof(*cmd);
12428
12429 buf = wmi_buf_alloc(wmi_handle, len);
12430 if (!buf) {
12431 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12432 return QDF_STATUS_E_FAILURE;
12433 }
12434
12435 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
12436 wmi_buf_data(buf);
12437 WMITLV_SET_HDR(&cmd->tlv_header,
12438 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
12439 WMITLV_GET_STRUCT_TLVLEN(
12440 wmi_set_periodic_channel_stats_config_fixed_param));
12441 cmd->enable = param->enable;
12442 cmd->stats_period = param->stats_period;
12443 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12444 param->pdev_id);
12445
12446 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
12447 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
12448
12449 if (ret != 0) {
12450 WMI_LOGE("Sending periodic chan stats config failed");
12451 wmi_buf_free(buf);
12452 }
12453
12454 return ret;
12455}
12456
12457/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012458 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
12459 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080012460 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012461 *
12462 * Return: 0 for success or error code
12463 */
12464static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080012465send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012466{
12467 wmi_buf_t buf;
12468 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080012469 wmi_pdev_get_nfcal_power_fixed_param *cmd;
12470 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012471
nobeljf74583b2018-01-25 16:35:36 -080012472 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012473 if (buf == NULL)
12474 return QDF_STATUS_E_NOMEM;
12475
nobeljf74583b2018-01-25 16:35:36 -080012476 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
12477 WMITLV_SET_HDR(&cmd->tlv_header,
12478 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
12479 WMITLV_GET_STRUCT_TLVLEN
12480 (wmi_pdev_get_nfcal_power_fixed_param));
12481 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
12482
12483 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053012484 WMI_PDEV_GET_NFCAL_POWER_CMDID);
12485 if (ret != 0) {
12486 WMI_LOGE("Sending get nfcal power cmd failed\n");
12487 wmi_buf_free(buf);
12488 }
12489
12490 return ret;
12491}
12492
12493/**
12494 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
12495 * @wmi_handle: wmi handle
12496 * @param: pointer to ht ie param
12497 *
12498 * Return: 0 for success or error code
12499 */
12500static QDF_STATUS
12501send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12502 struct ht_ie_params *param)
12503{
12504 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
12505 wmi_buf_t buf;
12506 QDF_STATUS ret;
12507 int32_t len;
12508 uint8_t *buf_ptr;
12509
12510 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12511 roundup(param->ie_len, sizeof(uint32_t));
12512
12513 buf = wmi_buf_alloc(wmi_handle, len);
12514 if (!buf) {
12515 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12516 return QDF_STATUS_E_FAILURE;
12517 }
12518
12519 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12520 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
12521 WMITLV_SET_HDR(&cmd->tlv_header,
12522 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
12523 WMITLV_GET_STRUCT_TLVLEN(
12524 wmi_pdev_set_ht_ie_cmd_fixed_param));
12525 cmd->reserved0 = 0;
12526 cmd->ie_len = param->ie_len;
12527 cmd->tx_streams = param->tx_streams;
12528 cmd->rx_streams = param->rx_streams;
12529
12530 buf_ptr += sizeof(*cmd);
12531 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12532 buf_ptr += WMI_TLV_HDR_SIZE;
12533 if (param->ie_len)
12534 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12535 cmd->ie_len);
12536
12537 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12538 WMI_PDEV_SET_HT_CAP_IE_CMDID);
12539
12540 if (ret != 0) {
12541 WMI_LOGE("Sending set ht ie cmd failed\n");
12542 wmi_buf_free(buf);
12543 }
12544
12545 return ret;
12546}
12547
12548/**
12549 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
12550 * @wmi_handle: wmi handle
12551 * @param: pointer to vht ie param
12552 *
12553 * Return: 0 for success or error code
12554 */
12555static QDF_STATUS
12556send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
12557 struct vht_ie_params *param)
12558{
12559 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
12560 wmi_buf_t buf;
12561 QDF_STATUS ret;
12562 int32_t len;
12563 uint8_t *buf_ptr;
12564
12565 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12566 roundup(param->ie_len, sizeof(uint32_t));
12567
12568 buf = wmi_buf_alloc(wmi_handle, len);
12569 if (!buf) {
12570 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12571 return QDF_STATUS_E_FAILURE;
12572 }
12573
12574 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12575 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
12576 WMITLV_SET_HDR(&cmd->tlv_header,
12577 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
12578 WMITLV_GET_STRUCT_TLVLEN(
12579 wmi_pdev_set_vht_ie_cmd_fixed_param));
12580 cmd->reserved0 = 0;
12581 cmd->ie_len = param->ie_len;
12582 cmd->tx_streams = param->tx_streams;
12583 cmd->rx_streams = param->rx_streams;
12584
12585 buf_ptr += sizeof(*cmd);
12586 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
12587 buf_ptr += WMI_TLV_HDR_SIZE;
12588 if (param->ie_len)
12589 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
12590 cmd->ie_len);
12591
12592 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12593 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
12594
12595 if (ret != 0) {
12596 WMI_LOGE("Sending set vht ie cmd failed\n");
12597 wmi_buf_free(buf);
12598 }
12599
12600 return ret;
12601}
12602
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012603/**
12604 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
12605 * @wmi_handle: wmi handle
12606 * @param: pointer to quiet mode params
12607 *
12608 * Return: 0 for success or error code
12609 */
12610static QDF_STATUS
12611send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
12612 struct set_quiet_mode_params *param)
12613{
12614 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
12615 wmi_buf_t buf;
12616 QDF_STATUS ret;
12617 int32_t len;
12618
12619 len = sizeof(*quiet_cmd);
12620 buf = wmi_buf_alloc(wmi_handle, len);
12621 if (!buf) {
12622 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12623 return QDF_STATUS_E_FAILURE;
12624 }
12625
12626 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12627 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
12628 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
12629 WMITLV_GET_STRUCT_TLVLEN(
12630 wmi_pdev_set_quiet_cmd_fixed_param));
12631 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
12632 quiet_cmd->enabled = param->enabled;
12633 quiet_cmd->period = (param->period)*(param->intval);
12634 quiet_cmd->duration = param->duration;
12635 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012636 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12637 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012638
12639 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12640 WMI_PDEV_SET_QUIET_MODE_CMDID);
12641
12642 if (ret != 0) {
12643 WMI_LOGE("Sending set quiet cmd failed\n");
12644 wmi_buf_free(buf);
12645 }
12646
12647 return ret;
12648}
12649
12650/**
12651 * send_set_bwf_cmd_tlv() - send set bwf command to fw
12652 * @wmi_handle: wmi handle
12653 * @param: pointer to set bwf param
12654 *
12655 * Return: 0 for success or error code
12656 */
12657static QDF_STATUS
12658send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
12659 struct set_bwf_params *param)
12660{
12661 wmi_bwf_peer_info *peer_info;
12662 wmi_peer_bwf_request_fixed_param *cmd;
12663 wmi_buf_t buf;
12664 QDF_STATUS retval;
12665 int32_t len;
12666 uint8_t *buf_ptr;
12667 int i;
12668
12669 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
12670 len += param->num_peers * sizeof(wmi_bwf_peer_info);
12671 buf = wmi_buf_alloc(wmi_handle, len);
12672 if (!buf) {
12673 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
12674 return QDF_STATUS_E_FAILURE;
12675 }
12676 buf_ptr = (uint8_t *)wmi_buf_data(buf);
12677 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
12678 WMITLV_SET_HDR(&cmd->tlv_header,
12679 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
12680 WMITLV_GET_STRUCT_TLVLEN(
12681 wmi_peer_bwf_request_fixed_param));
12682 cmd->num_peers = param->num_peers;
12683
12684 buf_ptr += sizeof(*cmd);
12685 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12686 sizeof(wmi_bwf_peer_info) *
12687 cmd->num_peers);
12688 buf_ptr += WMI_TLV_HDR_SIZE;
12689 peer_info = (wmi_bwf_peer_info *)buf_ptr;
12690
12691 for (i = 0; i < cmd->num_peers; i++) {
12692 WMITLV_SET_HDR(&peer_info->tlv_header,
12693 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
12694 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
12695 peer_info->bwf_guaranteed_bandwidth =
12696 param->peer_info[i].throughput;
12697 peer_info->bwf_max_airtime =
12698 param->peer_info[i].max_airtime;
12699 peer_info->bwf_peer_priority =
12700 param->peer_info[i].priority;
12701 qdf_mem_copy(&peer_info->peer_macaddr,
12702 &param->peer_info[i].peer_macaddr,
12703 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012704 peer_info->vdev_id =
12705 param->peer_info[i].vdev_id;
12706 peer_info->pdev_id =
12707 wmi_handle->ops->convert_pdev_id_host_to_target(
12708 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012709 peer_info++;
12710 }
12711
12712 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12713 WMI_PEER_BWF_REQUEST_CMDID);
12714
12715 if (retval != QDF_STATUS_SUCCESS) {
12716 WMI_LOGE("%s : WMI Failed\n", __func__);
12717 wmi_buf_free(buf);
12718 }
12719
12720 return retval;
12721}
12722
12723/**
12724 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
12725 * @wmi_handle: wmi handle
12726 * @param: pointer to hold mcast update param
12727 *
12728 * Return: 0 for success or error code
12729 */
12730static QDF_STATUS
12731send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
12732 struct mcast_group_update_params *param)
12733{
12734 wmi_peer_mcast_group_cmd_fixed_param *cmd;
12735 wmi_buf_t buf;
12736 QDF_STATUS ret;
12737 int32_t len;
12738 int offset = 0;
12739 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
12740
12741 len = sizeof(*cmd);
12742 buf = wmi_buf_alloc(wmi_handle, len);
12743 if (!buf) {
12744 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12745 return QDF_STATUS_E_FAILURE;
12746 }
12747 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
12748 WMITLV_SET_HDR(&cmd->tlv_header,
12749 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
12750 WMITLV_GET_STRUCT_TLVLEN(
12751 wmi_peer_mcast_group_cmd_fixed_param));
12752 /* confirm the buffer is 4-byte aligned */
12753 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
12754 qdf_mem_zero(cmd, sizeof(*cmd));
12755
12756 cmd->vdev_id = param->vap_id;
12757 /* construct the message assuming our endianness matches the target */
12758 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
12759 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
12760 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
12761 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
12762 if (param->is_action_delete)
12763 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
12764
12765 if (param->is_mcast_addr_len)
12766 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
12767
12768 if (param->is_filter_mode_snoop)
12769 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
12770
12771 /* unicast address spec only applies for non-wildcard cases */
12772 if (!param->wildcard && param->ucast_mac_addr) {
12773 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
12774 &cmd->ucast_mac_addr);
12775 }
Amar Singhal5593c902017-10-03 13:00:29 -070012776
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012777 if (param->mcast_ip_addr) {
12778 QDF_ASSERT(param->mcast_ip_addr_bytes <=
12779 sizeof(cmd->mcast_ip_addr));
12780 offset = sizeof(cmd->mcast_ip_addr) -
12781 param->mcast_ip_addr_bytes;
12782 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
12783 param->mcast_ip_addr,
12784 param->mcast_ip_addr_bytes);
12785 }
12786 if (!param->mask)
12787 param->mask = &dummymask[0];
12788
12789 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
12790 param->mask,
12791 param->mcast_ip_addr_bytes);
12792
12793 if (param->srcs && param->nsrcs) {
12794 cmd->num_filter_addr = param->nsrcs;
12795 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
12796 sizeof(cmd->filter_addr));
12797
12798 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
12799 param->nsrcs * param->mcast_ip_addr_bytes);
12800 }
12801
12802 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12803 WMI_PEER_MCAST_GROUP_CMDID);
12804
12805 if (ret != QDF_STATUS_SUCCESS) {
12806 WMI_LOGE("%s : WMI Failed\n", __func__);
12807 wmi_buf_free(buf);
12808 }
12809
12810 return ret;
12811}
12812
12813/**
12814 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12815 * command to fw
12816 * @wmi_handle: wmi handle
12817 * @param: pointer to hold spectral config parameter
12818 *
12819 * Return: 0 for success or error code
12820 */
12821static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12822 struct vdev_spectral_configure_params *param)
12823{
12824 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12825 wmi_buf_t buf;
12826 QDF_STATUS ret;
12827 int32_t len;
12828
12829 len = sizeof(*cmd);
12830 buf = wmi_buf_alloc(wmi_handle, len);
12831 if (!buf) {
12832 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12833 return QDF_STATUS_E_FAILURE;
12834 }
12835
12836 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12837 WMITLV_SET_HDR(&cmd->tlv_header,
12838 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12839 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012840 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012841
12842 cmd->vdev_id = param->vdev_id;
12843 cmd->spectral_scan_count = param->count;
12844 cmd->spectral_scan_period = param->period;
12845 cmd->spectral_scan_priority = param->spectral_pri;
12846 cmd->spectral_scan_fft_size = param->fft_size;
12847 cmd->spectral_scan_gc_ena = param->gc_enable;
12848 cmd->spectral_scan_restart_ena = param->restart_enable;
12849 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12850 cmd->spectral_scan_init_delay = param->init_delay;
12851 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12852 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12853 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12854 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12855 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12856 cmd->spectral_scan_pwr_format = param->pwr_format;
12857 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12858 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012859 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012860 cmd->spectral_scan_chn_mask = param->chn_mask;
12861
12862 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12863 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12864
12865 if (ret != 0) {
12866 WMI_LOGE("Sending set quiet cmd failed\n");
12867 wmi_buf_free(buf);
12868 }
12869
12870 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12871 __func__);
12872
12873 WMI_LOGI("vdev_id = %u\n"
12874 "spectral_scan_count = %u\n"
12875 "spectral_scan_period = %u\n"
12876 "spectral_scan_priority = %u\n"
12877 "spectral_scan_fft_size = %u\n"
12878 "spectral_scan_gc_ena = %u\n"
12879 "spectral_scan_restart_ena = %u\n"
12880 "spectral_scan_noise_floor_ref = %u\n"
12881 "spectral_scan_init_delay = %u\n"
12882 "spectral_scan_nb_tone_thr = %u\n"
12883 "spectral_scan_str_bin_thr = %u\n"
12884 "spectral_scan_wb_rpt_mode = %u\n"
12885 "spectral_scan_rssi_rpt_mode = %u\n"
12886 "spectral_scan_rssi_thr = %u\n"
12887 "spectral_scan_pwr_format = %u\n"
12888 "spectral_scan_rpt_mode = %u\n"
12889 "spectral_scan_bin_scale = %u\n"
12890 "spectral_scan_dBm_adj = %u\n"
12891 "spectral_scan_chn_mask = %u\n",
12892 param->vdev_id,
12893 param->count,
12894 param->period,
12895 param->spectral_pri,
12896 param->fft_size,
12897 param->gc_enable,
12898 param->restart_enable,
12899 param->noise_floor_ref,
12900 param->init_delay,
12901 param->nb_tone_thr,
12902 param->str_bin_thr,
12903 param->wb_rpt_mode,
12904 param->rssi_rpt_mode,
12905 param->rssi_thr,
12906 param->pwr_format,
12907 param->rpt_mode,
12908 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012909 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012910 param->chn_mask);
12911 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12912
12913 return ret;
12914}
12915
12916/**
12917 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12918 * command to fw
12919 * @wmi_handle: wmi handle
12920 * @param: pointer to hold spectral enable parameter
12921 *
12922 * Return: 0 for success or error code
12923 */
12924static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12925 struct vdev_spectral_enable_params *param)
12926{
12927 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12928 wmi_buf_t buf;
12929 QDF_STATUS ret;
12930 int32_t len;
12931
12932 len = sizeof(*cmd);
12933 buf = wmi_buf_alloc(wmi_handle, len);
12934 if (!buf) {
12935 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12936 return QDF_STATUS_E_FAILURE;
12937 }
12938
12939 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12940 WMITLV_SET_HDR(&cmd->tlv_header,
12941 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12942 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012943 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012944
12945 cmd->vdev_id = param->vdev_id;
12946
12947 if (param->active_valid) {
12948 cmd->trigger_cmd = param->active ? 1 : 2;
12949 /* 1: Trigger, 2: Clear Trigger */
12950 } else {
12951 cmd->trigger_cmd = 0; /* 0: Ignore */
12952 }
12953
12954 if (param->enabled_valid) {
12955 cmd->enable_cmd = param->enabled ? 1 : 2;
12956 /* 1: Enable 2: Disable */
12957 } else {
12958 cmd->enable_cmd = 0; /* 0: Ignore */
12959 }
12960
12961 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12962 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12963
12964 if (ret != 0) {
12965 WMI_LOGE("Sending scan enable CMD failed\n");
12966 wmi_buf_free(buf);
12967 }
12968
12969 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12970
12971 WMI_LOGI("vdev_id = %u\n"
12972 "trigger_cmd = %u\n"
12973 "enable_cmd = %u\n",
12974 cmd->vdev_id,
12975 cmd->trigger_cmd,
12976 cmd->enable_cmd);
12977
12978 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12979
12980 return ret;
12981}
12982
12983/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012984 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12985 * @param wmi_handle : handle to WMI.
12986 * @param param : pointer to hold thermal mitigation param
12987 *
12988 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12989 */
12990static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12991 wmi_unified_t wmi_handle,
12992 struct thermal_mitigation_params *param)
12993{
12994 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12995 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12996 wmi_buf_t buf = NULL;
12997 uint8_t *buf_ptr = NULL;
12998 int error;
12999 int32_t len;
13000 int i;
13001
13002 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
13003 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
13004
13005 buf = wmi_buf_alloc(wmi_handle, len);
13006 if (!buf) {
13007 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13008 return QDF_STATUS_E_NOMEM;
13009 }
13010 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
13011
13012 /* init fixed params */
13013 WMITLV_SET_HDR(tt_conf,
13014 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
13015 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
13016
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013017 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13018 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053013019 tt_conf->enable = param->enable;
13020 tt_conf->dc = param->dc;
13021 tt_conf->dc_per_event = param->dc_per_event;
13022 tt_conf->therm_throt_levels = THERMAL_LEVELS;
13023
13024 buf_ptr = (uint8_t *) ++tt_conf;
13025 /* init TLV params */
13026 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13027 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
13028
13029 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
13030 for (i = 0; i < THERMAL_LEVELS; i++) {
13031 WMITLV_SET_HDR(&lvl_conf->tlv_header,
13032 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
13033 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
13034 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
13035 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
13036 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
13037 lvl_conf->prio = param->levelconf[i].priority;
13038 lvl_conf++;
13039 }
13040
13041 error = wmi_unified_cmd_send(wmi_handle, buf, len,
13042 WMI_THERM_THROT_SET_CONF_CMDID);
13043 if (QDF_IS_STATUS_ERROR(error)) {
13044 wmi_buf_free(buf);
13045 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
13046 }
13047
13048 return error;
13049}
13050
13051/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013052 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
13053 * @wmi_handle: wmi handle
13054 * @param: pointer to pdev_qvit_params
13055 *
13056 * Return: 0 for success or error code
13057 */
13058static QDF_STATUS
13059send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
13060 struct pdev_qvit_params *param)
13061{
13062 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013063 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013064 uint8_t *cmd;
13065 static uint8_t msgref = 1;
13066 uint8_t segnumber = 0, seginfo, numsegments;
13067 uint16_t chunk_len, total_bytes;
13068 uint8_t *bufpos;
13069 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
13070
13071 bufpos = param->utf_payload;
13072 total_bytes = param->len;
13073 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
13074 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
13075 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
13076
13077 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
13078 numsegments++;
13079
13080 while (param->len) {
13081 if (param->len > MAX_WMI_QVIT_LEN)
13082 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
13083 else
13084 chunk_len = param->len;
13085
13086 buf = wmi_buf_alloc(wmi_handle,
13087 (chunk_len + sizeof(seghdrinfo) +
13088 WMI_TLV_HDR_SIZE));
13089 if (!buf) {
13090 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
13091 return QDF_STATUS_E_NOMEM;
13092 }
13093
13094 cmd = (uint8_t *) wmi_buf_data(buf);
13095
13096 seghdrinfo.len = total_bytes;
13097 seghdrinfo.msgref = msgref;
13098 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
13099 seghdrinfo.segmentInfo = seginfo;
13100
13101 segnumber++;
13102
13103 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
13104 (chunk_len + sizeof(seghdrinfo)));
13105 cmd += WMI_TLV_HDR_SIZE;
13106 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
13107 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
13108
13109 ret = wmi_unified_cmd_send(wmi_handle, buf,
13110 (chunk_len + sizeof(seghdrinfo) +
13111 WMI_TLV_HDR_SIZE),
13112 WMI_PDEV_QVIT_CMDID);
13113
13114 if (ret != 0) {
13115 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
13116 wmi_buf_free(buf);
13117 break;
13118 }
13119
13120 param->len -= chunk_len;
13121 bufpos += chunk_len;
13122 }
13123 msgref++;
13124
13125 return ret;
13126}
13127
13128/**
13129 * send_wmm_update_cmd_tlv() - send wmm update command to fw
13130 * @wmi_handle: wmi handle
13131 * @param: pointer to wmm update param
13132 *
13133 * Return: 0 for success or error code
13134 */
13135static QDF_STATUS
13136send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
13137 struct wmm_update_params *param)
13138{
13139 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
13140 wmi_wmm_params *wmm_param;
13141 wmi_buf_t buf;
13142 QDF_STATUS ret;
13143 int32_t len;
13144 int ac = 0;
13145 struct wmi_host_wmeParams *wmep;
13146 uint8_t *buf_ptr;
13147
13148 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
13149 buf = wmi_buf_alloc(wmi_handle, len);
13150 if (!buf) {
13151 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13152 return QDF_STATUS_E_FAILURE;
13153 }
13154
13155 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13156 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
13157 WMITLV_SET_HDR(&cmd->tlv_header,
13158 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
13159 WMITLV_GET_STRUCT_TLVLEN
13160 (wmi_pdev_set_wmm_params_cmd_fixed_param));
13161
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013162 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053013163
13164 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
13165
13166 for (ac = 0; ac < WME_NUM_AC; ac++) {
13167 wmep = &param->wmep_array[ac];
13168 wmm_param = (wmi_wmm_params *)buf_ptr;
13169 WMITLV_SET_HDR(&wmm_param->tlv_header,
13170 WMITLV_TAG_STRUC_wmi_wmm_params,
13171 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
13172 wmm_param->aifs = wmep->wmep_aifsn;
13173 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
13174 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
13175 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
13176 wmm_param->acm = wmep->wmep_acm;
13177 wmm_param->no_ack = wmep->wmep_noackPolicy;
13178 buf_ptr += sizeof(wmi_wmm_params);
13179 }
13180 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13181 WMI_PDEV_SET_WMM_PARAMS_CMDID);
13182
13183 if (ret != 0) {
13184 WMI_LOGE("Sending WMM update CMD failed\n");
13185 wmi_buf_free(buf);
13186 }
13187
13188 return ret;
13189}
13190
Sathish Kumar80f4f382017-04-24 11:36:00 +053013191/**
13192 * send_coex_config_cmd_tlv() - send coex config command to fw
13193 * @wmi_handle: wmi handle
13194 * @param: pointer to coex config param
13195 *
13196 * Return: 0 for success or error code
13197 */
13198static QDF_STATUS
13199send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
13200 struct coex_config_params *param)
13201{
13202 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
13203 wmi_buf_t buf;
13204 QDF_STATUS ret;
13205 int32_t len;
13206
13207 len = sizeof(*cmd);
13208 buf = wmi_buf_alloc(wmi_handle, len);
13209 if (!buf) {
13210 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
13211 return QDF_STATUS_E_FAILURE;
13212 }
13213
13214 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
13215 WMITLV_SET_HDR(&cmd->tlv_header,
13216 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
13217 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053013218 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053013219
13220 cmd->vdev_id = param->vdev_id;
13221 cmd->config_type = param->config_type;
13222 cmd->config_arg1 = param->config_arg1;
13223 cmd->config_arg2 = param->config_arg2;
13224 cmd->config_arg3 = param->config_arg3;
13225 cmd->config_arg4 = param->config_arg4;
13226 cmd->config_arg5 = param->config_arg5;
13227 cmd->config_arg6 = param->config_arg6;
13228
13229 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13230 WMI_COEX_CONFIG_CMDID);
13231
13232 if (ret != 0) {
13233 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
13234 wmi_buf_free(buf);
13235 }
13236
13237 return ret;
13238}
13239
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013240static
Govind Singh9ddd5162016-03-07 16:30:32 +053013241void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053013242 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053013243{
Govind Singhe7f2f342016-05-23 12:12:52 +053013244 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053013245 resource_cfg->num_peers = tgt_res_cfg->num_peers;
13246 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
13247 resource_cfg->num_offload_reorder_buffs =
13248 tgt_res_cfg->num_offload_reorder_buffs;
13249 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
13250 resource_cfg->num_tids = tgt_res_cfg->num_tids;
13251 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
13252 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
13253 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
13254 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
13255 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
13256 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
13257 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
13258 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
13259 resource_cfg->scan_max_pending_req =
13260 tgt_res_cfg->scan_max_pending_req;
13261 resource_cfg->bmiss_offload_max_vdev =
13262 tgt_res_cfg->bmiss_offload_max_vdev;
13263 resource_cfg->roam_offload_max_vdev =
13264 tgt_res_cfg->roam_offload_max_vdev;
13265 resource_cfg->roam_offload_max_ap_profiles =
13266 tgt_res_cfg->roam_offload_max_ap_profiles;
13267 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
13268 resource_cfg->num_mcast_table_elems =
13269 tgt_res_cfg->num_mcast_table_elems;
13270 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
13271 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
13272 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
13273 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
13274 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
13275 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
13276 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
13277 resource_cfg->vow_config = tgt_res_cfg->vow_config;
13278 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
13279 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
13280 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
13281 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
13282 resource_cfg->num_tdls_conn_table_entries =
13283 tgt_res_cfg->num_tdls_conn_table_entries;
13284 resource_cfg->beacon_tx_offload_max_vdev =
13285 tgt_res_cfg->beacon_tx_offload_max_vdev;
13286 resource_cfg->num_multicast_filter_entries =
13287 tgt_res_cfg->num_multicast_filter_entries;
13288 resource_cfg->num_wow_filters =
13289 tgt_res_cfg->num_wow_filters;
13290 resource_cfg->num_keep_alive_pattern =
13291 tgt_res_cfg->num_keep_alive_pattern;
13292 resource_cfg->keep_alive_pattern_size =
13293 tgt_res_cfg->keep_alive_pattern_size;
13294 resource_cfg->max_tdls_concurrent_sleep_sta =
13295 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
13296 resource_cfg->max_tdls_concurrent_buffer_sta =
13297 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
13298 resource_cfg->wmi_send_separate =
13299 tgt_res_cfg->wmi_send_separate;
13300 resource_cfg->num_ocb_vdevs =
13301 tgt_res_cfg->num_ocb_vdevs;
13302 resource_cfg->num_ocb_channels =
13303 tgt_res_cfg->num_ocb_channels;
13304 resource_cfg->num_ocb_schedules =
13305 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053013306 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
13307 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
13308 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013309 resource_cfg->max_num_dbs_scan_duty_cycle =
13310 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080013311 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080013312 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
13313 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053013314
Mukul Sharmad7c9e332017-11-02 17:42:36 +053013315 if (tgt_res_cfg->atf_config)
13316 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
13317 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
13318 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
13319 resource_cfg->flag1, 1);
13320 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
13321 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
13322 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053013323 if (tgt_res_cfg->cce_disable)
13324 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Govind Singh9ddd5162016-03-07 16:30:32 +053013325}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013326
13327/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13328 * @wmi_handle: pointer to wmi handle
13329 * @buf_ptr: pointer to current position in init command buffer
13330 * @len: pointer to length. This will be updated with current lenght of cmd
13331 * @param: point host parameters for init command
13332 *
13333 * Return: Updated pointer of buf_ptr.
13334 */
13335static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
13336 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
13337{
13338 uint16_t idx;
13339
13340 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13341 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13342 wmi_pdev_band_to_mac *band_to_mac;
13343
13344 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13345 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13346 sizeof(wmi_resource_config) +
13347 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13348 sizeof(wlan_host_memory_chunk)));
13349
13350 WMITLV_SET_HDR(&hw_mode->tlv_header,
13351 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13352 (WMITLV_GET_STRUCT_TLVLEN
13353 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13354
13355 hw_mode->hw_mode_index = param->hw_mode_id;
13356 hw_mode->num_band_to_mac = param->num_band_to_mac;
13357
13358 buf_ptr = (uint8_t *) (hw_mode + 1);
13359 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13360 WMI_TLV_HDR_SIZE);
13361 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13362 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13363 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13364 WMITLV_GET_STRUCT_TLVLEN
13365 (wmi_pdev_band_to_mac));
13366 band_to_mac[idx].pdev_id =
13367 wmi_handle->ops->convert_pdev_id_host_to_target(
13368 param->band_to_mac[idx].pdev_id);
13369 band_to_mac[idx].start_freq =
13370 param->band_to_mac[idx].start_freq;
13371 band_to_mac[idx].end_freq =
13372 param->band_to_mac[idx].end_freq;
13373 }
13374 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13375 (param->num_band_to_mac *
13376 sizeof(wmi_pdev_band_to_mac)) +
13377 WMI_TLV_HDR_SIZE;
13378
13379 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13380 (param->num_band_to_mac *
13381 sizeof(wmi_pdev_band_to_mac)));
13382 }
13383
13384 return buf_ptr;
13385}
13386
13387static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
13388 wmi_init_cmd_fixed_param *cmd)
13389{
13390 int num_whitelist;
13391 wmi_abi_version my_vers;
13392
13393 num_whitelist = sizeof(version_whitelist) /
13394 sizeof(wmi_whitelist_version_info);
13395 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
13396 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
13397 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
13398 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
13399 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
13400 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
13401
13402 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
13403 &my_vers,
13404 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
13405 &cmd->host_abi_vers);
13406
13407 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
13408 __func__,
13409 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
13410 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
13411 cmd->host_abi_vers.abi_version_ns_0,
13412 cmd->host_abi_vers.abi_version_ns_1,
13413 cmd->host_abi_vers.abi_version_ns_2,
13414 cmd->host_abi_vers.abi_version_ns_3);
13415
13416 /* Save version sent from host -
13417 * Will be used to check ready event
13418 */
13419 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
13420 sizeof(wmi_abi_version));
13421}
13422
Sathish Kumarfd347372017-02-13 12:29:09 +053013423static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053013424{
13425 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
13426 wmi_service_ready_event_fixed_param *ev;
13427
13428
13429 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
13430
13431 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
13432 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053013433 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013434
13435 /*Save fw version from service ready message */
13436 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053013437 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013438 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013439
Govind Singhb53420c2016-03-09 14:32:57 +053013440 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013441}
13442
13443/**
13444 * wmi_unified_save_fw_version_cmd() - save fw version
13445 * @wmi_handle: pointer to wmi handle
13446 * @res_cfg: resource config
13447 * @num_mem_chunks: no of mem chunck
13448 * @mem_chunk: pointer to mem chunck structure
13449 *
13450 * This function sends IE information to firmware
13451 *
Govind Singhb53420c2016-03-09 14:32:57 +053013452 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053013453 *
13454 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013455static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053013456 void *evt_buf)
13457{
13458 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
13459 wmi_ready_event_fixed_param *ev = NULL;
13460
13461 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
13462 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053013463 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
13464 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013465 &ev->fw_abi_vers)) {
13466 /*
13467 * Error: Our host version and the given firmware version
13468 * are incompatible.
13469 **/
Govind Singhb53420c2016-03-09 14:32:57 +053013470 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053013471 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
13472 __func__,
13473 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
13474 abi_version_0),
13475 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
13476 abi_version_0),
13477 wmi_handle->final_abi_vers.abi_version_ns_0,
13478 wmi_handle->final_abi_vers.abi_version_ns_1,
13479 wmi_handle->final_abi_vers.abi_version_ns_2,
13480 wmi_handle->final_abi_vers.abi_version_ns_3,
13481 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
13482 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
13483 ev->fw_abi_vers.abi_version_ns_0,
13484 ev->fw_abi_vers.abi_version_ns_1,
13485 ev->fw_abi_vers.abi_version_ns_2,
13486 ev->fw_abi_vers.abi_version_ns_3);
13487
Govind Singhb53420c2016-03-09 14:32:57 +053013488 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053013489 }
Govind Singhb53420c2016-03-09 14:32:57 +053013490 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013491 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053013492 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053013493 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053013494
Govind Singhb53420c2016-03-09 14:32:57 +053013495 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053013496}
Govind Singha4836fd2016-03-07 16:45:38 +053013497
13498/**
13499 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
13500 * @wmi_handle: wmi handle
13501 * @custom_addr: base mac address
13502 *
Govind Singhe7f2f342016-05-23 12:12:52 +053013503 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053013504 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013505static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013506 uint8_t *custom_addr)
13507{
13508 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
13509 wmi_buf_t buf;
13510 int err;
13511
13512 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13513 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013514 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053013515 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013516 }
13517
13518 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013519 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053013520
13521 WMITLV_SET_HDR(&cmd->tlv_header,
13522 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
13523 WMITLV_GET_STRUCT_TLVLEN
13524 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
13525 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013526 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13527 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013528 err = wmi_unified_cmd_send(wmi_handle, buf,
13529 sizeof(*cmd),
13530 WMI_PDEV_SET_BASE_MACADDR_CMDID);
13531 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053013532 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053013533 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013534 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013535 }
13536
13537 return 0;
13538}
13539
13540/**
13541 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
13542 * @handle: wmi handle
13543 * @event: Event received from FW
13544 * @len: Length of the event
13545 *
13546 * Enables the low frequency events and disables the high frequency
13547 * events. Bit 17 indicates if the event if low/high frequency.
13548 * 1 - high frequency, 0 - low frequency
13549 *
13550 * Return: 0 on successfully enabling/disabling the events
13551 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013552static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013553 uint8_t *event,
13554 uint32_t len)
13555{
13556 uint32_t num_of_diag_events_logs;
13557 wmi_diag_event_log_config_fixed_param *cmd;
13558 wmi_buf_t buf;
13559 uint8_t *buf_ptr;
13560 uint32_t *cmd_args, *evt_args;
13561 uint32_t buf_len, i;
13562
13563 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
13564 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
13565
Govind Singhb53420c2016-03-09 14:32:57 +053013566 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053013567
13568 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
13569 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013570 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053013571 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013572 }
13573 wmi_event = param_buf->fixed_param;
13574 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070013575
13576 if (num_of_diag_events_logs >
13577 param_buf->num_diag_events_logs_list) {
13578 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
13579 num_of_diag_events_logs,
13580 param_buf->num_diag_events_logs_list);
13581 return QDF_STATUS_E_INVAL;
13582 }
13583
Govind Singha4836fd2016-03-07 16:45:38 +053013584 evt_args = param_buf->diag_events_logs_list;
13585 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053013586 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013587 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053013588 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013589 }
13590
Govind Singhb53420c2016-03-09 14:32:57 +053013591 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013592 __func__, num_of_diag_events_logs);
13593
13594 /* Free any previous allocation */
13595 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053013596 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013597
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070013598 if (num_of_diag_events_logs >
13599 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
13600 WMI_LOGE("%s: excess num of logs:%d", __func__,
13601 num_of_diag_events_logs);
13602 QDF_ASSERT(0);
13603 return QDF_STATUS_E_INVAL;
13604 }
Govind Singha4836fd2016-03-07 16:45:38 +053013605 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053013606 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053013607 sizeof(uint32_t));
13608 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013609 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013610 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013611 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013612 }
13613 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
13614
13615 /* Prepare the send buffer */
13616 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13617 (num_of_diag_events_logs * sizeof(uint32_t));
13618
13619 buf = wmi_buf_alloc(wmi_handle, buf_len);
13620 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013621 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13622 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053013623 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013624 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013625 }
13626
13627 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13628 buf_ptr = (uint8_t *) cmd;
13629
13630 WMITLV_SET_HDR(&cmd->tlv_header,
13631 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13632 WMITLV_GET_STRUCT_TLVLEN(
13633 wmi_diag_event_log_config_fixed_param));
13634
13635 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
13636
13637 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13638
13639 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13640 (num_of_diag_events_logs * sizeof(uint32_t)));
13641
13642 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13643
13644 /* Populate the events */
13645 for (i = 0; i < num_of_diag_events_logs; i++) {
13646 /* Low freq (0) - Enable (1) the event
13647 * High freq (1) - Disable (0) the event
13648 */
13649 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
13650 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
13651 /* Set the event ID */
13652 WMI_DIAG_ID_SET(cmd_args[i],
13653 WMI_DIAG_ID_GET(evt_args[i]));
13654 /* Set the type */
13655 WMI_DIAG_TYPE_SET(cmd_args[i],
13656 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053013657 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053013658 wmi_handle->events_logs_list[i] = evt_args[i];
13659 }
13660
13661 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
13662 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013663 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013664 __func__);
13665 wmi_buf_free(buf);
13666 /* Not clearing events_logs_list, though wmi cmd failed.
13667 * Host can still have this list
13668 */
Govind Singh67922e82016-04-01 16:48:57 +053013669 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013670 }
13671
13672 return 0;
13673}
13674
13675/**
13676 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
13677 * @wmi_handle: wmi handle
13678 * @start_log: Start logging related parameters
13679 *
13680 * Send the command to the FW based on which specific logging of diag
13681 * event/log id can be started/stopped
13682 *
13683 * Return: None
13684 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013685static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013686 struct wmi_wifi_start_log *start_log)
13687{
13688 wmi_diag_event_log_config_fixed_param *cmd;
13689 wmi_buf_t buf;
13690 uint8_t *buf_ptr;
13691 uint32_t len, count, log_level, i;
13692 uint32_t *cmd_args;
13693 uint32_t total_len;
13694 count = 0;
13695
13696 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053013697 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053013698 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013699 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013700 }
13701 /* total_len stores the number of events where BITS 17 and 18 are set.
13702 * i.e., events of high frequency (17) and for extended debugging (18)
13703 */
13704 total_len = 0;
13705 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13706 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
13707 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
13708 total_len++;
13709 }
13710
13711 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
13712 (total_len * sizeof(uint32_t));
13713
13714 buf = wmi_buf_alloc(wmi_handle, len);
13715 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013716 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013717 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013718 }
13719 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
13720 buf_ptr = (uint8_t *) cmd;
13721
13722 WMITLV_SET_HDR(&cmd->tlv_header,
13723 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
13724 WMITLV_GET_STRUCT_TLVLEN(
13725 wmi_diag_event_log_config_fixed_param));
13726
13727 cmd->num_of_diag_events_logs = total_len;
13728
13729 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
13730
13731 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13732 (total_len * sizeof(uint32_t)));
13733
13734 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13735
Govind Singh224a7312016-06-21 14:33:26 +053013736 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053013737 log_level = 1;
13738 else
13739 log_level = 0;
13740
Govind Singhb53420c2016-03-09 14:32:57 +053013741 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053013742 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
13743 uint32_t val = wmi_handle->events_logs_list[i];
13744 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
13745 (WMI_DIAG_EXT_FEATURE_GET(val))) {
13746
13747 WMI_DIAG_ID_SET(cmd_args[count],
13748 WMI_DIAG_ID_GET(val));
13749 WMI_DIAG_TYPE_SET(cmd_args[count],
13750 WMI_DIAG_TYPE_GET(val));
13751 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
13752 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053013753 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053013754 count++;
13755 }
13756 }
13757
13758 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13759 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013760 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053013761 __func__);
13762 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013763 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013764 }
13765
Govind Singhb53420c2016-03-09 14:32:57 +053013766 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013767}
13768
13769/**
13770 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
13771 * @wmi_handle: WMI handle
13772 *
13773 * This function is used to send the flush command to the FW,
13774 * that will flush the fw logs that are residue in the FW
13775 *
13776 * Return: None
13777 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013778static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053013779{
13780 wmi_debug_mesg_flush_fixed_param *cmd;
13781 wmi_buf_t buf;
13782 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053013783 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013784
13785 buf = wmi_buf_alloc(wmi_handle, len);
13786 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013787 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053013788 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013789 }
13790
13791 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
13792 WMITLV_SET_HDR(&cmd->tlv_header,
13793 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13794 WMITLV_GET_STRUCT_TLVLEN(
13795 wmi_debug_mesg_flush_fixed_param));
13796 cmd->reserved0 = 0;
13797
13798 ret = wmi_unified_cmd_send(wmi_handle,
13799 buf,
13800 len,
13801 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013802 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013803 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013804 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013805 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013806 }
Govind Singhb53420c2016-03-09 14:32:57 +053013807 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013808
Govind Singh67922e82016-04-01 16:48:57 +053013809 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013810}
13811
13812/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013813 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013814 * @wmi_handle: wmi handle
13815 * @msg: PCL structure containing the PCL and the number of channels
13816 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013817 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013818 * firmware. The DBS Manager is the consumer of this information in the WLAN
13819 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13820 * to migrate to a new channel without host driver involvement. An example of
13821 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13822 * manage the channel selection without firmware involvement.
13823 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013824 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13825 * channel list. The weights corresponds to the channels sent in
13826 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13827 * weightage compared to the non PCL channels.
13828 *
Govind Singha4836fd2016-03-07 16:45:38 +053013829 * Return: Success if the cmd is sent successfully to the firmware
13830 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013831static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013832 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013833{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013834 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013835 wmi_buf_t buf;
13836 uint8_t *buf_ptr;
13837 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013838 uint32_t chan_len;
13839
13840 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013841
13842 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013843 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013844
13845 buf = wmi_buf_alloc(wmi_handle, len);
13846 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013847 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13848 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013849 }
13850
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013851 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013852 buf_ptr = (uint8_t *) cmd;
13853 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013854 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13855 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013856
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013857 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13858 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013859 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013860 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013861
13862 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013863 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013864 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013865 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013866 for (i = 0; i < chan_len ; i++) {
13867 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013868 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013869 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013870 }
13871 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013872 WMI_PDEV_SET_PCL_CMDID)) {
13873 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013874 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013875 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013876 }
Govind Singhb53420c2016-03-09 14:32:57 +053013877 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013878}
13879
13880/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013881 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013882 * @wmi_handle: wmi handle
13883 * @msg: Structure containing the following parameters
13884 *
13885 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13886 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13887 *
13888 * Provides notification to the WLAN firmware that host driver is requesting a
13889 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13890 * configurations that include the Dual Band Simultaneous (DBS) feature.
13891 *
13892 * Return: Success if the cmd is sent successfully to the firmware
13893 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013894static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013895 uint32_t hw_mode_index)
13896{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013897 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013898 wmi_buf_t buf;
13899 uint32_t len;
13900
13901 len = sizeof(*cmd);
13902
13903 buf = wmi_buf_alloc(wmi_handle, len);
13904 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013905 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13906 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013907 }
13908
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013909 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013910 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013911 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13912 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13913
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013914 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13915 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013916 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013917 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013918
13919 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013920 WMI_PDEV_SET_HW_MODE_CMDID)) {
13921 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013922 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013923 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013924 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013925 }
13926
Govind Singhb53420c2016-03-09 14:32:57 +053013927 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013928}
13929
13930/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013931 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013932 * @wmi_handle: wmi handle
13933 * @msg: Dual MAC config parameters
13934 *
13935 * Configures WLAN firmware with the dual MAC features
13936 *
Govind Singhb53420c2016-03-09 14:32:57 +053013937 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013938 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013939static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013940QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013941 struct wmi_dual_mac_config *msg)
13942{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013943 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013944 wmi_buf_t buf;
13945 uint32_t len;
13946
13947 len = sizeof(*cmd);
13948
13949 buf = wmi_buf_alloc(wmi_handle, len);
13950 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013951 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13952 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013953 }
13954
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013955 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013956 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013957 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013958 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013959 wmi_pdev_set_mac_config_cmd_fixed_param));
13960
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013961 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13962 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013963 cmd->concurrent_scan_config_bits = msg->scan_config;
13964 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013965 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013966 __func__, msg->scan_config, msg->fw_mode_config);
13967
13968 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013969 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13970 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013971 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013972 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013973 }
Govind Singhb53420c2016-03-09 14:32:57 +053013974 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013975}
13976
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013977#ifdef BIG_ENDIAN_HOST
13978/**
13979* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13980* @param data_len - data length
13981* @param data - pointer to data
13982*
13983* Return: QDF_STATUS - success or error status
13984*/
13985static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13986 struct fips_params *param)
13987{
13988 unsigned char *key_unaligned, *data_unaligned;
13989 int c;
13990 u_int8_t *key_aligned = NULL;
13991 u_int8_t *data_aligned = NULL;
13992
13993 /* Assigning unaligned space to copy the key */
13994 key_unaligned = qdf_mem_malloc(
13995 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13996 data_unaligned = qdf_mem_malloc(
13997 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13998
13999 /* Checking if kmalloc is succesful to allocate space */
14000 if (key_unaligned == NULL)
14001 return QDF_STATUS_SUCCESS;
14002 /* Checking if space is aligned */
14003 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
14004 /* align to 4 */
14005 key_aligned =
14006 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
14007 FIPS_ALIGN);
14008 } else {
14009 key_aligned = (u_int8_t *)key_unaligned;
14010 }
14011
14012 /* memset and copy content from key to key aligned */
14013 OS_MEMSET(key_aligned, 0, param->key_len);
14014 OS_MEMCPY(key_aligned, param->key, param->key_len);
14015
14016 /* print a hexdump for host debug */
14017 print_hex_dump(KERN_DEBUG,
14018 "\t Aligned and Copied Key:@@@@ ",
14019 DUMP_PREFIX_NONE,
14020 16, 1, key_aligned, param->key_len, true);
14021
14022 /* Checking if kmalloc is succesful to allocate space */
14023 if (data_unaligned == NULL)
14024 return QDF_STATUS_SUCCESS;
14025 /* Checking of space is aligned */
14026 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
14027 /* align to 4 */
14028 data_aligned =
14029 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
14030 FIPS_ALIGN);
14031 } else {
14032 data_aligned = (u_int8_t *)data_unaligned;
14033 }
14034
14035 /* memset and copy content from data to data aligned */
14036 OS_MEMSET(data_aligned, 0, param->data_len);
14037 OS_MEMCPY(data_aligned, param->data, param->data_len);
14038
14039 /* print a hexdump for host debug */
14040 print_hex_dump(KERN_DEBUG,
14041 "\t Properly Aligned and Copied Data:@@@@ ",
14042 DUMP_PREFIX_NONE,
14043 16, 1, data_aligned, param->data_len, true);
14044
14045 /* converting to little Endian both key_aligned and
14046 * data_aligned*/
14047 for (c = 0; c < param->key_len/4; c++) {
14048 *((u_int32_t *)key_aligned+c) =
14049 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
14050 }
14051 for (c = 0; c < param->data_len/4; c++) {
14052 *((u_int32_t *)data_aligned+c) =
14053 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
14054 }
14055
14056 /* update endian data to key and data vectors */
14057 OS_MEMCPY(param->key, key_aligned, param->key_len);
14058 OS_MEMCPY(param->data, data_aligned, param->data_len);
14059
14060 /* clean up allocated spaces */
14061 qdf_mem_free(key_unaligned);
14062 key_unaligned = NULL;
14063 key_aligned = NULL;
14064
14065 qdf_mem_free(data_unaligned);
14066 data_unaligned = NULL;
14067 data_aligned = NULL;
14068
14069 return QDF_STATUS_SUCCESS;
14070}
14071#else
14072/**
14073* fips_align_data_be() - DUMMY for LE platform
14074*
14075* Return: QDF_STATUS - success
14076*/
14077static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
14078 struct fips_params *param)
14079{
14080 return QDF_STATUS_SUCCESS;
14081}
14082#endif
14083
14084
14085/**
14086 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
14087 * @wmi_handle: wmi handle
14088 * @param: pointer to hold pdev fips param
14089 *
14090 * Return: 0 for success or error code
14091 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014092static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014093send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
14094 struct fips_params *param)
14095{
14096 wmi_pdev_fips_cmd_fixed_param *cmd;
14097 wmi_buf_t buf;
14098 uint8_t *buf_ptr;
14099 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
14100 QDF_STATUS retval = QDF_STATUS_SUCCESS;
14101
14102 /* Length TLV placeholder for array of bytes */
14103 len += WMI_TLV_HDR_SIZE;
14104 if (param->data_len)
14105 len += (param->data_len*sizeof(uint8_t));
14106
14107 /*
14108 * Data length must be multiples of 16 bytes - checked against 0xF -
14109 * and must be less than WMI_SVC_MSG_SIZE - static size of
14110 * wmi_pdev_fips_cmd structure
14111 */
14112
14113 /* do sanity on the input */
14114 if (!(((param->data_len & 0xF) == 0) &&
14115 ((param->data_len > 0) &&
14116 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
14117 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
14118 return QDF_STATUS_E_INVAL;
14119 }
14120
14121 buf = wmi_buf_alloc(wmi_handle, len);
14122 if (!buf) {
14123 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
14124 return QDF_STATUS_E_FAILURE;
14125 }
14126
14127 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14128 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
14129 WMITLV_SET_HDR(&cmd->tlv_header,
14130 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
14131 WMITLV_GET_STRUCT_TLVLEN
14132 (wmi_pdev_fips_cmd_fixed_param));
14133
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014134 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14135 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053014136 if (param->key != NULL && param->data != NULL) {
14137 cmd->key_len = param->key_len;
14138 cmd->data_len = param->data_len;
14139 cmd->fips_cmd = !!(param->op);
14140
14141 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
14142 return QDF_STATUS_E_FAILURE;
14143
14144 qdf_mem_copy(cmd->key, param->key, param->key_len);
14145
14146 if (param->mode == FIPS_ENGINE_AES_CTR ||
14147 param->mode == FIPS_ENGINE_AES_MIC) {
14148 cmd->mode = param->mode;
14149 } else {
14150 cmd->mode = FIPS_ENGINE_AES_CTR;
14151 }
14152 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
14153 cmd->key_len, cmd->data_len);
14154
14155 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
14156 cmd->key, cmd->key_len, true);
14157 buf_ptr += sizeof(*cmd);
14158
14159 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
14160
14161 buf_ptr += WMI_TLV_HDR_SIZE;
14162 if (param->data_len)
14163 qdf_mem_copy(buf_ptr,
14164 (uint8_t *) param->data, param->data_len);
14165
14166 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
14167 16, 1, buf_ptr, cmd->data_len, true);
14168
14169 buf_ptr += param->data_len;
14170
14171 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
14172 WMI_PDEV_FIPS_CMDID);
14173 qdf_print("%s return value %d\n", __func__, retval);
14174 } else {
14175 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
14176 wmi_buf_free(buf);
14177 retval = -QDF_STATUS_E_BADMSG;
14178 }
14179
14180 return retval;
14181}
14182
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014183#ifdef WLAN_PMO_ENABLE
14184/**
14185 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
14186 * @wmi_handle: wmi handle
14187 * @vdev_id: vdev id
14188 * @bitmap: Event bitmap
14189 * @enable: enable/disable
14190 *
14191 * Return: CDF status
14192 */
14193static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
14194 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014195 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014196 bool enable)
14197{
14198 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
14199 uint16_t len;
14200 wmi_buf_t buf;
14201 int ret;
14202
14203 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
14204 buf = wmi_buf_alloc(wmi_handle, len);
14205 if (!buf) {
14206 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14207 return QDF_STATUS_E_NOMEM;
14208 }
14209 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
14210 WMITLV_SET_HDR(&cmd->tlv_header,
14211 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
14212 WMITLV_GET_STRUCT_TLVLEN
14213 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
14214 cmd->vdev_id = vdev_id;
14215 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053014216 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
14217 WMI_WOW_MAX_EVENT_BM_LEN);
14218
14219 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
14220 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
14221 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014222
14223 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14224 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
14225 if (ret) {
14226 WMI_LOGE("Failed to config wow wakeup event");
14227 wmi_buf_free(buf);
14228 return QDF_STATUS_E_FAILURE;
14229 }
14230
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014231 return QDF_STATUS_SUCCESS;
14232}
14233
14234/**
14235 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
14236 * @wmi_handle: wmi handle
14237 * @vdev_id: vdev id
14238 * @ptrn_id: pattern id
14239 * @ptrn: pattern
14240 * @ptrn_len: pattern length
14241 * @ptrn_offset: pattern offset
14242 * @mask: mask
14243 * @mask_len: mask length
14244 * @user: true for user configured pattern and false for default pattern
14245 * @default_patterns: default patterns
14246 *
14247 * Return: CDF status
14248 */
14249static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
14250 uint8_t vdev_id, uint8_t ptrn_id,
14251 const uint8_t *ptrn, uint8_t ptrn_len,
14252 uint8_t ptrn_offset, const uint8_t *mask,
14253 uint8_t mask_len, bool user,
14254 uint8_t default_patterns)
14255{
14256 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14257 WOW_BITMAP_PATTERN_T *bitmap_pattern;
14258 wmi_buf_t buf;
14259 uint8_t *buf_ptr;
14260 int32_t len;
14261 int ret;
14262
14263 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14264 WMI_TLV_HDR_SIZE +
14265 1 * sizeof(WOW_BITMAP_PATTERN_T) +
14266 WMI_TLV_HDR_SIZE +
14267 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14268 WMI_TLV_HDR_SIZE +
14269 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14270 WMI_TLV_HDR_SIZE +
14271 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14272 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014273 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014274
14275 buf = wmi_buf_alloc(wmi_handle, len);
14276 if (!buf) {
14277 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14278 return QDF_STATUS_E_NOMEM;
14279 }
14280
14281 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14282 buf_ptr = (uint8_t *) cmd;
14283
14284 WMITLV_SET_HDR(&cmd->tlv_header,
14285 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14286 WMITLV_GET_STRUCT_TLVLEN
14287 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14288 cmd->vdev_id = vdev_id;
14289 cmd->pattern_id = ptrn_id;
14290
14291 cmd->pattern_type = WOW_BITMAP_PATTERN;
14292 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14293
14294 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14295 sizeof(WOW_BITMAP_PATTERN_T));
14296 buf_ptr += WMI_TLV_HDR_SIZE;
14297 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
14298
14299 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
14300 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
14301 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
14302
14303 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
14304 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
14305
14306 bitmap_pattern->pattern_offset = ptrn_offset;
14307 bitmap_pattern->pattern_len = ptrn_len;
14308
14309 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
14310 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
14311
14312 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
14313 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
14314
14315 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
14316 bitmap_pattern->pattern_id = ptrn_id;
14317
14318 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
14319 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
14320 bitmap_pattern->pattern_offset, user);
14321 WMI_LOGI("Pattern : ");
14322 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14323 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
14324
14325 WMI_LOGI("Mask : ");
14326 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
14327 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
14328
14329 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
14330
14331 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14332 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14333 buf_ptr += WMI_TLV_HDR_SIZE;
14334
14335 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14336 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14337 buf_ptr += WMI_TLV_HDR_SIZE;
14338
14339 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14340 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14341 buf_ptr += WMI_TLV_HDR_SIZE;
14342
14343 /* Fill TLV for pattern_info_timeout but no data. */
14344 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14345 buf_ptr += WMI_TLV_HDR_SIZE;
14346
14347 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053014348 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014349 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053014350 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014351
14352 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14353 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14354 if (ret) {
14355 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
14356 wmi_buf_free(buf);
14357 return QDF_STATUS_E_FAILURE;
14358 }
14359
14360 return QDF_STATUS_SUCCESS;
14361}
14362
Govind Singha4836fd2016-03-07 16:45:38 +053014363/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014364 * fill_arp_offload_params_tlv() - Fill ARP offload data
14365 * @wmi_handle: wmi handle
14366 * @offload_req: offload request
14367 * @buf_ptr: buffer pointer
14368 *
14369 * To fill ARP offload data to firmware
14370 * when target goes to wow mode.
14371 *
14372 * Return: None
14373 */
14374static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014375 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014376{
14377
14378 int i;
14379 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014380 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014381
14382 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14383 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
14384 *buf_ptr += WMI_TLV_HDR_SIZE;
14385 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
14386 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
14387 WMITLV_SET_HDR(&arp_tuple->tlv_header,
14388 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
14389 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
14390
14391 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014392 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014393 /* Copy the target ip addr and flags */
14394 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
14395 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014396 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014397 WMI_IPV4_ADDR_LEN);
14398 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014399 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014400 }
14401 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
14402 }
14403}
14404
14405#ifdef WLAN_NS_OFFLOAD
14406/**
14407 * fill_ns_offload_params_tlv() - Fill NS offload data
14408 * @wmi|_handle: wmi handle
14409 * @offload_req: offload request
14410 * @buf_ptr: buffer pointer
14411 *
14412 * To fill NS offload data to firmware
14413 * when target goes to wow mode.
14414 *
14415 * Return: None
14416 */
14417static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014418 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014419{
14420
14421 int i;
14422 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014423
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014424 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14425 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14426 *buf_ptr += WMI_TLV_HDR_SIZE;
14427 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
14428 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14429 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14430 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14431 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
14432
14433 /*
14434 * Fill data only for NS offload in the first ARP tuple for LA
14435 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014436 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014437 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14438 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014439 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014440 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014441 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014442 sizeof(WMI_IPV6_ADDR));
14443 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014444 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014445 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014446 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014447 ns_tuple->flags |=
14448 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14449 }
14450 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014451 i, &ns_req->self_ipv6_addr[i],
14452 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014453
14454 /* target MAC is optional, check if it is valid,
14455 * if this is not valid, the target will use the known
14456 * local MAC address rather than the tuple
14457 */
14458 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014459 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014460 &ns_tuple->target_mac);
14461 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14462 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14463 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14464 }
14465 }
14466 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14467 }
14468}
14469
14470
14471/**
14472 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
14473 * @wmi: wmi handle
14474 * @offload_req: offload request
14475 * @buf_ptr: buffer pointer
14476 *
14477 * To fill extended NS offload extended data to firmware
14478 * when target goes to wow mode.
14479 *
14480 * Return: None
14481 */
14482static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014483 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014484{
14485 int i;
14486 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
14487 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014488
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014489 count = ns_req->num_ns_offload_count;
14490 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014491 WMI_MAX_NS_OFFLOADS;
14492
14493 /* Populate extended NS offload tuples */
14494 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14495 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
14496 *buf_ptr += WMI_TLV_HDR_SIZE;
14497 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
14498 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
14499 WMITLV_SET_HDR(&ns_tuple->tlv_header,
14500 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
14501 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
14502
14503 /*
14504 * Fill data only for NS offload in the first ARP tuple for LA
14505 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014506 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014507 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
14508 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014509 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014510 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014511 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014512 sizeof(WMI_IPV6_ADDR));
14513 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014514 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014515 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014516 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014517 ns_tuple->flags |=
14518 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
14519 }
14520 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014521 i, &ns_req->self_ipv6_addr[i],
14522 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014523
14524 /* target MAC is optional, check if it is valid,
14525 * if this is not valid, the target will use the
14526 * known local MAC address rather than the tuple
14527 */
14528 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014529 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014530 &ns_tuple->target_mac);
14531 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
14532 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
14533 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
14534 }
14535 }
14536 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
14537 }
14538}
14539#else
14540static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014541 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014542{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014543}
14544
14545static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014546 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014547{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014548}
14549#endif
14550
14551/**
Govind Singha4836fd2016-03-07 16:45:38 +053014552 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
14553 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014554 * @arp_offload_req: arp offload request
14555 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053014556 * @arp_only: flag
14557 *
14558 * To configure ARP NS off load data to firmware
14559 * when target goes to wow mode.
14560 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014561 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053014562 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014563static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014564 struct pmo_arp_offload_params *arp_offload_req,
14565 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053014566 uint8_t vdev_id)
14567{
Govind Singha4836fd2016-03-07 16:45:38 +053014568 int32_t res;
14569 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053014570 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053014571 wmi_buf_t buf;
14572 int32_t len;
14573 uint32_t count = 0, num_ns_ext_tuples = 0;
14574
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014575 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053014576
Govind Singha4836fd2016-03-07 16:45:38 +053014577 /*
14578 * TLV place holder size for array of NS tuples
14579 * TLV place holder size for array of ARP tuples
14580 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014581 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
14582 WMI_TLV_HDR_SIZE +
14583 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
14584 WMI_TLV_HDR_SIZE +
14585 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014586
14587 /*
14588 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
14589 * extra length for extended NS offload tuples which follows ARP offload
14590 * tuples. Host needs to fill this structure in following format:
14591 * 2 NS ofload tuples
14592 * 2 ARP offload tuples
14593 * N numbers of extended NS offload tuples if HDD has given more than
14594 * 2 NS offload addresses
14595 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014596 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053014597 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014598 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
14599 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053014600 }
14601
14602 buf = wmi_buf_alloc(wmi_handle, len);
14603 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014604 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053014605 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014606 }
14607
Vivekc5823092018-03-22 23:27:21 +053014608 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014609 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
14610 WMITLV_SET_HDR(&cmd->tlv_header,
14611 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
14612 WMITLV_GET_STRUCT_TLVLEN
14613 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
14614 cmd->flags = 0;
14615 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014616 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053014617
Govind Singhb53420c2016-03-09 14:32:57 +053014618 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053014619
Govind Singha4836fd2016-03-07 16:45:38 +053014620 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053014621 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
14622 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
14623 if (num_ns_ext_tuples)
14624 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053014625
14626 res = wmi_unified_cmd_send(wmi_handle, buf, len,
14627 WMI_SET_ARP_NS_OFFLOAD_CMDID);
14628 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053014629 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053014630 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014631 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014632 }
14633
Govind Singhb53420c2016-03-09 14:32:57 +053014634 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014635}
14636
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014637/**
14638 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
14639 * @wmi_handle: wmi handle
14640 * @vdev_id: vdev id
14641 * @action: true for enable else false
14642 *
14643 * To enable enhance multicast offload to firmware
14644 * when target goes to wow mode.
14645 *
14646 * Return: QDF Status
14647 */
14648
14649static
14650QDF_STATUS send_enable_enhance_multicast_offload_tlv(
14651 wmi_unified_t wmi_handle,
14652 uint8_t vdev_id, bool action)
14653{
14654 QDF_STATUS status;
14655 wmi_buf_t buf;
14656 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
14657
14658 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14659 if (!buf) {
14660 WMI_LOGE("Failed to allocate buffer to send set key cmd");
14661 return QDF_STATUS_E_NOMEM;
14662 }
14663
14664 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
14665 wmi_buf_data(buf);
14666
14667 WMITLV_SET_HDR(&cmd->tlv_header,
14668 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
14669 WMITLV_GET_STRUCT_TLVLEN(
14670 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
14671
14672 cmd->vdev_id = vdev_id;
14673 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
14674 ENHANCED_MCAST_FILTER_ENABLED);
14675 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
14676 __func__, action, vdev_id);
14677 status = wmi_unified_cmd_send(wmi_handle, buf,
14678 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
14679 if (status != QDF_STATUS_SUCCESS) {
14680 qdf_nbuf_free(buf);
14681 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
14682 __func__);
14683 }
14684
14685 return status;
14686}
14687
14688/**
14689 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
14690 * @wmi_handle: wmi handle
14691 * @param evt_buf: pointer to event buffer
14692 * @param hdr: Pointer to hold header
14693 * @param bufp: Pointer to hold pointer to rx param buffer
14694 *
14695 * Return: QDF_STATUS_SUCCESS for success or error code
14696 */
14697static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
14698 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
14699{
14700 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
14701 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
14702
14703 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
14704 if (!param_buf) {
14705 WMI_LOGE("gtk param_buf is NULL");
14706 return QDF_STATUS_E_INVAL;
14707 }
14708
14709 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
14710 WMI_LOGE("Invalid length for GTK status");
14711 return QDF_STATUS_E_INVAL;
14712 }
14713
14714 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
14715 param_buf->fixed_param;
14716 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
14717 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
14718 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
14719 qdf_mem_copy(&gtk_rsp_param->replay_counter,
14720 &fixed_param->replay_counter,
14721 GTK_REPLAY_COUNTER_BYTES);
14722
14723 return QDF_STATUS_SUCCESS;
14724
14725}
14726
14727#ifdef FEATURE_WLAN_RA_FILTERING
14728/**
14729 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
14730 * @wmi_handle: wmi handle
14731 * @vdev_id: vdev id
14732 *
14733 * Return: CDF status
14734 */
14735static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
14736 uint8_t vdev_id, uint8_t default_pattern,
14737 uint16_t rate_limit_interval)
14738{
14739
14740 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
14741 wmi_buf_t buf;
14742 uint8_t *buf_ptr;
14743 int32_t len;
14744 int ret;
14745
14746 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
14747 WMI_TLV_HDR_SIZE +
14748 0 * sizeof(WOW_BITMAP_PATTERN_T) +
14749 WMI_TLV_HDR_SIZE +
14750 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
14751 WMI_TLV_HDR_SIZE +
14752 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
14753 WMI_TLV_HDR_SIZE +
14754 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
14755 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053014756 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014757
14758 buf = wmi_buf_alloc(wmi_handle, len);
14759 if (!buf) {
14760 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14761 return QDF_STATUS_E_NOMEM;
14762 }
14763
14764 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
14765 buf_ptr = (uint8_t *) cmd;
14766
14767 WMITLV_SET_HDR(&cmd->tlv_header,
14768 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
14769 WMITLV_GET_STRUCT_TLVLEN
14770 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
14771 cmd->vdev_id = vdev_id;
14772 cmd->pattern_id = default_pattern,
14773 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
14774 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
14775
14776 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
14777 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14778 buf_ptr += WMI_TLV_HDR_SIZE;
14779
14780 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
14781 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14782 buf_ptr += WMI_TLV_HDR_SIZE;
14783
14784 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
14785 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14786 buf_ptr += WMI_TLV_HDR_SIZE;
14787
14788 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
14789 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
14790 buf_ptr += WMI_TLV_HDR_SIZE;
14791
14792 /* Fill TLV for pattern_info_timeout but no data. */
14793 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14794 buf_ptr += WMI_TLV_HDR_SIZE;
14795
14796 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014797 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014798 buf_ptr += WMI_TLV_HDR_SIZE;
14799
Vivekc5823092018-03-22 23:27:21 +053014800 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014801
14802 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14803 rate_limit_interval, vdev_id);
14804
14805 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14806 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14807 if (ret) {
14808 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14809 wmi_buf_free(buf);
14810 return QDF_STATUS_E_FAILURE;
14811 }
14812
14813 return QDF_STATUS_SUCCESS;
14814
14815}
14816#endif /* FEATURE_WLAN_RA_FILTERING */
14817
14818/**
14819 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14820 * @wmi_handle: wmi handle
14821 * @vdev_id: vdev id
14822 * @multicastAddr: mcast address
14823 * @clearList: clear list flag
14824 *
14825 * Return: QDF_STATUS_SUCCESS for success or error code
14826 */
14827static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14828 uint8_t vdev_id,
14829 struct qdf_mac_addr multicast_addr,
14830 bool clearList)
14831{
14832 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14833 wmi_buf_t buf;
14834 int err;
14835
14836 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14837 if (!buf) {
14838 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14839 return QDF_STATUS_E_NOMEM;
14840 }
14841
14842 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14843 qdf_mem_zero(cmd, sizeof(*cmd));
14844
14845 WMITLV_SET_HDR(&cmd->tlv_header,
14846 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14847 WMITLV_GET_STRUCT_TLVLEN
14848 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14849 cmd->action =
14850 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14851 cmd->vdev_id = vdev_id;
14852 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14853
14854 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14855 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14856
14857 err = wmi_unified_cmd_send(wmi_handle, buf,
14858 sizeof(*cmd),
14859 WMI_SET_MCASTBCAST_FILTER_CMDID);
14860 if (err) {
14861 WMI_LOGE("Failed to send set_param cmd");
14862 wmi_buf_free(buf);
14863 return QDF_STATUS_E_FAILURE;
14864 }
14865
14866 return QDF_STATUS_SUCCESS;
14867}
14868
14869/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014870 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14871 * command to fw
14872 * @wmi_handle: wmi handle
14873 * @vdev_id: vdev id
14874 * @mcast_filter_params: mcast filter params
14875 *
14876 * Return: QDF_STATUS_SUCCESS for success or error code
14877 */
14878static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14879 wmi_unified_t wmi_handle,
14880 uint8_t vdev_id,
14881 struct pmo_mcast_filter_params *filter_param)
14882
14883{
14884 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14885 uint8_t *buf_ptr;
14886 wmi_buf_t buf;
14887 int err;
14888 int i;
14889 uint8_t *mac_addr_src_ptr = NULL;
14890 wmi_mac_addr *mac_addr_dst_ptr;
14891 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14892 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14893
14894 buf = wmi_buf_alloc(wmi_handle, len);
14895 if (!buf) {
14896 WMI_LOGE("Failed to allocate memory");
14897 return QDF_STATUS_E_NOMEM;
14898 }
14899
Vivekc5823092018-03-22 23:27:21 +053014900 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014901 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14902 wmi_buf_data(buf);
14903 qdf_mem_zero(cmd, sizeof(*cmd));
14904
14905 WMITLV_SET_HDR(&cmd->tlv_header,
14906 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14907 WMITLV_GET_STRUCT_TLVLEN
14908 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14909 cmd->operation =
14910 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14911 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14912 cmd->vdev_id = vdev_id;
14913 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14914
14915 buf_ptr += sizeof(*cmd);
14916 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14917 sizeof(wmi_mac_addr) *
14918 filter_param->multicast_addr_cnt);
14919
14920 if (filter_param->multicast_addr_cnt == 0)
14921 goto send_cmd;
14922
14923 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14924 mac_addr_dst_ptr = (wmi_mac_addr *)
14925 (buf_ptr + WMI_TLV_HDR_SIZE);
14926
14927 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14928 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14929 mac_addr_src_ptr += ATH_MAC_LEN;
14930 mac_addr_dst_ptr++;
14931 }
14932
14933send_cmd:
14934 err = wmi_unified_cmd_send(wmi_handle, buf,
14935 len,
14936 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14937 if (err) {
14938 WMI_LOGE("Failed to send set_param cmd");
14939 wmi_buf_free(buf);
14940 return QDF_STATUS_E_FAILURE;
14941 }
14942
14943 return QDF_STATUS_SUCCESS;
14944}
14945
14946
14947/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014948 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14949 * @wmi_handle: wmi handle
14950 * @vdev_id: vdev id
14951 * @params: GTK offload parameters
14952 *
14953 * Return: CDF status
14954 */
14955static
14956QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14957 struct pmo_gtk_req *params,
14958 bool enable_offload,
14959 uint32_t gtk_offload_opcode)
14960{
14961 int len;
14962 wmi_buf_t buf;
14963 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014964 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014965 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014966 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014967
14968 WMI_LOGD("%s Enter", __func__);
14969
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014970 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014971
14972 /* alloc wmi buffer */
14973 buf = wmi_buf_alloc(wmi_handle, len);
14974 if (!buf) {
14975 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14976 status = QDF_STATUS_E_NOMEM;
14977 goto out;
14978 }
14979
14980 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014981 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014982 WMITLV_SET_HDR(&cmd->tlv_header,
14983 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14984 WMITLV_GET_STRUCT_TLVLEN
14985 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14986
14987 cmd->vdev_id = vdev_id;
14988
14989 /* Request target to enable GTK offload */
14990 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14991 cmd->flags = gtk_offload_opcode;
14992
14993 /* Copy the keys and replay counter */
14994 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014995 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014996 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14997 GTK_REPLAY_COUNTER_BYTES);
14998 } else {
14999 cmd->flags = gtk_offload_opcode;
15000 }
15001
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015002 buf_ptr += sizeof(*cmd);
15003 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
15004 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015005
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053015006 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
15007 WMITLV_SET_HDR(&ext_param->tlv_header,
15008 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
15009 WMITLV_GET_STRUCT_TLVLEN(
15010 wmi_gtk_offload_fils_tlv_param));
15011 ext_param->vdev_id = vdev_id;
15012 ext_param->flags = cmd->flags;
15013 ext_param->kek_len = params->kek_len;
15014 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
15015 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
15016 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
15017 GTK_REPLAY_COUNTER_BYTES);
15018
15019 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 +053015020 /* send the wmi command */
15021 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15022 WMI_GTK_OFFLOAD_CMDID)) {
15023 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
15024 wmi_buf_free(buf);
15025 status = QDF_STATUS_E_FAILURE;
15026 }
15027
15028out:
15029 WMI_LOGD("%s Exit", __func__);
15030 return status;
15031}
15032
15033/**
15034 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
15035 * @wmi_handle: wmi handle
15036 * @params: GTK offload params
15037 *
15038 * Return: CDF status
15039 */
15040static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
15041 wmi_unified_t wmi_handle,
15042 uint8_t vdev_id,
15043 uint64_t offload_req_opcode)
15044{
15045 int len;
15046 wmi_buf_t buf;
15047 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
15048 QDF_STATUS status = QDF_STATUS_SUCCESS;
15049
15050 len = sizeof(*cmd);
15051
15052 /* alloc wmi buffer */
15053 buf = wmi_buf_alloc(wmi_handle, len);
15054 if (!buf) {
15055 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
15056 status = QDF_STATUS_E_NOMEM;
15057 goto out;
15058 }
15059
15060 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
15061 WMITLV_SET_HDR(&cmd->tlv_header,
15062 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
15063 WMITLV_GET_STRUCT_TLVLEN
15064 (WMI_GTK_OFFLOAD_CMD_fixed_param));
15065
15066 /* Request for GTK offload status */
15067 cmd->flags = offload_req_opcode;
15068 cmd->vdev_id = vdev_id;
15069
15070 /* send the wmi command */
15071 if (wmi_unified_cmd_send(wmi_handle, buf, len,
15072 WMI_GTK_OFFLOAD_CMDID)) {
15073 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
15074 wmi_buf_free(buf);
15075 status = QDF_STATUS_E_FAILURE;
15076 }
15077
15078out:
15079 return status;
15080}
15081
15082/**
15083 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
15084 * @wmi_handle: wmi handler
15085 * @action_params: pointer to action_params
15086 *
15087 * Return: 0 for success, otherwise appropriate error code
15088 */
15089static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
15090 struct pmo_action_wakeup_set_params *action_params)
15091{
15092 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
15093 wmi_buf_t buf;
15094 int i;
15095 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015096 uint32_t len = 0, *cmd_args;
15097 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015098
Vivekc5823092018-03-22 23:27:21 +053015099 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015100 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
15101 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015102 if (!buf) {
15103 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
15104 return QDF_STATUS_E_NOMEM;
15105 }
15106 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015107 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015108 WMITLV_SET_HDR(&cmd->tlv_header,
15109 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
15110 WMITLV_GET_STRUCT_TLVLEN(
15111 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
15112
15113 cmd->vdev_id = action_params->vdev_id;
15114 cmd->operation = action_params->operation;
15115
15116 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
15117 cmd->action_category_map[i] =
15118 action_params->action_category_map[i];
15119
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015120 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
15121 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015122 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015123 buf_ptr += WMI_TLV_HDR_SIZE;
15124 cmd_args = (uint32_t *) buf_ptr;
15125 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
15126 cmd_args[i] = action_params->action_per_category[i];
15127
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015128 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053015129 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015130 if (err) {
15131 WMI_LOGE("Failed to send ap_ps_egap cmd");
15132 wmi_buf_free(buf);
15133 return QDF_STATUS_E_FAILURE;
15134 }
15135
15136 return QDF_STATUS_SUCCESS;
15137}
15138
15139#ifdef FEATURE_WLAN_LPHB
15140
15141/**
15142 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
15143 * @wmi_handle: wmi handle
15144 * @lphb_conf_req: configuration info
15145 *
15146 * Return: CDF status
15147 */
15148static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
15149 wmi_hb_set_enable_cmd_fixed_param *params)
15150{
15151 QDF_STATUS status;
15152 wmi_buf_t buf = NULL;
15153 uint8_t *buf_ptr;
15154 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
15155 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
15156
15157
15158 buf = wmi_buf_alloc(wmi_handle, len);
15159 if (!buf) {
15160 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15161 return QDF_STATUS_E_NOMEM;
15162 }
15163
15164 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15165 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
15166 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
15167 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
15168 WMITLV_GET_STRUCT_TLVLEN
15169 (wmi_hb_set_enable_cmd_fixed_param));
15170
15171 /* fill in values */
15172 hb_enable_fp->vdev_id = params->session;
15173 hb_enable_fp->enable = params->enable;
15174 hb_enable_fp->item = params->item;
15175 hb_enable_fp->session = params->session;
15176
15177 status = wmi_unified_cmd_send(wmi_handle, buf,
15178 len, WMI_HB_SET_ENABLE_CMDID);
15179 if (QDF_IS_STATUS_ERROR(status)) {
15180 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
15181 status);
15182 wmi_buf_free(buf);
15183 }
15184
15185 return status;
15186}
15187
15188/**
15189 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
15190 * @wmi_handle: wmi handle
15191 * @lphb_conf_req: lphb config request
15192 *
15193 * Return: CDF status
15194 */
15195static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
15196 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
15197{
15198 QDF_STATUS status;
15199 wmi_buf_t buf = NULL;
15200 uint8_t *buf_ptr;
15201 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
15202 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
15203
15204 buf = wmi_buf_alloc(wmi_handle, len);
15205 if (!buf) {
15206 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15207 return QDF_STATUS_E_NOMEM;
15208 }
15209
15210 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15211 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
15212 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
15213 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
15214 WMITLV_GET_STRUCT_TLVLEN
15215 (wmi_hb_set_tcp_params_cmd_fixed_param));
15216
15217 /* fill in values */
15218 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15219 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15220 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15221 hb_tcp_params_fp->seq = lphb_conf_req->seq;
15222 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
15223 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
15224 hb_tcp_params_fp->interval = lphb_conf_req->interval;
15225 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
15226 hb_tcp_params_fp->session = lphb_conf_req->session;
15227 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
15228 &lphb_conf_req->gateway_mac,
15229 sizeof(hb_tcp_params_fp->gateway_mac));
15230
15231 status = wmi_unified_cmd_send(wmi_handle, buf,
15232 len, WMI_HB_SET_TCP_PARAMS_CMDID);
15233 if (QDF_IS_STATUS_ERROR(status)) {
15234 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
15235 status);
15236 wmi_buf_free(buf);
15237 }
15238
15239 return status;
15240}
15241
15242/**
15243 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
15244 * @wmi_handle: wmi handle
15245 * @lphb_conf_req: lphb config request
15246 *
15247 * Return: CDF status
15248 */
15249static
15250QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15251 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
15252{
15253 QDF_STATUS status;
15254 wmi_buf_t buf = NULL;
15255 uint8_t *buf_ptr;
15256 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
15257 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
15258
15259 buf = wmi_buf_alloc(wmi_handle, len);
15260 if (!buf) {
15261 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15262 return QDF_STATUS_E_NOMEM;
15263 }
15264
15265 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15266 hb_tcp_filter_fp =
15267 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
15268 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
15269 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
15270 WMITLV_GET_STRUCT_TLVLEN
15271 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
15272
15273 /* fill in values */
15274 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
15275 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
15276 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
15277 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
15278 memcpy((void *)&hb_tcp_filter_fp->filter,
15279 (void *)&g_hb_tcp_filter_fp->filter,
15280 WMI_WLAN_HB_MAX_FILTER_SIZE);
15281
15282 status = wmi_unified_cmd_send(wmi_handle, buf,
15283 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
15284 if (QDF_IS_STATUS_ERROR(status)) {
15285 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
15286 status);
15287 wmi_buf_free(buf);
15288 }
15289
15290 return status;
15291}
15292
15293/**
15294 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
15295 * @wmi_handle: wmi handle
15296 * @lphb_conf_req: lphb config request
15297 *
15298 * Return: CDF status
15299 */
15300static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
15301 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
15302{
15303 QDF_STATUS status;
15304 wmi_buf_t buf = NULL;
15305 uint8_t *buf_ptr;
15306 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
15307 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
15308
15309 buf = wmi_buf_alloc(wmi_handle, len);
15310 if (!buf) {
15311 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15312 return QDF_STATUS_E_NOMEM;
15313 }
15314
15315 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15316 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
15317 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
15318 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
15319 WMITLV_GET_STRUCT_TLVLEN
15320 (wmi_hb_set_udp_params_cmd_fixed_param));
15321
15322 /* fill in values */
15323 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
15324 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
15325 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
15326 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
15327 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
15328 hb_udp_params_fp->interval = lphb_conf_req->interval;
15329 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
15330 hb_udp_params_fp->session = lphb_conf_req->session;
15331 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
15332 &lphb_conf_req->gateway_mac,
15333 sizeof(lphb_conf_req->gateway_mac));
15334
15335 status = wmi_unified_cmd_send(wmi_handle, buf,
15336 len, WMI_HB_SET_UDP_PARAMS_CMDID);
15337 if (QDF_IS_STATUS_ERROR(status)) {
15338 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
15339 status);
15340 wmi_buf_free(buf);
15341 }
15342
15343 return status;
15344}
15345
15346/**
15347 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
15348 * @wmi_handle: wmi handle
15349 * @lphb_conf_req: lphb config request
15350 *
15351 * Return: CDF status
15352 */
15353static
15354QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
15355 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
15356{
15357 QDF_STATUS status;
15358 wmi_buf_t buf = NULL;
15359 uint8_t *buf_ptr;
15360 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
15361 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
15362
15363 buf = wmi_buf_alloc(wmi_handle, len);
15364 if (!buf) {
15365 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15366 return QDF_STATUS_E_NOMEM;
15367 }
15368
15369 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15370 hb_udp_filter_fp =
15371 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
15372 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
15373 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
15374 WMITLV_GET_STRUCT_TLVLEN
15375 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
15376
15377 /* fill in values */
15378 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
15379 hb_udp_filter_fp->length = lphb_conf_req->length;
15380 hb_udp_filter_fp->offset = lphb_conf_req->offset;
15381 hb_udp_filter_fp->session = lphb_conf_req->session;
15382 memcpy((void *)&hb_udp_filter_fp->filter,
15383 (void *)&lphb_conf_req->filter,
15384 WMI_WLAN_HB_MAX_FILTER_SIZE);
15385
15386 status = wmi_unified_cmd_send(wmi_handle, buf,
15387 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
15388 if (QDF_IS_STATUS_ERROR(status)) {
15389 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
15390 status);
15391 wmi_buf_free(buf);
15392 }
15393
15394 return status;
15395}
15396#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053015397
Dustin Brownf31f88b2017-05-12 14:01:44 -070015398static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
15399 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015400{
Dustin Brownf31f88b2017-05-12 14:01:44 -070015401 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015402 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070015403 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015404
Dustin Brownf31f88b2017-05-12 14:01:44 -070015405 if (!req) {
15406 WMI_LOGE("req is null");
15407 return QDF_STATUS_E_INVAL;
15408 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015409
Dustin Brownf31f88b2017-05-12 14:01:44 -070015410 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
15411 if (!wmi_buf) {
15412 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015413 return QDF_STATUS_E_NOMEM;
15414 }
15415
Dustin Brownf31f88b2017-05-12 14:01:44 -070015416 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015417 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070015418 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
15419 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
15420 cmd->vdev_id = req->vdev_id;
15421 cmd->enable = req->mode != PMO_HW_FILTER_DISABLED;
15422 cmd->hw_filter_bitmap = req->mode;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015423
Dustin Brownf31f88b2017-05-12 14:01:44 -070015424 WMI_LOGD("configure hw filter (vdev_id: %d, mode: %d)",
15425 req->vdev_id, req->mode);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015426
Dustin Brownf31f88b2017-05-12 14:01:44 -070015427 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
15428 WMI_HW_DATA_FILTER_CMDID);
15429 if (QDF_IS_STATUS_ERROR(status)) {
15430 WMI_LOGE("Failed to configure hw filter");
15431 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015432 }
15433
Dustin Brownf31f88b2017-05-12 14:01:44 -070015434 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015435}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053015436
15437/**
15438 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
15439 * @wmi_handle: wmi handle
15440 * @vdev_id: vdev id
15441 * @enable: Flag to enable/disable packet filter
15442 *
15443 * Return: QDF_STATUS_SUCCESS for success or error code
15444 */
15445static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
15446 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
15447{
15448 int32_t len;
15449 int ret = 0;
15450 wmi_buf_t buf;
15451 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
15452
15453 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
15454
15455 buf = wmi_buf_alloc(wmi_handle, len);
15456 if (!buf) {
15457 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
15458 return QDF_STATUS_E_NOMEM;
15459 }
15460
15461 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
15462 WMITLV_SET_HDR(&cmd->tlv_header,
15463 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
15464 WMITLV_GET_STRUCT_TLVLEN(
15465 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
15466
15467 cmd->vdev_id = vdev_id;
15468 if (enable)
15469 cmd->enable = PACKET_FILTER_SET_ENABLE;
15470 else
15471 cmd->enable = PACKET_FILTER_SET_DISABLE;
15472
15473 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
15474 __func__, cmd->enable, vdev_id);
15475
15476 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15477 WMI_PACKET_FILTER_ENABLE_CMDID);
15478 if (ret) {
15479 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
15480 wmi_buf_free(buf);
15481 }
15482
15483 return ret;
15484}
15485
15486/**
15487 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
15488 * @wmi_handle: wmi handle
15489 * @vdev_id: vdev id
15490 * @rcv_filter_param: Packet filter parameters
15491 * @filter_id: Filter id
15492 * @enable: Flag to add/delete packet filter configuration
15493 *
15494 * Return: QDF_STATUS_SUCCESS for success or error code
15495 */
15496static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
15497 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
15498 uint8_t filter_id, bool enable)
15499{
15500 int len, i;
15501 int err = 0;
15502 wmi_buf_t buf;
15503 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
15504
15505
15506 /* allocate the memory */
15507 len = sizeof(*cmd);
15508 buf = wmi_buf_alloc(wmi_handle, len);
15509 if (!buf) {
15510 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
15511 return QDF_STATUS_E_NOMEM;
15512 }
15513
15514 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
15515 WMITLV_SET_HDR(&cmd->tlv_header,
15516 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
15517 WMITLV_GET_STRUCT_TLVLEN
15518 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
15519
15520 cmd->vdev_id = vdev_id;
15521 cmd->filter_id = filter_id;
15522 if (enable)
15523 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
15524 else
15525 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
15526
15527 if (enable) {
15528 cmd->num_params = QDF_MIN(
15529 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
15530 rcv_filter_param->num_params);
15531 cmd->filter_type = rcv_filter_param->filter_type;
15532 cmd->coalesce_time = rcv_filter_param->coalesce_time;
15533
15534 for (i = 0; i < cmd->num_params; i++) {
15535 cmd->paramsData[i].proto_type =
15536 rcv_filter_param->params_data[i].protocol_layer;
15537 cmd->paramsData[i].cmp_type =
15538 rcv_filter_param->params_data[i].compare_flag;
15539 cmd->paramsData[i].data_length =
15540 rcv_filter_param->params_data[i].data_length;
15541 cmd->paramsData[i].data_offset =
15542 rcv_filter_param->params_data[i].data_offset;
15543 memcpy(&cmd->paramsData[i].compareData,
15544 rcv_filter_param->params_data[i].compare_data,
15545 sizeof(cmd->paramsData[i].compareData));
15546 memcpy(&cmd->paramsData[i].dataMask,
15547 rcv_filter_param->params_data[i].data_mask,
15548 sizeof(cmd->paramsData[i].dataMask));
15549 }
15550 }
15551
15552 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
15553 cmd->filter_action, cmd->filter_id, cmd->num_params);
15554 /* send the command along with data */
15555 err = wmi_unified_cmd_send(wmi_handle, buf, len,
15556 WMI_PACKET_FILTER_CONFIG_CMDID);
15557 if (err) {
15558 WMI_LOGE("Failed to send pkt_filter cmd");
15559 wmi_buf_free(buf);
15560 return QDF_STATUS_E_FAILURE;
15561 }
15562
15563 return QDF_STATUS_SUCCESS;
15564}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053015565#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053015566
Govind Singha4836fd2016-03-07 16:45:38 +053015567/**
15568 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
15569 * @wmi_handle: wmi handle
15570 * @request: SSID hotlist set request
15571 *
Govind Singhb53420c2016-03-09 14:32:57 +053015572 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053015573 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015574static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053015575send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
15576 struct ssid_hotlist_request_params *request)
15577{
15578 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
15579 wmi_buf_t wmi_buf;
15580 uint32_t len;
15581 uint32_t array_size;
15582 uint8_t *buf_ptr;
15583
15584 /* length of fixed portion */
15585 len = sizeof(*cmd);
15586
15587 /* length of variable portion */
15588 array_size =
15589 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
15590 len += WMI_TLV_HDR_SIZE + array_size;
15591
15592 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15593 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015594 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15595 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015596 }
15597
15598 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
15599 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
15600 buf_ptr;
15601 WMITLV_SET_HDR
15602 (&cmd->tlv_header,
15603 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
15604 WMITLV_GET_STRUCT_TLVLEN
15605 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
15606
15607 cmd->request_id = request->request_id;
15608 cmd->requestor_id = 0;
15609 cmd->vdev_id = request->session_id;
15610 cmd->table_id = 0;
15611 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
15612 cmd->total_entries = request->ssid_count;
15613 cmd->num_entries_in_page = request->ssid_count;
15614 cmd->first_entry_index = 0;
15615
15616 buf_ptr += sizeof(*cmd);
15617 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
15618
15619 if (request->ssid_count) {
15620 wmi_extscan_hotlist_ssid_entry *entry;
15621 int i;
15622
15623 buf_ptr += WMI_TLV_HDR_SIZE;
15624 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
15625 for (i = 0; i < request->ssid_count; i++) {
15626 WMITLV_SET_HDR
15627 (entry,
15628 WMITLV_TAG_ARRAY_STRUC,
15629 WMITLV_GET_STRUCT_TLVLEN
15630 (wmi_extscan_hotlist_ssid_entry));
15631 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053015632 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053015633 request->ssids[i].ssid.mac_ssid,
15634 request->ssids[i].ssid.length);
15635 entry->band = request->ssids[i].band;
15636 entry->min_rssi = request->ssids[i].rssi_low;
15637 entry->max_rssi = request->ssids[i].rssi_high;
15638 entry++;
15639 }
15640 cmd->mode = WMI_EXTSCAN_MODE_START;
15641 } else {
15642 cmd->mode = WMI_EXTSCAN_MODE_STOP;
15643 }
15644
15645 if (wmi_unified_cmd_send
15646 (wmi_handle, wmi_buf, len,
15647 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015648 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015649 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015650 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015651 }
15652
Govind Singhb53420c2016-03-09 14:32:57 +053015653 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015654}
15655
15656/**
15657 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
15658 * @wmi_handle: wmi handle
15659 * @vdev_id: vdev id
15660 *
15661 * This function sends roam synch complete event to fw.
15662 *
15663 * Return: CDF STATUS
15664 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015665static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015666 uint8_t vdev_id)
15667{
15668 wmi_roam_synch_complete_fixed_param *cmd;
15669 wmi_buf_t wmi_buf;
15670 uint8_t *buf_ptr;
15671 uint16_t len;
15672 len = sizeof(wmi_roam_synch_complete_fixed_param);
15673
15674 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15675 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015676 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
15677 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015678 }
15679 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
15680 buf_ptr = (uint8_t *) cmd;
15681 WMITLV_SET_HDR(&cmd->tlv_header,
15682 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
15683 WMITLV_GET_STRUCT_TLVLEN
15684 (wmi_roam_synch_complete_fixed_param));
15685 cmd->vdev_id = vdev_id;
15686 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15687 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015688 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053015689 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015690 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015691 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015692 }
15693
Govind Singhb53420c2016-03-09 14:32:57 +053015694 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015695}
15696
15697/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053015698 * send_fw_test_cmd_tlv() - send fw test command to fw.
15699 * @wmi_handle: wmi handle
15700 * @wmi_fwtest: fw test command
15701 *
15702 * This function sends fw test command to fw.
15703 *
15704 * Return: CDF STATUS
15705 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015706static
Anurag Chouhan459e0152016-07-22 20:19:54 +053015707QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
15708 struct set_fwtest_params *wmi_fwtest)
15709{
15710 wmi_fwtest_set_param_cmd_fixed_param *cmd;
15711 wmi_buf_t wmi_buf;
15712 uint16_t len;
15713
15714 len = sizeof(*cmd);
15715
15716 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15717 if (!wmi_buf) {
15718 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15719 return QDF_STATUS_E_NOMEM;
15720 }
15721
15722 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15723 WMITLV_SET_HDR(&cmd->tlv_header,
15724 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
15725 WMITLV_GET_STRUCT_TLVLEN(
15726 wmi_fwtest_set_param_cmd_fixed_param));
15727 cmd->param_id = wmi_fwtest->arg;
15728 cmd->param_value = wmi_fwtest->value;
15729
15730 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15731 WMI_FWTEST_CMDID)) {
15732 WMI_LOGP("%s: failed to send fw test command", __func__);
15733 qdf_nbuf_free(wmi_buf);
15734 return QDF_STATUS_E_FAILURE;
15735 }
15736
15737 return QDF_STATUS_SUCCESS;
15738}
15739
15740/**
Govind Singha4836fd2016-03-07 16:45:38 +053015741 * send_unit_test_cmd_tlv() - send unit test command to fw.
15742 * @wmi_handle: wmi handle
15743 * @wmi_utest: unit test command
15744 *
15745 * This function send unit test command to fw.
15746 *
15747 * Return: CDF STATUS
15748 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015749static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015750 struct wmi_unit_test_cmd *wmi_utest)
15751{
15752 wmi_unit_test_cmd_fixed_param *cmd;
15753 wmi_buf_t wmi_buf;
15754 uint8_t *buf_ptr;
15755 int i;
15756 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015757 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053015758
15759 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053015760 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015761 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
15762
15763 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15764 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015765 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15766 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015767 }
15768
15769 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
15770 buf_ptr = (uint8_t *) cmd;
15771 WMITLV_SET_HDR(&cmd->tlv_header,
15772 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
15773 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
15774 cmd->vdev_id = wmi_utest->vdev_id;
15775 cmd->module_id = wmi_utest->module_id;
15776 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015777 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053015778 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
15779 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15780 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015781 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070015782 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
15783 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
15784 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053015785 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080015786 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015787 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015788 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015789 }
15790 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15791 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015792 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015793 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015794 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015795 }
15796
Govind Singhb53420c2016-03-09 14:32:57 +053015797 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015798}
15799
15800/**
15801 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15802 * @wmi_handle: wma handle
15803 * @roaminvoke: roam invoke command
15804 *
15805 * Send roam invoke command to fw for fastreassoc.
15806 *
15807 * Return: CDF STATUS
15808 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015809static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015810 struct wmi_roam_invoke_cmd *roaminvoke,
15811 uint32_t ch_hz)
15812{
15813 wmi_roam_invoke_cmd_fixed_param *cmd;
15814 wmi_buf_t wmi_buf;
15815 u_int8_t *buf_ptr;
15816 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015817 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015818 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015819 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015820
15821 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015822 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015823 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15824 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015825 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15826 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15827 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015828 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15829 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015830 }
15831
15832 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15833 buf_ptr = (u_int8_t *) cmd;
15834 WMITLV_SET_HDR(&cmd->tlv_header,
15835 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15836 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15837 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015838 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015839 if (roaminvoke->is_same_bssid)
15840 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15841 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015842
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015843 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015844 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015845 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15846 cmd->num_buf = 1;
15847 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015848 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015849 cmd->num_buf = 0;
15850 }
Naveen Rawat77797922017-01-20 17:00:07 -080015851
Govind Singha4836fd2016-03-07 16:45:38 +053015852 cmd->roam_ap_sel_mode = 0;
15853 cmd->roam_delay = 0;
15854 cmd->num_chan = 1;
15855 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015856
Govind Singha4836fd2016-03-07 16:45:38 +053015857 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15858 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15859 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015860 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015861 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015862 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015863 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15864 (sizeof(wmi_mac_addr)));
15865 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15866 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015867
15868 /* move to next tlv i.e. bcn_prb_buf_list */
15869 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15870
15871 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15872 sizeof(wmi_tlv_buf_len_param));
15873
15874 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15875 buf_len_tlv->buf_len = roaminvoke->frame_len;
15876
15877 /* move to next tlv i.e. bcn_prb_frm */
15878 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15879 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15880 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15881
15882 /* copy frame after the header */
15883 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15884 roaminvoke->frame_buf,
15885 roaminvoke->frame_len);
15886
15887 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
15888 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
15889 buf_ptr + WMI_TLV_HDR_SIZE,
15890 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015891 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15892 cmd->flags, cmd->roam_scan_mode,
15893 cmd->roam_ap_sel_mode, cmd->roam_delay,
15894 cmd->num_chan, cmd->num_bssid);
15895 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015896
Govind Singha4836fd2016-03-07 16:45:38 +053015897 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15898 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015899 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015900 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015901 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015902 }
15903
Govind Singhb53420c2016-03-09 14:32:57 +053015904 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015905}
15906
15907/**
15908 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15909 * @wmi_handle: wmi handle
15910 * @command: command
15911 * @vdev_id: vdev id
15912 *
15913 * This function set roam offload command to fw.
15914 *
15915 * Return: CDF status
15916 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015917static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015918 uint32_t command, uint32_t vdev_id)
15919{
Govind Singh67922e82016-04-01 16:48:57 +053015920 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015921 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15922 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015923 int len;
15924 uint8_t *buf_ptr;
15925
15926 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15927 buf = wmi_buf_alloc(wmi_handle, len);
15928 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015929 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15930 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015931 }
15932
15933 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15934
15935 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15936 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15937 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15938 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15939 cmd_fp->vdev_id = vdev_id;
15940 cmd_fp->command_arg = command;
15941
15942 status = wmi_unified_cmd_send(wmi_handle, buf,
15943 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015944 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015945 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015946 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015947 goto error;
15948 }
15949
Govind Singhb53420c2016-03-09 14:32:57 +053015950 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15951 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015952
15953error:
15954 wmi_buf_free(buf);
15955
Govind Singh67922e82016-04-01 16:48:57 +053015956 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015957}
15958
15959/**
15960 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15961 * @wmi_handle: wmi handle
15962 * @ap_profile_p: ap profile
15963 * @vdev_id: vdev id
15964 *
15965 * Send WMI_ROAM_AP_PROFILE to firmware
15966 *
15967 * Return: CDF status
15968 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015969static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015970 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015971{
Govind Singha4836fd2016-03-07 16:45:38 +053015972 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015973 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015974 int len;
15975 uint8_t *buf_ptr;
15976 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015977 wmi_roam_cnd_scoring_param *score_param;
15978 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015979
15980 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015981 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015982 buf = wmi_buf_alloc(wmi_handle, len);
15983 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015984 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15985 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015986 }
15987
15988 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15989 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15990 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15991 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15992 WMITLV_GET_STRUCT_TLVLEN
15993 (wmi_roam_ap_profile_fixed_param));
15994 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015995 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015996 roam_ap_profile_fp->id = 0;
15997 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15998
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015999 profile = (wmi_ap_profile *)buf_ptr;
16000 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053016001 WMITLV_TAG_STRUC_wmi_ap_profile,
16002 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053016003 profile->flags = ap_profile->profile.flags;
16004 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
16005 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
16006 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
16007 profile->ssid.ssid_len);
16008 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
16009 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
16010 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
16011 profile->rsn_mcastmgmtcipherset =
16012 ap_profile->profile.rsn_mcastmgmtcipherset;
16013 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
16014
16015 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",
16016 profile->flags, profile->rssi_threshold,
16017 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
16018 profile->rsn_authmode, profile->rsn_ucastcipherset,
16019 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
16020 profile->rssi_abs_thresh);
16021
16022 buf_ptr += sizeof(wmi_ap_profile);
16023
16024 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
16025 WMITLV_SET_HDR(&score_param->tlv_header,
16026 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
16027 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
16028 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
16029 score_param->rssi_weightage_pcnt =
16030 ap_profile->param.rssi_weightage;
16031 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
16032 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
16033 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
16034 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
16035 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
16036 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
16037 score_param->esp_qbss_weightage_pcnt =
16038 ap_profile->param.esp_qbss_weightage;
16039 score_param->beamforming_weightage_pcnt =
16040 ap_profile->param.beamforming_weightage;
16041 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
16042 score_param->oce_wan_weightage_pcnt =
16043 ap_profile->param.oce_wan_weightage;
16044
16045 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",
16046 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
16047 score_param->ht_weightage_pcnt,
16048 score_param->vht_weightage_pcnt,
16049 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
16050 score_param->band_weightage_pcnt,
16051 score_param->nss_weightage_pcnt,
16052 score_param->esp_qbss_weightage_pcnt,
16053 score_param->beamforming_weightage_pcnt,
16054 score_param->pcl_weightage_pcnt,
16055 score_param->oce_wan_weightage_pcnt);
16056
16057 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
16058 score_param->band_scoring.score_pcnt =
16059 ap_profile->param.band_index_score;
16060 score_param->nss_scoring.score_pcnt =
16061 ap_profile->param.nss_index_score;
16062
16063 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
16064 score_param->bw_scoring.score_pcnt,
16065 score_param->band_scoring.score_pcnt,
16066 score_param->nss_scoring.score_pcnt);
16067
16068 score_param->rssi_scoring.best_rssi_threshold =
16069 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
16070 score_param->rssi_scoring.good_rssi_threshold =
16071 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
16072 score_param->rssi_scoring.bad_rssi_threshold =
16073 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
16074 score_param->rssi_scoring.good_rssi_pcnt =
16075 ap_profile->param.rssi_scoring.good_rssi_pcnt;
16076 score_param->rssi_scoring.bad_rssi_pcnt =
16077 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
16078 score_param->rssi_scoring.good_bucket_size =
16079 ap_profile->param.rssi_scoring.good_bucket_size;
16080 score_param->rssi_scoring.bad_bucket_size =
16081 ap_profile->param.rssi_scoring.bad_bucket_size;
16082 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
16083 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
16084
16085 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
16086 score_param->rssi_scoring.best_rssi_threshold,
16087 score_param->rssi_scoring.good_rssi_threshold,
16088 score_param->rssi_scoring.bad_rssi_threshold,
16089 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
16090 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
16091 score_param->rssi_scoring.good_rssi_pcnt,
16092 score_param->rssi_scoring.bad_rssi_pcnt,
16093 score_param->rssi_scoring.good_bucket_size,
16094 score_param->rssi_scoring.bad_bucket_size);
16095
16096 score_param->esp_qbss_scoring.num_slot =
16097 ap_profile->param.esp_qbss_scoring.num_slot;
16098 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
16099 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
16100 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
16101 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
16102 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
16103 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
16104 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
16105 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
16106
16107 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16108 score_param->esp_qbss_scoring.num_slot,
16109 score_param->esp_qbss_scoring.score_pcnt3_to_0,
16110 score_param->esp_qbss_scoring.score_pcnt7_to_4,
16111 score_param->esp_qbss_scoring.score_pcnt11_to_8,
16112 score_param->esp_qbss_scoring.score_pcnt15_to_12);
16113
16114 score_param->oce_wan_scoring.num_slot =
16115 ap_profile->param.oce_wan_scoring.num_slot;
16116 score_param->oce_wan_scoring.score_pcnt3_to_0 =
16117 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
16118 score_param->oce_wan_scoring.score_pcnt7_to_4 =
16119 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
16120 score_param->oce_wan_scoring.score_pcnt11_to_8 =
16121 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
16122 score_param->oce_wan_scoring.score_pcnt15_to_12 =
16123 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
16124
16125 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
16126 score_param->oce_wan_scoring.num_slot,
16127 score_param->oce_wan_scoring.score_pcnt3_to_0,
16128 score_param->oce_wan_scoring.score_pcnt7_to_4,
16129 score_param->oce_wan_scoring.score_pcnt11_to_8,
16130 score_param->oce_wan_scoring.score_pcnt15_to_12);
16131
Govind Singha4836fd2016-03-07 16:45:38 +053016132 status = wmi_unified_cmd_send(wmi_handle, buf,
16133 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053016134 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016135 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016136 status);
Govind Singh67922e82016-04-01 16:48:57 +053016137 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053016138 }
16139
Govind Singhb53420c2016-03-09 14:32:57 +053016140 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053016141
Govind Singh67922e82016-04-01 16:48:57 +053016142 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016143}
16144
16145/**
16146 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
16147 * @wmi_handle: wmi handle
16148 * @scan_period: scan period
16149 * @scan_age: scan age
16150 * @vdev_id: vdev id
16151 *
16152 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
16153 *
16154 * Return: CDF status
16155 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016156static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016157 uint32_t scan_period,
16158 uint32_t scan_age,
16159 uint32_t vdev_id)
16160{
Govind Singh67922e82016-04-01 16:48:57 +053016161 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016162 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053016163 int len;
16164 uint8_t *buf_ptr;
16165 wmi_roam_scan_period_fixed_param *scan_period_fp;
16166
16167 /* Send scan period values */
16168 len = sizeof(wmi_roam_scan_period_fixed_param);
16169 buf = wmi_buf_alloc(wmi_handle, len);
16170 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016171 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16172 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016173 }
16174
16175 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16176 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
16177 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
16178 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
16179 WMITLV_GET_STRUCT_TLVLEN
16180 (wmi_roam_scan_period_fixed_param));
16181 /* fill in scan period values */
16182 scan_period_fp->vdev_id = vdev_id;
16183 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
16184 scan_period_fp->roam_scan_age = scan_age;
16185
16186 status = wmi_unified_cmd_send(wmi_handle, buf,
16187 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053016188 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016189 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016190 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016191 goto error;
16192 }
16193
Govind Singhb53420c2016-03-09 14:32:57 +053016194 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053016195 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053016196 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016197error:
16198 wmi_buf_free(buf);
16199
Govind Singh67922e82016-04-01 16:48:57 +053016200 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016201}
16202
16203/**
16204 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
16205 * @wmi_handle: wmi handle
16206 * @chan_count: channel count
16207 * @chan_list: channel list
16208 * @list_type: list type
16209 * @vdev_id: vdev id
16210 *
16211 * Set roam offload channel list.
16212 *
16213 * Return: CDF status
16214 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016215static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016216 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070016217 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053016218 uint8_t list_type, uint32_t vdev_id)
16219{
Govind Singha4836fd2016-03-07 16:45:38 +053016220 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016221 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016222 int len, list_tlv_len;
16223 int i;
16224 uint8_t *buf_ptr;
16225 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053016226 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053016227
16228 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053016229 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053016230 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053016231 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053016232 }
16233 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053016234 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053016235 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
16236 buf = wmi_buf_alloc(wmi_handle, len);
16237 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016238 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16239 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016240 }
16241
16242 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16243 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
16244 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
16245 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
16246 WMITLV_GET_STRUCT_TLVLEN
16247 (wmi_roam_chan_list_fixed_param));
16248 chan_list_fp->vdev_id = vdev_id;
16249 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053016250 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053016251 /* external app is controlling channel list */
16252 chan_list_fp->chan_list_type =
16253 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
16254 } else {
16255 /* umac supplied occupied channel list in LFR */
16256 chan_list_fp->chan_list_type =
16257 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
16258 }
16259
16260 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
16261 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16262 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053016263 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016264 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053016265 for (i = 0; ((i < chan_list_fp->num_chan) &&
16266 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
16267 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053016268 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053016269 }
16270
16271 status = wmi_unified_cmd_send(wmi_handle, buf,
16272 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053016273 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016274 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016275 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016276 goto error;
16277 }
16278
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016279 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053016280 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016281error:
16282 wmi_buf_free(buf);
16283
Govind Singh67922e82016-04-01 16:48:57 +053016284 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016285}
16286
16287/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016288 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
16289 * @wmi_handle: wmi handle
16290 * @req_buf: per roam config buffer
16291 *
16292 * Return: QDF status
16293 */
16294static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
16295 struct wmi_per_roam_config_req *req_buf)
16296{
16297 wmi_buf_t buf = NULL;
16298 QDF_STATUS status;
16299 int len;
16300 uint8_t *buf_ptr;
16301 wmi_roam_per_config_fixed_param *wmi_per_config;
16302
16303 len = sizeof(wmi_roam_per_config_fixed_param);
16304 buf = wmi_buf_alloc(wmi_handle, len);
16305 if (!buf) {
16306 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16307 return QDF_STATUS_E_NOMEM;
16308 }
16309
16310 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16311 wmi_per_config =
16312 (wmi_roam_per_config_fixed_param *) buf_ptr;
16313 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
16314 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
16315 WMITLV_GET_STRUCT_TLVLEN
16316 (wmi_roam_per_config_fixed_param));
16317
16318 /* fill in per roam config values */
16319 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016320
16321 wmi_per_config->enable = req_buf->per_config.enable;
16322 wmi_per_config->high_rate_thresh =
16323 (req_buf->per_config.tx_high_rate_thresh << 16) |
16324 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
16325 wmi_per_config->low_rate_thresh =
16326 (req_buf->per_config.tx_low_rate_thresh << 16) |
16327 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
16328 wmi_per_config->pkt_err_rate_thresh_pct =
16329 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
16330 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
16331 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053016332 wmi_per_config->pkt_err_rate_mon_time =
16333 (req_buf->per_config.tx_per_mon_time << 16) |
16334 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053016335 wmi_per_config->min_candidate_rssi =
16336 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016337
16338 /* Send per roam config parameters */
16339 status = wmi_unified_cmd_send(wmi_handle, buf,
16340 len, WMI_ROAM_PER_CONFIG_CMDID);
16341 if (QDF_IS_STATUS_ERROR(status)) {
16342 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
16343 status);
16344 wmi_buf_free(buf);
16345 return status;
16346 }
16347
16348 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
16349 req_buf->per_config.enable, req_buf->vdev_id);
16350 return QDF_STATUS_SUCCESS;
16351}
16352
16353/**
Govind Singha4836fd2016-03-07 16:45:38 +053016354 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
16355 * @wmi_handle: wmi handle
16356 * @rssi_change_thresh: RSSI Change threshold
16357 * @bcn_rssi_weight: beacon RSSI weight
16358 * @vdev_id: vdev id
16359 *
16360 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
16361 *
16362 * Return: CDF status
16363 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016364static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016365 uint32_t vdev_id,
16366 int32_t rssi_change_thresh,
16367 uint32_t bcn_rssi_weight,
16368 uint32_t hirssi_delay_btw_scans)
16369{
Govind Singha4836fd2016-03-07 16:45:38 +053016370 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053016371 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053016372 int len;
16373 uint8_t *buf_ptr;
16374 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
16375
16376 /* Send rssi change parameters */
16377 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
16378 buf = wmi_buf_alloc(wmi_handle, len);
16379 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016380 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16381 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053016382 }
16383
16384 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16385 rssi_change_fp =
16386 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
16387 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
16388 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
16389 WMITLV_GET_STRUCT_TLVLEN
16390 (wmi_roam_scan_rssi_change_threshold_fixed_param));
16391 /* fill in rssi change threshold (hysteresis) values */
16392 rssi_change_fp->vdev_id = vdev_id;
16393 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
16394 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
16395 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
16396
16397 status = wmi_unified_cmd_send(wmi_handle, buf,
16398 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053016399 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016400 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016401 status);
Govind Singha4836fd2016-03-07 16:45:38 +053016402 goto error;
16403 }
16404
Govind Singhb53420c2016-03-09 14:32:57 +053016405 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053016406 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053016407 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
16408 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016409error:
16410 wmi_buf_free(buf);
16411
Govind Singh67922e82016-04-01 16:48:57 +053016412 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053016413}
16414
16415/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
16416 * @wmi_handle: wmi handle.
16417 * @cmd: size of command structure.
16418 * @per_entry_size: per entry size.
16419 *
16420 * This utility function calculates how many hotlist entries can
16421 * fit in one page.
16422 *
16423 * Return: number of entries
16424 */
16425static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
16426 size_t cmd_size,
16427 size_t per_entry_size)
16428{
16429 uint32_t avail_space = 0;
16430 int num_entries = 0;
16431 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
16432
16433 /* Calculate number of hotlist entries that can
16434 * be passed in wma message request.
16435 */
16436 avail_space = max_msg_len - cmd_size;
16437 num_entries = avail_space / per_entry_size;
16438 return num_entries;
16439}
16440
16441/**
16442 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
16443 * @wmi_handle: wmi handle
16444 * @photlist: hotlist command params
16445 * @buf_len: buffer length
16446 *
16447 * This function fills individual elements for hotlist request and
16448 * TLV for bssid entries
16449 *
16450 * Return: CDF Status.
16451 */
Sathish Kumarfd347372017-02-13 12:29:09 +053016452static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053016453 struct ext_scan_setbssi_hotlist_params *
16454 photlist, int *buf_len)
16455{
16456 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
16457 wmi_extscan_hotlist_entry *dest_hotlist;
16458 struct ap_threshold_params *src_ap = photlist->ap;
16459 wmi_buf_t buf;
16460 uint8_t *buf_ptr;
16461
16462 int j, index = 0;
16463 int cmd_len = 0;
16464 int num_entries;
16465 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016466 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053016467 int len = sizeof(*cmd);
16468
16469 len += WMI_TLV_HDR_SIZE;
16470 cmd_len = len;
16471
16472 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
16473 cmd_len,
16474 sizeof(*dest_hotlist));
16475 /* setbssid hotlist expects the bssid list
16476 * to be non zero value
16477 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080016478 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080016479 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053016480 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053016481 }
16482
16483 /* Split the hot list entry pages and send multiple command
16484 * requests if the buffer reaches the maximum request size
16485 */
16486 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053016487 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053016488 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
16489 buf = wmi_buf_alloc(wmi_handle, len);
16490 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053016491 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
16492 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016493 }
16494 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16495 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
16496 buf_ptr;
16497 WMITLV_SET_HDR(&cmd->tlv_header,
16498 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
16499 WMITLV_GET_STRUCT_TLVLEN
16500 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
16501
16502 /* Multiple requests are sent until the num_entries_in_page
16503 * matches the total_entries
16504 */
16505 cmd->request_id = photlist->requestId;
16506 cmd->vdev_id = photlist->sessionId;
16507 cmd->total_entries = numap;
16508 cmd->mode = 1;
16509 cmd->num_entries_in_page = min_entries;
16510 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
16511 cmd->first_entry_index = index;
16512
Govind Singhb53420c2016-03-09 14:32:57 +053016513 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016514 __func__, cmd->vdev_id, cmd->total_entries,
16515 cmd->num_entries_in_page,
16516 cmd->lost_ap_scan_count);
16517
16518 buf_ptr += sizeof(*cmd);
16519 WMITLV_SET_HDR(buf_ptr,
16520 WMITLV_TAG_ARRAY_STRUC,
16521 min_entries * sizeof(wmi_extscan_hotlist_entry));
16522 dest_hotlist = (wmi_extscan_hotlist_entry *)
16523 (buf_ptr + WMI_TLV_HDR_SIZE);
16524
16525 /* Populate bssid, channel info and rssi
16526 * for the bssid's that are sent as hotlists.
16527 */
16528 for (j = 0; j < min_entries; j++) {
16529 WMITLV_SET_HDR(dest_hotlist,
16530 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
16531 WMITLV_GET_STRUCT_TLVLEN
16532 (wmi_extscan_hotlist_entry));
16533
16534 dest_hotlist->min_rssi = src_ap->low;
16535 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
16536 &dest_hotlist->bssid);
16537
Govind Singhb53420c2016-03-09 14:32:57 +053016538 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053016539 __func__, dest_hotlist->channel,
16540 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053016541 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053016542 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16543 __func__, dest_hotlist->bssid.mac_addr31to0,
16544 dest_hotlist->bssid.mac_addr47to32);
16545 dest_hotlist++;
16546 src_ap++;
16547 }
16548 buf_ptr += WMI_TLV_HDR_SIZE +
16549 (min_entries * sizeof(wmi_extscan_hotlist_entry));
16550
16551 if (wmi_unified_cmd_send(wmi_handle, buf, len,
16552 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053016553 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053016554 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053016555 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053016556 }
16557 index = index + min_entries;
16558 num_entries = numap - min_entries;
16559 len = cmd_len;
16560 }
Govind Singhb53420c2016-03-09 14:32:57 +053016561 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053016562}
16563
Govind Singhbca3b1b2016-05-02 17:59:24 +053016564/**
Dustin Brown4423f632017-01-13 15:24:07 -080016565 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
16566 * @wmi_handle: the WMI handle
16567 * @vdev_id: the Id of the vdev to apply the configuration to
16568 * @ucast_mode: the active BPF mode to configure for unicast packets
16569 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
16570 * packets
16571 *
16572 * Return: QDF status
16573 */
16574static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
16575 uint8_t vdev_id,
16576 enum wmi_host_active_bpf_mode ucast_mode,
16577 enum wmi_host_active_bpf_mode mcast_bcast_mode)
16578{
16579 const WMITLV_TAG_ID tag_id =
16580 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
16581 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
16582 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
16583 QDF_STATUS status;
16584 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
16585 wmi_buf_t buf;
16586
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016587 WMI_LOGD("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
Dustin Brown4423f632017-01-13 15:24:07 -080016588 vdev_id, ucast_mode, mcast_bcast_mode);
16589
16590 /* allocate command buffer */
16591 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
16592 if (!buf) {
16593 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
16594 return QDF_STATUS_E_NOMEM;
16595 }
16596
16597 /* set TLV header */
16598 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
16599 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
16600
16601 /* populate data */
16602 cmd->vdev_id = vdev_id;
16603 cmd->uc_mode = ucast_mode;
16604 cmd->mcbc_mode = mcast_bcast_mode;
16605
16606 /* send to FW */
16607 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
16608 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
16609 if (QDF_IS_STATUS_ERROR(status)) {
16610 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
16611 status);
16612 wmi_buf_free(buf);
16613 return status;
16614 }
16615
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080016616 WMI_LOGD("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
Dustin Brown4423f632017-01-13 15:24:07 -080016617
16618 return QDF_STATUS_SUCCESS;
16619}
16620
16621/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053016622 * send_power_dbg_cmd_tlv() - send power debug commands
16623 * @wmi_handle: wmi handle
16624 * @param: wmi power debug parameter
16625 *
16626 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
16627 *
16628 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16629 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070016630static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
16631 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053016632{
16633 wmi_buf_t buf = NULL;
16634 QDF_STATUS status;
16635 int len, args_tlv_len;
16636 uint8_t *buf_ptr;
16637 uint8_t i;
16638 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
16639 uint32_t *cmd_args;
16640
16641 /* Prepare and send power debug cmd parameters */
16642 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
16643 len = sizeof(*cmd) + args_tlv_len;
16644 buf = wmi_buf_alloc(wmi_handle, len);
16645 if (!buf) {
16646 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16647 return QDF_STATUS_E_NOMEM;
16648 }
16649
16650 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16651 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
16652 WMITLV_SET_HDR(&cmd->tlv_header,
16653 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
16654 WMITLV_GET_STRUCT_TLVLEN
16655 (wmi_pdev_wal_power_debug_cmd_fixed_param));
16656
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016657 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16658 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053016659 cmd->module_id = param->module_id;
16660 cmd->num_args = param->num_args;
16661 buf_ptr += sizeof(*cmd);
16662 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
16663 (param->num_args * sizeof(uint32_t)));
16664 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
16665 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080016666 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053016667 cmd_args[i] = param->args[i];
16668 WMI_LOGI("%d,", param->args[i]);
16669 }
16670
16671 status = wmi_unified_cmd_send(wmi_handle, buf,
16672 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
16673 if (QDF_IS_STATUS_ERROR(status)) {
16674 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
16675 status);
16676 goto error;
16677 }
16678
16679 return QDF_STATUS_SUCCESS;
16680error:
16681 wmi_buf_free(buf);
16682
16683 return status;
16684}
16685
Govind Singhe7f2f342016-05-23 12:12:52 +053016686/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053016687 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
16688 * @wmi_handle: wmi handle
16689 * @param: wmi multiple vdev restart req param
16690 *
16691 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
16692 *
16693 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16694 */
16695static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
16696 wmi_unified_t wmi_handle,
16697 struct multiple_vdev_restart_params *param)
16698{
16699 wmi_buf_t buf;
16700 QDF_STATUS qdf_status;
16701 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
16702 int i;
16703 uint8_t *buf_ptr;
16704 uint32_t *vdev_ids;
16705 wmi_channel *chan_info;
16706 struct channel_param *tchan_info;
16707 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
16708
16709 len += sizeof(wmi_channel);
16710 if (param->num_vdevs)
16711 len += sizeof(uint32_t) * param->num_vdevs;
16712
16713 buf = wmi_buf_alloc(wmi_handle, len);
16714 if (!buf) {
16715 WMI_LOGE("Failed to allocate memory\n");
16716 qdf_status = QDF_STATUS_E_NOMEM;
16717 goto end;
16718 }
16719
16720 buf_ptr = (uint8_t *)wmi_buf_data(buf);
16721 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
16722 buf_ptr;
16723
16724 WMITLV_SET_HDR(&cmd->tlv_header,
16725 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
16726 WMITLV_GET_STRUCT_TLVLEN
16727 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016728 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
16729 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016730 cmd->requestor_id = param->requestor_id;
16731 cmd->disable_hw_ack = param->disable_hw_ack;
16732 cmd->cac_duration_ms = param->cac_duration_ms;
16733 cmd->num_vdevs = param->num_vdevs;
16734
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016735 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
16736 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
16737 " cmd->num_vdevs: %d ",
16738 __func__, cmd->pdev_id, cmd->requestor_id,
16739 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016740 buf_ptr += sizeof(*cmd);
16741
16742 WMITLV_SET_HDR(buf_ptr,
16743 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053016744 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016745 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
16746 for (i = 0; i < param->num_vdevs; i++) {
16747 vdev_ids[i] = param->vdev_ids[i];
16748 }
16749
Vivekc5823092018-03-22 23:27:21 +053016750 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016751
16752 WMITLV_SET_HDR(buf_ptr,
16753 WMITLV_TAG_STRUC_wmi_channel,
16754 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053016755 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016756 tchan_info = &(param->ch_param);
16757 chan_info->mhz = tchan_info->mhz;
16758 chan_info->band_center_freq1 = tchan_info->cfreq1;
16759 chan_info->band_center_freq2 = tchan_info->cfreq2;
16760 if (tchan_info->is_chan_passive)
16761 WMI_SET_CHANNEL_FLAG(chan_info,
16762 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016763 if (tchan_info->dfs_set)
16764 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
16765
Sathish Kumar45e991b2017-02-27 10:35:40 +053016766 if (tchan_info->allow_vht)
16767 WMI_SET_CHANNEL_FLAG(chan_info,
16768 WMI_CHAN_FLAG_ALLOW_VHT);
16769 else if (tchan_info->allow_ht)
16770 WMI_SET_CHANNEL_FLAG(chan_info,
16771 WMI_CHAN_FLAG_ALLOW_HT);
16772 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
16773 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
16774 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
16775 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
16776 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
16777 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080016778 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053016779
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080016780 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
16781 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
16782 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
16783 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
16784 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
16785 "tchan_info->reg_class_id: %d ,"
16786 "tchan_info->maxregpower : %d ", __func__,
16787 tchan_info->is_chan_passive, tchan_info->dfs_set,
16788 tchan_info->allow_vht, tchan_info->allow_ht,
16789 tchan_info->antennamax, tchan_info->phy_mode,
16790 tchan_info->minpower, tchan_info->maxpower,
16791 tchan_info->maxregpower, tchan_info->reg_class_id,
16792 tchan_info->maxregpower);
16793
Sathish Kumar45e991b2017-02-27 10:35:40 +053016794 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
16795 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
16796
16797 if (QDF_IS_STATUS_ERROR(qdf_status)) {
16798 WMI_LOGE("%s: Failed to send\n", __func__);
16799 wmi_buf_free(buf);
16800 }
16801
16802end:
16803 return qdf_status;
16804}
16805
16806/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080016807 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
16808 * @wmi_handle: wmi handle
16809 * @pdev_id: pdev id
16810 *
16811 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
16812 *
16813 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16814 */
16815static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
16816 uint32_t pdev_id)
16817{
16818 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
16819 wmi_buf_t buf;
16820 uint16_t len;
16821 QDF_STATUS ret;
16822
16823 len = sizeof(*cmd);
16824 buf = wmi_buf_alloc(wmi_handle, len);
16825
16826 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16827
16828 if (!buf) {
16829 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16830 return QDF_STATUS_E_NOMEM;
16831 }
16832
16833 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
16834 wmi_buf_data(buf);
16835
16836 WMITLV_SET_HDR(&cmd->tlv_header,
16837 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
16838 WMITLV_GET_STRUCT_TLVLEN(
16839 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
16840
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016841 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016842 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16843 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
16844 if (QDF_IS_STATUS_ERROR(ret)) {
16845 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16846 __func__, ret, pdev_id);
16847 wmi_buf_free(buf);
16848 return QDF_STATUS_E_FAILURE;
16849 }
16850
16851 return QDF_STATUS_SUCCESS;
16852}
16853
16854/**
16855 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
16856 * @wmi_handle: wmi handle
16857 * @pdev_id: pdev id
16858 *
16859 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
16860 *
16861 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
16862 */
16863static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
16864 uint32_t pdev_id)
16865{
16866 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
16867 wmi_buf_t buf;
16868 uint16_t len;
16869 QDF_STATUS ret;
16870
16871 len = sizeof(*cmd);
16872 buf = wmi_buf_alloc(wmi_handle, len);
16873
16874 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
16875
16876 if (!buf) {
16877 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16878 return QDF_STATUS_E_NOMEM;
16879 }
16880
16881 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
16882 wmi_buf_data(buf);
16883
16884 WMITLV_SET_HDR(&cmd->tlv_header,
16885 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
16886 WMITLV_GET_STRUCT_TLVLEN(
16887 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
16888
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016889 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080016890 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16891 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
16892 if (QDF_IS_STATUS_ERROR(ret)) {
16893 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
16894 __func__, ret, pdev_id);
16895 wmi_buf_free(buf);
16896 return QDF_STATUS_E_FAILURE;
16897 }
16898
16899 return QDF_STATUS_SUCCESS;
16900}
16901
16902/**
Govind Singhe7f2f342016-05-23 12:12:52 +053016903 * init_cmd_send_tlv() - send initialization cmd to fw
16904 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053016905 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053016906 *
16907 * Return: QDF_STATUS_SUCCESS for success or error code
16908 */
16909static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053016910 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053016911{
16912 wmi_buf_t buf;
16913 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053016914 uint8_t *buf_ptr;
16915 wmi_resource_config *resource_cfg;
16916 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053016917 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053016918 uint16_t idx;
16919 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053016920 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053016921
Kiran Venkatappa26117052016-12-23 19:58:54 +053016922 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
16923 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016924 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053016925
16926 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
16927 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
16928 WMI_TLV_HDR_SIZE +
16929 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
16930
16931 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053016932 if (!buf) {
16933 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16934 return QDF_STATUS_E_FAILURE;
16935 }
16936
16937 buf_ptr = (uint8_t *) wmi_buf_data(buf);
16938 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
16939 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
16940
16941 host_mem_chunks = (wlan_host_memory_chunk *)
16942 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
16943 + WMI_TLV_HDR_SIZE);
16944
16945 WMITLV_SET_HDR(&cmd->tlv_header,
16946 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
16947 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
16948
Kiran Venkatappa26117052016-12-23 19:58:54 +053016949 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053016950 WMITLV_SET_HDR(&resource_cfg->tlv_header,
16951 WMITLV_TAG_STRUC_wmi_resource_config,
16952 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
16953
Kiran Venkatappa26117052016-12-23 19:58:54 +053016954 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053016955 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
16956 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
16957 WMITLV_GET_STRUCT_TLVLEN
16958 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053016959 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
16960 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
16961 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053016962 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
16963 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053016964 idx, host_mem_chunks[idx].size,
16965 host_mem_chunks[idx].ptr);
16966 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053016967 cmd->num_host_mem_chunks = param->num_mem_chunks;
16968 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
16969
Govind Singhe7f2f342016-05-23 12:12:52 +053016970 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
16971 WMITLV_TAG_ARRAY_STRUC,
16972 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053016973 param->num_mem_chunks));
16974
16975 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016976 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053016977
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016978 /* Fill fw_abi_vers */
16979 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053016980
Abhishek Singh716c46c2016-05-04 16:24:07 +053016981 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
16982 if (QDF_IS_STATUS_ERROR(ret)) {
16983 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
16984 ret);
16985 wmi_buf_free(buf);
16986 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053016987
Abhishek Singh716c46c2016-05-04 16:24:07 +053016988 return ret;
16989
Govind Singhe7f2f342016-05-23 12:12:52 +053016990}
16991
16992/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016993 * send_addba_send_cmd_tlv() - send addba send command to fw
16994 * @wmi_handle: wmi handle
16995 * @param: pointer to delba send params
16996 * @macaddr: peer mac address
16997 *
16998 * Send WMI_ADDBA_SEND_CMDID command to firmware
16999 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17000 */
17001static QDF_STATUS
17002send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
17003 uint8_t macaddr[IEEE80211_ADDR_LEN],
17004 struct addba_send_params *param)
17005{
17006 wmi_addba_send_cmd_fixed_param *cmd;
17007 wmi_buf_t buf;
17008 uint16_t len;
17009 QDF_STATUS ret;
17010
17011 len = sizeof(*cmd);
17012
17013 buf = wmi_buf_alloc(wmi_handle, len);
17014 if (!buf) {
17015 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17016 return QDF_STATUS_E_NOMEM;
17017 }
17018
17019 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
17020
17021 WMITLV_SET_HDR(&cmd->tlv_header,
17022 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
17023 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
17024
17025 cmd->vdev_id = param->vdev_id;
17026 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17027 cmd->tid = param->tidno;
17028 cmd->buffersize = param->buffersize;
17029
17030 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
17031 if (QDF_IS_STATUS_ERROR(ret)) {
17032 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17033 wmi_buf_free(buf);
17034 return QDF_STATUS_E_FAILURE;
17035 }
17036
17037 return QDF_STATUS_SUCCESS;
17038}
17039
17040/**
17041 * send_delba_send_cmd_tlv() - send delba send command to fw
17042 * @wmi_handle: wmi handle
17043 * @param: pointer to delba send params
17044 * @macaddr: peer mac address
17045 *
17046 * Send WMI_DELBA_SEND_CMDID command to firmware
17047 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
17048 */
17049static QDF_STATUS
17050send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
17051 uint8_t macaddr[IEEE80211_ADDR_LEN],
17052 struct delba_send_params *param)
17053{
17054 wmi_delba_send_cmd_fixed_param *cmd;
17055 wmi_buf_t buf;
17056 uint16_t len;
17057 QDF_STATUS ret;
17058
17059 len = sizeof(*cmd);
17060
17061 buf = wmi_buf_alloc(wmi_handle, len);
17062 if (!buf) {
17063 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
17064 return QDF_STATUS_E_NOMEM;
17065 }
17066
17067 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
17068
17069 WMITLV_SET_HDR(&cmd->tlv_header,
17070 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
17071 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
17072
17073 cmd->vdev_id = param->vdev_id;
17074 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17075 cmd->tid = param->tidno;
17076 cmd->initiator = param->initiator;
17077 cmd->reasoncode = param->reasoncode;
17078
17079 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
17080 if (QDF_IS_STATUS_ERROR(ret)) {
17081 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17082 wmi_buf_free(buf);
17083 return QDF_STATUS_E_FAILURE;
17084 }
17085
17086 return QDF_STATUS_SUCCESS;
17087}
17088
17089/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080017090 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
17091 * to fw
17092 * @wmi_handle: wmi handle
17093 * @param: pointer to addba clearresp params
17094 * @macaddr: peer mac address
17095 * Return: 0 for success or error code
17096 */
17097static QDF_STATUS
17098send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
17099 uint8_t macaddr[IEEE80211_ADDR_LEN],
17100 struct addba_clearresponse_params *param)
17101{
17102 wmi_addba_clear_resp_cmd_fixed_param *cmd;
17103 wmi_buf_t buf;
17104 uint16_t len;
17105 QDF_STATUS ret;
17106
17107 len = sizeof(*cmd);
17108
17109 buf = wmi_buf_alloc(wmi_handle, len);
17110 if (!buf) {
17111 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
17112 return QDF_STATUS_E_FAILURE;
17113 }
17114 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
17115
17116 WMITLV_SET_HDR(&cmd->tlv_header,
17117 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
17118 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
17119
17120 cmd->vdev_id = param->vdev_id;
17121 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
17122
17123 ret = wmi_unified_cmd_send(wmi_handle,
17124 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
17125 if (QDF_IS_STATUS_ERROR(ret)) {
17126 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
17127 wmi_buf_free(buf);
17128 return QDF_STATUS_E_FAILURE;
17129 }
17130
17131 return QDF_STATUS_SUCCESS;
17132}
17133
17134/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017135 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
17136 * @wmi_handle: wmi handle
17137 * @bcn_ctrl_param: pointer to bcn_offload_control param
17138 *
17139 * Return: QDF_STATUS_SUCCESS for success or error code
17140 */
17141static
17142QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
17143 struct bcn_offload_control *bcn_ctrl_param)
17144{
17145 wmi_buf_t buf;
17146 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
17147 QDF_STATUS ret;
17148 uint32_t len;
17149
17150 len = sizeof(*cmd);
17151
17152 buf = wmi_buf_alloc(wmi_handle, len);
17153 if (!buf) {
17154 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17155 return QDF_STATUS_E_FAILURE;
17156 }
17157
17158 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
17159 WMITLV_SET_HDR(&cmd->tlv_header,
17160 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
17161 WMITLV_GET_STRUCT_TLVLEN
17162 (wmi_bcn_offload_ctrl_cmd_fixed_param));
17163 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053017164 switch (bcn_ctrl_param->bcn_ctrl_op) {
17165 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017166 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053017167 break;
17168 case BCN_OFFLD_CTRL_TX_ENABLE:
17169 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
17170 break;
17171 case BCN_OFFLD_CTRL_SWBA_DISABLE:
17172 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
17173 break;
17174 case BCN_OFFLD_CTRL_SWBA_ENABLE:
17175 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
17176 break;
17177 default:
17178 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
17179 bcn_ctrl_param->bcn_ctrl_op);
17180 wmi_buf_free(buf);
17181 return QDF_STATUS_E_FAILURE;
17182 break;
17183 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017184 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
17185 WMI_BCN_OFFLOAD_CTRL_CMDID);
17186
17187 if (QDF_IS_STATUS_ERROR(ret)) {
17188 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
17189 ret);
17190 wmi_buf_free(buf);
17191 }
17192
17193 return ret;
17194}
17195
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017196#ifdef WLAN_FEATURE_NAN_CONVERGENCE
17197static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
17198 struct nan_datapath_initiator_req *ndp_req)
17199{
17200 uint16_t len;
17201 wmi_buf_t buf;
17202 uint8_t *tlv_ptr;
17203 QDF_STATUS status;
17204 wmi_channel *ch_tlv;
17205 wmi_ndp_initiator_req_fixed_param *cmd;
17206 uint32_t passphrase_len, service_name_len;
17207 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
17208
17209 /*
17210 * WMI command expects 4 byte alligned len:
17211 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17212 */
17213 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
17214 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
17215 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
17216 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
17217 service_name_len =
17218 qdf_roundup(ndp_req->service_name.service_name_len, 4);
17219 /* allocated memory for fixed params as well as variable size data */
17220 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
17221 + ndp_cfg_len + ndp_app_info_len + pmk_len
17222 + passphrase_len + service_name_len;
17223
17224 buf = wmi_buf_alloc(wmi_handle, len);
17225 if (!buf) {
17226 WMI_LOGE("wmi_buf_alloc failed");
17227 return QDF_STATUS_E_NOMEM;
17228 }
17229
17230 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
17231 WMITLV_SET_HDR(&cmd->tlv_header,
17232 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
17233 WMITLV_GET_STRUCT_TLVLEN(
17234 wmi_ndp_initiator_req_fixed_param));
17235 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
17236 cmd->transaction_id = ndp_req->transaction_id;
17237 cmd->service_instance_id = ndp_req->service_instance_id;
17238 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
17239 &cmd->peer_discovery_mac_addr);
17240
17241 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
17242 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
17243 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
17244 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
17245 cmd->nan_csid = ndp_req->ncs_sk_type;
17246 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
17247 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
17248
17249 ch_tlv = (wmi_channel *)&cmd[1];
17250 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
17251 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
17252 ch_tlv->mhz = ndp_req->channel;
17253 tlv_ptr = (uint8_t *)&ch_tlv[1];
17254
17255 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17256 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17257 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17258 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17259
17260 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17261 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17262 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
17263 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17264
17265 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17266 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
17267 cmd->nan_pmk_len);
17268 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17269
17270 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17271 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
17272 cmd->nan_passphrase_len);
17273 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17274
17275 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17276 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17277 ndp_req->service_name.service_name,
17278 cmd->nan_servicename_len);
17279 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17280
17281 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
17282 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
17283 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
17284 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
17285 cmd->peer_discovery_mac_addr.mac_addr31to0,
17286 cmd->peer_discovery_mac_addr.mac_addr47to32);
17287
17288 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
17289 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17290 ndp_req->ndp_config.ndp_cfg,
17291 ndp_req->ndp_config.ndp_cfg_len);
17292
17293 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
17294 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17295 ndp_req->ndp_info.ndp_app_info,
17296 ndp_req->ndp_info.ndp_app_info_len);
17297
17298 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17299 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17300 ndp_req->pmk.pmk, cmd->nan_pmk_len);
17301
17302 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17303 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17304 ndp_req->passphrase.passphrase,
17305 cmd->nan_passphrase_len);
17306
17307 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17308 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17309 ndp_req->service_name.service_name,
17310 cmd->nan_servicename_len);
17311
17312 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
17313 WMI_NDP_INITIATOR_REQ_CMDID);
17314
17315 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17316 WMI_NDP_INITIATOR_REQ_CMDID);
17317 if (QDF_IS_STATUS_ERROR(status)) {
17318 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
17319 wmi_buf_free(buf);
17320 }
17321
17322 return status;
17323}
17324
17325static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
17326 struct nan_datapath_responder_req *req)
17327{
17328 uint16_t len;
17329 wmi_buf_t buf;
17330 uint8_t *tlv_ptr;
17331 QDF_STATUS status;
17332 wmi_ndp_responder_req_fixed_param *cmd;
17333 uint32_t passphrase_len, service_name_len;
17334 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
17335
17336 vdev_id = wlan_vdev_get_id(req->vdev);
17337 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
17338 vdev_id, req->transaction_id,
17339 req->ndp_rsp,
17340 req->ndp_instance_id,
17341 req->ndp_info.ndp_app_info_len);
17342
17343 /*
17344 * WMI command expects 4 byte alligned len:
17345 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
17346 */
17347 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
17348 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
17349 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
17350 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
17351 service_name_len =
17352 qdf_roundup(req->service_name.service_name_len, 4);
17353
17354 /* allocated memory for fixed params as well as variable size data */
17355 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
17356 + pmk_len + passphrase_len + service_name_len;
17357
17358 buf = wmi_buf_alloc(wmi_handle, len);
17359 if (!buf) {
17360 WMI_LOGE("wmi_buf_alloc failed");
17361 return QDF_STATUS_E_NOMEM;
17362 }
17363 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
17364 WMITLV_SET_HDR(&cmd->tlv_header,
17365 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
17366 WMITLV_GET_STRUCT_TLVLEN(
17367 wmi_ndp_responder_req_fixed_param));
17368 cmd->vdev_id = vdev_id;
17369 cmd->transaction_id = req->transaction_id;
17370 cmd->ndp_instance_id = req->ndp_instance_id;
17371 cmd->rsp_code = req->ndp_rsp;
17372 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
17373 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
17374 cmd->nan_pmk_len = req->pmk.pmk_len;
17375 cmd->nan_csid = req->ncs_sk_type;
17376 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
17377 cmd->nan_servicename_len = req->service_name.service_name_len;
17378
17379 tlv_ptr = (uint8_t *)&cmd[1];
17380 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
17381 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17382 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
17383
17384 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
17385 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
17386 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17387 req->ndp_info.ndp_app_info,
17388 req->ndp_info.ndp_app_info_len);
17389
17390 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
17391 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
17392 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
17393 cmd->nan_pmk_len);
17394
17395 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
17396 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
17397 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17398 req->passphrase.passphrase,
17399 cmd->nan_passphrase_len);
17400 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
17401
17402 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
17403 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
17404 req->service_name.service_name,
17405 cmd->nan_servicename_len);
17406
17407 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
17408
17409 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
17410 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
17411
17412 WMI_LOGD("ndp_config len: %d",
17413 req->ndp_config.ndp_cfg_len);
17414 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17415 req->ndp_config.ndp_cfg,
17416 req->ndp_config.ndp_cfg_len);
17417
17418 WMI_LOGD("ndp_app_info len: %d",
17419 req->ndp_info.ndp_app_info_len);
17420 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17421 req->ndp_info.ndp_app_info,
17422 req->ndp_info.ndp_app_info_len);
17423
17424 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
17425 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17426 req->pmk.pmk, cmd->nan_pmk_len);
17427
17428 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
17429 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17430 req->passphrase.passphrase,
17431 cmd->nan_passphrase_len);
17432
17433 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
17434 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17435 req->service_name.service_name,
17436 cmd->nan_servicename_len);
17437
17438 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
17439 WMI_NDP_RESPONDER_REQ_CMDID);
17440 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17441 WMI_NDP_RESPONDER_REQ_CMDID);
17442 if (QDF_IS_STATUS_ERROR(status)) {
17443 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
17444 wmi_buf_free(buf);
17445 }
17446 return status;
17447}
17448
17449static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
17450 struct nan_datapath_end_req *req)
17451{
17452 uint16_t len;
17453 wmi_buf_t buf;
17454 QDF_STATUS status;
17455 uint32_t ndp_end_req_len, i;
17456 wmi_ndp_end_req *ndp_end_req_lst;
17457 wmi_ndp_end_req_fixed_param *cmd;
17458
17459 /* len of tlv following fixed param */
17460 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
17461 /* above comes out to 4 byte alligned already, no need of padding */
17462 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
17463 buf = wmi_buf_alloc(wmi_handle, len);
17464 if (!buf) {
17465 WMI_LOGE("Malloc failed");
17466 return QDF_STATUS_E_NOMEM;
17467 }
17468
17469 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
17470 WMITLV_SET_HDR(&cmd->tlv_header,
17471 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
17472 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
17473
17474 cmd->transaction_id = req->transaction_id;
17475
17476 /* set tlv pointer to end of fixed param */
17477 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
17478 ndp_end_req_len);
17479
17480 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
17481 WMI_TLV_HDR_SIZE);
17482 for (i = 0; i < req->num_ndp_instances; i++) {
17483 WMITLV_SET_HDR(&ndp_end_req_lst[i],
17484 WMITLV_TAG_ARRAY_FIXED_STRUC,
17485 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
17486
17487 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
17488 }
17489
17490 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
17491 status = wmi_unified_cmd_send(wmi_handle, buf, len,
17492 WMI_NDP_END_REQ_CMDID);
17493 if (QDF_IS_STATUS_ERROR(status)) {
17494 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
17495 wmi_buf_free(buf);
17496 }
17497
17498 return status;
17499}
17500
17501static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017502 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017503{
17504 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
17505 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
17506
17507 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
17508 fixed_params = event->fixed_param;
17509
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017510 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017511 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17512 fixed_params->vdev_id,
17513 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017514 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017515 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017516 return QDF_STATUS_E_INVAL;
17517 }
17518
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017519 rsp->transaction_id = fixed_params->transaction_id;
17520 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17521 rsp->status = fixed_params->rsp_status;
17522 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017523
17524 return QDF_STATUS_SUCCESS;
17525}
17526
17527static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017528 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017529{
17530 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
17531 wmi_ndp_indication_event_fixed_param *fixed_params;
17532
17533 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
17534 fixed_params =
17535 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
17536
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017537 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17538 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17539 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17540 return QDF_STATUS_E_INVAL;
17541 }
17542
17543 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17544 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17545 fixed_params->ndp_app_info_len,
17546 event->num_ndp_app_info);
17547 return QDF_STATUS_E_INVAL;
17548 }
17549
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017550 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017551 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17552 fixed_params->vdev_id,
17553 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017554 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017555 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017556 return QDF_STATUS_E_INVAL;
17557 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017558 rsp->service_instance_id = fixed_params->service_instance_id;
17559 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17560 rsp->role = fixed_params->self_ndp_role;
17561 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017562
17563 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017564 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017565 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017566 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017567
17568 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
17569 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
17570 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
17571 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
17572 fixed_params->service_instance_id,
17573 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
17574 fixed_params->accept_policy,
17575 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017576 rsp->peer_mac_addr.bytes,
17577 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017578
17579 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17580 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17581 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17582
17583 WMI_LOGD("ndp_app_info - %d bytes",
17584 fixed_params->ndp_app_info_len);
17585 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17586 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17587
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017588 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
17589 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17590 rsp->ncs_sk_type = fixed_params->nan_csid;
17591 rsp->scid.scid_len = fixed_params->nan_scid_len;
17592 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
17593 rsp->ndp_config.ndp_cfg_len);
17594 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
17595 rsp->ndp_info.ndp_app_info_len);
17596 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017597 WMI_LOGD("scid hex dump:");
17598 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017599 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017600
17601 return QDF_STATUS_SUCCESS;
17602}
17603
17604static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017605 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017606{
17607 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
17608 wmi_ndp_confirm_event_fixed_param *fixed_params;
17609
17610 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
17611 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
17612 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",
17613 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
17614 fixed_params->ndp_instance_id, fixed_params->rsp_code,
17615 fixed_params->reason_code,
17616 fixed_params->num_active_ndps_on_peer);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017617
17618 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
17619 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
17620 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
17621 return QDF_STATUS_E_INVAL;
17622 }
17623
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017624 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
17625 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17626 &event->ndp_cfg, fixed_params->ndp_cfg_len);
17627
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053017628 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
17629 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
17630 fixed_params->ndp_app_info_len,
17631 event->num_ndp_app_info);
17632 return QDF_STATUS_E_INVAL;
17633 }
17634
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017635 WMI_LOGD("ndp_app_info - %d bytes",
17636 fixed_params->ndp_app_info_len);
17637 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
17638 &event->ndp_app_info, fixed_params->ndp_app_info_len);
17639
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017640 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017641 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17642 fixed_params->vdev_id,
17643 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017644 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017645 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017646 return QDF_STATUS_E_INVAL;
17647 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017648 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
17649 rsp->rsp_code = fixed_params->rsp_code;
17650 rsp->reason_code = fixed_params->reason_code;
17651 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017652 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017653 rsp->peer_ndi_mac_addr.bytes);
17654 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
17655 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
17656 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017657
17658 return QDF_STATUS_SUCCESS;
17659}
17660
17661static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017662 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017663{
17664 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
17665 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
17666
17667 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
17668 fixed_params = event->fixed_param;
17669
17670 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",
17671 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017672 rsp->peer_mac_addr.bytes, rsp->transaction_id,
17673 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017674
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017675 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017676 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
17677 fixed_params->vdev_id,
17678 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017679 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017680 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017681 return QDF_STATUS_E_INVAL;
17682 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017683 rsp->transaction_id = fixed_params->transaction_id;
17684 rsp->reason = fixed_params->reason_code;
17685 rsp->status = fixed_params->rsp_status;
17686 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017687 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017688 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017689
17690 return QDF_STATUS_SUCCESS;
17691}
17692
17693static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017694 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017695{
17696 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
17697 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
17698
17699 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
17700 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
17701 WMI_LOGD("WMI_NDP_END_RSP_EVENTID(0x%X) recieved. transaction_id: %d, rsp_status: %d, reason_code: %d",
17702 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
17703 fixed_params->rsp_status, fixed_params->reason_code);
17704
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017705 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017706 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017707 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017708 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017709 return QDF_STATUS_E_INVAL;
17710 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017711 rsp->transaction_id = fixed_params->transaction_id;
17712 rsp->reason = fixed_params->reason_code;
17713 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017714
17715 return QDF_STATUS_SUCCESS;
17716}
17717
17718static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
17719 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
17720{
17721 uint32_t i, buf_size;
17722 wmi_ndp_end_indication *ind;
17723 struct qdf_mac_addr peer_addr;
17724 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
17725
17726 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
17727 ind = event->ndp_end_indication_list;
17728
17729 if (event->num_ndp_end_indication_list == 0) {
17730 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017731 return QDF_STATUS_E_INVAL;
17732 }
17733
17734 WMI_LOGD("number of ndp instances = %d",
17735 event->num_ndp_end_indication_list);
17736
17737 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
17738 sizeof((*rsp)->ndp_map[0]))) {
17739 WMI_LOGE("num_ndp_end_ind_list %d too large",
17740 event->num_ndp_end_indication_list);
17741 return QDF_STATUS_E_INVAL;
17742 }
17743
17744 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
17745 sizeof((*rsp)->ndp_map[0]);
17746 *rsp = qdf_mem_malloc(buf_size);
17747 if (!(*rsp)) {
17748 WMI_LOGE("Failed to allocate memory");
17749 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017750 }
17751
17752 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
17753 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
17754 if (!(*rsp)->vdev) {
17755 WMI_LOGE("vdev is null");
17756 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080017757 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017758 return QDF_STATUS_E_INVAL;
17759 }
17760
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017761 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
17762 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
17763 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17764 peer_addr.bytes);
17765 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
17766 i, ind[i].type, ind[i].reason_code,
17767 ind[i].ndp_instance_id,
17768 ind[i].num_active_ndps_on_peer);
17769 /* Add each instance entry to the list */
17770 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
17771 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
17772 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
17773 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
17774 (*rsp)->ndp_map[i].num_active_ndp_sessions =
17775 ind[i].num_active_ndps_on_peer;
17776 (*rsp)->ndp_map[i].type = ind[i].type;
17777 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
17778 }
17779
17780 return QDF_STATUS_SUCCESS;
17781}
17782#endif
17783
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017784/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017785 * save_service_bitmap_tlv() - save service bitmap
17786 * @wmi_handle: wmi handle
17787 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017788 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017789 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017790 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017791 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017792static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017793QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017794 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017795{
17796 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017797 struct wmi_soc *soc = wmi_handle->soc;
17798
Govind Singhe7f2f342016-05-23 12:12:52 +053017799 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17800
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017801 /* If it is already allocated, use that buffer. This can happen
17802 * during target stop/start scenarios where host allocation is skipped.
17803 */
17804 if (!soc->wmi_service_bitmap) {
17805 soc->wmi_service_bitmap =
17806 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17807 if (!soc->wmi_service_bitmap) {
17808 WMI_LOGE("Failed memory allocation for service bitmap");
17809 return QDF_STATUS_E_NOMEM;
17810 }
17811 }
17812
17813 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017814 param_buf->wmi_service_bitmap,
17815 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017816
17817 if (bitmap_buf)
17818 qdf_mem_copy(bitmap_buf,
17819 param_buf->wmi_service_bitmap,
17820 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017821
17822 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017823}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017824
17825/**
17826 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17827 * @wmi_handle: wmi handle
17828 * @param evt_buf: pointer to event buffer
17829 * @param bitmap_buf: bitmap buffer, for converged legacy support
17830 *
17831 * Return: QDF_STATUS
17832 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017833static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017834QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017835 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017836{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017837 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17838 wmi_service_available_event_fixed_param *ev;
17839 struct wmi_soc *soc = wmi_handle->soc;
17840
17841 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17842
17843 ev = param_buf->fixed_param;
17844
17845 /* If it is already allocated, use that buffer. This can happen
17846 * during target stop/start scenarios where host allocation is skipped.
17847 */
17848 if (!soc->wmi_ext_service_bitmap) {
17849 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17850 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17851 if (!soc->wmi_ext_service_bitmap) {
17852 WMI_LOGE("Failed memory allocation for service bitmap");
17853 return QDF_STATUS_E_NOMEM;
17854 }
17855 }
17856
17857 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17858 ev->wmi_service_segment_bitmap,
17859 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017860
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017861 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17862 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17863 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17864
Rajeev Kumar77901472017-02-12 02:12:17 -080017865 if (bitmap_buf)
17866 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017867 soc->wmi_ext_service_bitmap,
17868 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017869
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017870 return QDF_STATUS_SUCCESS;
17871}
Govind Singhe7f2f342016-05-23 12:12:52 +053017872/**
17873 * is_service_enabled_tlv() - Check if service enabled
17874 * @param wmi_handle: wmi handle
17875 * @param service_id: service identifier
17876 *
17877 * Return: 1 enabled, 0 disabled
17878 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017879static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17880 uint32_t service_id)
17881{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017882 struct wmi_soc *soc = wmi_handle->soc;
17883
17884 if (!soc->wmi_service_bitmap) {
17885 WMI_LOGE("WMI service bit map is not saved yet\n");
17886 return false;
17887 }
17888
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017889 /* if wmi_service_enabled was received with extended bitmap,
17890 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017891 */
17892 if (soc->wmi_ext_service_bitmap)
17893 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17894 soc->wmi_ext_service_bitmap,
17895 service_id);
17896
17897 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17898 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017899}
Govind Singhe7f2f342016-05-23 12:12:52 +053017900
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017901static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17902 struct wlan_psoc_target_capability_info *cap)
17903{
17904 /* except LDPC all flags are common betwen legacy and here
17905 * also IBFEER is not defined for TLV
17906 */
17907 cap->ht_cap_info |= ev_target_cap & (
17908 WMI_HT_CAP_ENABLED
17909 | WMI_HT_CAP_HT20_SGI
17910 | WMI_HT_CAP_DYNAMIC_SMPS
17911 | WMI_HT_CAP_TX_STBC
17912 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17913 | WMI_HT_CAP_RX_STBC
17914 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17915 | WMI_HT_CAP_LDPC
17916 | WMI_HT_CAP_L_SIG_TXOP_PROT
17917 | WMI_HT_CAP_MPDU_DENSITY
17918 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17919 | WMI_HT_CAP_HT40_SGI);
17920 if (ev_target_cap & WMI_HT_CAP_LDPC)
17921 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17922 WMI_HOST_HT_CAP_TX_LDPC;
17923}
Govind Singhe7f2f342016-05-23 12:12:52 +053017924/**
17925 * extract_service_ready_tlv() - extract service ready event
17926 * @wmi_handle: wmi handle
17927 * @param evt_buf: pointer to received event buffer
17928 * @param cap: pointer to hold target capability information extracted from even
17929 *
17930 * Return: QDF_STATUS_SUCCESS for success or error code
17931 */
17932static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017933 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017934{
17935 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17936 wmi_service_ready_event_fixed_param *ev;
17937
17938
17939 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17940
17941 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17942 if (!ev) {
17943 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17944 return QDF_STATUS_E_FAILURE;
17945 }
17946
17947 cap->phy_capability = ev->phy_capability;
17948 cap->max_frag_entry = ev->max_frag_entry;
17949 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017950 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017951 cap->vht_cap_info = ev->vht_cap_info;
17952 cap->vht_supp_mcs = ev->vht_supp_mcs;
17953 cap->hw_min_tx_power = ev->hw_min_tx_power;
17954 cap->hw_max_tx_power = ev->hw_max_tx_power;
17955 cap->sys_cap_info = ev->sys_cap_info;
17956 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17957 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17958 cap->max_num_scan_channels = ev->max_num_scan_channels;
17959 cap->max_supported_macs = ev->max_supported_macs;
17960 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17961 cap->txrx_chainmask = ev->txrx_chainmask;
17962 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17963 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017964 cap->fw_version = ev->fw_build_vers;
17965 /* fw_version_1 is not available in TLV. */
17966 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017967
17968 return QDF_STATUS_SUCCESS;
17969}
17970
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017971/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17972 * to host internal WMI_HOST_REGDMN_MODE values.
17973 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17974 * host currently. Add this in the future if required.
17975 * 11AX (Phase II) : 11ax related values are not currently
17976 * advertised separately by FW. As part of phase II regulatory bring-up,
17977 * finalize the advertisement mechanism.
17978 * @target_wireless_mode: target wireless mode received in message
17979 *
17980 * Return: returns the host internal wireless mode.
17981 */
17982static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17983{
17984
17985 uint32_t wireless_modes = 0;
17986
17987 if (target_wireless_mode & REGDMN_MODE_11A)
17988 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17989
17990 if (target_wireless_mode & REGDMN_MODE_TURBO)
17991 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17992
17993 if (target_wireless_mode & REGDMN_MODE_11B)
17994 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17995
17996 if (target_wireless_mode & REGDMN_MODE_PUREG)
17997 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17998
17999 if (target_wireless_mode & REGDMN_MODE_11G)
18000 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
18001
18002 if (target_wireless_mode & REGDMN_MODE_108G)
18003 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
18004
18005 if (target_wireless_mode & REGDMN_MODE_108A)
18006 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
18007
18008 if (target_wireless_mode & REGDMN_MODE_XR)
18009 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
18010
18011 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
18012 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
18013
18014 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
18015 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
18016
18017 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
18018 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
18019
18020 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
18021 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
18022
18023 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
18024 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
18025
18026 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
18027 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
18028
18029 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
18030 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
18031
18032 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
18033 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
18034
18035 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
18036 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
18037
18038 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
18039 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
18040
18041 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
18042 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
18043
18044 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
18045 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
18046
18047 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
18048 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
18049
18050 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
18051 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
18052
18053 return wireless_modes;
18054}
18055
Govind Singhe7f2f342016-05-23 12:12:52 +053018056/**
18057 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
18058 * @wmi_handle: wmi handle
18059 * @param evt_buf: Pointer to event buffer
18060 * @param cap: pointer to hold HAL reg capabilities
18061 *
18062 * Return: QDF_STATUS_SUCCESS for success or error code
18063 */
18064static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080018065 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053018066{
18067 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18068
18069 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18070
18071 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
18072 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080018073 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053018074
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053018075 cap->wireless_modes = convert_wireless_modes_tlv(
18076 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053018077
Govind Singhe7f2f342016-05-23 12:12:52 +053018078 return QDF_STATUS_SUCCESS;
18079}
18080
18081/**
18082 * extract_host_mem_req_tlv() - Extract host memory request event
18083 * @wmi_handle: wmi handle
18084 * @param evt_buf: pointer to event buffer
18085 * @param num_entries: pointer to hold number of entries requested
18086 *
18087 * Return: Number of entries requested
18088 */
18089static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
18090 void *evt_buf, uint8_t *num_entries)
18091{
18092 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18093 wmi_service_ready_event_fixed_param *ev;
18094
18095 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18096
18097 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18098 if (!ev) {
18099 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18100 return NULL;
18101 }
18102
18103 *num_entries = ev->num_mem_reqs;
18104
18105 return (host_mem_req *)param_buf->mem_reqs;
18106}
18107
18108/**
18109 * save_fw_version_in_service_ready_tlv() - Save fw version in service
18110 * ready function
18111 * @wmi_handle: wmi handle
18112 * @param evt_buf: pointer to event buffer
18113 *
18114 * Return: QDF_STATUS_SUCCESS for success or error code
18115 */
18116static QDF_STATUS
18117save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
18118{
18119 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
18120 wmi_service_ready_event_fixed_param *ev;
18121
18122
18123 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
18124
18125 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
18126 if (!ev) {
18127 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
18128 return QDF_STATUS_E_FAILURE;
18129 }
18130
18131 /*Save fw version from service ready message */
18132 /*This will be used while sending INIT message */
18133 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
18134 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053018135
Govind Singhe7f2f342016-05-23 12:12:52 +053018136 return QDF_STATUS_SUCCESS;
18137}
18138
18139/**
18140 * ready_extract_init_status_tlv() - Extract init status from ready event
18141 * @wmi_handle: wmi handle
18142 * @param evt_buf: Pointer to event buffer
18143 *
18144 * Return: ready status
18145 */
18146static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
18147 void *evt_buf)
18148{
18149 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18150 wmi_ready_event_fixed_param *ev = NULL;
18151
Govind Singhe7f2f342016-05-23 12:12:52 +053018152 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18153 ev = param_buf->fixed_param;
18154
18155 qdf_print("%s:%d\n", __func__, ev->status);
18156
18157 return ev->status;
18158}
18159
18160/**
18161 * ready_extract_mac_addr_tlv() - extract mac address from ready event
18162 * @wmi_handle: wmi handle
18163 * @param evt_buf: pointer to event buffer
18164 * @param macaddr: Pointer to hold MAC address
18165 *
18166 * Return: QDF_STATUS_SUCCESS for success or error code
18167 */
18168static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
18169 void *evt_buf, uint8_t *macaddr)
18170{
18171 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18172 wmi_ready_event_fixed_param *ev = NULL;
18173
18174
18175 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18176 ev = param_buf->fixed_param;
18177
18178 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
18179
18180 return QDF_STATUS_SUCCESS;
18181}
18182
18183/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070018184 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
18185 * @wmi_handle: wmi handle
18186 * @param evt_buf: pointer to event buffer
18187 * @param macaddr: Pointer to hold number of MAC addresses
18188 *
18189 * Return: Pointer to addr list
18190 */
18191static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
18192 void *evt_buf, uint8_t *num_mac)
18193{
18194 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18195 wmi_ready_event_fixed_param *ev = NULL;
18196
18197 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18198 ev = param_buf->fixed_param;
18199
18200 *num_mac = ev->num_extra_mac_addr;
18201
18202 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
18203}
18204
18205/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018206 * extract_ready_params_tlv() - Extract data from ready event apart from
18207 * status, macaddr and version.
18208 * @wmi_handle: Pointer to WMI handle.
18209 * @evt_buf: Pointer to Ready event buffer.
18210 * @ev_param: Pointer to host defined struct to copy the data from event.
18211 *
18212 * Return: QDF_STATUS_SUCCESS on success.
18213 */
18214static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
18215 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
18216{
18217 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
18218 wmi_ready_event_fixed_param *ev = NULL;
18219
18220 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
18221 ev = param_buf->fixed_param;
18222
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018223 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018224 ev_param->num_dscp_table = ev->num_dscp_table;
18225 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
18226 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053018227 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053018228 /* Agile_cap in ready event is not supported in TLV target */
18229 ev_param->agile_capability = false;
18230
18231 return QDF_STATUS_SUCCESS;
18232}
18233
18234/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018235 * extract_dbglog_data_len_tlv() - extract debuglog data length
18236 * @wmi_handle: wmi handle
18237 * @param evt_buf: pointer to event buffer
18238 *
18239 * Return: length
18240 */
18241static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080018242 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053018243{
18244 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
18245
18246 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
18247
18248 *len = param_buf->num_bufp;
18249
18250 return param_buf->bufp;
18251}
18252
18253/**
18254 * extract_vdev_start_resp_tlv() - extract vdev start response
18255 * @wmi_handle: wmi handle
18256 * @param evt_buf: pointer to event buffer
18257 * @param vdev_rsp: Pointer to hold vdev response
18258 *
18259 * Return: QDF_STATUS_SUCCESS for success or error code
18260 */
18261static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
18262 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
18263{
18264 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
18265 wmi_vdev_start_response_event_fixed_param *ev;
18266
18267 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
18268 if (!param_buf) {
18269 qdf_print("Invalid start response event buffer\n");
18270 return QDF_STATUS_E_INVAL;
18271 }
18272
18273 ev = param_buf->fixed_param;
18274 if (!ev) {
18275 qdf_print("Invalid start response event buffer\n");
18276 return QDF_STATUS_E_INVAL;
18277 }
18278
18279 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
18280
18281 vdev_rsp->vdev_id = ev->vdev_id;
18282 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070018283 switch (ev->resp_type) {
18284 case WMI_VDEV_START_RESP_EVENT:
18285 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
18286 break;
18287 case WMI_VDEV_RESTART_RESP_EVENT:
18288 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
18289 break;
18290 default:
18291 qdf_print("Invalid start response event buffer\n");
18292 break;
18293 };
Govind Singhe7f2f342016-05-23 12:12:52 +053018294 vdev_rsp->status = ev->status;
18295 vdev_rsp->chain_mask = ev->chain_mask;
18296 vdev_rsp->smps_mode = ev->smps_mode;
18297 vdev_rsp->mac_id = ev->mac_id;
18298 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
18299 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
18300
18301 return QDF_STATUS_SUCCESS;
18302}
18303
18304/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053018305 * extract_vdev_delete_resp_tlv() - extract vdev delete response
18306 * @wmi_handle: wmi handle
18307 * @param evt_buf: pointer to event buffer
18308 * @param delete_rsp: Pointer to hold vdev delete response
18309 *
18310 * Return: QDF_STATUS_SUCCESS for success or error code
18311 */
18312static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
18313 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
18314{
18315 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
18316 wmi_vdev_delete_resp_event_fixed_param *ev;
18317
18318 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
18319 if (!param_buf) {
18320 WMI_LOGE("Invalid vdev delete response event buffer\n");
18321 return QDF_STATUS_E_INVAL;
18322 }
18323
18324 ev = param_buf->fixed_param;
18325 if (!ev) {
18326 WMI_LOGE("Invalid vdev delete response event\n");
18327 return QDF_STATUS_E_INVAL;
18328 }
18329
18330 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
18331 delete_rsp->vdev_id = ev->vdev_id;
18332
18333 return QDF_STATUS_SUCCESS;
18334}
18335
18336
18337/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018338 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053018339 * @wmi_handle: wmi handle
18340 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018341 * @param num_vdevs: Pointer to hold num vdev
18342 *
18343 * Return: QDF_STATUS_SUCCESS for success or error code
18344 */
18345static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18346 void *evt_buf, uint32_t *num_vdevs)
18347{
18348 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18349 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
18350 uint32_t vdev_map;
18351
18352 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
18353 if (!param_buf) {
18354 qdf_print("Invalid tbtt update ext event buffer\n");
18355 return QDF_STATUS_E_INVAL;
18356 }
18357 tbtt_offset_event = param_buf->fixed_param;
18358 vdev_map = tbtt_offset_event->vdev_map;
18359 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18360
18361 return QDF_STATUS_SUCCESS;
18362}
18363
18364/**
18365 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
18366 * @wmi_handle: wmi handle
18367 * @param evt_buf: pointer to event buffer
18368 * @param num_vdevs: Pointer to hold num vdev
18369 *
18370 * Return: QDF_STATUS_SUCCESS for success or error code
18371 */
18372static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
18373 void *evt_buf, uint32_t *num_vdevs)
18374{
18375 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18376 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
18377
18378 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18379 if (!param_buf) {
18380 qdf_print("Invalid tbtt update ext event buffer\n");
18381 return QDF_STATUS_E_INVAL;
18382 }
18383 tbtt_offset_ext_event = param_buf->fixed_param;
18384
18385 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
18386
18387 return QDF_STATUS_SUCCESS;
18388}
18389
18390/**
18391 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
18392 * @wmi_handle: wmi handle
18393 * @param evt_buf: pointer to event buffer
18394 * @param idx: Index refering to a vdev
18395 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053018396 *
18397 * Return: QDF_STATUS_SUCCESS for success or error code
18398 */
18399static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018400 void *evt_buf, uint8_t idx,
18401 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018402{
18403 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
18404 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018405 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018406
18407 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
18408 if (!param_buf) {
18409 qdf_print("Invalid tbtt update event buffer\n");
18410 return QDF_STATUS_E_INVAL;
18411 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018412
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018413 tbtt_offset_event = param_buf->fixed_param;
18414 vdev_map = tbtt_offset_event->vdev_map;
18415 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
18416 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
18417 return QDF_STATUS_E_INVAL;
18418 tbtt_param->tbttoffset =
18419 param_buf->tbttoffset_list[tbtt_param->vdev_id];
18420
18421 return QDF_STATUS_SUCCESS;
18422}
18423
18424/**
18425 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
18426 * @wmi_handle: wmi handle
18427 * @param evt_buf: pointer to event buffer
18428 * @param idx: Index refering to a vdev
18429 * @param tbtt_param: Pointer to tbttoffset event param
18430 *
18431 * Return: QDF_STATUS_SUCCESS for success or error code
18432 */
18433static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
18434 void *evt_buf, uint8_t idx,
18435 struct tbttoffset_params *tbtt_param)
18436{
18437 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
18438 wmi_tbtt_offset_info *tbtt_offset_info;
18439
18440 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
18441 if (!param_buf) {
18442 qdf_print("Invalid tbtt update event buffer\n");
18443 return QDF_STATUS_E_INVAL;
18444 }
18445 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
18446
18447 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
18448 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053018449
18450 return QDF_STATUS_SUCCESS;
18451}
18452
18453/**
18454 * extract_mgmt_rx_params_tlv() - extract management rx params from event
18455 * @wmi_handle: wmi handle
18456 * @param evt_buf: pointer to event buffer
18457 * @param hdr: Pointer to hold header
18458 * @param bufp: Pointer to hold pointer to rx param buffer
18459 *
18460 * Return: QDF_STATUS_SUCCESS for success or error code
18461 */
18462static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053018463 void *evt_buf, struct mgmt_rx_event_params *hdr,
18464 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053018465{
18466 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
18467 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018468 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053018469
18470 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
18471 if (!param_tlvs) {
18472 WMI_LOGE("Get NULL point message from FW");
18473 return QDF_STATUS_E_INVAL;
18474 }
18475
18476 ev_hdr = param_tlvs->hdr;
18477 if (!hdr) {
18478 WMI_LOGE("Rx event is NULL");
18479 return QDF_STATUS_E_INVAL;
18480 }
18481
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018482 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18483 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018484
18485 hdr->channel = ev_hdr->channel;
18486 hdr->snr = ev_hdr->snr;
18487 hdr->rate = ev_hdr->rate;
18488 hdr->phy_mode = ev_hdr->phy_mode;
18489 hdr->buf_len = ev_hdr->buf_len;
18490 hdr->status = ev_hdr->status;
18491 hdr->flags = ev_hdr->flags;
18492 hdr->rssi = ev_hdr->rssi;
18493 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053018494 for (i = 0; i < ATH_MAX_ANTENNA; i++)
18495 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053018496
18497 *bufp = param_tlvs->bufp;
18498
18499 return QDF_STATUS_SUCCESS;
18500}
18501
18502/**
18503 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
18504 * @wmi_handle: wmi handle
18505 * @param evt_buf: pointer to event buffer
18506 * @param vdev_id: Pointer to hold vdev identifier
18507 *
18508 * Return: QDF_STATUS_SUCCESS for success or error code
18509 */
18510static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
18511 void *evt_buf, uint32_t *vdev_id)
18512{
18513 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
18514 wmi_vdev_stopped_event_fixed_param *resp_event;
18515
18516 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
18517 if (!param_buf) {
18518 WMI_LOGE("Invalid event buffer");
18519 return QDF_STATUS_E_INVAL;
18520 }
18521 resp_event = param_buf->fixed_param;
18522 *vdev_id = resp_event->vdev_id;
18523
18524 return QDF_STATUS_SUCCESS;
18525}
18526
18527/**
18528 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
18529 * @wmi_handle: wmi handle
18530 * @param evt_buf: pointer to event buffer
18531 * @param param: Pointer to hold roam param
18532 *
18533 * Return: QDF_STATUS_SUCCESS for success or error code
18534 */
18535static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
18536 void *evt_buf, wmi_host_roam_event *param)
18537{
18538 WMI_ROAM_EVENTID_param_tlvs *param_buf;
18539 wmi_roam_event_fixed_param *evt;
18540
18541 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
18542 if (!param_buf) {
18543 WMI_LOGE("Invalid roam event buffer");
18544 return QDF_STATUS_E_INVAL;
18545 }
18546
18547 evt = param_buf->fixed_param;
18548 qdf_mem_zero(param, sizeof(*param));
18549
18550 param->vdev_id = evt->vdev_id;
18551 param->reason = evt->reason;
18552 param->rssi = evt->rssi;
18553
18554 return QDF_STATUS_SUCCESS;
18555}
18556
18557/**
18558 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
18559 * @wmi_handle: wmi handle
18560 * @param evt_buf: pointer to event buffer
18561 * @param param: Pointer to hold vdev scan param
18562 *
18563 * Return: QDF_STATUS_SUCCESS for success or error code
18564 */
18565static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018566 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053018567{
18568 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
18569 wmi_scan_event_fixed_param *evt = NULL;
18570
18571 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
18572 evt = param_buf->fixed_param;
18573
18574 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018575
Govind Singhe7f2f342016-05-23 12:12:52 +053018576 switch (evt->event) {
18577 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018578 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018579 break;
18580 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018581 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018582 break;
18583 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018584 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018585 break;
18586 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018587 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053018588 break;
18589 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018590 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018591 break;
18592 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018593 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018594 break;
18595 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018596 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018597 break;
18598 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018599 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018600 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053018601 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018602 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018603 break;
18604 case WMI_SCAN_EVENT_MAX:
18605 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018606 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018607 break;
18608 };
18609
18610 switch (evt->reason) {
18611 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018612 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018613 break;
18614 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018615 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018616 break;
18617 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018618 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018619 break;
18620 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018621 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053018622 break;
18623 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018624 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053018625 break;
18626 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018627 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018628 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018629 case WMI_SCAN_REASON_SUSPENDED:
18630 param->reason = SCAN_REASON_SUSPENDED;
18631 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018632 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053018633 param->reason = SCAN_REASON_MAX;
18634 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053018635 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018636 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053018637 break;
18638 };
18639
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053018640 param->chan_freq = evt->channel_freq;
18641 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053018642 param->scan_id = evt->scan_id;
18643 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053018644 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053018645
18646 return QDF_STATUS_SUCCESS;
18647}
18648
Frank Liu3d5e9992017-03-15 17:51:43 +080018649#ifdef CONVERGED_TDLS_ENABLE
18650/**
18651 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
18652 * @wmi_handle: wmi handle
18653 * @param evt_buf: pointer to event buffer
18654 * @param param: Pointer to hold vdev tdls param
18655 *
18656 * Return: QDF_STATUS_SUCCESS for success or error code
18657 */
18658static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
18659 void *evt_buf, struct tdls_event_info *param)
18660{
18661 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
18662 wmi_tdls_peer_event_fixed_param *evt;
18663
18664 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
18665 if (!param_buf) {
18666 WMI_LOGE("%s: NULL param_buf", __func__);
18667 return QDF_STATUS_E_NULL_VALUE;
18668 }
18669
18670 evt = param_buf->fixed_param;
18671
18672 qdf_mem_zero(param, sizeof(*param));
18673
18674 param->vdev_id = evt->vdev_id;
18675 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
18676 param->peermac.bytes);
18677 switch (evt->peer_status) {
18678 case WMI_TDLS_SHOULD_DISCOVER:
18679 param->message_type = TDLS_SHOULD_DISCOVER;
18680 break;
18681 case WMI_TDLS_SHOULD_TEARDOWN:
18682 param->message_type = TDLS_SHOULD_TEARDOWN;
18683 break;
18684 case WMI_TDLS_PEER_DISCONNECTED:
18685 param->message_type = TDLS_PEER_DISCONNECTED;
18686 break;
18687 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
18688 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
18689 break;
18690 default:
18691 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
18692 __func__, evt->peer_status);
18693 return QDF_STATUS_E_INVAL;
18694 };
18695
18696 switch (evt->peer_reason) {
18697 case WMI_TDLS_TEARDOWN_REASON_TX:
18698 param->peer_reason = TDLS_TEARDOWN_TX;
18699 break;
18700 case WMI_TDLS_TEARDOWN_REASON_RSSI:
18701 param->peer_reason = TDLS_TEARDOWN_RSSI;
18702 break;
18703 case WMI_TDLS_TEARDOWN_REASON_SCAN:
18704 param->peer_reason = TDLS_TEARDOWN_SCAN;
18705 break;
18706 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
18707 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
18708 break;
18709 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
18710 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
18711 break;
18712 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
18713 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
18714 break;
18715 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
18716 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
18717 break;
18718 case WMI_TDLS_ENTER_BUF_STA:
18719 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
18720 break;
18721 case WMI_TDLS_EXIT_BUF_STA:
18722 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
18723 break;
18724 case WMI_TDLS_ENTER_BT_BUSY_MODE:
18725 param->peer_reason = TDLS_ENTER_BT_BUSY;
18726 break;
18727 case WMI_TDLS_EXIT_BT_BUSY_MODE:
18728 param->peer_reason = TDLS_EXIT_BT_BUSY;
18729 break;
18730 case WMI_TDLS_SCAN_STARTED_EVENT:
18731 param->peer_reason = TDLS_SCAN_STARTED;
18732 break;
18733 case WMI_TDLS_SCAN_COMPLETED_EVENT:
18734 param->peer_reason = TDLS_SCAN_COMPLETED;
18735 break;
18736
18737 default:
18738 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
18739 __func__, evt->peer_reason, evt->peer_status);
18740 return QDF_STATUS_E_INVAL;
18741 };
18742
18743 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18744 __func__, param->peermac.bytes, param->message_type,
18745 param->peer_reason, param->vdev_id);
18746
18747 return QDF_STATUS_SUCCESS;
18748}
18749#endif
18750
Govind Singhe7f2f342016-05-23 12:12:52 +053018751/**
18752 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18753 * @wmi_handle: wmi handle
18754 * @param evt_buf: pointer to event buffer
18755 * @param param: Pointer to hold MGMT TX completion params
18756 *
18757 * Return: QDF_STATUS_SUCCESS for success or error code
18758 */
18759static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18760 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18761{
18762 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18763 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18764
18765 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18766 evt_buf;
18767 if (!param_buf) {
18768 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18769 return QDF_STATUS_E_INVAL;
18770 }
18771 cmpl_params = param_buf->fixed_param;
18772
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018773 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18774 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018775 param->desc_id = cmpl_params->desc_id;
18776 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018777 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018778
18779 return QDF_STATUS_SUCCESS;
18780}
18781
18782/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018783 * extract_offchan_data_tx_compl_param_tlv() -
18784 * extract Offchan data tx completion event params
18785 * @wmi_handle: wmi handle
18786 * @param evt_buf: pointer to event buffer
18787 * @param param: Pointer to hold offchan data TX completion params
18788 *
18789 * Return: QDF_STATUS_SUCCESS for success or error code
18790 */
18791static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18792 wmi_unified_t wmi_handle, void *evt_buf,
18793 struct wmi_host_offchan_data_tx_compl_event *param)
18794{
18795 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18796 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18797
18798 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18799 evt_buf;
18800 if (!param_buf) {
18801 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18802 return QDF_STATUS_E_INVAL;
18803 }
18804 cmpl_params = param_buf->fixed_param;
18805
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018806 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18807 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018808 param->desc_id = cmpl_params->desc_id;
18809 param->status = cmpl_params->status;
18810
18811 return QDF_STATUS_SUCCESS;
18812}
18813
18814/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018815 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18816 * status tlv
18817 * @wmi_handle: wmi handle
18818 * @param evt_buf: pointer to event buffer
18819 * @param param: Pointer to hold csa switch count status event param
18820 *
18821 * Return: QDF_STATUS_SUCCESS for success or error code
18822 */
18823static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18824 wmi_unified_t wmi_handle,
18825 void *evt_buf,
18826 struct pdev_csa_switch_count_status *param)
18827{
18828 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18829 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18830
18831 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18832 evt_buf;
18833 if (!param_buf) {
18834 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18835 return QDF_STATUS_E_INVAL;
18836 }
18837
18838 csa_status = param_buf->fixed_param;
18839
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018840 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18841 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018842 param->current_switch_count = csa_status->current_switch_count;
18843 param->num_vdevs = csa_status->num_vdevs;
18844 param->vdev_ids = param_buf->vdev_ids;
18845
18846 return QDF_STATUS_SUCCESS;
18847}
18848
18849/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018850 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18851 * param from event
18852 * @wmi_handle: wmi handle
18853 * @param evt_buf: pointer to event buffer
18854 * @param param: Pointer to hold tpc configuration
18855 *
18856 * Return: 0 for success or error code
18857 */
18858static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18859 void *evt_buf,
18860 wmi_host_pdev_tpc_config_event *param)
18861{
18862 wmi_pdev_tpc_config_event_fixed_param *event =
18863 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18864
18865 if (!event) {
18866 WMI_LOGE("Invalid event buffer");
18867 return QDF_STATUS_E_INVAL;
18868 }
18869
18870 param->pdev_id = event->pdev_id;
18871 param->regDomain = event->regDomain;
18872 param->chanFreq = event->chanFreq;
18873 param->phyMode = event->phyMode;
18874 param->twiceAntennaReduction = event->twiceAntennaReduction;
18875 param->twiceMaxRDPower = event->twiceMaxRDPower;
18876 param->powerLimit = event->powerLimit;
18877 param->rateMax = event->rateMax;
18878 param->numTxChain = event->numTxChain;
18879 param->ctl = event->ctl;
18880 param->flags = event->flags;
18881
18882 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18883 sizeof(param->maxRegAllowedPower));
18884 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18885 event->maxRegAllowedPowerAGCDD,
18886 sizeof(param->maxRegAllowedPowerAGCDD));
18887 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18888 event->maxRegAllowedPowerAGSTBC,
18889 sizeof(param->maxRegAllowedPowerAGSTBC));
18890 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18891 event->maxRegAllowedPowerAGTXBF,
18892 sizeof(param->maxRegAllowedPowerAGTXBF));
18893 WMI_LOGD("%s:extract success", __func__);
18894
18895 return QDF_STATUS_SUCCESS;
18896}
18897
18898/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018899 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018900 * @wmi_handle: wmi handle
18901 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018902 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018903 *
18904 * Return: QDF_STATUS_SUCCESS for success or error code
18905 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018906static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18907 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018908{
18909 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18910 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018911 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018912
18913 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18914 if (!param_buf) {
18915 WMI_LOGE("Invalid swba event buffer");
18916 return QDF_STATUS_E_INVAL;
18917 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018918
Govind Singhe7f2f342016-05-23 12:12:52 +053018919 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018920 *num_vdevs = swba_event->num_vdevs;
18921 if (!(*num_vdevs)) {
18922 vdev_map = swba_event->vdev_map;
18923 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18924 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018925
18926 return QDF_STATUS_SUCCESS;
18927}
18928
18929/**
18930 * extract_swba_tim_info_tlv() - extract swba tim info from event
18931 * @wmi_handle: wmi handle
18932 * @param evt_buf: pointer to event buffer
18933 * @param idx: Index to bcn info
18934 * @param tim_info: Pointer to hold tim info
18935 *
18936 * Return: QDF_STATUS_SUCCESS for success or error code
18937 */
18938static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18939 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18940{
18941 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18942 wmi_tim_info *tim_info_ev;
18943
18944 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18945 if (!param_buf) {
18946 WMI_LOGE("Invalid swba event buffer");
18947 return QDF_STATUS_E_INVAL;
18948 }
18949
18950 tim_info_ev = &param_buf->tim_info[idx];
18951
18952 tim_info->tim_len = tim_info_ev->tim_len;
18953 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18954 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18955 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18956 tim_info->tim_changed = tim_info_ev->tim_changed;
18957 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018958 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018959
18960 return QDF_STATUS_SUCCESS;
18961}
18962
18963/**
18964 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18965 * @wmi_handle: wmi handle
18966 * @param evt_buf: pointer to event buffer
18967 * @param idx: Index to bcn info
18968 * @param p2p_desc: Pointer to hold p2p NoA info
18969 *
18970 * Return: QDF_STATUS_SUCCESS for success or error code
18971 */
18972static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18973 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18974{
18975 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18976 wmi_p2p_noa_info *p2p_noa_info;
18977 uint8_t i = 0;
18978
18979 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18980 if (!param_buf) {
18981 WMI_LOGE("Invalid swba event buffer");
18982 return QDF_STATUS_E_INVAL;
18983 }
18984
18985 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18986
18987 p2p_desc->modified = false;
18988 p2p_desc->num_descriptors = 0;
18989 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18990 p2p_desc->modified = true;
18991 p2p_desc->index =
18992 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18993 p2p_desc->oppPS =
18994 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18995 p2p_desc->ctwindow =
18996 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18997 p2p_desc->num_descriptors =
18998 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18999 (p2p_noa_info);
19000 for (i = 0; i < p2p_desc->num_descriptors; i++) {
19001 p2p_desc->noa_descriptors[i].type_count =
19002 (uint8_t) p2p_noa_info->noa_descriptors[i].
19003 type_count;
19004 p2p_desc->noa_descriptors[i].duration =
19005 p2p_noa_info->noa_descriptors[i].duration;
19006 p2p_desc->noa_descriptors[i].interval =
19007 p2p_noa_info->noa_descriptors[i].interval;
19008 p2p_desc->noa_descriptors[i].start_time =
19009 p2p_noa_info->noa_descriptors[i].start_time;
19010 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053019011 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019012 }
19013
19014 return QDF_STATUS_SUCCESS;
19015}
19016
Wu Gaocd3a8512017-03-13 20:17:34 +080019017#ifdef CONVERGED_P2P_ENABLE
19018/**
19019 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
19020 * @wmi_handle: wmi handle
19021 * @param evt_buf: pointer to event buffer
19022 * @param param: Pointer to hold p2p noa info
19023 *
19024 * Return: QDF_STATUS_SUCCESS for success or error code
19025 */
19026static QDF_STATUS extract_p2p_noa_ev_param_tlv(
19027 wmi_unified_t wmi_handle, void *evt_buf,
19028 struct p2p_noa_info *param)
19029{
19030 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
19031 wmi_p2p_noa_event_fixed_param *fixed_param;
19032 uint8_t i;
19033 wmi_p2p_noa_info *wmi_noa_info;
19034 uint8_t *buf_ptr;
19035 uint32_t descriptors;
19036
19037 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
19038 if (!param_tlvs) {
19039 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
19040 return QDF_STATUS_E_INVAL;
19041 }
19042
19043 if (!param) {
19044 WMI_LOGE("noa information param is null");
19045 return QDF_STATUS_E_INVAL;
19046 }
19047
19048 fixed_param = param_tlvs->fixed_param;
19049 buf_ptr = (uint8_t *) fixed_param;
19050 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
19051 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
19052
19053 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
19054 WMI_LOGE("%s: noa attr is not modified", __func__);
19055 return QDF_STATUS_E_INVAL;
19056 }
19057
19058 param->vdev_id = fixed_param->vdev_id;
19059 param->index =
19060 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
19061 param->opps_ps =
19062 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
19063 param->ct_window =
19064 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
19065 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
19066 param->num_desc = (uint8_t) descriptors;
19067
19068 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
19069 param->index, param->opps_ps, param->ct_window,
19070 param->num_desc);
19071 for (i = 0; i < param->num_desc; i++) {
19072 param->noa_desc[i].type_count =
19073 (uint8_t) wmi_noa_info->noa_descriptors[i].
19074 type_count;
19075 param->noa_desc[i].duration =
19076 wmi_noa_info->noa_descriptors[i].duration;
19077 param->noa_desc[i].interval =
19078 wmi_noa_info->noa_descriptors[i].interval;
19079 param->noa_desc[i].start_time =
19080 wmi_noa_info->noa_descriptors[i].start_time;
19081 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
19082 __func__, i, param->noa_desc[i].type_count,
19083 param->noa_desc[i].duration,
19084 param->noa_desc[i].interval,
19085 param->noa_desc[i].start_time);
19086 }
19087
19088 return QDF_STATUS_SUCCESS;
19089}
19090
19091/**
19092 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
19093 * information from event
19094 * @wmi_handle: wmi handle
19095 * @param evt_buf: pointer to event buffer
19096 * @param param: Pointer to hold p2p lo stop event information
19097 *
19098 * Return: QDF_STATUS_SUCCESS for success or error code
19099 */
19100static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
19101 wmi_unified_t wmi_handle, void *evt_buf,
19102 struct p2p_lo_event *param)
19103{
19104 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
19105 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
19106
19107 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
19108 evt_buf;
19109 if (!param_tlvs) {
19110 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
19111 return QDF_STATUS_E_INVAL;
19112 }
19113
19114 if (!param) {
19115 WMI_LOGE("lo stop event param is null");
19116 return QDF_STATUS_E_INVAL;
19117 }
19118
19119 lo_param = param_tlvs->fixed_param;
19120 param->vdev_id = lo_param->vdev_id;
19121 param->reason_code = lo_param->reason;
19122 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
19123 param->vdev_id, param->reason_code);
19124
19125 return QDF_STATUS_SUCCESS;
19126}
19127#endif /* End of CONVERGED_P2P_ENABLE */
19128
Govind Singhe7f2f342016-05-23 12:12:52 +053019129/**
19130 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
19131 * @wmi_handle: wmi handle
19132 * @param evt_buf: pointer to event buffer
19133 * @param ev: Pointer to hold peer param
19134 *
19135 * Return: QDF_STATUS_SUCCESS for success or error code
19136 */
19137static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
19138 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
19139{
19140 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
19141 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
19142
19143 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
19144 kickout_event = param_buf->fixed_param;
19145
19146 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
19147 ev->peer_macaddr);
19148
19149 ev->reason = kickout_event->reason;
19150 ev->rssi = kickout_event->rssi;
19151
19152 return QDF_STATUS_SUCCESS;
19153}
19154
19155/**
19156 * extract_all_stats_counts_tlv() - extract all stats count from event
19157 * @wmi_handle: wmi handle
19158 * @param evt_buf: pointer to event buffer
19159 * @param stats_param: Pointer to hold stats count
19160 *
19161 * Return: QDF_STATUS_SUCCESS for success or error code
19162 */
19163static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
19164 void *evt_buf, wmi_host_stats_event *stats_param)
19165{
Govind Singhe7f2f342016-05-23 12:12:52 +053019166 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019167 wmi_per_chain_rssi_stats *rssi_event;
19168 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053019169
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019170 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053019171 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053019172 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019173 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053019174 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019175 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053019176 return QDF_STATUS_E_FAILURE;
19177 }
19178
19179 switch (ev->stats_id) {
19180 case WMI_REQUEST_PEER_STAT:
19181 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
19182 break;
19183
19184 case WMI_REQUEST_AP_STAT:
19185 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
19186 break;
19187
19188 case WMI_REQUEST_PDEV_STAT:
19189 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
19190 break;
19191
19192 case WMI_REQUEST_VDEV_STAT:
19193 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
19194 break;
19195
19196 case WMI_REQUEST_BCNFLT_STAT:
19197 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
19198 break;
19199
19200 case WMI_REQUEST_VDEV_RATE_STAT:
19201 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
19202 break;
19203
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019204 case WMI_REQUEST_BCN_STAT:
19205 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
19206 break;
19207
Govind Singhe7f2f342016-05-23 12:12:52 +053019208 default:
19209 stats_param->stats_id = 0;
19210 break;
19211
19212 }
19213
19214 stats_param->num_pdev_stats = ev->num_pdev_stats;
19215 stats_param->num_pdev_ext_stats = 0;
19216 stats_param->num_vdev_stats = ev->num_vdev_stats;
19217 stats_param->num_peer_stats = ev->num_peer_stats;
19218 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
19219 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019220 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053019221 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19222 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053019223
Naveen Rawat57e47aa2018-04-06 10:57:20 -070019224 /* if chain_stats is not populated */
19225 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
19226 return QDF_STATUS_SUCCESS;
19227
19228 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
19229 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
19230 return QDF_STATUS_SUCCESS;
19231
19232 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
19233 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
19234 return QDF_STATUS_SUCCESS;
19235
19236 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
19237
Govind Singhe7f2f342016-05-23 12:12:52 +053019238 return QDF_STATUS_SUCCESS;
19239}
19240
19241/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019242 * extract_pdev_tx_stats() - extract pdev tx stats from event
19243 */
19244static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
19245{
19246 /* Tx Stats */
19247 tx->comp_queued = tx_stats->comp_queued;
19248 tx->comp_delivered = tx_stats->comp_delivered;
19249 tx->msdu_enqued = tx_stats->msdu_enqued;
19250 tx->mpdu_enqued = tx_stats->mpdu_enqued;
19251 tx->wmm_drop = tx_stats->wmm_drop;
19252 tx->local_enqued = tx_stats->local_enqued;
19253 tx->local_freed = tx_stats->local_freed;
19254 tx->hw_queued = tx_stats->hw_queued;
19255 tx->hw_reaped = tx_stats->hw_reaped;
19256 tx->underrun = tx_stats->underrun;
19257 tx->tx_abort = tx_stats->tx_abort;
19258 tx->mpdus_requed = tx_stats->mpdus_requed;
19259 tx->data_rc = tx_stats->data_rc;
19260 tx->self_triggers = tx_stats->self_triggers;
19261 tx->sw_retry_failure = tx_stats->sw_retry_failure;
19262 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
19263 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
19264 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
19265 tx->pdev_resets = tx_stats->pdev_resets;
19266 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
19267 tx->phy_underrun = tx_stats->phy_underrun;
19268 tx->txop_ovf = tx_stats->txop_ovf;
19269
19270 return;
19271}
19272
19273
19274/**
19275 * extract_pdev_rx_stats() - extract pdev rx stats from event
19276 */
19277static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
19278{
19279 /* Rx Stats */
19280 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
19281 rx->status_rcvd = rx_stats->status_rcvd;
19282 rx->r0_frags = rx_stats->r0_frags;
19283 rx->r1_frags = rx_stats->r1_frags;
19284 rx->r2_frags = rx_stats->r2_frags;
19285 /* Only TLV */
19286 rx->r3_frags = 0;
19287 rx->htt_msdus = rx_stats->htt_msdus;
19288 rx->htt_mpdus = rx_stats->htt_mpdus;
19289 rx->loc_msdus = rx_stats->loc_msdus;
19290 rx->loc_mpdus = rx_stats->loc_mpdus;
19291 rx->oversize_amsdu = rx_stats->oversize_amsdu;
19292 rx->phy_errs = rx_stats->phy_errs;
19293 rx->phy_err_drop = rx_stats->phy_err_drop;
19294 rx->mpdu_errs = rx_stats->mpdu_errs;
19295
19296 return;
19297}
19298
19299/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019300 * extract_pdev_stats_tlv() - extract pdev stats from event
19301 * @wmi_handle: wmi handle
19302 * @param evt_buf: pointer to event buffer
19303 * @param index: Index into pdev stats
19304 * @param pdev_stats: Pointer to hold pdev stats
19305 *
19306 * Return: QDF_STATUS_SUCCESS for success or error code
19307 */
19308static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
19309 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
19310{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053019311 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19312 wmi_stats_event_fixed_param *ev_param;
19313 uint8_t *data;
19314
19315 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19316 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19317
19318 data = param_buf->data;
19319
19320 if (index < ev_param->num_pdev_stats) {
19321 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
19322 (index * sizeof(wmi_pdev_stats)));
19323
19324 pdev_stats->chan_nf = ev->chan_nf;
19325 pdev_stats->tx_frame_count = ev->tx_frame_count;
19326 pdev_stats->rx_frame_count = ev->rx_frame_count;
19327 pdev_stats->rx_clear_count = ev->rx_clear_count;
19328 pdev_stats->cycle_count = ev->cycle_count;
19329 pdev_stats->phy_err_count = ev->phy_err_count;
19330 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
19331
19332 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
19333 &(ev->pdev_stats.tx));
19334 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
19335 &(ev->pdev_stats.rx));
19336 }
19337
Govind Singhe7f2f342016-05-23 12:12:52 +053019338 return QDF_STATUS_SUCCESS;
19339}
19340
19341/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070019342 * extract_unit_test_tlv() - extract unit test data
19343 * @wmi_handle: wmi handle
19344 * @param evt_buf: pointer to event buffer
19345 * @param unit_test: pointer to hold unit test data
19346 * @param maxspace: Amount of space in evt_buf
19347 *
19348 * Return: QDF_STATUS_SUCCESS for success or error code
19349 */
19350static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
19351 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
19352{
19353 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
19354 wmi_unit_test_event_fixed_param *ev_param;
19355 uint32_t num_bufp;
19356 uint32_t copy_size;
19357 uint8_t *bufp;
19358
19359 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
19360 ev_param = param_buf->fixed_param;
19361 bufp = param_buf->bufp;
19362 num_bufp = param_buf->num_bufp;
19363 unit_test->vdev_id = ev_param->vdev_id;
19364 unit_test->module_id = ev_param->module_id;
19365 unit_test->diag_token = ev_param->diag_token;
19366 unit_test->flag = ev_param->flag;
19367 unit_test->payload_len = ev_param->payload_len;
19368 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
19369 ev_param->vdev_id,
19370 ev_param->module_id,
19371 ev_param->diag_token,
19372 ev_param->flag);
19373 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
19374 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
19375 bufp, num_bufp);
19376 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
19377 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
19378 unit_test->buffer_len = copy_size;
19379
19380 return QDF_STATUS_SUCCESS;
19381}
19382
19383/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019384 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
19385 * @wmi_handle: wmi handle
19386 * @param evt_buf: pointer to event buffer
19387 * @param index: Index into extended pdev stats
19388 * @param pdev_ext_stats: Pointer to hold extended pdev stats
19389 *
19390 * Return: QDF_STATUS_SUCCESS for success or error code
19391 */
19392static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
19393 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
19394{
19395 return QDF_STATUS_SUCCESS;
19396}
19397
19398/**
19399 * extract_vdev_stats_tlv() - extract vdev stats from event
19400 * @wmi_handle: wmi handle
19401 * @param evt_buf: pointer to event buffer
19402 * @param index: Index into vdev stats
19403 * @param vdev_stats: Pointer to hold vdev stats
19404 *
19405 * Return: QDF_STATUS_SUCCESS for success or error code
19406 */
19407static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
19408 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
19409{
19410 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19411 wmi_stats_event_fixed_param *ev_param;
19412 uint8_t *data;
19413
19414 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19415 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19416 data = (uint8_t *) param_buf->data;
19417
19418 if (index < ev_param->num_vdev_stats) {
19419 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
19420 ((ev_param->num_pdev_stats) *
19421 sizeof(wmi_pdev_stats)) +
19422 (index * sizeof(wmi_vdev_stats)));
19423
19424 vdev_stats->vdev_id = ev->vdev_id;
19425 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
19426 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
19427
19428 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
19429 sizeof(ev->tx_frm_cnt));
19430 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
19431 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
19432 ev->multiple_retry_cnt,
19433 sizeof(ev->multiple_retry_cnt));
19434 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
19435 sizeof(ev->fail_cnt));
19436 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
19437 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
19438 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
19439 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
19440 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
19441 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
19442 sizeof(ev->tx_rate_history));
19443 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
19444 sizeof(ev->bcn_rssi_history));
19445
19446 }
19447
19448 return QDF_STATUS_SUCCESS;
19449}
19450
19451/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053019452 * extract_bcn_stats_tlv() - extract bcn stats from event
19453 * @wmi_handle: wmi handle
19454 * @param evt_buf: pointer to event buffer
19455 * @param index: Index into vdev stats
19456 * @param bcn_stats: Pointer to hold bcn stats
19457 *
19458 * Return: QDF_STATUS_SUCCESS for success or error code
19459 */
19460static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
19461 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
19462{
19463 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19464 wmi_stats_event_fixed_param *ev_param;
19465 uint8_t *data;
19466
19467 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19468 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19469 data = (uint8_t *) param_buf->data;
19470
19471 if (index < ev_param->num_bcn_stats) {
19472 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
19473 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19474 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19475 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19476 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
19477 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
19478 (index * sizeof(wmi_bcn_stats)));
19479
19480 bcn_stats->vdev_id = ev->vdev_id;
19481 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
19482 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
19483 }
19484
19485 return QDF_STATUS_SUCCESS;
19486}
19487
19488/**
Govind Singhe7f2f342016-05-23 12:12:52 +053019489 * extract_peer_stats_tlv() - extract peer stats from event
19490 * @wmi_handle: wmi handle
19491 * @param evt_buf: pointer to event buffer
19492 * @param index: Index into peer stats
19493 * @param peer_stats: Pointer to hold peer stats
19494 *
19495 * Return: QDF_STATUS_SUCCESS for success or error code
19496 */
19497static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
19498 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
19499{
19500 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19501 wmi_stats_event_fixed_param *ev_param;
19502 uint8_t *data;
19503
19504 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19505 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19506 data = (uint8_t *) param_buf->data;
19507
19508 if (index < ev_param->num_peer_stats) {
19509 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
19510 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19511 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19512 (index * sizeof(wmi_peer_stats)));
19513
19514 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
19515
19516 OS_MEMCPY(&(peer_stats->peer_macaddr),
19517 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
19518
19519 peer_stats->peer_rssi = ev->peer_rssi;
19520 peer_stats->peer_tx_rate = ev->peer_tx_rate;
19521 peer_stats->peer_rx_rate = ev->peer_rx_rate;
19522 }
19523
19524 return QDF_STATUS_SUCCESS;
19525}
19526
19527/**
19528 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
19529 * @wmi_handle: wmi handle
19530 * @param evt_buf: pointer to event buffer
19531 * @param index: Index into bcn fault stats
19532 * @param bcnflt_stats: Pointer to hold bcn fault stats
19533 *
19534 * Return: QDF_STATUS_SUCCESS for success or error code
19535 */
19536static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
19537 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
19538{
19539 return QDF_STATUS_SUCCESS;
19540}
19541
19542/**
19543 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
19544 * @wmi_handle: wmi handle
19545 * @param evt_buf: pointer to event buffer
19546 * @param index: Index into extended peer stats
19547 * @param peer_extd_stats: Pointer to hold extended peer stats
19548 *
19549 * Return: QDF_STATUS_SUCCESS for success or error code
19550 */
19551static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
19552 void *evt_buf, uint32_t index,
19553 wmi_host_peer_extd_stats *peer_extd_stats)
19554{
19555 return QDF_STATUS_SUCCESS;
19556}
19557
19558/**
19559 * extract_chan_stats_tlv() - extract chan stats from event
19560 * @wmi_handle: wmi handle
19561 * @param evt_buf: pointer to event buffer
19562 * @param index: Index into chan stats
19563 * @param vdev_extd_stats: Pointer to hold chan stats
19564 *
19565 * Return: QDF_STATUS_SUCCESS for success or error code
19566 */
19567static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
19568 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
19569{
19570 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
19571 wmi_stats_event_fixed_param *ev_param;
19572 uint8_t *data;
19573
19574 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
19575 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
19576 data = (uint8_t *) param_buf->data;
19577
19578 if (index < ev_param->num_chan_stats) {
19579 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
19580 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
19581 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
19582 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
19583 (index * sizeof(wmi_chan_stats)));
19584
19585
19586 /* Non-TLV doesnt have num_chan_stats */
19587 chan_stats->chan_mhz = ev->chan_mhz;
19588 chan_stats->sampling_period_us = ev->sampling_period_us;
19589 chan_stats->rx_clear_count = ev->rx_clear_count;
19590 chan_stats->tx_duration_us = ev->tx_duration_us;
19591 chan_stats->rx_duration_us = ev->rx_duration_us;
19592 }
19593
19594 return QDF_STATUS_SUCCESS;
19595}
19596
19597/**
19598 * extract_profile_ctx_tlv() - extract profile context from event
19599 * @wmi_handle: wmi handle
19600 * @param evt_buf: pointer to event buffer
19601 * @idx: profile stats index to extract
19602 * @param profile_ctx: Pointer to hold profile context
19603 *
19604 * Return: QDF_STATUS_SUCCESS for success or error code
19605 */
19606static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
19607 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
19608{
19609 return QDF_STATUS_SUCCESS;
19610}
19611
19612/**
19613 * extract_profile_data_tlv() - extract profile data from event
19614 * @wmi_handle: wmi handle
19615 * @param evt_buf: pointer to event buffer
19616 * @param profile_data: Pointer to hold profile data
19617 *
19618 * Return: QDF_STATUS_SUCCESS for success or error code
19619 */
19620static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
19621 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
19622{
19623
19624 return QDF_STATUS_SUCCESS;
19625}
19626
19627/**
19628 * extract_chan_info_event_tlv() - extract chan information from event
19629 * @wmi_handle: wmi handle
19630 * @param evt_buf: pointer to event buffer
19631 * @param chan_info: Pointer to hold chan information
19632 *
19633 * Return: QDF_STATUS_SUCCESS for success or error code
19634 */
19635static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
19636 void *evt_buf, wmi_host_chan_info_event *chan_info)
19637{
19638 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
19639 wmi_chan_info_event_fixed_param *ev;
19640
19641 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
19642
19643 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
19644 if (!ev) {
19645 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
19646 return QDF_STATUS_E_FAILURE;
19647 }
19648
19649 chan_info->err_code = ev->err_code;
19650 chan_info->freq = ev->freq;
19651 chan_info->cmd_flags = ev->cmd_flags;
19652 chan_info->noise_floor = ev->noise_floor;
19653 chan_info->rx_clear_count = ev->rx_clear_count;
19654 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053019655 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19656 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053019657 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
19658 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
19659 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053019660 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
19661 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
19662 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19663 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
19664 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
19665 chan_info->rx_frame_count = ev->rx_frame_count;
19666 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
19667 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053019668
19669 return QDF_STATUS_SUCCESS;
19670}
19671
19672/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019673 * extract_pdev_utf_event_tlv() - extract UTF data info from event
19674 * @wmi_handle: WMI handle
19675 * @param evt_buf: Pointer to event buffer
19676 * @param param: Pointer to hold data
19677 *
19678 * Return : QDF_STATUS_SUCCESS for success or error code
19679 */
19680static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
19681 uint8_t *evt_buf,
19682 struct wmi_host_pdev_utf_event *event)
19683{
19684 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019685 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019686
19687 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
19688 event->data = param_buf->data;
19689 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019690 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053019691 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019692 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019693 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019694
19695 return QDF_STATUS_SUCCESS;
19696}
Govind Singhe7f2f342016-05-23 12:12:52 +053019697
Kiran Venkatappa06520822016-08-10 23:55:40 +053019698/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019699 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19700 * @wmi_handle: wmi handle
19701 * @param evt_buf: pointer to event buffer
19702 * @param param: Pointer to hold evt buf
19703 *
19704 * Return: QDF_STATUS_SUCCESS for success or error code
19705 */
19706static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19707 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19708{
19709 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19710 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19711 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19712 uint8_t i = 0, j = 0;
19713
19714 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19715 if (!param_buf)
19716 return QDF_STATUS_E_INVAL;
19717
19718 hw_caps = param_buf->soc_hw_mode_caps;
19719 if (!hw_caps)
19720 return QDF_STATUS_E_INVAL;
19721
19722 if (!hw_caps->num_chainmask_tables)
19723 return QDF_STATUS_E_INVAL;
19724
19725 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19726
19727 if (chainmask_caps == NULL)
19728 return QDF_STATUS_E_INVAL;
19729
19730 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19731
19732 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19733 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19734
19735 chainmask_table[i].cap_list[j].chainmask =
19736 chainmask_caps->chainmask;
19737
19738 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19739 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19740
19741 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19742 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19743
19744 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19745 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19746
19747 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19748 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19749
19750 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19751 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19752
19753 chainmask_table[i].cap_list[j].chain_mask_2G =
19754 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19755
19756 chainmask_table[i].cap_list[j].chain_mask_5G =
19757 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19758
19759 chainmask_table[i].cap_list[j].chain_mask_tx =
19760 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19761
19762 chainmask_table[i].cap_list[j].chain_mask_rx =
19763 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19764
19765 chainmask_table[i].cap_list[j].supports_aDFS =
19766 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19767
19768 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19769 chainmask_caps->supported_flags,
19770 chainmask_caps->chainmask
19771 );
19772 chainmask_caps++;
19773 }
19774 }
19775
19776 return QDF_STATUS_SUCCESS;
19777}
19778
19779/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019780 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19781 * from event
19782 * @wmi_handle: wmi handle
19783 * @param evt_buf: pointer to event buffer
19784 * @param param: Pointer to hold evt buf
19785 *
19786 * Return: QDF_STATUS_SUCCESS for success or error code
19787 */
19788static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019789 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019790{
19791 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19792 wmi_service_ready_ext_event_fixed_param *ev;
19793 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19794 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019795 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19796 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019797
19798 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19799 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019800 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019801
19802 ev = param_buf->fixed_param;
19803 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019804 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019805
19806 /* Move this to host based bitmap */
19807 param->default_conc_scan_config_bits =
19808 ev->default_conc_scan_config_bits;
19809 param->default_fw_config_bits = ev->default_fw_config_bits;
19810 param->he_cap_info = ev->he_cap_info;
19811 param->mpdu_density = ev->mpdu_density;
19812 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019813 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019814 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019815 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19816
19817 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019818 if (hw_caps)
19819 param->num_hw_modes = hw_caps->num_hw_modes;
19820 else
19821 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019822
19823 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019824 if (reg_caps)
19825 param->num_phy = reg_caps->num_phy;
19826 else
19827 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019828
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019829 if (hw_caps) {
19830 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
19831 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
19832 } else
19833 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019834
19835 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19836
19837 if (chain_mask_combo == NULL)
19838 return QDF_STATUS_SUCCESS;
19839
19840 qdf_print("Dumping chain mask combo data\n");
19841
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019842 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019843
19844 qdf_print("table_id : %d Num valid chainmasks: %d\n",
19845 chain_mask_combo->chainmask_table_id,
19846 chain_mask_combo->num_valid_chainmask
19847 );
19848
19849 param->chainmask_table[i].table_id =
19850 chain_mask_combo->chainmask_table_id;
19851 param->chainmask_table[i].num_valid_chainmasks =
19852 chain_mask_combo->num_valid_chainmask;
19853 chain_mask_combo++;
19854 }
19855 qdf_print("chain mask combo end\n");
19856
Kiran Venkatappa06520822016-08-10 23:55:40 +053019857 return QDF_STATUS_SUCCESS;
19858}
19859
19860/**
19861 * extract_hw_mode_cap_service_ready_ext_tlv() -
19862 * extract HW mode cap from service ready event
19863 * @wmi_handle: wmi handle
19864 * @param evt_buf: pointer to event buffer
19865 * @param param: Pointer to hold evt buf
19866 * @param hw_mode_idx: hw mode idx should be less than num_mode
19867 *
19868 * Return: QDF_STATUS_SUCCESS for success or error code
19869 */
19870static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19871 wmi_unified_t wmi_handle,
19872 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019873 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019874{
19875 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19876 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19877
19878 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19879 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019880 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019881
19882 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019883 if (!hw_caps)
19884 return QDF_STATUS_E_INVAL;
19885
Kiran Venkatappa06520822016-08-10 23:55:40 +053019886 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019887 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019888
19889 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19890 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19891
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019892 param->hw_mode_config_type =
19893 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19894
Kiran Venkatappa06520822016-08-10 23:55:40 +053019895 return QDF_STATUS_SUCCESS;
19896}
19897
19898/**
19899 * extract_mac_phy_cap_service_ready_ext_tlv() -
19900 * extract MAC phy cap from service ready event
19901 * @wmi_handle: wmi handle
19902 * @param evt_buf: pointer to event buffer
19903 * @param param: Pointer to hold evt buf
19904 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019905 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019906 *
19907 * Return: QDF_STATUS_SUCCESS for success or error code
19908 */
19909static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19910 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019911 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019912 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019913{
19914 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019915 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019916 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19917 uint32_t phy_map;
19918 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019919
19920 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19921 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019922 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019923
19924 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019925 if (!hw_caps)
19926 return QDF_STATUS_E_INVAL;
19927
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019928 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19929 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19930 break;
19931
19932 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19933 while (phy_map) {
19934 phy_map >>= 1;
19935 phy_idx++;
19936 }
19937 }
19938
19939 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019940 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019941
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019942 phy_idx += phy_id;
19943 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019944 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019945
19946 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019947
19948 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019949 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19950 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019951 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019952 param->supports_11b =
19953 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19954 param->supports_11g =
19955 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19956 param->supports_11a =
19957 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19958 param->supports_11n =
19959 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19960 param->supports_11ac =
19961 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19962 param->supports_11ax =
19963 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019964
19965 param->supported_bands = mac_phy_caps->supported_bands;
19966 param->ampdu_density = mac_phy_caps->ampdu_density;
19967 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19968 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19969 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19970 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19971 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19972 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19973 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19974 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19975 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19976 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19977 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19978 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19979 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19980 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19981 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19982 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019983 qdf_mem_copy(&param->he_cap_phy_info_2G,
19984 &mac_phy_caps->he_cap_phy_info_2G,
19985 sizeof(param->he_cap_phy_info_2G));
19986 qdf_mem_copy(&param->he_cap_phy_info_5G,
19987 &mac_phy_caps->he_cap_phy_info_5G,
19988 sizeof(param->he_cap_phy_info_5G));
19989 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19990 sizeof(param->he_ppet2G));
19991 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19992 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019993 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019994
19995 return QDF_STATUS_SUCCESS;
19996}
19997
19998/**
19999 * extract_reg_cap_service_ready_ext_tlv() -
20000 * extract REG cap from service ready event
20001 * @wmi_handle: wmi handle
20002 * @param evt_buf: pointer to event buffer
20003 * @param param: Pointer to hold evt buf
20004 * @param phy_idx: phy idx should be less than num_mode
20005 *
20006 * Return: QDF_STATUS_SUCCESS for success or error code
20007 */
20008static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
20009 wmi_unified_t wmi_handle,
20010 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080020011 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053020012{
20013 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20014 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
20015 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
20016
20017 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
20018 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020019 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020020
20021 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020022 if (!reg_caps)
20023 return QDF_STATUS_E_INVAL;
20024
Kiran Venkatappa06520822016-08-10 23:55:40 +053020025 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020026 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053020027
20028 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
20029
20030 param->phy_id = ext_reg_cap->phy_id;
20031 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
20032 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
20033 param->regcap1 = ext_reg_cap->regcap1;
20034 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053020035 param->wireless_modes = convert_wireless_modes_tlv(
20036 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053020037 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
20038 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
20039 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
20040 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
20041
20042 return QDF_STATUS_SUCCESS;
20043}
20044
Sathish Kumarf396c722017-11-17 17:30:41 +053020045static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
20046 wmi_unified_t wmi_handle,
20047 uint8_t *event, uint8_t idx,
20048 struct wlan_psoc_host_dbr_ring_caps *param)
20049{
20050 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
20051 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
20052
20053 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
20054 if (!param_buf)
20055 return QDF_STATUS_E_INVAL;
20056
20057 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
20058
20059 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20060 dbr_ring_caps->pdev_id);
20061 param->mod_id = dbr_ring_caps->mod_id;
20062 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
20063 param->min_buf_size = dbr_ring_caps->min_buf_size;
20064 param->min_buf_align = dbr_ring_caps->min_buf_align;
20065
20066 return QDF_STATUS_SUCCESS;
20067}
20068
20069static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
20070 uint8_t *event, struct direct_buf_rx_rsp *param)
20071{
20072 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20073 wmi_dma_buf_release_fixed_param *ev;
20074
20075 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20076 if (!param_buf)
20077 return QDF_STATUS_E_INVAL;
20078
20079 ev = param_buf->fixed_param;
20080 if (!ev)
20081 return QDF_STATUS_E_INVAL;
20082
20083 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20084 ev->pdev_id);
20085 param->mod_id = ev->mod_id;
20086 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053020087 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053020088 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
20089 param->pdev_id, param->mod_id, param->num_buf_release_entry);
20090
20091 return QDF_STATUS_SUCCESS;
20092}
20093
20094static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
20095 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
20096{
20097 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20098 wmi_dma_buf_release_entry *entry;
20099
20100 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20101 if (!param_buf)
20102 return QDF_STATUS_E_INVAL;
20103
20104 entry = &param_buf->entries[idx];
20105
20106 if (!entry) {
20107 WMI_LOGE("%s: Entry is NULL\n", __func__);
20108 return QDF_STATUS_E_FAILURE;
20109 }
20110
20111 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
20112
20113 param->paddr_lo = entry->paddr_lo;
20114 param->paddr_hi = entry->paddr_hi;
20115
20116 return QDF_STATUS_SUCCESS;
20117}
20118
Edayilliam Jayadev92651222018-04-06 16:37:17 +053020119static QDF_STATUS extract_dbr_buf_metadata_tlv(
20120 wmi_unified_t wmi_handle, uint8_t *event,
20121 uint8_t idx, struct direct_buf_rx_metadata *param)
20122{
20123 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
20124 wmi_dma_buf_release_spectral_meta_data *entry;
20125
20126 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
20127 if (!param_buf)
20128 return QDF_STATUS_E_INVAL;
20129
20130 entry = &param_buf->meta_data[idx];
20131
20132 if (!entry) {
20133 WMI_LOGE("%s: Entry is NULL\n", __func__);
20134 return QDF_STATUS_E_FAILURE;
20135 }
20136
20137 qdf_mem_copy(param->noisefloor, entry->noise_floor,
20138 sizeof(entry->noise_floor));
20139 return QDF_STATUS_SUCCESS;
20140}
20141
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020142/**
20143 * extract_dcs_interference_type_tlv() - extract dcs interference type
20144 * from event
20145 * @wmi_handle: wmi handle
20146 * @param evt_buf: pointer to event buffer
20147 * @param param: Pointer to hold dcs interference param
20148 *
20149 * Return: 0 for success or error code
20150 */
20151static QDF_STATUS extract_dcs_interference_type_tlv(
20152 wmi_unified_t wmi_handle,
20153 void *evt_buf, struct wmi_host_dcs_interference_param *param)
20154{
20155 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20156
20157 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20158 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020159 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020160
20161 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020162 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20163 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020164
20165 return QDF_STATUS_SUCCESS;
20166}
20167
20168/*
20169 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
20170 * @wmi_handle: wmi handle
20171 * @param evt_buf: pointer to event buffer
20172 * @param cw_int: Pointer to hold cw interference
20173 *
20174 * Return: 0 for success or error code
20175 */
20176static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
20177 void *evt_buf,
20178 wmi_host_ath_dcs_cw_int *cw_int)
20179{
20180 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20181 wlan_dcs_cw_int *ev;
20182
20183 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20184 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020185 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020186
20187 ev = param_buf->cw_int;
20188
20189 cw_int->channel = ev->channel;
20190
20191 return QDF_STATUS_SUCCESS;
20192}
20193
20194/**
20195 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
20196 * @wmi_handle: wmi handle
20197 * @param evt_buf: pointer to event buffer
20198 * @param wlan_stat: Pointer to hold wlan stats
20199 *
20200 * Return: 0 for success or error code
20201 */
20202static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
20203 void *evt_buf,
20204 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
20205{
20206 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
20207 wlan_dcs_im_tgt_stats_t *ev;
20208
20209 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
20210 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053020211 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053020212
20213 ev = param_buf->wlan_stat;
20214 wlan_stat->reg_tsf32 = ev->reg_tsf32;
20215 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
20216 wlan_stat->tx_waste_time = ev->tx_waste_time;
20217 wlan_stat->rx_time = ev->rx_time;
20218 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
20219 wlan_stat->mib_stats.listen_time = ev->listen_time;
20220 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
20221 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
20222 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
20223 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
20224 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
20225 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
20226 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
20227 wlan_stat->chan_nf = ev->chan_nf;
20228 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
20229
20230 return QDF_STATUS_SUCCESS;
20231}
20232
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020233/**
20234 * extract_thermal_stats_tlv() - extract thermal stats from event
20235 * @wmi_handle: wmi handle
20236 * @param evt_buf: Pointer to event buffer
20237 * @param temp: Pointer to hold extracted temperature
20238 * @param level: Pointer to hold extracted level
20239 *
20240 * Return: 0 for success or error code
20241 */
20242static QDF_STATUS
20243extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
20244 void *evt_buf, uint32_t *temp,
20245 uint32_t *level, uint32_t *pdev_id)
20246{
20247 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20248 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
20249
20250 param_buf =
20251 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20252 if (!param_buf)
20253 return QDF_STATUS_E_INVAL;
20254
20255 tt_stats_event = param_buf->fixed_param;
20256
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020257 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20258 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053020259 *temp = tt_stats_event->temp;
20260 *level = tt_stats_event->level;
20261
20262 return QDF_STATUS_SUCCESS;
20263}
20264
20265/**
20266 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
20267 * @wmi_handle: wmi handle
20268 * @param evt_buf: pointer to event buffer
20269 * @param idx: Index to level stats
20270 * @param levelcount: Pointer to hold levelcount
20271 * @param dccount: Pointer to hold dccount
20272 *
20273 * Return: 0 for success or error code
20274 */
20275static QDF_STATUS
20276extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
20277 void *evt_buf, uint8_t idx, uint32_t *levelcount,
20278 uint32_t *dccount)
20279{
20280 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
20281 wmi_therm_throt_level_stats_info *tt_level_info;
20282
20283 param_buf =
20284 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
20285 if (!param_buf)
20286 return QDF_STATUS_E_INVAL;
20287
20288 tt_level_info = param_buf->therm_throt_level_stats_info;
20289
20290 if (idx < THERMAL_LEVELS) {
20291 *levelcount = tt_level_info[idx].level_count;
20292 *dccount = tt_level_info[idx].dc_count;
20293 return QDF_STATUS_SUCCESS;
20294 }
20295
20296 return QDF_STATUS_E_FAILURE;
20297}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020298#ifdef BIG_ENDIAN_HOST
20299/**
20300 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
20301 * @param data_len - data length
20302 * @param data - pointer to data
20303 *
20304 * Return: QDF_STATUS - success or error status
20305 */
20306static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20307{
20308 uint8_t *data_aligned = NULL;
20309 int c;
20310 unsigned char *data_unaligned;
20311
20312 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
20313 FIPS_ALIGN));
20314 /* Assigning unaligned space to copy the data */
20315 /* Checking if kmalloc does succesful allocation */
20316 if (data_unaligned == NULL)
20317 return QDF_STATUS_E_FAILURE;
20318
20319 /* Checking if space is alligned */
20320 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
20321 /* align the data space */
20322 data_aligned =
20323 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
20324 } else {
20325 data_aligned = (u_int8_t *)data_unaligned;
20326 }
20327
20328 /* memset and copy content from data to data aligned */
20329 OS_MEMSET(data_aligned, 0, data_len);
20330 OS_MEMCPY(data_aligned, data, data_len);
20331 /* Endianness to LE */
20332 for (c = 0; c < data_len/4; c++) {
20333 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020334 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020335 }
20336
20337 /* Copy content to event->data */
20338 OS_MEMCPY(data, data_aligned, data_len);
20339
20340 /* clean up allocated space */
20341 qdf_mem_free(data_unaligned);
20342 data_aligned = NULL;
20343 data_unaligned = NULL;
20344
20345 /*************************************************************/
20346
20347 return QDF_STATUS_SUCCESS;
20348}
20349#else
20350/**
20351 * fips_conv_data_be() - DUMMY for LE platform
20352 *
20353 * Return: QDF_STATUS - success
20354 */
20355static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
20356{
20357 return QDF_STATUS_SUCCESS;
20358}
20359#endif
20360
20361/**
20362 * extract_fips_event_data_tlv() - extract fips event data
20363 * @wmi_handle: wmi handle
20364 * @param evt_buf: pointer to event buffer
20365 * @param param: pointer FIPS event params
20366 *
20367 * Return: 0 for success or error code
20368 */
20369static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
20370 void *evt_buf, struct wmi_host_fips_event_param *param)
20371{
20372 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
20373 wmi_pdev_fips_event_fixed_param *event;
20374
20375 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
20376 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
20377
20378 if (fips_conv_data_be(event->data_len, param_buf->data) !=
20379 QDF_STATUS_SUCCESS)
20380 return QDF_STATUS_E_FAILURE;
20381
20382 param->data = (uint32_t *)param_buf->data;
20383 param->data_len = event->data_len;
20384 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020385 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20386 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053020387
20388 return QDF_STATUS_SUCCESS;
20389}
20390
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053020391/*
20392 * extract_peer_delete_response_event_tlv() - extract peer delete response event
20393 * @wmi_handle: wmi handle
20394 * @param evt_buf: pointer to event buffer
20395 * @param vdev_id: Pointer to hold vdev_id
20396 * @param mac_addr: Pointer to hold peer mac address
20397 *
20398 * Return: QDF_STATUS_SUCCESS for success or error code
20399 */
20400static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
20401 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
20402{
20403 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
20404 wmi_peer_delete_resp_event_fixed_param *ev;
20405
20406 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
20407
20408 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
20409 if (!ev) {
20410 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
20411 return QDF_STATUS_E_FAILURE;
20412 }
20413
20414 param->vdev_id = ev->vdev_id;
20415 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
20416 &param->mac_address.bytes[0]);
20417
20418 return QDF_STATUS_SUCCESS;
20419}
20420
Govind Singhecf03cd2016-05-12 12:45:51 +053020421static bool is_management_record_tlv(uint32_t cmd_id)
20422{
jiad36c94d22018-01-22 15:37:03 +080020423 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
20424 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
20425 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053020426 return true;
jiad36c94d22018-01-22 15:37:03 +080020427 }
Govind Singhe7f2f342016-05-23 12:12:52 +053020428
Govind Singhecf03cd2016-05-12 12:45:51 +053020429 return false;
20430}
20431
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053020432static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20433{
20434 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
20435
20436 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
20437
20438 switch (set_cmd->param_id) {
20439 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
20440 case WMI_VDEV_PARAM_DTIM_POLICY:
20441 return HTC_TX_PACKET_TAG_AUTO_PM;
20442 default:
20443 break;
20444 }
20445
20446 return 0;
20447}
20448
20449static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
20450{
20451 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
20452
20453 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
20454
20455 switch (ps_cmd->param) {
20456 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
20457 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
20458 case WMI_STA_PS_ENABLE_QPOWER:
20459 return HTC_TX_PACKET_TAG_AUTO_PM;
20460 default:
20461 break;
20462 }
20463
20464 return 0;
20465}
20466
20467static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
20468 uint32_t cmd_id)
20469{
20470 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
20471 return 0;
20472
20473 switch (cmd_id) {
20474 case WMI_VDEV_SET_PARAM_CMDID:
20475 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
20476 case WMI_STA_POWERSAVE_PARAM_CMDID:
20477 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
20478 default:
20479 break;
20480 }
20481
20482 return 0;
20483}
20484
20485static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
20486{
20487 uint16_t tag = 0;
20488
20489 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
20490 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
20491 __func__);
20492 return tag;
20493 }
20494
20495 if (wmi_handle->tag_crash_inject)
20496 tag = HTC_TX_PACKET_TAG_AUTO_PM;
20497
20498 wmi_handle->tag_crash_inject = false;
20499 return tag;
20500}
20501
20502/**
20503 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
20504 * @wmi_handle: WMI handle
20505 * @buf: WMI buffer
20506 * @cmd_id: WMI command Id
20507 *
20508 * Return htc_tx_tag
20509 */
20510static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
20511 wmi_buf_t buf,
20512 uint32_t cmd_id)
20513{
20514 uint16_t htc_tx_tag = 0;
20515
20516 switch (cmd_id) {
20517 case WMI_WOW_ENABLE_CMDID:
20518 case WMI_PDEV_SUSPEND_CMDID:
20519 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
20520 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
20521 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
20522 case WMI_PDEV_RESUME_CMDID:
20523 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
20524 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
20525#ifdef FEATURE_WLAN_D0WOW
20526 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
20527#endif
20528 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
20529 break;
20530 case WMI_FORCE_FW_HANG_CMDID:
20531 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
20532 break;
20533 case WMI_VDEV_SET_PARAM_CMDID:
20534 case WMI_STA_POWERSAVE_PARAM_CMDID:
20535 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
20536 default:
20537 break;
20538 }
20539
20540 return htc_tx_tag;
20541}
20542
Sathish Kumard3ab1002017-02-07 17:10:59 +053020543/**
20544 * extract_channel_hopping_event_tlv() - extract channel hopping param
20545 * from event
20546 * @wmi_handle: wmi handle
20547 * @param evt_buf: pointer to event buffer
20548 * @param ch_hopping: Pointer to hold channel hopping param
20549 *
20550 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20551 */
20552static QDF_STATUS extract_channel_hopping_event_tlv(
20553 wmi_unified_t wmi_handle, void *evt_buf,
20554 wmi_host_pdev_channel_hopping_event *ch_hopping)
20555{
20556 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
20557 wmi_pdev_channel_hopping_event_fixed_param *event;
20558
20559 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
20560 event = (wmi_pdev_channel_hopping_event_fixed_param *)
20561 param_buf->fixed_param;
20562
20563 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
20564 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020565 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20566 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020567
20568 return QDF_STATUS_SUCCESS;
20569}
20570
20571/**
20572 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
20573 * @wmi_handle: wmi handle
20574 * @param evt_buf: pointer to event buffer
20575 * @param param: Pointer to hold tpc param
20576 *
20577 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20578 */
20579static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
20580 void *evt_buf,
20581 wmi_host_pdev_tpc_event *param)
20582{
20583 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
20584 wmi_pdev_tpc_event_fixed_param *event;
20585
20586 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
20587 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
20588
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020589 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
20590 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053020591 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
20592
20593 return QDF_STATUS_SUCCESS;
20594}
20595
nobeljf74583b2018-01-25 16:35:36 -080020596/**
20597 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
20598 * power param from event
20599 * @wmi_handle: wmi handle
20600 * @param evt_buf: pointer to event buffer
20601 * @param param: Pointer to hold nf cal power param
20602 *
20603 * Return: 0 for success or error code
20604 */
20605static QDF_STATUS
20606extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
20607 void *evt_buf,
20608 wmi_host_pdev_nfcal_power_all_channels_event *param)
20609{
20610 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
20611 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
20612 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
20613 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
20614 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
20615 uint32_t i;
20616
20617 param_buf =
20618 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
20619 event = param_buf->fixed_param;
20620 ch_nfdbr = param_buf->nfdbr;
20621 ch_nfdbm = param_buf->nfdbm;
20622 ch_freqnum = param_buf->freqnum;
20623
20624 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
20625 event->pdev_id, param_buf->num_nfdbr,
20626 param_buf->num_nfdbm, param_buf->num_freqnum);
20627
20628 if (param_buf->num_nfdbr >
20629 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20630 WMI_LOGE("invalid number of nfdBr");
20631 return QDF_STATUS_E_FAILURE;
20632 }
20633
20634 if (param_buf->num_nfdbm >
20635 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
20636 WMI_LOGE("invalid number of nfdBm");
20637 return QDF_STATUS_E_FAILURE;
20638 }
20639
20640 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
20641 WMI_LOGE("invalid number of freqNum");
20642 return QDF_STATUS_E_FAILURE;
20643 }
20644
20645 for (i = 0; i < param_buf->num_nfdbr; i++) {
20646 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
20647 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
20648 ch_nfdbr++;
20649 ch_nfdbm++;
20650 }
20651
20652 for (i = 0; i < param_buf->num_freqnum; i++) {
20653 param->freqnum[i] = ch_freqnum->freqNum;
20654 ch_freqnum++;
20655 }
20656
20657 param->pdev_id = event->pdev_id;
20658
20659 return QDF_STATUS_SUCCESS;
20660}
20661
Sathish Kumard3ab1002017-02-07 17:10:59 +053020662
20663#ifdef BIG_ENDIAN_HOST
20664/**
20665 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
20666 * @param data_len - data length
20667 * @param data - pointer to data
20668 *
20669 * Return: QDF_STATUS - success or error status
20670 */
20671static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
20672{
20673 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053020674 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053020675 /* Skip swapping the first word */
20676 datap += sizeof(uint32_t);
20677 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
20678 i++, datap += sizeof(uint32_t)) {
20679 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
20680 }
20681
20682 return QDF_STATUS_SUCCESS;
20683}
20684#else
20685/**
20686 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
20687 * @param data_len - data length
20688 * @param data - pointer to data
20689 *
20690 * Return: QDF_STATUS - success or error status
20691 */
20692static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20693{
20694 return QDF_STATUS_SUCCESS;
20695}
20696#endif
20697
20698/**
20699 * extract_wds_addr_event_tlv() - extract wds address from event
20700 * @wmi_handle: wmi handle
20701 * @param evt_buf: pointer to event buffer
20702 * @param wds_ev: Pointer to hold wds address
20703 *
20704 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20705 */
20706static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20707 void *evt_buf,
20708 uint16_t len, wds_addr_event_t *wds_ev)
20709{
20710 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20711 wmi_wds_addr_event_fixed_param *ev;
20712 int i;
20713
20714 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20715 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20716
20717 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20718 return QDF_STATUS_E_FAILURE;
20719
20720 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20721 sizeof(wds_ev->event_type));
20722 for (i = 0; i < 4; i++) {
20723 wds_ev->peer_mac[i] =
20724 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20725 wds_ev->dest_mac[i] =
20726 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20727 }
20728 for (i = 0; i < 2; i++) {
20729 wds_ev->peer_mac[4+i] =
20730 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20731 wds_ev->dest_mac[4+i] =
20732 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20733 }
20734 return QDF_STATUS_SUCCESS;
20735}
20736
20737/**
20738 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20739 * from event
20740 * @wmi_handle: wmi handle
20741 * @param evt_buf: pointer to event buffer
20742 * @param ev: Pointer to hold peer param and ps state
20743 *
20744 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20745 */
20746static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20747 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20748{
20749 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20750 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20751
20752 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20753 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20754 param_buf->fixed_param;
20755
20756 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20757 ev->peer_ps_state = event->peer_ps_state;
20758
20759 return QDF_STATUS_SUCCESS;
20760}
20761
20762/**
20763 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20764 * @wmi_handle: wmi handle
20765 * @param evt_buf: pointer to event buffer
20766 * @param inst_rssi_resp: Pointer to hold inst rssi response
20767 *
20768 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20769 */
20770static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20771 wmi_unified_t wmi_handle, void *evt_buf,
20772 wmi_host_inst_stats_resp *inst_rssi_resp)
20773{
20774 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20775 wmi_inst_rssi_stats_resp_fixed_param *event;
20776
20777 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20778 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20779
20780 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20781 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20782 inst_rssi_resp->iRSSI = event->iRSSI;
20783
20784 return QDF_STATUS_SUCCESS;
20785}
20786
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020787static struct cur_reg_rule
20788*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20789 wmi_regulatory_rule_struct *wmi_reg_rule)
20790{
20791 struct cur_reg_rule *reg_rule_ptr;
20792 uint32_t count;
20793
20794 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20795
20796 if (NULL == reg_rule_ptr) {
20797 WMI_LOGE("memory allocation failure");
20798 return NULL;
20799 }
20800
20801 for (count = 0; count < num_reg_rules; count++) {
20802 reg_rule_ptr[count].start_freq =
20803 WMI_REG_RULE_START_FREQ_GET(
20804 wmi_reg_rule[count].freq_info);
20805 reg_rule_ptr[count].end_freq =
20806 WMI_REG_RULE_END_FREQ_GET(
20807 wmi_reg_rule[count].freq_info);
20808 reg_rule_ptr[count].max_bw =
20809 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020810 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020811 reg_rule_ptr[count].reg_power =
20812 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020813 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020814 reg_rule_ptr[count].ant_gain =
20815 WMI_REG_RULE_ANTENNA_GAIN_GET(
20816 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020817 reg_rule_ptr[count].flags =
20818 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020819 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020820 }
20821
20822 return reg_rule_ptr;
20823}
20824
20825static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20826 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20827 struct cur_regulatory_info *reg_info, uint32_t len)
20828{
20829 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20830 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20831 wmi_regulatory_rule_struct *wmi_reg_rule;
20832 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20833
20834 WMI_LOGD("processing regulatory channel list");
20835
20836 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20837 if (!param_buf) {
20838 WMI_LOGE("invalid channel list event buf");
20839 return QDF_STATUS_E_FAILURE;
20840 }
20841
20842 chan_list_event_hdr = param_buf->fixed_param;
20843
20844 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20845 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20846 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020847 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020848 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20849 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020850 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020851 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020852 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020853 reg_info->ctry_code = chan_list_event_hdr->country_id;
20854 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20855 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20856 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20857 else if (chan_list_event_hdr->status_code ==
20858 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20859 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20860 else if (chan_list_event_hdr->status_code ==
20861 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20862 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20863 else if (chan_list_event_hdr->status_code ==
20864 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20865 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20866 else if (chan_list_event_hdr->status_code ==
20867 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20868 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20869 else if (chan_list_event_hdr->status_code ==
20870 WMI_REG_SET_CC_STATUS_FAIL)
20871 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20872
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020873 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20874 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20875 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20876 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20877
20878 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20879 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20880
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020881 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20882 __func__, reg_info->alpha2, reg_info->dfs_region,
20883 reg_info->min_bw_2g, reg_info->max_bw_2g,
20884 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020885
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020886 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20887 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020888 wmi_reg_rule =
20889 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20890 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20891 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020892 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20893 wmi_reg_rule);
20894 wmi_reg_rule += num_2g_reg_rules;
20895
20896 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20897 wmi_reg_rule);
20898
20899 WMI_LOGD("processed regulatory channel list");
20900
20901 return QDF_STATUS_SUCCESS;
20902}
20903
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020904static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20905 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20906 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20907{
20908 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20909 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20910
20911 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20912 if (!param_buf) {
20913 WMI_LOGE("invalid 11d country event buf");
20914 return QDF_STATUS_E_FAILURE;
20915 }
20916
20917 reg_11d_country_event = param_buf->fixed_param;
20918
20919 qdf_mem_copy(reg_11d_country->alpha2,
20920 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20921
20922 WMI_LOGD("processed 11d country event, new cc %s",
20923 reg_11d_country->alpha2);
20924
20925 return QDF_STATUS_SUCCESS;
20926}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020927
20928static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20929 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20930 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20931{
20932 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20933 wmi_avoid_freq_range_desc *afr_desc;
20934 uint32_t num_freq_ranges, freq_range_idx;
20935 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20936 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20937
20938 if (!param_buf) {
20939 WMI_LOGE("Invalid channel avoid event buffer");
20940 return QDF_STATUS_E_INVAL;
20941 }
20942
20943 afr_fixed_param = param_buf->fixed_param;
20944 if (!afr_fixed_param) {
20945 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20946 return QDF_STATUS_E_INVAL;
20947 }
20948
20949 if (!ch_avoid_ind) {
20950 WMI_LOGE("Invalid channel avoid indication buffer");
20951 return QDF_STATUS_E_INVAL;
20952 }
20953 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20954 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20955 afr_fixed_param->num_freq_ranges;
20956
20957 WMI_LOGD("Channel avoid event received with %d ranges",
20958 num_freq_ranges);
20959
20960 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20961 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20962 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20963 freq_range_idx++) {
20964 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20965 afr_desc->start_freq;
20966 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20967 afr_desc->end_freq;
20968 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20969 freq_range_idx, afr_desc->tlv_header,
20970 afr_desc->start_freq, afr_desc->end_freq);
20971 afr_desc++;
20972 }
20973
20974 return QDF_STATUS_SUCCESS;
20975}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020976#ifdef DFS_COMPONENT_ENABLE
20977/**
20978 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20979 * @wmi_handle: wma handle
20980 * @evt_buf: event buffer
20981 * @vdev_id: vdev id
20982 * @len: length of buffer
20983 *
20984 * Return: 0 for success or error code
20985 */
20986static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20987 uint8_t *evt_buf,
20988 uint32_t *vdev_id,
20989 uint32_t len)
20990{
20991 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20992 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20993
20994 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20995 if (!param_tlvs) {
20996 WMI_LOGE("invalid cac complete event buf");
20997 return QDF_STATUS_E_FAILURE;
20998 }
20999
21000 cac_event = param_tlvs->fixed_param;
21001 *vdev_id = cac_event->vdev_id;
21002 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
21003
21004 return QDF_STATUS_SUCCESS;
21005}
21006
21007/**
21008 * extract_dfs_radar_detection_event_tlv() - extract radar found event
21009 * @wmi_handle: wma handle
21010 * @evt_buf: event buffer
21011 * @radar_found: radar found event info
21012 * @len: length of buffer
21013 *
21014 * Return: 0 for success or error code
21015 */
21016static QDF_STATUS extract_dfs_radar_detection_event_tlv(
21017 wmi_unified_t wmi_handle,
21018 uint8_t *evt_buf,
21019 struct radar_found_info *radar_found,
21020 uint32_t len)
21021{
21022 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
21023 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
21024
21025 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
21026 if (!param_tlv) {
21027 WMI_LOGE("invalid radar detection event buf");
21028 return QDF_STATUS_E_FAILURE;
21029 }
21030
21031 radar_event = param_tlv->fixed_param;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021032 radar_found->pdev_id = wmi_handle->ops->
21033 convert_pdev_id_target_to_host(radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021034 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021035 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021036 radar_found->chan_width = radar_event->chan_width;
21037 radar_found->detector_id = radar_event->detector_id;
21038 radar_found->segment_id = radar_event->segment_id;
21039 radar_found->timestamp = radar_event->timestamp;
21040 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070021041 radar_found->freq_offset = radar_event->freq_offset;
21042 radar_found->sidx = radar_event->sidx;
21043
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080021044 WMI_LOGI("processed radar found event pdev %d,"
21045 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
21046 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
21047 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
21048 "is_chirp %d,detection mode %d\n",
21049 radar_event->pdev_id, radar_event->pdev_id,
21050 radar_event->timestamp, radar_event->chan_freq,
21051 radar_event->chan_width, radar_event->detector_id,
21052 radar_event->freq_offset, radar_event->segment_id,
21053 radar_event->sidx, radar_event->is_chirp,
21054 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021055
21056 return QDF_STATUS_SUCCESS;
21057}
bings1ea12532017-12-18 16:56:53 +080021058
21059#ifdef QCA_MCL_DFS_SUPPORT
21060/**
21061 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
21062 * @wmi_handle: wma handle
21063 * @evt_buf: event buffer
21064 * @wlan_radar_event: Pointer to struct radar_event_info
21065 * @len: length of buffer
21066 *
21067 * Return: QDF_STATUS
21068 */
21069static QDF_STATUS extract_wlan_radar_event_info_tlv(
21070 wmi_unified_t wmi_handle,
21071 uint8_t *evt_buf,
21072 struct radar_event_info *wlan_radar_event,
21073 uint32_t len)
21074{
21075 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
21076 wmi_dfs_radar_event_fixed_param *radar_event;
21077
21078 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
21079 if (!param_tlv) {
21080 WMI_LOGE("invalid wlan radar event buf");
21081 return QDF_STATUS_E_FAILURE;
21082 }
21083
21084 radar_event = param_tlv->fixed_param;
21085 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
21086 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
21087 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
21088 wlan_radar_event->rssi = radar_event->rssi;
21089 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
21090 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
21091 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
21092 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080021093 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
21094 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings1ea12532017-12-18 16:56:53 +080021095 wlan_radar_event->pdev_id = radar_event->pdev_id;
21096
21097 return QDF_STATUS_SUCCESS;
21098}
21099#else
21100static QDF_STATUS extract_wlan_radar_event_info_tlv(
21101 wmi_unified_t wmi_handle,
21102 uint8_t *evt_buf,
21103 struct radar_event_info *wlan_radar_event,
21104 uint32_t len)
21105{
21106 return QDF_STATUS_SUCCESS;
21107}
21108#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070021109#endif
21110
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021111/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021112 * send_get_rcpi_cmd_tlv() - send request for rcpi value
21113 * @wmi_handle: wmi handle
21114 * @get_rcpi_param: rcpi params
21115 *
21116 * Return: QDF status
21117 */
21118static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
21119 struct rcpi_req *get_rcpi_param)
21120{
21121 wmi_buf_t buf;
21122 wmi_request_rcpi_cmd_fixed_param *cmd;
21123 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
21124
21125 buf = wmi_buf_alloc(wmi_handle, len);
21126 if (!buf) {
21127 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21128 return QDF_STATUS_E_NOMEM;
21129 }
21130
21131 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
21132 WMITLV_SET_HDR(&cmd->tlv_header,
21133 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
21134 WMITLV_GET_STRUCT_TLVLEN
21135 (wmi_request_rcpi_cmd_fixed_param));
21136
21137 cmd->vdev_id = get_rcpi_param->vdev_id;
21138 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
21139 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070021140
21141 switch (get_rcpi_param->measurement_type) {
21142
21143 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21144 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21145 break;
21146
21147 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
21148 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
21149 break;
21150
21151 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21152 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21153 break;
21154
21155 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
21156 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
21157 break;
21158
21159 default:
21160 /*
21161 * invalid rcpi measurement type, fall back to
21162 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
21163 */
21164 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21165 break;
21166 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053021167 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
21168 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21169 WMI_REQUEST_RCPI_CMDID)) {
21170
21171 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
21172 __func__);
21173 wmi_buf_free(buf);
21174 return QDF_STATUS_E_FAILURE;
21175 }
21176
21177 return QDF_STATUS_SUCCESS;
21178}
21179
21180/**
21181 * extract_rcpi_response_event_tlv() - Extract RCPI event params
21182 * @wmi_handle: wmi handle
21183 * @evt_buf: pointer to event buffer
21184 * @res: pointer to hold rcpi response from firmware
21185 *
21186 * Return: QDF_STATUS_SUCCESS for successful event parse
21187 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
21188 */
21189static QDF_STATUS
21190extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
21191 void *evt_buf, struct rcpi_res *res)
21192{
21193 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
21194 wmi_update_rcpi_event_fixed_param *event;
21195
21196 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
21197 if (!param_buf) {
21198 WMI_LOGE(FL("Invalid rcpi event"));
21199 return QDF_STATUS_E_INVAL;
21200 }
21201
21202 event = param_buf->fixed_param;
21203 res->vdev_id = event->vdev_id;
21204 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
21205
21206 switch (event->measurement_type) {
21207
21208 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
21209 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
21210 break;
21211
21212 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
21213 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
21214 break;
21215
21216 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
21217 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
21218 break;
21219
21220 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
21221 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
21222 break;
21223
21224 default:
21225 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
21226 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
21227 return QDF_STATUS_E_FAILURE;
21228 }
21229
21230 if (event->status)
21231 return QDF_STATUS_E_FAILURE;
21232 else
21233 return QDF_STATUS_SUCCESS;
21234}
21235
21236/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053021237 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
21238 * host to target defines. For legacy there is not conversion
21239 * required. Just return pdev_id as it is.
21240 * @param pdev_id: host pdev_id to be converted.
21241 * Return: target pdev_id after conversion.
21242 */
21243static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
21244 uint32_t pdev_id)
21245{
21246 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
21247 return WMI_PDEV_ID_SOC;
21248
21249 /*No conversion required*/
21250 return pdev_id;
21251}
21252
21253/**
21254 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
21255 * target to host defines. For legacy there is not conversion
21256 * required. Just return pdev_id as it is.
21257 * @param pdev_id: target pdev_id to be converted.
21258 * Return: host pdev_id after conversion.
21259 */
21260static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
21261 uint32_t pdev_id)
21262{
21263 /*No conversion required*/
21264 return pdev_id;
21265}
21266
21267/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070021268 * send_set_country_cmd_tlv() - WMI scan channel list function
21269 * @param wmi_handle : handle to WMI.
21270 * @param param : pointer to hold scan channel list parameter
21271 *
21272 * Return: 0 on success and -ve on failure.
21273 */
21274static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
21275 struct set_country *params)
21276{
21277 wmi_buf_t buf;
21278 QDF_STATUS qdf_status;
21279 wmi_set_current_country_cmd_fixed_param *cmd;
21280 uint16_t len = sizeof(*cmd);
21281
21282 buf = wmi_buf_alloc(wmi_handle, len);
21283 if (!buf) {
21284 WMI_LOGE("Failed to allocate memory");
21285 qdf_status = QDF_STATUS_E_NOMEM;
21286 goto end;
21287 }
21288
21289 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
21290 WMITLV_SET_HDR(&cmd->tlv_header,
21291 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
21292 WMITLV_GET_STRUCT_TLVLEN
21293 (wmi_set_current_country_cmd_fixed_param));
21294
21295 WMI_LOGD("setting cuurnet country to %s", params->country);
21296
21297 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
21298
21299 cmd->pdev_id = params->pdev_id;
21300
21301 qdf_status = wmi_unified_cmd_send(wmi_handle,
21302 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
21303
21304 if (QDF_IS_STATUS_ERROR(qdf_status)) {
21305 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
21306 wmi_buf_free(buf);
21307 }
21308
21309end:
21310 return qdf_status;
21311}
21312
Abhijit Pradhand38a2692017-06-29 12:32:20 +053021313#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
21314 WMI_SET_BITS(alpha, 0, 8, val0); \
21315 WMI_SET_BITS(alpha, 8, 8, val1); \
21316 WMI_SET_BITS(alpha, 16, 8, val2); \
21317 } while (0)
21318
21319static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
21320 uint8_t pdev_id, struct cc_regdmn_s *rd)
21321{
21322 wmi_set_init_country_cmd_fixed_param *cmd;
21323 uint16_t len;
21324 wmi_buf_t buf;
21325 int ret;
21326
21327 len = sizeof(wmi_set_init_country_cmd_fixed_param);
21328 buf = wmi_buf_alloc(wmi_handle, len);
21329 if (!buf) {
21330 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
21331 return QDF_STATUS_E_NOMEM;
21332 }
21333 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
21334 WMITLV_SET_HDR(&cmd->tlv_header,
21335 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
21336 WMITLV_GET_STRUCT_TLVLEN
21337 (wmi_set_init_country_cmd_fixed_param));
21338
21339 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
21340
21341 if (rd->flags == CC_IS_SET) {
21342 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
21343 cmd->country_code.country_id = rd->cc.country_code;
21344 } else if (rd->flags == ALPHA_IS_SET) {
21345 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
21346 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
21347 rd->cc.alpha[0],
21348 rd->cc.alpha[1],
21349 rd->cc.alpha[2]);
21350 } else if (rd->flags == REGDMN_IS_SET) {
21351 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
21352 cmd->country_code.domain_code = rd->cc.regdmn_id;
21353 }
21354
21355 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
21356 WMI_SET_INIT_COUNTRY_CMDID);
21357 if (ret) {
21358 WMI_LOGE("Failed to config wow wakeup event");
21359 wmi_buf_free(buf);
21360 return QDF_STATUS_E_FAILURE;
21361 }
21362
21363 return QDF_STATUS_SUCCESS;
21364}
21365
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053021366/**
21367 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
21368 * configuration params
21369 * @wmi_handle: wmi handler
21370 * @limit_off_chan_param: pointer to wmi_off_chan_param
21371 *
21372 * Return: 0 for success and non zero for failure
21373 */
21374static
21375QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
21376 struct wmi_limit_off_chan_param *limit_off_chan_param)
21377{
21378 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
21379 wmi_buf_t buf;
21380 uint32_t len = sizeof(*cmd);
21381 int err;
21382
21383 buf = wmi_buf_alloc(wmi_handle, len);
21384 if (!buf) {
21385 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
21386 __func__);
21387 return QDF_STATUS_E_NOMEM;
21388 }
21389
21390 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
21391
21392 WMITLV_SET_HDR(&cmd->tlv_header,
21393 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
21394 WMITLV_GET_STRUCT_TLVLEN(
21395 wmi_vdev_limit_offchan_cmd_fixed_param));
21396
21397 cmd->vdev_id = limit_off_chan_param->vdev_id;
21398
21399 cmd->flags &= 0;
21400 if (limit_off_chan_param->status)
21401 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
21402 if (limit_off_chan_param->skip_dfs_chans)
21403 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
21404
21405 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
21406 cmd->rest_time = limit_off_chan_param->rest_time;
21407
21408 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
21409 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
21410 cmd->rest_time);
21411
21412 err = wmi_unified_cmd_send(wmi_handle, buf,
21413 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
21414 if (QDF_IS_STATUS_ERROR(err)) {
21415 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
21416 wmi_buf_free(buf);
21417 return QDF_STATUS_E_FAILURE;
21418 }
21419
21420 return QDF_STATUS_SUCCESS;
21421}
21422
Anurag Chouhan97f00422017-09-11 14:56:30 +053021423/**
21424 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
21425 * @wmi_handle: wmi handler
21426 * @req_buf: set arp stats request buffer
21427 *
21428 * Return: 0 for success and non zero for failure
21429 */
21430static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21431 struct set_arp_stats *req_buf)
21432{
21433 wmi_buf_t buf = NULL;
21434 QDF_STATUS status;
21435 int len;
21436 uint8_t *buf_ptr;
21437 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
21438
21439 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021440 if (req_buf->pkt_type_bitmap) {
21441 len += WMI_TLV_HDR_SIZE;
21442 len += sizeof(wmi_vdev_set_connectivity_check_stats);
21443 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053021444 buf = wmi_buf_alloc(wmi_handle, len);
21445 if (!buf) {
21446 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21447 return QDF_STATUS_E_NOMEM;
21448 }
21449
21450 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21451 wmi_set_arp =
21452 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
21453 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
21454 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
21455 WMITLV_GET_STRUCT_TLVLEN
21456 (wmi_vdev_set_arp_stats_cmd_fixed_param));
21457
21458 /* fill in per roam config values */
21459 wmi_set_arp->vdev_id = req_buf->vdev_id;
21460
21461 wmi_set_arp->set_clr = req_buf->flag;
21462 wmi_set_arp->pkt_type = req_buf->pkt_type;
21463 wmi_set_arp->ipv4 = req_buf->ip_addr;
21464
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053021465 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
21466 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
21467 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
21468
21469 /*
21470 * pkt_type_bitmap should be non-zero to ensure
21471 * presence of additional stats.
21472 */
21473 if (req_buf->pkt_type_bitmap) {
21474 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
21475
21476 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
21477 WMITLV_SET_HDR(buf_ptr,
21478 WMITLV_TAG_ARRAY_STRUC,
21479 sizeof(wmi_vdev_set_connectivity_check_stats));
21480 buf_ptr += WMI_TLV_HDR_SIZE;
21481 wmi_set_connect_stats =
21482 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
21483 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
21484 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
21485 WMITLV_GET_STRUCT_TLVLEN(
21486 wmi_vdev_set_connectivity_check_stats));
21487 wmi_set_connect_stats->pkt_type_bitmap =
21488 req_buf->pkt_type_bitmap;
21489 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
21490 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
21491 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
21492
21493 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
21494 wmi_set_connect_stats->pkt_type_bitmap,
21495 wmi_set_connect_stats->tcp_src_port,
21496 wmi_set_connect_stats->tcp_dst_port,
21497 wmi_set_connect_stats->icmp_ipv4);
21498 }
21499
Anurag Chouhan97f00422017-09-11 14:56:30 +053021500 /* Send per roam config parameters */
21501 status = wmi_unified_cmd_send(wmi_handle, buf,
21502 len, WMI_VDEV_SET_ARP_STAT_CMDID);
21503 if (QDF_IS_STATUS_ERROR(status)) {
21504 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
21505 status);
21506 goto error;
21507 }
21508
21509 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
21510 req_buf->flag, req_buf->vdev_id);
21511 return QDF_STATUS_SUCCESS;
21512error:
21513 wmi_buf_free(buf);
21514
21515 return status;
21516}
21517
21518/**
21519 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
21520 * @wmi_handle: wmi handler
21521 * @req_buf: get arp stats request buffer
21522 *
21523 * Return: 0 for success and non zero for failure
21524 */
21525static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
21526 struct get_arp_stats *req_buf)
21527{
21528 wmi_buf_t buf = NULL;
21529 QDF_STATUS status;
21530 int len;
21531 uint8_t *buf_ptr;
21532 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
21533
21534 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
21535 buf = wmi_buf_alloc(wmi_handle, len);
21536 if (!buf) {
21537 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
21538 return QDF_STATUS_E_NOMEM;
21539 }
21540
21541 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21542 get_arp_stats =
21543 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
21544 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
21545 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
21546 WMITLV_GET_STRUCT_TLVLEN
21547 (wmi_vdev_get_arp_stats_cmd_fixed_param));
21548
21549 /* fill in arp stats req cmd values */
21550 get_arp_stats->vdev_id = req_buf->vdev_id;
21551
21552 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
21553 /* Send per roam config parameters */
21554 status = wmi_unified_cmd_send(wmi_handle, buf,
21555 len, WMI_VDEV_GET_ARP_STAT_CMDID);
21556 if (QDF_IS_STATUS_ERROR(status)) {
21557 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
21558 status);
21559 goto error;
21560 }
21561
21562 return QDF_STATUS_SUCCESS;
21563error:
21564 wmi_buf_free(buf);
21565
21566 return status;
21567}
21568
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021569/**
21570 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
21571 * @wmi_handle: wmi handler
21572 * @pmk_info: pointer to PMK cache entry
21573 * @vdev_id: vdev id
21574 *
21575 * Return: 0 for success and non zero for failure
21576 */
21577static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
21578 struct wmi_unified_pmk_cache *pmk_info)
21579{
21580 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
21581 wmi_buf_t buf;
21582 QDF_STATUS status;
21583 uint8_t *buf_ptr;
21584 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021585 uint32_t len = sizeof(*cmd);
21586
21587 if (pmk_info->pmk_len)
21588 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021589
21590 buf = wmi_buf_alloc(wmi_handle, len);
21591 if (!buf) {
21592 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
21593 __func__);
21594 return QDF_STATUS_E_NOMEM;
21595 }
21596
21597 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21598 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
21599
21600 WMITLV_SET_HDR(&cmd->tlv_header,
21601 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
21602 WMITLV_GET_STRUCT_TLVLEN(
21603 wmi_pdev_update_pmk_cache_cmd_fixed_param));
21604
21605 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021606
21607 /* If pmk_info->pmk_len is 0, this is a flush request */
21608 if (!pmk_info->pmk_len) {
21609 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
21610 cmd->num_cache = 0;
21611 goto send_cmd;
21612 }
21613
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021614 cmd->num_cache = 1;
21615 buf_ptr += sizeof(*cmd);
21616
21617 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21618 sizeof(*pmksa));
21619 buf_ptr += WMI_TLV_HDR_SIZE;
21620
21621 pmksa = (wmi_pmk_cache *)buf_ptr;
21622 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
21623 WMITLV_GET_STRUCT_TLVLEN
21624 (wmi_pmk_cache));
21625 pmksa->pmk_len = pmk_info->pmk_len;
21626 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
21627 pmksa->pmkid_len = pmk_info->pmkid_len;
21628 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
21629 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
21630 pmksa->ssid.ssid_len = pmk_info->ssid.length;
21631 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
21632 pmksa->ssid.ssid_len);
21633 pmksa->cache_id = pmk_info->cache_id;
21634 pmksa->cat_flag = pmk_info->cat_flag;
21635 pmksa->action_flag = pmk_info->action_flag;
21636
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053021637send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053021638 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21639 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
21640 if (status != QDF_STATUS_SUCCESS) {
21641 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
21642 __func__, status);
21643 wmi_buf_free(buf);
21644 }
21645
21646 return status;
21647}
21648
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021649/**
21650 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
21651 * @wmi_handle: wmi handle
21652 * @param: reserved param
21653 *
21654 * Return: 0 for success or error code
21655 */
21656static QDF_STATUS
21657send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
21658 uint32_t param)
21659{
21660 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
21661 wmi_buf_t buf;
21662 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
21663
21664 buf = wmi_buf_alloc(wmi_handle, len);
21665 if (!buf) {
21666 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21667 return QDF_STATUS_E_FAILURE;
21668 }
21669 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
21670 WMITLV_SET_HDR(&cmd->tlv_header,
21671 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
21672 WMITLV_GET_STRUCT_TLVLEN
21673 (wmi_pdev_check_cal_version_cmd_fixed_param));
21674 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
21675 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21676 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
21677 wmi_buf_free(buf);
21678 return QDF_STATUS_E_FAILURE;
21679 }
21680
21681 return QDF_STATUS_SUCCESS;
21682}
21683
21684/**
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053021685 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
21686 * host to target defines.
21687 * @param pdev_id: host pdev_id to be converted.
21688 * Return: target pdev_id after conversion.
21689 */
21690static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
21691{
21692 switch (pdev_id) {
21693 case WMI_HOST_PDEV_ID_SOC:
21694 return WMI_PDEV_ID_SOC;
21695 case WMI_HOST_PDEV_ID_0:
21696 return WMI_PDEV_ID_1ST;
21697 case WMI_HOST_PDEV_ID_1:
21698 return WMI_PDEV_ID_2ND;
21699 case WMI_HOST_PDEV_ID_2:
21700 return WMI_PDEV_ID_3RD;
21701 }
21702
21703 QDF_ASSERT(0);
21704
21705 return WMI_PDEV_ID_SOC;
21706}
21707
21708/**
21709 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
21710 * target to host defines.
21711 * @param pdev_id: target pdev_id to be converted.
21712 * Return: host pdev_id after conversion.
21713 */
21714static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
21715{
21716 switch (pdev_id) {
21717 case WMI_PDEV_ID_SOC:
21718 return WMI_HOST_PDEV_ID_SOC;
21719 case WMI_PDEV_ID_1ST:
21720 return WMI_HOST_PDEV_ID_0;
21721 case WMI_PDEV_ID_2ND:
21722 return WMI_HOST_PDEV_ID_1;
21723 case WMI_PDEV_ID_3RD:
21724 return WMI_HOST_PDEV_ID_2;
21725 }
21726
21727 QDF_ASSERT(0);
21728
21729 return WMI_HOST_PDEV_ID_SOC;
21730}
21731
21732/**
21733 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
21734 *
21735 * Return None.
21736 */
21737static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
21738{
21739 wmi_handle->ops->convert_pdev_id_host_to_target =
21740 convert_host_pdev_id_to_target_pdev_id;
21741 wmi_handle->ops->convert_pdev_id_target_to_host =
21742 convert_target_pdev_id_to_host_pdev_id;
21743}
21744
21745/**
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021746 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21747 * @wmi_handle: wmi handle
21748 * @param evt_buf: pointer to event buffer
21749 * @param param: Pointer to hold peer caldata version data
21750 *
21751 * Return: 0 for success or error code
21752 */
21753static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21754 wmi_unified_t wmi_handle,
21755 void *evt_buf,
21756 wmi_host_pdev_check_cal_version_event *param)
21757{
21758 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21759 wmi_pdev_check_cal_version_event_fixed_param *event;
21760
21761 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21762 if (!param_tlvs) {
21763 WMI_LOGE("invalid cal version event buf");
21764 return QDF_STATUS_E_FAILURE;
21765 }
21766 event = param_tlvs->fixed_param;
21767 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21768 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21769 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21770 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21771
21772 param->software_cal_version = event->software_cal_version;
21773 param->board_cal_version = event->board_cal_version;
21774 param->cal_ok = event->cal_status;
21775
21776 return QDF_STATUS_SUCCESS;
21777}
21778
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021779/*
21780 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21781 * @wmi_handle: wmi handle
21782 * @params: pointer to wmi_btm_config
21783 *
21784 * Return: QDF_STATUS
21785 */
21786static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21787 struct wmi_btm_config *params)
21788{
21789
21790 wmi_btm_config_fixed_param *cmd;
21791 wmi_buf_t buf;
21792 uint32_t len;
21793
21794 len = sizeof(*cmd);
21795 buf = wmi_buf_alloc(wmi_handle, len);
21796 if (!buf) {
21797 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21798 return QDF_STATUS_E_NOMEM;
21799 }
21800
21801 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21802 WMITLV_SET_HDR(&cmd->tlv_header,
21803 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21804 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21805 cmd->vdev_id = params->vdev_id;
21806 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021807 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21808 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21809 cmd->stick_time_seconds = params->btm_sticky_time;
21810
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021811 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21812 WMI_ROAM_BTM_CONFIG_CMDID)) {
21813 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21814 __func__);
21815 wmi_buf_free(buf);
21816 return QDF_STATUS_E_FAILURE;
21817 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021818
21819 return QDF_STATUS_SUCCESS;
21820}
21821
21822/**
21823 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21824 * configurations to firmware.
21825 * @wmi_handle: wmi handle
21826 * @obss_cfg_param: obss detection configurations
21827 *
21828 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21829 *
21830 * Return: QDF_STATUS
21831 */
21832static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21833 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21834{
21835 wmi_buf_t buf;
21836 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21837 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21838
21839 buf = wmi_buf_alloc(wmi_handle, len);
21840 if (!buf) {
21841 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21842 return QDF_STATUS_E_NOMEM;
21843 }
21844
21845 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21846 WMITLV_SET_HDR(&cmd->tlv_header,
21847 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21848 WMITLV_GET_STRUCT_TLVLEN
21849 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21850
21851 cmd->vdev_id = obss_cfg_param->vdev_id;
21852 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21853 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21854 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21855 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21856 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21857 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21858 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21859 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021860
21861 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21862 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21863 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21864 wmi_buf_free(buf);
21865 return QDF_STATUS_E_FAILURE;
21866 }
21867
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021868 return QDF_STATUS_SUCCESS;
21869}
21870
Arif Hussain33d98502018-01-12 13:15:04 -080021871/**
21872 * extract_obss_detection_info_tlv() - Extract obss detection info
21873 * received from firmware.
21874 * @evt_buf: pointer to event buffer
21875 * @obss_detection: Pointer to hold obss detection info
21876 *
21877 * Return: QDF_STATUS
21878 */
21879static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21880 struct wmi_obss_detect_info
21881 *obss_detection)
21882{
21883 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21884 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21885
21886 if (!obss_detection) {
21887 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21888 return QDF_STATUS_E_INVAL;
21889 }
21890
21891 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21892 if (!param_buf) {
21893 WMI_LOGE("%s: Invalid evt_buf", __func__);
21894 return QDF_STATUS_E_INVAL;
21895 }
21896
21897 fix_param = param_buf->fixed_param;
21898 obss_detection->vdev_id = fix_param->vdev_id;
21899 obss_detection->matched_detection_masks =
21900 fix_param->matched_detection_masks;
21901 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21902 &obss_detection->matched_bssid_addr[0]);
21903 switch (fix_param->reason) {
21904 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21905 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21906 break;
21907 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21908 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21909 break;
21910 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21911 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21912 break;
21913 default:
21914 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21915 return QDF_STATUS_E_INVAL;
21916 }
21917
21918 return QDF_STATUS_SUCCESS;
21919}
21920
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021921/**
21922 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21923 * @wmi_handle: wmi handler
21924 * @params: pointer to 11k offload params
21925 *
21926 * Return: 0 for success and non zero for failure
21927 */
21928static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21929 struct wmi_11k_offload_params *params)
21930{
21931 wmi_11k_offload_report_fixed_param *cmd;
21932 wmi_buf_t buf;
21933 QDF_STATUS status;
21934 uint8_t *buf_ptr;
21935 wmi_neighbor_report_11k_offload_tlv_param
21936 *neighbor_report_offload_params;
21937 wmi_neighbor_report_offload *neighbor_report_offload;
21938
21939 uint32_t len = sizeof(*cmd);
21940
21941 if (params->offload_11k_bitmask &
21942 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21943 len += WMI_TLV_HDR_SIZE +
21944 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21945
21946 buf = wmi_buf_alloc(wmi_handle, len);
21947 if (!buf) {
21948 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21949 __func__);
21950 return QDF_STATUS_E_NOMEM;
21951 }
21952
21953 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21954 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21955
21956 WMITLV_SET_HDR(&cmd->tlv_header,
21957 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21958 WMITLV_GET_STRUCT_TLVLEN(
21959 wmi_11k_offload_report_fixed_param));
21960
21961 cmd->vdev_id = params->vdev_id;
21962 cmd->offload_11k = params->offload_11k_bitmask;
21963
21964 if (params->offload_11k_bitmask &
21965 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21966 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21967
21968 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21969 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21970 buf_ptr += WMI_TLV_HDR_SIZE;
21971
21972 neighbor_report_offload_params =
21973 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21974 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21975 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21976 WMITLV_GET_STRUCT_TLVLEN(
21977 wmi_neighbor_report_11k_offload_tlv_param));
21978
21979 neighbor_report_offload = &neighbor_report_offload_params->
21980 neighbor_rep_ofld_params;
21981
21982 neighbor_report_offload->time_offset =
21983 params->neighbor_report_params.time_offset;
21984 neighbor_report_offload->low_rssi_offset =
21985 params->neighbor_report_params.low_rssi_offset;
21986 neighbor_report_offload->bmiss_count_trigger =
21987 params->neighbor_report_params.bmiss_count_trigger;
21988 neighbor_report_offload->per_threshold_offset =
21989 params->neighbor_report_params.per_threshold_offset;
21990 neighbor_report_offload->neighbor_report_cache_timeout =
21991 params->neighbor_report_params.
21992 neighbor_report_cache_timeout;
21993 neighbor_report_offload->max_neighbor_report_req_cap =
21994 params->neighbor_report_params.
21995 max_neighbor_report_req_cap;
21996 neighbor_report_offload->ssid.ssid_len =
21997 params->neighbor_report_params.ssid.length;
21998 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21999 &params->neighbor_report_params.ssid.mac_ssid,
22000 neighbor_report_offload->ssid.ssid_len);
22001 }
22002
22003 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22004 WMI_11K_OFFLOAD_REPORT_CMDID);
22005 if (status != QDF_STATUS_SUCCESS) {
22006 WMI_LOGE("%s: failed to send 11k offload command %d",
22007 __func__, status);
22008 wmi_buf_free(buf);
22009 }
22010
22011 return status;
22012}
22013
22014/**
22015 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
22016 * command
22017 * @wmi_handle: wmi handler
22018 * @params: pointer to neighbor report invoke params
22019 *
22020 * Return: 0 for success and non zero for failure
22021 */
22022static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
22023 struct wmi_invoke_neighbor_report_params *params)
22024{
22025 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
22026 wmi_buf_t buf;
22027 QDF_STATUS status;
22028 uint8_t *buf_ptr;
22029 uint32_t len = sizeof(*cmd);
22030
22031 buf = wmi_buf_alloc(wmi_handle, len);
22032 if (!buf) {
22033 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
22034 __func__);
22035 return QDF_STATUS_E_NOMEM;
22036 }
22037
22038 buf_ptr = (uint8_t *) wmi_buf_data(buf);
22039 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
22040
22041 WMITLV_SET_HDR(&cmd->tlv_header,
22042 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
22043 WMITLV_GET_STRUCT_TLVLEN(
22044 wmi_11k_offload_invoke_neighbor_report_fixed_param));
22045
22046 cmd->vdev_id = params->vdev_id;
22047 cmd->flags = params->send_resp_to_host;
22048
22049 cmd->ssid.ssid_len = params->ssid.length;
22050 qdf_mem_copy(cmd->ssid.ssid,
22051 &params->ssid.mac_ssid,
22052 cmd->ssid.ssid_len);
22053
22054 status = wmi_unified_cmd_send(wmi_handle, buf, len,
22055 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
22056 if (status != QDF_STATUS_SUCCESS) {
22057 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
22058 __func__, status);
22059 wmi_buf_free(buf);
22060 }
22061
22062 return status;
22063}
22064
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022065#ifdef WLAN_SUPPORT_GREEN_AP
22066static QDF_STATUS extract_green_ap_egap_status_info_tlv(
22067 uint8_t *evt_buf,
22068 struct wlan_green_ap_egap_status_info *egap_status_info_params)
22069{
22070 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
22071 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
22072 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
22073
22074 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
22075 if (!param_buf) {
22076 WMI_LOGE("Invalid EGAP Info status event buffer");
22077 return QDF_STATUS_E_INVAL;
22078 }
22079
22080 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
22081 param_buf->fixed_param;
22082 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
22083 param_buf->chainmask_list;
22084
22085 egap_status_info_params->status = egap_info_event->status;
22086 egap_status_info_params->mac_id = chainmask_event->mac_id;
22087 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
22088 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
22089
22090 return QDF_STATUS_SUCCESS;
22091}
22092#endif
22093
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022094/*
22095 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
22096 * updating bss color change within firmware when AP announces bss color change.
22097 * @wmi_handle: wmi handle
22098 * @vdev_id: vdev ID
22099 * @enable: enable bss color change within firmware
22100 *
22101 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
22102 *
22103 * Return: QDF_STATUS
22104 */
22105static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
22106 uint32_t vdev_id,
22107 bool enable)
22108{
22109 wmi_buf_t buf;
22110 wmi_bss_color_change_enable_fixed_param *cmd;
22111 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
22112
22113 buf = wmi_buf_alloc(wmi_handle, len);
22114 if (!buf) {
22115 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22116 return QDF_STATUS_E_NOMEM;
22117 }
22118
22119 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
22120 WMITLV_SET_HDR(&cmd->tlv_header,
22121 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
22122 WMITLV_GET_STRUCT_TLVLEN
22123 (wmi_bss_color_change_enable_fixed_param));
22124 cmd->vdev_id = vdev_id;
22125 cmd->enable = enable;
22126 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22127 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
22128 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
22129 wmi_buf_free(buf);
22130 return QDF_STATUS_E_FAILURE;
22131 }
22132
22133 return QDF_STATUS_SUCCESS;
22134}
22135
22136/**
22137 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
22138 * configurations to firmware.
22139 * @wmi_handle: wmi handle
22140 * @cfg_param: obss detection configurations
22141 *
22142 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
22143 *
22144 * Return: QDF_STATUS
22145 */
22146static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
22147 wmi_unified_t wmi_handle,
22148 struct wmi_obss_color_collision_cfg_param *cfg_param)
22149{
22150 wmi_buf_t buf;
22151 wmi_obss_color_collision_det_config_fixed_param *cmd;
22152 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
22153
22154 buf = wmi_buf_alloc(wmi_handle, len);
22155 if (!buf) {
22156 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
22157 return QDF_STATUS_E_NOMEM;
22158 }
22159
22160 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
22161 buf);
22162 WMITLV_SET_HDR(&cmd->tlv_header,
22163 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
22164 WMITLV_GET_STRUCT_TLVLEN
22165 (wmi_obss_color_collision_det_config_fixed_param));
22166 cmd->vdev_id = cfg_param->vdev_id;
22167 cmd->flags = cfg_param->flags;
22168 cmd->current_bss_color = cfg_param->current_bss_color;
22169 cmd->detection_period_ms = cfg_param->detection_period_ms;
22170 cmd->scan_period_ms = cfg_param->scan_period_ms;
22171 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
22172
22173 switch (cfg_param->evt_type) {
22174 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
22175 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
22176 break;
22177 case OBSS_COLOR_COLLISION_DETECTION:
22178 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
22179 break;
22180 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22181 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22182 break;
22183 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
22184 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
22185 break;
22186 default:
22187 WMI_LOGE("%s: invalid event type: %d",
22188 __func__, cfg_param->evt_type);
22189 wmi_buf_free(buf);
22190 return QDF_STATUS_E_FAILURE;
22191 }
22192
22193 if (wmi_unified_cmd_send(wmi_handle, buf, len,
22194 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
22195 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
22196 __func__, cfg_param->vdev_id);
22197 wmi_buf_free(buf);
22198 return QDF_STATUS_E_FAILURE;
22199 }
22200
22201 return QDF_STATUS_SUCCESS;
22202}
22203
22204/**
22205 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
22206 * received from firmware.
22207 * @evt_buf: pointer to event buffer
22208 * @info: Pointer to hold bss collision info
22209 *
22210 * Return: QDF_STATUS
22211 */
22212static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
22213 struct wmi_obss_color_collision_info *info)
22214{
22215 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
22216 wmi_obss_color_collision_evt_fixed_param *fix_param;
22217
22218 if (!info) {
22219 WMI_LOGE("%s: Invalid obss color buffer", __func__);
22220 return QDF_STATUS_E_INVAL;
22221 }
22222
22223 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
22224 evt_buf;
22225 if (!param_buf) {
22226 WMI_LOGE("%s: Invalid evt_buf", __func__);
22227 return QDF_STATUS_E_INVAL;
22228 }
22229
22230 fix_param = param_buf->fixed_param;
22231 info->vdev_id = fix_param->vdev_id;
22232 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
22233 info->obss_color_bitmap_bit32to63 =
22234 fix_param->bss_color_bitmap_bit32to63;
22235
22236 switch (fix_param->evt_type) {
22237 case WMI_BSS_COLOR_COLLISION_DISABLE:
22238 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
22239 break;
22240 case WMI_BSS_COLOR_COLLISION_DETECTION:
22241 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
22242 break;
22243 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
22244 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
22245 break;
22246 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
22247 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
22248 break;
22249 default:
22250 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
22251 __func__, fix_param->evt_type, fix_param->vdev_id);
22252 return QDF_STATUS_E_FAILURE;
22253 }
22254
22255 return QDF_STATUS_SUCCESS;
22256}
22257
Arif Hussaine0eb7302018-03-01 14:40:59 -080022258/*
22259 * extract_comb_phyerr_tlv() - extract comb phy error from event
22260 * @wmi_handle: wmi handle
22261 * @evt_buf: pointer to event buffer
22262 * @datalen: data length of event buffer
22263 * @buf_offset: Pointer to hold value of current event buffer offset
22264 * post extraction
22265 * @phyerr: Pointer to hold phyerr
22266 *
22267 * Return: QDF_STATUS
22268 */
22269static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
22270 void *evt_buf,
22271 uint16_t datalen,
22272 uint16_t *buf_offset,
22273 wmi_host_phyerr_t *phyerr)
22274{
22275 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
22276 wmi_comb_phyerr_rx_hdr *pe_hdr;
22277
22278 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
22279 if (!param_tlvs) {
22280 WMI_LOGD("%s: Received null data from FW", __func__);
22281 return QDF_STATUS_E_FAILURE;
22282 }
22283
22284 pe_hdr = param_tlvs->hdr;
22285 if (!pe_hdr) {
22286 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
22287 return QDF_STATUS_E_FAILURE;
22288 }
22289
22290 /* Ensure it's at least the size of the header */
22291 if (datalen < sizeof(*pe_hdr)) {
22292 WMI_LOGD("%s: Expected minimum size %zu, received %d",
22293 __func__, sizeof(*pe_hdr), datalen);
22294 return QDF_STATUS_E_FAILURE;
22295 }
22296
22297 phyerr->pdev_id = wmi_handle->ops->
22298 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
22299 phyerr->tsf64 = pe_hdr->tsf_l32;
22300 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
22301 phyerr->bufp = param_tlvs->bufp;
22302 phyerr->buf_len = pe_hdr->buf_len;
22303 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
22304 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
22305 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
22306
22307 return QDF_STATUS_SUCCESS;
22308}
22309
22310/**
22311 * extract_single_phyerr_tlv() - extract single phy error from event
22312 * @wmi_handle: wmi handle
22313 * @evt_buf: pointer to event buffer
22314 * @datalen: data length of event buffer
22315 * @buf_offset: Pointer to hold value of current event buffer offset
22316 * post extraction
22317 * @phyerr: Pointer to hold phyerr
22318 *
22319 * Return: QDF_STATUS
22320 */
22321static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
22322 void *evt_buf,
22323 uint16_t datalen,
22324 uint16_t *buf_offset,
22325 wmi_host_phyerr_t *phyerr)
22326{
22327 wmi_single_phyerr_rx_event *ev;
22328 uint16_t n = *buf_offset;
22329 uint8_t *data = (uint8_t *)evt_buf;
22330
22331 if (n < datalen) {
22332 if ((datalen - n) < sizeof(ev->hdr)) {
22333 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
22334 __func__, datalen, n, sizeof(ev->hdr));
22335 return QDF_STATUS_E_FAILURE;
22336 }
22337
22338 /*
22339 * Obtain a pointer to the beginning of the current event.
22340 * data[0] is the beginning of the WMI payload.
22341 */
22342 ev = (wmi_single_phyerr_rx_event *)&data[n];
22343
22344 /*
22345 * Sanity check the buffer length of the event against
22346 * what we currently have.
22347 *
22348 * Since buf_len is 32 bits, we check if it overflows
22349 * a large 32 bit value. It's not 0x7fffffff because
22350 * we increase n by (buf_len + sizeof(hdr)), which would
22351 * in itself cause n to overflow.
22352 *
22353 * If "int" is 64 bits then this becomes a moot point.
22354 */
22355 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
22356 WMI_LOGD("%s: buf_len is garbage 0x%x",
22357 __func__, ev->hdr.buf_len);
22358 return QDF_STATUS_E_FAILURE;
22359 }
22360
22361 if ((n + ev->hdr.buf_len) > datalen) {
22362 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
22363 __func__, n, ev->hdr.buf_len, datalen);
22364 return QDF_STATUS_E_FAILURE;
22365 }
22366
22367 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
22368 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
22369 phyerr->bufp = &ev->bufp[0];
22370 phyerr->buf_len = ev->hdr.buf_len;
22371 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
22372
22373 /*
22374 * Advance the buffer pointer to the next PHY error.
22375 * buflen is the length of this payload, so we need to
22376 * advance past the current header _AND_ the payload.
22377 */
22378 n += sizeof(*ev) + ev->hdr.buf_len;
22379 }
22380 *buf_offset = n;
22381
22382 return QDF_STATUS_SUCCESS;
22383}
22384
Govind Singh5eb51532016-03-09 11:34:12 +053022385struct wmi_ops tlv_ops = {
22386 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
22387 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
22388 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053022389 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
22390 .send_hidden_ssid_vdev_restart_cmd =
22391 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022392 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
22393 .send_peer_param_cmd = send_peer_param_cmd_tlv,
22394 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022395 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022396 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022397 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070022398 .send_peer_rx_reorder_queue_setup_cmd =
22399 send_peer_rx_reorder_queue_setup_cmd_tlv,
22400 .send_peer_rx_reorder_queue_remove_cmd =
22401 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053022402 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
22403 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
22404 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022405 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
22406 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022407 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022408 .send_suspend_cmd = send_suspend_cmd_tlv,
22409 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080022410#ifdef FEATURE_WLAN_D0WOW
22411 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
22412 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
22413#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022414 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
22415 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
22416 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
22417 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
22418 .send_dbglog_cmd = send_dbglog_cmd_tlv,
22419 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
22420 .send_stats_request_cmd = send_stats_request_cmd_tlv,
22421 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053022422 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070022423 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022424 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022425 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022426 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
22427 .send_scan_start_cmd = send_scan_start_cmd_tlv,
22428 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
22429 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022430 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022431 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022432 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
22433 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022434 .send_set_sta_uapsd_auto_trig_cmd =
22435 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053022436 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
22437 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
22438 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022439#ifdef CONVERGED_P2P_ENABLE
22440 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
22441 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
22442#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053022443 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
22444 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022445#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053022446 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
22447 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
22448 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
22449 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
22450 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
22451 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
22452 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022453 .send_ocb_start_timing_advert_cmd =
22454 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080022455 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
22456 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
22457 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
22458 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
22459#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053022460 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
22461 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
22462 .send_set_mcc_channel_time_latency_cmd =
22463 send_set_mcc_channel_time_latency_cmd_tlv,
22464 .send_set_mcc_channel_time_quota_cmd =
22465 send_set_mcc_channel_time_quota_cmd_tlv,
22466 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
22467 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053022468 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022469 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
22470 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
22471 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022472 .send_probe_rsp_tmpl_send_cmd =
22473 send_probe_rsp_tmpl_send_cmd_tlv,
22474 .send_p2p_go_set_beacon_ie_cmd =
22475 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053022476 .send_setup_install_key_cmd =
22477 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022478 .send_set_gateway_params_cmd =
22479 send_set_gateway_params_cmd_tlv,
22480 .send_set_rssi_monitoring_cmd =
22481 send_set_rssi_monitoring_cmd_tlv,
22482 .send_scan_probe_setoui_cmd =
22483 send_scan_probe_setoui_cmd_tlv,
22484 .send_reset_passpoint_network_list_cmd =
22485 send_reset_passpoint_network_list_cmd_tlv,
22486 .send_set_passpoint_network_list_cmd =
22487 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022488 .send_roam_scan_offload_rssi_thresh_cmd =
22489 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070022490 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053022491 .send_roam_scan_filter_cmd =
22492 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022493 .send_set_epno_network_list_cmd =
22494 send_set_epno_network_list_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022495#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053022496 .send_ipa_offload_control_cmd =
22497 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053022498#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053022499 .send_extscan_get_capabilities_cmd =
22500 send_extscan_get_capabilities_cmd_tlv,
22501 .send_extscan_get_cached_results_cmd =
22502 send_extscan_get_cached_results_cmd_tlv,
22503 .send_extscan_stop_change_monitor_cmd =
22504 send_extscan_stop_change_monitor_cmd_tlv,
22505 .send_extscan_start_change_monitor_cmd =
22506 send_extscan_start_change_monitor_cmd_tlv,
22507 .send_extscan_stop_hotlist_monitor_cmd =
22508 send_extscan_stop_hotlist_monitor_cmd_tlv,
22509 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
22510 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
22511 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
22512 .send_plm_start_cmd = send_plm_start_cmd_tlv,
22513 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
22514 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070022515 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053022516 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
22517 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
22518 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
22519 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053022520 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022521 .send_snr_request_cmd = send_snr_request_cmd_tlv,
22522 .send_snr_cmd = send_snr_cmd_tlv,
22523 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022524#ifdef WLAN_PMO_ENABLE
22525 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
22526 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
22527 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
22528 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053022529 .send_multiple_add_clear_mcbc_filter_cmd =
22530 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070022531 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022532 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
22533 .send_process_gtk_offload_getinfo_cmd =
22534 send_process_gtk_offload_getinfo_cmd_tlv,
22535 .send_enable_enhance_multicast_offload_cmd =
22536 send_enable_enhance_multicast_offload_tlv,
22537 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
22538#ifdef FEATURE_WLAN_RA_FILTERING
22539 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
22540#endif
22541 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022542 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
22543 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022544 .send_lphb_config_tcp_pkt_filter_cmd =
22545 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022546 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
22547 .send_lphb_config_udp_pkt_filter_cmd =
22548 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053022549 .send_enable_disable_packet_filter_cmd =
22550 send_enable_disable_packet_filter_cmd_tlv,
22551 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053022552#endif /* End of WLAN_PMO_ENABLE */
22553#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053022554 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
22555 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022556 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053022557 .send_roam_scan_offload_mode_cmd =
22558 send_roam_scan_offload_mode_cmd_tlv,
22559 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
22560 .send_roam_scan_offload_ap_profile_cmd =
22561 send_roam_scan_offload_ap_profile_cmd_tlv,
22562#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022563#ifdef WLAN_SUPPORT_GREEN_AP
22564 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
22565 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053022566 .extract_green_ap_egap_status_info =
22567 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053022568#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053022569 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
22570 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022571 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080022572 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022573 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070022574#ifdef WLAN_FEATURE_CIF_CFR
22575 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
22576#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053022577 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022578 .send_dfs_phyerr_filter_offload_en_cmd =
22579 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022580 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
22581 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
22582 .send_del_ts_cmd = send_del_ts_cmd_tlv,
22583 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
22584 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022585 .send_process_add_periodic_tx_ptrn_cmd =
22586 send_process_add_periodic_tx_ptrn_cmd_tlv,
22587 .send_process_del_periodic_tx_ptrn_cmd =
22588 send_process_del_periodic_tx_ptrn_cmd_tlv,
22589 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
22590 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
22591 .send_set_app_type2_params_in_fw_cmd =
22592 send_set_app_type2_params_in_fw_cmd_tlv,
22593 .send_set_auto_shutdown_timer_cmd =
22594 send_set_auto_shutdown_timer_cmd_tlv,
22595 .send_nan_req_cmd = send_nan_req_cmd_tlv,
22596 .send_process_dhcpserver_offload_cmd =
22597 send_process_dhcpserver_offload_cmd_tlv,
22598 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
22599 .send_process_ch_avoid_update_cmd =
22600 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053022601 .send_pdev_set_regdomain_cmd =
22602 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022603 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
22604 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
22605 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
22606 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053022607 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053022608 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022609 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053022610 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022611 .send_set_base_macaddr_indicate_cmd =
22612 send_set_base_macaddr_indicate_cmd_tlv,
22613 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
22614 .send_enable_specific_fw_logs_cmd =
22615 send_enable_specific_fw_logs_cmd_tlv,
22616 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053022617 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053022618 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053022619 .send_pdev_set_dual_mac_config_cmd =
22620 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022621 .send_app_type1_params_in_fw_cmd =
22622 send_app_type1_params_in_fw_cmd_tlv,
22623 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
22624 .send_process_roam_synch_complete_cmd =
22625 send_process_roam_synch_complete_cmd_tlv,
22626 .send_unit_test_cmd = send_unit_test_cmd_tlv,
22627 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
22628 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053022629 .send_roam_scan_offload_scan_period_cmd =
22630 send_roam_scan_offload_scan_period_cmd_tlv,
22631 .send_roam_scan_offload_chan_list_cmd =
22632 send_roam_scan_offload_chan_list_cmd_tlv,
22633 .send_roam_scan_offload_rssi_change_cmd =
22634 send_roam_scan_offload_rssi_change_cmd_tlv,
22635 .send_get_buf_extscan_hotlist_cmd =
22636 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080022637 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053022638 .send_adapt_dwelltime_params_cmd =
22639 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053022640 .send_dbs_scan_sel_params_cmd =
22641 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022642 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022643 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
22644 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
22645 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
22646 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
22647 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
22648 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053022649 .send_vdev_set_custom_aggr_size_cmd =
22650 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053022651 .send_vdev_set_qdepth_thresh_cmd =
22652 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053022653 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
22654 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
22655 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053022656 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
22657 .send_smart_ant_set_training_info_cmd =
22658 send_smart_ant_set_training_info_cmd_tlv,
22659 .send_smart_ant_set_node_config_cmd =
22660 send_smart_ant_set_node_config_cmd_tlv,
22661 .send_set_atf_cmd = send_set_atf_cmd_tlv,
22662 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
22663 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022664 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
22665 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
22666 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
22667 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022668 .send_periodic_chan_stats_config_cmd =
22669 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053022670 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
22671 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
22672 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022673 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
22674 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
22675 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
22676 .send_vdev_spectral_configure_cmd =
22677 send_vdev_spectral_configure_cmd_tlv,
22678 .send_vdev_spectral_enable_cmd =
22679 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022680 .send_thermal_mitigation_param_cmd =
22681 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053022682 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
22683 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053022684 .send_process_update_edca_param_cmd =
22685 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053022686 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022687 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022688 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022689 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22690 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022691 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022692 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22693 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22694 .extract_host_mem_req = extract_host_mem_req_tlv,
22695 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022696 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022697 .is_service_enabled = is_service_enabled_tlv,
22698 .save_fw_version = save_fw_version_in_service_ready_tlv,
22699 .ready_extract_init_status = ready_extract_init_status_tlv,
22700 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022701 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022702 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022703 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22704 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022705 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022706 .extract_tbttoffset_update_params =
22707 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022708 .extract_ext_tbttoffset_update_params =
22709 extract_ext_tbttoffset_update_params_tlv,
22710 .extract_tbttoffset_num_vdevs =
22711 extract_tbttoffset_num_vdevs_tlv,
22712 .extract_ext_tbttoffset_num_vdevs =
22713 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022714 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22715 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22716 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22717 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022718#ifdef CONVERGED_TDLS_ENABLE
22719 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22720#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022721 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022722 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022723 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22724 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022725#ifdef CONVERGED_P2P_ENABLE
22726 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22727 .extract_p2p_lo_stop_ev_param =
22728 extract_p2p_lo_stop_ev_param_tlv,
22729#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022730 .extract_offchan_data_tx_compl_param =
22731 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022732 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22733 .extract_all_stats_count = extract_all_stats_counts_tlv,
22734 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022735 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022736 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22737 .extract_vdev_stats = extract_vdev_stats_tlv,
22738 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022739 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022740 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22741 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22742 .extract_chan_stats = extract_chan_stats_tlv,
22743 .extract_profile_ctx = extract_profile_ctx_tlv,
22744 .extract_profile_data = extract_profile_data_tlv,
22745 .extract_chan_info_event = extract_chan_info_event_tlv,
22746 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022747 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022748#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022749 .send_encrypt_decrypt_send_cmd =
22750 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022751 .extract_encrypt_decrypt_resp_event =
22752 extract_encrypt_decrypt_resp_event_tlv,
22753#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022754 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022755 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22756 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022757 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022758 .send_multiple_vdev_restart_req_cmd =
22759 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022760 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22761 .extract_hw_mode_cap_service_ready_ext =
22762 extract_hw_mode_cap_service_ready_ext_tlv,
22763 .extract_mac_phy_cap_service_ready_ext =
22764 extract_mac_phy_cap_service_ready_ext_tlv,
22765 .extract_reg_cap_service_ready_ext =
22766 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022767 .extract_dbr_ring_cap_service_ready_ext =
22768 extract_dbr_ring_cap_service_ready_ext_tlv,
22769 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22770 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022771 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022772 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022773 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022774 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22775 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22776 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022777 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022778 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022779 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022780 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022781 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022782 .extract_pdev_csa_switch_count_status =
22783 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022784 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022785 .extract_pdev_tpc_config_ev_param =
22786 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022787 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022788 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22789 .extract_peer_sta_ps_statechange_ev =
22790 extract_peer_sta_ps_statechange_ev_tlv,
22791 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022792 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080022793 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22794 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022795 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022796 extract_reg_chan_list_update_event_tlv,
22797 .extract_chainmask_tables =
22798 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022799 .extract_thermal_stats = extract_thermal_stats_tlv,
22800 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022801 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22802 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022803#ifdef DFS_COMPONENT_ENABLE
22804 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22805 .extract_dfs_radar_detection_event =
22806 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022807 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022808#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022809 .convert_pdev_id_host_to_target =
22810 convert_host_pdev_id_to_target_pdev_id_legacy,
22811 .convert_pdev_id_target_to_host =
22812 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022813
22814 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22815 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22816 .extract_reg_11d_new_country_event =
22817 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022818 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022819 .send_limit_off_chan_cmd =
22820 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022821 .extract_reg_ch_avoid_event =
22822 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022823 .send_pdev_caldata_version_check_cmd =
22824 send_pdev_caldata_version_check_cmd_tlv,
22825 .extract_pdev_caldata_version_check_ev_param =
22826 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022827 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22828 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022829 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22830#if defined(WLAN_FEATURE_FILS_SK)
22831 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22832#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022833 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022834#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22835 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22836 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22837 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22838 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22839 .extract_ndp_ind = extract_ndp_ind_tlv,
22840 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22841 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22842 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22843 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
22844#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022845 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022846 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022847 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022848#ifdef WLAN_SUPPORT_FILS
22849 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22850 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22851 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22852#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022853 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22854 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022855 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22856 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22857 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22858 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022859 .send_bss_color_change_enable_cmd =
22860 send_bss_color_change_enable_cmd_tlv,
22861 .send_obss_color_collision_cfg_cmd =
22862 send_obss_color_collision_cfg_cmd_tlv,
22863 .extract_obss_color_collision_info =
22864 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022865 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22866 .extract_single_phyerr = extract_single_phyerr_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053022867};
22868
Govind Singhe7f2f342016-05-23 12:12:52 +053022869/**
22870 * populate_tlv_event_id() - populates wmi event ids
22871 *
22872 * @param event_ids: Pointer to hold event ids
22873 * Return: None
22874 */
22875static void populate_tlv_events_id(uint32_t *event_ids)
22876{
22877 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22878 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22879 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22880 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22881 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22882 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22883 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22884 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22885 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22886 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22887 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22888 event_ids[wmi_service_ready_ext_event_id] =
22889 WMI_SERVICE_READY_EXT_EVENTID;
22890 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22891 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22892 event_ids[wmi_vdev_install_key_complete_event_id] =
22893 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22894 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22895 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22896
22897 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22898 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22899 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22900 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22901 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22902 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22903 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22904 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022905 event_ids[wmi_peer_delete_response_event_id] =
22906 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022907 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22908 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22909 event_ids[wmi_tbttoffset_update_event_id] =
22910 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022911 event_ids[wmi_ext_tbttoffset_update_event_id] =
22912 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022913 event_ids[wmi_offload_bcn_tx_status_event_id] =
22914 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22915 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22916 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22917 event_ids[wmi_mgmt_tx_completion_event_id] =
22918 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022919 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22920 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022921 event_ids[wmi_tx_delba_complete_event_id] =
22922 WMI_TX_DELBA_COMPLETE_EVENTID;
22923 event_ids[wmi_tx_addba_complete_event_id] =
22924 WMI_TX_ADDBA_COMPLETE_EVENTID;
22925 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22926
22927 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22928
22929 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22930 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22931
22932 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022933 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022934
22935 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22936
22937 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022938 event_ids[wmi_p2p_lo_stop_event_id] =
22939 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022940 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22941 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022942 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022943 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22944 event_ids[wmi_wow_initial_wakeup_event_id] =
22945 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22946
22947 event_ids[wmi_rtt_meas_report_event_id] =
22948 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22949 event_ids[wmi_tsf_meas_report_event_id] =
22950 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22951 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22952 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22953 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22954 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22955 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022956 event_ids[wmi_diag_event_id_log_supported_event_id] =
22957 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22958 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22959 event_ids[wmi_nlo_scan_complete_event_id] =
22960 WMI_NLO_SCAN_COMPLETE_EVENTID;
22961 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22962 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22963
22964 event_ids[wmi_gtk_offload_status_event_id] =
22965 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22966 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22967 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22968 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22969
22970 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22971
22972 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22973
22974 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22975 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22976 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22977 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22978 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22979 event_ids[wmi_wlan_profile_data_event_id] =
22980 WMI_WLAN_PROFILE_DATA_EVENTID;
22981 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22982 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22983 event_ids[wmi_vdev_get_keepalive_event_id] =
22984 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22985 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22986
22987 event_ids[wmi_diag_container_event_id] =
22988 WMI_DIAG_DATA_CONTAINER_EVENTID;
22989
22990 event_ids[wmi_host_auto_shutdown_event_id] =
22991 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22992
22993 event_ids[wmi_update_whal_mib_stats_event_id] =
22994 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22995
22996 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22997 event_ids[wmi_update_vdev_rate_stats_event_id] =
22998 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22999
23000 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070023001 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023002
23003 /** Set OCB Sched Response, deprecated */
23004 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
23005
23006 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
23007 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
23008 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
23009
23010 /* GPIO Event */
23011 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
23012 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
23013
23014 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
23015 event_ids[wmi_rfkill_state_change_event_id] =
23016 WMI_RFKILL_STATE_CHANGE_EVENTID;
23017
23018 /* TDLS Event */
23019 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
23020
23021 event_ids[wmi_batch_scan_enabled_event_id] =
23022 WMI_BATCH_SCAN_ENABLED_EVENTID;
23023 event_ids[wmi_batch_scan_result_event_id] =
23024 WMI_BATCH_SCAN_RESULT_EVENTID;
23025 /* OEM Event */
23026 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
23027 event_ids[wmi_oem_meas_report_event_id] =
23028 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
23029 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
23030
23031 /* NAN Event */
23032 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
23033
23034 /* LPI Event */
23035 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
23036 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
23037 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
23038
23039 /* ExtScan events */
23040 event_ids[wmi_extscan_start_stop_event_id] =
23041 WMI_EXTSCAN_START_STOP_EVENTID;
23042 event_ids[wmi_extscan_operation_event_id] =
23043 WMI_EXTSCAN_OPERATION_EVENTID;
23044 event_ids[wmi_extscan_table_usage_event_id] =
23045 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
23046 event_ids[wmi_extscan_cached_results_event_id] =
23047 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
23048 event_ids[wmi_extscan_wlan_change_results_event_id] =
23049 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
23050 event_ids[wmi_extscan_hotlist_match_event_id] =
23051 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
23052 event_ids[wmi_extscan_capabilities_event_id] =
23053 WMI_EXTSCAN_CAPABILITIES_EVENTID;
23054 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
23055 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
23056
23057 /* mDNS offload events */
23058 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
23059
23060 /* SAP Authentication offload events */
23061 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
23062 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
23063
23064 /** Out-of-context-of-bss (OCB) events */
23065 event_ids[wmi_ocb_set_config_resp_event_id] =
23066 WMI_OCB_SET_CONFIG_RESP_EVENTID;
23067 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
23068 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
23069 event_ids[wmi_dcc_get_stats_resp_event_id] =
23070 WMI_DCC_GET_STATS_RESP_EVENTID;
23071 event_ids[wmi_dcc_update_ndl_resp_event_id] =
23072 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
23073 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
23074 /* System-On-Chip events */
23075 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
23076 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
23077 event_ids[wmi_soc_hw_mode_transition_event_id] =
23078 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
23079 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
23080 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053023081 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053023082 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
23083 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053023084 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053023085 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
23086 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
23087 event_ids[wmi_peer_sta_ps_statechg_event_id] =
23088 WMI_PEER_STA_PS_STATECHG_EVENTID;
23089 event_ids[wmi_pdev_channel_hopping_event_id] =
23090 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053023091 event_ids[wmi_offchan_data_tx_completion_event] =
23092 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070023093 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
23094 event_ids[wmi_dfs_radar_detection_event_id] =
23095 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053023096 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070023097 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053023098 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053023099 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053023100 event_ids[wmi_service_available_event_id] =
23101 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053023102 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053023103 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053023104 /* NDP events */
23105 event_ids[wmi_ndp_initiator_rsp_event_id] =
23106 WMI_NDP_INITIATOR_RSP_EVENTID;
23107 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
23108 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
23109 event_ids[wmi_ndp_responder_rsp_event_id] =
23110 WMI_NDP_RESPONDER_RSP_EVENTID;
23111 event_ids[wmi_ndp_end_indication_event_id] =
23112 WMI_NDP_END_INDICATION_EVENTID;
23113 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
23114
23115 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
23116 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
23117 event_ids[wmi_pdev_chip_power_stats_event_id] =
23118 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
23119 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
23120 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
23121 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
23122 event_ids[wmi_bpf_capability_info_event_id] =
23123 WMI_BPF_CAPABILIY_INFO_EVENTID;
23124 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
23125 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
23126 event_ids[wmi_report_rx_aggr_failure_event_id] =
23127 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
23128 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
23129 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
23130 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
23131 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
23132 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
23133 event_ids[wmi_pdev_hw_mode_transition_event_id] =
23134 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
23135 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
23136 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
23137 event_ids[wmi_coex_bt_activity_event_id] =
23138 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
23139 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
23140 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
23141 event_ids[wmi_radio_tx_power_level_stats_event_id] =
23142 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
23143 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053023144 event_ids[wmi_dma_buf_release_event_id] =
23145 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080023146 event_ids[wmi_sap_obss_detection_report_event_id] =
23147 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053023148 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080023149 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080023150 event_ids[wmi_obss_color_collision_report_event_id] =
23151 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080023152 event_ids[wmi_pdev_div_rssi_antid_event_id] =
23153 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023154}
23155
Soumya Bhat488092d2017-03-22 14:41:01 +053023156/**
23157 * populate_tlv_service() - populates wmi services
23158 *
23159 * @param wmi_service: Pointer to hold wmi_service
23160 * Return: None
23161 */
23162static void populate_tlv_service(uint32_t *wmi_service)
23163{
23164 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023165 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023166 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
23167 wmi_service[wmi_service_roam_scan_offload] =
23168 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
23169 wmi_service[wmi_service_bcn_miss_offload] =
23170 WMI_SERVICE_BCN_MISS_OFFLOAD;
23171 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
23172 wmi_service[wmi_service_sta_advanced_pwrsave] =
23173 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
23174 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
23175 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
23176 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
23177 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
23178 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
23179 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
23180 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
23181 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
23182 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
23183 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
23184 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
23185 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
23186 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
23187 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
23188 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
23189 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
23190 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
23191 wmi_service[wmi_service_packet_power_save] =
23192 WMI_SERVICE_PACKET_POWER_SAVE;
23193 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
23194 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
23195 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
23196 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
23197 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
23198 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
23199 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
23200 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
23201 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
23202 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
23203 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
23204 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
23205 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
23206 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
23207 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
23208 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
23209 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
23210 wmi_service[wmi_service_mcc_bcn_interval_change] =
23211 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
23212 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
23213 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
23214 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
23215 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
23216 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
23217 wmi_service[wmi_service_lte_ant_share_support] =
23218 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
23219 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
23220 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
23221 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
23222 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
23223 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
23224 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
23225 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
23226 wmi_service[wmi_service_bcn_txrate_override] =
23227 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
23228 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
23229 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
23230 wmi_service[wmi_service_estimate_linkspeed] =
23231 WMI_SERVICE_ESTIMATE_LINKSPEED;
23232 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
23233 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
23234 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
23235 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
23236 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
23237 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
23238 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
23239 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
23240 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
23241 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
23242 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
23243 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
23244 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
23245 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
23246 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
23247 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
23248 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
23249 wmi_service[wmi_service_sap_auth_offload] =
23250 WMI_SERVICE_SAP_AUTH_OFFLOAD;
23251 wmi_service[wmi_service_dual_band_simultaneous_support] =
23252 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
23253 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
23254 wmi_service[wmi_service_ap_arpns_offload] =
23255 WMI_SERVICE_AP_ARPNS_OFFLOAD;
23256 wmi_service[wmi_service_per_band_chainmask_support] =
23257 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
23258 wmi_service[wmi_service_packet_filter_offload] =
23259 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
23260 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
23261 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
23262 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
23263 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
23264 wmi_service[wmi_service_multiple_vdev_restart] =
23265 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
23266
23267 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
23268 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
23269 wmi_service[wmi_service_smart_antenna_sw_support] =
23270 WMI_SERVICE_UNAVAILABLE;
23271 wmi_service[wmi_service_smart_antenna_hw_support] =
23272 WMI_SERVICE_UNAVAILABLE;
23273 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053023274 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023275 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053023276 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
23277 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
23278 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
23279 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
23280 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
23281 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
23282 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
23283 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053023284 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
23285 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
23286 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053023287 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053023288 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
23289 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
23290 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
23291 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
23292 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
23293 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053023294 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
23295 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
23296 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
23297 wmi_service[wmi_service_unified_wow_capability] =
23298 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
23299 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
23300 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
23301 wmi_service[wmi_service_sync_delete_cmds] =
23302 WMI_SERVICE_SYNC_DELETE_CMDS;
23303 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
23304 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
23305 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
23306 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
23307 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
23308 wmi_service[wmi_service_deprecated_replace] =
23309 WMI_SERVICE_DEPRECATED_REPLACE;
23310 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
23311 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
23312 wmi_service[wmi_service_enhanced_mcast_filter] =
23313 WMI_SERVICE_ENHANCED_MCAST_FILTER;
23314 wmi_service[wmi_service_half_rate_quarter_rate_support] =
23315 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
23316 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
23317 wmi_service[wmi_service_p2p_listen_offload_support] =
23318 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
23319 wmi_service[wmi_service_mark_first_wakeup_packet] =
23320 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
23321 wmi_service[wmi_service_multiple_mcast_filter_set] =
23322 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
23323 wmi_service[wmi_service_host_managed_rx_reorder] =
23324 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
23325 wmi_service[wmi_service_flash_rdwr_support] =
23326 WMI_SERVICE_FLASH_RDWR_SUPPORT;
23327 wmi_service[wmi_service_wlan_stats_report] =
23328 WMI_SERVICE_WLAN_STATS_REPORT;
23329 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
23330 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
23331 wmi_service[wmi_service_dfs_phyerr_offload] =
23332 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
23333 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
23334 wmi_service[wmi_service_fw_mem_dump_support] =
23335 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
23336 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
23337 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
23338 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
23339 wmi_service[wmi_service_hw_data_filtering] =
23340 WMI_SERVICE_HW_DATA_FILTERING;
23341 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
23342 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053023343 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053023344 wmi_service[wmi_service_extended_nss_support] =
23345 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053023346 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053023347 wmi_service[wmi_service_bcn_offload_start_stop_support] =
23348 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053023349 wmi_service[wmi_service_offchan_data_tid_support] =
23350 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053023351 wmi_service[wmi_service_support_dma] =
23352 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023353 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
23354 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
23355 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053023356 wmi_service[wmi_service_11k_neighbour_report_support] =
23357 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080023358 wmi_service[wmi_service_ap_obss_detection_offload] =
23359 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
23360 wmi_service[wmi_service_bss_color_offload] =
23361 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053023362 wmi_service[wmi_service_gmac_offload_support] =
23363 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023364
Soumya Bhat488092d2017-03-22 14:41:01 +053023365}
23366
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023367#ifndef CONFIG_MCL
23368
Govind Singhe7f2f342016-05-23 12:12:52 +053023369/**
23370 * populate_pdev_param_tlv() - populates pdev params
23371 *
23372 * @param pdev_param: Pointer to hold pdev params
23373 * Return: None
23374 */
23375static void populate_pdev_param_tlv(uint32_t *pdev_param)
23376{
23377 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
23378 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
23379 pdev_param[wmi_pdev_param_txpower_limit2g] =
23380 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
23381 pdev_param[wmi_pdev_param_txpower_limit5g] =
23382 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
23383 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
23384 pdev_param[wmi_pdev_param_beacon_gen_mode] =
23385 WMI_PDEV_PARAM_BEACON_GEN_MODE;
23386 pdev_param[wmi_pdev_param_beacon_tx_mode] =
23387 WMI_PDEV_PARAM_BEACON_TX_MODE;
23388 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
23389 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
23390 pdev_param[wmi_pdev_param_protection_mode] =
23391 WMI_PDEV_PARAM_PROTECTION_MODE;
23392 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
23393 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
23394 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
23395 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
23396 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
23397 pdev_param[wmi_pdev_param_sta_kickout_th] =
23398 WMI_PDEV_PARAM_STA_KICKOUT_TH;
23399 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
23400 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
23401 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
23402 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
23403 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
23404 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
23405 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
23406 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
23407 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
23408 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
23409 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
23410 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
23411 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
23412 pdev_param[wmi_pdev_param_ltr_sleep_override] =
23413 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
23414 pdev_param[wmi_pdev_param_ltr_rx_override] =
23415 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
23416 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
23417 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
23418 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
23419 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
23420 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
23421 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
23422 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
23423 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
23424 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
23425 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
23426 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
23427 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
23428 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
23429 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
23430 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
23431 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
23432 pdev_param[wmi_pdev_param_peer_stats_update_period] =
23433 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
23434 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
23435 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
23436 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
23437 pdev_param[wmi_pdev_param_arp_ac_override] =
23438 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
23439 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
23440 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
23441 pdev_param[wmi_pdev_param_ani_poll_period] =
23442 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
23443 pdev_param[wmi_pdev_param_ani_listen_period] =
23444 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
23445 pdev_param[wmi_pdev_param_ani_ofdm_level] =
23446 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
23447 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
23448 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
23449 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
23450 pdev_param[wmi_pdev_param_idle_ps_config] =
23451 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
23452 pdev_param[wmi_pdev_param_power_gating_sleep] =
23453 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
23454 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
23455 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
23456 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
23457 pdev_param[wmi_pdev_param_hw_rfkill_config] =
23458 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
23459 pdev_param[wmi_pdev_param_low_power_rf_enable] =
23460 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
23461 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
23462 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
23463 pdev_param[wmi_pdev_param_power_collapse_enable] =
23464 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
23465 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
23466 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
23467 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
23468 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
23469 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
23470 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
23471 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
23472 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
23473 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
23474 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
23475 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
23476 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
23477 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
23478 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
23479 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
23480 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
23481 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
23482 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
23483 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
23484 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
23485 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
23486 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
23487 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
23488 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
23489 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
23490 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
23491 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
23492 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
23493 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
23494 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
23495 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
23496 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
23497 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
23498 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
23499 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
23500 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
23501 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
23502 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
23503 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
23504 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
23505 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
23506 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
23507 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
23508 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023509 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
23510 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
23511 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053023512 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
23513 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023514 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053023515 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023516 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
23517 pdev_param[wmi_pdev_param_proxy_sta_mode] =
23518 WMI_PDEV_PARAM_PROXY_STA_MODE;
23519 pdev_param[wmi_pdev_param_mu_group_policy] =
23520 WMI_PDEV_PARAM_MU_GROUP_POLICY;
23521 pdev_param[wmi_pdev_param_noise_detection] =
23522 WMI_PDEV_PARAM_NOISE_DETECTION;
23523 pdev_param[wmi_pdev_param_noise_threshold] =
23524 WMI_PDEV_PARAM_NOISE_THRESHOLD;
23525 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
23526 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
23527 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023528 pdev_param[wmi_pdev_param_atf_strict_sch] =
23529 WMI_PDEV_PARAM_ATF_STRICT_SCH;
23530 pdev_param[wmi_pdev_param_atf_sched_duration] =
23531 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023532 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
23533 pdev_param[wmi_pdev_param_sensitivity_level] =
23534 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
23535 pdev_param[wmi_pdev_param_signed_txpower_2g] =
23536 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
23537 pdev_param[wmi_pdev_param_signed_txpower_5g] =
23538 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070023539 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
23540 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
23541 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
23542 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023543 pdev_param[wmi_pdev_param_cca_threshold] =
23544 WMI_PDEV_PARAM_CCA_THRESHOLD;
23545 pdev_param[wmi_pdev_param_rts_fixed_rate] =
23546 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023547 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023548 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
23549 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
23550 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
23551 pdev_param[wmi_pdev_param_arp_srcaddr] =
23552 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
23553 pdev_param[wmi_pdev_param_arp_dstaddr] =
23554 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
23555 pdev_param[wmi_pdev_param_txpower_decr_db] =
23556 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053023557 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
23558 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023559 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
23560 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053023561 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023562 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023563 pdev_param[wmi_pdev_param_cust_txpower_scale] =
23564 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053023565 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
23566 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023567 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
23568 WMI_UNAVAILABLE_PARAM;
23569 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
23570 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023571 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
23572 pdev_param[wmi_pdev_param_block_interbss] =
23573 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053023574 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023575 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
23576 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
23577 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053023578 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053023579 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023580 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
23581 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053023582 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053023583 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
23584 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053023585 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
23586 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
23587 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
23588 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
23589 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
23590 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
23591 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
23592 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
23593 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
23594 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
23595 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
23596 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
23597 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
23598 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
23599 pdev_param[wmi_pdev_param_fast_channel_reset] =
23600 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
23601 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053023602 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053023603 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053023604}
23605
23606/**
23607 * populate_vdev_param_tlv() - populates vdev params
23608 *
23609 * @param vdev_param: Pointer to hold vdev params
23610 * Return: None
23611 */
23612static void populate_vdev_param_tlv(uint32_t *vdev_param)
23613{
23614 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
23615 vdev_param[wmi_vdev_param_fragmentation_threshold] =
23616 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
23617 vdev_param[wmi_vdev_param_beacon_interval] =
23618 WMI_VDEV_PARAM_BEACON_INTERVAL;
23619 vdev_param[wmi_vdev_param_listen_interval] =
23620 WMI_VDEV_PARAM_LISTEN_INTERVAL;
23621 vdev_param[wmi_vdev_param_multicast_rate] =
23622 WMI_VDEV_PARAM_MULTICAST_RATE;
23623 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
23624 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
23625 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
23626 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
23627 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
23628 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
23629 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
23630 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
23631 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
23632 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
23633 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
23634 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
23635 vdev_param[wmi_vdev_param_bmiss_count_max] =
23636 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
23637 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
23638 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
23639 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
23640 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
23641 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
23642 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
23643 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
23644 vdev_param[wmi_vdev_param_disable_htprotection] =
23645 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
23646 vdev_param[wmi_vdev_param_sta_quickkickout] =
23647 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
23648 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
23649 vdev_param[wmi_vdev_param_protection_mode] =
23650 WMI_VDEV_PARAM_PROTECTION_MODE;
23651 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
23652 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
23653 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
23654 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
23655 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
23656 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
23657 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
23658 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
23659 vdev_param[wmi_vdev_param_bcast_data_rate] =
23660 WMI_VDEV_PARAM_BCAST_DATA_RATE;
23661 vdev_param[wmi_vdev_param_mcast_data_rate] =
23662 WMI_VDEV_PARAM_MCAST_DATA_RATE;
23663 vdev_param[wmi_vdev_param_mcast_indicate] =
23664 WMI_VDEV_PARAM_MCAST_INDICATE;
23665 vdev_param[wmi_vdev_param_dhcp_indicate] =
23666 WMI_VDEV_PARAM_DHCP_INDICATE;
23667 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23668 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23669 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23670 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23671 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23672 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23673 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23674 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23675 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23676 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23677 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23678 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23679 vdev_param[wmi_vdev_param_packet_powersave] =
23680 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23681 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23682 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23683 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23684 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23685 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23686 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23687 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23688 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23689 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23690 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23691 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23692 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23693 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23694 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23695 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23696 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23697 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23698 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23699 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23700 vdev_param[wmi_vdev_param_roam_fw_offload] =
23701 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23702 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23703 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23704 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23705 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23706 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23707 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23708 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23709 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23710 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23711 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23712 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23713 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23714 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23715 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23716 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23717 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23718 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23719 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23720 vdev_param[wmi_vdev_param_inactivity_cnt] =
23721 WMI_VDEV_PARAM_INACTIVITY_CNT;
23722 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23723 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23724 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23725 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23726 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23727 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23728 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23729 vdev_param[wmi_vdev_param_rx_leak_window] =
23730 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23731 vdev_param[wmi_vdev_param_stats_avg_factor] =
23732 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23733 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23734 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23735 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23736 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23737 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23738 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023739 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23740 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023741 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023742 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23743 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23744 WMI_VDEV_PARAM_HE_RANGE_EXT;
23745 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23746 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023747 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023748 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23749 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23750 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23751 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23752 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23753 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23754 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023755 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23756 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23757 vdev_param[wmi_vdev_param_rc_num_retries] =
23758 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23759 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23760 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23761 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23762 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23763 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23764 vdev_param[wmi_vdev_param_vht80_ratemask] =
23765 WMI_VDEV_PARAM_VHT80_RATEMASK;
23766 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23767 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23768 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023769 vdev_param[wmi_vdev_param_set_he_ltf] =
23770 WMI_VDEV_PARAM_HE_LTF;
Sathish Kumar6011c742017-11-08 14:49:58 +053023771 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23772 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023773 vdev_param[wmi_vdev_param_set_ba_mode] =
23774 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023775 vdev_param[wmi_vdev_param_capabilities] =
23776 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023777 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23778 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023779}
23780#endif
23781
Govind Singh5eb51532016-03-09 11:34:12 +053023782/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023783 * populate_target_defines_tlv() - Populate target defines and params
23784 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023785 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023786 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023787 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023788#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023789static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023790{
Govind Singhe7f2f342016-05-23 12:12:52 +053023791 populate_pdev_param_tlv(wmi_handle->pdev_param);
23792 populate_vdev_param_tlv(wmi_handle->vdev_param);
23793}
23794#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023795static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23796{ }
23797#endif
23798
23799/**
Zhang Qian537fca62018-01-03 16:33:24 +080023800 * wmi_ocb_ut_attach() - Attach OCB test framework
23801 * @wmi_handle: wmi handle
23802 *
23803 * Return: None
23804 */
23805#ifdef WLAN_OCB_UT
23806void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23807#else
23808static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23809{
23810 return;
23811}
23812#endif
23813
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023814#ifdef WLAN_SUPPORT_TWT
23815void wmi_twt_attach_tlv(struct wmi_unified *wmi_handle);
23816#else
23817static void wmi_twt_attach_tlv(struct wmi_unified *wmi_handle)
23818{
23819 return;
23820}
23821#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023822/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023823 * wmi_tlv_attach() - Attach TLV APIs
23824 *
23825 * Return: None
23826 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023827void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023828{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023829 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023830 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023831 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023832#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023833 /* Skip saving WMI_CMD_HDR and TLV HDR */
23834 wmi_handle->log_info.buf_offset_command = 8;
23835 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023836 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023837#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023838 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023839 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023840 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023841 wmi_twt_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023842}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023843qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023844
23845/**
23846 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23847 *
23848 * Return: None
23849 */
23850void wmi_tlv_init(void)
23851{
23852 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23853}